mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-20 00:30:20 +00:00
Version 0.1.3 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@202 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
49
file.c
49
file.c
@@ -324,9 +324,27 @@ static int ast_filehelper(char *filename, char *filename2, char *fmt, int action
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_fileexists(char *filename, char *fmt)
|
int ast_fileexists(char *filename, char *fmt, char *preflang)
|
||||||
{
|
{
|
||||||
return ast_filehelper(filename, NULL, fmt, ACTION_EXISTS);
|
char filename2[256];
|
||||||
|
char lang2[MAX_LANGUAGE];
|
||||||
|
int res = -1;
|
||||||
|
if (preflang && strlen(preflang)) {
|
||||||
|
snprintf(filename2, sizeof(filename2), "%s-%s", filename, preflang);
|
||||||
|
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
|
||||||
|
if (res < 1) {
|
||||||
|
strncpy(lang2, preflang, sizeof(lang2));
|
||||||
|
strtok(lang2, "_");
|
||||||
|
if (strcmp(lang2, preflang)) {
|
||||||
|
snprintf(filename2, sizeof(filename2), "%s-%s", filename, lang2);
|
||||||
|
res = ast_filehelper(filename2, NULL, fmt, ACTION_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res < 1) {
|
||||||
|
res = ast_filehelper(filename, NULL, fmt, ACTION_EXISTS);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_filedelete(char *filename, char *fmt)
|
int ast_filedelete(char *filename, char *fmt)
|
||||||
@@ -339,7 +357,7 @@ int ast_filerename(char *filename, char *filename2, char *fmt)
|
|||||||
return ast_filehelper(filename, filename2, fmt, ACTION_RENAME);
|
return ast_filehelper(filename, filename2, fmt, ACTION_RENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_streamfile(struct ast_channel *chan, char *filename)
|
int ast_streamfile(struct ast_channel *chan, char *filename, char *preflang)
|
||||||
{
|
{
|
||||||
/* This is a fairly complex routine. Essentially we should do
|
/* This is a fairly complex routine. Essentially we should do
|
||||||
the following:
|
the following:
|
||||||
@@ -355,9 +373,23 @@ int ast_streamfile(struct ast_channel *chan, char *filename)
|
|||||||
*/
|
*/
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
struct ast_channel *trans;
|
struct ast_channel *trans;
|
||||||
int fmts;
|
int fmts = -1;
|
||||||
|
char filename2[256];
|
||||||
|
char lang2[MAX_LANGUAGE];
|
||||||
ast_stopstream(chan);
|
ast_stopstream(chan);
|
||||||
fmts = ast_fileexists(filename, NULL);
|
if (preflang && strlen(preflang)) {
|
||||||
|
snprintf(filename2, sizeof(filename2), "%s-%s", filename, preflang);
|
||||||
|
fmts = ast_fileexists(filename2, NULL, NULL);
|
||||||
|
if (fmts < 1) {
|
||||||
|
strncpy(lang2, preflang, sizeof(lang2));
|
||||||
|
snprintf(filename2, sizeof(filename2), "%s-%s", filename, lang2);
|
||||||
|
fmts = ast_fileexists(filename2, NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fmts < 1) {
|
||||||
|
strncpy(filename2, filename, sizeof(filename2));
|
||||||
|
fmts = ast_fileexists(filename2, NULL, NULL);
|
||||||
|
}
|
||||||
if (fmts < 1) {
|
if (fmts < 1) {
|
||||||
ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
|
ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -379,10 +411,11 @@ int ast_streamfile(struct ast_channel *chan, char *filename)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fd = ast_filehelper(filename, (char *)trans, NULL, ACTION_OPEN);
|
fd = ast_filehelper(filename2, (char *)trans, NULL, ACTION_OPEN);
|
||||||
if (fd >= 0) {
|
if (fd >= 0) {
|
||||||
#if 0
|
#if 1
|
||||||
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s'\n", filename);
|
if (option_verbose > 2)
|
||||||
|
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s'\n", filename2);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user