-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharg.h
29 lines (23 loc) · 820 Bytes
/
arg.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
#ifndef _MIMINO_ARG_H
#define _MIMINO_ARG_H
// Tells parse_args() which arguments we want to parse
typedef struct {
char short_arg; // with single dash
char *long_arg; // with double dash
char *err; // returned error message
char type; // one of [bsr]
// Boolean value set by parse_args().
// Is set to 1 if the argument was present, otherwise it's 0.
int bvalue;
// String value set by parse_args().
// Only set for string types.
char *value;
} Argdef;
// raw is for arguments given without flags
#define ARGDEF_TYPE_BOOL 'b'
#define ARGDEF_TYPE_STRING 's'
#define ARGDEF_TYPE_RAW 'r'
int parse_args(int argc, char **argv, int argdefc, Argdef *argdefs);
void print_argdef(Argdef *);
void print_argdefs(Argdef *a, int count);
#endif // _MIMINO_ARG_H