gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-mdb] branch master updated (e5b1473 -> 681e05c)


From: gnunet
Subject: [taler-taler-mdb] branch master updated (e5b1473 -> 681e05c)
Date: Thu, 31 Oct 2019 12:55:27 +0100

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

grothoff pushed a change to branch master
in repository taler-mdb.

    from e5b1473  clearly no leak, remove unnecessary init, remove unnecessary 
nfc_close()
     new 376c443  improve uncrustify rules
     new 681e05c  reindent

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 contrib/uncrustify.cfg | 19 ++++++++++++++
 src/communication.c    | 67 +++++++++++++++++++++++++++++++-------------------
 src/configuration.h    |  1 -
 src/main.c             | 40 ++++++++++++++++--------------
 src/nfc.c              | 37 ++++++++++++++++------------
 src/product.c          | 50 +++++++++++++++++++++++--------------
 src/product.h          |  1 -
 src/wallet.c           | 60 ++++++++++++++++++++++++++------------------
 src/wallet.h           |  2 --
 9 files changed, 171 insertions(+), 106 deletions(-)

diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg
index f56c8e7..12dd62c 100644
--- a/contrib/uncrustify.cfg
+++ b/contrib/uncrustify.cfg
@@ -49,8 +49,14 @@ nl_assign_brace=remove
 
 # No extra newlines that cause noisy diffs
 nl_start_of_file=remove
+nl_before_func_body_proto = 2
+nl_before_func_body_def = 3
+nl_after_func_proto = 2
+nl_after_func_body = 3
 # If there's no new line, it's not a text file!
 nl_end_of_file=add
+nl_max_blank_in_func = 3
+nl_max = 3
 
 sp_inside_paren = remove
 
@@ -69,6 +75,7 @@ sp_between_ptr_star = remove
 sp_before_sparen = add
 
 sp_inside_fparen = remove
+sp_inside_sparen = remove
 
 # add space before function call and decl: "foo (x)"
 sp_func_call_paren = add
@@ -76,3 +83,15 @@ sp_func_proto_paren = add
 sp_func_proto_paren_empty = add
 sp_func_def_paren = add
 sp_func_def_paren_empty = add
+
+# We'd want it for "if ( (foo) || (bar) )", but not for "if (m())",
+# so as uncrustify doesn't give exactly what we want => ignore
+sp_paren_paren = ignore
+sp_inside_paren = remove
+sp_bool = force
+
+nl_func_type_name = force
+#nl_branch_else = add
+nl_else_brace = add
+nl_elseif_brace = add
+nl_for_brace = add
diff --git a/src/communication.c b/src/communication.c
index db74106..a62e5e8 100644
--- a/src/communication.c
+++ b/src/communication.c
@@ -30,9 +30,11 @@ along with
 #include "wallet.h"
 #include "configuration.h"
 
-int taler_init (CURL **curl)
+
+int
+taler_init (CURL **curl)
 {
-  if ( *curl != NULL )
+  if (*curl != NULL)
   {
     printf ("taler_init: curl handle already initialized\n");
     return EXIT_FAILURE;
@@ -41,7 +43,7 @@ int taler_init (CURL **curl)
   // initialize curl
   CURLcode result = curl_global_init (CURL_GLOBAL_ALL);
   *curl = curl_easy_init ();
-  if ( ! (*curl) ||(result != CURLE_OK) )
+  if (! (*curl) || (result != CURLE_OK) )
   {
     printf ("taler_init: could not inizialize curl handle\n");
     return EXIT_FAILURE;
@@ -50,16 +52,20 @@ int taler_init (CURL **curl)
   return EXIT_SUCCESS;
 }
 
-void taler_exit (CURL **curl)
+
+void
+taler_exit (CURL **curl)
 {
   curl_easy_cleanup (*curl);
   curl_global_cleanup ();
 }
 
-int taler_alloc_string (char **string, size_t size)
+
+int
+taler_alloc_string (char **string, size_t size)
 {
   *string = malloc (size);
-  if ( ! (*string) )
+  if (! (*string) )
   {
     printf ("taler_alloc: unable to allocate string");
     exit (EXIT_FAILURE);
@@ -67,14 +73,16 @@ int taler_alloc_string (char **string, size_t size)
   return EXIT_SUCCESS;
 }
 
-static size_t _taler_write_response (void *contents, size_t size, size_t nmemb,
-                                     void *userp)
+
+static size_t
+_taler_write_response (void *contents, size_t size, size_t nmemb,
+                       void *userp)
 {
   size_t realSize = size * nmemb;
   struct TalerResponse *response = (struct TalerResponse *) userp;
 
   char *tempString = realloc (response->string, response->size + realSize + 1);
-  if ( ! tempString )
+  if (! tempString)
   {
     printf ("Allocation failure");
     return EXIT_FAILURE;
@@ -88,7 +96,9 @@ static size_t _taler_write_response (void *contents, size_t 
size, size_t nmemb,
   return realSize;
 }
 
-int taler_create_order_req (ProductOrder *product)
+
+int
+taler_create_order_req (ProductOrder *product)
 {
   char buffer[256];
 
@@ -96,7 +106,7 @@ int taler_create_order_req (ProductOrder *product)
            product->amount, product->product);
 
   char*temp = realloc (product->orderRequest, strlen (buffer) + 1);
-  if ( ! temp )
+  if (! temp)
   {
     printf ("could not allocate order\n");
     return EXIT_FAILURE;
@@ -109,7 +119,9 @@ int taler_create_order_req (ProductOrder *product)
   return EXIT_SUCCESS;
 }
 
-int taler_create_order (CURL *curl, ProductOrder *product)
+
+int
+taler_create_order (CURL *curl, ProductOrder *product)
 {
   // reset the response size
   product->response->size = 0;
@@ -134,7 +146,7 @@ int taler_create_order (CURL *curl, ProductOrder *product)
 
   // perform the call
   CURLcode result = curl_easy_perform (curl);
-  if ( result != CURLE_OK )
+  if (result != CURLE_OK)
   {
     printf ("could not communicate with \"%s\"\n", url);
     return EXIT_FAILURE;
@@ -149,7 +161,9 @@ int taler_create_order (CURL *curl, ProductOrder *product)
   return EXIT_SUCCESS;
 }
 
-int taler_check_payment_status (CURL *curl, ProductOrder *product)
+
+int
+taler_check_payment_status (CURL *curl, ProductOrder *product)
 {
   // reset the response size
   product->response->size = 0;
@@ -171,7 +185,7 @@ int taler_check_payment_status (CURL *curl, ProductOrder 
*product)
 
   // perform the call
   CURLcode result = curl_easy_perform (curl);
-  if ( result != CURLE_OK )
+  if (result != CURLE_OK)
   {
     printf ("could not communicate with \"%s\"\n", product->checkUrl);
     return EXIT_FAILURE;
@@ -186,43 +200,46 @@ int taler_check_payment_status (CURL *curl, ProductOrder 
*product)
   return EXIT_SUCCESS;
 }
 
-int taler_parse_json (const TalerResponse *response, const char *memberName,
-                      char **returnStr, bool isBoolean)
+
+int
+taler_parse_json (const TalerResponse *response, const char *memberName,
+                  char **returnStr, bool isBoolean)
 {
-  if ( ! (*returnStr) )
+  if (! (*returnStr) )
     taler_alloc_string (returnStr, 1);
   char *result = NULL;
   char *temp = NULL;
   char mbr[64];
 
-  if ( isBoolean )
+  if (isBoolean)
   {
     // If the wanted member is of type boolean
     sprintf (mbr, "\"%s\": true", memberName);
-    if ( (temp = strstr (response->string, mbr)) != NULL )
+    if ( (temp = strstr (response->string, mbr)) != NULL)
       result = "true";
     else
       result = "false";
   }
-  else{
+  else
+  {
     // String type members
     sprintf (mbr, "\"%s\":", memberName);
-    if ( (temp = strstr (response->string, mbr)) != NULL )
+    if ( (temp = strstr (response->string, mbr)) != NULL)
     {
-      if ( (temp = strstr (response->string, ": ")) != NULL )
+      if ( (temp = strstr (response->string, ": ")) != NULL)
       {
         result = strtok (temp, "\"");
         result = strtok (NULL, "\"");
       }
     }
   }
-  if ( ! result )
+  if (! result)
   {
     printf ("taler_parse_json: no member named \"%s\" found!\n\n", memberName);
     return EXIT_FAILURE;
   }
   temp = realloc (*returnStr, strlen (result) + 1);
-  if ( ! temp )
+  if (! temp)
   {
     printf ("taler_parse_json: could not allocate memory for member\n");
     return EXIT_FAILURE;
diff --git a/src/configuration.h b/src/configuration.h
index 4e008ab..aa0be01 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -39,7 +39,6 @@ static const char*const JSON_PAY_URI = "taler_pay_uri";
 static const char*const JSON_ORDER_ID = "order_id";
 
 
-
 //// will be replaced with libjansson functionalites 
-----------------------------------------------------------------------------------
 // ajust sprintf in taler_create_order_req communication.c if changed
 static const char*const JSON_ORDER = "{\n"
diff --git a/src/main.c b/src/main.c
index 8fff739..05e6bae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,24 +43,25 @@ ProductOrder product;
 nfc_context *context = NULL;
 
 
-void *start_nfc_transmission (void *ignored)
+void *
+start_nfc_transmission (void *ignored)
 {
   // supress warning about unused variable
   (void) ignored;
 
-  if ( pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0 )
+  if (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, NULL) != 0)
   {
     printf ("Error setting thread cancelling type\n");
   }
   // start endless transmission loop (until threads gets cancelled)
-  while ( 1 )
+  while (1)
   {
-    if ( pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL) != 0 )
+    if (pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL) != 0)
     {
       printf ("Error setting thread cancelling state\n");
     }
     nfc_transmit (context, product.payUrl, strlen (product.payUrl) );
-    if ( pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
+    if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL) != 0)
     {
       printf ("Error setting thread cancelling state\n");
     }
@@ -70,11 +71,12 @@ void *start_nfc_transmission (void *ignored)
 }
 
 
-int main (  )
+int
+main (  )
 {
   // initialize nfc
   nfc_init (&context);
-  if ( ! context )
+  if (! context)
   {
     printf ("Unable to init libnfc\n");
     return EXIT_FAILURE;
@@ -82,25 +84,25 @@ int main (  )
 
   // inizialize taler
   CURL *curl = NULL;
-  if ( taler_init (&curl) )
+  if (taler_init (&curl) )
   {
     printf ("Unable to init taler communication\n");
     return EXIT_FAILURE;
   }
 
   // inizialize product
-  if ( product_init (&product, CURRENCY) )
+  if (product_init (&product, CURRENCY) )
   {
     printf ("Unable to init product\n");
     return EXIT_FAILURE;
   }
 
 
-  while ( true )
+  while (true)
   {
     printf ("Waiting for MBD input\n");
     printf ("Enter to simulate Snickers, x to quit\n");
-    if ( getchar () == 'x' )
+    if (getchar () == 'x')
       break;
 
     // DEMO snickers
@@ -112,7 +114,7 @@ int main (  )
     taler_create_order_req (&product);
 
     // create the order
-    while ( taler_create_order (curl, &product) )
+    while (taler_create_order (curl, &product) )
       ;
 
     // store the order id into the struct
@@ -122,7 +124,7 @@ int main (  )
     product_set_check_url (&product);
 
     // check the payment status for the first time
-    while ( taler_check_payment_status (curl, &product) )
+    while (taler_check_payment_status (curl, &product) )
       ;
 
     // store the url to pay, to do this task the payment status has to be 
called before, because the url will be in the response
@@ -130,19 +132,19 @@ int main (  )
 
     // start a thread to send payment request to taler wallet
     pthread_t nfcThread;
-    if ( pthread_create (&nfcThread, NULL, start_nfc_transmission, NULL) )
+    if (pthread_create (&nfcThread, NULL, start_nfc_transmission, NULL) )
     {
       printf ("Could not create thread");
       return EXIT_FAILURE;
     }
 
     // check the payment status, if paid exit while loop and end thread 
transmitting nfc messages
-    while ( ! product.paid )
+    while (! product.paid)
     {
       printf ("Order payment processing\n");
       fflush (stdout);
       sleep (5);
-      while ( taler_check_payment_status (curl, &product) )
+      while (taler_check_payment_status (curl, &product) )
         ;
       // set the boolean paid member of ProductOrder struct
       product_set_paid_status (&product);
@@ -152,17 +154,17 @@ int main (  )
     printf ("Order no.: %s paid!\n\n", product.orderID);
 
     // send cancel request to nfc thread
-    while ( pthread_cancel (nfcThread) != 0 )
+    while (pthread_cancel (nfcThread) != 0)
     {
       printf ("Error sending cancel request to thread for nfc transmission");
     }
     void*res;
-    if ( pthread_join (nfcThread, &res) == 0 )
+    if (pthread_join (nfcThread, &res) == 0)
     {
       printf ("Thread for nfc transmission finished\n");
       fflush (stdout);
     }
-    else if ( res == PTHREAD_CANCELED )
+    else if (res == PTHREAD_CANCELED)
     {
       printf ("Thread for nfc transmission finished\n");
       fflush (stdout);
diff --git a/src/nfc.c b/src/nfc.c
index 2be0a11..20cdb01 100644
--- a/src/nfc.c
+++ b/src/nfc.c
@@ -29,25 +29,25 @@ along with
 #include "nfc.h"
 #include "wallet.h"
 
-
 // upper and lower bounds for mifare targets uid length
 #define UID_LEN_UPPER 7
 #define UID_LEN_LOWER 4
 
 
-int nfc_transmit (nfc_context *context, const char *talerPayUrl, size_t 
urlSize)
+int
+nfc_transmit (nfc_context *context, const char *talerPayUrl, size_t urlSize)
 {
   nfc_device *pnd;
 
   pnd = nfc_open (context, NULL);    // NULL could be replaced with connstring 
if the correct is known
-  if ( ! pnd )
+  if (! pnd)
   {
     printf ("Unable to open NFC device\n");
     return EXIT_FAILURE;
   }
 
   // initialize device as reader
-  if ( nfc_initiator_init (pnd) < 0 )
+  if (nfc_initiator_init (pnd) < 0)
   {
     nfc_perror (pnd, "nfc_initiator_init");
     nfc_close (pnd);
@@ -60,14 +60,14 @@ int nfc_transmit (nfc_context *context, const char 
*talerPayUrl, size_t urlSize)
   nfc_target nt;
 
   // connect to a target device
-  if ( nfc_connect_target (pnd, &nt) )
+  if (nfc_connect_target (pnd, &nt) )
   {
     nfc_close (pnd);
     return EXIT_FAILURE;
   }
 
   // send the message to the wallet
-  if ( wallet_transmit (pnd, talerPayUrl, urlSize) )
+  if (wallet_transmit (pnd, talerPayUrl, urlSize) )
   {
     // the transmition failed, the target has to be reselected when using 
MIFARE as defined in libnfc --> exit
     nfc_close (pnd);
@@ -81,7 +81,9 @@ int nfc_transmit (nfc_context *context, const char 
*talerPayUrl, size_t urlSize)
   return EXIT_SUCCESS;
 }
 
-int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
+
+int
+nfc_connect_target (nfc_device *pnd, nfc_target *nt)
 {
   const nfc_modulation nmMifare[] = { {
                                         .nmt = NMT_ISO14443A,
@@ -90,21 +92,22 @@ int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
 
   printf ("nfc_connect_target: trying to connect to target\n");
   int ctr = 2;
-  while ( ctr > 0 )
+  while (ctr > 0)
   {
     // set uid lenght to zero ( in case of second selecting the length still 
has the old value )
     nt->nti.nai.szUidLen = 0;
-    if ( nfc_initiator_select_passive_target (pnd, nmMifare[0], NULL, 0, nt) <=
-         0 )
+    if (nfc_initiator_select_passive_target (pnd, nmMifare[0], NULL, 0, nt) <=
+        0)
     {
       printf ("nfc_connect_target: failed to connect\n");
     }
-    else if ((nt->nti.nai.szUidLen > UID_LEN_UPPER) ||(nt->nti.nai.szUidLen <
-                                                       UID_LEN_LOWER) )
+    else if ( (nt->nti.nai.szUidLen > UID_LEN_UPPER) ||
+              (nt->nti.nai.szUidLen < UID_LEN_LOWER) )
     {
       printf ("nfc_connect_target: failed to connect\n");
     }
-    else {
+    else
+    {
       printf ("nfc_connect_target: Target selected!\n");
       nfc_display_target_uid (nt);
       return EXIT_SUCCESS;
@@ -112,14 +115,16 @@ int nfc_connect_target (nfc_device *pnd, nfc_target *nt)
     sleep (1);
     ctr--;
   }
-
   return EXIT_FAILURE;
 }
 
-void nfc_display_target_uid (nfc_target *nt)
+
+void
+nfc_display_target_uid (nfc_target *nt)
 {
   printf ("UID: ");
-  for ( unsigned int uidPos = 0; uidPos < nt->nti.nai.szUidLen; uidPos++ ) {
+  for (unsigned int uidPos = 0; uidPos < nt->nti.nai.szUidLen; uidPos++)
+  {
     printf ("%.2x ", nt->nti.nai.abtUid[uidPos]);
   }
   printf ("\n\n");
diff --git a/src/product.c b/src/product.c
index 7c361e7..522a38c 100644
--- a/src/product.c
+++ b/src/product.c
@@ -31,16 +31,20 @@ the attributes.
 #include "configuration.h"
 #include "communication.h"
 
-void product_reset (ProductOrder *product)
+
+void
+product_reset (ProductOrder *product)
 {
   product->amount = NULL;
   product->product = NULL;
   product->paid = false;
 }
 
-int product_init (ProductOrder *product, const char *currency)
+
+int
+product_init (ProductOrder *product, const char *currency)
 {
-  if ( ! product )
+  if (! product)
   {
     printf ("product_init: product order struct must be provided\n");
     return EXIT_FAILURE;
@@ -48,22 +52,22 @@ int product_init (ProductOrder *product, const char 
*currency)
 
   // malloc for every string member with size 1, every other func just calls 
realloc, because this struct gets used over and over again
   product->response = malloc (sizeof(TalerResponse) );
-  if ( ! product->response )
+  if (! product->response)
   {
     printf ("product_init: unable to allocate memory for response struct\n");
     return EXIT_FAILURE;
   }
-  if ( taler_alloc_string (&(product->response->string), 1) )
+  if (taler_alloc_string (&(product->response->string), 1) )
     return EXIT_FAILURE;
-  if ( taler_alloc_string (&(product->orderID), 1) )
+  if (taler_alloc_string (&(product->orderID), 1) )
     return EXIT_FAILURE;
-  if ( taler_alloc_string (&(product->orderRequest), 1) )
+  if (taler_alloc_string (&(product->orderRequest), 1) )
     return EXIT_FAILURE;
-  if ( taler_alloc_string (&(product->payUrl), 1) )
+  if (taler_alloc_string (&(product->payUrl), 1) )
     return EXIT_FAILURE;
-  if ( taler_alloc_string (&(product->checkUrl), 1) )
+  if (taler_alloc_string (&(product->checkUrl), 1) )
     return EXIT_FAILURE;
-  if ( taler_alloc_string (&(product->currency), strlen (currency) + 1) )
+  if (taler_alloc_string (&(product->currency), strlen (currency) + 1) )
     return EXIT_FAILURE;
   strcpy (product->currency, currency);
   product->amount = NULL;
@@ -73,7 +77,9 @@ int product_init (ProductOrder *product, const char *currency)
   return EXIT_SUCCESS;
 }
 
-void product_exit (ProductOrder *product)
+
+void
+product_exit (ProductOrder *product)
 {
   free (product->response->string);
   free (product->response);
@@ -87,12 +93,14 @@ void product_exit (ProductOrder *product)
   product->paid = false;
 }
 
-int product_set_check_url (ProductOrder *product)
+
+int
+product_set_check_url (ProductOrder *product)
 {
   size_t len = strlen (BACKEND_BASE_URL) + strlen (CHECK);
   char *url = realloc (product->checkUrl, len + strlen (ORDER_CHECK) + strlen (
                          product->orderID) + 1);
-  if ( ! url )
+  if (! url)
   {
     printf ("could not allocate memory for order url\n");
     return EXIT_FAILURE;
@@ -106,25 +114,31 @@ int product_set_check_url (ProductOrder *product)
   return EXIT_SUCCESS;
 }
 
-int product_set_order_id (ProductOrder *product)
+
+int
+product_set_order_id (ProductOrder *product)
 {
   return taler_parse_json (product->response, JSON_ORDER_ID,
                            &(product->orderID), false);
 }
 
-int product_set_pay_url (ProductOrder *product)
+
+int
+product_set_pay_url (ProductOrder *product)
 {
   return taler_parse_json (product->response, JSON_PAY_URI, &(product->payUrl),
                            false);
 }
 
-int product_set_paid_status (ProductOrder *product)
+
+int
+product_set_paid_status (ProductOrder *product)
 {
   char *temp = NULL;
-  if ( taler_alloc_string (&temp, 1) == EXIT_SUCCESS )
+  if (taler_alloc_string (&temp, 1) == EXIT_SUCCESS)
   {
     taler_parse_json (product->response, JSON_PAID, &temp, true);
-    if ( strcmp (temp, "true") == 0 )
+    if (strcmp (temp, "true") == 0)
       product->paid = true;
     free (temp);
     return EXIT_SUCCESS;
diff --git a/src/product.h b/src/product.h
index 6ab1844..c091e63 100644
--- a/src/product.h
+++ b/src/product.h
@@ -51,7 +51,6 @@ typedef struct ProductOrder
   TalerResponse *response;
 } ProductOrder;
 
-
 int product_init (ProductOrder *product, const char*currency);
 
 void product_exit (ProductOrder *product);
diff --git a/src/wallet.c b/src/wallet.c
index 1233223..321f751 100644
--- a/src/wallet.c
+++ b/src/wallet.c
@@ -30,23 +30,24 @@ along with
 #include "wallet.h"
 
 
-int wallet_select_aid (nfc_device *pnd)
+int
+wallet_select_aid (nfc_device *pnd)
 {
   uint8_t response[] = { 0x00, 0x00 };
 
   int size = sizeof(select_file) + sizeof(taler_aid);
   uint8_t message[size];
-  if ( concat_message (select_file, sizeof(select_file), taler_aid, message,
-                       size) )
+  if (concat_message (select_file, sizeof(select_file), taler_aid, message,
+                      size) )
     return EXIT_FAILURE;
 
   printf ("wallet_select_aid: Selecting Taler apk using AID: ");
-  for ( unsigned int i = 0; i < sizeof(taler_aid); ++i )
+  for (unsigned int i = 0; i < sizeof(taler_aid); ++i)
     printf ("%.2x", taler_aid[i]);
   printf ("\n");
 
-  if ( nfc_initiator_transceive_bytes (pnd, message, size, response,
-                                       sizeof(response), TRANSMIT_TIMEOUT) < 0 
)
+  if (nfc_initiator_transceive_bytes (pnd, message, size, response,
+                                      sizeof(response), TRANSMIT_TIMEOUT) < 0)
   {
     printf ("wallet_select_aid: Failed to select apk\n\n");
     return EXIT_FAILURE;
@@ -55,20 +56,22 @@ int wallet_select_aid (nfc_device *pnd)
   return check_response (response, sizeof(response) );
 }
 
-int wallet_put_message (nfc_device *pnd, const char *msg, size_t msgSize)
+
+int
+wallet_put_message (nfc_device *pnd, const char *msg, size_t msgSize)
 {
   uint8_t response[] = { 0x00, 0x00 };
 
   int size = sizeof(put_data) + msgSize;
   uint8_t message[size];
-  if ( concat_message (put_data, sizeof(put_data), (const uint8_t*) msg,
-                       message, size) )
+  if (concat_message (put_data, sizeof(put_data), (const uint8_t*) msg,
+                      message, size) )
     return EXIT_FAILURE;
 
   printf ("wallet_put_messsage: Sending 'PUT DATA' command to wallet\n");
 
-  if ( nfc_initiator_transceive_bytes (pnd, message, size, response,
-                                       sizeof(response), TRANSMIT_TIMEOUT) < 0 
)
+  if (nfc_initiator_transceive_bytes (pnd, message, size, response,
+                                      sizeof(response), TRANSMIT_TIMEOUT) < 0)
   {
     printf ("wallet_put_message: Failed to put message\n\n");
     return EXIT_FAILURE;
@@ -78,33 +81,38 @@ int wallet_put_message (nfc_device *pnd, const char *msg, 
size_t msgSize)
 }
 
 
-int wallet_transmit (nfc_device *pnd, const char *msg, size_t msgLen)
+int
+wallet_transmit (nfc_device *pnd, const char *msg, size_t msgLen)
 {
-  if ( ! msg )
+  if (! msg)
   {
     printf ("wallet_transmit: No message to send\n\n");
     return EXIT_FAILURE;
   }
 
-  if ( wallet_select_aid (pnd) )
+  if (wallet_select_aid (pnd) )
     return EXIT_FAILURE;
   printf ("wallet_transmit: Taler wallet apk selected\n\n");
-  if ( wallet_put_message (pnd, msg, msgLen)  )
+  if (wallet_put_message (pnd, msg, msgLen)  )
     return EXIT_FAILURE;
   printf ("wallet_transmit: Transmitted message to taler wallet\n\n");
 
   return EXIT_SUCCESS;
 }
 
-int check_response (uint8_t *response, uint8_t responseLen)
+
+int
+check_response (uint8_t *response, uint8_t responseLen)
 {
-  if ( strcmp ((char*) response, APDU_SUCCESS) == 0 )
+  if (strcmp ((char*) response, APDU_SUCCESS) == 0)
   {
     printf ("Transmission success\n");
   }
-  else {
+  else
+  {
     printf ("Transmission failure, return code: ");
-    for ( uint8_t i = 0; i < responseLen; ++i ) {
+    for (uint8_t i = 0; i < responseLen; ++i)
+    {
       printf ("%.2x ", response[i]);
     }
     printf ("\n");
@@ -114,20 +122,24 @@ int check_response (uint8_t *response, uint8_t 
responseLen)
   return EXIT_SUCCESS;
 }
 
-int concat_message (const uint8_t*command, size_t commandSize, const
-                    uint8_t*message, uint8_t *retMsg, size_t returnSize)
+
+int
+concat_message (const uint8_t*command, size_t commandSize, const
+                uint8_t*message, uint8_t *retMsg, size_t returnSize)
 {
-  if ( ! command || ! message )
+  if (! command || ! message)
   {
     printf ("concat_message: command and message can't be null");
     return EXIT_FAILURE;
   }
 
   uint8_t i = 0;
-  for (; i < commandSize; ++i ) {
+  for (; i < commandSize; ++i)
+  {
     retMsg[i] = command[i];
   }
-  for (; i < returnSize; ++i) {
+  for (; i < returnSize; ++i)
+  {
     retMsg[i] = message[i - commandSize];
   }
 
diff --git a/src/wallet.h b/src/wallet.h
index 885645c..5944b5d 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -42,8 +42,6 @@ static const uint8_t taler_aid[] = { 0xA0, 0x00, 0x00, 0x02, 
0x47, 0x10, 0x01 };
 static const uint8_t select_file[] = { 0x00, 0xA4, 0x04, 0x00, 0x07 };
 static const uint8_t put_data[] = { 0x00, 0xDA, 0x01, 0x00, 0x7c, 0x01 };
 
-
-
 int wallet_select_aid (nfc_device *pnd);
 
 int wallet_put_message (nfc_device *pnd, const char *msg, size_t msgSize);

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



reply via email to

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