mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
Add CLI tab completion to 'acl show'.
The 'acl show' CLI command allows you to show the details about a specific named ACL in acl.conf. This patch adds tab completion to the command. Review: https://reviewboard.asterisk.org/r/2230/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377329 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -503,6 +503,13 @@ static void cli_display_named_acl_list(int fd)
|
|||||||
/* \brief ACL command show <name> */
|
/* \brief ACL command show <name> */
|
||||||
static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
{
|
{
|
||||||
|
RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
|
||||||
|
int length;
|
||||||
|
int which;
|
||||||
|
struct ao2_iterator i;
|
||||||
|
struct named_acl *named_acl;
|
||||||
|
char *match = NULL;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CLI_INIT:
|
case CLI_INIT:
|
||||||
e->command = "acl show";
|
e->command = "acl show";
|
||||||
@@ -511,8 +518,24 @@ static char *handle_show_named_acl_cmd(struct ast_cli_entry *e, int cmd, struct
|
|||||||
" Shows a list of named ACLs or lists all entries in a given named ACL.\n";
|
" Shows a list of named ACLs or lists all entries in a given named ACL.\n";
|
||||||
return NULL;
|
return NULL;
|
||||||
case CLI_GENERATE:
|
case CLI_GENERATE:
|
||||||
|
if (!cfg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
length = strlen(a->word);
|
||||||
|
which = 0;
|
||||||
|
i = ao2_iterator_init(cfg->named_acl_list, 0);
|
||||||
|
while ((named_acl = ao2_iterator_next(&i))) {
|
||||||
|
if (!strncasecmp(a->word, named_acl->name, length) && ++which > a->n) {
|
||||||
|
match = ast_strdup(named_acl->name);
|
||||||
|
ao2_ref(named_acl, -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ao2_ref(named_acl, -1);
|
||||||
|
}
|
||||||
|
ao2_iterator_destroy(&i);
|
||||||
|
return match;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (a->argc == 2) {
|
if (a->argc == 2) {
|
||||||
cli_display_named_acl_list(a->fd);
|
cli_display_named_acl_list(a->fd);
|
||||||
|
Reference in New Issue
Block a user