Merge kpflemings moh_files fixes (bug #3224)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4635 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
86dada47fc
commit
7b968f6151
|
@ -684,7 +684,7 @@ static int moh_scan_files(struct mohclass *class) {
|
||||||
struct dirent *files_dirent;
|
struct dirent *files_dirent;
|
||||||
char path[512];
|
char path[512];
|
||||||
char filepath[MAX_MOHFILE_LEN];
|
char filepath[MAX_MOHFILE_LEN];
|
||||||
char *scan;
|
char *ext;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int dirnamelen;
|
int dirnamelen;
|
||||||
int i;
|
int i;
|
||||||
|
@ -713,8 +713,12 @@ static int moh_scan_files(struct mohclass *class) {
|
||||||
if (!S_ISREG(statbuf.st_mode))
|
if (!S_ISREG(statbuf.st_mode))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((scan = strrchr(filepath, '.')))
|
if ((ext = strrchr(filepath, '.')))
|
||||||
*scan = '\0';
|
*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 */
|
/* 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++)
|
for (i = 0; i < class->total_files; i++)
|
||||||
|
@ -955,8 +959,29 @@ static int moh_cli(int fd, int argc, char *argv[])
|
||||||
return 0;
|
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 = { { "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)
|
int load_module(void)
|
||||||
{
|
{
|
||||||
|
@ -966,6 +991,7 @@ int load_module(void)
|
||||||
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
|
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
|
||||||
ast_register_atexit(ast_moh_destroy);
|
ast_register_atexit(ast_moh_destroy);
|
||||||
ast_cli_register(&cli_moh);
|
ast_cli_register(&cli_moh);
|
||||||
|
ast_cli_register(&cli_moh_files_show);
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_register_application(app1, moh1_exec, synopsis1, descrip1);
|
res = ast_register_application(app1, moh1_exec, synopsis1, descrip1);
|
||||||
if (!res)
|
if (!res)
|
||||||
|
|
Loading…
Reference in New Issue