librpc/ndr: add GUID_hexstring()
authorStefan Metzmacher <metze@samba.org>
Thu, 13 Nov 2008 20:28:02 +0000 (21:28 +0100)
committerStefan Metzmacher <metze@samba.org>
Sun, 16 Nov 2008 15:37:22 +0000 (16:37 +0100)
metze

librpc/ndr/libndr.h
librpc/ndr/uuid.c

index ad94c59e90b357b74561dd10f7bdfc138300b3b5..eafaf688af270a6c2629f77046927ad887888a24 100644 (file)
@@ -519,6 +519,7 @@ bool GUID_all_zero(const struct GUID *u);
 int GUID_compare(const struct GUID *u1, const struct GUID *u2);
 char *GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
 char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid);
+char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid);
 char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid);
 struct GUID GUID_random(void);
 
index bb8c49254de0feba8fe73c4c729cd0619b6f2bcd..aa24ac4494540c4a1f8482f9a8f3e2eb652d087b 100644 (file)
@@ -251,6 +251,31 @@ _PUBLIC_ char *GUID_string2(TALLOC_CTX *mem_ctx, const struct GUID *guid)
        return ret;
 }
 
+_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;
+
+       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)) {
+               talloc_free(tmp_mem);
+               return NULL;
+       }
+
+       ret = data_blob_hex_string(mem_ctx, &guid_blob);
+       talloc_free(tmp_mem);
+       return ret;
+}
+
 _PUBLIC_ char *NS_GUID_string(TALLOC_CTX *mem_ctx, const struct GUID *guid)
 {
        return talloc_asprintf(mem_ctx,