gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] branch master updated: allow passing of fancy time to timetrave


From: gnunet
Subject: [gnunet] branch master updated: allow passing of fancy time to timetravel option
Date: Sun, 29 Mar 2020 12:56:04 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 73514dd0e allow passing of fancy time to timetravel option
     new e0be2a0d9 Merge branch 'master' of git+ssh://gnunet.org/gnunet
73514dd0e is described below

commit 73514dd0e561b521c2c23eb6038301eac3cdcbb1
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Mar 29 12:51:26 2020 +0200

    allow passing of fancy time to timetravel option
---
 src/pq/pq_connect.c       |  2 +-
 src/util/common_logging.c |  4 +++-
 src/util/getopt_helpers.c | 32 ++++++++++++++++++++++++++++----
 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,
        (0 != code) )
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Could not run PSQL on file %s: %d",
+                "Could not run PSQL on file %s: %d\n",
                 buf,
                 (int) code);
     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 ()
  * @return #GNUNET_OK on success
  */
 int
-GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
+GNUNET_log_setup (const char *comp,
+                  const char *loglevel,
+                  const char *logfile)
 {
   const char *env_logfile;
 
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,
                      const char *value)
 {
   long long delta;
+  long long minus;
+  struct GNUNET_TIME_Relative rt;
 
   (void) scls;
   (void) ctx;
-  if (1 != sscanf (value,
-                   "%lld",
-                   &delta))
+  while (isspace (value[0]))
+    value++;
+  minus = 1;
+  if (value[0] == '-')
+  {
+    minus = -1;
+    value++;
+  }
+  else if (value[0] == '+')
+  {
+    value++;
+  }
+  if (GNUNET_OK !=
+      GNUNET_STRINGS_fancy_time_to_relative (value,
+                                             &rt))
   {
     fprintf (stderr,
-             _ ("You must pass a number to the `%s' option.\n"),
+             _ (
+               "You must pass a relative time (optionally with sign) to the 
`%s' option.\n"),
+             option);
+    return GNUNET_SYSERR;
+  }
+  if (rt.rel_value_us > LONG_LONG_MAX)
+  {
+    fprintf (stderr,
+             _ ("Value given for time travel `%s' option is too big.\n"),
              option);
     return GNUNET_SYSERR;
   }
+  delta = (long long) rt.rel_value_us;
+  delta *= minus;
   GNUNET_TIME_set_offset (delta);
   return GNUNET_OK;
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]