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. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_end_ (void) |
Do not use directly. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_allow_null (struct GNUNET_JSON_PackSpec in) |
Modify packer instruction to allow NULL as a value. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_bool (const char *name, bool b) |
Generate packer instruction for a JSON field of type bool. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_double (const char *name, double f) |
Generate packer instruction for a JSON field of type double. More... | |
struct GNUNET_JSON_PackSpec | GNUNET_JSON_pack_string (const char *name, const char *s) |
Generate packer instruction for a JSON field of type string. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 29 of file json_pack.c.
References GNUNET_JSON_PackSpec::field_name, 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 69 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 80 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 88 of file json_pack.c.
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 101 of file json_pack.c.
References removetrailingwhitespace::f, 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 114 of file json_pack.c.
Referenced by GNUNET_JSON_pack_blinded_message(), GNUNET_JSON_pack_blinded_sig(), 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 127 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 145 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 |
o | object to steal |
Definition at line 165 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 |
o | object to increment reference counter of |
Definition at line 187 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 210 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 232 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 255 of file json_pack.c.
References 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 272 of file json_pack.c.
References 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 289 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 310 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 319 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 332 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 341 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 354 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 367 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 404 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 445 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.