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