if (pos == 3) {
ast_mutex_lock(&peerl.lock);
for (p = peerl.peers ; p ; p = p->next) {
- if (!strncasecmp(p->name, word, wordlen)) {
- if (++which > state) {
- res = ast_strdup(p->name);
- break;
- }
+ if (!strncasecmp(p->name, word, wordlen) && ++which > state) {
+ res = ast_strdup(p->name);
+ break;
}
}
ast_mutex_unlock(&peerl.lock);
static char *autoanswer_complete(const char *line, const char *word, int pos, int state)
{
- int l = strlen(word);
-
- switch(state) {
- case 0:
- if (l && !strncasecmp(word, "on", MIN(l, 2)))
- return ast_strdup("on");
- case 1:
- if (l && !strncasecmp(word, "off", MIN(l, 3)))
- return ast_strdup("off");
- default:
- return NULL;
- }
- return NULL;
+ static char *choices[] = { "on", "off", NULL };
+
+ return (pos != 1) ? NULL : ast_cli_complete(word, choices, state);
}
static char autoanswer_usage[] =
ast_mutex_lock(&provlock);
for (c = templates; c; c = c->next) {
- if (!strncasecmp(word, c->name, wordlen)) {
- if (++which > state) {
- ret = strdup(c->name);
- break;
- }
+ if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
+ ret = strdup(c->name);
+ break;
}
}
ast_mutex_unlock(&provlock);