aboutsummaryrefslogtreecommitdiffstats
path: root/smtpd/parser.c
diff options
context:
space:
mode:
authorGilles Chehade <gilles@poolp.org>2013-07-19 11:29:28 +0200
committerGilles Chehade <gilles@poolp.org>2013-07-19 11:29:28 +0200
commit7ccd2e068561dfcb4355f999474c89231f4b6c4d (patch)
treec5b2f297fd5f02c879fe40c79fa60451a2081521 /smtpd/parser.c
parentMerge branch 'portable' of ssh://ssh.poolp.org/git/opensmtpd into portable (diff)
parentImplement command abbreviation when there is no ambiguity. (diff)
downloadOpenSMTPD-7ccd2e068561dfcb4355f999474c89231f4b6c4d.tar.xz
OpenSMTPD-7ccd2e068561dfcb4355f999474c89231f4b6c4d.zip
Merge branch 'master' into portable
Diffstat (limited to 'smtpd/parser.c')
-rw-r--r--smtpd/parser.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/smtpd/parser.c b/smtpd/parser.c
index 0f0cd5ee..8fd280a6 100644
--- a/smtpd/parser.c
+++ b/smtpd/parser.c
@@ -176,7 +176,7 @@ int
cmd_run(int argc, char **argv)
{
struct parameter param[ARGVMAX];
- struct node *node, *tmp, *stack[ARGVMAX];
+ struct node *node, *tmp, *stack[ARGVMAX], *best;
int i, j, np;
node = root;
@@ -193,8 +193,25 @@ cmd_run(int argc, char **argv)
break;
}
}
- if (tmp == NULL)
- goto fail;
+ if (tmp == NULL) {
+ best = NULL;
+ TAILQ_FOREACH(tmp, &node->children, entry) {
+ if (tmp->type != P_TOKEN)
+ continue;
+ if (strstr(tmp->token, argv[i]) != tmp->token)
+ continue;
+ if (best)
+ goto fail;
+ best = tmp;
+ }
+ if (best == NULL)
+ goto fail;
+ stack[i] = best;
+ node = best;
+ param[np].type = node->type;
+ if (node->type != P_TOKEN)
+ np++;
+ }
}
if (node->cmd == NULL)