[Asterisk-cvs] asterisk config.c,1.35,1.36

markster at lists.digium.com markster at lists.digium.com
Sat Dec 11 00:19:09 CST 2004


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv20096

Modified Files:
	config.c 
Log Message:
Add support for globbing (bug #2825)


Index: config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/config.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- config.c	5 Dec 2004 07:29:09 -0000	1.35
+++ config.c	11 Dec 2004 05:16:30 -0000	1.36
@@ -17,6 +17,10 @@
 #include <string.h>
 #include <errno.h>
 #include <time.h>
+#define AST_INCLUDE_GLOB 1
+#ifdef AST_INCLUDE_GLOB
+# include <glob.h>
+#endif
 #include <asterisk/config.h>
 #include <asterisk/config_pvt.h>
 #include <asterisk/cli.h>
@@ -299,7 +303,8 @@
 						if(arg && cur) {
 							ast_log(LOG_WARNING, "Including files with explicit config engine no longer permitted.  Please use extconfig.conf to specify all mappings\n");
 						} else {
-							__ast_load(cur, tmp, _tmpc, _last, includelevel + 1);
+							if (!__ast_load(cur, tmp, _tmpc, _last, includelevel + 1))
+								return -1;
 						}
 					} else
 						ast_log(LOG_WARNING, "Maximum Include level (%d) exceeded\n", includelevel);
@@ -503,6 +508,24 @@
 	} else {
 		snprintf(fn, sizeof(fn), "%s/%s", (char *)ast_config_AST_CONFIG_DIR, configfile);
 	}
+#ifdef AST_INCLUDE_GLOB
+	{
+		int glob_ret;
+		glob_t globbuf;
+		globbuf.gl_offs = 0;	/* initialize it to silence gcc */
+		glob_ret = glob(fn, GLOB_NOMATCH|GLOB_BRACE, NULL, &globbuf);
+		if (glob_ret == GLOB_NOSPACE)
+			ast_log(LOG_WARNING,
+				"Glob Expansion of pattern '%s' failed: Not enough memory\n", fn);
+		else if (glob_ret  == GLOB_ABORTED)
+			ast_log(LOG_WARNING,
+				"Glob Expansion of pattern '%s' failed: Read error\n", fn);
+		else  {
+			/* loop over expanded files */
+			int i;
+			for (i=0; i<globbuf.gl_pathc; i++) {
+				strncpy(fn, globbuf.gl_pathv[i], sizeof(fn)-1);
+#endif
 	if ((option_verbose > 1) && !option_debug) {
 		ast_verbose(  VERBOSE_PREFIX_2 "Parsing '%s': ", fn);
 		fflush(stdout);
@@ -569,7 +592,7 @@
 								new_buf = comment_p + 1;
 						}
 					}
-					if (process_buf && cfg_process(tmp, _tmpc, _last, process_buf, lineno, configfile, includelevel)) {
+					if (process_buf && cfg_process(tmp, _tmpc, _last, process_buf, lineno, fn, includelevel)) {
 						tmp = NULL;
 						break;
 					}
@@ -588,6 +611,15 @@
 	if (comment) {
 		ast_log(LOG_WARNING,"Unterminated comment detected beginning on line %d\n", nest[comment]);
 	}
+#ifdef AST_INCLUDE_GLOB
+					if (!tmp)
+						break;
+				}
+				globfree(&globbuf);
+			}
+		}
+#endif
+
 	return tmp;
 }
 




More information about the svn-commits mailing list