aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-03-29 12:51:26 +0200
committerChristian Grothoff <christian@grothoff.org>2020-03-29 12:51:26 +0200
commit73514dd0e561b521c2c23eb6038301eac3cdcbb1 (patch)
tree26506453dd21572c85fbb3f81dbade064ed39781
parent0eaaeeeccd18fcfdef4c37ea56fc40daf097706a (diff)
downloadgnunet-73514dd0e561b521c2c23eb6038301eac3cdcbb1.tar.gz
gnunet-73514dd0e561b521c2c23eb6038301eac3cdcbb1.zip
allow passing of fancy time to timetravel option
-rw-r--r--src/pq/pq_connect.c2
-rw-r--r--src/util/common_logging.c4
-rw-r--r--src/util/getopt_helpers.c32
3 files changed, 32 insertions, 6 deletions
diff --git a/src/pq/pq_connect.c b/src/pq/pq_connect.c
index a7a57f98a..8da273b2b 100644
--- a/src/pq/pq_connect.c
+++ b/src/pq/pq_connect.c
@@ -190,7 +190,7 @@ apply_patch (struct GNUNET_PQ_Context *db,
190 (0 != code) ) 190 (0 != code) )
191 { 191 {
192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 192 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
193 "Could not run PSQL on file %s: %d", 193 "Could not run PSQL on file %s: %d\n",
194 buf, 194 buf,
195 (int) code); 195 (int) code);
196 return GNUNET_SYSERR; 196 return GNUNET_SYSERR;
diff --git a/src/util/common_logging.c b/src/util/common_logging.c
index 27ac88a05..527dffc02 100644
--- a/src/util/common_logging.c
+++ b/src/util/common_logging.c
@@ -705,7 +705,9 @@ parse_all_definitions ()
705 * @return #GNUNET_OK on success 705 * @return #GNUNET_OK on success
706 */ 706 */
707int 707int
708GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile) 708GNUNET_log_setup (const char *comp,
709 const char *loglevel,
710 const char *logfile)
709{ 711{
710 const char *env_logfile; 712 const char *env_logfile;
711 713
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index a2572ccab..f053158ae 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -623,18 +623,42 @@ set_timetravel_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
623 const char *value) 623 const char *value)
624{ 624{
625 long long delta; 625 long long delta;
626 long long minus;
627 struct GNUNET_TIME_Relative rt;
626 628
627 (void) scls; 629 (void) scls;
628 (void) ctx; 630 (void) ctx;
629 if (1 != sscanf (value, 631 while (isspace (value[0]))
630 "%lld", 632 value++;
631 &delta)) 633 minus = 1;
634 if (value[0] == '-')
635 {
636 minus = -1;
637 value++;
638 }
639 else if (value[0] == '+')
640 {
641 value++;
642 }
643 if (GNUNET_OK !=
644 GNUNET_STRINGS_fancy_time_to_relative (value,
645 &rt))
632 { 646 {
633 fprintf (stderr, 647 fprintf (stderr,
634 _ ("You must pass a number to the `%s' option.\n"), 648 _ (
649 "You must pass a relative time (optionally with sign) to the `%s' option.\n"),
650 option);
651 return GNUNET_SYSERR;
652 }
653 if (rt.rel_value_us > LONG_LONG_MAX)
654 {
655 fprintf (stderr,
656 _ ("Value given for time travel `%s' option is too big.\n"),
635 option); 657 option);
636 return GNUNET_SYSERR; 658 return GNUNET_SYSERR;
637 } 659 }
660 delta = (long long) rt.rel_value_us;
661 delta *= minus;
638 GNUNET_TIME_set_offset (delta); 662 GNUNET_TIME_set_offset (delta);
639 return GNUNET_OK; 663 return GNUNET_OK;
640} 664}