Merge pull request #1211 in FS/freeswitch from ~MOCHOUINARD/freeswitch:bugfix/FS-10108-patch-mod_freetdm-make-the-freetdm to master

* commit '119dd7e8e841b5294ae4b85b7cc028df40acc45e':
  FS-10108: mod_freetdm - Configurable FreeTDM Configuration file locations
This commit is contained in:
Mike Jerris 2017-04-28 20:09:39 +00:00
commit a4e624bec8
1 changed files with 31 additions and 0 deletions

View File

@ -3460,6 +3460,32 @@ static void parse_bri_pri_spans(switch_xml_t cfg, switch_xml_t spans)
ftdm_span_start(span);
}
}
static switch_status_t load_config_path(void)
{
const char *cf = "freetdm.conf";
switch_xml_t cfg, xml, settings, param;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
if ((settings = switch_xml_child(cfg, "settings"))) {
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "mod-dir")) {
ftdm_global_set_mod_directory(val);
} else if (!strcasecmp(var, "conf-dir")) {
ftdm_global_set_config_directory(val);
}
}
}
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t load_config(void)
{
@ -5600,6 +5626,11 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir);
if (load_config_path() != SWITCH_STATUS_SUCCESS) {
ftdm_global_destroy();
return SWITCH_STATUS_TERM;
}
if (ftdm_global_init() != FTDM_SUCCESS) {
ftdm_global_destroy();
ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n");