diff options
author | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-26 14:36:11 +0000 |
---|---|---|
committer | seanbright <seanbright@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-05-26 14:36:11 +0000 |
commit | f59511529256c3c05b7d9ee7554a539a44cba7a2 (patch) | |
tree | bfad54582b61426d2676f4f17195b3a384a9566c /main/pbx.c | |
parent | 9d7571a4414c433ce06e719aaa9fe63d363ecce4 (diff) |
Add new ast_complete_applications function so that we can use it with the
'channel originate ... application <app>' CLI command.
(And yeah, I cleaned up some whitespace in res_clioriginate.c... big whoop,
wanna fight about it!?)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@196758 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/pbx.c')
-rw-r--r-- | main/pbx.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/main/pbx.c b/main/pbx.c index 4e4b1c683..460f48207 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -5558,9 +5558,6 @@ static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct as { struct ast_app *aa; int app, no_registered_app = 1; - char *ret = NULL; - int which = 0; - int wordlen; switch (cmd) { case CLI_INIT: @@ -5575,18 +5572,7 @@ static char *handle_show_application(struct ast_cli_entry *e, int cmd, struct as * application at one time. You can type 'show application Dial Echo' and * you will see informations about these two applications ... */ - wordlen = strlen(a->word); - /* return the n-th [partial] matching entry */ - AST_RWLIST_RDLOCK(&apps); - AST_RWLIST_TRAVERSE(&apps, aa, list) { - if (!strncasecmp(a->word, aa->name, wordlen) && ++which > a->n) { - ret = ast_strdup(aa->name); - break; - } - } - AST_RWLIST_UNLOCK(&apps); - - return ret; + return ast_complete_applications(a->line, a->word, a->n); } if (a->argc < 4) { @@ -9878,3 +9864,22 @@ int ast_async_parseable_goto(struct ast_channel *chan, const char *goto_string) { return pbx_parseable_goto(chan, goto_string, 1); } + +char *ast_complete_applications(const char *line, const char *word, int state) +{ + struct ast_app *app = NULL; + int which = 0; + char *ret = NULL; + size_t wordlen = strlen(word); + + AST_RWLIST_RDLOCK(&apps); + AST_RWLIST_TRAVERSE(&apps, app, list) { + if (!strncasecmp(word, app->name, wordlen) && ++which > state) { + ret = ast_strdup(app->name); + break; + } + } + AST_RWLIST_UNLOCK(&apps); + + return ret; +} |