GNUnet 0.22.2
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#if ! defined (__GNUNET_UTIL_LIB_H_INSIDE__)
37#error "Only <gnunet_util_lib.h> can be included directly."
38#endif
39
40#ifndef GNUNET_GETOPT_LIB_H
41#define GNUNET_GETOPT_LIB_H
42
43#ifdef __cplusplus
44extern "C" {
45#if 0 /* keep Emacsens' auto-indent happy */
46}
47#endif
48#endif
49
50
52
57{
61 const char *binaryName;
62
66 const char *binaryOptions;
67
72
76 char *const *argv;
77
81 unsigned int argc;
82
86 unsigned int currentArgument;
87};
88
89
101 void *scls,
102 const char *option,
103 const char *value);
104
105
110{
114 const char shortName;
115
119 const char *name;
120
124 const char *argumentHelp;
125
129 const char *description;
130
136
141
146
151
156 void (*cleaner) (void *cls);
157
161 void *scls;
162};
163
164
174 const char *about);
175
176
188 const char *name);
189
190
198GNUNET_GETOPT_option_version (const char *version);
199
200
207GNUNET_GETOPT_option_logfile (char **logfn);
208
209
221 const char *name,
222 const char *argumentHelp,
223 const char *description,
224 char **str);
225
237 const char *name,
238 const char *argumentHelp,
239 const char *description,
240 char **str);
241
242
256 const char *name,
257 const char *argumentHelp,
258 const char *description,
259 void *val,
260 size_t val_size);
261
262
275#define GNUNET_GETOPT_option_base32_auto(shortName, \
276 name, \
277 argumentHelp, \
278 description, \
279 val) \
280 GNUNET_GETOPT_option_base32_fixed_size (shortName, \
281 name, \
282 argumentHelp, \
283 description, \
284 val, \
285 sizeof(*val))
286
287
299 const char *name,
300 const char *description,
301 int *val);
302
303
315 const char *name,
316 const char *argumentHelp,
317 const char *description,
318 unsigned int *val);
319
320
332 const char *name,
333 const char *argumentHelp,
334 const char *description,
335 uint16_t *val);
336
337
349 const char *name,
350 const char *argumentHelp,
351 const char *description,
352 unsigned long long *val);
353
354
367 const char *name,
368 const char *argumentHelp,
369 const char *description,
370 struct GNUNET_TIME_Relative *val);
371
372
385 const char *name,
386 const char *argumentHelp,
387 const char *description,
388 struct GNUNET_TIME_Absolute *val);
389
390
403 const char *name,
404 const char *argumentHelp,
405 const char *description,
406 struct GNUNET_TIME_Timestamp *val);
407
408
419 const char *name,
420 const char *description,
421 unsigned int *val);
422
423
431GNUNET_GETOPT_option_loglevel (char **level);
432
433
441GNUNET_GETOPT_option_verbose (unsigned int *level);
442
443
451
452
461
462
471
472
476#define GNUNET_GETOPT_OPTION_END \
477 { \
478 '\0', NULL, NULL, NULL, 0, 0, 0, NULL, NULL, NULL \
479 }
480
481
492int
493GNUNET_GETOPT_run (const char *binaryOptions,
494 const struct GNUNET_GETOPT_CommandLineOption *allOptions,
495 unsigned int argc,
496 char *const *argv);
497
498
499#if 0 /* keep Emacsens' auto-indent happy */
500{
501#endif
502#ifdef __cplusplus
503}
504#endif
505
506/* ifndef GNUNET_GETOPT_LIB_H */
507#endif
508 /* end of group getopt */
510 /* end of group addition */
512
513/* end of gnunet_getopt_lib.h */
static struct GNUNET_FS_Handle * ctx
static char * name
Name (label) of the records to list.
static char * value
Value of the record to add/remove.
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:884
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_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_help(const struct GNUNET_OS_ProjectData *pd, const char *about)
Defining the option to print the command line help text (-h option).
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)
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.
Project-specific data used to help the OS subsystem find installation paths.
Time for absolute times used by GNUnet, in microseconds.
Time for relative time used by GNUnet, in microseconds.
Time for timestamps used by GNUnet, in microseconds rounded to seconds.