gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant] 03/03: Dynamic currency at the generator.


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant] 03/03: Dynamic currency at the generator.
Date: Tue, 12 Jun 2018 10:28:48 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository merchant.

commit f7be081ad266ee9ea11047033599d30b90fb5f32
Author: Marcello Stanisci <address@hidden>
AuthorDate: Tue Jun 12 10:27:46 2018 +0200

    Dynamic currency at the generator.
    
    Moving currency-dependant strings allocation
    above the run method.
---
 .../taler-merchant-generate-payments_new.c         | 165 +++++++++++----------
 1 file changed, 88 insertions(+), 77 deletions(-)

diff --git a/src/merchant-tools/taler-merchant-generate-payments_new.c 
b/src/merchant-tools/taler-merchant-generate-payments_new.c
index 986ddc7..b910d81 100644
--- a/src/merchant-tools/taler-merchant-generate-payments_new.c
+++ b/src/merchant-tools/taler-merchant-generate-payments_new.c
@@ -127,58 +127,38 @@ static char *merchant_url;
 static char *currency;
 
 /**
- * Actual commands collection.
+ * Convenience macros to allocate all the currency-dependant
+ * strings;  note that the argument list of the macro is ignored.
+ * It is kept as a way to make the macro more auto-descriptive
+ * where it is called.
  */
-static void
-run (void *cls,
-     struct TALER_TESTING_Interpreter *is)
-{
 
-  /* Currency strings.  */
-  char *CURRENCY_25_05;
-  char *CURRENCY_10;
-  char *CURRENCY_9_98;
-  char *CURRENCY_5;
-  char *CURRENCY_4_99;
-  char *CURRENCY_0_02;
-  char *CURRENCY_0_01;
-
-  GNUNET_asprintf (&CURRENCY_25_05,
-                   "%s:25.05",
-                   currency);
-
-  GNUNET_asprintf (&CURRENCY_10,
-                   "%s:10",
+#define ALLOCATE_AMOUNTS(...) \
+  GNUNET_asprintf (&CURRENCY_25_05, \
+                   "%s:25.05", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_10, \
+                   "%s:10", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_9_98, \
+                   "%s:9.98", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_5, \
+                   "%s:5", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_4_99, \
+                   "%s:4.99", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_0_02, \
+                   "%s:0.02", \
+                   currency); \
+  GNUNET_asprintf (&CURRENCY_0_01, \
+                   "%s:0.01", \
                    currency);
 
-  GNUNET_asprintf (&CURRENCY_9_98,
-                   "%s:9.98",
-                   currency);
-
-  GNUNET_asprintf (&CURRENCY_5,
-                   "%s:5",
-                   currency);
-
-  GNUNET_asprintf (&CURRENCY_4_99,
-                   "%s:4.99",
-                   currency);
-
-  GNUNET_asprintf (&CURRENCY_0_02,
-                   "%s:0.02",
-                   currency);
-
-  GNUNET_asprintf (&CURRENCY_0_01,
-                   "%s:0.01",
-                   currency);
-
-  /* Orders.  */
-  char *order_worth_5;
-  char *order_worth_10_2coins;
-  char *order_worth_5_track;
-  char *order_worth_5_unaggregated;
-
-  GNUNET_asprintf
-    (&order_worth_5,
+#define ALLOCATE_ORDERS(...) \
+  GNUNET_asprintf \
+    (&order_worth_5, \
      "{\"max_fee\":\
        {\"currency\":\"%s\",\
         \"value\":0,\
@@ -192,14 +172,12 @@ run (void *cls,
         \"summary\": \"merchant-lib testcase\",\
         \"fulfillment_url\": \"https://example.com/\",\
         \"products\": [ {\"description\":\"ice cream\",\
-                         \"value\":\"{%s:5}\"} ]\
-     }",
-     currency,
-     currency,
-     currency);
-
-  GNUNET_asprintf
-    (&order_worth_10_2coins,
+                         \"value\":\"{%s:5}\"} ] }", \
+     currency, \
+     currency, \
+     currency); \
+  GNUNET_asprintf \
+    (&order_worth_10_2coins, \
      "{\"max_fee\":\
        {\"currency\":\"%s\",\
         \"value\":0,\
@@ -213,14 +191,12 @@ run (void *cls,
         \"summary\": \"2-coins untracked payment\",\
         \"fulfillment_url\": \"https://example.com/\",\
         \"products\": [ {\"description\":\"2-coins payment\",\
-                         \"value\":\"{%s:10}\"} ]\
-     }",
-     currency,
-     currency,
-     currency);
-
-  GNUNET_asprintf
-    (&order_worth_5_track,
+                         \"value\":\"{%s:10}\"} ] }", \
+     currency, \
+     currency, \
+     currency); \
+  GNUNET_asprintf \
+    (&order_worth_5_track, \
      "{\"max_fee\":\
        {\"currency\":\"%s\",\
         \"value\":0,\
@@ -234,15 +210,12 @@ run (void *cls,
         \"summary\": \"ice track cream!\",\
         \"fulfillment_url\": \"https://example.com/\",\
         \"products\": [ {\"description\":\"ice track cream\",\
-                         \"value\":\"{%s:5}\"} ]\
-     }",
-     currency,
-     currency,
-     currency);
-
-
-  GNUNET_asprintf
-    (&order_worth_5_unaggregated,
+                         \"value\":\"{%s:5}\"} ] }", \
+     currency, \
+     currency, \
+     currency); \
+  GNUNET_asprintf \
+    (&order_worth_5_unaggregated, \
      "{\"max_fee\":\
        {\"currency\":\"%s\",\
         \"value\":0,\
@@ -256,12 +229,50 @@ run (void *cls,
         \"summary\": \"unaggregated deposit!\",\
         \"fulfillment_url\": \"https://example.com/\",\
         \"products\": [ {\"description\":\"unaggregated cream\",\
-                         \"value\":\"{%s:5}\"} ]\
-     }",
-     currency,
-     currency,
+                         \"value\":\"{%s:5}\"} ] }", \
+     currency, \
+     currency, \
      currency);
 
+/**
+ * Actual commands collection.
+ */
+static void
+run (void *cls,
+     struct TALER_TESTING_Interpreter *is)
+{
+
+  /* Currency strings.  */
+  char *CURRENCY_25_05;
+  char *CURRENCY_10;
+  char *CURRENCY_9_98;
+  char *CURRENCY_5;
+  char *CURRENCY_4_99;
+  char *CURRENCY_0_02;
+  char *CURRENCY_0_01;
+
+  ALLOCATE_AMOUNTS
+    (CURRENCY_25_05,
+     CURRENCY_10,
+     CURRENCY_9_98,
+     CURRENCY_5,
+     CURRENCY_4_99,
+     CURRENCY_0_02,
+     CURRENCY_0_01);
+
+
+  /* Orders.  */
+  char *order_worth_5;
+  char *order_worth_10_2coins;
+  char *order_worth_5_track;
+  char *order_worth_5_unaggregated;
+
+  ALLOCATE_ORDERS
+    (order_worth_5,
+     order_worth_10_2coins,
+     order_worth_5_track,
+     order_worth_5_unaggregated);
+
   struct TALER_TESTING_Command commands[] = {
 
     CMD_TRANSFER_TO_EXCHANGE

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]