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