Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (51 sloc) 1.655 kb
1ec1765d »
2007-11-22 Introduced new option parsing mechanism, getconfopt.
1 #ifndef GETCONFOPT__H
2 #define GETCONFOPT__H
3
4 struct option;
5 struct stralloc;
6
7 struct option_type
8 {
9 int needsarg;
10 int (*parse)(struct option*,const char*);
11 void (*fetch)(struct option*);
12 };
13
14 extern const struct option_type opt_copy_flag;
15 extern const struct option_type opt_cstr;
16 extern const struct option_type opt_cstr_flag;
17 extern const struct option_type opt_flag;
18 extern const struct option_type opt_str;
19 extern const struct option_type opt_ulong;
20 extern const struct option_type opt_ulong_flag;
21 extern const struct option_type opt_version;
22
23 struct option
24 {
25 union
26 {
27 int *flag;
28 unsigned long *ulong;
29 const char **cstr;
30 struct stralloc *str;
31 } var;
4b523b73 »
2010-10-24 getconfopt: Make the set value and flag char const in struct option
32 const char ch;
1ec1765d »
2007-11-22 Introduced new option parsing mechanism, getconfopt.
33 const struct option_type *type;
4b523b73 »
2010-10-24 getconfopt: Make the set value and flag char const in struct option
34 const union
1ec1765d »
2007-11-22 Introduced new option parsing mechanism, getconfopt.
35 {
36 int flag;
37 unsigned long ulong;
38 const char *cstr;
39 } value;
40 const char *filename;
41 };
42
6fb9df55 »
2010-10-25 getconfopt: Read default files before parsing command line values
43 #define OPT_COPY_FLAG(VAR,CH) {{.str=&VAR},CH,&opt_copy_flag,{0},0}
44 #define OPT_CSTR(VAR,CH,FILENAME) {{.cstr=&VAR},CH,&opt_cstr,{0},FILENAME}
45 #define OPT_CSTR_FLAG(VAR,CH,VALUE,FILENAME) {{.cstr=&VAR},CH,&opt_cstr_flag,{.cstr=VALUE},FILENAME}
46 #define OPT_FLAG(VAR,CH,VALUE,FILENAME) {{.flag=&VAR},CH,&opt_flag,{.flag=VALUE},FILENAME}
47 #define OPT_STR(VAR,CH,FILENAME) {{.str=&VAR},CH,&opt_str,{0},FILENAME}
48 #define OPT_ULONG(VAR,CH,FILENAME) {{.ulong=&VAR},CH,&opt_ulong,{0},FILENAME}
49 #define OPT_ULONG_FLAG(VAR,CH,VALUE,FILENAME) {{.ulong=&VAR},CH,&opt_ulong_flag,{.ulong=VALUE},FILENAME}
1ec1765d »
2007-11-22 Introduced new option parsing mechanism, getconfopt.
50 #define OPT_END \
6fb9df55 »
2010-10-25 getconfopt: Read default files before parsing command line values
51 {{0},'v',&opt_version,{0},0},\
52 {{0},'V',&opt_version,{0},0},\
53 {{0},0,0,{0},0}
1ec1765d »
2007-11-22 Introduced new option parsing mechanism, getconfopt.
54
55 extern int getconfopt(int argc, char *argv[], struct option *options,
56 int dochdir,const char **dir);
57
58 #endif
Something went wrong with that request. Please try again.