From 8cec5cf35f17568009c70d37bb8b2a1f360d3422 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 11 Oct 2001 08:40:42 +0000 Subject: first step in converting the head branch to use lang_tdb.c instead of gettext for internationalisation support. There is more to do (This used to be commit ab7f67677a1ade4669e5c2750d0a38422ea616a9) --- source3/web/neg_lang.c | 107 ------------------------------------------------- 1 file changed, 107 deletions(-) (limited to 'source3/web/neg_lang.c') diff --git a/source3/web/neg_lang.c b/source3/web/neg_lang.c index 8cb41a34ec..32f52aa473 100644 --- a/source3/web/neg_lang.c +++ b/source3/web/neg_lang.c @@ -161,114 +161,7 @@ static BOOL ln_negotiate_language_help( LNNegotiator* pLn, const char* pstrLanga rassert(ln_getPreflangCount(pLn) != 0); return (ln_getPreflangCount(pLn) != 0); } -/* parse catalog file header and get encoding information.*/ -static BOOL parse_po_header(const char* pheader, pstring pencoding_name) -{ - const char *ap_i_v = "Project-Id-Version:"; - const char *acharset = "charset="; - char* penc; - int nenc; - - if(pencoding_name == NULL) return False; - if(pheader == NULL || *pheader == '\0') - { - /* error or catalog is not available. */ - pstrcpy(pencoding_name,""); - return False; - } - penc = strstr(pheader, acharset); - if(strncmp(pheader, ap_i_v, strlen(ap_i_v)) != 0 || penc == NULL) - { - /* catalog file exists, but header is not good.*/ - pstrcpy(pencoding_name, ""); - return True; - } - nenc = strcspn(penc + strlen(acharset), "\n"); - strncpy(pencoding_name, - penc + strlen(acharset), nenc); - return True; -} -/* ad-hoc mime charset -> samba encoding name converter. - character conversion is done when internal samba data, - such as paramters, open files, share names, are going to be displayed. - it is only valid for japanese encodings because samba-2.0.7 only has - these three character convertors. - so other .po file(catalog file) should be encoded with one which - samba can deal with (i.e same as DOS codepage). - display-time conversion is deleted on this version because - all catalog files are encoded with samba internal encoding (DOS codepage). - - THIS FUNCTION is ALREADY obsolated and maybe removed soon, -- monyo -*/ -#define LN_SAMBA_ENCODINGS 3 -static const char* get_samba_enc(const char* penc) -{ - int i; - static const fstring fdefault = ""; - static const fstring fmimeenc[LN_SAMBA_ENCODINGS] = - { - "EUC-JP", "Shift_JIS", "ISO-2022-JP" - }; - static const fstring fsambaenc[LN_SAMBA_ENCODINGS] = - { - "euc", "sjis", "jis" - }; - for(i = 0; i < LN_SAMBA_ENCODINGS; i++) - { - if(strcasecmp(penc, fmimeenc[i]) == 0) - return fsambaenc[i]; - } - return fdefault; -} -/* ************************************************************ - find a better language. - if the language specified by web browser matches to a language - which is supported by the swat server, this function returns it. - *********************************************************** */ -static void set_a_language(const char* planguage) -{ - /* included gettext source is affected by - these env.variables without locale settings. - */ - /* - putenv(env) will not duplicate env argument - but smbw_setenv() does this. - */ - FILE *file; - smbw_setenv("LANGUAGE", planguage); - smbw_setenv("LANG", planguage); - bindtextdomain(I18N_PACKAGE, I18N_LOCALEDIR); - textdomain(I18N_PACKAGE); -} -static int ln_set_pref_language(LNNegotiator* pLn) -{ - int j; - pstring enc_name; - - for(j = 0; j < ln_getPreflangCount(pLn); j++) - { - set_a_language(ln_getPreflang(pLn, j)); - /* then check for _("") special entry which has - a lot of information about .po file. */ - if(parse_po_header(_(""), enc_name)) - { - /* the catalog file must exist and may have - encoding information .*/ - /* - but in this version, catalog files must be - written with samba-internal encoding (i.e. - dos encoding, dos codepage) - so there is no need to convert. - //ln_init_swat_encoding(get_samba_enc(enc_name)); - ln_init_swat_encoding(enc_name); - */ - return j; - } - } - return LN_NO_AVAILABLE_LANG; - /* no available or return the default? */ -} /* ************************************************************** initialize gettext. Before this, cgi_setup() should be done. cgi_setup() calls ln_negotiate_language() if the user specifies -- cgit