From patchwork Fri May 20 16:30:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Milard X-Patchwork-Id: 68270 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp3857454qge; Fri, 20 May 2016 08:51:50 -0700 (PDT) X-Received: by 10.141.43.194 with SMTP id u185mr4181459qhe.75.1463759510121; Fri, 20 May 2016 08:51:50 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d11si18700463qkg.81.2016.05.20.08.51.49; Fri, 20 May 2016 08:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id BDD226164C; Fri, 20 May 2016 15:51:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 500B761895; Fri, 20 May 2016 15:35:11 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 7C7C861806; Fri, 20 May 2016 15:35:07 +0000 (UTC) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by lists.linaro.org (Postfix) with ESMTPS id 5169C61806 for ; Fri, 20 May 2016 15:32:22 +0000 (UTC) Received: by mail-lb0-f171.google.com with SMTP id k7so15786221lbm.0 for ; Fri, 20 May 2016 08:32:22 -0700 (PDT) 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=xL54FKbf10MmrDpJiHx8ofIRCu/pb4cexqJ7xBous6k=; b=Ozf0B6m9eT0HO0FwaZpp9vloqHotqcxhGXYNMJazlXT7HyWFXW4V08f6FeTTls1jCO J+XFxTsbU5i+OaAQJFaHgyxBdCGO6HArgDlB2p/5ObOMDjDJ9EeN5rVgprtGdWN5I+dT YBX7vA+scpV4PT2SZ/j4FTnkBd4G3QU6RngArBMfLeCNCMlqvX0CA+1RJiSpRHXuUzcE 2IFellB5wEzA2lAunvNcLuc3ASkVxYwi9r4hTTimSR3enA9L/gs+tveeFXVbqhImjyCP fex8OLS9BOyF0YSK0eTUmg98AZauJzuJCVkAMBqTH0U6om2JGJ6pCxumJqTV8Oha21om qjyg== X-Gm-Message-State: AOPr4FXXZy6zYGCSZJHe44qeDSSEpGoy1YuP+/LuOzJXDB8Hcuj2Os6b8Veq/Jo3oxyLrJmyESA= X-Received: by 10.112.55.202 with SMTP id u10mr1340780lbp.45.1463758341255; Fri, 20 May 2016 08:32:21 -0700 (PDT) Received: from erachmi-ericsson.ki.sw.ericsson.se (c-83-233-90-46.cust.bredband2.com. [83.233.90.46]) by smtp.gmail.com with ESMTPSA id tg1sm3348847lbb.7.2016.05.20.08.32.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 May 2016 08:32:20 -0700 (PDT) From: Christophe Milard To: maxim.uvarov@linaro.com, lng-odp@lists.linaro.org Date: Fri, 20 May 2016 18:30:36 +0200 Message-Id: <1463761851-37121-21-git-send-email-christophe.milard@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> References: <1463761851-37121-1-git-send-email-christophe.milard@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv9 20/35] example: generator: adding helper cmd line parsing X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" odp_generator now calls the helper command line parsing so that helper can collect its options. Hence enabling process mode run. Signed-off-by: Christophe Milard --- example/generator/odp_generator.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index dd3e023..ccae907 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -919,7 +919,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) size_t len; odp_cpumask_t cpumask, cpumask_args, cpumask_and; int i, num_workers; - static struct option longopts[] = { + static const struct option longopts[] = { {"interface", required_argument, NULL, 'I'}, {"workers", required_argument, NULL, 'w'}, {"cpumask", required_argument, NULL, 'c'}, @@ -936,14 +936,20 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) {NULL, 0, NULL, 0} }; + static const char *shortopts = "+I:a:b:s:d:p:i:m:n:t:w:c:h"; + + /* let helper collect its own arguments (e.g. --odph_proc) */ + odph_parse_options(argc, argv, shortopts, longopts); + appl_args->mode = -1; /* Invalid, must be changed by parsing */ appl_args->number = -1; appl_args->payload = 56; appl_args->timeout = -1; + opterr = 0; /* do not issue errors on helper options */ + while (1) { - opt = getopt_long(argc, argv, "+I:a:b:s:d:p:i:m:n:t:w:c:h", - longopts, &long_index); + opt = getopt_long(argc, argv, shortopts, longopts, &long_index); if (opt == -1) break; /* No more options */