mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 11:58:40 +00:00
Merged revisions 231688 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ................ r231688 | mnicholson | 2009-11-30 15:31:55 -0600 (Mon, 30 Nov 2009) | 15 lines Merged revisions 231614 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r231614 | mnicholson | 2009-11-30 15:11:44 -0600 (Mon, 30 Nov 2009) | 8 lines Remove duplicate entries from voicemail format lists. This prevents app_voicemail from entering an infinite loop when the same format is specified twice in the format list. (closes issue #15625) Reported by: Shagg63 Tested by: mnicholson Review: https://reviewboard.asterisk.org/r/429/ ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@231690 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
60
main/file.c
60
main/file.c
@@ -1351,6 +1351,66 @@ int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *
|
||||
return res;
|
||||
}
|
||||
|
||||
char *ast_format_str_reduce(char *fmts)
|
||||
{
|
||||
struct ast_format *f;
|
||||
struct ast_format *fmts_ptr[AST_MAX_FORMATS];
|
||||
char *fmts_str[AST_MAX_FORMATS];
|
||||
char *stringp, *type;
|
||||
char *orig = fmts;
|
||||
int i, j, x, found;
|
||||
int len = strlen(fmts) + 1;
|
||||
|
||||
if (AST_RWLIST_RDLOCK(&formats)) {
|
||||
ast_log(LOG_WARNING, "Unable to lock format list\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stringp = ast_strdupa(fmts);
|
||||
|
||||
for (x = 0; (type = strsep(&stringp, "|")) && x < AST_MAX_FORMATS; x++) {
|
||||
AST_RWLIST_TRAVERSE(&formats, f, list) {
|
||||
if (exts_compare(f->exts, type)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fmts_str[x] = type;
|
||||
if (found) {
|
||||
fmts_ptr[x] = f;
|
||||
} else {
|
||||
fmts_ptr[x] = NULL;
|
||||
}
|
||||
}
|
||||
AST_RWLIST_UNLOCK(&formats);
|
||||
|
||||
for (i = 0; i < x; i++) {
|
||||
/* special handling for the first entry */
|
||||
if (i == 0) {
|
||||
fmts += snprintf(fmts, len, "%s", fmts_str[i]);
|
||||
len -= (fmts - orig);
|
||||
continue;
|
||||
}
|
||||
|
||||
found = 0;
|
||||
for (j = 0; j < i; j++) {
|
||||
/* this is a duplicate */
|
||||
if (fmts_ptr[j] == fmts_ptr[i]) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
fmts += snprintf(fmts, len, "|%s", fmts_str[i]);
|
||||
len -= (fmts - orig);
|
||||
}
|
||||
}
|
||||
|
||||
return orig;
|
||||
}
|
||||
|
||||
static char *handle_cli_core_show_file_formats(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||
{
|
||||
#define FORMAT "%-10s %-10s %-20s\n"
|
||||
|
||||
Reference in New Issue
Block a user