summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-08-25 16:18:24 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-08-25 16:18:24 +0200
commiteb559970846f0fa27f1f25c482cd07210a56f4b1 (patch)
tree8526637825e520e1420b17515934ced794a33c01 /src/util
parent3742239c13001433eeade439a0e0490f07351c43 (diff)
downloadexchange-eb559970846f0fa27f1f25c482cd07210a56f4b1.tar.gz
exchange-eb559970846f0fa27f1f25c482cd07210a56f4b1.tar.bz2
exchange-eb559970846f0fa27f1f25c482cd07210a56f4b1.zip
re-format code
Diffstat (limited to 'src/util')
-rw-r--r--src/util/amount.c16
-rw-r--r--src/util/crypto.c42
-rw-r--r--src/util/crypto_wire.c18
-rw-r--r--src/util/test_amount.c129
-rw-r--r--src/util/test_crypto.c11
-rw-r--r--src/util/test_url.c12
-rw-r--r--src/util/util.c71
7 files changed, 163 insertions, 136 deletions
diff --git a/src/util/amount.c b/src/util/amount.c
index ac6be27d8..8e801267f 100644
--- a/src/util/amount.c
+++ b/src/util/amount.c
@@ -69,7 +69,7 @@ TALER_string_to_amount (const char *str,
invalidate (denom);
/* skip leading whitespace */
- while (isspace( (unsigned char) str[0]))
+ while (isspace ( (unsigned char) str[0]))
str++;
if ('\0' == str[0])
{
@@ -164,7 +164,7 @@ TALER_string_to_amount (const char *str,
}
return GNUNET_OK;
- fail:
+ fail:
/* set currency to 'invalid' to prevent accidental use */
memset (denom->currency,
0,
@@ -208,7 +208,7 @@ TALER_amount_hton (struct TALER_AmountNBO *res,
const struct TALER_Amount *d)
{
GNUNET_assert (GNUNET_YES ==
- TALER_amount_is_valid (d));
+ TALER_amount_is_valid (d));
res->value = GNUNET_htonll (d->value);
res->fraction = htonl (d->fraction);
memcpy (res->currency,
@@ -233,7 +233,7 @@ TALER_amount_ntoh (struct TALER_Amount *res,
dn->currency,
TALER_CURRENCY_LEN);
GNUNET_assert (GNUNET_YES ==
- TALER_amount_is_valid (res));
+ TALER_amount_is_valid (res));
}
@@ -308,7 +308,7 @@ TALER_amount_cmp_currency (const struct TALER_Amount *a1,
(GNUNET_NO == TALER_amount_is_valid (a2)) )
return GNUNET_SYSERR;
if (0 == strcasecmp (a1->currency,
- a2->currency))
+ a2->currency))
return GNUNET_YES;
return GNUNET_NO;
}
@@ -331,7 +331,7 @@ TALER_amount_cmp_currency_nbo (const struct TALER_AmountNBO *a1,
(GNUNET_NO == test_valid_nbo (a2)) )
return GNUNET_SYSERR;
if (0 == strcasecmp (a1->currency,
- a2->currency))
+ a2->currency))
return GNUNET_YES;
return GNUNET_NO;
}
@@ -362,9 +362,9 @@ TALER_amount_cmp (const struct TALER_Amount *a1,
n1 = *a1;
n2 = *a2;
GNUNET_assert (GNUNET_SYSERR !=
- TALER_amount_normalize (&n1));
+ TALER_amount_normalize (&n1));
GNUNET_assert (GNUNET_SYSERR !=
- TALER_amount_normalize (&n2));
+ TALER_amount_normalize (&n2));
if (n1.value == n2.value)
{
if (n1.fraction < n2.fraction)
diff --git a/src/util/crypto.c b/src/util/crypto.c
index 95eb11eba..4ddd86c1a 100644
--- a/src/util/crypto.c
+++ b/src/util/crypto.c
@@ -48,14 +48,14 @@ fatal_error_handler (void *cls,
fprintf (stderr,
"Fatal error in libgcrypt: %s\n",
msg);
- abort();
+ abort ();
}
/**
* Initialize libgcrypt.
*/
-void __attribute__ ((constructor))
+void __attribute__ ((constructor))
TALER_gcrypt_init ()
{
gcry_set_fatalerror_handler (&fatal_error_handler,
@@ -125,8 +125,10 @@ TALER_test_coin_valid (const struct TALER_CoinPublicInfo *coin_public_info,
* @param[out] ts computed transfer secret
*/
void
-TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin_priv,
- const struct TALER_TransferPrivateKeyP *trans_priv,
+TALER_link_derive_transfer_secret (const struct
+ TALER_CoinSpendPrivateKeyP *coin_priv,
+ const struct
+ TALER_TransferPrivateKeyP *trans_priv,
struct TALER_TransferSecretP *ts)
{
struct TALER_CoinSpendPublicKeyP coin_pub;
@@ -150,8 +152,10 @@ TALER_link_derive_transfer_secret (const struct TALER_CoinSpendPrivateKeyP *coin
* @param[out] transfer_secret set to the shared secret
*/
void
-TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans_priv,
- const struct TALER_CoinSpendPublicKeyP *coin_pub,
+TALER_link_reveal_transfer_secret (const struct
+ TALER_TransferPrivateKeyP *trans_priv,
+ const struct
+ TALER_CoinSpendPublicKeyP *coin_pub,
struct TALER_TransferSecretP *transfer_secret)
{
GNUNET_assert (GNUNET_OK ==
@@ -170,9 +174,12 @@ TALER_link_reveal_transfer_secret (const struct TALER_TransferPrivateKeyP *trans
* @param[out] transfer_secret set to the shared secret
*/
void
-TALER_link_recover_transfer_secret (const struct TALER_TransferPublicKeyP *trans_pub,
- const struct TALER_CoinSpendPrivateKeyP *coin_priv,
- struct TALER_TransferSecretP *transfer_secret)
+TALER_link_recover_transfer_secret (const struct
+ TALER_TransferPublicKeyP *trans_pub,
+ const struct
+ TALER_CoinSpendPrivateKeyP *coin_priv,
+ struct TALER_TransferSecretP *
+ transfer_secret)
{
GNUNET_assert (GNUNET_OK ==
GNUNET_CRYPTO_eddsa_ecdh (&coin_priv->eddsa_priv,
@@ -349,7 +356,7 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
hash_context = GNUNET_CRYPTO_hash_context_start ();
/* first, iterate over transfer public keys for hash_context */
- for (unsigned int i=0;i<kappa;i++)
+ for (unsigned int i = 0; i<kappa; i++)
{
GNUNET_CRYPTO_hash_context_read (hash_context,
&rcs[i].transfer_pub,
@@ -357,7 +364,7 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
}
/* next, add all of the hashes from the denomination keys to the
hash_context */
- for (unsigned int i=0;i<num_new_coins;i++)
+ for (unsigned int i = 0; i<num_new_coins; i++)
{
char *buf;
size_t buf_size;
@@ -365,11 +372,12 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
/* The denomination keys should / must all be identical regardless
of what offset we use, so we use [0]. */
GNUNET_assert (kappa > 0); /* sanity check */
- buf_size = GNUNET_CRYPTO_rsa_public_key_encode (rcs[0].new_coins[i].dk->rsa_public_key,
- &buf);
+ buf_size = GNUNET_CRYPTO_rsa_public_key_encode (
+ rcs[0].new_coins[i].dk->rsa_public_key,
+ &buf);
GNUNET_CRYPTO_hash_context_read (hash_context,
- buf,
- buf_size);
+ buf,
+ buf_size);
GNUNET_free (buf);
}
@@ -388,11 +396,11 @@ TALER_refresh_get_commitment (struct TALER_RefreshCommitmentP *rc,
}
/* finally, add all the envelopes */
- for (unsigned int i=0;i<kappa;i++)
+ for (unsigned int i = 0; i<kappa; i++)
{
const struct TALER_RefreshCommitmentEntry *rce = &rcs[i];
- for (unsigned int j=0;j<num_new_coins;j++)
+ for (unsigned int j = 0; j<num_new_coins; j++)
{
const struct TALER_RefreshCoinData *rcd = &rce->new_coins[j];
diff --git a/src/util/crypto_wire.c b/src/util/crypto_wire.c
index ca6b9d216..e799812e4 100644
--- a/src/util/crypto_wire.c
+++ b/src/util/crypto_wire.c
@@ -55,8 +55,10 @@ TALER_exchange_wire_signature_hash (const char *payto_url,
*/
int
TALER_exchange_wire_signature_check (const char *payto_url,
- const struct TALER_MasterPublicKeyP *master_pub,
- const struct TALER_MasterSignatureP *master_sig)
+ const struct
+ TALER_MasterPublicKeyP *master_pub,
+ const struct
+ TALER_MasterSignatureP *master_sig)
{
struct TALER_MasterWireDetailsPS wd;
@@ -80,7 +82,8 @@ TALER_exchange_wire_signature_check (const char *payto_url,
*/
void
TALER_exchange_wire_signature_make (const char *payto_url,
- const struct TALER_MasterPrivateKeyP *master_priv,
+ const struct
+ TALER_MasterPrivateKeyP *master_priv,
struct TALER_MasterSignatureP *master_sig)
{
struct TALER_MasterWireDetailsPS wd;
@@ -134,8 +137,10 @@ TALER_merchant_wire_signature_hash (const char *payto_url,
int
TALER_merchant_wire_signature_check (const char *payto_url,
const char *salt,
- const struct TALER_MerchantPublicKeyP *merch_pub,
- const struct TALER_MerchantSignatureP *merch_sig)
+ const struct
+ TALER_MerchantPublicKeyP *merch_pub,
+ const struct
+ TALER_MerchantSignatureP *merch_sig)
{
struct TALER_MasterWireDetailsPS wd;
@@ -162,7 +167,8 @@ TALER_merchant_wire_signature_check (const char *payto_url,
void
TALER_merchant_wire_signature_make (const char *payto_url,
const char *salt,
- const struct TALER_MerchantPrivateKeyP *merch_priv,
+ const struct
+ TALER_MerchantPrivateKeyP *merch_priv,
struct TALER_MerchantSignatureP *merch_sig)
{
struct TALER_MasterWireDetailsPS wd;
diff --git a/src/util/test_amount.c b/src/util/test_amount.c
index 3854297dd..a8b37823c 100644
--- a/src/util/test_amount.c
+++ b/src/util/test_amount.c
@@ -25,8 +25,8 @@
int
-main(int argc,
- const char *const argv[])
+main (int argc,
+ const char *const argv[])
{
struct TALER_Amount a1;
struct TALER_Amount a2;
@@ -34,51 +34,52 @@ main(int argc,
char *c;
GNUNET_log_setup ("test-amout",
- "WARNING",
- NULL);
+ "WARNING",
+ NULL);
/* test invalid conversions */
GNUNET_log_skip (6, GNUNET_NO);
/* non-numeric */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount ("EUR:4a",
- &a1));
+ TALER_string_to_amount ("EUR:4a",
+ &a1));
/* non-numeric */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount ("EUR:4.4a",
- &a1));
+ TALER_string_to_amount ("EUR:4.4a",
+ &a1));
/* non-numeric */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount ("EUR:4.a4",
- &a1));
+ TALER_string_to_amount ("EUR:4.a4",
+ &a1));
/* no currency */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount (":4.a4",
- &a1));
+ TALER_string_to_amount (":4.a4",
+ &a1));
/* precision too high */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount ("EUR:4.123456789",
- &a1));
+ TALER_string_to_amount ("EUR:4.123456789",
+ &a1));
/* value too big */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_string_to_amount ("EUR:1234567890123456789012345678901234567890123456789012345678901234567890",
- &a1));
+ TALER_string_to_amount (
+ "EUR:1234567890123456789012345678901234567890123456789012345678901234567890",
+ &a1));
GNUNET_log_skip (0, GNUNET_YES);
/* test conversion without fraction */
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:4",
- &a1));
+ TALER_string_to_amount ("EUR:4",
+ &a1));
GNUNET_assert (0 == strcasecmp ("EUR",
- a1.currency));
+ a1.currency));
GNUNET_assert (4 == a1.value);
GNUNET_assert (0 == a1.fraction);
/* test conversion with leading zero in fraction */
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("eur:0.02",
- &a2));
+ TALER_string_to_amount ("eur:0.02",
+ &a2));
GNUNET_assert (0 == strcasecmp ("eur",
- a2.currency));
+ a2.currency));
GNUNET_assert (0 == a2.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 2 == a2.fraction);
c = TALER_amount_to_string (&a2);
@@ -88,95 +89,95 @@ main(int argc,
/* test conversion with leading space and with fraction */
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (" eur:4.12",
- &a2));
+ TALER_string_to_amount (" eur:4.12",
+ &a2));
GNUNET_assert (0 == strcasecmp ("eur",
- a2.currency));
+ a2.currency));
GNUNET_assert (4 == a2.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 12 == a2.fraction);
/* test use of local currency */
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount (" *LOCAL:4444.1000",
- &a3));
+ TALER_string_to_amount (" *LOCAL:4444.1000",
+ &a3));
GNUNET_assert (0 == strcasecmp ("*LOCAL",
- a3.currency));
+ a3.currency));
GNUNET_assert (4444 == a3.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 10 == a3.fraction);
/* test CMP with equal and unequal currencies */
GNUNET_assert (GNUNET_NO ==
- TALER_amount_cmp_currency (&a1,
- &a3));
+ TALER_amount_cmp_currency (&a1,
+ &a3));
GNUNET_assert (GNUNET_YES ==
- TALER_amount_cmp_currency (&a1,
- &a2));
+ TALER_amount_cmp_currency (&a1,
+ &a2));
/* test subtraction failure (currency missmatch) */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_subtract (&a3,
- &a3,
- &a2));
+ TALER_amount_subtract (&a3,
+ &a3,
+ &a2));
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
/* test subtraction failure (negative result) */
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_subtract (&a3,
- &a1,
- &a2));
+ TALER_amount_subtract (&a3,
+ &a1,
+ &a2));
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
/* test subtraction success cases */
GNUNET_assert (GNUNET_YES ==
- TALER_amount_subtract (&a3,
- &a2,
- &a1));
+ TALER_amount_subtract (&a3,
+ &a2,
+ &a1));
GNUNET_assert (GNUNET_NO ==
- TALER_amount_subtract (&a3,
- &a1,
- &a1));
+ TALER_amount_subtract (&a3,
+ &a1,
+ &a1));
GNUNET_assert (0 == a3.value);
GNUNET_assert (0 == a3.fraction);
GNUNET_assert (GNUNET_NO ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
/* test addition success */
GNUNET_assert (GNUNET_OK ==
- TALER_amount_add (&a3,
- &a3,
- &a2));
+ TALER_amount_add (&a3,
+ &a3,
+ &a2));
GNUNET_assert (GNUNET_NO ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
/* test normalization */
a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE;
a3.value = 4;
GNUNET_assert (GNUNET_YES ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
/* test conversion to string */
c = TALER_amount_to_string (&a3);
GNUNET_assert (0 == strcmp ("EUR:6",
- c));
+ c));
GNUNET_free (c);
/* test normalization with fraction overflow */
a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE + 1;
a3.value = 4;
GNUNET_assert (GNUNET_YES ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
c = TALER_amount_to_string (&a3);
GNUNET_assert (0 == strcmp ("EUR:6.00000001",
- c));
+ c));
GNUNET_free (c);
/* test normalization with overflow */
a3.fraction = 2 * TALER_AMOUNT_FRAC_BASE + 1;
a3.value = UINT64_MAX - 1;
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_normalize (&a3));
+ TALER_amount_normalize (&a3));
c = TALER_amount_to_string (&a3);
GNUNET_assert (NULL == c);
@@ -186,7 +187,7 @@ main(int argc,
a2.fraction = 2;
a2.value = 5;
GNUNET_assert (GNUNET_SYSERR ==
- TALER_amount_add (&a3, &a1, &a2));
+ TALER_amount_add (&a3, &a1, &a2));
/* test addition with underflow on fraction */
a1.fraction = 1;
@@ -194,19 +195,19 @@ main(int argc,
a2.fraction = 2;
a2.value = 0;
GNUNET_assert (GNUNET_OK ==
- TALER_amount_subtract (&a3, &a1, &a2));
+ TALER_amount_subtract (&a3, &a1, &a2));
GNUNET_assert (UINT64_MAX - 1 == a3.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE - 1 == a3.fraction);
/* test division */
GNUNET_assert (GNUNET_OK ==
- TALER_string_to_amount ("EUR:3.33",
- &a1));
+ TALER_string_to_amount ("EUR:3.33",
+ &a1));
TALER_amount_divide (&a2,
&a1,
1);
GNUNET_assert (0 == strcasecmp ("EUR",
- a2.currency));
+ a2.currency));
GNUNET_assert (3 == a2.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 33 == a2.fraction);
@@ -214,7 +215,7 @@ main(int argc,
&a1,
3);
GNUNET_assert (0 == strcasecmp ("EUR",
- a2.currency));
+ a2.currency));
GNUNET_assert (1 == a2.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 100 * 11 == a2.fraction);
@@ -222,14 +223,14 @@ main(int argc,
&a1,
2);
GNUNET_assert (0 == strcasecmp ("EUR",
- a2.currency));
+ a2.currency));
GNUNET_assert (1 == a2.value);
GNUNET_assert (TALER_AMOUNT_FRAC_BASE / 1000 * 665 == a2.fraction);
TALER_amount_divide (&a2,
&a1,
TALER_AMOUNT_FRAC_BASE * 2);
GNUNET_assert (0 == strcasecmp ("EUR",
- a2.currency));
+ a2.currency));
GNUNET_assert (0 == a2.value);
GNUNET_assert (1 == a2.fraction);
diff --git a/src/util/test_crypto.c b/src/util/test_crypto.c
index bba9275af..c3c7b957c 100644
--- a/src/util/test_crypto.c
+++ b/src/util/test_crypto.c
@@ -47,12 +47,12 @@ test_high_level ()
coin_priv.eddsa_priv = *pk;
GNUNET_free (pk);
GNUNET_CRYPTO_eddsa_key_get_public (&coin_priv.eddsa_priv,
- &coin_pub.eddsa_pub);
+ &coin_pub.eddsa_pub);
pk2 = GNUNET_CRYPTO_ecdhe_key_create ();
trans_priv.ecdhe_priv = *pk2;
GNUNET_free (pk2);
GNUNET_CRYPTO_ecdhe_key_get_public (&trans_priv.ecdhe_priv,
- &trans_pub.ecdhe_pub);
+ &trans_pub.ecdhe_pub);
TALER_link_derive_transfer_secret (&coin_priv,
&trans_priv,
&secret);
@@ -98,7 +98,8 @@ test_planchets ()
struct TALER_FreshCoin coin;
dk_priv.rsa_private_key = GNUNET_CRYPTO_rsa_private_key_create (1024);
- dk_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (dk_priv.rsa_private_key);
+ dk_pub.rsa_public_key = GNUNET_CRYPTO_rsa_private_key_get_public (
+ dk_priv.rsa_private_key);
TALER_planchet_setup_random (&ps);
GNUNET_assert (GNUNET_OK ==
TALER_planchet_prepare (&dk_pub,
@@ -123,8 +124,8 @@ test_planchets ()
int
-main(int argc,
- const char *const argv[])
+main (int argc,
+ const char *const argv[])
{
if (0 != test_high_level ())
return 1;
diff --git a/src/util/test_url.c b/src/util/test_url.c
index 3734da4e0..59a5e3fa7 100644
--- a/src/util/test_url.c
+++ b/src/util/test_url.c
@@ -49,10 +49,14 @@ main (int argc,
cf (TALER_urlencode ("foo bar "), "foo%20bar%20");
cf (TALER_urlencode ("% % "), "%25%20%25%20");
- cf (TALER_url_join ("https://taler.net/", "foo", NULL), "https://taler.net/foo");
- cf (TALER_url_join ("https://taler.net", "foo", NULL), "https://taler.net/foo");
- cf (TALER_url_join ("https://taler.net/", "/foo", NULL), "https://taler.net/foo");
- cf (TALER_url_join ("https://taler.net/", "/foo/", NULL), "https://taler.net/foo/");
+ cf (TALER_url_join ("https://taler.net/", "foo", NULL),
+ "https://taler.net/foo");
+ cf (TALER_url_join ("https://taler.net", "foo", NULL),
+ "https://taler.net/foo");
+ cf (TALER_url_join ("https://taler.net/", "/foo", NULL),
+ "https://taler.net/foo");
+ cf (TALER_url_join ("https://taler.net/", "/foo/", NULL),
+ "https://taler.net/foo/");
cf (TALER_url_join ("https://taler.net/", "foo", "x", "42", NULL),
"https://taler.net/foo?x=42");
diff --git a/src/util/util.c b/src/util/util.c
index eea4c91aa..e4697fab4 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -46,13 +46,13 @@ TALER_b2s (const void *buf,
char *tmp;
GNUNET_CRYPTO_hash (buf,
- buf_size,
- &hc);
+ buf_size,
+ &hc);
tmp = GNUNET_STRINGS_data_to_string_alloc (&hc,
sizeof (hc));
memcpy (ret,
- tmp,
- 8);
+ tmp,
+ 8);
GNUNET_free (tmp);
ret[8] = '\0';
return ret;
@@ -120,7 +120,7 @@ set_amount (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
amount))
{
FPRINTF (stderr,
- _("Failed to parse amount in option `%s'\n"),
+ _ ("Failed to parse amount in option `%s'\n"),
option);
return GNUNET_SYSERR;
}
@@ -168,25 +168,26 @@ TALER_getopt_get_amount (char shortName,
* #GNUNET_NO otherwise
*/
static bool
-is_reserved(char c)
+is_reserved (char c)
{
- switch (c) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
- case '-': case '.': case '_': case '~':
- return GNUNET_NO;
- default:
- break;
+ switch (c)
+ {
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
+ case '-': case '.': case '_': case '~':
+ return GNUNET_NO;
+ default:
+ break;
}
return GNUNET_YES;
}
@@ -215,7 +216,7 @@ TALER_urlencode (const char *s)
{
if (GNUNET_YES == is_reserved (s[i]))
{
- snprintf(&out[t], 4, "%%%02X", s[i]);
+ snprintf (&out[t], 4, "%%%02X", s[i]);
t += 2;
continue;
}
@@ -305,7 +306,8 @@ TALER_url_join (const char *base_url,
va_start (args, path);
- while (1) {
+ while (1)
+ {
char *key;
char *value;
key = va_arg (args, char *);
@@ -360,7 +362,8 @@ url_absolute_raw_va (const char *proto,
grow_string_path (&res, path, &n);
- while (1) {
+ while (1)
+ {
char *key;
char *value;
key = va_arg (args, char *);
@@ -425,21 +428,23 @@ TALER_url_absolute_mhd (struct MHD_Connection *connection,
{
/* By default we assume we're running under HTTPS */
const char *proto = "https";
- const char *forwarded_proto = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Proto");
+ const char *forwarded_proto = MHD_lookup_connection_value (connection,
+ MHD_HEADER_KIND,
+ "X-Forwarded-Proto");
const char *host;
const char *forwarded_host;
const char *prefix;
va_list args;
char *result;
-
-
+
+
if (NULL != forwarded_proto)
{
proto = forwarded_proto;
}
else
{
- /* likely not reverse proxy, figure out if we are
+ /* likely not reverse proxy, figure out if we are
http by asking MHD */
const union MHD_ConnectionInfo *ci;
@@ -459,9 +464,11 @@ TALER_url_absolute_mhd (struct MHD_Connection *connection,
}
}
host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "Host");
- forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Host");
+ forwarded_host = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+ "X-Forwarded-Host");
- prefix = MHD_lookup_connection_value (connection, MHD_HEADER_KIND, "X-Forwarded-Prefix");
+ prefix = MHD_lookup_connection_value (connection, MHD_HEADER_KIND,
+ "X-Forwarded-Prefix");
if (NULL == prefix)
prefix = "";