From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: [RFC 6/7] l2fwd: rework long options parsing Date: Mon, 19 Sep 2016 15:42:46 +0200 Message-ID: <1474292567-21912-7-git-send-email-olivier.matz@6wind.com> References: <1474292567-21912-1-git-send-email-olivier.matz@6wind.com> Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, david.hunt@intel.com To: dev@dpdk.org Return-path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 5DB24378E for ; Mon, 19 Sep 2016 15:43:00 +0200 (CEST) In-Reply-To: <1474292567-21912-1-git-send-email-olivier.matz@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: Olivier Matz --- examples/l2fwd/main.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 41ac1e1..028900b 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -376,6 +376,24 @@ l2fwd_parse_timer_period(const char *q_arg) return n; } +static const char short_options[] = + "p:" /* portmask */ + "q:" /* number of queues */ + "T:" /* timer period */ + ; + +enum { + /* long options mapped to a short option */ + + /* first long only option value must be >= 256, so that we won't + * conflict with short options */ + CMD_LINE_OPT_MIN_NUM = 256, +}; + +static const struct option lgopts[] = { + {NULL, 0, 0, 0} +}; + /* Parse the argument given in the command line of the application */ static int l2fwd_parse_args(int argc, char **argv) @@ -384,9 +402,6 @@ l2fwd_parse_args(int argc, char **argv) char **argvopt; int option_index; char *prgname = argv[0]; - static struct option lgopts[] = { - {NULL, 0, 0, 0} - }; argvopt = argv; @@ -425,11 +440,6 @@ l2fwd_parse_args(int argc, char **argv) timer_period = timer_secs; break; - /* long options */ - case 0: - l2fwd_usage(prgname); - return -1; - default: l2fwd_usage(prgname); return -1; -- 2.8.1