From: Christian Grothoff Date: Sun, 22 Jan 2017 11:21:24 +0000 (+0100) Subject: introcude GNUNET_i2s2() X-Git-Tag: taler-0.2.1~381 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=02132e8fc311b966154fd5d9f0b3686ea8c2bf86;p=oweals%2Fgnunet.git introcude GNUNET_i2s2() --- diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 9ad604711..fdcae66fa 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h @@ -610,6 +610,22 @@ const char * GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); +/** + * @ingroup logging + * Convert a peer identity 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_i2s(), except that another + * buffer is used so both #GNUNET_i2s() and #GNUNET_i2s2() can be + * used within the same log statement. + * + * @param pid the peer identity + * @return string form of the pid; will be overwritten by next + * call to #GNUNET_i2s(). + */ +const char * +GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); + + /** * @ingroup logging * Convert a peer identity to a string (for printing debug messages). diff --git a/src/util/common_logging.c b/src/util/common_logging.c index ce229826e..dad5d3776 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -1217,6 +1217,31 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) } +/** + * Convert a peer identity 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_i2s(), except that another + * buffer is used so both #GNUNET_i2s() and #GNUNET_i2s2() can be + * used within the same log statement. + * + * @param pid the peer identity + * @return string form of the pid; will be overwritten by next + * call to #GNUNET_i2s. + */ +const char * +GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid) +{ + static char buf[256]; + char *ret; + + ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); + strcpy (buf, ret); + GNUNET_free (ret); + buf[4] = '\0'; + return buf; +} + + /** * Convert a peer identity to a string (for printing debug messages). * This is one of the very few calls in the entire API that is