diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-22 12:21:24 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-22 12:21:24 +0100 |
commit | 02132e8fc311b966154fd5d9f0b3686ea8c2bf86 (patch) | |
tree | 2917a9efadd6c66432b21c88131691c0ca38424a | |
parent | 0e6da3245dec82dd5f3a0f1cd3f3505bf454422d (diff) | |
download | gnunet-02132e8fc311b966154fd5d9f0b3686ea8c2bf86.tar.gz gnunet-02132e8fc311b966154fd5d9f0b3686ea8c2bf86.zip |
introcude GNUNET_i2s2()
-rw-r--r-- | src/include/gnunet_common.h | 16 | ||||
-rw-r--r-- | src/util/common_logging.c | 25 |
2 files changed, 41 insertions, 0 deletions
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 | |||
@@ -614,6 +614,22 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid); | |||
614 | * @ingroup logging | 614 | * @ingroup logging |
615 | * Convert a peer identity to a string (for printing debug messages). | 615 | * Convert a peer identity to a string (for printing debug messages). |
616 | * This is one of the very few calls in the entire API that is | 616 | * This is one of the very few calls in the entire API that is |
617 | * NOT reentrant! Identical to #GNUNET_i2s(), except that another | ||
618 | * buffer is used so both #GNUNET_i2s() and #GNUNET_i2s2() can be | ||
619 | * used within the same log statement. | ||
620 | * | ||
621 | * @param pid the peer identity | ||
622 | * @return string form of the pid; will be overwritten by next | ||
623 | * call to #GNUNET_i2s(). | ||
624 | */ | ||
625 | const char * | ||
626 | GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid); | ||
627 | |||
628 | |||
629 | /** | ||
630 | * @ingroup logging | ||
631 | * Convert a peer identity to a string (for printing debug messages). | ||
632 | * This is one of the very few calls in the entire API that is | ||
617 | * NOT reentrant! | 633 | * NOT reentrant! |
618 | * | 634 | * |
619 | * @param pid the peer identity | 635 | * @param pid the peer identity |
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 | |||
@@ -1220,6 +1220,31 @@ GNUNET_i2s (const struct GNUNET_PeerIdentity *pid) | |||
1220 | /** | 1220 | /** |
1221 | * Convert a peer identity to a string (for printing debug messages). | 1221 | * Convert a peer identity to a string (for printing debug messages). |
1222 | * This is one of the very few calls in the entire API that is | 1222 | * This is one of the very few calls in the entire API that is |
1223 | * NOT reentrant! Identical to #GNUNET_i2s(), except that another | ||
1224 | * buffer is used so both #GNUNET_i2s() and #GNUNET_i2s2() can be | ||
1225 | * used within the same log statement. | ||
1226 | * | ||
1227 | * @param pid the peer identity | ||
1228 | * @return string form of the pid; will be overwritten by next | ||
1229 | * call to #GNUNET_i2s. | ||
1230 | */ | ||
1231 | const char * | ||
1232 | GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid) | ||
1233 | { | ||
1234 | static char buf[256]; | ||
1235 | char *ret; | ||
1236 | |||
1237 | ret = GNUNET_CRYPTO_eddsa_public_key_to_string (&pid->public_key); | ||
1238 | strcpy (buf, ret); | ||
1239 | GNUNET_free (ret); | ||
1240 | buf[4] = '\0'; | ||
1241 | return buf; | ||
1242 | } | ||
1243 | |||
1244 | |||
1245 | /** | ||
1246 | * Convert a peer identity to a string (for printing debug messages). | ||
1247 | * This is one of the very few calls in the entire API that is | ||
1223 | * NOT reentrant! | 1248 | * NOT reentrant! |
1224 | * | 1249 | * |
1225 | * @param pid the peer identity | 1250 | * @param pid the peer identity |