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_RELATIVE_EXPIRATION_TIME "relative_expiration"
35 #define GNUNET_JSON_GNSRECORD_ABSOLUTE_EXPIRATION_TIME "absolute_expiration"
36 #define GNUNET_JSON_GNSRECORD_FLAG_PRIVATE "is_private"
37 #define GNUNET_JSON_GNSRECORD_FLAG_SUPPLEMENTAL "is_supplemental"
38 #define GNUNET_JSON_GNSRECORD_FLAG_RELATIVE "is_relative_expiration"
39 #define GNUNET_JSON_GNSRECORD_FLAG_SHADOW "is_shadow"
40 #define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name"
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;
97 unpack_state = json_unpack_ex (
data,
100 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b}",
115 if (0 != unpack_state)
118 "Error gnsdata object has a wrong format: `%s'!\n",
120 unpack_state = json_unpack_ex (
data,
123 "{s:s, s:s, s:I, s:b, s:b, s:b, s:b}",
138 if ((0 != unpack_state) || (is_rel_exp))
141 "Error gnsdata object has a wrong format: `%s'!\n",
142 (is_rel_exp) ?
"No relative expiration given" : err.text);
168 if (1 == supplemental)
188 if (! json_is_array (
data))
191 "Error gns record data JSON is not an array!\n");
196 * json_array_size (
data));
214 int unpack_state = 0;
219 if (! json_is_object (root))
222 "Error record JSON is not an object!\n");
226 unpack_state = json_unpack (root,
232 if (0 != unpack_state)
235 "Error namestore records object has a wrong format!\n");
277 gnsrecord_info->
rd =
rd;
304 const char *record_type_str;
310 data = json_object ();
317 json_object_set_new (
data,
319 json_string (rname)))
339 "Packing %s %s %lu %d\n",
340 value_str, record_type_str,
rd[i].expiration_time,
rd[i].flags);
341 record = json_pack (
"{s:s,s:s,s:I,s:b,s:b,s:b,s:b}",
348 rd[i].expiration_time,
366 json_array_append_new (
records,
376 json_object_set_new (
data,
static int ret
Return value of the commandline.
static size_t data_size
Number of bytes in data.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
uint32_t data
The data value.
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 unsigned int records
Number of records we found.
API that can be used to manipulate GNS record data.
functions to parse JSON objects into GNUnet objects
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
@ 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_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.
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.
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.
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.
#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_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