]> git.ipfire.org Git - thirdparty/glibc.git/blob - locale/localeinfo.h
Update.
[thirdparty/glibc.git] / locale / localeinfo.h
1 /* Declarations for internal libc locale interfaces
2 Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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. */
19
20 #ifndef _LOCALEINFO_H
21 #define _LOCALEINFO_H 1
22
23 #include <stddef.h>
24 #include <langinfo.h>
25 #include <limits.h>
26 #include <time.h>
27 #include <stdint.h>
28 #include <sys/types.h>
29
30 /* This has to be changed whenever a new locale is defined. */
31 #define __LC_LAST 13
32
33 #include <intl/loadinfo.h> /* For loaded_l10nfile definition. */
34
35 /* Magic number at the beginning of a locale data file for CATEGORY. */
36 #define LIMAGIC(category) (0x980505 ^ (category))
37
38 /* Two special weight constants for the collation data. */
39 #define FORWARD_CHAR ((uint32_t) 0xfffffffd)
40 #define ELLIPSIS_CHAR ((uint32_t) 0xfffffffe)
41 #define IGNORE_CHAR ((uint32_t) 0xffffffff)
42
43 /* We use a special value for the usage counter in `locale_data' to
44 signal that this data must never be removed anymore. */
45 #define MAX_USAGE_COUNT (UINT_MAX - 1)
46 #define UNDELETABLE UINT_MAX
47
48 /* Structure describing locale data in core for a category. */
49 struct locale_data
50 {
51 const char *name;
52 const char *filedata; /* Region mapping the file data. */
53 off_t filesize; /* Size of the file (and the region). */
54 int mmaped; /* If nonzero the data is mmaped. */
55
56 unsigned int usage_count; /* Counter for users. */
57
58 unsigned int nstrings; /* Number of strings below. */
59 union locale_data_value
60 {
61 const uint32_t *wstr;
62 const char *string;
63 unsigned int word;
64 }
65 values[0]; /* Items, usually pointers into `filedata'. */
66 };
67
68 /* We know three kinds of collation sorting rules. */
69 enum coll_sort_rule
70 {
71 illegal_0__,
72 sort_forward,
73 sort_backward,
74 illegal_3__,
75 sort_position,
76 sort_forward_position,
77 sort_backward_position,
78 sort_mask
79 };
80
81 /* We can map the types of the entries into a few categories. */
82 enum value_type
83 {
84 none,
85 string,
86 stringarray,
87 byte,
88 bytearray,
89 word,
90 stringlist,
91 wordarray
92 };
93
94
95 /* Structure to access `era' information from LC_TIME. */
96 struct era_entry
97 {
98 uint32_t direction; /* Contains '+' or '-'. */
99 int32_t offset;
100 int32_t start_date[3];
101 int32_t stop_date[3];
102 const char name_fmt[0];
103 };
104
105
106 /* For each category declare the variable for the current locale data. */
107 #define DEFINE_CATEGORY(category, category_name, items, a) \
108 extern struct locale_data *_nl_current_##category;
109 #include "categories.def"
110 #undef DEFINE_CATEGORY
111
112 extern const char *const _nl_category_names[__LC_LAST];
113 extern const size_t _nl_category_name_sizes[__LC_LAST];
114 extern struct locale_data * *const _nl_current[__LC_LAST];
115
116 /* Name of the standard locales. */
117 extern const char _nl_C_name[];
118 extern const char _nl_POSIX_name[];
119
120 /* Extract the current CATEGORY locale's string for ITEM. */
121 #define _NL_CURRENT(category, item) \
122 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].string)
123
124 /* Extract the current CATEGORY locale's string for ITEM. */
125 #define _NL_CURRENT_WSTR(category, item) \
126 ((wchar_t *) (_nl_current_##category->values[_NL_ITEM_INDEX (item)].wstr))
127
128 /* Extract the current CATEGORY locale's word for ITEM. */
129 #define _NL_CURRENT_WORD(category, item) \
130 (_nl_current_##category->values[_NL_ITEM_INDEX (item)].word)
131
132 /* This is used in lc-CATEGORY.c to define _nl_current_CATEGORY. */
133 #define _NL_CURRENT_DEFINE(category) \
134 extern struct locale_data _nl_C_##category; \
135 struct locale_data *_nl_current_##category = &_nl_C_##category
136
137 /* Load the locale data for CATEGORY from the file specified by *NAME.
138 If *NAME is "", use environment variables as specified by POSIX,
139 and fill in *NAME with the actual name used. The directories
140 listed in LOCALE_PATH are searched for the locale files. */
141 extern struct locale_data *_nl_find_locale (const char *locale_path,
142 size_t locale_path_len,
143 int category, const char **name);
144
145 /* Try to load the file described by FILE. */
146 extern void _nl_load_locale (struct loaded_l10nfile *file, int category);
147
148 /* Free all resource. */
149 extern void _nl_unload_locale (struct locale_data *locale);
150
151 /* Free the locale and give back all memory if the usage count is one. */
152 extern void _nl_remove_locale (int locale, struct locale_data *data);
153
154
155 /* Return `era' entry which corresponds to TP. Used in strftime. */
156 extern struct era_entry *_nl_get_era_entry (const struct tm *tp);
157
158 /* Return `alt_digit' which corresponds to NUMBER. Used in strftime. */
159 extern const char *_nl_get_alt_digit (unsigned int number);
160
161 /* Similar, but now for wide characters. */
162 extern const wchar_t *_nl_get_walt_digit (unsigned int number);
163
164
165 /* Global variables for LC_COLLATE category data. */
166 extern const uint32_t *__collate_tablewc;
167 extern const uint32_t *__collate_extrawc;
168 extern const uint32_t *__collate_element_hash;
169 extern const char *__collate_element_strings;
170 extern const uint32_t *__collate_element_values;
171 extern const uint32_t *__collate_symbol_hash;
172 extern const char *__collate_symbol_strings;
173 extern const uint32_t *__collate_symbol_classes;
174
175 #endif /* localeinfo.h */