]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/command.h
libxcmd: rename args_command to command_iterator
[thirdparty/xfsprogs-dev.git] / include / command.h
1 /*
2 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
4 *
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
7 * published by the Free Software Foundation.
8 *
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.
13 *
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
17 */
18 #ifndef __COMMAND_H__
19 #define __COMMAND_H__
20
21 #include <sys/time.h>
22
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)
29 #define CMD_FLAG_FOREIGN_OK (1<<30) /* command not restricted to XFS */
30
31 typedef int (*cfunc_t)(int argc, char **argv);
32 typedef void (*helpfunc_t)(void);
33
34 typedef struct cmdinfo {
35 const char *name;
36 const char *altname;
37 cfunc_t cfunc;
38 int argmin;
39 int argmax;
40 int canpush;
41 int flags;
42 const char *args;
43 const char *oneline;
44 helpfunc_t help;
45 } cmdinfo_t;
46
47 extern cmdinfo_t *cmdtab;
48 extern int ncmds;
49
50 extern void help_init(void);
51 extern void quit_init(void);
52
53 typedef int (*iterfunc_t)(int index);
54 typedef int (*checkfunc_t)(const cmdinfo_t *ci);
55
56 extern void add_command(const cmdinfo_t *ci);
57 extern void add_user_command(char *optarg);
58 extern void add_command_iterator(iterfunc_t func);
59 extern void add_check_command(checkfunc_t cf);
60
61 extern const cmdinfo_t *find_command(const char *cmd);
62
63 extern void command_loop(void);
64 extern int command_usage(const cmdinfo_t *ci);
65 extern int command(const cmdinfo_t *ci, int argc, char **argv);
66
67 extern void report_io_times(const char *verb, struct timeval *t2,
68 long long offset, long long count,
69 long long total, int ops, int compact);
70
71 #endif /* __COMMAND_H__ */