diff options
-rwxr-xr-x | include/asterisk/pbx.h | 9 | ||||
-rwxr-xr-x | pbx/pbx_config.c | 26 | ||||
-rwxr-xr-x | res/res_parking.c | 2 |
3 files changed, 34 insertions, 3 deletions
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 1a1ab65f5..e1d7f96e2 100755 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -118,6 +118,7 @@ int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data, int newstac //! Register a new context /*! + * \param extcontexts pointer to the ast_context structure pointer * \param name name of the new context * \param registrar registrar of the context * This will first search for a context with your name. If it exists already, it will not @@ -125,7 +126,13 @@ int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data, int newstac * and registrar. * It returns NULL on failure, and an ast_context structure on success */ -struct ast_context *ast_context_create(char *name, char *registrar); +struct ast_context *ast_context_create(struct ast_context **extcontexts, char *name, char *registrar); + +//! Merge the temporary contexts into a global contexts list and delete from the global list the ones that are being added +/*! + * \param extcontexts pointer to the ast_context structure pointer + */ +void ast_merge_contexts_and_delete(struct ast_context **extcontexts); //! Destroy a context (matches the specified context (or ANY context if NULL) /*! diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 45953c6f5..0b15e5694 100755 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -44,6 +44,8 @@ static int write_protect_config = 1; static pthread_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER; +static struct ast_context *local_contexts = NULL; + /* * Help for commands provided by this module ... */ @@ -89,6 +91,12 @@ static char context_remove_ignorepat_help[] = "\n" "Example: remove ignorepat _3XX from local\n"; +static char reload_extensions_help[] = +"Usage: reload extensions.conf without reloading any other modules\n" +" This command does not delete global variables\n" +"\n" +"Example: reload extensions\n"; + /* * Implementation of functions provided by this module */ @@ -1337,6 +1345,15 @@ static int handle_context_remove_ignorepat(int fd, int argc, char *argv[]) return RESULT_SUCCESS; } +static int pbx_load_module(void); + +static int handle_reload_extensions(int fd, int argc, char *argv[]) +{ + if (argc!=2) return RESULT_SHOWUSAGE; + pbx_load_module(); + return RESULT_SUCCESS; +} + static char *complete_context_remove_ignorepat(char *line, char *word, int pos, int state) { @@ -1492,6 +1509,10 @@ static struct ast_cli_entry context_remove_ignorepat_cli = "Remove ignore pattern from context", context_remove_ignorepat_help, complete_context_remove_ignorepat }; +static struct ast_cli_entry reload_extensions_cli = + { { "extensions", "reload", NULL}, handle_reload_extensions, + "Reload extensions and *only* extensions", reload_extensions_help }; + /* * Standard module functions ... */ @@ -1505,6 +1526,7 @@ int unload_module(void) ast_cli_unregister(&context_remove_extension_cli); ast_cli_unregister(&context_remove_ignorepat_cli); ast_cli_unregister(&context_add_ignorepat_cli); + ast_cli_unregister(&reload_extensions_cli); ast_context_destroy(NULL, registrar); return 0; } @@ -1536,7 +1558,7 @@ static int pbx_load_module(void) cxt = ast_category_browse(cfg, cxt); continue; } - if ((con=ast_context_create(cxt, registrar))) { + if ((con=ast_context_create(&local_contexts,cxt, registrar))) { v = ast_variable_browse(cfg, cxt); while(v) { if (!strcasecmp(v->name, "exten")) { @@ -1619,6 +1641,7 @@ static int pbx_load_module(void) } ast_destroy(cfg); } + ast_merge_contexts_and_delete(&local_contexts); return 0; } @@ -1634,6 +1657,7 @@ int load_module(void) ast_cli_register(&context_add_extension_cli); ast_cli_register(&context_add_ignorepat_cli); ast_cli_register(&context_remove_ignorepat_cli); + ast_cli_register(&reload_extensions_cli); return 0; } diff --git a/res/res_parking.c b/res/res_parking.c index 781d1d859..13bdbaf6b 100755 --- a/res/res_parking.c +++ b/res/res_parking.c @@ -633,7 +633,7 @@ int load_module(void) } con = ast_context_find(parking_con); if (!con) { - con = ast_context_create(parking_con, registrar); + con = ast_context_create(NULL,parking_con, registrar); if (!con) { ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con); return -1; |