commit d0f3643c3166bd41bcf16c71e1ea4db829704122
parent 3e131ed22a9e809e8a7ba79e853bef83fab3823f
Author: Boss Marco <bossm8@students.bfh.ch>
Date: Mon, 11 Nov 2019 17:53:55 +0100
first steps in configurable products
Diffstat:
| M | src/main.c | | | 55 | ++++++++++++++++++++++++++++--------------------------- |
1 file changed, 28 insertions(+), 27 deletions(-)
diff --git a/src/main.c b/src/main.c
@@ -42,7 +42,7 @@ along with
#define NFC_TIMEOUT 500
#define MAX_HTTP_RETRY_FREQ GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MILLISECONDS, 500)
+ GNUNET_TIME_UNIT_MILLISECONDS, 500)
/**
* Code returned by libnfc in case of success.
@@ -209,9 +209,9 @@ shutdown_task (void *cls)
{
for (unsigned int i = 0; NrOfProducts > i; i++)
{
- GNUNET_free(products[i].description);
- GNUNET_free(products[i].price);
- GNUNET_free(products[i].number);
+ GNUNET_free (products[i].description);
+ GNUNET_free (products[i].price);
+ GNUNET_free (products[i].number);
}
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -264,7 +264,7 @@ wallet_transmit_uri (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"'PUT DATA' command transmission failed, return code: %x%x\n",
response[0],
- response[1]);
+ response[1]);
pa->task = GNUNET_SCHEDULER_add_now (&connect_target,
pa);
return;
@@ -328,7 +328,7 @@ wallet_select_aid (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"AID selection failure, return code: %x%x, trying to find another NFC client\n",
response[0],
- response[1]);
+ response[1]);
pa->task = GNUNET_SCHEDULER_add_delayed (NFC_FAILURE_RETRY_FREQ,
&connect_target,
pa);
@@ -663,15 +663,15 @@ start_read_keyboard ()
}
static void
-read_products (void* cls,
+read_products (void*cls,
const char *section)
{
struct Product tmpProduct;
- char* tmpKey;
+ char*tmpKey;
- if(0 == strncmp(section,
- "product",
- strlen("product")))
+ if (0 == strncmp (section,
+ "product",
+ strlen ("product")))
{
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cls,
@@ -707,7 +707,7 @@ read_products (void* cls,
return;
}
tmpProduct.key = tmpKey[0];
- GNUNET_free(tmpKey);
+ GNUNET_free (tmpKey);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cls,
section,
@@ -720,24 +720,25 @@ read_products (void* cls,
return;
}
NrOfProducts++;
- if(NULL == products)
+ if (NULL == products)
/*products = GNUNET_new_array(1,
sizeof(struct Product)); */
- products = GNUNET_new(struct Product);
+ products = GNUNET_new (struct Product);
else
/*GNUNET_array_grow(products,
sizeof(products),
sizeof(products)+sizeof(struct Product)); NOT WORKING ? */
- products = GNUNET_realloc(products,
- NrOfProducts*sizeof(struct Product));
+ products = GNUNET_realloc (products,
+ NrOfProducts * sizeof(struct Product));
- products[NrOfProducts-1].description = GNUNET_strdup(tmpProduct.description);
- GNUNET_free(tmpProduct.description);
- products[NrOfProducts-1].price = GNUNET_strdup(tmpProduct.price);
- GNUNET_free(tmpProduct.price);
- products[NrOfProducts-1].number = GNUNET_strdup(tmpProduct.number);
- GNUNET_free(tmpProduct.number);
- products[NrOfProducts-1].key = tmpProduct.key;
+ products[NrOfProducts - 1].description = GNUNET_strdup (
+ tmpProduct.description);
+ GNUNET_free (tmpProduct.description);
+ products[NrOfProducts - 1].price = GNUNET_strdup (tmpProduct.price);
+ GNUNET_free (tmpProduct.price);
+ products[NrOfProducts - 1].number = GNUNET_strdup (tmpProduct.number);
+ GNUNET_free (tmpProduct.number);
+ products[NrOfProducts - 1].key = tmpProduct.key;
}
}
@@ -820,10 +821,10 @@ run (void *cls,
global_ret = EXIT_FAILURE;
return;
}
- GNUNET_CONFIGURATION_iterate_sections(cfg,
- &read_products,
- (void*)cfg);
- GNUNET_assert(NULL != products);
+ GNUNET_CONFIGURATION_iterate_sections (cfg,
+ &read_products,
+ (void *) cfg);
+ GNUNET_assert (NULL != products);
GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
NULL);