cur->dead = 1;
cur = cur->next;
}
- cfg = ast_config_load("iaxprov.conf", config_flags);
+ cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags);
if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) {
/* Load as appropriate */
cat = ast_category_browse(cfg, NULL);
*/
struct ast_config *ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags);
-#define ast_config_load(filename, flags) ast_config_load2(filename, __FILE__, flags)
+#define ast_config_load(filename, flags) ast_config_load2(filename, AST_MODULE, flags)
/*! \brief Destroys a config
* \param config pointer to config data structure
void ast_udptl_init(void);
-void ast_udptl_reload(void);
+int ast_udptl_reload(void);
#if defined(__cplusplus) || defined(c_plusplus)
}
} found = { 0, 0 };
if (ast_opt_override_config) {
- cfg = ast_config_load(ast_config_AST_CONFIG_FILE, config_flags);
+ cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags);
if (!cfg)
ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE);
} else
- cfg = ast_config_load(config, config_flags);
+ cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags);
/* init with buildtime config */
ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir));
struct ast_flags cfg_flags = { 0 };
struct ast_variable *v;
- if (!(cfg = ast_config_load("cli.conf", cfg_flags)))
+ if (!(cfg = ast_config_load2("cli.conf", "" /* core, can't reload */, cfg_flags)))
return;
fd = open("/dev/null", O_RDWR);
int res=0;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((config = ast_config_load("cdr.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
ast_mutex_lock(&cdr_batch_lock);
configtmp = ast_config_new();
configtmp->max_include_level = 1;
- config = ast_config_internal_load(extconfig_conf, configtmp, flags, "", "config.c");
+ config = ast_config_internal_load(extconfig_conf, configtmp, flags, "", "extconfig");
if (!config) {
ast_config_destroy(configtmp);
return 0;
return CLI_SUCCESS;
}
+static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct cache_file_mtime *cfmtime;
+ struct seenlist {
+ AST_LIST_ENTRY(seenlist) list;
+ char filename[0];
+ } *seenlist;
+ AST_LIST_HEAD_NOLOCK(, seenlist) seenhead = AST_LIST_HEAD_NOLOCK_INIT_VALUE;
+ char *completion_value = NULL;
+ int wordlen, which = 0;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "config reload";
+ e->usage =
+ "Usage: config reload <filename.conf>\n"
+ " Reloads all modules that reference <filename.conf>\n";
+ return NULL;
+ case CLI_GENERATE:
+ if (a->pos > 2) {
+ return NULL;
+ }
+
+ wordlen = strlen(a->word);
+
+ AST_LIST_LOCK(&cfmtime_head);
+ AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
+ int seen = 0;
+ AST_LIST_TRAVERSE(&seenhead, seenlist, list) {
+ if (strcmp(seenlist->filename, cfmtime->filename) == 0) {
+ seen = 1;
+ break;
+ }
+ }
+
+ if (seen) {
+ continue;
+ }
+
+ if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) {
+ completion_value = ast_strdup(cfmtime->filename);
+ break;
+ }
+
+ /* Otherwise save that we've seen this filename */
+ if (!(seenlist = ast_malloc(sizeof(*seenlist) + strlen(cfmtime->filename) + 1))) {
+ break;
+ }
+ strcpy(seenlist->filename, cfmtime->filename);
+ AST_LIST_INSERT_HEAD(&seenhead, seenlist, list);
+ }
+ AST_LIST_UNLOCK(&cfmtime_head);
+
+ /* Remove seenlist */
+ while ((seenlist = AST_LIST_REMOVE_HEAD(&seenhead, list))) {
+ ast_free(seenlist);
+ }
+
+ return completion_value;
+ }
+
+ if (a->argc != 3) {
+ return CLI_SHOWUSAGE;
+ }
+
+ AST_LIST_LOCK(&cfmtime_head);
+ AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
+ if (!strcmp(cfmtime->filename, a->argv[2])) {
+ char *buf = alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
+ sprintf(buf, "module reload %s", cfmtime->who_asked);
+ ast_cli_command(a->fd, buf);
+ }
+ }
+ AST_LIST_UNLOCK(&cfmtime_head);
+
+ return CLI_SUCCESS;
+}
+
+static char *handle_cli_config_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ struct cache_file_mtime *cfmtime;
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "config list";
+ e->usage =
+ "Usage: config list\n"
+ " Show all modules that have loaded a configuration file\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ AST_LIST_LOCK(&cfmtime_head);
+ AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
+ ast_cli(a->fd, "%-20.20s %-50s\n", cfmtime->who_asked, cfmtime->filename);
+ }
+ AST_LIST_UNLOCK(&cfmtime_head);
+
+ return CLI_SUCCESS;
+}
+
static struct ast_cli_entry cli_config[] = {
AST_CLI_DEFINE(handle_cli_core_show_config_mappings, "Display config mappings (file names to config engines)"),
+ AST_CLI_DEFINE(handle_cli_config_reload, "Force a reload on modules using a particular configuration file"),
+ AST_CLI_DEFINE(handle_cli_config_list, "Show all files that have loaded a configuration file"),
};
int register_config_cli()
int was_enabled;
int res = -1;
- if ((config = ast_config_load("dnsmgr.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
/* ensure that no refresh cycles run while the reload is in progress */
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_config *cfg;
- cfg = ast_config_load(CONFIG_FILE_NAME, config_flags);
+ cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags);
if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) {
const char *value;
struct ast_variable *v;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((cfg = ast_config_load("enum.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load2("enum.conf", "enum", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
/* Destroy existing list */
atxferdropcall = DEFAULT_ATXFER_DROP_CALL;
atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES;
- cfg = ast_config_load("features.conf", config_flags);
+ cfg = ast_config_load2("features.conf", "features", config_flags);
if (!cfg) {
ast_log(LOG_WARNING,"Could not load features.conf\n");
return 0;
struct http_uri_redirect *redirect;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((cfg = ast_config_load("http.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
+ if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
#include "asterisk/lock.h"
#include "asterisk/features.h"
#include "asterisk/dsp.h"
+#include "asterisk/udptl.h"
#ifdef DLFCNCOMPAT
#include "asterisk/dlfcn-compat.h"
{ "logger", logger_reload },
{ "features", ast_features_reload },
{ "dsp", ast_dsp_reload},
+ { "udptl", ast_udptl_reload },
{ NULL, NULL }
};
embedded_module_list.first = NULL;
}
- if (!(cfg = ast_config_load(AST_MODULE_CONFIG, config_flags))) {
+ if (!(cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags))) {
ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG);
goto done;
}
const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((cfg = ast_config_load("logger.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load2("logger.conf", "logger", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return;
/* delete our list of log channels */
astman_send_error(s, m, "Filename not specified");
return 0;
}
- if (!(cfg = ast_config_load(fn, config_flags))) {
+ if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
astman_send_error(s, m, "Config file not found");
return 0;
}
astman_send_error(s, m, "Filename not specified");
return 0;
}
- if (!(cfg = ast_config_load(fn, config_flags))) {
+ if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
astman_send_error(s, m, "Config file not found or file has invalid syntax");
return 0;
}
return 0;
}
- if (!(cfg = ast_config_load(fn, config_flags))) {
+ if (!(cfg = ast_config_load2(fn, "manager", config_flags))) {
astman_send_error(s, m, "Config file not found");
return 0;
}
astman_send_error(s, m, "Filename not specified");
return 0;
}
- if (!(cfg = ast_config_load(sfn, config_flags))) {
+ if (!(cfg = ast_config_load2(sfn, "manager", config_flags))) {
astman_send_error(s, m, "Config file not found");
return 0;
}
/* Append placeholder event so master_eventq never runs dry */
append_event("Event: Placeholder\r\n\r\n", 0);
}
- if ((cfg = ast_config_load("manager.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load2("manager.conf", "manager", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
displayconnects = 1;
AST_RWLIST_WRLOCK(&users);
/* First, get users from users.conf */
- ucfg = ast_config_load("users.conf", config_flags);
+ ucfg = ast_config_load2("users.conf", "manager", config_flags);
if (ucfg && (ucfg != CONFIG_STATUS_FILEUNCHANGED)) {
const char *hasmanager;
int genhasmanager = ast_true(ast_variable_retrieve(ucfg, "general", "hasmanager"));
const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((cfg = ast_config_load("rtp.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load2("rtp.conf", "rtp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return 0;
rtpstart = 5000;
const char *s;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- if ((cfg = ast_config_load("udptl.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if ((cfg = ast_config_load2("udptl.conf", "udptl", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
return;
udptlstart = 4500;
ast_verb(2, "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend);
}
-void ast_udptl_reload(void)
+int ast_udptl_reload(void)
{
__ast_udptl_reload(1);
+ return 0;
}
void ast_udptl_init(void)