ROSS
tw-opts.h
Go to the documentation of this file.
1 #ifndef INC_tw_opts_h
2 #define INC_tw_opts_h
3 
5 {
7  TWOPTTYPE_ULONG, /**< value must be an "unsigned long*" */
8  TWOPTTYPE_ULONGLONG, /**< value must be an "unsigned long long*" */
9  TWOPTTYPE_UINT, /**< value must be an "unsigned int*" */
10  TWOPTTYPE_STIME, /**< value must be a "tw_stime*" */
11  TWOPTTYPE_DOUBLE, /**< value must be a "double *" */
12  TWOPTTYPE_CHAR, /**< value must be a "char *" */
13  TWOPTTYPE_FLAG, /**< value must be an "unsigned int*" */
15 };
16 typedef enum tw_opttype tw_opttype;
17 
18 typedef struct tw_optdef tw_optdef;
19 struct tw_optdef
20 {
22  const char *name;
23  const char *help;
24  void *value;
25 };
26 
27 #define TWOPT_GROUP(h) { TWOPTTYPE_GROUP, NULL, (h), NULL }
28 #define TWOPT_ULONG(n,v,h) { TWOPTTYPE_ULONG, (n), (h), &(v) }
29 #define TWOPT_ULONGLONG(n,v,h) { TWOPTTYPE_ULONGLONG, (n), (h), &(v) }
30 #define TWOPT_UINT(n,v,h) { TWOPTTYPE_UINT, (n), (h), &(v) }
31 #define TWOPT_STIME(n,v,h) { TWOPTTYPE_STIME, (n), (h), &(v) }
32 #define TWOPT_DOUBLE(n,v,h) { TWOPTTYPE_DOUBLE, (n), (h), &(v) }
33 #define TWOPT_CHAR(n,v,h) { TWOPTTYPE_CHAR, (n), (h), &(v) }
34 #define TWOPT_FLAG(n,v,h) { TWOPTTYPE_FLAG, (n), (h), &(v) }
35 #define TWOPT_END() { (tw_opttype)0, NULL, NULL, NULL }
36 
37 /** Remove options from the command line arguments. */
38 extern void tw_opt_parse(int *argc, char ***argv);
39 /** Add an opt group */
40 extern void tw_opt_add(const tw_optdef *options);
41 /** Pretty-print the option descriptions (for --help) */
42 extern void tw_opt_print(void);
43 /** Pretty-print the option descriptions and current values */
44 extern void tw_opt_settings(FILE *f);
45 
46 #endif
void tw_opt_add(const tw_optdef *options)
Definition: tw-opts.c:14
void tw_opt_print(void)
Definition: tw-opts.c:215
void * value
Definition: tw-opts.h:24
const char * help
Definition: tw-opts.h:23
tw_opttype type
Definition: tw-opts.h:21
void tw_opt_parse(int *argc, char ***argv)
Definition: tw-opts.c:427
tw_opttype
Definition: tw-opts.h:4
const char * name
Definition: tw-opts.h:22
void tw_opt_settings(FILE *f)
Definition: tw-opts.c:138