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