![]() |
GNUnet
0.11.x
|
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 int | 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 int | 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 int | 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 int | parse_object (void *cls, json_t *root, struct GNUNET_JSON_Specification *spec) |
Parse given JSON object to a JSON object. More... | |
static void | clean_object (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. More... | |
static int | 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 int | 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 int | 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 int | 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 int | 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 int | 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 int | parse_abs_time (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_absolute_time (const char *name, struct GNUNET_TIME_Absolute *at) |
Absolute time. More... | |
static int | parse_abs_time_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_absolute_time_nbo (const char *name, struct GNUNET_TIME_AbsoluteNBO *at) |
Absolute time in network byte order. More... | |
static int | 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 int | 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 int | 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 int | 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 35 of file json_helper.c.
References GNUNET_JSON_Specification::parser, and ret.
Referenced by add_attribute_cont(), add_credential_cont(), 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 56 of file json_helper.c.
References enc, GNUNET_break_op, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, len, GNUNET_JSON_Specification::ptr, and GNUNET_JSON_Specification::ptr_size.
Referenced by GNUNET_JSON_spec_fixed().
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 96 of file json_helper.c.
References name, parse_fixed_data(), GNUNET_JSON_Specification::parser, ret, and size.
|
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 123 of file json_helper.c.
References data, GNUNET_break_op, GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, GNUNET_JSON_Specification::ptr, res, size, and GNUNET_JSON_Specification::size_ptr.
Referenced by GNUNET_JSON_spec_varsize().
|
static |
Cleanup data left from parsing variable size data.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 168 of file json_helper.c.
References GNUNET_free, GNUNET_JSON_Specification::ptr, and GNUNET_JSON_Specification::size_ptr.
Referenced by GNUNET_JSON_spec_varsize().
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 189 of file json_helper.c.
References clean_variable_data(), name, parse_variable_data(), GNUNET_JSON_Specification::parser, ret, and size.
|
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 218 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_string().
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 242 of file json_helper.c.
References name, parse_string(), GNUNET_JSON_Specification::parser, and ret.
|
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 269 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_json().
|
static |
Cleanup data left from parsing JSON object.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 291 of file json_helper.c.
References GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_json().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json | ( | const char * | name, |
json_t ** | jsonp | ||
) |
JSON object.
name | name of the JSON field | |
[out] | jsonp | where to store the JSON found under name |
Definition at line 311 of file json_helper.c.
References clean_object(), name, parse_object(), GNUNET_JSON_Specification::parser, and ret.
|
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 338 of file json_helper.c.
References testconfigure::b, GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_bool().
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 366 of file json_helper.c.
References testconfigure::b, name, parse_bool(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 392 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_uint8().
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 422 of file json_helper.c.
References name, parse_u8(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 448 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_uint16().
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 478 of file json_helper.c.
References name, parse_u16(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 504 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_uint32().
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 534 of file json_helper.c.
References name, parse_u32(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 560 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_uint64().
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 585 of file json_helper.c.
References name, parse_u64(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 611 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_int64().
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 636 of file json_helper.c.
References name, parse_i64(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.
|
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 664 of file json_helper.c.
References GNUNET_TIME_Absolute::abs_value_us, GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_ABS, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_absolute_time(), and parse_abs_time_nbo().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time | ( | const char * | name, |
struct GNUNET_TIME_Absolute * | at | ||
) |
Absolute time.
name | name of the JSON field | |
[out] | at | where to store the absolute time found under name |
Definition at line 715 of file json_helper.c.
References name, parse_abs_time(), GNUNET_JSON_Specification::parser, and ret.
|
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 741 of file json_helper.c.
References GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_absolute_hton(), parse_abs_time(), GNUNET_JSON_Specification::parser, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_absolute_time_nbo().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time_nbo | ( | const char * | name, |
struct GNUNET_TIME_AbsoluteNBO * | at | ||
) |
Absolute time in network byte order.
name | name of the JSON field | |
[out] | at | where to store the absolute time found under name |
Definition at line 769 of file json_helper.c.
References name, parse_abs_time_nbo(), GNUNET_JSON_Specification::parser, and ret.
|
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 795 of file json_helper.c.
References GNUNET_break_op, GNUNET_OK, GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_JSON_Specification::ptr, and GNUNET_TIME_Relative::rel_value_us.
Referenced by GNUNET_JSON_spec_relative_time().
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 846 of file json_helper.c.
References name, parse_rel_time(), GNUNET_JSON_Specification::parser, and ret.
|
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 872 of file json_helper.c.
References buf, enc, GNUNET_break_op, GNUNET_CRYPTO_rsa_public_key_decode(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, len, pk, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_rsa_public_key().
|
static |
Cleanup data left from parsing RSA public key.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 919 of file json_helper.c.
References GNUNET_CRYPTO_rsa_public_key_free(), pk, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_rsa_public_key().
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 939 of file json_helper.c.
References clean_rsa_public_key(), name, parse_rsa_public_key(), GNUNET_JSON_Specification::parser, pk, and ret.
|
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 966 of file json_helper.c.
References buf, GNUNET_break_op, GNUNET_CRYPTO_rsa_signature_decode(), GNUNET_free, GNUNET_malloc, GNUNET_OK, GNUNET_STRINGS_string_to_data(), GNUNET_SYSERR, GNUNET_JSON_Specification::ptr, res, and size.
Referenced by GNUNET_JSON_spec_rsa_signature().
|
static |
Cleanup data left from parsing RSA signature.
cls | closure, NULL | |
[out] | spec | where to free the data |
Definition at line 1013 of file json_helper.c.
References GNUNET_CRYPTO_rsa_signature_free(), and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_rsa_signature().
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 1033 of file json_helper.c.
References clean_rsa_signature(), name, parse_rsa_signature(), GNUNET_JSON_Specification::parser, and ret.
|
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 1060 of file json_helper.c.
References GNUNET_break_op, GNUNET_NO, GNUNET_OK, GNUNET_SYSERR, GNUNET_YES, and GNUNET_JSON_Specification::ptr.
Referenced by GNUNET_JSON_spec_boolean().
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean | ( | const char * | name, |
int * | boolean | ||
) |
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
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 1083 of file json_helper.c.
References name, parse_boolean(), GNUNET_JSON_Specification::parser, ret, and GNUNET_JSON_Specification::size_ptr.