From patchwork Tue Nov 7 15:05:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 118187 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp638976edm; Tue, 7 Nov 2017 07:12:15 -0800 (PST) X-Google-Smtp-Source: ABhQp+SHSE3g6DxYLpoVzy54DtONU6u+IknP+59HKH48pereTf8if4QBoG74Kl+lO5KvKd1wLM9U X-Received: by 10.37.109.4 with SMTP id i4mr11380286ybc.368.1510067535785; Tue, 07 Nov 2017 07:12:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510067535; cv=none; d=google.com; s=arc-20160816; b=tN0VKbmalyCKNG/9Bzmanc/E06NPj8td43UDk+yh/xuGohYj3jI3xs9n+CZQ8T4d54 JDt4KCp8Yvm+PaCLUAgi/LVmSPpXIuywBrQPXVZkEa8NW7qqmGFdGgCBv/DkLgFD5tlX 2fsphrVBVFKWV1OOFehO1jZczHrMCQnoIYhi/UiegGZt7GJfDBZyy8OlIZ3HkPEUyi/G A7FtWMyb8mJSrGRgNuZZ+o77tO976DaNikBjs9uZLtfEb2BiqbeyDYzH9PkF0HXa7rMB LyGA4hRF54BWFpH4Q6hOcBOkiLilTD57efDVPhUDB/BnvRUBPmhgyHJLIEOFQVOLMOnz 8R0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SzfuxM2CFCCq3NBz+c8hfiunWZDu/VF9gUjeaknaGC4=; b=E7HRA5vdLHZ8I69n2tGFMglNJNsDDeaAgrXNYs8tC8sLbN/cSfUeZCILqKLqdjk34o pJxu/2lw+UA5X+XsBPN5dDI9cdL9wRriZhGVPIy0eDV5YZh79DkmxYNTUpR49ism3pBx YD+RAaVTdtauAFVrg8FWE+/qk50WEltu3nhYCF/cSv3uqEGMTgKFngTPuWhHQWLIs1Mh F/JrtojWiMY8i5BBV5B0jgCDAyRjjihzoFtWSx2ZxdSrSMzHriGiS9G09gDfsPfGWEhj L0zrHc2LJy19qnCsuut/JqK7mqwQjgnyuu3MnknNmvVouELd0FE8l1JnMepWGdBVz2qO aK8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SMEOf9dA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i28si321148ybj.778.2017.11.07.07.12.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 07 Nov 2017 07:12:15 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=SMEOf9dA; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5Xz-00019F-4j for patch@linaro.org; Tue, 07 Nov 2017 10:12:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC5SC-0005nD-Qs for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC5S9-0008SY-AQ for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:16 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:49140) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eC5S9-0008Rh-4Q for qemu-devel@nongnu.org; Tue, 07 Nov 2017 10:06:13 -0500 Received: by mail-wm0-x241.google.com with SMTP id p75so4402192wmg.3 for ; Tue, 07 Nov 2017 07:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SzfuxM2CFCCq3NBz+c8hfiunWZDu/VF9gUjeaknaGC4=; b=SMEOf9dAuQQDXQ9mFe9OIZstzpmaSpGG3fQDcQ4VTbwgD4v/upWloniWz7ZixIAUyZ 5Y3hS42cr0kkiT9b2VCM8djwOADP8i0Y0SxuOlST9raS/UiOscg2pbHBPkbMvbsjWDIM YrB7OqQS8nMLUJIWPxPZdDVXSood+Snx5p6VU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SzfuxM2CFCCq3NBz+c8hfiunWZDu/VF9gUjeaknaGC4=; b=WKTc9uE3kPzDzGs0/r3Y1fXdolyWCuUks33mKaCE7D+k5nIB9qOWCggSPKXwePybwW FgeqoFRI7UCF1AO9qinLj5EPmLQ1onNO5SM6+dtBSuqE+JpI4o2aAjSO2mM+mke0x9vU g+XLVOb8OCdSRluqlZ8wjbO3LJq9fhLKAgLmZ+5MDlpXwd+xM4oZ3FhPKoWZV1LFVYVg ctIOJy+YR3SPQNUKyrq4wu7x1iGUlY391bbuNP02j27pilNpX2Sc3Sq0YkgmHlE2tZw6 8SHE9SrwL9X/CF+2RC+dJ68QGjCAF+hicW15fumyVMKLy0jk1PhbUm/89xCHN2S6m8N+ EQtQ== X-Gm-Message-State: AJaThX6skQzDXNd2tFTIXLS9YZKTifdAUzkTmNZvdzLlfVp/uWQadCMq rHSa2ijZ2il7mv8Sh//dJEtfQg== X-Received: by 10.28.214.134 with SMTP id n128mr1893205wmg.59.1510067172008; Tue, 07 Nov 2017 07:06:12 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 195sm35980329wmj.3.2017.11.07.07.06.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Nov 2017 07:06:10 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 9CBF33E040E; Tue, 7 Nov 2017 15:06:09 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Tue, 7 Nov 2017 15:05:50 +0000 Message-Id: <20171107150558.22131-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107150558.22131-1-alex.bennee@linaro.org> References: <20171107150558.22131-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [RISU PATCH 02/10] risu.c: split out setting up options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Dave.Martin@arm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This is a prerequisite to properly handling architecture specific options. Signed-off-by: Alex Bennée --- risu.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) -- 2.14.2 diff --git a/risu.c b/risu.c index 47471c6..a5d155d 100644 --- a/risu.c +++ b/risu.c @@ -282,6 +282,21 @@ void usage(void) "(default 9191)\n"); } +struct option * setup_options(char **short_opts) +{ + static struct option default_longopts[] = { + {"help", no_argument, 0, '?'}, + {"master", no_argument, &ismaster, 1}, + {"host", required_argument, 0, 'h'}, + {"port", required_argument, 0, 'p'}, + {"test-fp-exc", no_argument, &test_fp_exc, 1}, + {0, 0, 0, 0} + }; + + *short_opts = "h:p:t:"; + return default_longopts; +} + int main(int argc, char **argv) { /* some handy defaults to make testing easier */ @@ -289,20 +304,14 @@ int main(int argc, char **argv) char *hostname = "localhost"; char *imgfile; char *trace_fn = NULL; + struct option *longopts; + char *shortopts; - /* TODO clean this up later */ + longopts = setup_options(&shortopts); for (;;) { - static struct option longopts[] = { - {"help", no_argument, 0, '?'}, - {"master", no_argument, &ismaster, 1}, - {"host", required_argument, 0, 'h'}, - {"port", required_argument, 0, 'p'}, - {"test-fp-exc", no_argument, &test_fp_exc, 1}, - {0, 0, 0, 0} - }; int optidx = 0; - int c = getopt_long(argc, argv, "h:p:t:", longopts, &optidx); + int c = getopt_long(argc, argv, shortopts, longopts, &optidx); if (c == -1) { break; }