From 91bb5623de1586912d323bf4dfd19c02d2a376d6 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 26 Jul 2021 17:25:53 +0200 Subject: JSON: implement taler-specific json pack functions --- src/include/taler_json_lib.h | 111 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) (limited to 'src/include') diff --git a/src/include/taler_json_lib.h b/src/include/taler_json_lib.h index 1089f5bdf..4ed259b21 100644 --- a/src/include/taler_json_lib.h +++ b/src/include/taler_json_lib.h @@ -37,6 +37,117 @@ "JSON parsing failed at %s:%u: %s (%s)\n", \ __FILE__, __LINE__, error.text, error.source) + +/** + * Generate packer instruction for a JSON field of type + * absolute time. + * The absolute time value is expected to be already rounded. + * + * @param name name of the field to add to the object + * @param at absolute time to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_time_abs (const char *name, + struct GNUNET_TIME_Absolute at); + + +/** + * Generate packer instruction for a JSON field of type + * absolute time in network byte order. + * The absolute time value is expected to be already rounded. + * + * @param name name of the field to add to the object + * @param at absolute time to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_time_abs_nbo (const char *name, + struct GNUNET_TIME_AbsoluteNBO at); + + +/** + * Generate packer instruction for a JSON field of type + * relative time. + * The relative time value is expected to be already rounded. + * + * @param name name of the field to add to the object + * @param rt relative time to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_time_rel (const char *name, + struct GNUNET_TIME_Relative rt); + + +/** + * Generate packer instruction for a JSON field of type + * relative time in network byte order. + * The relative time value is expected to be already rounded. + * + * @param name name of the field to add to the object + * @param rt relative time to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_time_rel_nbo (const char *name, + struct GNUNET_TIME_RelativeNBO rt); + + +/** + * Generate packer instruction for a JSON field of type + * denomination public key. + * + * @param name name of the field to add to the object + * @param pk public key + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_denomination_public_key (const char *name, + const struct + TALER_DenominationPublicKey *pk); + + +/** + * Generate packer instruction for a JSON field of type + * denomination signature. + * + * @param name name of the field to add to the object + * @param sig signature + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_denomination_signature (const char *name, + const struct + TALER_DenominationSignature *sig); + + +/** + * Generate packer instruction for a JSON field of type + * amount. + * + * @param name name of the field to add to the object + * @param amount valid amount to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_amount (const char *name, + const struct TALER_Amount *amount); + + +/** + * Generate packer instruction for a JSON field of type + * amount. + * + * @param name name of the field to add to the object + * @param amount valid amount to pack + * @return json pack specification + */ +struct GNUNET_JSON_PackSpec +TALER_JSON_pack_amount_nbo (const char *name, + const struct TALER_AmountNBO *amount); + + /** * Convert a TALER amount to a JSON object. * -- cgit v1.2.3