[asterisk-commits] murf: branch murf/bug8684-trunk r81263 - /team/murf/bug8684-trunk/main/config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 28 14:09:32 CDT 2007


Author: murf
Date: Tue Aug 28 14:09:32 2007
New Revision: 81263

URL: http://svn.digium.com/view/asterisk?view=rev&rev=81263
Log:
oops; make sure #execs get output too, and even if the include/exec is after the last statements.

Modified:
    team/murf/bug8684-trunk/main/config.c

Modified: team/murf/bug8684-trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug8684-trunk/main/config.c?view=diff&rev=81263&r1=81262&r2=81263
==============================================================================
--- team/murf/bug8684-trunk/main/config.c (original)
+++ team/murf/bug8684-trunk/main/config.c Tue Aug 28 14:09:32 2007
@@ -1276,7 +1276,10 @@
 			for (incl=cfg->includes; incl; incl = incl->next) {
 				if (strcmp(incl->include_location_file, cat->file) == 0){
 					if (cat->lineno > incl->include_location_lineno && !incl->output) {
-						fprintf(f,"#include \"%s\"\n", incl->included_file);
+						if (incl->exec)
+							fprintf(f,"#exec \"%s\"\n", incl->exec_file);
+						else
+							fprintf(f,"#include \"%s\"\n", incl->included_file);
 						incl->output = 1;
 					}
 				}
@@ -1320,7 +1323,10 @@
 				for (incl=cfg->includes; incl; incl = incl->next) {
 					if (strcmp(incl->include_location_file, var->file) == 0){
 						if (var->lineno > incl->include_location_lineno && !incl->output) {
-							fprintf(f,"#include \"%s\"\n", incl->included_file);
+							if (incl->exec)
+								fprintf(f,"#exec \"%s\"\n", incl->exec_file);
+							else
+								fprintf(f,"#include \"%s\"\n", incl->included_file);
 							incl->output = 1;
 						}
 					}
@@ -1353,6 +1359,39 @@
 		ast_verb(2, "Unable to write (%s)", strerror(errno));
 		return -1;
 	}
+
+	/* Now, for files with trailing #include/#exec statements,
+	   we have to make sure every entry is output */
+
+	for (incl=cfg->includes; incl; incl = incl->next) {
+		if (!incl->output) {
+			/* open the respective file */
+			if (!incl->include_location_file || incl->include_location_file[0] == 0) {
+				if (configfile[0] == '/')
+					ast_copy_string(fn, configfile, sizeof(fn));
+				else
+					snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
+			} else if (incl->include_location_file[0] == '/') 
+				ast_copy_string(fn, incl->include_location_file, sizeof(fn));
+			else
+				snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, incl->include_location_file);
+			f = fopen(fn, "a");
+			if (!f)
+			{
+				ast_debug(1, "Unable to open for writing: %s\n", fn);
+				ast_verb(2, "Unable to write %s (%s)", fn, strerror(errno));
+				return -1;
+			}
+			
+			/* output the respective include */
+			if (incl->exec)
+				fprintf(f,"#exec \"%s\"\n", incl->exec_file);
+			else
+				fprintf(f,"#include \"%s\"\n", incl->included_file);
+			incl->output = 1;
+		}
+	}
+				
 	fclose(f);
 	return 0;
 }




More information about the asterisk-commits mailing list