From patchwork Wed Nov 12 00:25:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 409784 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2F94E140139 for ; Wed, 12 Nov 2014 11:31:20 +1100 (AEDT) Received: from localhost ([::1]:51576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLqA-0001z4-Ap for incoming@patchwork.ozlabs.org; Tue, 11 Nov 2014 19:31:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlW-00024M-Bu for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoLlM-0008Um-BO for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:30 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:35204) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLlM-0008U9-7N for qemu-devel@nongnu.org; Tue, 11 Nov 2014 19:26:20 -0500 Received: by mail-oi0-f47.google.com with SMTP id a3so7900136oib.34 for ; Tue, 11 Nov 2014 16:26:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N1yhlxhlz1AsdPMLaGIapvHInGayJUCPq94stU6Ydto=; b=FFHwhnlAsaaRRy2wbRcog6R7izcleo+H+De9AtafxDQkYFnNAQA7UHfVlbI0w/LoCg P01NJrF9jPEG4ltlPugbQGNzTNXAfCm+qD7vYEi7k7wlFIukWmy0tZJSqaKXdZFGlRUs 5bvWMtnrRCkTMV2HxfOjBc6Z9RxrrwJaftZ6ipPygpEWlSDwuRDYVV2kH+qPWpO8PLwp LFQ40Jc7S3OLXkEm+PBsoV+R77orAD61lhPl5A1boGrsM2ikoj32aEtWiC3LQ+bAknMC j+PLlVYaatCo7uE8YO2e8954IlvFoHTRZxDC4RydZsX66B1KKBSv4IyVmk0bLOKqe11V 0iKw== X-Gm-Message-State: ALoCoQkDHwsp4/O/Ww/l2yIVvcKWGng8c6LLSQGzTDj6mxzHRvN+3dz86tXYCXtpIIcPO3aI+rU0 X-Received: by 10.182.68.106 with SMTP id v10mr35544402obt.32.1415751979885; Tue, 11 Nov 2014 16:26:19 -0800 (PST) Received: from gbellows-linaro.bellowshome.net (99-179-1-128.lightspeed.austtx.sbcglobal.net. [99.179.1.128]) by mx.google.com with ESMTPSA id d3sm6239765obs.18.2014.11.11.16.26.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:26:19 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org, christoffer.dall@linaro.org, alex.bennee@linaro.org Date: Tue, 11 Nov 2014 18:25:52 -0600 Message-Id: <1415751963-4081-5-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> References: <1415751963-4081-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.218.47 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH v1 04/15] android-console: Consolidate redir help text X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Consolidated the Android emulator console help text for the redir command to make the hndler functions more readable. This establishes the pattern to be used for each command added in the future. Signed-off-by: Greg Bellows --- android-console.c | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/android-console.c b/android-console.c index 2de4a0c..0be5949 100644 --- a/android-console.c +++ b/android-console.c @@ -240,11 +240,24 @@ void android_console_redir_remove(Monitor *mon, const QDict *qdict) } #endif -static const char *redir_list_help = - "list current port redirections. " - "use 'redir add' and 'redir del' to add and remove them\n"; - -static const char *redir_add_help = +enum { + CMD_REDIR, + CMD_REDIR_LIST, + CMD_REDIR_ADD, + CMD_REDIR_DEL, +}; + +static const char *redir_help[] = { + /* CMD_REDIR */ + "allows you to add, list and remove UDP and/or PORT redirection " + "from the host to the device\n" + "as an example, 'redir tcp:5000:6000' will route any packet sent " + "to the host's TCP port 5000\n" + "to TCP port 6000 of the emulated device", + /* CMD_REDIR_LIST */ + "list current port redirections. use 'redir add' and 'redir del' to add " + "and remove them", + /* CMD_REDIR_ADD */ "add a new port redirection, arguments must be:\n" "\n" " redir add ::\n" @@ -257,34 +270,31 @@ static const char *redir_add_help = "\n" "as an example, 'redir tcp:5000:6000' will allow any packets sent to\n" "the host's TCP port 5000 to be routed to TCP port 6000 of the " - "emulated device\n"; - -static const char *redir_del_help = + "emulated device", + /* CMD_REDIR_DEL */ "remove a port redirecion that was created with 'redir add', " "arguments must be:\n" " redir del :\n\n" - "see the 'help redir add' for the meaning of and \n"; + "see the 'help redir add' for the meaning of and ", +}; void android_console_redir(Monitor *mon, const QDict *qdict) { /* This only gets called for bad subcommands and help requests */ const char *helptext = qdict_get_try_str(qdict, "helptext"); + /* Default to the first entry which is the parent help message */ + int cmd = CMD_REDIR; + if (helptext) { if (strstr(helptext, "add")) { - monitor_printf(mon, "%s", redir_add_help); - return; + cmd = CMD_REDIR_ADD; } else if (strstr(helptext, "del")) { - monitor_printf(mon, "%s", redir_del_help); - return; + cmd = CMD_REDIR_DEL; } else if (strstr(helptext, "list")) { - monitor_printf(mon, "%s", redir_list_help); - return; + cmd = CMD_REDIR_LIST; } } - monitor_printf(mon, "allows you to add, list and remove and/or " - "PORT redirection from the host to the device\n" - "as an example, 'redir tcp:5000:6000' will route " - "any packet sent to the host's TCP port 5000\n" - "to TCP port 6000 of the emulated device\n"); + monitor_printf(mon, "%s\n", redir_help[cmd]); } +