1*16dce513Schristos /* Copyright (C) 1996-1999, 2000-2002 Free Software Foundation, Inc. 2*16dce513Schristos This file is part of the GNU C Library. 3*16dce513Schristos Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. 4*16dce513Schristos 5*16dce513Schristos This program is free software; you can redistribute it and/or modify it 6*16dce513Schristos under the terms of the GNU Library General Public License as published 7*16dce513Schristos by the Free Software Foundation; either version 2, or (at your option) 8*16dce513Schristos any later version. 9*16dce513Schristos 10*16dce513Schristos This program is distributed in the hope that it will be useful, 11*16dce513Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 12*16dce513Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*16dce513Schristos Library General Public License for more details. 14*16dce513Schristos 15*16dce513Schristos You should have received a copy of the GNU Library General Public 16*16dce513Schristos License along with this program; if not, write to the Free Software 17*16dce513Schristos Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 18*16dce513Schristos USA. */ 19*16dce513Schristos 20*16dce513Schristos #ifndef _LOADINFO_H 21*16dce513Schristos #define _LOADINFO_H 1 22*16dce513Schristos 23*16dce513Schristos /* Declarations of locale dependent catalog lookup functions. 24*16dce513Schristos Implemented in 25*16dce513Schristos 26*16dce513Schristos localealias.c Possibly replace a locale name by another. 27*16dce513Schristos explodename.c Split a locale name into its various fields. 28*16dce513Schristos l10nflist.c Generate a list of filenames of possible message catalogs. 29*16dce513Schristos finddomain.c Find and open the relevant message catalogs. 30*16dce513Schristos 31*16dce513Schristos The main function _nl_find_domain() in finddomain.c is declared 32*16dce513Schristos in gettextP.h. 33*16dce513Schristos */ 34*16dce513Schristos 35*16dce513Schristos #ifndef PARAMS 36*16dce513Schristos # if __STDC__ || defined __GNUC__ || defined __SUNPRO_C || defined __cplusplus || __PROTOTYPES 37*16dce513Schristos # define PARAMS(args) args 38*16dce513Schristos # else 39*16dce513Schristos # define PARAMS(args) () 40*16dce513Schristos # endif 41*16dce513Schristos #endif 42*16dce513Schristos 43*16dce513Schristos #ifndef internal_function 44*16dce513Schristos # define internal_function 45*16dce513Schristos #endif 46*16dce513Schristos 47*16dce513Schristos /* Tell the compiler when a conditional or integer expression is 48*16dce513Schristos almost always true or almost always false. */ 49*16dce513Schristos #ifndef HAVE_BUILTIN_EXPECT 50*16dce513Schristos # define __builtin_expect(expr, val) (expr) 51*16dce513Schristos #endif 52*16dce513Schristos 53*16dce513Schristos /* Separator in PATH like lists of pathnames. */ 54*16dce513Schristos #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ 55*16dce513Schristos /* Win32, OS/2, DOS */ 56*16dce513Schristos # define PATH_SEPARATOR ';' 57*16dce513Schristos #else 58*16dce513Schristos /* Unix */ 59*16dce513Schristos # define PATH_SEPARATOR ':' 60*16dce513Schristos #endif 61*16dce513Schristos 62*16dce513Schristos /* Encoding of locale name parts. */ 63*16dce513Schristos #define CEN_REVISION 1 64*16dce513Schristos #define CEN_SPONSOR 2 65*16dce513Schristos #define CEN_SPECIAL 4 66*16dce513Schristos #define XPG_NORM_CODESET 8 67*16dce513Schristos #define XPG_CODESET 16 68*16dce513Schristos #define TERRITORY 32 69*16dce513Schristos #define CEN_AUDIENCE 64 70*16dce513Schristos #define XPG_MODIFIER 128 71*16dce513Schristos 72*16dce513Schristos #define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE) 73*16dce513Schristos #define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER) 74*16dce513Schristos 75*16dce513Schristos 76*16dce513Schristos struct loaded_l10nfile 77*16dce513Schristos { 78*16dce513Schristos const char *filename; 79*16dce513Schristos int decided; 80*16dce513Schristos 81*16dce513Schristos const void *data; 82*16dce513Schristos 83*16dce513Schristos struct loaded_l10nfile *next; 84*16dce513Schristos struct loaded_l10nfile *successor[1]; 85*16dce513Schristos }; 86*16dce513Schristos 87*16dce513Schristos 88*16dce513Schristos /* Normalize codeset name. There is no standard for the codeset 89*16dce513Schristos names. Normalization allows the user to use any of the common 90*16dce513Schristos names. The return value is dynamically allocated and has to be 91*16dce513Schristos freed by the caller. */ 92*16dce513Schristos extern const char *_nl_normalize_codeset PARAMS ((const char *codeset, 93*16dce513Schristos size_t name_len)); 94*16dce513Schristos 95*16dce513Schristos /* Lookup a locale dependent file. 96*16dce513Schristos *L10NFILE_LIST denotes a pool of lookup results of locale dependent 97*16dce513Schristos files of the same kind, sorted in decreasing order of ->filename. 98*16dce513Schristos DIRLIST and DIRLIST_LEN are an argz list of directories in which to 99*16dce513Schristos look, containing at least one directory (i.e. DIRLIST_LEN > 0). 100*16dce513Schristos MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER, 101*16dce513Schristos SPECIAL, SPONSOR, REVISION are the pieces of the locale name, as 102*16dce513Schristos produced by _nl_explode_name(). FILENAME is the filename suffix. 103*16dce513Schristos The return value is the lookup result, either found in *L10NFILE_LIST, 104*16dce513Schristos or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL. 105*16dce513Schristos If the return value is non-NULL, it is added to *L10NFILE_LIST, and 106*16dce513Schristos its ->next field denotes the chaining inside *L10NFILE_LIST, and 107*16dce513Schristos furthermore its ->successor[] field contains a list of other lookup 108*16dce513Schristos results from which this lookup result inherits. */ 109*16dce513Schristos extern struct loaded_l10nfile * 110*16dce513Schristos _nl_make_l10nflist PARAMS ((struct loaded_l10nfile **l10nfile_list, 111*16dce513Schristos const char *dirlist, size_t dirlist_len, int mask, 112*16dce513Schristos const char *language, const char *territory, 113*16dce513Schristos const char *codeset, 114*16dce513Schristos const char *normalized_codeset, 115*16dce513Schristos const char *modifier, const char *special, 116*16dce513Schristos const char *sponsor, const char *revision, 117*16dce513Schristos const char *filename, int do_allocate)); 118*16dce513Schristos 119*16dce513Schristos /* Lookup the real locale name for a locale alias NAME, or NULL if 120*16dce513Schristos NAME is not a locale alias (but possibly a real locale name). 121*16dce513Schristos The return value is statically allocated and must not be freed. */ 122*16dce513Schristos extern const char *_nl_expand_alias PARAMS ((const char *name)); 123*16dce513Schristos 124*16dce513Schristos /* Split a locale name NAME into its pieces: language, modifier, 125*16dce513Schristos territory, codeset, special, sponsor, revision. 126*16dce513Schristos NAME gets destructively modified: NUL bytes are inserted here and 127*16dce513Schristos there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY, 128*16dce513Schristos *CODESET, *SPECIAL, *SPONSOR, *REVISION gets assigned either a 129*16dce513Schristos pointer into the old NAME string, or NULL. *NORMALIZED_CODESET 130*16dce513Schristos gets assigned the expanded *CODESET, if it is different from *CODESET; 131*16dce513Schristos this one is dynamically allocated and has to be freed by the caller. 132*16dce513Schristos The return value is a bitmask, where each bit corresponds to one 133*16dce513Schristos filled-in value: 134*16dce513Schristos XPG_MODIFIER, CEN_AUDIENCE for *MODIFIER, 135*16dce513Schristos TERRITORY for *TERRITORY, 136*16dce513Schristos XPG_CODESET for *CODESET, 137*16dce513Schristos XPG_NORM_CODESET for *NORMALIZED_CODESET, 138*16dce513Schristos CEN_SPECIAL for *SPECIAL, 139*16dce513Schristos CEN_SPONSOR for *SPONSOR, 140*16dce513Schristos CEN_REVISION for *REVISION. 141*16dce513Schristos */ 142*16dce513Schristos extern int _nl_explode_name PARAMS ((char *name, const char **language, 143*16dce513Schristos const char **modifier, 144*16dce513Schristos const char **territory, 145*16dce513Schristos const char **codeset, 146*16dce513Schristos const char **normalized_codeset, 147*16dce513Schristos const char **special, 148*16dce513Schristos const char **sponsor, 149*16dce513Schristos const char **revision)); 150*16dce513Schristos 151*16dce513Schristos /* Split a locale name NAME into a leading language part and all the 152*16dce513Schristos rest. Return a pointer to the first character after the language, 153*16dce513Schristos i.e. to the first byte of the rest. */ 154*16dce513Schristos extern char *_nl_find_language PARAMS ((const char *name)); 155*16dce513Schristos 156*16dce513Schristos #endif /* loadinfo.h */ 157