mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 08:11:21 +00:00
use ast_cli_complete() to largely simplify the command completion code.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@15852 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -150,29 +150,15 @@ static int handle_orig(int fd, int argc, char *argv[])
|
|||||||
|
|
||||||
static char *complete_orig(const char *line, const char *word, int pos, int state)
|
static char *complete_orig(const char *line, const char *word, int pos, int state)
|
||||||
{
|
{
|
||||||
int wordlen;
|
static char *choices[] = { "application", "extension", NULL };
|
||||||
char *app = "application";
|
char *ret;
|
||||||
char *exten = "extension";
|
|
||||||
char *ret = NULL;
|
|
||||||
|
|
||||||
if (pos != 2 || state)
|
if (pos != 2)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
STANDARD_INCREMENT_USECOUNT;
|
STANDARD_INCREMENT_USECOUNT;
|
||||||
|
|
||||||
wordlen = strlen(word);
|
ret = ast_cli_complete(word, choices, state);
|
||||||
|
|
||||||
if (ast_strlen_zero(word)) {
|
|
||||||
/* show the options in alphabetical order */
|
|
||||||
if (!state)
|
|
||||||
ret = strdup(app);
|
|
||||||
else
|
|
||||||
ret = strdup(exten);
|
|
||||||
} else if (!strncasecmp(word, app, wordlen)) {
|
|
||||||
ret = strdup(app);
|
|
||||||
} else if (!strncasecmp(word, exten, wordlen)) {
|
|
||||||
ret = strdup(exten);
|
|
||||||
}
|
|
||||||
|
|
||||||
STANDARD_DECREMENT_USECOUNT;
|
STANDARD_DECREMENT_USECOUNT;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user