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