]>
Commit | Line | Data |
---|---|---|
e246ba5f | 1 | /* |
f302e9e4 NS |
2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | |
dfc130f3 | 4 | * |
f302e9e4 NS |
5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License as | |
e246ba5f | 7 | * published by the Free Software Foundation. |
dfc130f3 | 8 | * |
f302e9e4 NS |
9 | * This program is distributed in the hope that it would be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
dfc130f3 | 13 | * |
f302e9e4 NS |
14 | * You should have received a copy of the GNU General Public License |
15 | * along with this program; if not, write the Free Software Foundation, | |
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
e246ba5f | 17 | */ |
3d93ccb7 NS |
18 | #ifndef __COMMAND_H__ |
19 | #define __COMMAND_H__ | |
e246ba5f | 20 | |
a9b61ce9 DW |
21 | #include <sys/time.h> |
22 | ||
7a9b7314 DC |
23 | /* |
24 | * A "oneshot" command ony runs once per command execution. It does | |
25 | * not iterate the command args function callout and so can be used | |
26 | * for functions like "help" that should only ever be run once. | |
27 | */ | |
28 | #define CMD_FLAG_ONESHOT (1<<31) | |
29647c8d | 29 | #define CMD_FLAG_FOREIGN_OK (1<<30) /* command not restricted to XFS */ |
92058d25 | 30 | #define CMD_FLAG_LIBRARY (1<<29) /* command provided by libxcmd */ |
802d66e3 | 31 | |
e246ba5f NS |
32 | typedef int (*cfunc_t)(int argc, char **argv); |
33 | typedef void (*helpfunc_t)(void); | |
34 | ||
35 | typedef struct cmdinfo { | |
36 | const char *name; | |
37 | const char *altname; | |
38 | cfunc_t cfunc; | |
39 | int argmin; | |
40 | int argmax; | |
41 | int canpush; | |
48c46ee3 | 42 | int flags; |
e246ba5f NS |
43 | const char *args; |
44 | const char *oneline; | |
45 | helpfunc_t help; | |
46 | } cmdinfo_t; | |
47 | ||
48 | extern cmdinfo_t *cmdtab; | |
49 | extern int ncmds; | |
50 | ||
3d93ccb7 NS |
51 | extern void help_init(void); |
52 | extern void quit_init(void); | |
53 | ||
ef346a25 | 54 | typedef int (*iterfunc_t)(int index); |
3d93ccb7 NS |
55 | typedef int (*checkfunc_t)(const cmdinfo_t *ci); |
56 | ||
e246ba5f | 57 | extern void add_command(const cmdinfo_t *ci); |
3d93ccb7 | 58 | extern void add_user_command(char *optarg); |
58a1899a | 59 | extern void add_oneshot_user_command(char *optarg); |
ef346a25 | 60 | extern void add_command_iterator(iterfunc_t func); |
3d93ccb7 NS |
61 | extern void add_check_command(checkfunc_t cf); |
62 | ||
63 | extern const cmdinfo_t *find_command(const char *cmd); | |
64 | ||
65 | extern void command_loop(void); | |
48c46ee3 | 66 | extern int command_usage(const cmdinfo_t *ci); |
802d66e3 | 67 | extern int command(const cmdinfo_t *ci, int argc, char **argv); |
e246ba5f | 68 | |
a9b61ce9 DW |
69 | extern void report_io_times(const char *verb, struct timeval *t2, |
70 | long long offset, long long count, | |
71 | long long total, int ops, int compact); | |
72 | ||
3d93ccb7 | 73 | #endif /* __COMMAND_H__ */ |