32#define GNUNET_JSON_GNSRECORD_VALUE "value"
33#define GNUNET_JSON_GNSRECORD_RECORD_DATA "data"
34#define GNUNET_JSON_GNSRECORD_TYPE "record_type"
35#define GNUNET_JSON_GNSRECORD_RELATIVE_EXPIRATION_TIME "relative_expiration"
36#define GNUNET_JSON_GNSRECORD_ABSOLUTE_EXPIRATION_TIME "absolute_expiration"
37#define GNUNET_JSON_GNSRECORD_FLAG_MAINTENANCE "is_maintenance"
38#define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE "is_private"
39#define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL "is_supplemental"
40#define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE "is_relative_expiration"
41#define GNUNET_JSON_GNSRECORD_FLAG_SHADOW "is_shadow"
42#define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name"
59 if (NULL != *(gnsrecord_info->
rd))
61 for (
int i = 0; i < *(gnsrecord_info->
rd_count); i++)
63 tmp = (
char*) (*(gnsrecord_info->
rd))[i].
data;
68 *(gnsrecord_info->
rd) = NULL;
70 if (NULL != *(gnsrecord_info->
name))
72 *(gnsrecord_info->
name) = NULL;
90 const char *record_type;
100 unpack_state = json_unpack_ex (
data,
103 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b, s:b}",
120 if (0 != unpack_state)
123 "Error gnsdata object has a wrong format: `%s'!\n",
125 unpack_state = json_unpack_ex (
data,
128 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b, s:b}",
145 if ((0 != unpack_state) || (is_rel_exp))
148 "Error gnsdata object has a wrong format: `%s'!\n",
149 (is_rel_exp) ?
"No relative expiration given" : err.text);
175 if (1 == maintenance)
179 if (1 == supplemental)
199 if (! json_is_array (
data))
202 "Error gns record data JSON is not an array!\n");
207 * json_array_size (
data));
227 int unpack_state = 0;
232 if (! json_is_object (root))
235 "Error record JSON is not an object!\n");
239 unpack_state = json_unpack (root,
245 if (0 != unpack_state)
248 "Error namestore records object has a wrong format!\n");
298 gnsrecord_info->
rd =
rd;
317 const char *record_type_str;
323 data = json_object ();
330 json_object_set_new (
data,
332 json_string (rname)))
352 "Packing %s %s %" PRIu64
" %d\n",
353 value_str, record_type_str,
rd[i].expiration_time,
rd[i].flags);
355 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b, s:b}",
361 rd[i].expiration_time,
381 json_array_append_new (
records,
391 json_object_set_new (
data,
static int ret
Final status code.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static char * data
The data to insert into the dht.
static char * name
Name (label) of the records to list.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static char * value
Value of the record to add/remove.
static size_t data_size
Number of bytes in data.
static unsigned int records
Number of records we found.
API that can be used to manipulate JSON GNS record data.
API that can be used to manipulate GNS record data.
functions to parse JSON objects into GNUnet objects
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.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g.
int GNUNET_GNSRECORD_string_to_value(uint32_t type, const char *s, void **data, size_t *data_size)
Convert human-readable version of the value s of a record of type type to the respective binary repre...
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.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
@ GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION
This expiration time of the record is a relative time (not an absolute time).
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
@ GNUNET_GNSRECORD_RF_MAINTENANCE
Maintenance records.
@ GNUNET_GNSRECORD_RF_SHADOW
This record should not be used unless all (other) records in the set with an absolute expiration time...
@ GNUNET_GNSRECORD_RF_PRIVATE
This is a private record of this peer and it should thus not be published.
#define GNUNET_log(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_JSON_GNSRECORD_FLAG_SHADOW
static int parse_record_data(struct GnsRecordInfo *gnsrecord_info, json_t *data)
Parse given JSON object to gns record.
#define GNUNET_JSON_GNSRECORD_VALUE
#define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE
#define GNUNET_JSON_GNSRECORD_FLAG_MAINTENANCE
#define GNUNET_JSON_GNSRECORD_ABSOLUTE_EXPIRATION_TIME
#define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL
static void clean_gnsrecordobject(void *cls, struct GNUNET_JSON_Specification *spec)
Cleanup data left from parsing the record.
#define GNUNET_JSON_GNSRECORD_RELATIVE_EXPIRATION_TIME
#define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE
static int parse_record(json_t *data, struct GNUNET_GNSRECORD_Data *rd)
Parse given JSON object to gns record.
#define GNUNET_JSON_GNSRECORD_RECORD_NAME
#define GNUNET_JSON_GNSRECORD_TYPE
static int parse_gnsrecordobject(void *cls, json_t *root, struct GNUNET_JSON_Specification *spec)
static void cleanup_recordinfo(struct GnsRecordInfo *gnsrecord_info)
#define GNUNET_JSON_GNSRECORD_RECORD_DATA
uint32_t record_type
Type of the GNS/DNS record.
const void * data
Binary value stored in the DNS record.
size_t data_size
Number of bytes in data.
enum GNUNET_GNSRECORD_Flags flags
Flags for the record.
uint64_t expiration_time
Expiration time for the DNS record.
Entry in parser specification for GNUNET_JSON_parse().
void * ptr
Pointer, details specific to the parser.
Time for absolute times used by GNUnet, in microseconds.
uint64_t abs_value_us
The actual value.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
struct GNUNET_GNSRECORD_Data ** rd