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... | |
Enumerations | |
enum | GNUNET_JSON_PostResult { GNUNET_JSON_PR_SUCCESS , GNUNET_JSON_PR_CONTINUE , GNUNET_JSON_PR_OUT_OF_MEMORY , GNUNET_JSON_PR_REQUEST_TOO_LARGE , GNUNET_JSON_PR_JSON_INVALID } |
Return codes from GNUNET_JSON_post_parser(). 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_json (const char *name, json_t **jsonp) |
JSON object. More... | |
struct GNUNET_JSON_Specification | GNUNET_JSON_spec_bool (const char *name, bool *b) |
boolean. 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_uint64 (const char *name, uint64_t *u64) |
64-bit 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... | |
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... | |
enum GNUNET_JSON_PostResult | GNUNET_JSON_post_parser (size_t buffer_max, struct MHD_Connection *connection, void **con_cls, const char *upload_data, size_t *upload_data_size, json_t **json) |
Process a POST request containing a JSON object. More... | |
void | GNUNET_JSON_post_parser_cleanup (void *con_cls) |
Function called whenever we are done with a request to clean up our state. 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_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... | |
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 196 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 219 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 429 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 440 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 645 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 801 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 832 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 64 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 598 of file gnunet_json_lib.h.
Return codes from GNUNET_JSON_post_parser().
Enumerator | |
---|---|
GNUNET_JSON_PR_SUCCESS | Parsing successful, JSON result is in |
GNUNET_JSON_PR_CONTINUE | Parsing continues, call again soon! |
GNUNET_JSON_PR_OUT_OF_MEMORY | Sorry, memory allocation (malloc()) failed. |
GNUNET_JSON_PR_REQUEST_TOO_LARGE | Request size exceeded |
GNUNET_JSON_PR_JSON_INVALID | JSON parsing failed. This was not a JSON upload. |
Definition at line 498 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. | |
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 1 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, consensus-simulation::parser, and GNUNET_JSON_Specification::parser.
Referenced by add_attribute_cont(), add_credential_cont(), bulk_tx_start(), consume_ticket_cont(), namestore_add_or_update(), and revoke_ticket_cont().
void GNUNET_JSON_parse_free | ( | struct GNUNET_JSON_Specification * | spec | ) |
Frees all elements allocated during a GNUNET_JSON_parse() operation.
spec | specification of the parse operation |
Definition at line 94 of file json.c.
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 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().
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. |
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
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.
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 978 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.
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.
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.
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 893 of file json_helper.c.
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 978 of file json_helper.c.
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 buf, 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(), and GNUNET_JSON_from_rsa_signature().
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 53 of file json_generator.c.
References buf, data, GNUNET_break, GNUNET_free, GNUNET_MAX_MALLOC_CHECKED, GNUNET_STRINGS_base64_encode(), len, and size.
json_t* GNUNET_JSON_from_timestamp | ( | struct GNUNET_TIME_Timestamp | stamp | ) |
Convert timestamp to a json string.
stamp | the time stamp |
Definition at line 83 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().
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 127 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 134 of file json_generator.c.
References GNUNET_break, GNUNET_TIME_relative_is_forever(), and GNUNET_TIME_Relative::rel_value_us.
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 178 of file json_generator.c.
References buf, GNUNET_CRYPTO_rsa_public_key_encode(), GNUNET_free, GNUNET_JSON_from_data(), pk, and ret.
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 194 of file json_generator.c.
References buf, GNUNET_CRYPTO_rsa_signature_encode(), GNUNET_free, GNUNET_JSON_from_data(), and ret.
enum GNUNET_JSON_PostResult GNUNET_JSON_post_parser | ( | size_t | buffer_max, |
struct MHD_Connection * | connection, | ||
void ** | con_cls, | ||
const char * | upload_data, | ||
size_t * | upload_data_size, | ||
json_t ** | json | ||
) |
Process a POST request containing a JSON object.
This function realizes an MHD POST processor that will (incrementally) process JSON data uploaded to the HTTP server. It will store the required state in the con_cls, which must be cleaned up using #GNUNET_JSON_post_parser_callback().
buffer_max | maximum allowed size for the buffer |
connection | MHD connection handle (for meta data about the upload) |
con_cls | the closure (will point to a struct Buffer * ) |
upload_data | the POST data |
upload_data_size | number of bytes in upload_data |
json | the JSON object for a completed request |
Definition at line 122 of file json_mhd.c.
Referenced by create_response().
void GNUNET_JSON_post_parser_cleanup | ( | void * | con_cls | ) |
Function called whenever we are done with a request to clean up our state.
con_cls | value as it was left by GNUNET_JSON_post_parser(), to be cleaned up |
Definition at line 367 of file json_mhd.c.
References buffer_deinit(), and GNUNET_free.
Referenced by create_response().
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 94 of file json.c.
References GNUNET_JSON_Specification::cleaner, GNUNET_JSON_Specification::cls, and GNUNET_JSON_Specification::parser.
json_t* GNUNET_JSON_pack_ | ( | struct GNUNET_JSON_PackSpec | spec[] | ) |
Pack a JSON object from a spec.
Aborts if packing fails.
spec | specification object |
Definition at line 30 of file json_pack.c.
References GNUNET_JSON_PackSpec::field_name, GNUNET_assert, 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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.
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 30 of file json_pack.c.