summaryrefslogtreecommitdiff
path: root/main/ccss.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/ccss.c')
-rw-r--r--main/ccss.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/main/ccss.c b/main/ccss.c
index ed0bba7f5..9cf16e34d 100644
--- a/main/ccss.c
+++ b/main/ccss.c
@@ -4547,11 +4547,9 @@ static int kill_cores(void *obj, void *arg, int flags)
return 0;
}
-static char *complete_core_id(const char *line, const char *word, int pos, int state)
+static char *complete_core_id(const char *word)
{
- int which = 0;
int wordlen = strlen(word);
- char *ret = NULL;
struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
struct cc_core_instance *core_instance;
@@ -4559,15 +4557,16 @@ static char *complete_core_id(const char *line, const char *word, int pos, int s
cc_unref(core_instance, "CLI tab completion iteration")) {
char core_id_str[20];
snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
- if (!strncmp(word, core_id_str, wordlen) && ++which > state) {
- ret = ast_strdup(core_id_str);
- cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
- break;
+ if (!strncmp(word, core_id_str, wordlen)) {
+ if (ast_cli_completion_add(ast_strdup(core_id_str))) {
+ cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
+ break;
+ }
}
}
ao2_iterator_destroy(&core_iter);
- return ret;
+ return NULL;
}
static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -4583,7 +4582,7 @@ static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
return NULL;
case CLI_GENERATE:
if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
- return complete_core_id(a->line, a->word, a->pos, a->n);
+ return complete_core_id(a->word);
}
return NULL;
}
@@ -4616,7 +4615,7 @@ static struct ast_cli_entry cc_cli[] = {
AST_CLI_DEFINE(handle_cc_kill, "Kill a CC transaction"),
};
-static void cc_shutdown(void)
+static int unload_module(void)
{
ast_devstate_prov_del("ccss");
ast_cc_agent_unregister(&generic_agent_callbacks);
@@ -4642,30 +4641,32 @@ static void cc_shutdown(void)
ao2_t_ref(generic_monitors, -1, "Unref generic_monitor container in cc_shutdown");
generic_monitors = NULL;
}
+
+ return 0;
}
-int ast_cc_init(void)
+static int load_module(void)
{
int res;
if (!(cc_core_instances = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
cc_core_instance_hash_fn, cc_core_instance_cmp_fn,
"Create core instance container"))) {
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
if (!(generic_monitors = ao2_t_container_alloc(CC_CORE_INSTANCES_BUCKETS,
generic_monitor_instance_list_hash_fn, generic_monitor_instance_list_cmp_fn,
"Create generic monitor container"))) {
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
if (!(cc_core_taskprocessor = ast_taskprocessor_get("CCSS_core", TPS_REF_DEFAULT))) {
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
if (!(cc_sched_context = ast_sched_context_create())) {
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
if (ast_sched_start_thread(cc_sched_context)) {
- return -1;
+ return AST_MODULE_LOAD_FAILURE;
}
res = ast_register_application2(ccreq_app, ccreq_exec, NULL, NULL, NULL);
res |= ast_register_application2(cccancel_app, cccancel_exec, NULL, NULL, NULL);
@@ -4681,7 +4682,12 @@ int ast_cc_init(void)
initialize_cc_devstate_map();
res |= ast_devstate_prov_add("ccss", ccss_device_state);
- ast_register_cleanup(cc_shutdown);
-
- return res;
+ return res ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS;
}
+
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER, "Call Completion Supplementary Services",
+ .support_level = AST_MODULE_SUPPORT_CORE,
+ .load = load_module,
+ .unload = unload_module,
+ .load_pri = AST_MODPRI_CORE,
+);