diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-08-14 22:05:34 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-08-14 22:05:34 +0200 |
commit | 3d1627daa7b62a30b8bb2d201829b1a6034e85be (patch) | |
tree | 0869314f7ccf1cd696a035ed1a6432a034d4379e /src/util/util.c | |
parent | 8a4043248893a7c7cb3b896a0ed24d7611796c98 (diff) |
helper function for debugging
Diffstat (limited to 'src/util/util.c')
-rw-r--r-- | src/util/util.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/util/util.c b/src/util/util.c index f45598b0c..08438cfab 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -28,6 +28,38 @@ /** + * Convert a buffer to an 8-character string + * representative of the contents. This is used + * for logging binary data when debugging. + * + * @param buf buffer to log + * @param buf_size number of bytes in @a buf + * @return text representation of buf, valid until next + * call to this function + */ +const char * +TALER_b2s (const void *buf, + size_t buf_size) +{ + static char ret[9]; + struct GNUNET_HashCode hc; + char *tmp; + + GNUNET_CRYPTO_hash (buf, + buf_size, + &hc); + tmp = GNUNET_STRINGS_data_to_string_alloc (&hc, + sizeof (hc)); + memcpy (ret, + tmp, + 8); + GNUNET_free (tmp); + ret[8] = '\0'; + return ret; +} + + +/** * Obtain denomination amount from configuration file. * * @param cfg configuration to use |