summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_stack.c37
-rw-r--r--main/loader.c5
-rw-r--r--res/res_agi.c1
3 files changed, 30 insertions, 13 deletions
diff --git a/apps/app_stack.c b/apps/app_stack.c
index b0f703bb6..562be8ac9 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -36,6 +36,8 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h"
#include "asterisk/agi.h"
+static int agi_loaded = 0;
+
static const char *app_gosub = "Gosub";
static const char *app_gosubif = "GosubIf";
static const char *app_return = "Return";
@@ -490,12 +492,15 @@ static int unload_module(void)
{
struct ast_context *con;
- if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
- ast_context_remove_extension2(con, "s", 1, NULL);
- ast_context_destroy(con, "app_stack"); /* leave nothing behind */
+ if (agi_loaded) {
+ ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
+
+ if ((con = ast_context_find("app_stack_gosub_virtual_context"))) {
+ ast_context_remove_extension2(con, "s", 1, NULL);
+ ast_context_destroy(con, "app_stack"); /* leave nothing behind */
+ }
}
- ast_agi_unregister(ast_module_info->self, &gosub_agi_command);
ast_unregister_application(app_return);
ast_unregister_application(app_pop);
ast_unregister_application(app_gosubif);
@@ -508,19 +513,31 @@ static int unload_module(void)
static int load_module(void)
{
struct ast_context *con;
- con = ast_context_find_or_create(NULL, NULL, "app_stack_gosub_virtual_context", "app_stack");
- if (!con) {
- ast_log(LOG_ERROR, "Virtual context 'app_stack_gosub_virtual_context' does not exist and unable to create\n");
- return AST_MODULE_LOAD_DECLINE;
+
+ if (!ast_module_check("res_agi.so")) {
+ if (ast_load_resource("res_agi.so") == AST_MODULE_LOAD_SUCCESS) {
+ agi_loaded = 1;
+ }
} else {
- ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_stack");
+ agi_loaded = 1;
+ }
+
+ if (agi_loaded) {
+ con = ast_context_find_or_create(NULL, NULL, "app_stack_gosub_virtual_context", "app_stack");
+ if (!con) {
+ ast_log(LOG_ERROR, "Virtual context 'app_stack_gosub_virtual_context' does not exist and unable to create\n");
+ return AST_MODULE_LOAD_DECLINE;
+ } else {
+ ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_stack");
+ }
+
+ ast_agi_register(ast_module_info->self, &gosub_agi_command);
}
ast_register_application(app_pop, pop_exec, pop_synopsis, pop_descrip);
ast_register_application(app_return, return_exec, return_synopsis, return_descrip);
ast_register_application(app_gosubif, gosubif_exec, gosubif_synopsis, gosubif_descrip);
ast_register_application(app_gosub, gosub_exec, gosub_synopsis, gosub_descrip);
- ast_agi_register(ast_module_info->self, &gosub_agi_command);
ast_custom_function_register(&local_function);
return 0;
diff --git a/main/loader.c b/main/loader.c
index baddec707..b5a451617 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -726,11 +726,12 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi
int ast_load_resource(const char *resource_name)
{
+ int res;
AST_LIST_LOCK(&module_list);
- load_resource(resource_name, 0);
+ res = load_resource(resource_name, 0);
AST_LIST_UNLOCK(&module_list);
- return 0;
+ return res;
}
struct load_order_entry {
diff --git a/res/res_agi.c b/res/res_agi.c
index 952c28c27..4c3c701a5 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -2722,7 +2722,6 @@ static char *handle_cli_agi_show(struct ast_cli_entry *e, int cmd, struct ast_cl
" When called with a topic as an argument, displays usage\n"
" information on the given command. If called without a\n"
" topic, it provides a list of AGI commands.\n";
- break;
case CLI_GENERATE:
return NULL;
}