]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - include/command.h
xfs: fix off-by-one error in xfs_rtalloc_query_range
[thirdparty/xfsprogs-dev.git] / include / command.h
CommitLineData
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 */
b0e515d6
DW
28#define CMD_FLAG_ONESHOT (1u << 31)
29#define CMD_FLAG_FOREIGN_OK (1u << 30) /* command not restricted to XFS */
30#define CMD_FLAG_LIBRARY (1u << 29) /* command provided by libxcmd */
802d66e3 31
e246ba5f
NS
32typedef int (*cfunc_t)(int argc, char **argv);
33typedef void (*helpfunc_t)(void);
34
35typedef 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
48extern cmdinfo_t *cmdtab;
49extern int ncmds;
50
3d93ccb7
NS
51extern void help_init(void);
52extern void quit_init(void);
53
ef346a25 54typedef int (*iterfunc_t)(int index);
3d93ccb7
NS
55typedef int (*checkfunc_t)(const cmdinfo_t *ci);
56
e246ba5f 57extern void add_command(const cmdinfo_t *ci);
3d93ccb7 58extern void add_user_command(char *optarg);
58a1899a 59extern void add_oneshot_user_command(char *optarg);
ef346a25 60extern void add_command_iterator(iterfunc_t func);
3d93ccb7
NS
61extern void add_check_command(checkfunc_t cf);
62
63extern const cmdinfo_t *find_command(const char *cmd);
64
65extern void command_loop(void);
48c46ee3 66extern int command_usage(const cmdinfo_t *ci);
802d66e3 67extern int command(const cmdinfo_t *ci, int argc, char **argv);
e246ba5f 68
a9b61ce9
DW
69extern 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__ */