//! 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
* 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)
/*!
static pthread_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
+static struct ast_context *local_contexts = NULL;
+
/*
* Help for commands provided by this module ...
*/
"\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
*/
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)
{
"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 ...
*/
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;
}
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")) {
}
ast_destroy(cfg);
}
+ ast_merge_contexts_and_delete(&local_contexts);
return 0;
}
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;
}