# Allow separate configuration sections in zapata.conf, just like # the ones in users.conf . --- trunk.orig/channels/chan_zap.c +++ trunk/channels/chan_zap.c @@ -13989,6 +13989,7 @@ static int setup_zap(int reload) struct zt_chan_conf base_conf = zt_chan_conf_default(); struct zt_chan_conf conf; struct ast_flags config_flags = { reload == 1 ? CONFIG_FLAG_FILEUNCHANGED : 0 }; + char *cat; int res; #ifdef HAVE_PRI @@ -14087,15 +14088,45 @@ static int setup_zap(int reload) v = ast_variable_browse(cfg, "channels"); res = process_zap(&base_conf, v, reload, 0); - ast_config_destroy(cfg); if (res) { ast_mutex_unlock(&iflock); + ast_config_destroy(cfg); if (ucfg) ast_config_destroy(cfg); return res; } if (ucfg) { - char *cat; + process_zap(&base_conf, ast_variable_browse(ucfg, "general"), 1, 1); + } + + /* Now get configuration from all normal sections in zapata.conf: */ + for (cat = ast_category_browse(cfg, NULL); cat ; cat = ast_category_browse(cfg, cat)) { + /* [channels] and [trunkgroups] are used. Let's also reserve + * [globals] and [general] for future use + */ + if (!strcasecmp(cat, "general") || + !strcasecmp(cat, "trunkgroups") || + !strcasecmp(cat, "globals") || + !strcasecmp(cat, "channels") + ) + continue; + if (memcpy(&conf, &base_conf, sizeof(conf)) == NULL) { + ast_log(LOG_ERROR, "Not enough memory for conf copy\n"); + ast_config_destroy(cfg); + return -1; + } + process_zap(&conf, ast_variable_browse(cfg, cat), reload, 0); + if (res) { + ast_mutex_unlock(&iflock); + ast_config_destroy(cfg); + if (ucfg) + ast_config_destroy(cfg); + return res; + } + } + ast_config_destroy(cfg); + + if (ucfg) { const char *chans; process_zap(&base_conf, ast_variable_browse(ucfg, "general"), 1, 1); for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {