From: lurchi Date: Sat, 8 Jul 2017 19:50:20 +0000 (+0200) Subject: implement GNUNET_h2s2 for printing two hashes in one log output line X-Git-Tag: gnunet-0.11.0rc0~195 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=cdf3b6745f83502a6fd246cb92a225f09bc4de0d;p=oweals%2Fgnunet.git implement GNUNET_h2s2 for printing two hashes in one log output line --- 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).