diff options
Diffstat (limited to 'src/util/common_logging.c')
-rw-r--r-- | src/util/common_logging.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index fbc0de50c9..6161d0c6d0 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c @@ -1012,6 +1012,43 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind) /** + * Convert a short hash to a string (for printing debug messages). + * This is one of the very few calls in the entire API that is + * NOT reentrant! + * + * @param hc the short hash code + * @return string form; will be overwritten by next call to GNUNET_h2s. + */ +const char * +GNUNET_short_h2s (const struct GNUNET_CRYPTO_ShortHashCode * hc) +{ + static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret; + + GNUNET_CRYPTO_short_hash_to_enc (hc, &ret); + ret.short_encoding[8] = '\0'; + return (const char *) ret.short_encoding; +} + + +/** + * Convert a short hash to a string (for printing debug messages). + * This is one of the very few calls in the entire API that is + * NOT reentrant! + * + * @param hc the short hash code + * @return string form; will be overwritten by next call to GNUNET_h2s_full. + */ +const char * +GNUNET_short_h2s_full (const struct GNUNET_CRYPTO_ShortHashCode * hc) +{ + static struct GNUNET_CRYPTO_ShortHashAsciiEncoded ret; + + GNUNET_CRYPTO_short_hash_to_enc (hc, &ret); + ret.short_encoding[sizeof (ret) - 1] = '\0'; + return (const char *) ret.short_encoding; +} + +/** * 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! |