aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_getopt_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_getopt_lib.h')
-rw-r--r--src/include/gnunet_getopt_lib.h65
1 files changed, 43 insertions, 22 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h
index ddeeffef4..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/**
@@ -136,6 +133,11 @@ struct GNUNET_GETOPT_CommandLineOption
136 int option_mandatory; 133 int option_mandatory;
137 134
138 /** 135 /**
136 * Is the option exclusive?
137 */
138 int option_exclusive;
139
140 /**
139 * Handler for the option. 141 * Handler for the option.
140 */ 142 */
141 GNUNET_GETOPT_CommandLineOptionProcessor processor; 143 GNUNET_GETOPT_CommandLineOptionProcessor processor;
@@ -144,13 +146,12 @@ struct GNUNET_GETOPT_CommandLineOption
144 * 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
145 * the arguments. Can be NULL. 147 * the arguments. Can be NULL.
146 */ 148 */
147 void (*cleaner)(void *cls); 149 void (*cleaner) (void *cls);
148 150
149 /** 151 /**
150 * Specific closure to pass to the processor. 152 * Specific closure to pass to the processor.
151 */ 153 */
152 void *scls; 154 void *scls;
153
154}; 155};
155 156
156 157
@@ -174,7 +175,6 @@ struct GNUNET_GETOPT_CommandLineOption
174GNUNET_GETOPT_option_version (const char *version); 175GNUNET_GETOPT_option_version (const char *version);
175 176
176 177
177
178/** 178/**
179 * Allow user to specify log file name (-l option) 179 * Allow user to specify log file name (-l option)
180 * 180 *
@@ -249,8 +249,17 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName,
249 * @param[out] val binary value decoded from Crockford Base32-encoded argument; 249 * @param[out] val binary value decoded from Crockford Base32-encoded argument;
250 * size is determined by type (sizeof (*val)). 250 * size is determined by type (sizeof (*val)).
251 */ 251 */
252#define GNUNET_GETOPT_option_base32_auto(shortName,name,argumentHelp,description,val) \ 252#define GNUNET_GETOPT_option_base32_auto(shortName, \
253 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))
254 263
255 264
256/** 265/**
@@ -297,10 +306,10 @@ GNUNET_GETOPT_option_uint (char shortName,
297 */ 306 */
298struct GNUNET_GETOPT_CommandLineOption 307struct GNUNET_GETOPT_CommandLineOption
299GNUNET_GETOPT_option_uint16 (char shortName, 308GNUNET_GETOPT_option_uint16 (char shortName,
300 const char *name, 309 const char *name,
301 const char *argumentHelp, 310 const char *argumentHelp,
302 const char *description, 311 const char *description,
303 uint16_t *val); 312 uint16_t *val);
304 313
305 314
306/** 315/**
@@ -421,10 +430,22 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt);
421 430
422 431
423/** 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/**
424 * Marker for the end of the list of options. 443 * Marker for the end of the list of options.
425 */ 444 */
426#define GNUNET_GETOPT_OPTION_END \ 445#define GNUNET_GETOPT_OPTION_END \
427 { '\0', NULL, NULL, NULL, 0, 0, NULL, NULL, NULL } 446 { \
447 '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
448 }
428 449
429 450
430/** 451/**
@@ -444,7 +465,7 @@ GNUNET_GETOPT_run (const char *binaryOptions,
444 char *const *argv); 465 char *const *argv);
445 466
446 467
447#if 0 /* keep Emacsens' auto-indent happy */ 468#if 0 /* keep Emacsens' auto-indent happy */
448{ 469{
449#endif 470#endif
450#ifdef __cplusplus 471#ifdef __cplusplus