[Asterisk-cvs] asterisk/res res_musiconhold.c,1.61,1.62

anthm at lists.digium.com anthm at lists.digium.com
Thu Jun 30 14:08:38 CDT 2005


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

Modified Files:
	res_musiconhold.c 
Log Message:
Apply NODIR Patch (Bug #4619)

Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- res_musiconhold.c	6 Jun 2005 22:12:19 -0000	1.61
+++ res_musiconhold.c	30 Jun 2005 18:08:27 -0000	1.62
@@ -286,20 +286,24 @@
 static int spawn_mp3(struct mohclass *class)
 {
 	int fds[2];
-	int files=0;
+	int files = 0;
 	char fns[MAX_MP3S][80];
 	char *argv[MAX_MP3S + 50];
 	char xargs[256];
 	char *argptr;
 	int argc = 0;
-	DIR *dir;
+	DIR *dir = NULL;
 	struct dirent *de;
 
 	
-	dir = opendir(class->dir);
-	if (!dir && !strstr(class->dir,"http://") && !strstr(class->dir,"HTTP://")) {
-		ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir);
-		return -1;
+	if (!strcasecmp(class->dir, "nodir")) {
+		files = 1;
+	} else {
+		dir = opendir(class->dir);
+		if (!dir && !strstr(class->dir,"http://") && !strstr(class->dir,"HTTP://")) {
+			ast_log(LOG_WARNING, "%s is not a valid directory\n", class->dir);
+			return -1;
+		}
 	}
 
 	if (!ast_test_flag(class, MOH_CUSTOM)) {
@@ -347,12 +351,12 @@
 		}
 	}
 
-	files = 0;
+
 	if (strstr(class->dir,"http://") || strstr(class->dir,"HTTP://")) {
 		strncpy(fns[files], class->dir, sizeof(fns[files]) - 1);
 		argv[argc++] = fns[files];
 		files++;
-	} else {
+	} else if (dir) {
 		while ((de = readdir(dir)) && (files < MAX_MP3S)) {
 			if ((strlen(de->d_name) > 3) && 
 			    ((ast_test_flag(class, MOH_CUSTOM) && 
@@ -366,8 +370,9 @@
 		}
 	}
 	argv[argc] = NULL;
-	closedir(dir);
-	
+	if (dir) {
+		closedir(dir);
+	}
 	if (pipe(fds)) {	
 		ast_log(LOG_WARNING, "Pipe failed\n");
 		return -1;




More information about the svn-commits mailing list