aboutsummaryrefslogtreecommitdiffstats
path: root/tipc/cmdl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tipc/cmdl.c')
-rw-r--r--tipc/cmdl.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/tipc/cmdl.c b/tipc/cmdl.c
index b816f7d4..4a2f4fd9 100644
--- a/tipc/cmdl.c
+++ b/tipc/cmdl.c
@@ -62,6 +62,11 @@ struct opt *get_opt(struct opt *opts, char *key)
return NULL;
}
+bool has_opt(struct opt *opts, char *key)
+{
+ return get_opt(opts, key) ? true : false;
+}
+
char *shift_cmdl(struct cmdl *cmdl)
{
int next;
@@ -80,7 +85,7 @@ int parse_opts(struct opt *opts, struct cmdl *cmdl)
int i;
int cnt = 0;
- for (i = cmdl->optind; i < cmdl->argc; i += 2) {
+ for (i = cmdl->optind; i < cmdl->argc; i++) {
struct opt *o;
o = find_opt(opts, cmdl->argv[i]);
@@ -89,9 +94,13 @@ int parse_opts(struct opt *opts, struct cmdl *cmdl)
cmdl->argv[i]);
return -EINVAL;
}
+ if (o->flag & OPT_KEYVAL) {
+ cmdl->optind++;
+ i++;
+ }
cnt++;
- o->val = cmdl->argv[i + 1];
- cmdl->optind += 2;
+ o->val = cmdl->argv[i];
+ cmdl->optind++;
}
return cnt;