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