diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-10-25 17:50:06 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-10-25 17:50:06 +0000 |
commit | b2724a44d0ce19b6451b6c0da4ed6ea32394307c (patch) | |
tree | c163913c8f39ede741e20c64b56d3467f9ddc0cb | |
parent | 79ab512ffd931a402ca29d279d670782b2cae1e4 (diff) |
Verify includes, and give warnings if invalid (bug #429)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@1667 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-x | include/asterisk/pbx.h | 7 | ||||
-rwxr-xr-x | pbx.c | 14 | ||||
-rwxr-xr-x | pbx/pbx_config.c | 4 |
3 files changed, 25 insertions, 0 deletions
diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 23366d2eb..9beb5667a 100755 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -376,6 +376,13 @@ int ast_context_remove_include(char *context, char *include, char *registrar); */ int ast_context_remove_include2(struct ast_context *con, char *include, char *registrar); +//! Verifies includes in an ast_contect structure +/*! + * \param con context in which to verify the includes + * Returns 0 if no problems found, -1 if there were any missing context + */ +int ast_context_verify_includes(struct ast_context *con); + //! Add a switch /*! * \param context context to which to add the switch @@ -4644,3 +4644,17 @@ struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, else return ip->next; } + +int ast_context_verify_includes(struct ast_context *con) +{ + struct ast_include *inc; + int res = 0; + + for (inc = ast_walk_context_includes(con, NULL); inc; inc = ast_walk_context_includes(con, inc)) + if (!ast_context_find(inc->rname)) { + res = -1; + ast_log(LOG_WARNING, "Context '%s' tries includes non-existant context '%s'\n", + ast_get_context_name(con), inc->rname); + } + return res; +} diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 29a2039df..c09677a02 100755 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1653,6 +1653,10 @@ static int pbx_load_module(void) ast_destroy(cfg); } ast_merge_contexts_and_delete(&local_contexts,registrar); + + for (con = ast_walk_contexts(NULL); con; con = ast_walk_contexts(con)) + ast_context_verify_includes(con); + return 0; } |