diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-11-25 21:28:17 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-11-25 21:28:17 +0100 |
commit | 47223238c240493887e1222ef76950e60871e84f (patch) | |
tree | 331c15586b9f843650bd721d1d76bb2a22c0ff5f | |
parent | fdc4ee8b9ab1c31abc5eaaf42b236b984dc2692b (diff) | |
download | merchant-47223238c240493887e1222ef76950e60871e84f.tar.gz merchant-47223238c240493887e1222ef76950e60871e84f.tar.bz2 merchant-47223238c240493887e1222ef76950e60871e84f.zip |
more cleanup of auditors logic
-rw-r--r-- | src/backend/taler-merchant-httpd.h | 11 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_auditors.c | 50 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_auditors.h | 18 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_contract.c | 12 |
4 files changed, 58 insertions, 33 deletions
diff --git a/src/backend/taler-merchant-httpd.h b/src/backend/taler-merchant-httpd.h index 26982c6d..3acff594 100644 --- a/src/backend/taler-merchant-httpd.h +++ b/src/backend/taler-merchant-httpd.h @@ -89,17 +89,6 @@ struct TMH_RequestHandler }; - -struct MERCHANT_Auditor -{ - /** - * Auditor's legal name - */ - char *name; - -}; - - /** * Each MHD response handler that sets the "connection_cls" to a * non-NULL value must use a struct that has this struct as its first diff --git a/src/backend/taler-merchant-httpd_auditors.c b/src/backend/taler-merchant-httpd_auditors.c index ba3c63fc..8b7a5eb6 100644 --- a/src/backend/taler-merchant-httpd_auditors.c +++ b/src/backend/taler-merchant-httpd_auditors.c @@ -23,28 +23,39 @@ #include "taler-merchant-httpd_auditors.h" /** - * Active auditors + * Our representation of an auditor. + */ +struct MERCHANT_Auditor +{ + /** + * Auditor's legal name (FIXME: this is not what we really want.) + */ + char *name; + +}; + + +/** + * Array of the auditors this merchant is willing to accept. */ static struct MERCHANT_Auditor *auditors; /** - * The number of active auditors + * The length of the #auditors array. */ static unsigned int nauditors; /** - * Array of auditors accepted by this mint. + * JSON representation of the auditors accepted by this mint. */ json_t *j_auditors; /** - * Parses auditors from the configuration. + * Parses auditor information from the configuration. * * @param cfg the configuration - * @param mints the array of auditors upon successful parsing. Will be NULL upon - * error. - * @return the number of auditors in the above array; #GNUNET_SYSERR upon error in + * @return the number of auditors found; #GNUNET_SYSERR upon error in * parsing. */ int @@ -106,11 +117,30 @@ TMH_AUDITORS_init (const struct GNUNET_CONFIGURATION_Handle *cfg) /* Generate preferred mint(s) array. */ j_auditors = json_array (); for (cnt = 0; cnt < nauditors; cnt++) - { json_array_append_new (j_auditors, json_pack ("{s:s}", "name", auditors[cnt].name)); - } - return nauditors; } + + +/** + * Release auditor information state. + */ +void +TMH_AUDITORS_done () +{ + unsigned int i; + + json_decref (j_auditors); + j_auditors = NULL; + for (i=0;i<nauditors;i++) + { + GNUNET_free (auditors[i].name); + } + GNUNET_free (auditors); + auditors = NULL; + nauditors = 0; +} + +/* end of taler-merchant-httpd_auditors.c */ diff --git a/src/backend/taler-merchant-httpd_auditors.h b/src/backend/taler-merchant-httpd_auditors.h index 3cbc4e1b..92d2bc7e 100644 --- a/src/backend/taler-merchant-httpd_auditors.h +++ b/src/backend/taler-merchant-httpd_auditors.h @@ -24,29 +24,35 @@ #include <jansson.h> #include <gnunet/gnunet_util_lib.h> -#include <curl/curl.h> #include <taler/taler_util.h> #include <taler/taler_mint_service.h> #include "taler-merchant-httpd.h" /** - * Array of auditors accepted by this mint. + * JSON representation of the auditors accepted by this mint. */ extern json_t *j_auditors; /** - * Parses auditors from the configuration. + * Parses auditor information from the configuration. * * @param cfg the configuration - * @param mints the array of auditors upon successful parsing. Will be NULL upon - * error. - * @return the number of auditors in the above array; #GNUNET_SYSERR upon error in + * @return the number of auditors found; #GNUNET_SYSERR upon error in * parsing. */ int TMH_AUDITORS_init (const struct GNUNET_CONFIGURATION_Handle *cfg); +/** + * Release auditor information state. + */ +void +TMH_AUDITORS_done (void); + + + + #endif diff --git a/src/backend/taler-merchant-httpd_contract.c b/src/backend/taler-merchant-httpd_contract.c index f2aca318..93292c87 100644 --- a/src/backend/taler-merchant-httpd_contract.c +++ b/src/backend/taler-merchant-httpd_contract.c @@ -69,12 +69,12 @@ MH_handler_contract (struct TMH_RequestHandler *rh, return MHD_YES; /* add fields to the "root" that the backend should provide */ - json_object_set_new (root, - "mints", - trusted_mints); - json_object_set_new (root, - "auditors", - j_auditors); + json_object_set (root, + "mints", + trusted_mints); + json_object_set (root, + "auditors", + j_auditors); json_object_set_new (root, "H_wire", TALER_json_from_data (&h_wire, |