[Asterisk-cvs] asterisk/res res_musiconhold.c,1.43,1.44

markster at lists.digium.com markster at lists.digium.com
Sun Jan 2 18:32:45 CST 2005


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

Modified Files:
	res_musiconhold.c 
Log Message:
Merge kpflemings moh_files fixes (bug #3224)


Index: res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- res_musiconhold.c	26 Dec 2004 00:33:17 -0000	1.43
+++ res_musiconhold.c	3 Jan 2005 00:38:01 -0000	1.44
@@ -684,7 +684,7 @@
 	struct dirent *files_dirent;
 	char path[512];
 	char filepath[MAX_MOHFILE_LEN];
-	char *scan;
+	char *ext;
 	struct stat statbuf;
 	int dirnamelen;
 	int i;
@@ -713,8 +713,12 @@
 		if (!S_ISREG(statbuf.st_mode))
 			continue;
 
-		if ((scan = strrchr(filepath, '.')))
-			*scan = '\0';
+		if ((ext = strrchr(filepath, '.')))
+			*ext = '\0';
+
+		/* check to see if this file's format can be opened */
+		if (ast_fileexists(filepath, ext, NULL) == -1)
+			continue;
 
 		/* if the file is present in multiple formats, ensure we only put it into the list once */
 		for (i = 0; i < class->total_files; i++)
@@ -955,8 +959,29 @@
 	return 0;
 }
 
+static int cli_files_show(int fd, int argc, char *argv[])
+{
+	int i;
+	struct mohclass *class;
+
+	ast_mutex_lock(&moh_lock);
+	for (class = mohclasses; class; class = class->next) {
+		if (!class->total_files)
+			continue;
+
+		ast_cli(fd, "Class: %s\n", class->class);
+		for (i = 0; i < class->total_files; i++)
+			ast_cli(fd, "\tFile: %s\n", class->filearray[i]);
+	}
+	ast_mutex_unlock(&moh_lock);
+
+	return 0;
+}
+
 static struct ast_cli_entry  cli_moh = { { "moh", "reload"}, moh_cli, "Music On Hold", "Music On Hold", NULL};
 
+static struct ast_cli_entry  cli_moh_files_show = { { "moh", "files", "show"}, cli_files_show, "List MOH file-based classes", "Lists all loaded file-based MOH classes and their files", NULL};
+
 
 int load_module(void)
 {
@@ -966,6 +991,7 @@
 	res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
 	ast_register_atexit(ast_moh_destroy);
 	ast_cli_register(&cli_moh);
+	ast_cli_register(&cli_moh_files_show);
 	if (!res)
 		res = ast_register_application(app1, moh1_exec, synopsis1, descrip1);
 	if (!res)




More information about the svn-commits mailing list