aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_getopt_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-06-22 23:28:58 +0200
committerChristian Grothoff <christian@grothoff.org>2019-06-22 23:28:58 +0200
commit988ac7f121b646cba3ca44567f54b1315398505d (patch)
tree96a6e224c13bd6c692b4bf68eb0f97c632095c46 /src/include/gnunet_getopt_lib.h
parentea20a69462912d46cf4f9dc47e6c7945c9da5f97 (diff)
downloadgnunet-988ac7f121b646cba3ca44567f54b1315398505d.tar.gz
gnunet-988ac7f121b646cba3ca44567f54b1315398505d.zip
finish #4623
Diffstat (limited to 'src/include/gnunet_getopt_lib.h')
-rw-r--r--src/include/gnunet_getopt_lib.h60
1 files changed, 38 insertions, 22 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index 17e36d889..1e99c63d0 100644
--- a/src/include/gnunet_getopt_lib.h
+++ b/src/include/gnunet_getopt_lib.h
@@ -33,9 +33,8 @@
33#define GNUNET_GETOPT_LIB_H 33#define GNUNET_GETOPT_LIB_H
34 34
35#ifdef __cplusplus 35#ifdef __cplusplus
36extern "C" 36extern "C" {
37{ 37#if 0 /* keep Emacsens' auto-indent happy */
38#if 0 /* keep Emacsens' auto-indent happy */
39} 38}
40#endif 39#endif
41#endif 40#endif
@@ -77,7 +76,6 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
77 * Current argument. 76 * Current argument.
78 */ 77 */
79 unsigned int currentArgument; 78 unsigned int currentArgument;
80
81}; 79};
82 80
83 81
@@ -90,12 +88,11 @@ struct GNUNET_GETOPT_CommandLineProcessorContext
90 * @param value argument, NULL if none was given 88 * @param value argument, NULL if none was given
91 * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort 89 * @return #GNUNET_OK to continue processing other options, #GNUNET_SYSERR to abort
92 */ 90 */
93typedef int 91typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) (
94(*GNUNET_GETOPT_CommandLineOptionProcessor) (struct 92 struct GNUNET_GETOPT_CommandLineProcessorContext *ctx,
95 GNUNET_GETOPT_CommandLineProcessorContext *ctx, 93 void *scls,
96 void *scls, 94 const char *option,
97 const char *option, 95 const char *value);
98 const char *value);
99 96
100 97
101/** 98/**
@@ -149,13 +146,12 @@ struct GNUNET_GETOPT_CommandLineOption
149 * Function to call on @e scls to clean up after processing all 146 * Function to call on @e scls to clean up after processing all
150 * the arguments. Can be NULL. 147 * the arguments. Can be NULL.
151 */ 148 */
152 void (*cleaner)(void *cls); 149 void (*cleaner) (void *cls);
153 150
154 /** 151 /**
155 * Specific closure to pass to the processor. 152 * Specific closure to pass to the processor.
156 */ 153 */
157 void *scls; 154 void *scls;
158
159}; 155};
160 156
161 157
@@ -179,7 +175,6 @@ struct GNUNET_GETOPT_CommandLineOption
179GNUNET_GETOPT_option_version (const char *version); 175GNUNET_GETOPT_option_version (const char *version);
180 176
181 177
182
183/** 178/**
184 * Allow user to specify log file name (-l option) 179 * Allow user to specify log file name (-l option)
185 * 180 *
@@ -254,8 +249,17 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
254 * @param[out] val binary value decoded from Crockford Base32-encoded argument; 249 * @param[out] val binary value decoded from Crockford Base32-encoded argument;
255 * size is determined by type (sizeof (*val)). 250 * size is determined by type (sizeof (*val)).
256 */ 251 */
257#define GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \ 252#define GNUNET_GETOPT_option_base32_auto(shortName, \
258 GNUNET_GETOPT_option_base32_fixed_size(shortName,name,argumentHelp,description,val,sizeof(*val)) 253 name, \
254 argumentHelp, \
255 description, \
256 val) \
257 GNUNET_GETOPT_option_base32_fixed_size (shortName, \
258 name, \
259 argumentHelp, \
260 description, \
261 val, \
262 sizeof (*val))
259 263
260 264
261/** 265/**
@@ -302,10 +306,10 @@ GNUNET_GETOPT_option_uint (char shortName,
302 */ 306 */
303struct GNUNET_GETOPT_CommandLineOption 307struct GNUNET_GETOPT_CommandLineOption
304GNUNET_GETOPT_option_uint16 (char shortName, 308GNUNET_GETOPT_option_uint16 (char shortName,
305 const char *name, 309 const char *name,
306 const char *argumentHelp, 310 const char *argumentHelp,
307 const char *description, 311 const char *description,
308 uint16_t *val); 312 uint16_t *val);
309 313
310 314
311/** 315/**
@@ -426,10 +430,22 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
426 430
427 431
428/** 432/**
433 * Make the given option mutually exclusive with other options.
434 *
435 * @param opt option to modify
436 * @return @a opt with the exclusive flag set.
437 */
438struct GNUNET_GETOPT_CommandLineOption
439GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt);
440
441
442/**
429 * Marker for the end of the list of options. 443 * Marker for the end of the list of options.
430 */ 444 */
431#define GNUNET_GETOPT_OPTION_END \ 445#define GNUNET_GETOPT_OPTION_END \
432 { '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL } 446 { \
447 '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
448 }
433 449
434 450
435/** 451/**
@@ -449,7 +465,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
449 char *const *argv); 465 char *const *argv);
450 466
451 467
452#if 0 /* keep Emacsens' auto-indent happy */ 468#if 0 /* keep Emacsens' auto-indent happy */
453{ 469{
454#endif 470#endif
455#ifdef __cplusplus 471#ifdef __cplusplus