summaryrefslogtreecommitdiff
path: root/res/res_musiconhold.c
diff options
context:
space:
mode:
authorAnthony Minessale II <anthmct@yahoo.com>2005-01-04 19:09:00 +0000
committerAnthony Minessale II <anthmct@yahoo.com>2005-01-04 19:09:00 +0000
commit66049c961b08af5db9cbcb240d2df28dda458556 (patch)
treef2b759e4e349929b6be4b4c8ee2349cd480bb2ad /res/res_musiconhold.c
parentedd3fe50fb5c9abb9d1fbda8b67af752c7d73852 (diff)
tweak to make music load classes more elegantly
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4661 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_musiconhold.c')
-rwxr-xr-xres/res_musiconhold.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 8cee69be5..aecfeb0d0 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -700,7 +700,6 @@ static int moh_scan_files(struct mohclass *class) {
getcwd(path, 512);
chdir(class->dir);
memset(class->filearray, 0, MAX_MOHFILES*MAX_MOHFILE_LEN);
-
while ((files_dirent = readdir(files_DIR))) {
if ((strlen(files_dirent->d_name) < 4) || ((strlen(files_dirent->d_name) + dirnamelen) >= MAX_MOHFILE_LEN))
continue;
@@ -984,11 +983,21 @@ static struct ast_cli_entry cli_moh = { { "moh", "reload"}, moh_cli, "Music On
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};
+static int init_classes(void) {
+ struct mohclass *moh;
+ load_moh_classes();
+ moh = mohclasses;
+ while(moh) {
+ if (moh->total_files)
+ moh_scan_files(moh);
+ moh = moh->next;
+ }
+ return 0;
+}
int load_module(void)
{
int res;
- load_moh_classes();
ast_install_music_functions(local_ast_moh_start, local_ast_moh_stop, local_ast_moh_cleanup);
res = ast_register_application(app0, moh0_exec, synopsis0, descrip0);
ast_register_atexit(ast_moh_destroy);
@@ -999,19 +1008,12 @@ int load_module(void)
if (!res)
res = ast_register_application(app2, moh2_exec, synopsis2, descrip2);
- return res;
+ return init_classes();
}
int reload(void)
{
- struct mohclass *moh = mohclasses;
- load_moh_classes();
- while(moh) {
- if (moh->total_files)
- moh_scan_files(moh);
- moh = moh->next;
- }
- return 0;
+ return init_classes();
}