31 #define GNUNET_JSON_GNSRECORD_VALUE "value" 32 #define GNUNET_JSON_GNSRECORD_RECORD_DATA "data" 33 #define GNUNET_JSON_GNSRECORD_TYPE "record_type" 34 #define GNUNET_JSON_GNSRECORD_EXPIRATION_TIME "expiration_time" 35 #define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE "private" 36 #define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL "supplemental" 37 #define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE "relative_expiration" 38 #define GNUNET_JSON_GNSRECORD_FLAG_SHADOW "shadow" 39 #define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name" 40 #define GNUNET_JSON_GNSRECORD_NEVER "never" 57 if (NULL != *(gnsrecord_info->
rd))
59 for (
int i = 0; i < *(gnsrecord_info->
rd_count); i++)
61 tmp = (
char*) (*(gnsrecord_info->
rd))[i].
data;
66 *(gnsrecord_info->
rd) = NULL;
68 if (NULL != *(gnsrecord_info->
name))
70 *(gnsrecord_info->
name) = NULL;
88 const char *record_type;
89 const char *expiration_time;
97 unpack_state = json_unpack (data,
98 "{s:s, s:s, s:s, s:b, s:b, s:b, s:b}",
113 if (0 != unpack_state)
116 "Error gnsdata object has a wrong format!\n");
138 else if ((1 != rel_exp) &&
141 &abs_expiration_time)))
147 &rel_expiration_time))
159 if (1 == supplemental)
179 if (! json_is_array (data))
182 "Error gns record data JSON is not an array!\n");
185 *(gnsrecord_info->
rd_count) = json_array_size (data);
187 * json_array_size (data));
190 json_array_foreach (data, index, value)
205 int unpack_state = 0;
210 if (! json_is_object (root))
213 "Error record JSON is not an object!\n");
217 unpack_state = json_unpack (root,
223 if (0 != unpack_state)
226 "Error namestore records object has a wrong format!\n");
268 gnsrecord_info->
rd =
rd;
297 const char *expiration_time_str;
298 const char *record_type_str;
304 data = json_object ();
311 json_object_set_new (data,
313 json_string (rname)))
319 records = json_array ();
344 "Packing %s %s %s %d\n",
345 value_str, record_type_str, expiration_time_str, rd[i].flags);
346 record = json_pack (
"{s:s,s:s,s:s,s:b,s:b,s:b,s:b}",
355 "relative_expiration",
365 json_decref (records);
370 json_array_append_new (records,
374 json_decref (records);
380 json_object_set_new (data,
#define GNUNET_JSON_GNSRECORD_VALUE
#define GNUNET_JSON_GNSRECORD_RECORD_NAME
This record should not be used unless all (other) records with an absolute expiration time have expir...
#define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL
uint64_t rel_value_us
The actual value.
functions to parse JSON objects into GNUnet objects
static size_t data_size
Number of bytes in data.
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_JSON_GNSRECORD_EXPIRATION_TIME
int GNUNET_STRINGS_fancy_time_to_relative(const char *fancy_time, struct GNUNET_TIME_Relative *rtime)
Convert a given fancy human-readable time to our internal representation.
static int ret
Return value of the commandline.
int GNUNET_STRINGS_fancy_time_to_absolute(const char *fancy_time, struct GNUNET_TIME_Absolute *atime)
Convert a given fancy human-readable time to our internal representation.
This is a supplemental record.
static int parse_record_data(struct GnsRecordInfo *gnsrecord_info, json_t *data)
Parse given JSON object to gns record.
Entry in parser specification for GNUNET_JSON_parse().
size_t data_size
Number of bytes in data.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
uint64_t abs_value_us
The actual value.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_TIME_UNIT_FOREVER_ABS
Constant used to specify "forever".
static unsigned int records
Number of records we found.
static void cleanup_recordinfo(struct GnsRecordInfo *gnsrecord_info)
#define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE
static int parse_gnsrecordobject(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
const void * data
Binary value stored in the DNS record.
static char * value
Value of the record to add/remove.
uint64_t expiration_time
Expiration time for the DNS record.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
This is a private record of this peer and it should thus not be handed out to other peers...
GNUNET_JSON_Parser parser
Function for how to parse this type of entry.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of a 'value' of a record to the binary representation.
struct GNUNET_JSON_Specification GNUNET_GNSRECORD_JSON_spec_gnsrecord(struct GNUNET_GNSRECORD_Data **rd, unsigned int *rd_count, char **name)
JSON Specification for GNS Records.
void * ptr
Pointer, details specific to the parser.
#define GNUNET_JSON_GNSRECORD_TYPE
static int parse_record(json_t *data, struct GNUNET_GNSRECORD_Data *rd)
Parse given JSON object to gns record.
json_t * GNUNET_GNSRECORD_JSON_from_gnsrecord(const char *rname, const struct GNUNET_GNSRECORD_Data *rd, unsigned int rd_count)
Convert GNS record to JSON.
uint32_t record_type
Type of the GNS/DNS record.
static void clean_gnsrecordobject(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing the record.
#define GNUNET_log(kind,...)
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
Time for absolute times used by GNUnet, in microseconds.
struct GNUNET_GNSRECORD_Data ** rd
#define GNUNET_JSON_GNSRECORD_NEVER
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
This expiration time of the record is a relative time (not an absolute time).
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
#define GNUNET_JSON_GNSRECORD_RECORD_DATA
uint32_t data
The data value.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the 'value' of a record to a string.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number (i.e.
#define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
Time for relative time used by GNUnet, in microseconds.
#define GNUNET_JSON_GNSRECORD_FLAG_SHADOW