GNUnet  0.17.6
gnunet_getopt_lib.h
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2001-2013 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
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/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
36 #ifndef GNUNET_GETOPT_LIB_H
37 #define GNUNET_GETOPT_LIB_H
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #if 0 /* keep Emacsens' auto-indent happy */
42 }
43 #endif
44 #endif
45 
47 
52 {
56  const char *binaryName;
57 
61  const char *binaryOptions;
62 
67 
71  char *const *argv;
72 
76  unsigned int argc;
77 
81  unsigned int currentArgument;
82 };
83 
84 
96  void *scls,
97  const char *option,
98  const char *value);
99 
100 
105 {
109  const char shortName;
110 
114  const char *name;
115 
119  const char *argumentHelp;
120 
124  const char *description;
125 
131 
136 
141 
146 
151  void (*cleaner) (void *cls);
152 
156  void *scls;
157 };
158 
159 
167 GNUNET_GETOPT_option_help (const char *about);
168 
169 
181  const char *name);
182 
183 
191 GNUNET_GETOPT_option_version (const char *version);
192 
193 
200 GNUNET_GETOPT_option_logfile (char **logfn);
201 
202 
214  const char *name,
215  const char *argumentHelp,
216  const char *description,
217  char **str);
218 
230  const char *name,
231  const char *argumentHelp,
232  const char *description,
233  char **str);
234 
235 
249  const char *name,
250  const char *argumentHelp,
251  const char *description,
252  void *val,
253  size_t val_size);
254 
255 
268 #define GNUNET_GETOPT_option_base32_auto(shortName, \
269  name, \
270  argumentHelp, \
271  description, \
272  val) \
273  GNUNET_GETOPT_option_base32_fixed_size (shortName, \
274  name, \
275  argumentHelp, \
276  description, \
277  val, \
278  sizeof(*val))
279 
280 
292  const char *name,
293  const char *description,
294  int *val);
295 
296 
308  const char *name,
309  const char *argumentHelp,
310  const char *description,
311  unsigned int *val);
312 
313 
325  const char *name,
326  const char *argumentHelp,
327  const char *description,
328  uint16_t *val);
329 
330 
342  const char *name,
343  const char *argumentHelp,
344  const char *description,
345  unsigned long long *val);
346 
347 
360  const char *name,
361  const char *argumentHelp,
362  const char *description,
363  struct GNUNET_TIME_Relative *val);
364 
365 
378  const char *name,
379  const char *argumentHelp,
380  const char *description,
381  struct GNUNET_TIME_Absolute *val);
382 
383 
396  const char *name,
397  const char *argumentHelp,
398  const char *description,
399  struct GNUNET_TIME_Timestamp *val);
400 
401 
413  const char *name,
414  const char *description,
415  unsigned int *val);
416 
417 
425 GNUNET_GETOPT_option_loglevel (char **level);
426 
427 
435 GNUNET_GETOPT_option_verbose (unsigned int *level);
436 
437 
444 GNUNET_GETOPT_option_logfile (char **logfn);
445 
446 
453 GNUNET_GETOPT_option_cfgfile (char **fn);
454 
455 
464 
465 
474 
475 
479 #define GNUNET_GETOPT_OPTION_END \
480  { \
481  '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
482  }
483 
484 
495 int
496 GNUNET_GETOPT_run (const char *binaryOptions,
497  const struct GNUNET_GETOPT_CommandLineOption *allOptions,
498  unsigned int argc,
499  char *const *argv);
500 
501 
502 #if 0 /* keep Emacsens' auto-indent happy */
503 {
504 #endif
505 #ifdef __cplusplus
506 }
507 #endif
508 
509 /* ifndef GNUNET_GETOPT_LIB_H */
510 #endif
511  /* end of group getopt */
513  /* end of group addition */
515 
516 /* end of gnunet_getopt_lib.h */
static char * value
Value of the record to add/remove.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
Configuration API.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_timestamp(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Timestamp *val)
Allow user to specify a struct GNUNET_TIME_Timestamp (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_increment_uint(char shortName, const char *name, const char *description, unsigned int *val)
Increment val each time the option flag is given by one.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_cfgfile(char **fn)
Allow user to specify configuration file name (-c option)
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_logfile(char **logfn)
Allow user to specify log file name (-l option)
int GNUNET_GETOPT_run(const char *binaryOptions, const struct GNUNET_GETOPT_CommandLineOption *allOptions, unsigned int argc, char *const *argv)
Parse the command line.
Definition: getopt.c:883
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a filename (automatically path expanded).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_exclusive(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mutually exclusive with other options.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_mandatory(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mandatory.
int(* GNUNET_GETOPT_CommandLineOptionProcessor)(struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, void *scls, const char *option, const char *value)
Process a command line option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_help(const char *about)
Defining the option to print the command line help text (-h option).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_timetravel(char shortName, const char *name)
Allow user to specify a long long with an offset to add to the current system time to construct the t...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_base32_fixed_size(char shortName, const char *name, const char *argumentHelp, const char *description, void *val, size_t val_size)
Allow user to specify a binary value using Crockford Base32 encoding.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_absolute_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Absolute *val)
Allow user to specify a struct GNUNET_TIME_Absolute (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_loglevel(char **level)
Define the '-L' log level option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_ulong(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned long long *val)
Allow user to specify an unsigned long long.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint16(char shortName, const char *name, const char *argumentHelp, const char *description, uint16_t *val)
Allow user to specify an uint16_t.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_version(const char *version)
Define the option to print the version of the application (-v option)
const char * name
Definition of a command line option.
int require_argument
Is an argument required? GNUNET_NO (includes optional) or GNUNET_YES (required)
const char * description
Help text for the option (description)
const char * argumentHelp
Name of the argument for the user in help text.
int option_exclusive
Is the option exclusive?
int option_mandatory
Is the presence of this option mandatory?
const char * name
Long name of the option (may not be NULL)
void * scls
Specific closure to pass to the processor.
GNUNET_GETOPT_CommandLineOptionProcessor processor
Handler for the option.
const char shortName
Short name of the option.
void(* cleaner)(void *cls)
Function to call on scls to clean up after processing all the arguments.
General context for command line processors.
const char * binaryName
Name of the application.
const char * binaryOptions
Name of application with option summary.
const struct GNUNET_GETOPT_CommandLineOption * allOptions
Array with all command line options.
char *const * argv
Original command line.
unsigned int argc
Total number of argv's.
unsigned int currentArgument
Current argument.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Rounded time for timestamps used by GNUnet, in seconds.