summaryrefslogtreecommitdiff
path: root/main/file.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-09-03 18:42:38 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-09-03 18:42:38 +0000
commit7f745ecd731d5f0a0254fe4caf01f877e53c31fb (patch)
treec0090d9d5636ac4615994a5b7ba5f364a62e7660 /main/file.c
parent43be8f9f07f61bd2e6bad040353b987d2ea1899c (diff)
Document language prompt submission process.
This patch adds a document describing the language prompt submission process, licensing terms and other issues related to that process. In addition, it modifies the sound file searching process to support language codes with any number of suffices (not limited to just "xx" or "xx_YY"), so that prompts can be named with gender, customer/company, etc. suffices as well. (closes issue #15771) Reported by: jtodd Patches: language-criteria.txt uploaded by jtodd git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@216006 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/file.c')
-rw-r--r--main/file.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/main/file.c b/main/file.c
index c89cee97c..c66742f72 100644
--- a/main/file.c
+++ b/main/file.c
@@ -557,10 +557,7 @@ static int fileexists_test(const char *filename, const char *fmt, const char *la
/*!
* \brief helper routine to locate a file with a given format
* and language preference.
- * Try preflang, preflang with stripped '_' suffix, or NULL.
- * In the standard asterisk, language goes just before the last component.
- * In an alternative configuration, the language should be a prefix
- * to the actual filename.
+ * Try preflang, preflang with stripped '_' suffices, or NULL.
*
* The last parameter(s) point to a buffer of sufficient size,
* which on success is filled with the matching filename.
@@ -569,36 +566,35 @@ static int fileexists_core(const char *filename, const char *fmt, const char *pr
char *buf, int buflen)
{
int res = -1;
- char *lang = NULL;
+ char *lang;
if (buf == NULL) {
return -1;
}
/* We try languages in the following order:
- * preflang (may include dialect)
+ * preflang (may include dialect and style codes)
* lang (preflang without dialect - if any)
* <none>
* default (unless the same as preflang or lang without dialect)
*/
- /* Try preferred language */
- if (!ast_strlen_zero(preflang)) {
- /* try the preflang exactly as it was requested */
- if ((res = fileexists_test(filename, fmt, preflang, buf, buflen)) > 0) {
+ lang = ast_strdupa(preflang);
+
+ /* Try preferred language, including removing any style or dialect codes */
+ while (!ast_strlen_zero(lang)) {
+ char *end;
+
+ if ((res = fileexists_test(filename, fmt, lang, buf, buflen)) > 0) {
return res;
- } else {
- /* try without a dialect */
- char *postfix = NULL;
- postfix = lang = ast_strdupa(preflang);
-
- strsep(&postfix, "_");
- if (postfix) {
- if ((res = fileexists_test(filename, fmt, lang, buf, buflen)) > 0) {
- return res;
- }
- }
}
+
+ if ((end = strrchr(lang, '_')) != NULL) {
+ *end = '\0';
+ continue;
+ }
+
+ break;
}
/* Try without any language */