1 /* Declarations for internal libc locale interfaces
2 Copyright (C) 1995, 96, 97, 98, 99,2000,2001 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library 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.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
21 #define _LOCALEINFO_H 1
28 #include <sys/types.h>
30 /* This has to be changed whenever a new locale is defined. */
33 #include <intl/loadinfo.h> /* For loaded_l10nfile definition. */
35 /* Magic number at the beginning of a locale data file for CATEGORY. */
36 #define LIMAGIC(category) ((unsigned int) (0x20000828 ^ (category)))
38 /* Two special weight constants for the collation data. */
41 /* We use a special value for the usage counter in `locale_data' to
42 signal that this data must never be removed anymore. */
43 #define MAX_USAGE_COUNT (UINT_MAX - 1)
44 #define UNDELETABLE UINT_MAX
46 /* Structure describing locale data in core for a category. */
50 const char *filedata
; /* Region mapping the file data. */
51 off_t filesize
; /* Size of the file (and the region). */
52 int mmaped
; /* If nonzero the data is mmaped. */
54 unsigned int usage_count
; /* Counter for users. */
56 int use_translit
; /* Nonzero if the mb*towv*() and wc*tomb()
57 functions should use transliteration. */
58 const char *options
; /* Extra options from the locale name,
59 not used in the path to the locale data. */
61 unsigned int nstrings
; /* Number of strings below. */
62 union locale_data_value
68 values __flexarr
; /* Items, usually pointers into `filedata'. */
71 /* We know three kinds of collation sorting rules. */
79 sort_forward_position
,
80 sort_backward_position
,
84 /* We can map the types of the entries into a few categories. */
101 /* Definitions for `era' information from LC_TIME. */
102 #define ERA_NAME_FORMAT_MEMBERS 4
104 #define ERA_M_FORMAT 1
106 #define ERA_W_FORMAT 3
109 /* Structure to access `era' information from LC_TIME. */
112 uint32_t direction
; /* Contains '+' or '-'. */
114 int32_t start_date
[3];
115 int32_t stop_date
[3];
116 const char *era_name
;
117 const char *era_format
;
118 const wchar_t *era_wname
;
119 const wchar_t *era_wformat
;
120 int absolute_direction
;
121 /* absolute direction:
122 +1 indicates that year number is higher in the future. (like A.D.)
123 -1 indicates that year number is higher in the past. (like B.C.) */
127 /* LC_CTYPE specific:
128 Hardwired indices for standard wide character translation mappings. */
136 /* LC_CTYPE specific:
137 Access a wide character class with a single character index.
138 _ISCTYPE (c, desc) = iswctype (btowc (c), desc).
139 c must be an `unsigned char'. desc must be a nonzero wctype_t. */
140 #define _ISCTYPE(c, desc) \
141 (((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)
144 /* For each category declare the variable for the current locale data. */
145 #define DEFINE_CATEGORY(category, category_name, items, a) \
146 extern struct locale_data *_nl_current_##category;
147 #include "categories.def"
148 #undef DEFINE_CATEGORY
150 extern const char *const _nl_category_names
[__LC_LAST
];
151 extern const size_t _nl_category_name_sizes
[__LC_LAST
];
152 extern struct locale_data
* *const _nl_current
[__LC_LAST
];
154 /* Name of the standard locales. */
155 extern const char _nl_C_name
[];
156 extern const char _nl_POSIX_name
[];
158 /* The standard codeset. */
159 extern const char _nl_C_codeset
[];
161 /* Extract the current CATEGORY locale's string for ITEM. */
162 #define _NL_CURRENT(category, item) \
163 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
165 /* Extract the current CATEGORY locale's string for ITEM. */
166 #define _NL_CURRENT_WSTR(category, item) \
167 ((wchar_t *) (_nl_current_##category->values[_NL_ITEM_INDEX (item)].wstr))
169 /* Extract the current CATEGORY locale's word for ITEM. */
170 #define _NL_CURRENT_WORD(category, item) \
171 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
173 /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
174 #define _NL_CURRENT_DEFINE(category) \
175 extern struct locale_data _nl_C_##category; \
176 struct locale_data *_nl_current_##category = &_nl_C_##category
178 /* Load the locale data for CATEGORY from the file specified by *NAME.
179 If *NAME is "", use environment variables as specified by POSIX,
180 and fill in *NAME with the actual name used. The directories
181 listed in LOCALE_PATH are searched for the locale files. */
182 extern struct locale_data
*_nl_find_locale (const char *locale_path
,
183 size_t locale_path_len
,
184 int category
, const char **name
);
186 /* Try to load the file described by FILE. */
187 extern void _nl_load_locale (struct loaded_l10nfile
*file
, int category
);
189 /* Free all resource. */
190 extern void _nl_unload_locale (struct locale_data
*locale
);
192 /* Free the locale and give back all memory if the usage count is one. */
193 extern void _nl_remove_locale (int locale
, struct locale_data
*data
);
196 /* Return `era' entry which corresponds to TP. Used in strftime. */
197 extern struct era_entry
*_nl_get_era_entry (const struct tm
*tp
);
199 /* Return `era' cnt'th entry . Used in strptime. */
200 extern struct era_entry
*_nl_select_era_entry (int cnt
);
202 /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */
203 extern const char *_nl_get_alt_digit (unsigned int number
);
205 /* Similar, but now for wide characters. */
206 extern const wchar_t *_nl_get_walt_digit (unsigned int number
);
208 /* Postload processing. */
209 extern void _nl_postload_ctype (void);
210 extern void _nl_postload_time (void);
213 #endif /* localeinfo.h */