gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taler-mdb] branch master updated (5e1227f -> b78da91)


From: gnunet
Subject: [taler-taler-mdb] branch master updated (5e1227f -> b78da91)
Date: Fri, 24 Jan 2020 12:36:38 +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 5e1227f  merge
     new 09cf042  fix style issues
     new b78da91  fix style issues (merge)

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:
 src/main.c | 219 +++++++++++++++++++++++++++++++------------------------------
 1 file changed, 111 insertions(+), 108 deletions(-)

diff --git a/src/main.c b/src/main.c
index 2127a7b..a1cdcfc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -590,17 +590,17 @@ static char *currency;
 /**
  * Taler Backend url read from configuration file
  */
-static char *backendBaseUrl;
+static char *backend_base_url;
 
 /**
  * Taler fulfillment url read from configuration file
  */
-static char *fulfillmentUrl;
+static char *fulfillment_url;
 
 /**
  * Fulfillment message to display after successfull payment, read from 
configuration file
  */
-static char *fulfillmentMsg;
+static char *fulfillment_msg;
 
 /**
  * Authorization for the taler backend
@@ -630,57 +630,57 @@ static struct MdbHandle mdb;
 /**
  * MDB response to the request for configuration.
  */
-static struct MdbCommand readerConfigData;
+static struct MdbCommand cmd_reader_config_data;
 
 /**
  * Ask MDB to begin session (with "infinite" money)
  */
-static struct MdbCommand beginSession;
+static struct MdbCommand cmd_begin_session;
 
 /**
  * Refuse vending request (payment failed)
  */
-static struct MdbCommand denyVend;
+static struct MdbCommand cmd_deny_vend;
 
 /**
  * Approve vending request (payment succeeded)
  */
-static struct MdbCommand approveVend;
+static struct MdbCommand cmd_approve_vend;
 
 /**
  * Confirm cancellation by machine.
  */
-static struct MdbCommand readerCancelled;
+static struct MdbCommand cmd_reader_cancelled;
 
 /**
  * Approve Revalue
  */
-static struct MdbCommand revalueApproved;
+static struct MdbCommand cmd_revalue_approved;
 
 /**
  * Send Revalue Limit Amount
  */
-static struct MdbCommand revalueAmount;
+static struct MdbCommand cmd_revalue_amount;
 
 /**
  * Send NACK
  */
-static struct MdbCommand readerNACK;
+static struct MdbCommand cmd_reader_NACK;
 
 /**
  * Display Request for Sold Out
  */
-static struct MdbCommand readerDisplaySoldOut;
+static struct MdbCommand cmd_reader_display_sold_out;
 
 /**
  * Display Request for Error Message
  */
-static struct MdbCommand readerDisplayInternalError;
+static struct MdbCommand cmd_reader_display_internal_error;
 
 /**
  * Display Request for Error Message
  */
-static struct MdbCommand readerDisplayBackendNotReachable;
+static struct MdbCommand cmd_reader_display_backend_not_reachable;
 
 /**
  * Terminate session.
@@ -715,7 +715,7 @@ static char backlight_off = '0';
 /**
  * State for the implementation of the 'cancel' button.
  */
-static struct CancelButton cancelButton;
+static struct CancelButton cancel_button;
 
 /**
  * Name of the UART device with the MDB (i.e. /dev/ttyAMA0).
@@ -945,7 +945,7 @@ cleanup_payment (struct PaymentActivity *pa)
  * @brief Shutdown the mdb communication tasks
  */
 static void
-mdb_shutdown ()
+mdb_shutdown (void)
 {
   if (NULL != mdb.rtask)
   {
@@ -1059,18 +1059,18 @@ shutdown_task (void *cls)
       close (qrDisplay.backlightfd);
     qrDisplay.backlightfd = -1;
   }
-  if (0 < cancelButton.cancelbuttonfd)
+  if (0 < cancel_button.cancelbuttonfd)
   {
-    close (cancelButton.cancelbuttonfd);
-    cancelButton.cancelbuttonfd = open ("/sys/class/gpio/unexport",
-                                        O_WRONLY);
-    if (0 > cancelButton.cancelbuttonfd)
+    close (cancel_button.cancelbuttonfd);
+    cancel_button.cancelbuttonfd = open ("/sys/class/gpio/unexport",
+                                         O_WRONLY);
+    if (0 > cancel_button.cancelbuttonfd)
     {
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Unable to open /gpio/unexport for cancel button\n");
     }
-    (void) write (cancelButton.cancelbuttonfd, "23", 2);
-    close (cancelButton.cancelbuttonfd);
+    (void) write (cancel_button.cancelbuttonfd, "23", 2);
+    close (cancel_button.cancelbuttonfd);
   }
   /* free the allocated productes read from config file */
   if (NULL != products)
@@ -1371,7 +1371,7 @@ check_payment_cb (void *cls,
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Backend request to /check-payment failed: %u\n",
                 http_status);
-    mdb.cmd = &readerDisplayBackendNotReachable;
+    mdb.cmd = &cmd_reader_display_backend_not_reachable;
     run_mdb_event_loop ();
     cleanup_payment (pa);
     GNUNET_assert (payment_activity == pa);
@@ -1381,7 +1381,7 @@ check_payment_cb (void *cls,
 
   if (paid)
   {
-    mdb.cmd = &approveVend;
+    mdb.cmd = &cmd_approve_vend;
     payment_activity->paid = GNUNET_YES;
     run_mdb_event_loop ();
     if ((disable_mdb) && (! disable_tty))
@@ -1435,7 +1435,7 @@ check_payment_again (void *cls)
   pa->delay_pay_task = NULL;
   GNUNET_assert (NULL == pa->cpo);
   pa->cpo = TALER_MERCHANT_check_payment (ctx,
-                                          backendBaseUrl,
+                                          backend_base_url,
                                           pa->order_id,
                                           NULL /* snack machine, no Web crap 
*/,
                                           BACKEND_POLL_TIMEOUT,
@@ -1470,7 +1470,7 @@ proposal_cb (void *cls,
                 "Failed to setup order with backend: %u/%d\n",
                 http_status,
                 (int) ec);
-    mdb.cmd = &readerDisplayBackendNotReachable;
+    mdb.cmd = &cmd_reader_display_backend_not_reachable;
     run_mdb_event_loop ();
     cleanup_payment (pa);
     GNUNET_assert (payment_activity == pa);
@@ -1482,7 +1482,7 @@ proposal_cb (void *cls,
               order_id);
   pa->order_id = GNUNET_strdup (order_id);
   pa->cpo = TALER_MERCHANT_check_payment (ctx,
-                                          backendBaseUrl,
+                                          backend_base_url,
                                           pa->order_id,
                                           NULL /* snack machine, no Web crap 
*/,
                                           GNUNET_TIME_UNIT_ZERO,
@@ -1519,8 +1519,8 @@ launch_payment (struct Product *product)
   /* create the fulfillment url, e.g. 
"taler://fulfillment-success/Enjoy+your+ice+cream!"; */
   GNUNET_asprintf (&fulflmntUrl,
                    "%s%s%s#%s",
-                   fulfillmentUrl,
-                   fulfillmentMsg,
+                   fulfillment_url,
+                   fulfillment_msg,
                    product->description,
                    uuid_s);
   GNUNET_free (uuid_s);
@@ -1544,7 +1544,7 @@ launch_payment (struct Product *product)
   pa->amount = product->price;
   /* put the order on the merchant's backend */
   pa->po = TALER_MERCHANT_order_put (ctx,
-                                     backendBaseUrl,
+                                     backend_base_url,
                                      orderReq,
                                      &proposal_cb,
                                      pa);
@@ -1557,7 +1557,7 @@ launch_payment (struct Product *product)
     return NULL;
   }
   /* Start to read the button on the VM to cancel this payment */
-  if (0 < cancelButton.cancelbuttonfd)
+  if (0 < cancel_button.cancelbuttonfd)
     start_read_cancel_button ();
   return pa;
 }
@@ -1635,7 +1635,7 @@ vend_failure ()
   mdb.session_running = GNUNET_NO;
   r = GNUNET_new (struct Refund);
   r->rio = TALER_MERCHANT_refund_increase (ctx,
-                                           backendBaseUrl,
+                                           backend_base_url,
                                            payment_activity->order_id,
                                            &payment_activity->amount,
                                            "failed to dispense product",
@@ -1687,7 +1687,7 @@ read_keyboard_command (void *cls)
     case 'c':
       if (GNUNET_NO == payment_activity->paid)
       {
-        mdb.cmd = &denyVend;
+        mdb.cmd = &cmd_deny_vend;
       }
       else
       {
@@ -1700,7 +1700,7 @@ read_keyboard_command (void *cls)
       break;
     case 'a':
       payment_activity->paid = GNUNET_YES;
-      mdb.cmd = &approveVend;
+      mdb.cmd = &cmd_approve_vend;
       run_mdb_event_loop ();
       break;
     case 'n':
@@ -1750,7 +1750,7 @@ read_keyboard_command (void *cls)
         GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                     "Product %s sold out, denying vend\n",
                     products[i].description);
-        mdb.cmd = &readerDisplaySoldOut;
+        mdb.cmd = &cmd_reader_display_sold_out;
         run_mdb_event_loop ();
         start_read_keyboard ();
         return;
@@ -1777,8 +1777,8 @@ cancel_button_pressed (void *cls)
   char value;
   cancelbutton_task = NULL;
 
-  read (cancelButton.cancelbuttonfd, &value, 1);
-  lseek (cancelButton.cancelbuttonfd, 0, SEEK_SET);
+  read (cancel_button.cancelbuttonfd, &value, 1);
+  lseek (cancel_button.cancelbuttonfd, 0, SEEK_SET);
   /* This point should only be reached  when a order is pending, because
    * the scheduler read file gets added in the function "launch_payment".
    * But anyway safe check, else do nothing */
@@ -1791,7 +1791,7 @@ cancel_button_pressed (void *cls)
       if (GNUNET_NO == payment_activity->paid)
       {
         /* The current payment was not paid already, deny it */
-        mdb.cmd = &denyVend;
+        mdb.cmd = &cmd_deny_vend;
       }
       else
       {
@@ -1856,7 +1856,7 @@ start_read_keyboard ()
 static void
 start_read_cancel_button ()
 {
-  struct GNUNET_DISK_FileHandle fh = { cancelButton.cancelbuttonfd };
+  struct GNUNET_DISK_FileHandle fh = { cancel_button.cancelbuttonfd };
 
   GNUNET_assert (NULL == cancelbutton_task);
   cancelbutton_task = GNUNET_SCHEDULER_add_read_file (
@@ -1981,19 +1981,19 @@ write_mdb_command (void *cls)
 static void
 handle_ack ()
 {
-  if (&beginSession == mdb.last_cmd)
+  if (&cmd_begin_session == mdb.last_cmd)
     mdb.session_running = GNUNET_YES;
-  if (&denyVend == mdb.last_cmd)
+  if (&cmd_deny_vend == mdb.last_cmd)
   {
     mdb.session_running = GNUNET_NO;
     mdb.cmd = &endSession;
   }
-  if (&readerDisplaySoldOut == mdb.last_cmd)
-    mdb.cmd = &denyVend;
-  if (&readerDisplayInternalError == mdb.last_cmd)
-    mdb.cmd = &denyVend;
-  if (&readerDisplayBackendNotReachable == mdb.last_cmd)
-    mdb.cmd = &denyVend;
+  if (&cmd_reader_display_sold_out == mdb.last_cmd)
+    mdb.cmd = &cmd_deny_vend;
+  if (&cmd_reader_display_internal_error == mdb.last_cmd)
+    mdb.cmd = &cmd_deny_vend;
+  if (&cmd_reader_display_backend_not_reachable == mdb.last_cmd)
+    mdb.cmd = &cmd_deny_vend;
   mdb.last_cmd = NULL;
   /* Cause the write-task to be re-scheduled now */
   if (NULL != mdb.wtask)
@@ -2091,7 +2091,7 @@ handle_command (const char *hex,
           }
           if ( ((uint8_t) (chkSum & 0xFF)) != tmp )
           {
-            mdb.cmd = &readerDisplayInternalError;
+            mdb.cmd = &cmd_reader_display_internal_error;
             GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                         "Received command with wrong checksum `%.*s'\n",
                         (int) hex_len,
@@ -2132,7 +2132,7 @@ handle_command (const char *hex,
                 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                             "Product %s sold out, denying vend\n",
                             products[i].description);
-                mdb.cmd = &readerDisplaySoldOut;
+                mdb.cmd = &cmd_reader_display_sold_out;
                 return;
               }
               payment_activity = launch_payment (&products[i]);
@@ -2141,7 +2141,7 @@ handle_command (const char *hex,
           GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                       "Unknown product %u selected on MDB, denying vend\n",
                       product);
-          mdb.cmd = &denyVend;
+          mdb.cmd = &cmd_deny_vend;
           break;
         }
       case VMC_VEND_SUCCESS:
@@ -2202,14 +2202,14 @@ handle_command (const char *hex,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                       "Received request for revalue via MDB\n");
-          mdb.cmd = &revalueApproved;
+          mdb.cmd = &cmd_revalue_approved;
           break;
         }
       case VMC_REVALUE_LIMIT_REQUEST:
         {
           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                       "Received request for revalue limit amount via MDB\n");
-          mdb.cmd = &revalueAmount;
+          mdb.cmd = &cmd_revalue_amount;
           break;
         }
       default:
@@ -2247,7 +2247,7 @@ handle_command (const char *hex,
         {
           GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                       "Received request for configuration via MDB\n");
-          mdb.cmd = &readerConfigData;
+          mdb.cmd = &cmd_reader_config_data;
           break;
 
         }
@@ -2324,7 +2324,7 @@ handle_command (const char *hex,
         mdb.session_running = GNUNET_NO;
         break;
       case VMC_READER_CANCEL:
-        mdb.cmd = &readerCancelled;
+        mdb.cmd = &cmd_reader_cancelled;
         mdb.session_running = GNUNET_NO;
         break;
       default:
@@ -2470,7 +2470,7 @@ run_mdb_event_loop ()
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "Begining MDB session\n");
-    mdb.cmd = &beginSession;
+    mdb.cmd = &cmd_begin_session;
   }
   /* start write task if he doesn't exist and if there is a cmd waiting to get 
sent */
   if ( (NULL == mdb.wtask) &&
@@ -2746,7 +2746,7 @@ run (void *cls,
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              "taler-mdb",
                                              "backend-base-url",
-                                             &backendBaseUrl))
+                                             &backend_base_url))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "taler-mdb",
@@ -2779,7 +2779,7 @@ run (void *cls,
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              "taler-mdb",
                                              "fulfillment-url",
-                                             &fulfillmentUrl))
+                                             &fulfillment_url))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "taler-mdb",
@@ -2791,7 +2791,7 @@ run (void *cls,
       GNUNET_CONFIGURATION_get_value_string (cfg,
                                              "taler-mdb",
                                              "fulfillment-msg",
-                                             &fulfillmentMsg))
+                                             &fulfillment_msg))
   {
     GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
                                "taler-mdb",
@@ -2839,29 +2839,29 @@ run (void *cls,
                                             authorization));
 
   /* open gpio pin for cance button */
-  cancelButton.cancelbuttonfd = open ("/sys/class/gpio/export",
-                                      O_WRONLY);
-  if (0 > cancelButton.cancelbuttonfd)
+  cancel_button.cancelbuttonfd = open ("/sys/class/gpio/export",
+                                       O_WRONLY);
+  if (0 > cancel_button.cancelbuttonfd)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Unable to open /gpio/export for cancel button\n");
   }
-  (void) write (cancelButton.cancelbuttonfd, "23", 2);
-  close (cancelButton.cancelbuttonfd);
+  (void) write (cancel_button.cancelbuttonfd, "23", 2);
+  close (cancel_button.cancelbuttonfd);
 
-  cancelButton.cancelbuttonfd = open ("/sys/class/gpio/gpio23/direction",
-                                      O_WRONLY);
-  if (0 > cancelButton.cancelbuttonfd)
+  cancel_button.cancelbuttonfd = open ("/sys/class/gpio/gpio23/direction",
+                                       O_WRONLY);
+  if (0 > cancel_button.cancelbuttonfd)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Unable to open /gpio/gpio23/direction for cancel button\n");
   }
-  (void) write (cancelButton.cancelbuttonfd, "in", 2);
-  close (cancelButton.cancelbuttonfd);
+  (void) write (cancel_button.cancelbuttonfd, "in", 2);
+  close (cancel_button.cancelbuttonfd);
 
-  cancelButton.cancelbuttonfd = open ("/sys/class/gpio/gpio23/value",
-                                      O_RDONLY);
-  if (0 > cancelButton.cancelbuttonfd)
+  cancel_button.cancelbuttonfd = open ("/sys/class/gpio/gpio23/value",
+                                       O_RDONLY);
+  if (0 > cancel_button.cancelbuttonfd)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                 "Unable to open /gpio/gpio23/value for cancel button\n");
@@ -3058,50 +3058,53 @@ main (int argc,
     }
   }
   /* make the needed commands for the communication with the vending machine 
controller */
-  readerConfigData = setup_mdb_cmd ("Reader Config",
-                                    READER_CONFIG,
-                                    READER_FEATURE_LEVEL READER_COUNTRYCODE
-                                    READER_SCALE_FACTOR READER_DECIMAL_PLACES
-                                    READER_MAX_RESPONSE_TIME
-                                    READER_MISC_OPTIONS);
-  beginSession = setup_mdb_cmd ("Begin Session",
-                                READER_BEGIN_SESSION,
-                                READER_FUNDS_AVAILABLE);
-  approveVend = setup_mdb_cmd ("Approve Vend",
-                               READER_VEND_APPROVE,
-                               READER_VEND_AMOUNT);
-  readerCancelled = setup_mdb_cmd ("Confirm cancellation",
-                                   READER_CANCELLED,
-                                   NULL);
-  denyVend = setup_mdb_cmd ("Deny Vend",
-                            READER_VEND_DENIED,
-                            NULL);
+  cmd_reader_config_data = setup_mdb_cmd ("Reader Config",
+                                          READER_CONFIG,
+                                          READER_FEATURE_LEVEL
+                                          READER_COUNTRYCODE
+                                          READER_SCALE_FACTOR
+                                          READER_DECIMAL_PLACES
+                                          READER_MAX_RESPONSE_TIME
+                                          READER_MISC_OPTIONS);
+  cmd_begin_session = setup_mdb_cmd ("Begin Session",
+                                     READER_BEGIN_SESSION,
+                                     READER_FUNDS_AVAILABLE);
+  cmd_approve_vend = setup_mdb_cmd ("Approve Vend",
+                                    READER_VEND_APPROVE,
+                                    READER_VEND_AMOUNT);
+  cmd_reader_cancelled = setup_mdb_cmd ("Confirm cancellation",
+                                        READER_CANCELLED,
+                                        NULL);
+  cmd_deny_vend = setup_mdb_cmd ("Deny Vend",
+                                 READER_VEND_DENIED,
+                                 NULL);
   endSession = setup_mdb_cmd ("End Session",
                               READER_END_SESSION,
                               NULL);
-  revalueApproved = setup_mdb_cmd ("Reader Approve Revalue",
-                                   READER_REVALUE_APPROVED,
-                                   NULL);
+  cmd_revalue_approved = setup_mdb_cmd ("Reader Approve Revalue",
+                                        READER_REVALUE_APPROVED,
+                                        NULL);
 
-  revalueAmount = setup_mdb_cmd ("Send Revalue Limit Amount",
-                                 READER_REVALUE_LIMIT,
-                                 READER_REVALUE_LIMIT_AMOUNT);
+  cmd_revalue_amount = setup_mdb_cmd ("Send Revalue Limit Amount",
+                                      READER_REVALUE_LIMIT,
+                                      READER_REVALUE_LIMIT_AMOUNT);
 
-  readerNACK = setup_mdb_cmd ("Reader NACK",
-                              READER_NACK,
-                              NULL);
+  cmd_reader_NACK = setup_mdb_cmd ("Reader NACK",
+                                   READER_NACK,
+                                   NULL);
 
-  readerDisplaySoldOut = setup_mdb_cmd ("Display Sold Out",
-                                        READER_DISPLAY_REQUEST,
-                                        READER_DISPLAY_REQUEST_TIME
-                                        READER_DISPLAY_SOLD_OUT);
+  cmd_reader_display_sold_out = setup_mdb_cmd ("Display Sold Out",
+                                               READER_DISPLAY_REQUEST,
+                                               READER_DISPLAY_REQUEST_TIME
+                                               READER_DISPLAY_SOLD_OUT);
 
-  readerDisplayInternalError = setup_mdb_cmd ("Display Communication Error",
-                                              READER_DISPLAY_REQUEST,
-                                              READER_DISPLAY_REQUEST_TIME
-                                              READER_DISPLAY_INTERNAL_ERROR);
+  cmd_reader_display_internal_error = setup_mdb_cmd (
+    "Display Communication Error",
+    READER_DISPLAY_REQUEST,
+    READER_DISPLAY_REQUEST_TIME
+    READER_DISPLAY_INTERNAL_ERROR);
 
-  readerDisplayBackendNotReachable = setup_mdb_cmd (
+  cmd_reader_display_backend_not_reachable = setup_mdb_cmd (
     "Display Backend not reachable",
     READER_DISPLAY_REQUEST,
     READER_DISPLAY_REQUEST_TIME

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



reply via email to

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