[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 10/28: add GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 10/28: add GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME |
Date: |
Fri, 17 Mar 2017 12:09:42 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
commit 85b043ef34186a24d960cb32417da2a610eae526
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Mar 15 10:26:37 2017 +0100
add GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME
---
src/include/gnunet_getopt_lib.h | 18 ++++++++++++
src/util/getopt_helpers.c | 65 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+)
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index 0acf15679..bc2e079da 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -317,6 +317,24 @@ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
/**
+ * Allow user to specify a `struct GNUNET_TIME_Absolute`
+ * (using human-readable "fancy" time).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Absolute *val);
+
+
+/**
* Increment @a val each time the option flag is given by one.
*
* @param shortName short name of the option
diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c
index 9f6f4c764..31fe093a9 100644
--- a/src/util/getopt_helpers.c
+++ b/src/util/getopt_helpers.c
@@ -647,6 +647,71 @@ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
/**
+ * Set an option of type 'struct GNUNET_TIME_Absolute' from the command line.
+ * A pointer to this function should be passed as part of the
+ * 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
+ * of this type. It should be followed by a pointer to a value of
+ * type 'struct GNUNET_TIME_Absolute'.
+ *
+ * @param ctx command line processing context
+ * @param scls additional closure (will point to the 'struct
GNUNET_TIME_Relative')
+ * @param option name of the option
+ * @param value actual value of the option as a string.
+ * @return #GNUNET_OK if parsing the value worked
+ */
+static int
+set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
+ void *scls,
+ const char *option,
+ const char *value)
+{
+ struct GNUNET_TIME_Absolute *val = scls;
+
+ if (GNUNET_OK !=
+ GNUNET_STRINGS_fancy_time_to_absolute (value,
+ val))
+ {
+ FPRINTF (stderr,
+ _("You must pass absolute time to the `%s' option.\n"),
+ option);
+ return GNUNET_SYSERR;
+ }
+ return GNUNET_OK;
+}
+
+
+/**
+ * Allow user to specify a `struct GNUNET_TIME_Absolute`
+ * (using human-readable "fancy" time).
+ *
+ * @param shortName short name of the option
+ * @param name long name of the option
+ * @param argumentHelp help text for the option argument
+ * @param description long help text for the option
+ * @param[out] val set to the time specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName,
+ const char *name,
+ const char *argumentHelp,
+ const char *description,
+ struct GNUNET_TIME_Absolute *val)
+{
+ struct GNUNET_GETOPT_CommandLineOption clo = {
+ .shortName = shortName,
+ .name = name,
+ .argumentHelp = argumentHelp,
+ .description = description,
+ .require_argument = 1,
+ .processor = &set_absolute_time,
+ .scls = (void *) val
+ };
+
+ return clo;
+}
+
+
+/**
* Set an option of type 'unsigned int' from the command line.
* A pointer to this function should be passed as part of the
* 'struct GNUNET_GETOPT_CommandLineOption' array to initialize options
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (2951cdb72 -> 5b085881a), gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 02/28: Test commit, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 04/28: Merge branch 'getopt' of git+ssh://gnunet.org/gnunet into getopt, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 05/28: add GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 06/28: Port 'statistics' to the new getopt API., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 03/28: fix test case, implement base32 argument parser logic, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 01/28: getopt major style fix, remove macro-mania with nicer typed functions, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 12/28: Port 'statistics' to the new getopt API., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 11/28: add json command line option parser, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 13/28: Porting 'arm'., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 10/28: add GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME,
gnunet <=
- [GNUnet-SVN] [gnunet] 15/28: merging, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 16/28: Porting 'nat'., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 07/28: Porting 'arm'., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 17/28: Porting 'nat-auto'., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 14/28: add way to mark options as mandatory, get tests to pass again, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 09/28: fix test case, implement base32 argument parser logic, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 26/28: Fix compiler warnings., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 27/28: Merge branch 'master' into getopt, gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 25/28: Last commit as of getopt porting. 'social' still gives warnings., gnunet, 2017/03/17
- [GNUnet-SVN] [gnunet] 18/28: Still porting to new getopt API., gnunet, 2017/03/17