root / cmd.h @ 6c0d7ee8
History | View | Annotate | Download (2.2 kB)
1 | e3aff4f6 | aliguori | /*
|
---|---|---|---|
2 | e3aff4f6 | aliguori | * Copyright (c) 2000-2005 Silicon Graphics, Inc.
|
3 | e3aff4f6 | aliguori | * All Rights Reserved.
|
4 | e3aff4f6 | aliguori | *
|
5 | e3aff4f6 | aliguori | * This program is free software; you can redistribute it and/or
|
6 | e3aff4f6 | aliguori | * modify it under the terms of the GNU General Public License as
|
7 | e3aff4f6 | aliguori | * published by the Free Software Foundation.
|
8 | e3aff4f6 | aliguori | *
|
9 | e3aff4f6 | aliguori | * This program is distributed in the hope that it would be useful,
|
10 | e3aff4f6 | aliguori | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11 | e3aff4f6 | aliguori | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12 | e3aff4f6 | aliguori | * GNU General Public License for more details.
|
13 | e3aff4f6 | aliguori | *
|
14 | e3aff4f6 | aliguori | * You should have received a copy of the GNU General Public License
|
15 | e3aff4f6 | aliguori | * along with this program; if not, write the Free Software Foundation,
|
16 | e3aff4f6 | aliguori | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 | e3aff4f6 | aliguori | */
|
18 | e3aff4f6 | aliguori | #ifndef __COMMAND_H__
|
19 | e3aff4f6 | aliguori | #define __COMMAND_H__
|
20 | e3aff4f6 | aliguori | |
21 | e3aff4f6 | aliguori | #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */ |
22 | e3aff4f6 | aliguori | |
23 | e3aff4f6 | aliguori | typedef int (*cfunc_t)(int argc, char **argv); |
24 | e3aff4f6 | aliguori | typedef void (*helpfunc_t)(void); |
25 | e3aff4f6 | aliguori | |
26 | e3aff4f6 | aliguori | typedef struct cmdinfo { |
27 | e3aff4f6 | aliguori | const char *name; |
28 | e3aff4f6 | aliguori | const char *altname; |
29 | e3aff4f6 | aliguori | cfunc_t cfunc; |
30 | e3aff4f6 | aliguori | int argmin;
|
31 | e3aff4f6 | aliguori | int argmax;
|
32 | e3aff4f6 | aliguori | int canpush;
|
33 | e3aff4f6 | aliguori | int flags;
|
34 | e3aff4f6 | aliguori | const char *args; |
35 | e3aff4f6 | aliguori | const char *oneline; |
36 | e3aff4f6 | aliguori | helpfunc_t help; |
37 | e3aff4f6 | aliguori | } cmdinfo_t; |
38 | e3aff4f6 | aliguori | |
39 | e3aff4f6 | aliguori | extern cmdinfo_t *cmdtab;
|
40 | e3aff4f6 | aliguori | extern int ncmds; |
41 | e3aff4f6 | aliguori | |
42 | e3aff4f6 | aliguori | extern void help_init(void); |
43 | e3aff4f6 | aliguori | extern void quit_init(void); |
44 | e3aff4f6 | aliguori | |
45 | e3aff4f6 | aliguori | typedef int (*argsfunc_t)(int index); |
46 | e3aff4f6 | aliguori | typedef int (*checkfunc_t)(const cmdinfo_t *ci); |
47 | e3aff4f6 | aliguori | |
48 | e3aff4f6 | aliguori | extern void add_command(const cmdinfo_t *ci); |
49 | e3aff4f6 | aliguori | extern void add_user_command(char *optarg); |
50 | e3aff4f6 | aliguori | extern void add_args_command(argsfunc_t af); |
51 | e3aff4f6 | aliguori | extern void add_check_command(checkfunc_t cf); |
52 | e3aff4f6 | aliguori | |
53 | e3aff4f6 | aliguori | extern const cmdinfo_t *find_command(const char *cmd); |
54 | e3aff4f6 | aliguori | |
55 | e3aff4f6 | aliguori | extern void command_loop(void); |
56 | e3aff4f6 | aliguori | extern int command_usage(const cmdinfo_t *ci); |
57 | e3aff4f6 | aliguori | extern int command(const cmdinfo_t *ci, int argc, char **argv); |
58 | e3aff4f6 | aliguori | |
59 | e3aff4f6 | aliguori | /* from input.h */
|
60 | e3aff4f6 | aliguori | extern char **breakline(char *input, int *count); |
61 | e3aff4f6 | aliguori | extern void doneline(char *input, char **vec); |
62 | e3aff4f6 | aliguori | extern char *fetchline(void); |
63 | e3aff4f6 | aliguori | |
64 | e3aff4f6 | aliguori | extern long long cvtnum(char *s); |
65 | e3aff4f6 | aliguori | extern void cvtstr(double value, char *str, size_t sz); |
66 | e3aff4f6 | aliguori | |
67 | e3aff4f6 | aliguori | extern struct timeval tsub(struct timeval t1, struct timeval t2); |
68 | e3aff4f6 | aliguori | extern double tdiv(double value, struct timeval tv); |
69 | e3aff4f6 | aliguori | |
70 | e3aff4f6 | aliguori | enum {
|
71 | e3aff4f6 | aliguori | DEFAULT_TIME = 0x0,
|
72 | e3aff4f6 | aliguori | TERSE_FIXED_TIME = 0x1,
|
73 | e3aff4f6 | aliguori | VERBOSE_FIXED_TIME = 0x2
|
74 | e3aff4f6 | aliguori | }; |
75 | e3aff4f6 | aliguori | |
76 | e3aff4f6 | aliguori | extern void timestr(struct timeval *tv, char *str, size_t sz, int flags); |
77 | e3aff4f6 | aliguori | |
78 | 856ae5c3 | blueswir1 | extern char *progname; |
79 | 856ae5c3 | blueswir1 | |
80 | e3aff4f6 | aliguori | #endif /* __COMMAND_H__ */ |