1 /* Copyright (C) 1996-2020 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 6 it under the terms of the GNU Lesser General Public License as published by 7 the Free Software Foundation; either version 2.1 of the License, or 8 (at your option) 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 13 GNU Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public License 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 17 18 #ifndef _LOADINFO_H 19 #define _LOADINFO_H 1 20 21 /* Declarations of locale dependent catalog lookup functions. 22 Implemented in 23 24 localealias.c Possibly replace a locale name by another. 25 explodename.c Split a locale name into its various fields. 26 l10nflist.c Generate a list of filenames of possible message catalogs. 27 finddomain.c Find and open the relevant message catalogs. 28 29 The main function _nl_find_domain() in finddomain.c is declared 30 in gettextP.h. 31 */ 32 33 #ifndef internal_function 34 # define internal_function 35 #endif 36 37 #ifndef LIBINTL_DLL_EXPORTED 38 # define LIBINTL_DLL_EXPORTED 39 #endif 40 41 /* Tell the compiler when a conditional or integer expression is 42 almost always true or almost always false. */ 43 #ifndef HAVE_BUILTIN_EXPECT 44 # define __builtin_expect(expr, val) (expr) 45 #endif 46 47 /* Separator in PATH like lists of pathnames. */ 48 #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ 49 /* Win32, OS/2, DOS */ 50 # define PATH_SEPARATOR ';' 51 #else 52 /* Unix */ 53 # define PATH_SEPARATOR ':' 54 #endif 55 56 /* Encoding of locale name parts. */ 57 #define XPG_NORM_CODESET 1 58 #define XPG_CODESET 2 59 #define XPG_TERRITORY 4 60 #define XPG_MODIFIER 8 61 62 63 struct loaded_l10nfile 64 { 65 const char *filename; 66 #if defined _WIN32 && !defined __CYGWIN__ 67 const wchar_t *wfilename; 68 #endif 69 int decided; 70 71 const void *data; 72 73 struct loaded_l10nfile *next; 74 struct loaded_l10nfile *successor[1]; 75 }; 76 77 78 /* Normalize codeset name. There is no standard for the codeset 79 names. Normalization allows the user to use any of the common 80 names. The return value is dynamically allocated and has to be 81 freed by the caller. */ 82 extern const char *_nl_normalize_codeset (const char *codeset, 83 size_t name_len); 84 85 /* Lookup a locale dependent file. 86 *L10NFILE_LIST denotes a pool of lookup results of locale dependent 87 files of the same kind, sorted in decreasing order of ->filename. 88 89 DIRLIST and DIRLIST_LEN are an argz list of directories in which to 90 look. 91 Likewise, on native Windows, WDIRLIST and WDIRLIST_LEN are wide-char 92 list of directories in which to look. Only one of DIRLIST, WDIRLIST 93 is non-NULL. 94 DIRLIST and WDIRLIST contain at least one directory, i.e. 95 DIRLIST_LEN + WDIRLIST_LEN > 0. 96 Outside glibc, only one directory is used, i.e. 97 DIRLIST_LEN == strlen (DIRLIST) + 1, WDIRLIST_LEN == 0, or 98 DIRLIST_LEN == 0, WDIRLIST_LEN == wcslen (WDIRLIST) + 1. 99 100 MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER 101 are the pieces of the locale name, as produced by _nl_explode_name(). 102 FILENAME is the filename suffix. 103 104 The return value is the lookup result, either found in *L10NFILE_LIST, 105 or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL. 106 If the return value is non-NULL, it is added to *L10NFILE_LIST, and 107 its ->next field denotes the chaining inside *L10NFILE_LIST, and 108 furthermore its ->successor[] field contains a list of other lookup 109 results from which this lookup result inherits. */ 110 extern struct loaded_l10nfile * 111 _nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list, 112 const char *dirlist, size_t dirlist_len, 113 #if defined _WIN32 && !defined __CYGWIN__ 114 const wchar_t *wdirlist, size_t wdirlist_len, 115 #endif 116 int mask, 117 const char *language, const char *territory, 118 const char *codeset, const char *normalized_codeset, 119 const char *modifier, 120 const char *filename, int do_allocate); 121 122 /* Lookup the real locale name for a locale alias NAME, or NULL if 123 NAME is not a locale alias (but possibly a real locale name). 124 The return value is statically allocated and must not be freed. */ 125 /* Part of the libintl ABI only for the sake of the gettext.m4 macro. */ 126 extern LIBINTL_DLL_EXPORTED const char *_nl_expand_alias (const char *name); 127 128 /* Split a locale name NAME into its pieces: language, modifier, 129 territory, codeset. 130 NAME gets destructively modified: NUL bytes are inserted here and 131 there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY, 132 *CODESET gets assigned either a pointer into the old NAME string, or 133 NULL. *NORMALIZED_CODESET gets assigned the expanded *CODESET, if it 134 is different from *CODESET; this one is dynamically allocated and has 135 to be freed by the caller. 136 The return value is a bitmask, where each bit corresponds to one 137 filled-in value: 138 XPG_MODIFIER for *MODIFIER, 139 XPG_TERRITORY for *TERRITORY, 140 XPG_CODESET for *CODESET, 141 XPG_NORM_CODESET for *NORMALIZED_CODESET. 142 */ 143 extern int _nl_explode_name (char *name, const char **language, 144 const char **modifier, const char **territory, 145 const char **codeset, 146 const char **normalized_codeset); 147 148 #endif /* loadinfo.h */ 149