]> git.proxmox.com Git - mirror_qemu.git/blame - cmd.h
qemu-io: Factor out qemuio_command
[mirror_qemu.git] / cmd.h
CommitLineData
e3aff4f6
AL
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
8167ee88 15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
e3aff4f6
AL
16 */
17#ifndef __COMMAND_H__
18#define __COMMAND_H__
19
734c3b85
KW
20#include "qemu-common.h"
21
e3aff4f6
AL
22#define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
23
734c3b85
KW
24extern BlockDriverState *qemuio_bs;
25
26typedef int (*cfunc_t)(BlockDriverState *bs, int argc, char **argv);
e3aff4f6
AL
27typedef void (*helpfunc_t)(void);
28
29typedef struct cmdinfo {
30 const char *name;
31 const char *altname;
32 cfunc_t cfunc;
33 int argmin;
34 int argmax;
35 int canpush;
36 int flags;
37 const char *args;
38 const char *oneline;
39 helpfunc_t help;
40} cmdinfo_t;
41
42extern cmdinfo_t *cmdtab;
43extern int ncmds;
44
64b85a8f
BS
45void help_init(void);
46void quit_init(void);
e3aff4f6 47
734c3b85 48typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci);
e3aff4f6 49
64b85a8f
BS
50void add_command(const cmdinfo_t *ci);
51void add_user_command(char *optarg);
64b85a8f 52void add_check_command(checkfunc_t cf);
e3aff4f6 53
64b85a8f 54const cmdinfo_t *find_command(const char *cmd);
e3aff4f6 55
64b85a8f
BS
56void command_loop(void);
57int command_usage(const cmdinfo_t *ci);
58int command(const cmdinfo_t *ci, int argc, char **argv);
e3aff4f6
AL
59
60/* from input.h */
64b85a8f 61char **breakline(char *input, int *count);
64b85a8f 62char *fetchline(void);
e3aff4f6 63
64b85a8f 64void cvtstr(double value, char *str, size_t sz);
e3aff4f6 65
64b85a8f
BS
66struct timeval tsub(struct timeval t1, struct timeval t2);
67double tdiv(double value, struct timeval tv);
e3aff4f6
AL
68
69enum {
70 DEFAULT_TIME = 0x0,
71 TERSE_FIXED_TIME = 0x1,
72 VERBOSE_FIXED_TIME = 0x2
73};
74
64b85a8f 75void timestr(struct timeval *tv, char *str, size_t sz, int flags);
e3aff4f6 76
856ae5c3
BS
77extern char *progname;
78
dd583296
KW
79bool qemuio_command(const char *cmd);
80
e3aff4f6 81#endif /* __COMMAND_H__ */