astobj2_container: Use ast_cli_completion_add for container names.
Change-Id: I4f0fc09e820eb8d8da2354a177dbcf503c56ddd1
This commit is contained in:
parent
607baba9f4
commit
aa0d95c730
|
@ -935,12 +935,15 @@ void ao2_container_unregister(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(AO2_DEBUG)
|
#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 */
|
if (ast_cli_completion_add(ast_strdup(reg->name))) {
|
||||||
return (which->find_nth < ++which->count) ? (CMP_MATCH | CMP_STOP) : 0;
|
return CMP_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* defined(AO2_DEBUG) */
|
#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)
|
static char *complete_container_names(struct ast_cli_args *a)
|
||||||
{
|
{
|
||||||
struct ao2_reg_partial_key partial_key;
|
struct ao2_reg_partial_key partial_key;
|
||||||
struct ao2_reg_match which;
|
|
||||||
struct ao2_reg_container *reg;
|
|
||||||
char *name;
|
|
||||||
|
|
||||||
if (a->pos != 3) {
|
if (a->pos != 3) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -958,17 +958,10 @@ static char *complete_container_names(struct ast_cli_args *a)
|
||||||
|
|
||||||
partial_key.len = strlen(a->word);
|
partial_key.len = strlen(a->word);
|
||||||
partial_key.name = a->word;
|
partial_key.name = a->word;
|
||||||
which.find_nth = a->n;
|
ao2_callback(reg_containers, partial_key.len ? OBJ_SEARCH_PARTIAL_KEY : 0,
|
||||||
which.count = 0;
|
ao2_complete_reg_cb, &partial_key);
|
||||||
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");
|
return NULL;
|
||||||
if (reg) {
|
|
||||||
name = ast_strdup(reg->name);
|
|
||||||
ao2_t_ref(reg, -1, "Done with registered container object.");
|
|
||||||
} else {
|
|
||||||
name = NULL;
|
|
||||||
}
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
#endif /* defined(AO2_DEBUG) */
|
#endif /* defined(AO2_DEBUG) */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue