diff options
author | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-02-25 22:31:51 +0000 |
---|---|---|
committer | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-02-25 22:31:51 +0000 |
commit | 701ba57042212fb040f92bd25f1ec3af40db2f43 (patch) | |
tree | 340230ce9bbc3b49326f8ff2fac3b659d1270a00 /file.c | |
parent | f9d08103cac28c6411974f5553cf163faf7ff14e (diff) |
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: http://svn.digium.com/svn/asterisk/trunk@2247 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'file.c')
-rwxr-xr-x | file.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -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); |