From 02132e8fc311b966154fd5d9f0b3686ea8c2bf86 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 22 Jan 2017 12:21:24 +0100 Subject: [PATCH] introcude GNUNET_i2s2() --- src/include/gnunet_common.h | 16 ++++++++++++++++ src/util/common_logging.c | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) 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 -- 2.25.1