summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorMark Spencer <markster@digium.com>2005-01-03 00:38:01 +0000
committerMark Spencer <markster@digium.com>2005-01-03 00:38:01 +0000
commit7b968f6151b4f280693f389a5c4e8407ca2023c3 (patch)
treee4360fcffc1a00286e69956e39b1bde726459ceb /res/res_musiconhold.c
parent86dada47fc659c123cc7e77dbb43378823495e46 (diff)
Merge kpflemings moh_files fixes (bug #3224)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_musiconhold.c')
-rwxr-xr-xres/res_musiconhold.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index fa202a1cb..e5bce131a 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -684,7 +684,7 @@ static int moh_scan_files(struct mohclass *class) {
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 @@ static int moh_scan_files(struct mohclass *class) {
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 @@ static int moh_cli(int fd, int argc, char *argv[])
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 @@ int load_module(void)
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)