diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-31 03:25:55 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-03-31 03:25:55 +0000 |
commit | 86448499e03a51f19670ff808e59817ebaad413a (patch) | |
tree | 096d165c78caab323c025706d89b9e395ca5430f /file.c | |
parent | 2192c24d248240582046dda1979aafebf028e5e6 (diff) |
Use requested extension (bug #3894)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5312 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'file.c')
-rwxr-xr-x | file.c | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -351,7 +351,7 @@ static int ast_filehelper(const char *filename, const char *filename2, const cha while(f) { if (!fmt || exts_compare(f->exts, fmt)) { char *stringp=NULL; - exts = strdup(f->exts); + exts = ast_strdupa(f->exts); /* Try each kind of extension */ stringp=exts; ext = strsep(&stringp, "|"); @@ -426,7 +426,7 @@ static int ast_filehelper(const char *filename, const char *filename2, const cha } ext = strsep(&stringp, "|"); } while(ext); - free(exts); + } f = f->next; } @@ -797,7 +797,6 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons struct ast_format *f; struct ast_filestream *fs=NULL; char *fn; - char *ext; if (ast_mutex_lock(&formatlock)) { ast_log(LOG_WARNING, "Unable to lock format list\n"); return NULL; @@ -805,12 +804,7 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons f = formats; while(f) { if (exts_compare(f->exts, type)) { - char *stringp=NULL; - /* XXX Implement check XXX */ - ext = strdup(f->exts); - stringp=ext; - ext = strsep(&stringp, "|"); - fn = build_filename(filename, ext); + fn = build_filename(filename, type); fd = open(fn, flags | myflags); if (fd >= 0) { errno = 0; @@ -829,7 +823,6 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons } else if (errno != EEXIST) ast_log(LOG_WARNING, "Unable to open file %s: %s\n", fn, strerror(errno)); free(fn); - free(ext); break; } f = f->next; @@ -846,7 +839,6 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con struct ast_format *f; struct ast_filestream *fs=NULL; char *fn,*orig_fn=NULL; - char *ext; char *buf=NULL; size_t size = 0; @@ -867,14 +859,9 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con f = formats; while(f) { if (exts_compare(f->exts, type)) { - char *stringp=NULL; - /* XXX Implement check XXX */ - ext = ast_strdupa(f->exts); - stringp=ext; - ext = strsep(&stringp, "|"); - fn = build_filename(filename, ext); + fn = build_filename(filename, type); fd = open(fn, flags | myflags, mode); - + if (option_cache_record_files && fd >= 0) { close(fd); /* @@ -903,7 +890,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con fs->flags = flags; fs->mode = mode; if (option_cache_record_files) { - fs->realfilename = build_filename(filename, ext); + fs->realfilename = build_filename(filename, type); fs->filename = strdup(fn); } else { fs->realfilename = NULL; |