From: Volker Lendecke Date: Fri, 3 Feb 2012 02:27:19 +0000 (+0100) Subject: lib/util: Add hex_encode_buf X-Git-Tag: tevent-0.9.15~40 X-Git-Url: http://git.samba.org/samba.git/?p=nivanova%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=a0e44c30e21013f0136ddefc1bbbdc020413e749 lib/util: Add hex_encode_buf Autobuild-User: Volker Lendecke Autobuild-Date: Mon Feb 6 09:15:33 CET 2012 on sn-devel-104 --- diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index 9df3ddfcd0e..5ce2e5e5352 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -261,6 +261,11 @@ _PUBLIC_ size_t strhex_to_str(char *p, size_t p_len, const char *strhex, size_t */ _PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *strhex) ; +/** + * Print a buf in hex. Assumes dst is at least (srclen*2)+1 large. + */ +_PUBLIC_ void hex_encode_buf(char *dst, const uint8_t *src, size_t srclen); + /** * Routine to print a buffer as HEX digits, into an allocated string. */ diff --git a/lib/util/util.c b/lib/util/util.c index c4fbd0b39fc..867da0a3405 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -758,20 +758,31 @@ _PUBLIC_ _PURE_ DATA_BLOB strhex_to_data_blob(TALLOC_CTX *mem_ctx, const char *s return ret_blob; } +/** + * Print a buf in hex. Assumes dst is at least (srclen*2)+1 large. + */ +_PUBLIC_ void hex_encode_buf(char *dst, const uint8_t *src, size_t srclen) +{ + size_t i; + for (i=0; i