functions to parse JSON objects into GNUnet objects More...
Go to the source code of this file.
Data Structures | |
struct | GNUNET_JSON_Specification |
Entry in parser specification for GNUNET_JSON_parse(). More... | |
struct | GNUNET_JSON_PackSpec |
Element in the array to give to the packer. More... | |
Macros | |
#define | GNUNET_JSON_spec_fixed_auto(name, obj) GNUNET_JSON_spec_fixed (name, (obj), sizeof(*(obj))) |
Fixed size object (in network byte order, encoded using Crockford Base32hex encoding). More... | |
#define | GNUNET_JSON_spec_fixed64_auto(name, obj) GNUNET_JSON_spec_fixed (name, (obj), sizeof(*(obj))) |
Fixed size object (in network byte order, encoded using base64 encoding). More... | |
#define | GNUNET_JSON_from_data_auto(ptr) GNUNET_JSON_from_data (ptr, sizeof(*(ptr))) |
Convert binary data to a JSON string with the base32crockford encoding. More... | |
#define | GNUNET_JSON_from_data64_auto(ptr) GNUNET_JSON_from_data64 (ptr, sizeof(*(ptr))) |
Convert binary data to a JSON string with base64 encoding. More... | |
#define | GNUNET_JSON_PACK(...) |
Pack a JSON object from a spec. More... | |
#define | GNUNET_JSON_pack_data_auto(name, blob) GNUNET_JSON_pack_data_varsize (name, (blob), sizeof (*(blob))) |
Generate packer instruction for a JSON field where the size is automatically determined from the argument. More... | |
#define | GNUNET_JSON_pack_data64_auto(name, blob) GNUNET_JSON_pack_data64_varsize (name, (blob), sizeof (*(blob))) |
Generate packer instruction for a JSON field where the size is automatically determined from the argument. More... | |
Typedefs | |
typedef enum GNUNET_GenericReturnValue(* | GNUNET_JSON_Parser) (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Function called to parse JSON argument. More... | |
typedef void(* | GNUNET_JSON_Cleaner) (void *cls, struct GNUNET_JSON_Specification *spec) |
Function called to clean up data from earlier parsing. More... | |
typedef json_t *(* | GNUNET_JSON_PackCallback) (const struct GNUNET_JSON_PackSpec *se) |
Function called to pack an element into the JSON object as part of GNUNET_JSON_pack_(). More... | |
Functions | |
enum GNUNET_GenericReturnValue | GNUNET_JSON_parse (const json_t *root, struct GNUNET_JSON_Specification *spec, const char **error_json_name, unsigned int *error_line) |
Navigate and parse data in a JSON tree. More... | |
void | GNUNET_JSON_parse_free (struct GNUNET_JSON_Specification *spec) |
Frees all elements allocated during a GNUNET_JSON_parse() operation. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_end (void) |
End of a parser specification. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_mark_optional (struct GNUNET_JSON_Specification spec, bool *missing) |
Set the "optional" flag for a parser specification entry. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_fixed (const char *name, void *obj, size_t size) |
Variable size object (in network byte order, encoded using Crockford Base32hex encoding). More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_fixed64 (const char *name, void *obj, size_t size) |
Variable size object (in network byte order, encoded using base64 encoding). More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_varsize (const char *name, void **obj, size_t *size) |
Variable size object (in network byte order, encoded using Crockford Base32hex encoding). More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_string (const char *name, const char **strptr) |
The expected field stores a string. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_string_copy (const char *name, char **strptr) |
The expected field stores a string. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_json (const char *name, json_t **jsonp) |
JSON object or array. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_object_copy (const char *name, json_t **jsonp) |
JSON object, reference counter not incremented. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_array_copy (const char *name, json_t **jsonp) |
JSON array, reference counter not incremented. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_object_const (const char *name, const json_t **jsonp) |
JSON object, reference counter not incremented. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_array_const (const char *name, const json_t **jsonp) |
JSON array, reference counter not incremented. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_bool (const char *name, bool *b) |
boolean. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_double (const char *name, double *f) |
double. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint8 (const char *name, uint8_t *u8) |
8-bit integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint16 (const char *name, uint16_t *u16) |
16-bit integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint32 (const char *name, uint32_t *u32) |
32-bit integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint (const char *name, unsigned int *ui) |
Unsigned integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_ull (const char *name, unsigned long long *ull) |
Unsigned long long. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint64 (const char *name, uint64_t *u64) |
64-bit integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_int16 (const char *name, int16_t *i16) |
16-bit signed integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_int64 (const char *name, int64_t *i64) |
64-bit signed integer. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_boolean (const char *name, int *boolean) |
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO). More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_timestamp (const char *name, struct GNUNET_TIME_Timestamp *t) |
Timestamp. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO *tn) |
Timestamp in network byte order. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_relative_time (const char *name, struct GNUNET_TIME_Relative *rt) |
Relative time. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_rsa_public_key (const char *name, struct GNUNET_CRYPTO_RsaPublicKey **pk) |
Specification for parsing an RSA public key. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_rsa_signature (const char *name, struct GNUNET_CRYPTO_RsaSignature **sig) |
Specification for parsing an RSA signature. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_blinded_message (const char *name, struct GNUNET_CRYPTO_BlindedMessage **msg) |
Specification for parsing a blinded message. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_blinded_signature (const char *field, struct GNUNET_CRYPTO_BlindedSignature **b_sig) |
Specification for parsing a blinded signature. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_unblinded_signature (const char *field, struct GNUNET_CRYPTO_UnblindedSignature **ub_sig) |
Specification for parsing an unblinded signature. More... | |
json_t * | GNUNET_JSON_from_data (const void *data, size_t size) |
Convert binary data to a JSON string with the base32crockford encoding. More... | |
json_t * | GNUNET_JSON_from_data64 (const void *data, size_t size) |
Convert binary data to a JSON string with base64 encoding. More... | |
json_t * | GNUNET_JSON_from_timestamp (struct GNUNET_TIME_Timestamp stamp) |
Convert timestamp to a json string. More... | |
json_t * | GNUNET_JSON_from_timestamp_nbo (struct GNUNET_TIME_TimestampNBO stamp) |
Convert timestamp to a json string. More... | |
json_t * | GNUNET_JSON_from_time_rel (struct GNUNET_TIME_Relative stamp) |
Convert relative timestamp to a json string. More... | |
json_t * | GNUNET_JSON_from_rsa_public_key (const struct GNUNET_CRYPTO_RsaPublicKey *pk) |
Convert RSA public key to JSON. More... | |
json_t * | GNUNET_JSON_from_rsa_signature (const struct GNUNET_CRYPTO_RsaSignature *sig) |
Convert RSA signature to JSON. More... | |
struct GNUNET_GETOPT_CommandLineOption | GNUNET_JSON_getopt (char shortName, const char *name, const char *argumentHelp, const char *description, json_t **json) |
Allow user to specify a JSON input value. More... | |
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 at) |
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 parse JSON objects into GNUnet objects
Definition in file gnunet_json_lib.h.
#define GNUNET_JSON_spec_fixed_auto | ( | name, | |
obj | |||
) | GNUNET_JSON_spec_fixed (name, (obj), sizeof(*(obj))) |
Fixed size object (in network byte order, encoded using Crockford Base32hex encoding).
name | name of the JSON field |
obj | pointer where to write the data (type of *obj will determine size) |
Definition at line 200 of file gnunet_json_lib.h.
#define GNUNET_JSON_spec_fixed64_auto | ( | name, | |
obj | |||
) | GNUNET_JSON_spec_fixed (name, (obj), sizeof(*(obj))) |
Fixed size object (in network byte order, encoded using base64 encoding).
name | name of the JSON field |
obj | pointer where to write the data (type of *obj will determine size) |
Definition at line 223 of file gnunet_json_lib.h.
#define GNUNET_JSON_from_data_auto | ( | ptr | ) | GNUNET_JSON_from_data (ptr, sizeof(*(ptr))) |
Convert binary data to a JSON string with the base32crockford encoding.
ptr | binary data, sizeof (*ptr) must yield correct size |
Definition at line 566 of file gnunet_json_lib.h.
#define GNUNET_JSON_from_data64_auto | ( | ptr | ) | GNUNET_JSON_from_data64 (ptr, sizeof(*(ptr))) |
Convert binary data to a JSON string with base64 encoding.
ptr | binary data, sizeof (*ptr) must yield correct size |
Definition at line 577 of file gnunet_json_lib.h.
#define GNUNET_JSON_PACK | ( | ... | ) |
Pack a JSON object from a spec.
Aborts if packing fails.
... | list of specification objects |
Definition at line 720 of file gnunet_json_lib.h.
#define GNUNET_JSON_pack_data_auto | ( | name, | |
blob | |||
) | GNUNET_JSON_pack_data_varsize (name, (blob), sizeof (*(blob))) |
Generate packer instruction for a JSON field where the size is automatically determined from the argument.
name | name of the field to add to the object |
blob | data to pack, must not be an array |
Definition at line 891 of file gnunet_json_lib.h.
#define GNUNET_JSON_pack_data64_auto | ( | name, | |
blob | |||
) | GNUNET_JSON_pack_data64_varsize (name, (blob), sizeof (*(blob))) |
Generate packer instruction for a JSON field where the size is automatically determined from the argument.
Use base64-encoding, instead of the more common Crockford base32-encoding.
name | name of the field to add to the object |
blob | data to pack, must not be an array |
Definition at line 922 of file gnunet_json_lib.h.
typedef enum GNUNET_GenericReturnValue(* GNUNET_JSON_Parser) (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Function called to parse JSON argument.
cls | closure |
root | JSON to parse |
spec | our specification entry with further details |
Definition at line 1 of file gnunet_json_lib.h.
typedef void(* GNUNET_JSON_Cleaner) (void *cls, struct GNUNET_JSON_Specification *spec) |
Function called to clean up data from earlier parsing.
cls | closure |
spec | our specification entry with data to clean. |
Definition at line 62 of file gnunet_json_lib.h.
typedef json_t *(* GNUNET_JSON_PackCallback) (const struct GNUNET_JSON_PackSpec *se) |
Function called to pack an element into the JSON object as part of GNUNET_JSON_pack_().
se | pack specification to execute |
Definition at line 666 of file gnunet_json_lib.h.
enum GNUNET_GenericReturnValue GNUNET_JSON_parse | ( | const json_t * | root, |
struct GNUNET_JSON_Specification * | spec, | ||
const char ** | error_json_name, | ||
unsigned int * | error_line | ||
) |
Navigate and parse data in a JSON tree.
Tries to parse the root to find all of the values given in the spec. If one of the entries in spec cannot be found or parsed, the name of the JSON field is returned in error_json_name, and the offset of the entry in spec is returned in error_line.
root | the JSON node to start the navigation at. | |
[in,out] | spec | parse specification array |
[out] | error_json_name | which JSON field was problematic |
[out] | error_line | which index into spec did we encounter an error |
Definition at line 32 of file json.c.
References GNUNET_JSON_Specification::field, GNUNET_ERROR_TYPE_WARNING, GNUNET_JSON_parse_free(), GNUNET_log, GNUNET_OK, GNUNET_SYSERR, GNUNET_JSON_Specification::missing, warningfilter::parser, and GNUNET_JSON_Specification::parser.
Referenced by add_attribute_cont(), add_credential_cont(), bulk_tx_start(), consume_ticket_cont(), namestore_add_or_update(), parse_blinded_message(), parse_blinded_sig(), parse_unblinded_sig(), and revoke_ticket_cont().
void GNUNET_JSON_parse_free | ( | struct GNUNET_JSON_Specification * | spec | ) |
Frees all elements allocated during a GNUNET_JSON_parse() operation.
Convenience function to be called if cleaning up all heap-allocated data from a GNUNET_JSON_parse() is desired. The function does not have to be called if no data was heap-allocated (e.g. only integers, strings and fixed-sized data was used), or if the application calls the respective code to free the heap (not always GNUNET_free(), depends on the data type!) on the returned heap-allocated data itself.
[in,out] | spec | specification of the parse operation |
Definition at line 100 of file json.c.
References GNUNET_JSON_Specification::cleaner, GNUNET_JSON_Specification::cls, and GNUNET_JSON_Specification::parser.
Referenced by add_attribute_cont(), add_credential_cont(), consume_ticket_cont(), GNUNET_JSON_parse(), namestore_add_or_update(), and revoke_ticket_cont().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end | ( | void | ) |
End of a parser specification.
Definition at line 33 of file json_helper.c.
References ret.
Referenced by add_attribute_cont(), add_credential_cont(), bulk_tx_start(), consume_ticket_cont(), namestore_add_or_update(), parse_blinded_message(), parse_blinded_sig(), parse_unblinded_sig(), and revoke_ticket_cont().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_mark_optional | ( | struct GNUNET_JSON_Specification | spec, |
bool * | missing | ||
) |
Set the "optional" flag for a parser specification entry.
spec | specification to modify | |
[out] | missing | set to true if the argument is missing, NULL is allowed. |
Definition at line 88 of file json.c.
References GNUNET_JSON_Specification::missing, and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed | ( | const char * | name, |
void * | obj, | ||
size_t | size | ||
) |
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
name | name of the JSON field | |
[out] | obj | pointer where to write the data, must have size bytes |
size | number of bytes expected in obj |
Definition at line 115 of file json_helper.c.
References name, parse_fixed_data(), ret, and size.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_fixed64 | ( | const char * | name, |
void * | obj, | ||
size_t | size | ||
) |
Variable size object (in network byte order, encoded using base64 encoding).
name | name of the JSON field | |
[out] | obj | pointer where to write the data, must have size bytes |
size | number of bytes expected in obj |
Definition at line 176 of file json_helper.c.
References name, parse_fixed64_data(), ret, and size.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_varsize | ( | const char * | name, |
void ** | obj, | ||
size_t * | size | ||
) |
Variable size object (in network byte order, encoded using Crockford Base32hex encoding).
name | name of the JSON field | |
[out] | obj | pointer where to write the data, will be allocated |
[out] | size | where to store the number of bytes allocated for obj |
Definition at line 250 of file json_helper.c.
References clean_variable_data(), name, parse_variable_data(), ret, and size.
Referenced by parse_blinded_message().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string | ( | const char * | name, |
const char ** | strptr | ||
) |
The expected field stores a string.
name | name of the JSON field |
strptr | where to store a pointer to the field |
Definition at line 296 of file json_helper.c.
References name, parse_string(), and ret.
Referenced by consume_ticket_cont(), parse_blinded_message(), parse_blinded_sig(), and parse_unblinded_sig().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string_copy | ( | const char * | name, |
char ** | strptr | ||
) |
The expected field stores a string.
name | name of the JSON field |
strptr | where to store a pointer to the field |
Definition at line 338 of file json_helper.c.
References name, parse_string_copy(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json | ( | const char * | name, |
json_t ** | jsonp | ||
) |
JSON object or array.
Reference counter is incremented.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 396 of file json_helper.c.
References clean_json(), name, parse_json(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_copy | ( | const char * | name, |
json_t ** | jsonp | ||
) |
JSON object, reference counter not incremented.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 477 of file json_helper.c.
References clean_json(), name, parse_object_copy(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_copy | ( | const char * | name, |
json_t ** | jsonp | ||
) |
JSON array, reference counter not incremented.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 558 of file json_helper.c.
References clean_json(), name, parse_array_copy(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_object_const | ( | const char * | name, |
const json_t ** | jsonp | ||
) |
JSON object, reference counter not incremented.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 437 of file json_helper.c.
References name, parse_object_const(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_array_const | ( | const char * | name, |
const json_t ** | jsonp | ||
) |
JSON array, reference counter not incremented.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 518 of file json_helper.c.
References name, parse_array_const(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_bool | ( | const char * | name, |
bool * | b | ||
) |
boolean.
name | name of the JSON field | |
[out] | b | where to store the boolean found under name |
Definition at line 604 of file json_helper.c.
References name, parse_bool(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_double | ( | const char * | name, |
double * | f | ||
) |
double.
name | name of the JSON field | |
[out] | f | where to store the double found under name |
Definition at line 644 of file json_helper.c.
References name, parse_double(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8 | ( | const char * | name, |
uint8_t * | u8 | ||
) |
8-bit integer.
name | name of the JSON field | |
[out] | u8 | where to store the integer found under name |
Definition at line 691 of file json_helper.c.
References name, parse_u8(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16 | ( | const char * | name, |
uint16_t * | u16 | ||
) |
16-bit integer.
name | name of the JSON field | |
[out] | u16 | where to store the integer found under name |
Definition at line 738 of file json_helper.c.
References name, parse_u16(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32 | ( | const char * | name, |
uint32_t * | u32 | ||
) |
32-bit integer.
name | name of the JSON field | |
[out] | u32 | where to store the integer found under name |
Definition at line 785 of file json_helper.c.
References name, parse_u32(), and ret.
Referenced by parse_blinded_sig().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint | ( | const char * | name, |
unsigned int * | ui | ||
) |
Unsigned integer.
name | name of the JSON field | |
[out] | ui | where to store the integer found under name |
Definition at line 832 of file json_helper.c.
References name, parse_ui(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_ull | ( | const char * | name, |
unsigned long long * | ull | ||
) |
Unsigned long long.
name | name of the JSON field | |
[out] | ull | where to store the unsigned long long found under name |
Definition at line 879 of file json_helper.c.
References name, parse_ull(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64 | ( | const char * | name, |
uint64_t * | u64 | ||
) |
64-bit integer.
name | name of the JSON field | |
[out] | u64 | where to store the integer found under name |
Definition at line 921 of file json_helper.c.
References name, parse_u64(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int16 | ( | const char * | name, |
int16_t * | i16 | ||
) |
16-bit signed integer.
name | name of the JSON field | |
[out] | i16 | where to store the integer found under name |
Definition at line 969 of file json_helper.c.
References name, parse_i16(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int64 | ( | const char * | name, |
int64_t * | i64 | ||
) |
64-bit signed integer.
name | name of the JSON field | |
[out] | i64 | where to store the integer found under name |
Definition at line 1011 of file json_helper.c.
References name, parse_i64(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean | ( | const char * | name, |
int * | boolean | ||
) |
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
name | name of the JSON field | |
[out] | boolean | where to store the boolean found under name |
Definition at line 1415 of file json_helper.c.
References name, parse_boolean(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp | ( | const char * | name, |
struct GNUNET_TIME_Timestamp * | t | ||
) |
Timestamp.
name | name of the JSON field | |
[out] | t | at where to store the absolute time found under name |
Definition at line 1087 of file json_helper.c.
References name, parse_timestamp(), ret, and t.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_timestamp_nbo | ( | const char * | name, |
struct GNUNET_TIME_TimestampNBO * | tn | ||
) |
Timestamp in network byte order.
name | name of the JSON field | |
[out] | tn | where to store the absolute time found under name |
Definition at line 1132 of file json_helper.c.
References name, parse_timestamp_nbo(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time | ( | const char * | name, |
struct GNUNET_TIME_Relative * | rt | ||
) |
Relative time.
name | name of the JSON field | |
[out] | rt | where to store the relative time found under name |
Definition at line 1202 of file json_helper.c.
References name, parse_rel_time(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_public_key | ( | const char * | name, |
struct GNUNET_CRYPTO_RsaPublicKey ** | pk | ||
) |
Specification for parsing an RSA public key.
name | name of the JSON field |
pk | where to store the RSA key found under name |
Definition at line 1286 of file json_helper.c.
References clean_rsa_public_key(), name, parse_rsa_public_key(), pk, and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature | ( | const char * | name, |
struct GNUNET_CRYPTO_RsaSignature ** | sig | ||
) |
Specification for parsing an RSA signature.
name | name of the JSON field |
sig | where to store the RSA signature found under name |
Definition at line 1371 of file json_helper.c.
References clean_rsa_signature(), name, parse_rsa_signature(), and ret.
Referenced by parse_blinded_sig(), and parse_unblinded_sig().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_message | ( | const char * | name, |
struct GNUNET_CRYPTO_BlindedMessage ** | msg | ||
) |
Specification for parsing a blinded message.
name | name of the JSON field |
sig | where to store the blinded message found under name |
Definition at line 1552 of file json_helper.c.
References clean_blinded_message(), msg, name, parse_blinded_message(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_blinded_signature | ( | const char * | field, |
struct GNUNET_CRYPTO_BlindedSignature ** | b_sig | ||
) |
Specification for parsing a blinded signature.
name | name of the JSON field |
sig | where to store the blinded signature found under name |
Definition at line 1687 of file json_helper.c.
References clean_blinded_sig(), GNUNET_JSON_Specification::field, parse_blinded_sig(), and ret.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_unblinded_signature | ( | const char * | field, |
struct GNUNET_CRYPTO_UnblindedSignature ** | ub_sig | ||
) |
Specification for parsing an unblinded signature.
name | name of the JSON field |
sig | where to store the unblinded signature found under name |
Definition at line 1820 of file json_helper.c.
References clean_unblinded_sig(), GNUNET_JSON_Specification::field, parse_unblinded_sig(), and ret.
json_t * GNUNET_JSON_from_data | ( | const void * | data, |
size_t | size | ||
) |
Convert binary data to a JSON string with the base32crockford encoding.
data | binary data |
size | size of data in bytes |
Definition at line 31 of file json_generator.c.
References data, GNUNET_break, GNUNET_free, GNUNET_MAX_MALLOC_CHECKED, GNUNET_STRINGS_data_to_string_alloc(), and size.
Referenced by GNUNET_JSON_from_rsa_public_key(), GNUNET_JSON_from_rsa_signature(), and GNUNET_JSON_pack_data_varsize().
json_t * GNUNET_JSON_from_data64 | ( | const void * | data, |
size_t | size | ||
) |
Convert binary data to a JSON string with base64 encoding.
data | binary data |
size | size of data in bytes |
Definition at line 52 of file json_generator.c.
References data, GNUNET_break, GNUNET_free, GNUNET_MAX_MALLOC_CHECKED, GNUNET_STRINGS_base64_encode(), and size.
Referenced by GNUNET_JSON_pack_data64_varsize().
json_t * GNUNET_JSON_from_timestamp | ( | struct GNUNET_TIME_Timestamp | stamp | ) |
Convert timestamp to a json string.
stamp | the time stamp |
Definition at line 81 of file json_generator.c.
References GNUNET_TIME_Timestamp::abs_time, GNUNET_TIME_Absolute::abs_value_us, GNUNET_assert, GNUNET_break, GNUNET_TIME_absolute_is_never(), and GNUNET_TIME_UNIT_SECONDS.
Referenced by GNUNET_JSON_from_timestamp_nbo(), and GNUNET_JSON_pack_timestamp().
json_t * GNUNET_JSON_from_timestamp_nbo | ( | struct GNUNET_TIME_TimestampNBO | stamp | ) |
Convert timestamp to a json string.
stamp | the time stamp |
Definition at line 125 of file json_generator.c.
References GNUNET_JSON_from_timestamp(), and GNUNET_TIME_timestamp_ntoh().
json_t * GNUNET_JSON_from_time_rel | ( | struct GNUNET_TIME_Relative | stamp | ) |
Convert relative timestamp to a json string.
stamp | the time stamp |
Definition at line 132 of file json_generator.c.
References GNUNET_break, GNUNET_TIME_relative_is_forever(), and GNUNET_TIME_Relative::rel_value_us.
Referenced by GNUNET_JSON_pack_time_rel().
json_t * GNUNET_JSON_from_rsa_public_key | ( | const struct GNUNET_CRYPTO_RsaPublicKey * | pk | ) |
Convert RSA public key to JSON.
pk | public key to convert |
Definition at line 176 of file json_generator.c.
References GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_free, GNUNET_JSON_from_data(), pk, and ret.
Referenced by GNUNET_JSON_pack_rsa_public_key().
json_t * GNUNET_JSON_from_rsa_signature | ( | const struct GNUNET_CRYPTO_RsaSignature * | sig | ) |
Convert RSA signature to JSON.
sig | signature to convert |
Definition at line 192 of file json_generator.c.
References GNUNET_CRYPTO_rsa_signature_encode(), GNUNET_free, GNUNET_JSON_from_data(), and ret.
Referenced by GNUNET_JSON_pack_rsa_signature().
struct GNUNET_GETOPT_CommandLineOption GNUNET_JSON_getopt | ( | char | shortName, |
const char * | name, | ||
const char * | argumentHelp, | ||
const char * | description, | ||
json_t ** | json | ||
) |
Allow user to specify a JSON input value.
shortName | short name of the option | |
name | long name of the option | |
argumentHelp | help text for the option argument | |
description | long help text for the option | |
[out] | val | set to the JSON specified at the command line |
Definition at line 147 of file json.c.
References GNUNET_GETOPT_CommandLineOption::argumentHelp, GNUNET_GETOPT_CommandLineOption::description, name, set_json(), and GNUNET_GETOPT_CommandLineOption::shortName.
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::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 75 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 86 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 94 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 108 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 122 of file json_pack.c.
References GNUNET_assert, name, and ps.
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 136 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 155 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 176 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 198 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 221 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 244 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 268 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 286 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 304 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 326 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 335 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 349 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 358 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 371 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 384 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 422 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 464 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.