diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-26 21:20:50 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-26 21:20:50 +0000 |
commit | 4d88cfdab51c45dd464f8d8cf893f43a287012d4 (patch) | |
tree | 7b208b24111d20e17d362d1a3bdab092a075a995 /apps/app_stack.c | |
parent | 688dbc7fa761b7ac61393a0da9049465a84ded78 (diff) |
improve handling of API calls provided by loaded modules through use of some GCC features; this makes app_stack's usage of AGI APIs even cleaner, and will allow it to work 'as expected' either with or without res_agi being loaded
reviewed at http://reviewboard.digium.com/r/62
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@159631 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_stack.c')
-rw-r--r-- | apps/app_stack.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/apps/app_stack.c b/apps/app_stack.c index cebe161af..0a911e5ec 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -38,9 +38,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/app.h" #include "asterisk/manager.h" #include "asterisk/channel.h" - -/* usage of AGI is optional, so indicate that to the header file */ -#define ASTERISK_AGI_OPTIONAL #include "asterisk/agi.h" /*** DOCUMENTATION @@ -576,9 +573,7 @@ static int unload_module(void) { struct ast_context *con; - if (ast_agi_unregister) { - ast_agi_unregister(ast_module_info->self, &gosub_agi_command); - + if (ast_agi_unregister(ast_module_info->self, &gosub_agi_command) == 1) { if ((con = ast_context_find("app_stack_gosub_virtual_context"))) { ast_context_remove_extension2(con, "s", 1, NULL, 0); ast_context_destroy(con, "app_stack"); /* leave nothing behind */ @@ -598,19 +593,13 @@ static int load_module(void) { struct ast_context *con; - /* usage of AGI is optional, so check to see if the ast_agi_register() - function is available; if so, use it. - */ - if (ast_agi_register) { - con = ast_context_find_or_create(NULL, NULL, "app_stack_gosub_virtual_context", "app_stack"); - if (!con) { + if (ast_agi_register(ast_module_info->self, &gosub_agi_command) == 1) { + if (!(con = ast_context_find_or_create(NULL, NULL, "app_stack_gosub_virtual_context", "app_stack"))) { 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_xml(app_pop, pop_exec); |