diff options
author | Christophe Varoqui <root@xa-s05.(none)> | 2005-12-16 22:07:13 +0100 |
---|---|---|
committer | Christophe Varoqui <root@xa-s05.(none)> | 2005-12-16 22:07:13 +0100 |
commit | aecb783f20c788ff07b184036f3ed453ef0c3979 (patch) | |
tree | cf92738daf4d6dd7840a1b0b603a1ce61dcf573c /multipathd/cli.c | |
parent | d1e62b7249b8f91132979eabb997e74ccc849cc5 (diff) | |
download | multipath-tools-aecb783f20c788ff07b184036f3ed453ef0c3979.tar.gz multipath-tools-aecb783f20c788ff07b184036f3ed453ef0c3979.tar.bz2 multipath-tools-aecb783f20c788ff07b184036f3ed453ef0c3979.zip |
[multipathd] allow shortcut in CLI syntax
For example "li maps topo" is allowed and synonymous of "list maps
topology".
Diffstat (limited to 'multipathd/cli.c')
-rw-r--r-- | multipathd/cli.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/multipathd/cli.c b/multipathd/cli.c index fa24187..c723747 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -151,14 +151,26 @@ static struct key * find_key (char * str) { int i; + int len, klen; struct key * kw = NULL; - - vector_foreach_slot (keys, kw, i) - if (strlen(str) == strlen(kw->str) && - !strcmp(kw->str, str)) - return kw; - - return NULL; + struct key * foundkw = NULL; + + vector_foreach_slot (keys, kw, i) { + len = strlen(str); + klen = strlen(kw->str); + + if (strncmp(kw->str, str, len)) + continue; + else if (len == klen) + return kw; /* exact match */ + else if (len < klen) { + if (!foundkw) + foundkw = kw; /* shortcut match */ + else + return NULL; /* ambiguous word */ + } + } + return foundkw; } static struct handler * |