functions to generate specifciations for JSON parsing More...
Go to the source code of this file.
Functions | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_end () |
End of a parser specification. More... | |
static enum GNUNET_GenericReturnValue | parse_fixed_data (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to fixed size data. 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... | |
static enum GNUNET_GenericReturnValue | parse_fixed64_data (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to fixed size data. 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... | |
static enum GNUNET_GenericReturnValue | parse_variable_data (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to variable size data. More... | |
static void | clean_variable_data (void *cls, struct GNUNET_JSON_Specification *spec) |
Cleanup data left from parsing variable size data. 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... | |
static enum GNUNET_GenericReturnValue | parse_string (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to string. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_string (const char *name, const char **strptr) |
The expected field stores a string. More... | |
static enum GNUNET_GenericReturnValue | parse_json (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a JSON object. More... | |
static void | clean_json (void *cls, struct GNUNET_JSON_Specification *spec) |
Cleanup data left from parsing JSON object. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_json (const char *name, json_t **jsonp) |
JSON object or array. More... | |
static enum GNUNET_GenericReturnValue | parse_object_const (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a JSON object. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_object_const (const char *name, const json_t **jsonp) |
JSON object, reference counter not incremented. More... | |
static enum GNUNET_GenericReturnValue | parse_array_const (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON to a JSON array. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_array_const (const char *name, const json_t **jsonp) |
JSON array, reference counter not incremented. More... | |
static enum GNUNET_GenericReturnValue | parse_bool (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a bool. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_bool (const char *name, bool *b) |
boolean. More... | |
static enum GNUNET_GenericReturnValue | parse_u8 (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a uint8_t. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint8 (const char *name, uint8_t *u8) |
8-bit integer. More... | |
static enum GNUNET_GenericReturnValue | parse_u16 (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a uint16_t. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint16 (const char *name, uint16_t *u16) |
16-bit integer. More... | |
static enum GNUNET_GenericReturnValue | parse_u32 (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a uint32_t. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint32 (const char *name, uint32_t *u32) |
32-bit integer. More... | |
static enum GNUNET_GenericReturnValue | parse_u64 (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a uint64_t. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_uint64 (const char *name, uint64_t *u64) |
64-bit integer. More... | |
static enum GNUNET_GenericReturnValue | parse_i64 (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a int64_t. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_int64 (const char *name, int64_t *i64) |
64-bit signed integer. More... | |
static enum GNUNET_GenericReturnValue | parse_timestamp (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a timestamp. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_timestamp (const char *name, struct GNUNET_TIME_Timestamp *t) |
Timestamp. More... | |
static enum GNUNET_GenericReturnValue | parse_timestamp_nbo (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to absolute time. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_timestamp_nbo (const char *name, struct GNUNET_TIME_TimestampNBO *at) |
Timestamp in network byte order. More... | |
static enum GNUNET_GenericReturnValue | parse_rel_time (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to relative time. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_relative_time (const char *name, struct GNUNET_TIME_Relative *rt) |
Relative time. More... | |
static enum GNUNET_GenericReturnValue | parse_rsa_public_key (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to RSA public key. More... | |
static void | clean_rsa_public_key (void *cls, struct GNUNET_JSON_Specification *spec) |
Cleanup data left from parsing RSA public key. 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... | |
static enum GNUNET_GenericReturnValue | parse_rsa_signature (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to RSA signature. More... | |
static void | clean_rsa_signature (void *cls, struct GNUNET_JSON_Specification *spec) |
Cleanup data left from parsing RSA signature. 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... | |
static enum GNUNET_GenericReturnValue | parse_boolean (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to an int as a boolean. 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... | |
functions to generate specifciations for JSON parsing
Definition in file json_helper.c.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end | ( | void | ) |
End of a parser specification.
Definition at line 1 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(), and revoke_ticket_cont().
|
static |
Parse given JSON object to fixed size data.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 1 of file json_helper.c.
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 1 of file json_helper.c.
|
static |
Parse given JSON object to fixed size data.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 1 of file json_helper.c.
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 1 of file json_helper.c.
|
static |
Parse given JSON object to variable size data.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 1 of file json_helper.c.
|
static |
Cleanup data left from parsing variable size data.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 215 of file json_helper.c.
References GNUNET_JSON_Specification::cls, GNUNET_free, GNUNET_JSON_Specification::ptr, and GNUNET_JSON_Specification::size_ptr.
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 215 of file json_helper.c.
|
static |
Parse given JSON object to string.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 215 of file json_helper.c.
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 215 of file json_helper.c.
|
static |
Parse given JSON object to a JSON object.
(Yes, trivial.)
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 215 of file json_helper.c.
|
static |
Cleanup data left from parsing JSON object.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 326 of file json_helper.c.
References GNUNET_JSON_Specification::ptr.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a JSON object.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON to a JSON array.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a bool.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a uint8_t.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a uint16_t.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a uint32_t.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a uint64_t.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a int64_t.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to a timestamp.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to absolute time.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to relative time.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
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 326 of file json_helper.c.
|
static |
Parse given JSON object to RSA public key.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 326 of file json_helper.c.
|
static |
Cleanup data left from parsing RSA public key.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 979 of file json_helper.c.
References GNUNET_CRYPTO_rsa_public_key_free(), pk, and GNUNET_JSON_Specification::ptr.
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 979 of file json_helper.c.
|
static |
Parse given JSON object to RSA signature.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 979 of file json_helper.c.
|
static |
Cleanup data left from parsing RSA signature.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 1064 of file json_helper.c.
References GNUNET_CRYPTO_rsa_signature_free(), and GNUNET_JSON_Specification::ptr.
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 1064 of file json_helper.c.
|
static |
Parse given JSON object to an int as a boolean.
cls | closure, NULL | |
root | the json object representing data | |
[out] | spec | where to write the data |
Definition at line 1064 of file json_helper.c.
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 1064 of file json_helper.c.