Update.
[glibc.git] / locale / programs / locales.h
blob1cd3a3f92ebdee21ac570eb55bda76263ef2b1d6
1 /* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
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. */
20 #ifndef _LOCALES_H
21 #define _LOCALES_H
23 #include <ctype.h>
25 /* Undefine following line in production version. */
26 /* #define NDEBUG 1 */
27 #include <assert.h>
29 #include "linereader.h"
30 #include "locfile-token.h"
31 #include "charset.h"
32 #include "locfile.h"
33 #include "localeinfo.h"
36 /* List of locale definition files which are used in `copy' instructions. */
37 struct copy_def_list_t
39 struct copy_def_list_t *next;
41 const char *name;
42 int mask;
44 struct localedef_t *locale;
46 struct
48 void *data;
49 size_t len;
50 } binary[6];
53 extern struct copy_def_list_t copy_posix;
56 /* Header of the locale data files. */
57 struct locale_file
59 int magic;
60 int n;
64 /* Handle LC_CTYPE category. */
66 static inline unsigned int
67 charclass_to_bit (enum token_t tok)
69 static unsigned int lastbit = _ISalnum;
71 switch (tok)
73 #define CLASS(name) case tok_##name: return _IS##name
74 CLASS (upper);
75 CLASS (lower);
76 CLASS (alpha);
77 CLASS (digit);
78 CLASS (alnum);
79 CLASS (space);
80 CLASS (cntrl);
81 CLASS (punct);
82 CLASS (graph);
83 CLASS (print);
84 CLASS (xdigit);
85 CLASS (blank);
86 #undef CLASS
87 case tok_string:
88 lastbit <<= 1;
89 if (lastbit == 0ul)
90 /* Exit status 2 means a limitation in the implementation is
91 exceeded. */
92 error (2, 0, _("too many character classes defined"));
93 return lastbit;
94 default:
95 assert (1 == 0);
97 return 0;
100 /* Remember name of newly created charclass. */
101 void ctype_startup (struct linereader *lr, struct localedef_t *locale,
102 struct charset_t *charset);
103 void ctype_finish (struct localedef_t *locale, struct charset_t *charset);
105 void ctype_output (struct localedef_t *locale, struct charset_t *charset,
106 const char *output_path);
108 int ctype_is_charclass (struct linereader *lr, struct localedef_t *locale,
109 const char *name);
110 void ctype_class_new (struct linereader *lr, struct localedef_t *locale,
111 enum token_t tok, struct token *code,
112 struct charset_t *charset);
113 void ctype_class_start (struct linereader *lr, struct localedef_t *locale,
114 enum token_t tok, const char *name,
115 struct charset_t *charset);
116 void ctype_class_from (struct linereader *lr, struct localedef_t *locale,
117 struct token *code, struct charset_t *charset);
118 void ctype_class_to (struct linereader *lr, struct localedef_t *locale,
119 struct token *code, struct charset_t *charset);
120 void ctype_class_end (struct linereader *lr, struct localedef_t *locale);
122 int ctype_is_charconv (struct linereader *lr, struct localedef_t *locale,
123 const char *name);
124 void ctype_map_new (struct linereader *lr, struct localedef_t *locale,
125 enum token_t tok, struct token *code,
126 struct charset_t *charset);
127 void ctype_map_start (struct linereader *lr, struct localedef_t *locale,
128 enum token_t tok, const char *name,
129 struct charset_t *charset);
130 void ctype_map_from (struct linereader *lr, struct localedef_t *locale,
131 struct token *code, struct charset_t *charset);
132 void ctype_map_to (struct linereader *lr, struct localedef_t *locale,
133 struct token *code, struct charset_t *charset);
134 void ctype_map_end (struct linereader *lr, struct localedef_t *locale);
137 /* Handle LC_COLLATE category. */
139 void collate_startup (struct linereader *lr, struct localedef_t *locale,
140 struct charset_t *charset);
142 void collate_finish (struct localedef_t *locale,
143 struct charset_t *charset);
145 void collate_output (struct localedef_t *locale, struct charset_t *charset,
146 const char *output_path);
148 void collate_element_to (struct linereader *lr, struct localedef_t *locale,
149 struct token *code, struct charset_t *charset);
150 void collate_element_from (struct linereader *lr,
151 struct localedef_t *locale, struct token *code,
152 struct charset_t *charset);
153 void collate_symbol (struct linereader *lr, struct localedef_t *locale,
154 struct token *code, struct charset_t *charset);
155 void collate_new_order (struct linereader *lr, struct localedef_t *locale,
156 enum coll_sort_rule sort_rule);
157 void collate_build_arrays (struct linereader *lr,
158 struct localedef_t *locale);
159 int collate_order_elem (struct linereader *lr, struct localedef_t *locale,
160 struct token *code, struct charset_t *charset);
161 int collate_weight_bsymbol (struct linereader *lr,
162 struct localedef_t *locale,
163 struct token *code, struct charset_t *charset);
164 int collate_next_weight (struct linereader *lr,
165 struct localedef_t *locale);
166 int collate_simple_weight (struct linereader *lr,
167 struct localedef_t *locale,
168 struct token *code, struct charset_t *charset);
169 void collate_end_weight (struct linereader *lr,
170 struct localedef_t *locale);
173 /* Handle LC_MONETARY category. */
175 void monetary_startup (struct linereader *lr, struct localedef_t *locale,
176 struct charset_t *charset);
178 void monetary_finish (struct localedef_t *locale);
180 void monetary_output (struct localedef_t *locale, const char *output_path);
182 void monetary_add (struct linereader *lr, struct localedef_t *locale,
183 enum token_t tok, struct token *code,
184 struct charset_t *charset);
187 /* Handle LC_NUMERIC category. */
189 void numeric_startup (struct linereader *lr, struct localedef_t *locale,
190 struct charset_t *charset);
192 void numeric_finish (struct localedef_t *locale);
194 void numeric_output (struct localedef_t *locale, const char *output_path);
196 void numeric_add (struct linereader *lr, struct localedef_t *locale,
197 enum token_t tok, struct token *code,
198 struct charset_t *charset);
201 /* Handle LC_TIME category. */
203 void time_startup (struct linereader *lr, struct localedef_t *locale,
204 struct charset_t *charset);
206 void time_finish (struct localedef_t *locale);
208 void time_output (struct localedef_t *locale, const char *output_path);
210 void time_add (struct linereader *lr, struct localedef_t *locale,
211 enum token_t tok, struct token *code,
212 struct charset_t *charset);
215 /* Handle LC_MESSAGES category. */
217 void messages_startup (struct linereader *lr, struct localedef_t *locale,
218 struct charset_t *charset);
220 void messages_finish (struct localedef_t *locale);
222 void messages_output (struct localedef_t *locale, const char *output_path);
224 void messages_add (struct linereader *lr, struct localedef_t *locale,
225 enum token_t tok, struct token *code,
226 struct charset_t *charset);
229 #endif /* locales.h */