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: 40625 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E32CB205DF for ; Wed, 12 Nov 2014 00:31:43 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id n15sf5918389lbi.6 for ; Tue, 11 Nov 2014 16:31:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=N1yhlxhlz1AsdPMLaGIapvHInGayJUCPq94stU6Ydto=; b=joH0Na4y0RCtOvTYo8zqTzCkNfmql8liFISrnhrhIqBOwqddR8MTgvJsedZPnseOVV g7JWwj1/TxyQBLaCl5cBJyFExHEsD3fG3ZX3cWLeiCKJlmNInyquSOQQp8eMNeb2+mX2 UMi0G1vT0T9lbbODqTCJENtCMMHTdcxzehd8cLM+nscTIKZmVlh4hQc7/Mmp7VFi+MNS /rzELm95mpPb5vp1P+oMsisrzNsdQY8k9r9OwafXJACfuAqaCR2C9djw4jnpPkqAQ1XL uIcGIhNstf4Q1a9vA6fxfy9Gny/56yjmMK8n4v78qtMOblcQQDk0DP2BS4yVYzf9/o94 C4QA== X-Gm-Message-State: ALoCoQl0ijzWRR6pcEb4pM3zB4nOfY6JswwxX25vjRF06fxDt02wiIxf/ML34JJUrA4jL/G2THFJ X-Received: by 10.112.162.6 with SMTP id xw6mr7032191lbb.4.1415752302748; Tue, 11 Nov 2014 16:31:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.11.163 with SMTP id ej3ls612276lad.95.gmail; Tue, 11 Nov 2014 16:31:41 -0800 (PST) X-Received: by 10.112.171.225 with SMTP id ax1mr38995580lbc.40.1415752301871; Tue, 11 Nov 2014 16:31:41 -0800 (PST) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id ro8si33123148lbb.75.2014.11.11.16.31.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:31:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by mail-lb0-f173.google.com with SMTP id n15so8490071lbi.4 for ; Tue, 11 Nov 2014 16:31:41 -0800 (PST) X-Received: by 10.152.120.73 with SMTP id la9mr39164794lab.23.1415752301714; Tue, 11 Nov 2014 16:31:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp347426lbc; Tue, 11 Nov 2014 16:31:40 -0800 (PST) X-Received: by 10.224.123.132 with SMTP id p4mr56089825qar.3.1415752300232; Tue, 11 Nov 2014 16:31:40 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y20si39208865qay.99.2014.11.11.16.31.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 16:31:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:51576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoLqU-0001z4-M3 for patch@linaro.org; Tue, 11 Nov 2014 19:31:38 -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-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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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]); } +