1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#ifndef __COMMAND_H__
18#define __COMMAND_H__
19
20#define CMD_FLAG_GLOBAL ((int)0x80000000)
21
22typedef int (*cfunc_t)(int argc, char **argv);
23typedef void (*helpfunc_t)(void);
24
25typedef struct cmdinfo {
26 const char *name;
27 const char *altname;
28 cfunc_t cfunc;
29 int argmin;
30 int argmax;
31 int canpush;
32 int flags;
33 const char *args;
34 const char *oneline;
35 helpfunc_t help;
36} cmdinfo_t;
37
38extern cmdinfo_t *cmdtab;
39extern int ncmds;
40
41void help_init(void);
42void quit_init(void);
43
44typedef int (*argsfunc_t)(int index);
45typedef int (*checkfunc_t)(const cmdinfo_t *ci);
46
47void add_command(const cmdinfo_t *ci);
48void add_user_command(char *optarg);
49void add_args_command(argsfunc_t af);
50void add_check_command(checkfunc_t cf);
51
52const cmdinfo_t *find_command(const char *cmd);
53
54void command_loop(void);
55int command_usage(const cmdinfo_t *ci);
56int command(const cmdinfo_t *ci, int argc, char **argv);
57
58
59char **breakline(char *input, int *count);
60void doneline(char *input, char **vec);
61char *fetchline(void);
62
63long long cvtnum(char *s);
64void cvtstr(double value, char *str, size_t sz);
65
66struct timeval tsub(struct timeval t1, struct timeval t2);
67double tdiv(double value, struct timeval tv);
68
69enum {
70 DEFAULT_TIME = 0x0,
71 TERSE_FIXED_TIME = 0x1,
72 VERBOSE_FIXED_TIME = 0x2
73};
74
75void timestr(struct timeval *tv, char *str, size_t sz, int flags);
76
77extern char *progname;
78
79#endif
80