static char *handle_manager_show_event(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
- struct ao2_container *events;
+ RAII_VAR(struct ao2_container *, events, NULL, ao2_cleanup);
struct ao2_iterator it_events;
struct ast_xml_doc_item *item, *temp;
int length;
ao2_ref(item, -1);
}
ao2_iterator_destroy(&it_events);
- ao2_ref(events, -1);
return match;
}
if (!(item = ao2_find(events, a->argv[3], OBJ_KEY))) {
ast_cli(a->fd, "Could not find event '%s'\n", a->argv[3]);
- ao2_ref(events, -1);
return CLI_SUCCESS;
}
}
ao2_ref(item, -1);
- ao2_ref(events, -1);
return CLI_SUCCESS;
}
* \retval NULL failure
*\retval non-NULL successfully allocated named ACL
*/
-void *named_acl_alloc(const char *cat)
+static void *named_acl_alloc(const char *cat)
{
struct named_acl *named_acl;
* \param cat name of the ACL wanted to be found
* \retval pointer to the named ACL if available. Null if not found.
*/
-void *named_acl_find(struct ao2_container *container, const char *cat)
+static void *named_acl_find(struct ao2_container *container, const char *cat)
{
struct named_acl tmp;
ast_copy_string(tmp.name, cat, sizeof(tmp.name));
return acl;
}
-struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined) {
+struct ast_ha *ast_named_acl_find(const char *name, int *is_realtime, int *is_undefined)
+{
struct ast_ha *ha = NULL;
RAII_VAR(struct named_acl_config *, cfg, ao2_global_obj_ref(globals), ao2_cleanup);
/* \brief ACL command show <name> */
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) {
case CLI_INIT:
e->command = "acl show";
" Shows a list of named ACLs or lists all entries in a given named ACL.\n";
return NULL;
case CLI_GENERATE:
- return NULL;
+ if (!cfg) {
+ 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) {