helper function for debugging
This commit is contained in:
parent
8a40432488
commit
3d1627daa7
@ -73,6 +73,30 @@ void
|
|||||||
TALER_gcrypt_init (void);
|
TALER_gcrypt_init (void);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a buffer to an 8-character string
|
||||||
|
* representative of the contents. This is used
|
||||||
|
* for logging binary data when debugging.
|
||||||
|
*
|
||||||
|
* @param buf buffer to log
|
||||||
|
* @param buf_size number of bytes in @a buf
|
||||||
|
* @return text representation of buf, valid until next
|
||||||
|
* call to this function
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
TALER_b2s (const void *buf,
|
||||||
|
size_t buf_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a fixed-sized object to a string using
|
||||||
|
* #TALER_b2s().
|
||||||
|
*
|
||||||
|
* @param obj address of object to convert
|
||||||
|
* @return string representing the binary obj buffer
|
||||||
|
*/
|
||||||
|
#define TALER_B2S(obj) TALER_b2s (obj, sizeof (*obj))
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Round a time value so that it is suitable for transmission
|
* Round a time value so that it is suitable for transmission
|
||||||
* via JSON encodings.
|
* via JSON encodings.
|
||||||
|
@ -27,6 +27,38 @@
|
|||||||
#include <gcrypt.h>
|
#include <gcrypt.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert a buffer to an 8-character string
|
||||||
|
* representative of the contents. This is used
|
||||||
|
* for logging binary data when debugging.
|
||||||
|
*
|
||||||
|
* @param buf buffer to log
|
||||||
|
* @param buf_size number of bytes in @a buf
|
||||||
|
* @return text representation of buf, valid until next
|
||||||
|
* call to this function
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
TALER_b2s (const void *buf,
|
||||||
|
size_t buf_size)
|
||||||
|
{
|
||||||
|
static char ret[9];
|
||||||
|
struct GNUNET_HashCode hc;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
GNUNET_CRYPTO_hash (buf,
|
||||||
|
buf_size,
|
||||||
|
&hc);
|
||||||
|
tmp = GNUNET_STRINGS_data_to_string_alloc (&hc,
|
||||||
|
sizeof (hc));
|
||||||
|
memcpy (ret,
|
||||||
|
tmp,
|
||||||
|
8);
|
||||||
|
GNUNET_free (tmp);
|
||||||
|
ret[8] = '\0';
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain denomination amount from configuration file.
|
* Obtain denomination amount from configuration file.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user