summaryrefslogtreecommitdiff
path: root/src/mint-lib/mint_api_json.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-06-20 22:40:06 +0200
committerChristian Grothoff <christian@grothoff.org>2015-06-20 22:40:06 +0200
commit61752e033436d73c7a70bc12d5be4706f1595ab6 (patch)
tree459abddec65b460ce4b1473ed96d8a5df3d6ed21 /src/mint-lib/mint_api_json.h
parente2d453f1d2c9db904f2d3dc3146c7fc3f2565bef (diff)
downloadexchange-61752e033436d73c7a70bc12d5be4706f1595ab6.tar.gz
exchange-61752e033436d73c7a70bc12d5be4706f1595ab6.tar.bz2
exchange-61752e033436d73c7a70bc12d5be4706f1595ab6.zip
simplify /keys parser by using json parser interpreter
Diffstat (limited to 'src/mint-lib/mint_api_json.h')
-rw-r--r--src/mint-lib/mint_api_json.h66
1 files changed, 63 insertions, 3 deletions
diff --git a/src/mint-lib/mint_api_json.h b/src/mint-lib/mint_api_json.h
index 87afbd44b..78107ed9e 100644
--- a/src/mint-lib/mint_api_json.h
+++ b/src/mint-lib/mint_api_json.h
@@ -129,7 +129,7 @@ struct MAJ_Specification
/**
* How many bytes to write to @e dest.
*/
- size_t dest_len;
+ size_t dest_size;
} fixed_data;
@@ -145,7 +145,7 @@ struct MAJ_Specification
/**
* Where to store the number of bytes allocated at `*dest`.
*/
- size_t *dest_len_p;
+ size_t *dest_size_p;
} variable_data;
@@ -164,7 +164,6 @@ struct MAJ_Specification
};
-
/**
* Navigate and parse data in a JSON tree.
*
@@ -187,4 +186,65 @@ void
MAJ_parse_free (struct MAJ_Specification *spec);
+/**
+ * End of a parser specification.
+ */
+#define MAJ_spec_end { .cmd = MAJ_CMD_END }
+
+/**
+ * Fixed size object (in network byte order, encoded using Crockford
+ * Base32hex encoding).
+ *
+ * @param name name of the JSON field
+ * @param obj pointer where to write the data (type of `*obj` will determine size)
+ */
+#define MAJ_spec_fixed_auto(name,obj) { .cmd = MAJ_CMD_BINARY_FIXED, .field = name, .details.fixed_data.dest = obj, .details.fixed_data.dest_size = sizeof (*obj) }
+
+
+/**
+ * Absolute time.
+ *
+ * @param name name of the JSON field
+ * @param at where to store the absolute time found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_absolute_time (const char *name,
+ struct GNUNET_TIME_Absolute *at);
+
+
+/**
+ * Specification for parsing an amount value.
+ *
+ * @param name name of the JSON field
+ * @param at where to store the absolute time found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_amount (const char *name,
+ struct TALER_Amount *amount);
+
+
+/**
+ * Specification for parsing an RSA public key.
+ *
+ * @param name name of the JSON field
+ * @param pk where to store the RSA key found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_rsa_public_key (const char *name,
+ struct GNUNET_CRYPTO_rsa_PublicKey **pk);
+
+
+/**
+ * Specification for parsing an RSA signature.
+ *
+ * @param name name of the JSON field
+ * @param sig where to store the RSA signature found under @a name
+ */
+struct MAJ_Specification
+MAJ_spec_rsa_signature (const char *name,
+ struct GNUNET_CRYPTO_rsa_Signature **sig);
+
+
+
+
/* end of mint_api_json.h */