diff options
Diffstat (limited to 'src/include/gnunet_getopt_lib.h')
-rw-r--r-- | src/include/gnunet_getopt_lib.h | 148 |
1 files changed, 72 insertions, 76 deletions
diff --git a/src/include/gnunet_getopt_lib.h b/src/include/gnunet_getopt_lib.h index 1e99c63d0..ef744fbc9 100644 --- a/src/include/gnunet_getopt_lib.h +++ b/src/include/gnunet_getopt_lib.h | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
@@ -44,9 +44,7 @@ extern "C" { | |||
44 | /** | 44 | /** |
45 | * @brief General context for command line processors. | 45 | * @brief General context for command line processors. |
46 | */ | 46 | */ |
47 | struct GNUNET_GETOPT_CommandLineProcessorContext | 47 | struct GNUNET_GETOPT_CommandLineProcessorContext { |
48 | { | ||
49 | |||
50 | /** | 48 | /** |
51 | * Name of the application | 49 | * Name of the application |
52 | */ | 50 | */ |
@@ -98,9 +96,7 @@ typedef int (*GNUNET_GETOPT_CommandLineOptionProcessor) ( | |||
98 | /** | 96 | /** |
99 | * @brief Definition of a command line option. | 97 | * @brief Definition of a command line option. |
100 | */ | 98 | */ |
101 | struct GNUNET_GETOPT_CommandLineOption | 99 | struct GNUNET_GETOPT_CommandLineOption { |
102 | { | ||
103 | |||
104 | /** | 100 | /** |
105 | * Short name of the option. | 101 | * Short name of the option. |
106 | */ | 102 | */ |
@@ -162,7 +158,7 @@ struct GNUNET_GETOPT_CommandLineOption | |||
162 | * @param about string with brief description of the application | 158 | * @param about string with brief description of the application |
163 | */ | 159 | */ |
164 | struct GNUNET_GETOPT_CommandLineOption | 160 | struct GNUNET_GETOPT_CommandLineOption |
165 | GNUNET_GETOPT_option_help (const char *about); | 161 | GNUNET_GETOPT_option_help(const char *about); |
166 | 162 | ||
167 | 163 | ||
168 | /** | 164 | /** |
@@ -172,7 +168,7 @@ GNUNET_GETOPT_option_help (const char *about); | |||
172 | * @param version string with the version number | 168 | * @param version string with the version number |
173 | */ | 169 | */ |
174 | struct GNUNET_GETOPT_CommandLineOption | 170 | struct GNUNET_GETOPT_CommandLineOption |
175 | GNUNET_GETOPT_option_version (const char *version); | 171 | GNUNET_GETOPT_option_version(const char *version); |
176 | 172 | ||
177 | 173 | ||
178 | /** | 174 | /** |
@@ -181,7 +177,7 @@ GNUNET_GETOPT_option_version (const char *version); | |||
181 | * @param[out] logfn set to the name of the logfile | 177 | * @param[out] logfn set to the name of the logfile |
182 | */ | 178 | */ |
183 | struct GNUNET_GETOPT_CommandLineOption | 179 | struct GNUNET_GETOPT_CommandLineOption |
184 | GNUNET_GETOPT_option_logfile (char **logfn); | 180 | GNUNET_GETOPT_option_logfile(char **logfn); |
185 | 181 | ||
186 | 182 | ||
187 | /** | 183 | /** |
@@ -194,11 +190,11 @@ GNUNET_GETOPT_option_logfile (char **logfn); | |||
194 | * @param[out] str set to the string | 190 | * @param[out] str set to the string |
195 | */ | 191 | */ |
196 | struct GNUNET_GETOPT_CommandLineOption | 192 | struct GNUNET_GETOPT_CommandLineOption |
197 | GNUNET_GETOPT_option_string (char shortName, | 193 | GNUNET_GETOPT_option_string(char shortName, |
198 | const char *name, | 194 | const char *name, |
199 | const char *argumentHelp, | 195 | const char *argumentHelp, |
200 | const char *description, | 196 | const char *description, |
201 | char **str); | 197 | char **str); |
202 | 198 | ||
203 | /** | 199 | /** |
204 | * Allow user to specify a filename (automatically path expanded). | 200 | * Allow user to specify a filename (automatically path expanded). |
@@ -210,11 +206,11 @@ GNUNET_GETOPT_option_string (char shortName, | |||
210 | * @param[out] str set to the string | 206 | * @param[out] str set to the string |
211 | */ | 207 | */ |
212 | struct GNUNET_GETOPT_CommandLineOption | 208 | struct GNUNET_GETOPT_CommandLineOption |
213 | GNUNET_GETOPT_option_filename (char shortName, | 209 | GNUNET_GETOPT_option_filename(char shortName, |
214 | const char *name, | 210 | const char *name, |
215 | const char *argumentHelp, | 211 | const char *argumentHelp, |
216 | const char *description, | 212 | const char *description, |
217 | char **str); | 213 | char **str); |
218 | 214 | ||
219 | 215 | ||
220 | /** | 216 | /** |
@@ -229,12 +225,12 @@ GNUNET_GETOPT_option_filename (char shortName, | |||
229 | * @param val_size size of @a val in bytes | 225 | * @param val_size size of @a val in bytes |
230 | */ | 226 | */ |
231 | struct GNUNET_GETOPT_CommandLineOption | 227 | struct GNUNET_GETOPT_CommandLineOption |
232 | GNUNET_GETOPT_option_base32_fixed_size (char shortName, | 228 | GNUNET_GETOPT_option_base32_fixed_size(char shortName, |
233 | const char *name, | 229 | const char *name, |
234 | const char *argumentHelp, | 230 | const char *argumentHelp, |
235 | const char *description, | 231 | const char *description, |
236 | void *val, | 232 | void *val, |
237 | size_t val_size); | 233 | size_t val_size); |
238 | 234 | ||
239 | 235 | ||
240 | /** | 236 | /** |
@@ -254,12 +250,12 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName, | |||
254 | argumentHelp, \ | 250 | argumentHelp, \ |
255 | description, \ | 251 | description, \ |
256 | val) \ | 252 | val) \ |
257 | GNUNET_GETOPT_option_base32_fixed_size (shortName, \ | 253 | GNUNET_GETOPT_option_base32_fixed_size(shortName, \ |
258 | name, \ | 254 | name, \ |
259 | argumentHelp, \ | 255 | argumentHelp, \ |
260 | description, \ | 256 | description, \ |
261 | val, \ | 257 | val, \ |
262 | sizeof (*val)) | 258 | sizeof(*val)) |
263 | 259 | ||
264 | 260 | ||
265 | /** | 261 | /** |
@@ -272,10 +268,10 @@ GNUNET_GETOPT_option_base32_fixed_size (char shortName, | |||
272 | * @param[out] val set to 1 if the option is present | 268 | * @param[out] val set to 1 if the option is present |
273 | */ | 269 | */ |
274 | struct GNUNET_GETOPT_CommandLineOption | 270 | struct GNUNET_GETOPT_CommandLineOption |
275 | GNUNET_GETOPT_option_flag (char shortName, | 271 | GNUNET_GETOPT_option_flag(char shortName, |
276 | const char *name, | 272 | const char *name, |
277 | const char *description, | 273 | const char *description, |
278 | int *val); | 274 | int *val); |
279 | 275 | ||
280 | 276 | ||
281 | /** | 277 | /** |
@@ -288,11 +284,11 @@ GNUNET_GETOPT_option_flag (char shortName, | |||
288 | * @param[out] val set to the value specified at the command line | 284 | * @param[out] val set to the value specified at the command line |
289 | */ | 285 | */ |
290 | struct GNUNET_GETOPT_CommandLineOption | 286 | struct GNUNET_GETOPT_CommandLineOption |
291 | GNUNET_GETOPT_option_uint (char shortName, | 287 | GNUNET_GETOPT_option_uint(char shortName, |
292 | const char *name, | 288 | const char *name, |
293 | const char *argumentHelp, | 289 | const char *argumentHelp, |
294 | const char *description, | 290 | const char *description, |
295 | unsigned int *val); | 291 | unsigned int *val); |
296 | 292 | ||
297 | 293 | ||
298 | /** | 294 | /** |
@@ -305,11 +301,11 @@ GNUNET_GETOPT_option_uint (char shortName, | |||
305 | * @param[out] val set to the value specified at the command line | 301 | * @param[out] val set to the value specified at the command line |
306 | */ | 302 | */ |
307 | struct GNUNET_GETOPT_CommandLineOption | 303 | struct GNUNET_GETOPT_CommandLineOption |
308 | GNUNET_GETOPT_option_uint16 (char shortName, | 304 | GNUNET_GETOPT_option_uint16(char shortName, |
309 | const char *name, | 305 | const char *name, |
310 | const char *argumentHelp, | 306 | const char *argumentHelp, |
311 | const char *description, | 307 | const char *description, |
312 | uint16_t *val); | 308 | uint16_t *val); |
313 | 309 | ||
314 | 310 | ||
315 | /** | 311 | /** |
@@ -322,11 +318,11 @@ GNUNET_GETOPT_option_uint16 (char shortName, | |||
322 | * @param[out] val set to the value specified at the command line | 318 | * @param[out] val set to the value specified at the command line |
323 | */ | 319 | */ |
324 | struct GNUNET_GETOPT_CommandLineOption | 320 | struct GNUNET_GETOPT_CommandLineOption |
325 | GNUNET_GETOPT_option_ulong (char shortName, | 321 | GNUNET_GETOPT_option_ulong(char shortName, |
326 | const char *name, | 322 | const char *name, |
327 | const char *argumentHelp, | 323 | const char *argumentHelp, |
328 | const char *description, | 324 | const char *description, |
329 | unsigned long long *val); | 325 | unsigned long long *val); |
330 | 326 | ||
331 | 327 | ||
332 | /** | 328 | /** |
@@ -340,11 +336,11 @@ GNUNET_GETOPT_option_ulong (char shortName, | |||
340 | * @param[out] val set to the time specified at the command line | 336 | * @param[out] val set to the time specified at the command line |
341 | */ | 337 | */ |
342 | struct GNUNET_GETOPT_CommandLineOption | 338 | struct GNUNET_GETOPT_CommandLineOption |
343 | GNUNET_GETOPT_option_relative_time (char shortName, | 339 | GNUNET_GETOPT_option_relative_time(char shortName, |
344 | const char *name, | 340 | const char *name, |
345 | const char *argumentHelp, | 341 | const char *argumentHelp, |
346 | const char *description, | 342 | const char *description, |
347 | struct GNUNET_TIME_Relative *val); | 343 | struct GNUNET_TIME_Relative *val); |
348 | 344 | ||
349 | 345 | ||
350 | /** | 346 | /** |
@@ -358,11 +354,11 @@ GNUNET_GETOPT_option_relative_time (char shortName, | |||
358 | * @param[out] val set to the time specified at the command line | 354 | * @param[out] val set to the time specified at the command line |
359 | */ | 355 | */ |
360 | struct GNUNET_GETOPT_CommandLineOption | 356 | struct GNUNET_GETOPT_CommandLineOption |
361 | GNUNET_GETOPT_option_absolute_time (char shortName, | 357 | GNUNET_GETOPT_option_absolute_time(char shortName, |
362 | const char *name, | 358 | const char *name, |
363 | const char *argumentHelp, | 359 | const char *argumentHelp, |
364 | const char *description, | 360 | const char *description, |
365 | struct GNUNET_TIME_Absolute *val); | 361 | struct GNUNET_TIME_Absolute *val); |
366 | 362 | ||
367 | 363 | ||
368 | /** | 364 | /** |
@@ -375,10 +371,10 @@ GNUNET_GETOPT_option_absolute_time (char shortName, | |||
375 | * @param[out] val set to 1 if the option is present | 371 | * @param[out] val set to 1 if the option is present |
376 | */ | 372 | */ |
377 | struct GNUNET_GETOPT_CommandLineOption | 373 | struct GNUNET_GETOPT_CommandLineOption |
378 | GNUNET_GETOPT_option_increment_uint (char shortName, | 374 | GNUNET_GETOPT_option_increment_uint(char shortName, |
379 | const char *name, | 375 | const char *name, |
380 | const char *description, | 376 | const char *description, |
381 | unsigned int *val); | 377 | unsigned int *val); |
382 | 378 | ||
383 | 379 | ||
384 | /** | 380 | /** |
@@ -388,7 +384,7 @@ GNUNET_GETOPT_option_increment_uint (char shortName, | |||
388 | * @param[out] level set to the log level | 384 | * @param[out] level set to the log level |
389 | */ | 385 | */ |
390 | struct GNUNET_GETOPT_CommandLineOption | 386 | struct GNUNET_GETOPT_CommandLineOption |
391 | GNUNET_GETOPT_option_loglevel (char **level); | 387 | GNUNET_GETOPT_option_loglevel(char **level); |
392 | 388 | ||
393 | 389 | ||
394 | /** | 390 | /** |
@@ -398,7 +394,7 @@ GNUNET_GETOPT_option_loglevel (char **level); | |||
398 | * @param[out] level set to the verbosity level | 394 | * @param[out] level set to the verbosity level |
399 | */ | 395 | */ |
400 | struct GNUNET_GETOPT_CommandLineOption | 396 | struct GNUNET_GETOPT_CommandLineOption |
401 | GNUNET_GETOPT_option_verbose (unsigned int *level); | 397 | GNUNET_GETOPT_option_verbose(unsigned int *level); |
402 | 398 | ||
403 | 399 | ||
404 | /** | 400 | /** |
@@ -407,7 +403,7 @@ GNUNET_GETOPT_option_verbose (unsigned int *level); | |||
407 | * @param[out] logfn set to the name of the logfile | 403 | * @param[out] logfn set to the name of the logfile |
408 | */ | 404 | */ |
409 | struct GNUNET_GETOPT_CommandLineOption | 405 | struct GNUNET_GETOPT_CommandLineOption |
410 | GNUNET_GETOPT_option_logfile (char **logfn); | 406 | GNUNET_GETOPT_option_logfile(char **logfn); |
411 | 407 | ||
412 | 408 | ||
413 | /** | 409 | /** |
@@ -416,7 +412,7 @@ GNUNET_GETOPT_option_logfile (char **logfn); | |||
416 | * @param[out] fn set to the name of the configuration file | 412 | * @param[out] fn set to the name of the configuration file |
417 | */ | 413 | */ |
418 | struct GNUNET_GETOPT_CommandLineOption | 414 | struct GNUNET_GETOPT_CommandLineOption |
419 | GNUNET_GETOPT_option_cfgfile (char **fn); | 415 | GNUNET_GETOPT_option_cfgfile(char **fn); |
420 | 416 | ||
421 | 417 | ||
422 | /** | 418 | /** |
@@ -426,7 +422,7 @@ GNUNET_GETOPT_option_cfgfile (char **fn); | |||
426 | * @return @a opt with the mandatory flag set. | 422 | * @return @a opt with the mandatory flag set. |
427 | */ | 423 | */ |
428 | struct GNUNET_GETOPT_CommandLineOption | 424 | struct GNUNET_GETOPT_CommandLineOption |
429 | GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt); | 425 | GNUNET_GETOPT_option_mandatory(struct GNUNET_GETOPT_CommandLineOption opt); |
430 | 426 | ||
431 | 427 | ||
432 | /** | 428 | /** |
@@ -436,7 +432,7 @@ GNUNET_GETOPT_option_mandatory (struct GNUNET_GETOPT_CommandLineOption opt); | |||
436 | * @return @a opt with the exclusive flag set. | 432 | * @return @a opt with the exclusive flag set. |
437 | */ | 433 | */ |
438 | struct GNUNET_GETOPT_CommandLineOption | 434 | struct GNUNET_GETOPT_CommandLineOption |
439 | GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt); | 435 | GNUNET_GETOPT_option_exclusive(struct GNUNET_GETOPT_CommandLineOption opt); |
440 | 436 | ||
441 | 437 | ||
442 | /** | 438 | /** |
@@ -459,10 +455,10 @@ GNUNET_GETOPT_option_exclusive (struct GNUNET_GETOPT_CommandLineOption opt); | |||
459 | * argument, or #GNUNET_SYSERR on error | 455 | * argument, or #GNUNET_SYSERR on error |
460 | */ | 456 | */ |
461 | int | 457 | int |
462 | GNUNET_GETOPT_run (const char *binaryOptions, | 458 | GNUNET_GETOPT_run(const char *binaryOptions, |
463 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, | 459 | const struct GNUNET_GETOPT_CommandLineOption *allOptions, |
464 | unsigned int argc, | 460 | unsigned int argc, |
465 | char *const *argv); | 461 | char *const *argv); |
466 | 462 | ||
467 | 463 | ||
468 | #if 0 /* keep Emacsens' auto-indent happy */ | 464 | #if 0 /* keep Emacsens' auto-indent happy */ |