aboutsummaryrefslogtreecommitdiff
path: root/src/json
diff options
context:
space:
mode:
authorLucien Heuzeveldt <lucien.heuzeveldt@gmail.com>2021-12-23 22:49:57 +0100
committerGian Demarmels <gian@demarmels.org>2022-02-04 15:33:07 +0100
commit3225566c93eceb52078fbe13fc301722f349b2c0 (patch)
treef011f29c49103aaf2a573b4711a97d642944037e /src/json
parentdb9b84970dbd5aacc9eca1f19bb03d27a06e3452 (diff)
implement exchange_api_csr
Diffstat (limited to 'src/json')
-rw-r--r--src/json/json_helper.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index 1942d09bd..ef1617ef3 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -658,7 +658,7 @@ TALER_JSON_spec_i18n_str (const char *name,
return ret;
}
-
+//FIXME:
enum GNUNET_GenericReturnValue
TALER_JSON_parse_agemask (const json_t *root,
struct TALER_AgeMask *mask)
@@ -688,6 +688,54 @@ TALER_JSON_parse_agemask (const json_t *root,
}
return GNUNET_OK;
+/**
+ * Parse given JSON object to CS R.
+ *
+ * @param cls closure, NULL
+ * @param root the json object representing data
+ * @param[out] spec where to write the data
+ * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error
+ */
+static enum GNUNET_GenericReturnValue
+parse_csr (void *cls,
+ json_t *root,
+ struct GNUNET_JSON_Specification *spec)
+{
+ struct GNUNET_CRYPTO_CsRPublic *r_pub = spec->ptr;
+
+ struct GNUNET_JSON_Specification dspec[] = {
+ GNUNET_JSON_spec_fixed (spec->field, r_pub, sizeof (struct
+ GNUNET_CRYPTO_CsRPublic)),
+ GNUNET_JSON_spec_end ()
+ };
+ const char *emsg;
+ unsigned int eline;
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (root,
+ dspec,
+ &emsg,
+ &eline))
+ {
+ GNUNET_break_op (0);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+struct GNUNET_JSON_Specification
+TALER_JSON_spec_csr (const char *field,
+ struct GNUNET_CRYPTO_CsRPublic *r_pub)
+{
+ struct GNUNET_JSON_Specification ret = {
+ .parser = &parse_csr,
+ .cleaner = NULL,
+ .field = field,
+ .ptr = r_pub
+ };
+
+ return ret;
}