From cdf3b6745f83502a6fd246cb92a225f09bc4de0d Mon Sep 17 00:00:00 2001 From: lurchi Date: Sat, 8 Jul 2017 21:50:20 +0200 Subject: [PATCH] implement GNUNET_h2s2 for printing two hashes in one log output line --- src/util/common_logging.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/util/common_logging.c b/src/util/common_logging.c index 34481fe13..33edb9b1a 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -1155,6 +1155,27 @@ GNUNET_h2s (const struct GNUNET_HashCode * hc) } +/** + * Convert a hash to a string (for printing debug messages). + * This is one of the very few calls in the entire API that is + * NOT reentrant! Identical to #GNUNET_h2s(), except that another + * buffer is used so both #GNUNET_h2s() and #GNUNET_i2s2() can be + * used within the same log statement. + * + * @param hc the hash code + * @return string form; will be overwritten by next call to GNUNET_h2s. + */ +const char * +GNUNET_h2s2 (const struct GNUNET_HashCode * hc) +{ + static struct GNUNET_CRYPTO_HashAsciiEncoded ret; + + GNUNET_CRYPTO_hash_to_enc (hc, &ret); + ret.encoding[8] = '\0'; + return (const char *) ret.encoding; +} + + /** * @ingroup logging * Convert a short hash value to a string (for printing debug messages). -- 2.25.1