-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopts.h
72 lines (65 loc) · 1.6 KB
/
opts.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* This software is Copyright 1995-2005 Peter Seebach. Please see the
* associated file "COPYRIGHT" for copyright information, or write
*/
/* option library definitions */
enum {
OFLAG_NONE = 0x0,
OFLAG_SAVE = 0x1,
OFLAG_DFL = OFLAG_SAVE << 1,
OFLAG_SET = OFLAG_DFL << 1,
OFLAG_ARG = OFLAG_SET << 1,
OFLAG_CONST = OFLAG_ARG << 1,
OFLAG_NOVAL = OFLAG_CONST << 1,
OFLAG_MAX = OFLAG_NOVAL << 1
};
enum {
OTYPE_END, /* end of options */
OTYPE_NUL, /* no content */
OTYPE_BOL, /* boolean */
OTYPE_SHR,
OTYPE_INT,
OTYPE_LNG,
OTYPE_STR,
OTYPE_BUF,
OTYPE_DBL,
OTYPE_ARG, /* multiple args */
OTYPE_MAX
};
struct option_struct;
typedef union {
double v_double;
char *v_str;
char v_buf; /* ick */
int v_int;
short v_short;
long v_long;
} opt_value;
typedef int (*optsverify)(struct option_struct *, opt_value *);
typedef void (*optssettor)(struct option_struct *, opt_value *);
typedef struct option_struct {
int type;
char abbr;
char *name;
char *desc;
int flags;
void *value;
void *defalt; /* sic. */
optsverify verify;
optssettor settor;
int *is_set;
} option;
/* our provided interface */
extern int optsload(option *, char *), optssave(option *, char *);
extern char *optsprint(option *);
extern char *optsusage(option *);
extern int optscheck(option *);
extern int optsgets(int, char **, option *);
extern int optsget(int, char **, option *);
extern int optsopt(int, char **, char *);
extern int optsetstyle(int);
extern option *optsmake(char *);
extern option *optsfind(int, char *, option *);
extern int optsind, optserr, optsok;
extern opt_value optsval;
extern char *optsarg;