the next step in the intl changeover. This should get us compiling agian,
[kai/samba.git] / source3 / web / neg_lang.c
1 /*
2    Unix SMB/Netbios implementation.
3    Version 3.0
4    SWAT language handling
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20    Created by Ryo Kawahara <rkawa@lbe.co.jp> 
21 */
22
23 #include "includes.h"
24
25 /*
26   during a file download we first check to see if there is a language
27   specific file available. If there is then use that, otherwise 
28   just open the specified file
29 */
30 int web_open(const char *fname, int flags, mode_t mode)
31 {
32         char *p = NULL;
33         char *lang = lang_tdb_current();
34         int fd;
35         if (lang) {
36                 asprintf(&p, "lang/%s/%s", lang, fname);
37                 if (p) {
38                         fd = sys_open(p, flags, mode);
39                         free(p);
40                         if (fd != -1) {
41                                 return fd;
42                         }
43                 }
44         }
45
46         /* fall through to default name */
47         return sys_open(fname, flags, mode);
48 }
49
50
51 /*
52   choose from a list of languages. The list can be comma or space
53   separated
54   Keep choosing until we get a hit 
55 */
56 void web_set_lang(const char *lang_list)
57 {
58         fstring lang;
59         char *p = (char *)lang_list;
60         
61         while (next_token(&p, lang, ", \t\r\n", sizeof(lang))) {
62                 if (lang_tdb_init(lang)) return;
63         }
64         
65         /* it's not an error to not initialise - we just fall back to 
66            the default */
67 }