Bug #1087. Fix wav49 format so it can be played. Make file functions

looking for extension use f->exts instead of f->name.  Fix bug
where error message didn't print file extension. Fix comments in header file.
Everything is completely backwards compatible


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2247 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
James Golovich
2004-02-25 22:31:51 +00:00
parent 38198d8cb3
commit 462cfbe8ae
5 changed files with 34 additions and 16 deletions

24
file.c
View File

@@ -287,6 +287,22 @@ static char *build_filename(char *filename, char *ext)
}
static int exts_compare(char *exts, char *type)
{
char *stringp = NULL, *ext;
char tmp[256];
strncpy(tmp, exts, sizeof(tmp) - 1);
stringp = tmp;
while ((ext = strsep(&stringp, "|"))) {
if (!strcmp(ext, type)) {
return 1;
}
}
return 0;
}
#define ACTION_EXISTS 1
#define ACTION_DELETE 2
#define ACTION_RENAME 3
@@ -319,7 +335,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action
}
f = formats;
while(f) {
if (!fmt || !strcasecmp(f->name, fmt)) {
if (!fmt || exts_compare(f->exts, fmt)) {
char *stringp=NULL;
exts = strdup(f->exts);
/* Try each kind of extension */
@@ -376,7 +392,7 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action
chan->vstream = s;
} else {
close(ret);
ast_log(LOG_WARNING, "Unable to open fd on %s\n", filename);
ast_log(LOG_WARNING, "Unable to open fd on %s\n", fn);
}
} else
ast_log(LOG_WARNING, "Couldn't open file %s\n", fn);
@@ -748,7 +764,7 @@ struct ast_filestream *ast_readfile(char *filename, char *type, char *comment, i
}
f = formats;
while(f) {
if (!strcasecmp(f->name, type)) {
if (exts_compare(f->exts, type)) {
char *stringp=NULL;
/* XXX Implement check XXX */
ext = strdup(f->exts);
@@ -803,7 +819,7 @@ struct ast_filestream *ast_writefile(char *filename, char *type, char *comment,
f = formats;
while(f) {
if (!strcasecmp(f->name, type)) {
if (exts_compare(f->exts, type)) {
char *stringp=NULL;
/* XXX Implement check XXX */
ext = strdup(f->exts);