aboutsummaryrefslogtreecommitdiff
path: root/src/mint-lib/mint_api_json.c
diff options
context:
space:
mode:
authorFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-08-10 15:11:11 +0200
committerFournier Nicolas <nicolas.fournier@ensta-paristech.fr>2015-08-10 15:11:11 +0200
commitd6c1340bcdfef8228a7802bf046f4f8babf44f5e (patch)
tree0a4c8f5f68c8e566768651aba342877337525b12 /src/mint-lib/mint_api_json.c
parentb02dc90ba08d0653bfd121f87425804c10901f23 (diff)
parentcf3345a96f4e5c3fc1085052170e79adfaaff220 (diff)
Merge branch 'master' of taler.net:/var/git/mint
Diffstat (limited to 'src/mint-lib/mint_api_json.c')
-rw-r--r--src/mint-lib/mint_api_json.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/mint-lib/mint_api_json.c b/src/mint-lib/mint_api_json.c
index 8b0b5437..b1517394 100644
--- a/src/mint-lib/mint_api_json.c
+++ b/src/mint-lib/mint_api_json.c
@@ -253,6 +253,37 @@ parse_json (json_t *root,
}
break;
+ case MAJ_CMD_UINT16:
+ {
+ json_int_t val;
+
+ if (! json_is_integer (pos))
+ {
+ GNUNET_break_op (0);
+ return i;
+ }
+ val = json_integer_value (pos);
+ if ( (0 > val) || (val > UINT16_MAX) )
+ {
+ GNUNET_break_op (0);
+ return i;
+ }
+ *spec[i].details.u16 = (uint16_t) val;
+ }
+ break;
+
+ case MAJ_CMD_JSON_OBJECT:
+ {
+ if (! (json_is_object (pos) || json_is_array (pos)) )
+ {
+ GNUNET_break_op (0);
+ return i;
+ }
+ json_incref (pos);
+ *spec[i].details.obj = pos;
+ }
+ break;
+
default:
GNUNET_break (0);
return i;
@@ -307,6 +338,10 @@ parse_free (struct MAJ_Specification *spec,
GNUNET_free (*spec[i].details.eddsa_signature.purpose_p);
*spec[i].details.eddsa_signature.purpose_p = NULL;
break;
+ case MAJ_CMD_JSON_OBJECT:
+ json_decref (*spec[i].details.obj);
+ *spec[i].details.obj = NULL;
+ break;
default:
GNUNET_break (0);
break;
@@ -418,6 +453,46 @@ MAJ_spec_amount (const char *name,
/**
+ * 16-bit integer.
+ *
+ * @param name name of the JSON field
+ * @param[out] u16 where to store the integer found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_uint16 (const char *name,
+ uint16_t *u16)
+{
+ struct MAJ_Specification ret =
+ {
+ .cmd = MAJ_CMD_UINT16,
+ .field = name,
+ .details.u16 = u16
+ };
+ return ret;
+}
+
+
+/**
+ * JSON object.
+ *
+ * @param name name of the JSON field
+ * @param[out] jsonp where to store the JSON found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_json (const char *name,
+ json_t **jsonp)
+{
+ struct MAJ_Specification ret =
+ {
+ .cmd = MAJ_CMD_JSON_OBJECT,
+ .field = name,
+ .details.obj = jsonp
+ };
+ return ret;
+}
+
+
+/**
* Specification for parsing an RSA public key.
*
* @param name name of the JSON field