63 if (NULL == (enc = json_string_value (root)))
69 if (((len * 5) / 8) != spec->
ptr_size)
132 str = json_string_value (root);
138 size = (strlen (str) * 5) / 8;
155 *(
void **) spec->
ptr = data;
174 *(
void **) spec->
ptr = NULL;
224 str = json_string_value (root);
230 *(
const char **) spec->
ptr = str;
273 if (! (json_is_object (root) || json_is_array (root)))
279 *(json_t **) spec->
ptr = root;
294 json_t **
ptr = (json_t **) spec->
ptr;
344 if (json_true () == root)
349 if (json_false () == root)
375 .ptr_size =
sizeof(bool),
397 uint8_t *up = spec->
ptr;
399 if (! json_is_integer (root))
404 val = json_integer_value (root);
405 if ((0 > val) || (val > UINT8_MAX))
431 .ptr_size =
sizeof(uint8_t),
453 uint16_t *up = spec->
ptr;
455 if (! json_is_integer (root))
460 val = json_integer_value (root);
461 if ((0 > val) || (val > UINT16_MAX))
466 *up = (uint16_t) val;
487 .ptr_size =
sizeof(uint16_t),
509 uint32_t *up = spec->
ptr;
511 if (! json_is_integer (root))
516 val = json_integer_value (root);
517 if ((0 > val) || (val > UINT32_MAX))
522 *up = (uint32_t) val;
543 .ptr_size =
sizeof(uint32_t),
565 uint64_t *up = spec->
ptr;
567 if (! json_is_integer (root))
572 val = json_integer_value (root);
573 *up = (uint64_t) val;
594 .ptr_size =
sizeof(uint64_t),
616 int64_t *up = spec->
ptr;
618 if (! json_is_integer (root))
623 val = json_integer_value (root);
645 .ptr_size =
sizeof(int64_t),
670 unsigned long long int tval;
672 if (! json_is_object (root))
677 json_t_ms = json_object_get (root,
"t_ms");
678 if (json_is_integer (json_t_ms))
680 tval = json_integer_value (json_t_ms);
691 if (json_is_string (json_t_ms))
694 val = json_string_value (json_t_ms);
695 if ((0 == strcasecmp (val,
"never")))
801 unsigned long long int tval;
803 if (! json_is_object (root))
808 json_d_ms = json_object_get (root,
"d_ms");
809 if (json_is_integer (json_d_ms))
811 tval = json_integer_value (json_d_ms);
822 if (json_is_string (json_d_ms))
825 val = json_string_value (json_d_ms);
826 if ((0 == strcasecmp (val,
"forever")))
882 if (NULL == (enc = json_string_value (root)))
888 buf_len = (len * 5) / 8;
976 str = json_string_value (root);
982 size = (strlen (str) * 5) / 8;
1064 int *bp = spec->
ptr;
1066 if (! json_is_boolean (root))
1092 .ptr_size =
sizeof(int),
void * cls
Closure for parser and cleaner.
static void clean_variable_data(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing variable size data.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint32(const char *name, uint32_t *u32)
32-bit integer.
uint64_t rel_value_us
The actual value.
void GNUNET_CRYPTO_rsa_signature_free(struct GNUNET_CRYPTO_RsaSignature *sig)
Free memory occupied by signature.
functions to parse JSON objects into GNUnet objects
static int parse_rsa_public_key(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA public key.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_json(const char *name, json_t **jsonp)
JSON object.
static int parse_u16(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint16_t.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint16(const char *name, uint16_t *u16)
16-bit integer.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time_nbo(const char *name, struct GNUNET_TIME_AbsoluteNBO *at)
Absolute time in network byte order.
static int ret
Return value of the commandline.
Entry in parser specification for GNUNET_JSON_parse().
static int parse_rsa_signature(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to RSA signature.
static int parse_bool(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a bool.
static void clean_rsa_signature(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA signature.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
uint64_t abs_value_us
The actual value.
The public information of an RSA key pair.
struct GNUNET_CRYPTO_RsaSignature * GNUNET_CRYPTO_rsa_signature_decode(const void *buf, size_t buf_size)
Decode the signature from the data-format back to the "normal", internal format.
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static int parse_u32(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint32_t.
static int parse_object(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a JSON object.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
struct GNUNET_CRYPTO_RsaPublicKey * GNUNET_CRYPTO_rsa_public_key_decode(const char *buf, size_t len)
Decode the public key from the data-format back to the "normal", internal format. ...
static void clean_rsa_public_key(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing RSA public key.
static void clean_object(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing JSON object.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
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).
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_bool(const char *name, bool *b)
boolean.
static int parse_i64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a int64_t.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_end()
End of a parser specification.
static int parse_boolean(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to an int as a boolean.
static unsigned int size
Size of the "table".
static int parse_variable_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to variable size data.
void * ptr
Pointer, details specific to the parser.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint8(const char *name, uint8_t *u8)
8-bit integer.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_rsa_signature(const char *name, struct GNUNET_CRYPTO_RsaSignature **sig)
Specification for parsing an RSA signature.
static int parse_u64(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint64_t.
static int parse_string(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to string.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_uint64(const char *name, uint64_t *u64)
64-bit integer.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_string(const char *name, const char **strptr)
The expected field stores a string.
static int parse_rel_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to relative time.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_relative_time(const char *name, struct GNUNET_TIME_Relative *rt)
Relative time.
struct GNUNET_IDENTITY_PrivateKey pk
Private key from command line option, or NULL.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_boolean(const char *name, int *boolean)
Boolean (true mapped to GNUNET_YES, false mapped to GNUNET_NO).
static int parse_fixed_data(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to fixed size data.
static OpusEncoder * enc
OPUS encoder.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_absolute_time(const char *name, struct GNUNET_TIME_Absolute *at)
Absolute time.
size_t ptr_size
Number of bytes available in ptr.
size_t * size_ptr
Where should we store the final size of ptr.
static int parse_u8(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to a uint8_t.
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).
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.
void GNUNET_CRYPTO_rsa_public_key_free(struct GNUNET_CRYPTO_RsaPublicKey *key)
Free memory occupied by the public key.
Time for absolute times used by GNUnet, in microseconds.
static int parse_abs_time_nbo(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
uint32_t data
The data value.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
struct GNUNET_JSON_Specification GNUNET_JSON_spec_int64(const char *name, int64_t *i64)
64-bit signed integer.
static int parse_abs_time(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
Parse given JSON object to absolute time.
#define GNUNET_malloc(size)
Wrapper around malloc.
int GNUNET_STRINGS_string_to_data(const char *enc, size_t enclen, void *out, size_t out_size)
Convert CrockfordBase32 encoding back to data.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...