CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/miniopt.h
Views: 3959
1
/*
2
* Command line options parser.
3
*
4
* $Copyright Open Broadcom Corporation$
5
* $Id: miniopt.h 241182 2011-02-17 21:50:03Z gmo $
6
*/
7
8
9
#ifndef MINI_OPT_H
10
#define MINI_OPT_H
11
12
#ifdef __cplusplus
13
extern "C" {
14
#endif
15
16
/* ---- Include Files ---------------------------------------------------- */
17
/* ---- Constants and Types ---------------------------------------------- */
18
19
#define MINIOPT_MAXKEY 128 /* Max options */
20
typedef struct miniopt {
21
22
/* These are persistent after miniopt_init() */
23
const char* name; /* name for prompt in error strings */
24
const char* flags; /* option chars that take no args */
25
bool longflags; /* long options may be flags */
26
bool opt_end; /* at end of options (passed a "--") */
27
28
/* These are per-call to miniopt() */
29
30
int consumed; /* number of argv entries cosumed in
31
* the most recent call to miniopt()
32
*/
33
bool positional;
34
bool good_int; /* 'val' member is the result of a sucessful
35
* strtol conversion of the option value
36
*/
37
char opt;
38
char key[MINIOPT_MAXKEY];
39
char* valstr; /* positional param, or value for the option,
40
* or null if the option had
41
* no accompanying value
42
*/
43
uint uval; /* strtol translation of valstr */
44
int val; /* strtol translation of valstr */
45
} miniopt_t;
46
47
void miniopt_init(miniopt_t *t, const char* name, const char* flags, bool longflags);
48
int miniopt(miniopt_t *t, char **argv);
49
50
51
/* ---- Variable Externs ------------------------------------------------- */
52
/* ---- Function Prototypes ---------------------------------------------- */
53
54
55
#ifdef __cplusplus
56
}
57
#endif
58
59
#endif /* MINI_OPT_H */
60
61