bglibs
include
cli.h
1
#ifndef CLI__H__
2
#define CLI__H__
3
4
enum
cli_option_type {
5
CLI_FLAG,
6
CLI_COUNTER,
7
CLI_INTEGER,
8
CLI_UINTEGER,
9
CLI_STRING,
10
CLI_STRINGLIST,
11
CLI_FUNCTION,
12
CLI_SEPARATOR,
13
};
14
typedef
enum
cli_option_type cli_option_type;
15
16
struct
cli_option
17
{
18
char
ch;
19
const
char
* name;
20
cli_option_type type;
21
int
flag_value;
22
void
* dataptr;
23
const
char
* helpstr;
24
const
char
* defaultstr;
25
};
26
typedef
struct
cli_option
cli_option
;
27
28
struct
cli_stringlist
29
{
30
const
char
* string;
31
const
struct
cli_option
* option;
32
struct
cli_stringlist
* next;
33
};
34
typedef
struct
cli_stringlist
cli_stringlist
;
35
36
typedef
void
cli_function(
const
char
*
string
,
const
struct
cli_option
* option);
37
38
/* The following are required from the CLI program */
39
extern
const
char
cli_help_prefix[];
40
extern
const
char
cli_help_suffix[];
41
extern
const
char
cli_args_usage[];
42
extern
const
int
cli_args_min;
43
extern
const
int
cli_args_max;
44
extern
cli_option
cli_options[];
45
extern
int
cli_main(
int
argc,
char
** argv);
46
47
/* The following are provided to the CLI program */
48
extern
const
char
* argv0;
49
extern
const
char
* argv0base;
50
extern
const
char
* argv0dir;
51
extern
void
usage(
int
exit_value,
const
char
* errorstr);
52
extern
void
cli_show_help(
void
);
53
54
#endif
str::s
char * s
Definition:
str.h:36
obuf_putu
int obuf_putu(obuf *out, unsigned long data)
Definition:
obuf_putunumw.c:21
cli_stringlist
Definition:
cli.h:29
obuf_endl
int obuf_endl(obuf *out)
Definition:
obuf_endl.c:4
str::len
unsigned len
Definition:
str.h:40
obuf_write
int obuf_write(obuf *out, const char *data, unsigned datalen)
Definition:
obuf_write.c:30
outbuf
obuf outbuf
Definition:
obuf_stdout.c:7
fmt_char
unsigned fmt_char(char *buffer, int ch, unsigned width, char pad)
Definition:
char.c:21
cli_option
Definition:
cli.h:17
str
Definition:
str.h:31
Generated on Tue Jan 5 2021 12:18:07 for bglibs by
1.8.20