1 /* localeinfo.h -- declarations for internal libc locale interfaces
2 Copyright (C) 1995, 1996, 1997 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
27 #include <sys/types.h>
29 #include "../intl/loadinfo.h" /* For loaded_l10nfile definition. */
31 /* Magic number at the beginning of a locale data file for CATEGORY. */
32 #define LIMAGIC(category) (0x960617de ^ (category))
34 /* Two special weight constants for the collation data. */
35 #define FORWARD_CHAR ((wchar_t) 0xfffffffd)
36 #define ELLIPSIS_CHAR ((wchar_t) 0xfffffffe)
37 #define IGNORE_CHAR ((wchar_t) 0xffffffff)
39 /* We use a special value for the usage counter in `locale_data' to
40 signal that this data must never be removed anymore. */
41 #define MAX_USAGE_COUNT (UINT_MAX - 1)
42 #define UNDELETABLE UINT_MAX
44 /* Structure describing locale data in core for a category. */
48 const char *filedata
; /* Region mapping the file data. */
49 off_t filesize
; /* Size of the file (and the region). */
50 int mmaped
; /* If nonzero the data is mmaped. */
52 unsigned int usage_count
; /* Counter for users. */
54 unsigned int nstrings
; /* Number of strings below. */
55 union locale_data_value
61 values
[0]; /* Items, usually pointers into `filedata'. */
64 /* We know three kinds of collation sorting rules. */
72 sort_forward_position
,
73 sort_backward_position
,
77 /* We can map the types of the entries into a few categories. */
90 /* Structure to access `era' information from LC_TIME. */
93 u_int32_t direction
; /* Contains '+' or '-'. */
95 int32_t start_date
[3];
97 const char name_fmt
[0];
101 /* For each category declare the variable for the current locale data. */
102 #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
103 extern struct locale_data *_nl_current_##category;
104 #include "categories.def"
105 #undef DEFINE_CATEGORY
107 extern const char *const _nl_category_names
[LC_ALL
+ 1];
108 extern const size_t _nl_category_name_sizes
[LC_ALL
+ 1];
109 extern struct locale_data
* *const _nl_current
[LC_ALL
+ 1];
111 /* Name of the standard locales. */
112 extern const char _nl_C_name
[];
113 extern const char _nl_POSIX_name
[];
115 /* Extract the current CATEGORY locale's string for ITEM. */
116 #define _NL_CURRENT(category, item) \
117 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
119 /* Extract the current CATEGORY locale's word for ITEM. */
120 #define _NL_CURRENT_WORD(category, item) \
121 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
123 /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
124 #define _NL_CURRENT_DEFINE(category) \
125 extern struct locale_data _nl_C_##category; \
126 struct locale_data *_nl_current_##category = &_nl_C_##category
128 /* Load the locale data for CATEGORY from the file specified by *NAME.
129 If *NAME is "", use environment variables as specified by POSIX,
130 and fill in *NAME with the actual name used. The directories
131 listed in LOCALE_PATH are searched for the locale files. */
132 extern struct locale_data
*_nl_find_locale (const char *locale_path
,
133 size_t locale_path_len
,
134 int category
, const char **name
);
136 /* Try to load the file described by FILE. */
137 extern void _nl_load_locale (struct loaded_l10nfile
*file
, int category
);
139 /* Free all resource. */
140 extern void _nl_unload_locale (struct locale_data
*locale
);
142 /* Free the locale and give back all memory if the usage count is one. */
143 extern void _nl_remove_locale (int locale
, struct locale_data
*data
);
146 /* Return `era' entry which corresponds to TP. Used in strftime. */
147 extern struct era_entry
*_nl_get_era_entry (const struct tm
*tp
);
149 /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */
150 extern const char *_nl_get_alt_digit (unsigned int number
);
153 /* Global variables for LC_COLLATE category data. */
154 extern const u_int32_t
*__collate_table
;
155 extern const u_int32_t
*__collate_extra
;
156 extern const u_int32_t
*__collate_element_hash
;
157 extern const char *__collate_element_strings
;
158 extern const wchar_t *__collate_element_values
;
159 extern const u_int32_t
*__collate_symbol_hash
;
160 extern const char *__collate_symbol_strings
;
161 extern const u_int32_t
*__collate_symbol_classes
;
163 #endif /* localeinfo.h */