r4027: add a useful function for debugging
authorStefan Metzmacher <metze@samba.org>
Wed, 1 Dec 2004 16:51:37 +0000 (16:51 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:06:15 +0000 (13:06 -0500)
metze
(This used to be commit 41b1ba53fc201b7b9f9d806dccef6258b2a1d157)

source4/lib/data_blob.c

index c5f15f12710809bae299106ae365b1e305625065..a4506fee4548101afe6797effa5e7a1651bd716d 100644 (file)
@@ -142,3 +142,21 @@ BOOL data_blob_equal(const DATA_BLOB *d1, const DATA_BLOB *d2)
        return False;
 }
 
+/*******************************************************************
+print the data_blob as hex string
+*******************************************************************/
+char *data_blob_hex_string(TALLOC_CTX *mem_ctx, DATA_BLOB *blob)
+{
+       int i;
+       char *hex_string;
+
+       hex_string = talloc_array_p(mem_ctx, char, (blob->length*2)+1);
+       if (!hex_string) {
+               return NULL;
+       }
+
+       for (i = 0; i < blob->length; i++)
+               slprintf(&hex_string[i*2], 3, "%02X", blob->data[i]);
+
+       return hex_string;
+}