diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2022-07-08 14:37:03 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2022-07-08 14:37:03 +0200 |
commit | 78cba4124a993ba97923ff0543f2a5942f297cdc (patch) | |
tree | 8c44038e1e9d6820bc906a046abffc47566fe534 /src/json/json_helper.c | |
parent | 3abeb45550e1cbf4939583c9b6ff48335fe6f1a9 (diff) | |
download | gnunet-78cba4124a993ba97923ff0543f2a5942f297cdc.tar.gz gnunet-78cba4124a993ba97923ff0543f2a5942f297cdc.zip |
timestamps are in seconds, kill redundant _ms variant
Diffstat (limited to 'src/json/json_helper.c')
-rw-r--r-- | src/json/json_helper.c | 53 |
1 files changed, 9 insertions, 44 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c index def26afb8..27bb9f41c 100644 --- a/src/json/json_helper.c +++ b/src/json/json_helper.c | |||
@@ -111,7 +111,7 @@ GNUNET_JSON_spec_fixed (const char *name, | |||
111 | * @param[out] spec where to write the data | 111 | * @param[out] spec where to write the data |
112 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 112 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
113 | */ | 113 | */ |
114 | static int | 114 | static enum GNUNET_GenericReturnValue |
115 | parse_variable_data (void *cls, | 115 | parse_variable_data (void *cls, |
116 | json_t *root, | 116 | json_t *root, |
117 | struct GNUNET_JSON_Specification *spec) | 117 | struct GNUNET_JSON_Specification *spec) |
@@ -190,7 +190,7 @@ GNUNET_JSON_spec_varsize (const char *name, | |||
190 | * @param[out] spec where to write the data | 190 | * @param[out] spec where to write the data |
191 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 191 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
192 | */ | 192 | */ |
193 | static int | 193 | static enum GNUNET_GenericReturnValue |
194 | parse_string (void *cls, | 194 | parse_string (void *cls, |
195 | json_t *root, | 195 | json_t *root, |
196 | struct GNUNET_JSON_Specification *spec) | 196 | struct GNUNET_JSON_Specification *spec) |
@@ -236,7 +236,7 @@ GNUNET_JSON_spec_string (const char *name, | |||
236 | * @param[out] spec where to write the data | 236 | * @param[out] spec where to write the data |
237 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 237 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
238 | */ | 238 | */ |
239 | static int | 239 | static enum GNUNET_GenericReturnValue |
240 | parse_object (void *cls, | 240 | parse_object (void *cls, |
241 | json_t *root, | 241 | json_t *root, |
242 | struct GNUNET_JSON_Specification *spec) | 242 | struct GNUNET_JSON_Specification *spec) |
@@ -299,7 +299,7 @@ GNUNET_JSON_spec_json (const char *name, | |||
299 | * @param[out] spec where to write the data | 299 | * @param[out] spec where to write the data |
300 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 300 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
301 | */ | 301 | */ |
302 | static int | 302 | static enum GNUNET_GenericReturnValue |
303 | parse_bool (void *cls, | 303 | parse_bool (void *cls, |
304 | json_t *root, | 304 | json_t *root, |
305 | struct GNUNET_JSON_Specification *spec) | 305 | struct GNUNET_JSON_Specification *spec) |
@@ -347,7 +347,7 @@ GNUNET_JSON_spec_bool (const char *name, | |||
347 | * @param[out] spec where to write the data | 347 | * @param[out] spec where to write the data |
348 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 348 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
349 | */ | 349 | */ |
350 | static int | 350 | static enum GNUNET_GenericReturnValue |
351 | parse_u8 (void *cls, | 351 | parse_u8 (void *cls, |
352 | json_t *root, | 352 | json_t *root, |
353 | struct GNUNET_JSON_Specification *spec) | 353 | struct GNUNET_JSON_Specification *spec) |
@@ -397,7 +397,7 @@ GNUNET_JSON_spec_uint8 (const char *name, | |||
397 | * @param[out] spec where to write the data | 397 | * @param[out] spec where to write the data |
398 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 398 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
399 | */ | 399 | */ |
400 | static int | 400 | static enum GNUNET_GenericReturnValue |
401 | parse_u16 (void *cls, | 401 | parse_u16 (void *cls, |
402 | json_t *root, | 402 | json_t *root, |
403 | struct GNUNET_JSON_Specification *spec) | 403 | struct GNUNET_JSON_Specification *spec) |
@@ -447,7 +447,7 @@ GNUNET_JSON_spec_uint16 (const char *name, | |||
447 | * @param[out] spec where to write the data | 447 | * @param[out] spec where to write the data |
448 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 448 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
449 | */ | 449 | */ |
450 | static int | 450 | static enum GNUNET_GenericReturnValue |
451 | parse_u32 (void *cls, | 451 | parse_u32 (void *cls, |
452 | json_t *root, | 452 | json_t *root, |
453 | struct GNUNET_JSON_Specification *spec) | 453 | struct GNUNET_JSON_Specification *spec) |
@@ -497,7 +497,7 @@ GNUNET_JSON_spec_uint32 (const char *name, | |||
497 | * @param[out] spec where to write the data | 497 | * @param[out] spec where to write the data |
498 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 498 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
499 | */ | 499 | */ |
500 | static int | 500 | static enum GNUNET_GenericReturnValue |
501 | parse_u64 (void *cls, | 501 | parse_u64 (void *cls, |
502 | json_t *root, | 502 | json_t *root, |
503 | struct GNUNET_JSON_Specification *spec) | 503 | struct GNUNET_JSON_Specification *spec) |
@@ -542,7 +542,7 @@ GNUNET_JSON_spec_uint64 (const char *name, | |||
542 | * @param[out] spec where to write the data | 542 | * @param[out] spec where to write the data |
543 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error | 543 | * @return #GNUNET_OK upon successful parsing; #GNUNET_SYSERR upon error |
544 | */ | 544 | */ |
545 | static int | 545 | static enum GNUNET_GenericReturnValue |
546 | parse_i64 (void *cls, | 546 | parse_i64 (void *cls, |
547 | json_t *root, | 547 | json_t *root, |
548 | struct GNUNET_JSON_Specification *spec) | 548 | struct GNUNET_JSON_Specification *spec) |
@@ -596,7 +596,6 @@ parse_timestamp (void *cls, | |||
596 | { | 596 | { |
597 | struct GNUNET_TIME_Timestamp *ts = spec->ptr; | 597 | struct GNUNET_TIME_Timestamp *ts = spec->ptr; |
598 | json_t *json_t_s; | 598 | json_t *json_t_s; |
599 | json_t *json_t_ms; | ||
600 | unsigned long long int tval; | 599 | unsigned long long int tval; |
601 | 600 | ||
602 | if (! json_is_object (root)) | 601 | if (! json_is_object (root)) |
@@ -636,40 +635,6 @@ parse_timestamp (void *cls, | |||
636 | GNUNET_break_op (0); | 635 | GNUNET_break_op (0); |
637 | return GNUNET_SYSERR; | 636 | return GNUNET_SYSERR; |
638 | } | 637 | } |
639 | json_t_ms = json_object_get (root, | ||
640 | "t_ms"); | ||
641 | if (json_is_integer (json_t_ms)) | ||
642 | { | ||
643 | tval = json_integer_value (json_t_ms); | ||
644 | GNUNET_break_op (0 == tval % 1000); | ||
645 | tval -= tval % 1000; | ||
646 | /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */ | ||
647 | ts->abs_time.abs_value_us | ||
648 | = tval * GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us; | ||
649 | if (ts->abs_time.abs_value_us | ||
650 | / GNUNET_TIME_UNIT_MILLISECONDS.rel_value_us | ||
651 | != tval) | ||
652 | { | ||
653 | /* Integer overflow */ | ||
654 | GNUNET_break_op (0); | ||
655 | return GNUNET_SYSERR; | ||
656 | } | ||
657 | return GNUNET_OK; | ||
658 | } | ||
659 | if (json_is_string (json_t_ms)) | ||
660 | { | ||
661 | const char *val; | ||
662 | |||
663 | val = json_string_value (json_t_ms); | ||
664 | if ((0 == strcasecmp (val, | ||
665 | "never"))) | ||
666 | { | ||
667 | ts->abs_time = GNUNET_TIME_UNIT_FOREVER_ABS; | ||
668 | return GNUNET_OK; | ||
669 | } | ||
670 | GNUNET_break_op (0); | ||
671 | return GNUNET_SYSERR; | ||
672 | } | ||
673 | GNUNET_break_op (0); | 638 | GNUNET_break_op (0); |
674 | return GNUNET_SYSERR; | 639 | return GNUNET_SYSERR; |
675 | } | 640 | } |