From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhLpb-0004jW-5a for qemu-devel@nongnu.org; Tue, 28 May 2013 11:29:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhLpV-0007YB-JG for qemu-devel@nongnu.org; Tue, 28 May 2013 11:28:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhLpV-0007Y4-9X for qemu-devel@nongnu.org; Tue, 28 May 2013 11:28:53 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4SFSqY9013407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 May 2013 11:28:52 -0400 From: Kevin Wolf Date: Tue, 28 May 2013 17:27:29 +0200 Message-Id: <1369754856-30036-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1369754856-30036-1-git-send-email-kwolf@redhat.com> References: <1369754856-30036-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 09/16] qemu-io: Move 'quit' function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, lcapitulino@redhat.com This one only makes sense in the context of the qemu-io tool, so move it to qemu-io.c. Adapt coding style and register it like other commands. Signed-off-by: Kevin Wolf --- cmd.c | 29 ----------------------------- cmd.h | 2 -- qemu-io.c | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 32 deletions(-) diff --git a/cmd.c b/cmd.c index 2941ad3..8496e74 100644 --- a/cmd.c +++ b/cmd.c @@ -410,32 +410,3 @@ timestr( snprintf(ts, size, "0.%04u sec", (unsigned int) (usec * 10000)); } } - - -/* from libxcmd/quit.c */ - -static cmdinfo_t quit_cmd; - -/* ARGSUSED */ -static int -quit_f( - BlockDriverState *bs, - int argc, - char **argv) -{ - return 1; -} - -void -quit_init(void) -{ - quit_cmd.name = _("quit"); - quit_cmd.altname = _("q"); - quit_cmd.cfunc = quit_f; - quit_cmd.argmin = -1; - quit_cmd.argmax = -1; - quit_cmd.flags = CMD_FLAG_GLOBAL; - quit_cmd.oneline = _("exit the program"); - - add_command(&quit_cmd); -} diff --git a/cmd.h b/cmd.h index 89e7c6e..5b6f61b 100644 --- a/cmd.h +++ b/cmd.h @@ -42,8 +42,6 @@ typedef struct cmdinfo { extern cmdinfo_t *cmdtab; extern int ncmds; -void quit_init(void); - typedef int (*checkfunc_t)(BlockDriverState *bs, const cmdinfo_t *ci); void add_command(const cmdinfo_t *ci); diff --git a/qemu-io.c b/qemu-io.c index cfee840..83788b4 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -137,6 +137,21 @@ static int open_f(BlockDriverState *bs, int argc, char **argv) return openfile(argv[optind], flags, growable); } +static int quit_f(BlockDriverState *bs, int argc, char **argv) +{ + return 1; +} + +static const cmdinfo_t quit_cmd = { + .name = "quit", + .altname = "q", + .cfunc = quit_f, + .argmin = -1, + .argmax = -1, + .flags = CMD_FLAG_GLOBAL, + .oneline = "exit the program", +}; + static void usage(const char *name) { printf( @@ -247,7 +262,7 @@ int main(int argc, char **argv) bdrv_init(); /* initialize commands */ - quit_init(); + add_command(&quit_cmd); add_command(&open_cmd); add_command(&close_cmd); -- 1.8.1.4