]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - include/command.h
xfsprogs: Release v6.7.0
[thirdparty/xfsprogs-dev.git] / include / command.h
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6 #ifndef __COMMAND_H__
7 #define __COMMAND_H__
8
9 #include <sys/time.h>
10
11 /*
12 * A "oneshot" command ony runs once per command execution. It does
13 * not iterate the command args function callout and so can be used
14 * for functions like "help" that should only ever be run once.
15 */
16 #define CMD_FLAG_ONESHOT (1u << 31)
17 #define CMD_FLAG_FOREIGN_OK (1u << 30) /* command not restricted to XFS */
18 #define CMD_FLAG_LIBRARY (1u << 29) /* command provided by libxcmd */
19
20 typedef int (*cfunc_t)(int argc, char **argv);
21 typedef void (*helpfunc_t)(void);
22
23 typedef struct cmdinfo {
24 const char *name;
25 const char *altname;
26 cfunc_t cfunc;
27 int argmin;
28 int argmax;
29 int canpush;
30 int flags;
31 const char *args;
32 const char *oneline;
33 helpfunc_t help;
34 } cmdinfo_t;
35
36 extern cmdinfo_t *cmdtab;
37 extern int ncmds;
38
39 extern void help_init(void);
40 extern void quit_init(void);
41
42 typedef int (*iterfunc_t)(int index);
43 typedef int (*checkfunc_t)(const cmdinfo_t *ci);
44
45 extern void add_command(const cmdinfo_t *ci);
46 extern void add_user_command(char *optarg);
47 extern void add_oneshot_user_command(char *optarg);
48 extern void add_command_iterator(iterfunc_t func);
49 extern void add_check_command(checkfunc_t cf);
50
51 extern const cmdinfo_t *find_command(const char *cmd);
52
53 extern void command_loop(void);
54 extern int command_usage(const cmdinfo_t *ci);
55 extern int command(const cmdinfo_t *ci, int argc, char **argv);
56
57 extern void report_io_times(const char *verb, struct timeval *t2,
58 long long offset, long long count,
59 long long total, int ops, int compact);
60
61 #endif /* __COMMAND_H__ */