[Asterisk-code-review] astobj2 container: Use ast cli completion add for container ... (asterisk[master])
Corey Farrell
asteriskteam at digium.com
Thu Mar 15 07:31:08 CDT 2018
Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8533
Change subject: astobj2_container: Use ast_cli_completion_add for container names.
......................................................................
astobj2_container: Use ast_cli_completion_add for container names.
Change-Id: I4f0fc09e820eb8d8da2354a177dbcf503c56ddd1
---
M main/astobj2_container.c
1 file changed, 11 insertions(+), 18 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/33/8533/1
diff --git a/main/astobj2_container.c b/main/astobj2_container.c
index ae647d2..9bea58f 100644
--- a/main/astobj2_container.c
+++ b/main/astobj2_container.c
@@ -935,12 +935,15 @@
}
#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 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 @@
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) */
--
To view, visit https://gerrit.asterisk.org/8533
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f0fc09e820eb8d8da2354a177dbcf503c56ddd1
Gerrit-Change-Number: 8533
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180315/22cc2950/attachment.html>
More information about the asterisk-code-review
mailing list