summaryrefslogtreecommitdiff
path: root/librpc/ndr/uuid.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-10 14:29:19 +1100
committerAndrew Tridgell <tridge@samba.org>2009-12-10 17:51:28 +1100
commit3ce800dcbe097f0683cedf7465f0562c7111444a (patch)
tree383c9d1862e9950e1a8f2b5dfda02f39109e0807 /librpc/ndr/uuid.c
parent2493776f59f13ce20a39c0767bdfe85de6b0bdcd (diff)
downloadsamba-3ce800dcbe097f0683cedf7465f0562c7111444a.tar.gz
samba-3ce800dcbe097f0683cedf7465f0562c7111444a.tar.bz2
samba-3ce800dcbe097f0683cedf7465f0562c7111444a.zip
libndr: added a GUID_to_ndr_blob() helper function
This can be used in many places that deal with GUIDs
Diffstat (limited to 'librpc/ndr/uuid.c')
-rw-r--r--librpc/ndr/uuid.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/librpc/ndr/uuid.c b/librpc/ndr/uuid.c
index c3f6a05453..429a1b1ac9 100644
--- a/librpc/ndr/uuid.c
+++ b/librpc/ndr/uuid.c
@@ -25,6 +25,17 @@
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/ndr_misc.h"
+/**
+ build a NDR blob from a GUID
+*/
+_PUBLIC_ NTSTATUS GUID_to_ndr_blob(const struct GUID *guid, TALLOC_CTX *mem_ctx, DATA_BLOB *b)
+{
+ enum ndr_err_code ndr_err;
+ ndr_err = ndr_push_struct_blob(b, mem_ctx, NULL, guid,
+ (ndr_push_flags_fn_t)ndr_push_GUID);
+ return ndr_map_error2ntstatus(ndr_err);
+}
+
/**
build a GUID from a NDR data blob
@@ -280,18 +291,15 @@ _PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
char *ret;
DATA_BLOB guid_blob;
- enum ndr_err_code ndr_err;
TALLOC_CTX *tmp_mem;
+ NTSTATUS status;
tmp_mem = talloc_new(mem_ctx);
if (!tmp_mem) {
return NULL;
}
- ndr_err = ndr_push_struct_blob(&guid_blob, tmp_mem,
- NULL,
- guid,
- (ndr_push_flags_fn_t)ndr_push_GUID);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
+ if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_mem);
return NULL;
}