]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tipc/cmdl.c
ll_map: Add function to remove link cache entry by index
[mirror_iproute2.git] / tipc / cmdl.c
index b816f7d45f3f37437a8a5da58256f276c8deaee4..f2f259cc5320730c40cb92860471ecb5a89731c8 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "cmdl.h"
 
-const struct cmd *find_cmd(const struct cmd *cmds, char *str)
+static const struct cmd *find_cmd(const struct cmd *cmds, char *str)
 {
        const struct cmd *c;
        const struct cmd *match = NULL;
@@ -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;