diff options
Diffstat (limited to 'src/json/json_generator.c')
-rw-r--r-- | src/json/json_generator.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/json/json_generator.c b/src/json/json_generator.c index dd875871e..594fcaf27 100644 --- a/src/json/json_generator.c +++ b/src/json/json_generator.c | |||
@@ -213,7 +213,8 @@ GNUNET_JSON_from_gnsrecord (const char*rname, | |||
213 | const struct GNUNET_GNSRECORD_Data *rd, | 213 | const struct GNUNET_GNSRECORD_Data *rd, |
214 | unsigned int rd_count) | 214 | unsigned int rd_count) |
215 | { | 215 | { |
216 | struct GNUNET_TIME_Absolute expiration_time; | 216 | struct GNUNET_TIME_Absolute abs_exp; |
217 | struct GNUNET_TIME_Relative rel_exp; | ||
217 | const char *expiration_time_str; | 218 | const char *expiration_time_str; |
218 | const char *record_type_str; | 219 | const char *record_type_str; |
219 | char *value_str; | 220 | char *value_str; |
@@ -248,22 +249,34 @@ GNUNET_JSON_from_gnsrecord (const char*rname, | |||
248 | value_str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, | 249 | value_str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, |
249 | rd[i].data, | 250 | rd[i].data, |
250 | rd[i].data_size); | 251 | rd[i].data_size); |
251 | expiration_time = GNUNET_GNSRECORD_record_get_expiration_time (1, &rd[i]); | 252 | if (GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION & rd[i].flags) |
252 | expiration_time_str = GNUNET_STRINGS_absolute_time_to_string ( | 253 | { |
253 | expiration_time); | 254 | rel_exp.rel_value_us = rd[i].expiration_time; |
255 | expiration_time_str = GNUNET_STRINGS_relative_time_to_string (rel_exp, | ||
256 | GNUNET_NO); | ||
257 | } else { | ||
258 | abs_exp.abs_value_us = rd[i].expiration_time; | ||
259 | expiration_time_str = GNUNET_STRINGS_absolute_time_to_string (abs_exp); | ||
260 | } | ||
254 | record_type_str = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); | 261 | record_type_str = GNUNET_GNSRECORD_number_to_typename (rd[i].record_type); |
255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
256 | "Packing %s %s %s %d\n", | 263 | "Packing %s %s %s %d\n", |
257 | value_str, record_type_str, expiration_time_str, rd[i].flags); | 264 | value_str, record_type_str, expiration_time_str, rd[i].flags); |
258 | record = json_pack ("{s:s,s:s,s:s,s:i}", | 265 | record = json_pack ("{s:s,s:s,s:s,s:b,s:b,s:b,s:b}", |
259 | "value", | 266 | "value", |
260 | value_str, | 267 | value_str, |
261 | "record_type", | 268 | "record_type", |
262 | record_type_str, | 269 | record_type_str, |
263 | "expiration_time", | 270 | "expiration_time", |
264 | expiration_time_str, | 271 | expiration_time_str, |
265 | "flag", | 272 | "private", |
266 | rd[i].flags); | 273 | rd[i].flags & GNUNET_GNSRECORD_RF_PRIVATE, |
274 | "relative_expiration", | ||
275 | rd[i].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION, | ||
276 | "supplemental", | ||
277 | rd[i].flags & GNUNET_GNSRECORD_RF_SUPPLEMENTAL, | ||
278 | "shadow", | ||
279 | rd[i].flags & GNUNET_GNSRECORD_RF_SHADOW_RECORD); | ||
267 | GNUNET_free (value_str); | 280 | GNUNET_free (value_str); |
268 | if (NULL == record) | 281 | if (NULL == record) |
269 | { | 282 | { |