diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 14:43:56 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 14:43:56 +0000 |
commit | d4c3816decb6b11de305ef9df8759d04b71b2d31 (patch) | |
tree | 1dbcb579b7a8e6a0e0d9987eebccd845ccebd579 /res/res_musiconhold.c | |
parent | 41de061a131928f4cddd6fdb18eb1b5ec33f33ba (diff) |
Add a new option for files-based music on hold to ensure that the sort order
of the files is alphabetical.
(closes issue #10855)
Reported by: jamesgolovich
Patches:
asterisk-mohsortalpha.diff.txt uploaded by jamesgolovich (license 176)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@84168 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_musiconhold.c')
-rw-r--r-- | res/res_musiconhold.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c index 80b272526..4c4f21724 100644 --- a/res/res_musiconhold.c +++ b/res/res_musiconhold.c @@ -125,6 +125,7 @@ struct moh_files_state { #define MOH_SINGLE (1 << 1) #define MOH_CUSTOM (1 << 2) #define MOH_RANDOMIZE (1 << 3) +#define MOH_SORTALPHA (1 << 4) struct mohclass { char name[MAX_MUSICCLASS]; @@ -810,6 +811,16 @@ static int moh_add_file(struct mohclass *class, const char *filepath) return 0; } +static int moh_sort_compare(const void *i1, const void *i2) +{ + char *s1, *s2; + + s1 = ((char **)i1)[0]; + s2 = ((char **)i2)[0]; + + return strcasecmp(s1, s2); +} + static int moh_scan_files(struct mohclass *class) { DIR *files_DIR; @@ -871,6 +882,8 @@ static int moh_scan_files(struct mohclass *class) { closedir(files_DIR); chdir(path); + if (ast_test_flag(class, MOH_SORTALPHA)) + qsort(&class->filearray[0], class->total_files, sizeof(char *), moh_sort_compare); return class->total_files; } @@ -1061,6 +1074,10 @@ static int load_moh_classes(int reload) class->digit = *var->value; else if (!strcasecmp(var->name, "random")) ast_set2_flag(class, ast_true(var->value), MOH_RANDOMIZE); + else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "random")) + ast_set_flag(class, MOH_RANDOMIZE); + else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) + ast_set_flag(class, MOH_SORTALPHA); else if (!strcasecmp(var->name, "format")) { class->format = ast_getformatbyname(var->value); if (!class->format) { |