aboutsummaryrefslogtreecommitdiff
path: root/src/json/json_helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-12-22 13:13:56 +0100
committerChristian Grothoff <christian@grothoff.org>2019-12-22 13:13:56 +0100
commitfddbcfc58514509e00b4b7f72d97f344233fde51 (patch)
tree776d9b49575def7dbbc73f909e438d5d6ea4d1f3 /src/json/json_helper.c
parent6d8ba0321cde6cf5dd240b9cbcf36dc95bfdc798 (diff)
downloadgnunet-fddbcfc58514509e00b4b7f72d97f344233fde51.tar.gz
gnunet-fddbcfc58514509e00b4b7f72d97f344233fde51.zip
flo forgot to update the NBO parser
Diffstat (limited to 'src/json/json_helper.c')
-rw-r--r--src/json/json_helper.c44
1 files changed, 10 insertions, 34 deletions
diff --git a/src/json/json_helper.c b/src/json/json_helper.c
index e7711a03e..a405b8c3b 100644
--- a/src/json/json_helper.c
+++ b/src/json/json_helper.c
@@ -564,7 +564,7 @@ parse_abs_time (void *cls,
564 json_t *json_t_ms; 564 json_t *json_t_ms;
565 unsigned long long int tval; 565 unsigned long long int tval;
566 566
567 if (!json_is_object (root)) 567 if (! json_is_object (root))
568 { 568 {
569 GNUNET_break_op (0); 569 GNUNET_break_op (0);
570 return GNUNET_SYSERR; 570 return GNUNET_SYSERR;
@@ -638,41 +638,17 @@ parse_abs_time_nbo (void *cls,
638 struct GNUNET_JSON_Specification *spec) 638 struct GNUNET_JSON_Specification *spec)
639{ 639{
640 struct GNUNET_TIME_AbsoluteNBO *abs = spec->ptr; 640 struct GNUNET_TIME_AbsoluteNBO *abs = spec->ptr;
641 const char *val;
642 unsigned long long int tval;
643 struct GNUNET_TIME_Absolute a; 641 struct GNUNET_TIME_Absolute a;
642 struct GNUNET_JSON_Specification ispec;
644 643
645 val = json_string_value (root); 644 ispec = *spec;
646 if (NULL == val) 645 ispec.parser = &parse_abs_time;
647 { 646 ispec.ptr = &a;
648 GNUNET_break_op (0); 647 if (GNUNET_OK !=
649 return GNUNET_SYSERR; 648 parse_abs_time (NULL,
650 } 649 root,
651 if ((0 == strcasecmp (val, 650 &ispec))
652 "/forever/")) ||
653 (0 == strcasecmp (val,
654 "/end of time/")) ||
655 (0 == strcasecmp (val,
656 "/never/")))
657 {
658 *abs = GNUNET_TIME_absolute_hton (GNUNET_TIME_UNIT_FOREVER_ABS);
659 return GNUNET_OK;
660 }
661 if (1 != sscanf (val,
662 "/Date(%llu)/",
663 &tval))
664 {
665 GNUNET_break_op (0);
666 return GNUNET_SYSERR;
667 }
668 /* Time is in seconds in JSON, but in microseconds in GNUNET_TIME_Absolute */
669 a.abs_value_us = tval * 1000LL * 1000LL;
670 if ((a.abs_value_us) / 1000LL / 1000LL != tval)
671 {
672 /* Integer overflow */
673 GNUNET_break_op (0);
674 return GNUNET_SYSERR; 651 return GNUNET_SYSERR;
675 }
676 *abs = GNUNET_TIME_absolute_hton (a); 652 *abs = GNUNET_TIME_absolute_hton (a);
677 return GNUNET_OK; 653 return GNUNET_OK;
678} 654}
@@ -719,7 +695,7 @@ parse_rel_time (void *cls,
719 json_t *json_d_ms; 695 json_t *json_d_ms;
720 unsigned long long int tval; 696 unsigned long long int tval;
721 697
722 if (!json_is_object (root)) 698 if (! json_is_object (root))
723 { 699 {
724 GNUNET_break_op (0); 700 GNUNET_break_op (0);
725 return GNUNET_SYSERR; 701 return GNUNET_SYSERR;