functions to pack JSON objects More...
Go to the source code of this file.
Functions | |
| json_t * | GNUNET_JSON_pack_ (struct GNUNET_JSON_PackSpec spec[]) |
| Pack a JSON object from a spec. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_end_ (void) |
| Do not use directly. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_allow_null (struct GNUNET_JSON_PackSpec in) |
| Modify packer instruction to allow NULL as a value. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_bool (const char *name, bool b) |
| Generate packer instruction for a JSON field of type bool. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_double (const char *name, double f) |
| Generate packer instruction for a JSON field of type double. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_string (const char *name, const char *s) |
| Generate packer instruction for a JSON field of type string. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_uint64 (const char *name, uint64_t num) |
| Generate packer instruction for a JSON field of type unsigned integer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_int64 (const char *name, int64_t num) |
| Generate packer instruction for a JSON field of type signed integer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_object_steal (const char *name, json_t *o) |
| Generate packer instruction for a JSON field of type JSON object where the reference is taken over by the packer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_object_incref (const char *name, json_t *o) |
| Generate packer instruction for a JSON field of type JSON object where the reference counter is incremented by the packer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_array_steal (const char *name, json_t *a) |
| Generate packer instruction for a JSON field of type JSON array where the reference is taken over by the packer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_array_incref (const char *name, json_t *a) |
| Generate packer instruction for a JSON field of type JSON array where the reference counter is incremented by the packer. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_data_varsize (const char *name, const void *blob, size_t blob_size) |
| Generate packer instruction for a JSON field of type variable size binary blob. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_data64_varsize (const char *name, const void *blob, size_t blob_size) |
| Generate packer instruction for a JSON field of type variable size binary blob. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_timestamp (const char *name, struct GNUNET_TIME_Timestamp t) |
| Generate packer instruction for a JSON field of type timestamp. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO at) |
| Generate packer instruction for a JSON field of type timestamp in network byte order. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_time_rel (const char *name, struct GNUNET_TIME_Relative rt) |
| Generate packer instruction for a JSON field of type relative time. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_time_rel_nbo (const char *name, struct GNUNET_TIME_RelativeNBO rt) |
| Generate packer instruction for a JSON field of type relative time in network byte order. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_rsa_public_key (const char *name, const struct GNUNET_CRYPTO_RsaPublicKey *pk) |
| Generate packer instruction for a JSON field of type RSA public key. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_rsa_signature (const char *name, const struct GNUNET_CRYPTO_RsaSignature *sig) |
| Generate packer instruction for a JSON field of type RSA signature. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_unblinded_signature (const char *name, const struct GNUNET_CRYPTO_UnblindedSignature *sig) |
| Generate packer instruction for a JSON field of type unblinded signature. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_blinded_message (const char *name, const struct GNUNET_CRYPTO_BlindedMessage *msg) |
| Generate packer instruction for a JSON field of type blinded message. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_blinded_sig (const char *name, const struct GNUNET_CRYPTO_BlindedSignature *sig) |
| Generate packer instruction for a JSON field of type blinded signature. | |
| struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_time_rounder_interval (const char *name, enum GNUNET_TIME_RounderInterval ri) |
| Generate packer instruction of a time rounder interval. | |
functions to pack JSON objects
Definition in file json_pack.c.
| json_t * GNUNET_JSON_pack_ | ( | struct GNUNET_JSON_PackSpec | spec[] | ) |
Pack a JSON object from a spec.
Aborts if packing fails.
| spec | specification object |
Definition at line 30 of file json_pack.c.
References GNUNET_JSON_PackSpec::final, GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_JSON_PackSpec::object, and ret.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_end_ | ( | void | ) |
Do not use directly.
Use GNUNET_JSON_PACK.
Definition at line 76 of file json_pack.c.
References ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_allow_null | ( | struct GNUNET_JSON_PackSpec | in | ) |
Modify packer instruction to allow NULL as a value.
| in | json pack specification to modify |
Definition at line 87 of file json_pack.c.
References GNUNET_JSON_PackSpec::allow_null.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_bool | ( | const char * | name, |
| bool | b | ||
| ) |
Generate packer instruction for a JSON field of type bool.
| name | name of the field to add to the object |
| b | boolean value |
Definition at line 95 of file json_pack.c.
References GNUNET_assert, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_double | ( | const char * | name, |
| double | f | ||
| ) |
Generate packer instruction for a JSON field of type double.
| name | name of the field to add to the object |
| f | double value |
Definition at line 109 of file json_pack.c.
References GNUNET_assert, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_string | ( | const char * | name, |
| const char * | s | ||
| ) |
Generate packer instruction for a JSON field of type string.
| name | name of the field to add to the object |
| s | string value |
Definition at line 123 of file json_pack.c.
References GNUNET_assert, name, and ps.
Referenced by GNUNET_JSON_pack_blinded_message(), GNUNET_JSON_pack_blinded_sig(), GNUNET_JSON_pack_time_rounder_interval(), and GNUNET_JSON_pack_unblinded_signature().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_uint64 | ( | const char * | name, |
| uint64_t | num | ||
| ) |
Generate packer instruction for a JSON field of type unsigned integer.
Note that the maximum allowed value is still limited by JSON and not UINT64_MAX.
| name | name of the field to add to the object |
| num | numeric value |
Definition at line 137 of file json_pack.c.
References GNUNET_assert, name, and ps.
Referenced by GNUNET_JSON_pack_blinded_sig().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_int64 | ( | const char * | name, |
| int64_t | num | ||
| ) |
Generate packer instruction for a JSON field of type signed integer.
| name | name of the field to add to the object |
| num | numeric value |
Definition at line 156 of file json_pack.c.
References GNUNET_assert, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_object_steal | ( | const char * | name, |
| json_t * | o | ||
| ) |
Generate packer instruction for a JSON field of type JSON object where the reference is taken over by the packer.
| name | name of the field to add to the object, if NULL, the keys of o will be placed in the top level of the resulting object |
| o | object to steal |
Definition at line 177 of file json_pack.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, name, and ps.
Referenced by GNUNET_JSON_pack_time_rel().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_object_incref | ( | const char * | name, |
| json_t * | o | ||
| ) |
Generate packer instruction for a JSON field of type JSON object where the reference counter is incremented by the packer.
Note that a deep copy is not performed.
| name | name of the field to add to the object, if NULL, the keys of o will be placed in the top level of the resulting object |
| o | object to increment reference counter of |
Definition at line 199 of file json_pack.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_array_steal | ( | const char * | name, |
| json_t * | a | ||
| ) |
Generate packer instruction for a JSON field of type JSON array where the reference is taken over by the packer.
| name | name of the field to add to the object |
| a | array to steal |
Definition at line 222 of file json_pack.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_array_incref | ( | const char * | name, |
| json_t * | a | ||
| ) |
Generate packer instruction for a JSON field of type JSON array where the reference counter is incremented by the packer.
Note that a deep copy is not performed.
| name | name of the field to add to the object |
| a | array to increment reference counter of |
Definition at line 245 of file json_pack.c.
References GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_data_varsize | ( | const char * | name, |
| const void * | blob, | ||
| size_t | blob_size | ||
| ) |
Generate packer instruction for a JSON field of type variable size binary blob.
| name | name of the field to add to the object |
| blob | binary data to pack |
| blob_size | number of bytes in blob |
Definition at line 269 of file json_pack.c.
References GNUNET_assert, GNUNET_JSON_from_data(), name, and ps.
Referenced by GNUNET_JSON_pack_blinded_message().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_data64_varsize | ( | const char * | name, |
| const void * | blob, | ||
| size_t | blob_size | ||
| ) |
Generate packer instruction for a JSON field of type variable size binary blob.
Use base64-encoding, instead of the more common Crockford base32-encoding.
| name | name of the field to add to the object |
| blob | binary data to pack |
| blob_size | number of bytes in blob |
Definition at line 287 of file json_pack.c.
References GNUNET_assert, GNUNET_JSON_from_data64(), name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_timestamp | ( | const char * | name, |
| struct GNUNET_TIME_Timestamp | at | ||
| ) |
Generate packer instruction for a JSON field of type timestamp.
| name | name of the field to add to the object |
| at | timestamp pack, a value of 0 is only allowed with GNUNET_JSON_pack_allow_null()! |
Definition at line 305 of file json_pack.c.
References GNUNET_assert, GNUNET_JSON_from_timestamp(), GNUNET_TIME_absolute_is_zero(), name, ps, and t.
Referenced by GNUNET_JSON_pack_timestamp_nbo().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_timestamp_nbo | ( | const char * | name, |
| struct GNUNET_TIME_TimestampNBO | at | ||
| ) |
Generate packer instruction for a JSON field of type timestamp in network byte order.
| name | name of the field to add to the object |
| at | timestamp to pack, a value of 0 is only allowed with GNUNET_JSON_pack_allow_null()! |
Definition at line 327 of file json_pack.c.
References GNUNET_JSON_pack_timestamp(), GNUNET_TIME_timestamp_ntoh(), and name.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_rel | ( | const char * | name, |
| struct GNUNET_TIME_Relative | rt | ||
| ) |
Generate packer instruction for a JSON field of type relative time.
| name | name of the field to add to the object |
| rt | relative time to pack |
Definition at line 336 of file json_pack.c.
References GNUNET_assert, GNUNET_JSON_from_time_rel(), GNUNET_JSON_pack_object_steal(), and name.
Referenced by GNUNET_JSON_pack_time_rel_nbo().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_rel_nbo | ( | const char * | name, |
| struct GNUNET_TIME_RelativeNBO | rt | ||
| ) |
Generate packer instruction for a JSON field of type relative time in network byte order.
| name | name of the field to add to the object |
| rt | relative time to pack |
Definition at line 350 of file json_pack.c.
References GNUNET_JSON_pack_time_rel(), GNUNET_TIME_relative_ntoh(), and name.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_rsa_public_key | ( | const char * | name, |
| const struct GNUNET_CRYPTO_RsaPublicKey * | pk | ||
| ) |
Generate packer instruction for a JSON field of type RSA public key.
| name | name of the field to add to the object |
| pk | RSA public key |
Definition at line 359 of file json_pack.c.
References GNUNET_JSON_from_rsa_public_key(), name, pk, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_rsa_signature | ( | const char * | name, |
| const struct GNUNET_CRYPTO_RsaSignature * | sig | ||
| ) |
Generate packer instruction for a JSON field of type RSA signature.
| name | name of the field to add to the object |
| sig | RSA signature |
Definition at line 372 of file json_pack.c.
References GNUNET_JSON_from_rsa_signature(), name, and ps.
Referenced by GNUNET_JSON_pack_blinded_sig(), and GNUNET_JSON_pack_unblinded_signature().
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_unblinded_signature | ( | const char * | name, |
| const struct GNUNET_CRYPTO_UnblindedSignature * | sig | ||
| ) |
Generate packer instruction for a JSON field of type unblinded signature.
| name | name of the field to add to the object |
| sig | unblinded signature |
Definition at line 385 of file json_pack.c.
References GNUNET_assert, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_JSON_PACK, GNUNET_JSON_pack_data_auto, GNUNET_JSON_pack_rsa_signature(), GNUNET_JSON_pack_string(), name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_blinded_message | ( | const char * | name, |
| const struct GNUNET_CRYPTO_BlindedMessage * | msg | ||
| ) |
Generate packer instruction for a JSON field of type blinded message.
| name | name of the field to add to the object |
| msg | blinded message |
Definition at line 423 of file json_pack.c.
References GNUNET_assert, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_JSON_PACK, GNUNET_JSON_pack_data_auto, GNUNET_JSON_pack_data_varsize(), GNUNET_JSON_pack_string(), msg, name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_blinded_sig | ( | const char * | name, |
| const struct GNUNET_CRYPTO_BlindedSignature * | sig | ||
| ) |
Generate packer instruction for a JSON field of type blinded signature.
| name | name of the field to add to the object |
| sig | blinded signature |
Definition at line 465 of file json_pack.c.
References GNUNET_assert, GNUNET_CRYPTO_BSA_CS, GNUNET_CRYPTO_BSA_INVALID, GNUNET_CRYPTO_BSA_RSA, GNUNET_JSON_PACK, GNUNET_JSON_pack_data_auto, GNUNET_JSON_pack_rsa_signature(), GNUNET_JSON_pack_string(), GNUNET_JSON_pack_uint64(), name, and ps.
| struct GNUNET_JSON_PackSpec GNUNET_JSON_pack_time_rounder_interval | ( | const char * | name, |
| enum GNUNET_TIME_RounderInterval | ri | ||
| ) |
Generate packer instruction of a time rounder interval.
| name | name of the field to add to the object |
| ri | rounder interval to add |
Definition at line 502 of file json_pack.c.
References GNUNET_break, GNUNET_JSON_pack_string(), GNUNET_TIME_round_interval2s(), name, ri, and str.