[asterisk-commits] tzafrir: branch group/zapata_conf r84118 - /team/group/zapata_conf/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 28 22:15:33 CDT 2007


Author: tzafrir
Date: Fri Sep 28 22:15:32 2007
New Revision: 84118

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84118
Log:
Patch from #9503 - separate sections in zapata.conf:
Will process sections in zapata.conf for channels just like it processes 
sections in users.conf - configuration does not "flow freely" in them.

Note that this change is fully backward-compatible - the semantics of
[channels] in zapata.conf and of users.conf remains the same.

Modified:
    team/group/zapata_conf/channels/chan_zap.c

Modified: team/group/zapata_conf/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/zapata_conf/channels/chan_zap.c?view=diff&rev=84118&r1=84117&r2=84118
==============================================================================
--- team/group/zapata_conf/channels/chan_zap.c (original)
+++ team/group/zapata_conf/channels/chan_zap.c Fri Sep 28 22:15:32 2007
@@ -12805,6 +12805,7 @@
 {
 	struct ast_config *cfg, *ucfg;
 	struct ast_variable *v;
+	char *cat;
  	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 };
@@ -12904,17 +12905,40 @@
 
 	v = ast_variable_browse(cfg, "channels");
 	res = process_zap(&base_conf, v, reload, 0);
-	ast_config_destroy(cfg);
 	if (res) {
 		if (ucfg)
 			ast_config_destroy(ucfg);
+		ast_config_destroy(cfg);
 		ast_mutex_unlock(&iflock);
 		return res;
 	}
 	if (ucfg) {
-		char *cat;
+		process_zap(&base_conf, ast_variable_browse(ucfg, "general"), 1, 1);
+	}
+	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");
+			if (ucfg)
+				ast_config_destroy(ucfg);
+			ast_config_destroy(cfg);
+			ast_mutex_unlock(&iflock);
+			return -1;
+		}
+		process_zap(&conf, ast_variable_browse(cfg, cat), reload, 0);
+	}
+	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)) {
 			if (!strcasecmp(cat, "general"))
 				continue;




More information about the asterisk-commits mailing list