aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorChristophe Milard <christophe.milard@linaro.org>2016-04-15 11:52:26 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2016-05-23 15:07:00 +0300
commit1721f54f810e52f2f7e427e3d525b4badf9ad050 (patch)
tree72fd20ef3e84c1efacbce636948e866da2ed38d0 /example
parente6751a5c955122db99fd375714bdda232a73c4a9 (diff)
example: switch: adding helper cmd line parsing
odp_switch now calls the helper command line parsing so that helper can collect its options. Hence enabling process mode run. Signed-off-by: Christophe Milard <christophe.milard@linaro.org> Reviewed-by: Brian Brooks <brian.brooks@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'example')
-rw-r--r--example/switch/odp_switch.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/example/switch/odp_switch.c b/example/switch/odp_switch.c
index 9358c2c29..0c9b2575e 100644
--- a/example/switch/odp_switch.c
+++ b/example/switch/odp_switch.c
@@ -748,7 +748,7 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
char *token;
size_t len;
unsigned i;
- static struct option longopts[] = {
+ static const struct option longopts[] = {
{"count", required_argument, NULL, 'c'},
{"time", required_argument, NULL, 't'},
{"accuracy", required_argument, NULL, 'a'},
@@ -757,12 +757,18 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args)
{NULL, 0, NULL, 0}
};
+ static const char *shortopts = "+c:+t:+a:i:h";
+
+ /* let helper collect its own arguments (e.g. --odph_proc) */
+ odph_parse_options(argc, argv, shortopts, longopts);
+
appl_args->time = 0; /* loop forever if time to run is 0 */
appl_args->accuracy = 10; /* get and print pps stats second */
+ opterr = 0; /* do not issue errors on helper options */
+
while (1) {
- opt = getopt_long(argc, argv, "+c:+t:+a:i:h",
- longopts, &long_index);
+ opt = getopt_long(argc, argv, shortopts, longopts, &long_index);
if (opt == -1)
break; /* No more options */