diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-28 20:31:28 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-28 20:31:28 +0100 |
commit | bc8f6e81a4d737625e05e5e268d0d682489873d5 (patch) | |
tree | b706d187c7627c7522ff1ef1eb8663dc11c88d17 | |
parent | 62d3d352502f5b1d109b18456a87c704a70fcca5 (diff) |
move data_to_string_alloc to GNUnet
-rw-r--r-- | src/include/taler_util.h | 24 | ||||
-rw-r--r-- | src/mint/taler-mint-keyup.c | 9 | ||||
-rw-r--r-- | src/util/json.c | 3 | ||||
-rw-r--r-- | src/util/util.c | 30 |
4 files changed, 11 insertions, 55 deletions
diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 5ee90a6cc..00f139286 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h @@ -1,6 +1,6 @@ /* This file is part of TALER - (C) 2014 Christian Grothoff (and other contributing authors) + (C) 2014, 2015 Christian Grothoff (and other contributing authors) TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -13,15 +13,13 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/> */ - /** * @file include/taler_util.h * @brief Interface for common utility functions * @author Sree Harsha Totakura <sreeharsha@totakura.in> */ - -#ifndef UTIL_H_ -#define UTIL_H_ +#ifndef TALER_UTIL_H_ +#define TALER_UTIL_H_ #include <gnunet/gnunet_util_lib.h> #include <gcrypt.h> @@ -234,22 +232,6 @@ TALER_amount_normalize (struct TALER_Amount amount); char * TALER_amount_to_string (struct TALER_Amount amount); -/* ****************** FIXME: move to GNUnet? ************** */ - -/** - * Return the base32crockford encoding of the given buffer. - * - * The returned string will be freshly allocated, and must be free'd - * with #GNUNET_free(). - * - * @param buffer with data - * @param size size of the buffer - * @return freshly allocated, null-terminated string - */ -char * -TALER_data_to_string_alloc (const void *buf, - size_t size); - /* ****************** Coin crypto primitives ************* */ diff --git a/src/mint/taler-mint-keyup.c b/src/mint/taler-mint-keyup.c index 03c66216b..35a4c0410 100644 --- a/src/mint/taler-mint-keyup.c +++ b/src/mint/taler-mint-keyup.c @@ -180,7 +180,8 @@ get_cointype_dir (const struct CoinTypeParams *p) unsigned int i; hash_coin_type (p, &hash); - hash_str = TALER_data_to_string_alloc (&hash, sizeof (struct GNUNET_HashCode)); + hash_str = GNUNET_STRINGS_data_to_string_alloc (&hash, + sizeof (struct GNUNET_HashCode)); GNUNET_assert (HASH_CUTOFF <= strlen (hash_str) + 1); GNUNET_assert (NULL != hash_str); hash_str[HASH_CUTOFF] = 0; @@ -363,7 +364,8 @@ mint_keys_update_signkeys () { struct TALER_MINT_SignKeyIssuePriv signkey_issue; ssize_t nwrite; - printf ("Generating signing key for %s.\n", GNUNET_STRINGS_absolute_time_to_string (anchor)); + printf ("Generating signing key for %s.\n", + GNUNET_STRINGS_absolute_time_to_string (anchor)); create_signkey_issue_priv (anchor, signkey_duration, &signkey_issue); nwrite = GNUNET_DISK_fn_write (skf, &signkey_issue, sizeof (struct TALER_MINT_SignKeyIssue), (GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ)); @@ -498,7 +500,8 @@ mint_keys_update_cointype (const char *coin_alias) struct TALER_MINT_DenomKeyIssuePriv denomkey_issue; int ret; printf ("Generating denomination key for type '%s', start %s.\n", - coin_alias, GNUNET_STRINGS_absolute_time_to_string (p.anchor)); + coin_alias, + GNUNET_STRINGS_absolute_time_to_string (p.anchor)); printf ("Target path: %s\n", dkf); create_denomkey_issue (&p, &denomkey_issue); ret = TALER_MINT_write_denom_key (dkf, &denomkey_issue); diff --git a/src/util/json.c b/src/util/json.c index 120e1be5c..fecf0c5af 100644 --- a/src/util/json.c +++ b/src/util/json.c @@ -133,7 +133,8 @@ TALER_JSON_from_data (const void *data, size_t size) { char *buf; json_t *json; - buf = TALER_data_to_string_alloc (data, size); + + buf = GNUNET_STRINGS_data_to_string_alloc (data, size); json = json_string (buf); GNUNET_free (buf); return json; diff --git a/src/util/util.c b/src/util/util.c index de085d088..b09f4dbdd 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -28,36 +28,6 @@ #include <gnunet/gnunet_util_lib.h> #include <gcrypt.h> -/** - * Return the base32crockford encoding of the given buffer. - * - * The returned string will be freshly allocated, and must be free'd - * with GNUNET_free(). - * - * @param buffer with data - * @param size size of the buffer - * @return freshly allocated, null-terminated string - */ -char * -TALER_data_to_string_alloc (const void *buf, size_t size) -{ - char *str_buf; - size_t len = size * 8; - char *end; - - if (len % 5 > 0) - len += 5 - len % 5; - len /= 5; - str_buf = GNUNET_malloc (len + 1); - end = GNUNET_STRINGS_data_to_string (buf, size, str_buf, len); - if (NULL == end) - { - GNUNET_free (str_buf); - return NULL; - } - *end = '\0'; - return str_buf; -} /** |