mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
Merge data_blob_hex_string from Samba4.
Guenther
This commit is contained in:
parent
fbd99071f9
commit
686d8939d9
@ -156,3 +156,25 @@ DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
|
|||||||
data_blob_clear(&blob);
|
data_blob_clear(&blob);
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
print the data_blob as hex string
|
||||||
|
**/
|
||||||
|
_PUBLIC_ char *data_blob_hex_string(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char *hex_string;
|
||||||
|
|
||||||
|
hex_string = talloc_array(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]);
|
||||||
|
|
||||||
|
hex_string[(blob->length*2)] = '\0';
|
||||||
|
return hex_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user