aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-29 16:51:51 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2006-03-29 16:51:51 +0000
commitc2d0a0894a7212c7f2ca9e7afa089f701d56285f (patch)
tree2afcf403677a6f79b22d1cb48da6cc4a9dc8585d /pbx.c
parent9aeb117db9b66c3d1f974567120998540fdd1a4d (diff)
another batch of cli simplifications.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@16129 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r--pbx.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/pbx.c b/pbx.c
index 66cbe1e5a..6ab28ba6d 100644
--- a/pbx.c
+++ b/pbx.c
@@ -3092,33 +3092,9 @@ static int handle_show_applications(int fd, int argc, char *argv[])
static char *complete_show_applications(const char *line, const char *word, int pos, int state)
{
- int wordlen = strlen(word);
+ static char* choices[] = { "like", "describing", NULL };
- if (pos == 2) {
- if (ast_strlen_zero(word)) {
- switch (state) {
- case 0:
- return strdup("like");
- case 1:
- return strdup("describing");
- default:
- return NULL;
- }
- } else if (! strncasecmp(word, "like", wordlen)) {
- if (state == 0) {
- return strdup("like");
- } else {
- return NULL;
- }
- } else if (! strncasecmp(word, "describing", wordlen)) {
- if (state == 0) {
- return strdup("describing");
- } else {
- return NULL;
- }
- }
- }
- return NULL;
+ return (pos != 2) ? NULL : ast_cli_complete(word, choices, state);
}
/*
@@ -3144,16 +3120,11 @@ static char *complete_show_dialplan_context(const char *line, const char *word,
wordlen = strlen(word);
- /* ... walk through all contexts ... */
+ /* walk through all contexts and return the n-th match */
while ( (c = ast_walk_contexts(c)) ) {
- /* ... word matches context name? yes? ... */
- if (!strncasecmp(word, ast_get_context_name(c), wordlen)) {
- /* ... for serve? ... */
- if (++which > state) {
- /* ... yes, serve this context name ... */
- ret = strdup(ast_get_context_name(c));
- break;
- }
+ if (!strncasecmp(word, ast_get_context_name(c), wordlen) && ++which > state) {
+ ret = ast_strdup(ast_get_context_name(c));
+ break;
}
}