diff options
author | Joshua Colp <jcolp@digium.com> | 2018-03-16 19:09:48 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2018-03-16 19:09:48 -0500 |
commit | d5bfba60d2c609852da2f89677e878567d133674 (patch) | |
tree | 552fbc065cc6348f4361397809ab2c457622a829 /main | |
parent | 6df575541becf04ec7b4f32deb2092c9a1a24e0f (diff) | |
parent | aa0d95c7308bfc670f7b6593ab3d463c5b169e1c (diff) |
Merge "astobj2_container: Use ast_cli_completion_add for container names."
Diffstat (limited to 'main')
-rw-r--r-- | main/astobj2_container.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/main/astobj2_container.c b/main/astobj2_container.c index ae647d2dd..9bea58f74 100644 --- a/main/astobj2_container.c +++ b/main/astobj2_container.c @@ -935,12 +935,15 @@ void ao2_container_unregister(const char *name) } #if defined(AO2_DEBUG) -static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags) +static int ao2_complete_reg_cb(void *obj, void *arg, int flags) { - struct ao2_reg_match *which = data; + struct ao2_reg_container *reg = obj; - /* ao2_reg_sort_cb() has already filtered the search to matching keys */ - return (which->find_nth < ++which->count) ? (CMP_MATCH | CMP_STOP) : 0; + if (ast_cli_completion_add(ast_strdup(reg->name))) { + return CMP_STOP; + } + + return 0; } #endif /* defined(AO2_DEBUG) */ @@ -948,9 +951,6 @@ static int ao2_complete_reg_cb(void *obj, void *arg, void *data, int flags) static char *complete_container_names(struct ast_cli_args *a) { struct ao2_reg_partial_key partial_key; - struct ao2_reg_match which; - struct ao2_reg_container *reg; - char *name; if (a->pos != 3) { return NULL; @@ -958,17 +958,10 @@ static char *complete_container_names(struct ast_cli_args *a) partial_key.len = strlen(a->word); partial_key.name = a->word; - which.find_nth = a->n; - which.count = 0; - reg = ao2_t_callback_data(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0, - ao2_complete_reg_cb, &partial_key, &which, "Find partial registered container"); - if (reg) { - name = ast_strdup(reg->name); - ao2_t_ref(reg, -1, "Done with registered container object."); - } else { - name = NULL; - } - return name; + ao2_callback(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0, + ao2_complete_reg_cb, &partial_key); + + return NULL; } #endif /* defined(AO2_DEBUG) */ |