defining data structures for validation
[oweals/gnunet.git] / src / include / gnunet_getopt_lib.h
index c2bd72340db00d2b2e7bf1ad20ca36ff2cf0d497..ddeeffef4325c0007ac142531e8a4fbc4dd07ac9 100644 (file)
@@ -2,20 +2,20 @@
      This file is part of GNUnet.
      Copyright (C) 2001-2013 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     SPDX-License-Identifier: AGPL3.0-or-later
 */
 
 /**
@@ -161,7 +161,7 @@ struct GNUNET_GETOPT_CommandLineOption
  * @param about string with brief description of the application
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_HELP (const char *about);
+GNUNET_GETOPT_option_help (const char *about);
 
 
 /**
@@ -171,7 +171,7 @@ GNUNET_GETOPT_OPTION_HELP (const char *about);
  * @param version string with the version number
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_VERSION (const char *version);
+GNUNET_GETOPT_option_version (const char *version);
 
 
 
@@ -181,7 +181,7 @@ GNUNET_GETOPT_OPTION_VERSION (const char *version);
  * @param[out] logfn set to the name of the logfile
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
+GNUNET_GETOPT_option_logfile (char **logfn);
 
 
 /**
@@ -194,7 +194,7 @@ GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
  * @param[out] str set to the string
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_STRING (char shortName,
+GNUNET_GETOPT_option_string (char shortName,
                              const char *name,
                              const char *argumentHelp,
                              const char *description,
@@ -210,7 +210,7 @@ GNUNET_GETOPT_OPTION_STRING (char shortName,
  * @param[out] str set to the string
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_FILENAME (char shortName,
+GNUNET_GETOPT_option_filename (char shortName,
                                const char *name,
                                const char *argumentHelp,
                                const char *description,
@@ -229,12 +229,12 @@ GNUNET_GETOPT_OPTION_FILENAME (char shortName,
  * @param val_size size of @a val in bytes
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName,
-                                            const char *name,
-                                            const char *argumentHelp,
-                                            const char *description,
-                                            void *val,
-                                            size_t val_size);
+GNUNET_GETOPT_option_base32_fixed_size (char shortName,
+                                        const char *name,
+                                        const char *argumentHelp,
+                                        const char *description,
+                                        void *val,
+                                        size_t val_size);
 
 
 /**
@@ -249,8 +249,8 @@ GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName,
  * @param[out] val binary value decoded from Crockford Base32-encoded argument;
  *             size is determined by type (sizeof (*val)).
  */
-#define GNUNET_GETOPT_OPTION_SET_BASE32_AUTO(shortName,name,argumentHelp,description,val) \
-  GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE(shortName,name,argumentHelp,description,val,sizeof(*val))
+#define GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \
+  GNUNET_GETOPT_option_base32_fixed_size(shortName,name,argumentHelp,description,val,sizeof(*val))
 
 
 /**
@@ -263,10 +263,10 @@ GNUNET_GETOPT_OPTION_SET_BASE32_FIXED_SIZE (char shortName,
  * @param[out] val set to 1 if the option is present
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
-                              const char *name,
-                              const char *description,
-                              int *val);
+GNUNET_GETOPT_option_flag (char shortName,
+                           const char *name,
+                           const char *description,
+                           int *val);
 
 
 /**
@@ -279,11 +279,28 @@ GNUNET_GETOPT_OPTION_SET_ONE (char shortName,
  * @param[out] val set to the value specified at the command line
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
-                               const char *name,
-                               const char *argumentHelp,
-                               const char *description,
-                               unsigned int *val);
+GNUNET_GETOPT_option_uint (char shortName,
+                           const char *name,
+                           const char *argumentHelp,
+                           const char *description,
+                           unsigned int *val);
+
+
+/**
+ * Allow user to specify an uint16_t.
+ *
+ * @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 value specified at the command line
+ */
+struct GNUNET_GETOPT_CommandLineOption
+GNUNET_GETOPT_option_uint16 (char shortName,
+                            const char *name,
+                            const char *argumentHelp,
+                            const char *description,
+                            uint16_t *val);
 
 
 /**
@@ -296,11 +313,11 @@ GNUNET_GETOPT_OPTION_SET_UINT (char shortName,
  * @param[out] val set to the value specified at the command line
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
-                                const char *name,
-                                const char *argumentHelp,
-                                const char *description,
-                                unsigned long long *val);
+GNUNET_GETOPT_option_ulong (char shortName,
+                            const char *name,
+                            const char *argumentHelp,
+                            const char *description,
+                            unsigned long long *val);
 
 
 /**
@@ -314,11 +331,11 @@ GNUNET_GETOPT_OPTION_SET_ULONG (char shortName,
  * @param[out] val set to the time specified at the command line
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
-                                        const char *name,
-                                        const char *argumentHelp,
-                                        const char *description,
-                                        struct GNUNET_TIME_Relative *val);
+GNUNET_GETOPT_option_relative_time (char shortName,
+                                    const char *name,
+                                    const char *argumentHelp,
+                                    const char *description,
+                                    struct GNUNET_TIME_Relative *val);
 
 
 /**
@@ -332,11 +349,11 @@ GNUNET_GETOPT_OPTION_SET_RELATIVE_TIME (char shortName,
  * @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);
+GNUNET_GETOPT_option_absolute_time (char shortName,
+                                    const char *name,
+                                    const char *argumentHelp,
+                                    const char *description,
+                                    struct GNUNET_TIME_Absolute *val);
 
 
 /**
@@ -349,10 +366,10 @@ GNUNET_GETOPT_OPTION_SET_ABSOLUTE_TIME (char shortName,
  * @param[out] val set to 1 if the option is present
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
-                                      const char *name,
-                                      const char *description,
-                                      unsigned int *val);
+GNUNET_GETOPT_option_increment_uint (char shortName,
+                                     const char *name,
+                                     const char *description,
+                                     unsigned int *val);
 
 
 /**
@@ -362,7 +379,7 @@ GNUNET_GETOPT_OPTION_INCREMENT_VALUE (char shortName,
  * @param[out] level set to the log level
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_LOGLEVEL (char **level);
+GNUNET_GETOPT_option_loglevel (char **level);
 
 
 /**
@@ -372,7 +389,7 @@ GNUNET_GETOPT_OPTION_LOGLEVEL (char **level);
  * @param[out] level set to the verbosity level
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level);
+GNUNET_GETOPT_option_verbose (unsigned int *level);
 
 
 /**
@@ -381,7 +398,7 @@ GNUNET_GETOPT_OPTION_VERBOSE (unsigned int *level);
  * @param[out] logfn set to the name of the logfile
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
+GNUNET_GETOPT_option_logfile (char **logfn);
 
 
 /**
@@ -390,7 +407,7 @@ GNUNET_GETOPT_OPTION_LOGFILE (char **logfn);
  * @param[out] fn set to the name of the configuration file
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_CFG_FILE (char **fn);
+GNUNET_GETOPT_option_cfgfile (char **fn);
 
 
 /**
@@ -400,7 +417,7 @@ GNUNET_GETOPT_OPTION_CFG_FILE (char **fn);
  * @return @a opt with the mandatory flag set.
  */
 struct GNUNET_GETOPT_CommandLineOption
-GNUNET_GETOPT_OPTION_MANDATORY (struct GNUNET_GETOPT_CommandLineOption opt);
+GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
 
 
 /**