9fe85e9e078004d16a886273e4697d3746041e5c
[platform/upstream/linaro-glibc.git] / locale / programs / locales.h
1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
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
17 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.  */
19
20 #ifndef _LOCALES_H
21 #define _LOCALES_H
22
23 #include <ctype.h>
24
25 /* Undefine following line in production version.  */
26 /* #define NDEBUG 1 */
27 #include <assert.h>
28
29 #include "linereader.h"
30 #include "locfile-token.h"
31 #include "charset.h"
32 #include "locfile.h"
33 #include "localeinfo.h"
34
35
36 /* Header of the locale data files.  */
37 struct locale_file
38 {
39   int magic;
40   int n;
41 };
42
43
44 /* Handle LC_CTYPE category.  */
45
46 static inline unsigned int
47 charclass_to_bit (enum token_t tok)
48 {
49   static unsigned int lastbit = _ISalnum;
50
51   switch (tok)
52     {
53 #define CLASS(name) case tok_##name: return _IS##name
54     CLASS (upper);
55     CLASS (lower);
56     CLASS (alpha);
57     CLASS (digit);
58     CLASS (alnum);
59     CLASS (space);
60     CLASS (cntrl);
61     CLASS (punct);
62     CLASS (graph);
63     CLASS (print);
64     CLASS (xdigit);
65     CLASS (blank);
66 #undef CLASS
67     case tok_string:
68       lastbit <<= 1;
69       if (lastbit == 0ul)
70         /* Exit status 2 means a limitation in the implementation is
71            exceeded.  */
72         error (2, 0, _("too many character classes defined"));
73       return lastbit;
74     default:
75       assert (1 == 0);
76     }
77   return 0;
78 }
79
80 /* Remember name of newly created charclass.  */
81 void ctype_startup (struct linereader *lr, struct localedef_t *locale,
82                     struct charset_t *charset);
83 void ctype_finish (struct localedef_t *locale, struct charset_t *charset);
84
85 void ctype_output (struct localedef_t *locale, struct charset_t *charset,
86                    const char *output_path);
87
88 int ctype_is_charclass (struct linereader *lr, struct localedef_t *locale,
89                         const char *name);
90 void ctype_class_new (struct linereader *lr, struct localedef_t *locale,
91                       enum token_t tok, struct token *code,
92                       struct charset_t *charset);
93 void ctype_class_start (struct linereader *lr, struct localedef_t *locale,
94                         enum token_t tok, const char *name,
95                         struct charset_t *charset);
96 void ctype_class_from (struct linereader *lr, struct localedef_t *locale,
97                        struct token *code, struct charset_t *charset);
98 void ctype_class_to (struct linereader *lr, struct localedef_t *locale,
99                      struct token *code, struct charset_t *charset);
100 void ctype_class_end (struct linereader *lr, struct localedef_t *locale);
101
102 int ctype_is_charconv (struct linereader *lr, struct localedef_t *locale,
103                        const char *name);
104 void ctype_map_new (struct linereader *lr, struct localedef_t *locale,
105                     enum token_t tok, struct token *code,
106                     struct charset_t *charset);
107 void ctype_map_start (struct linereader *lr, struct localedef_t *locale,
108                       enum token_t tok, const char *name,
109                       struct charset_t *charset);
110 void ctype_map_from (struct linereader *lr, struct localedef_t *locale,
111                      struct token *code, struct charset_t *charset);
112 void ctype_map_to (struct linereader *lr, struct localedef_t *locale,
113                    struct token *code, struct charset_t *charset);
114 void ctype_map_end (struct linereader *lr, struct localedef_t *locale);
115
116
117 /* Handle LC_COLLATE category.  */
118
119 void collate_startup (struct linereader *lr, struct localedef_t *locale,
120                       struct charset_t *charset);
121
122 void collate_finish (struct localedef_t *locale,
123                      struct charset_t *charset);
124
125 void collate_output (struct localedef_t *locale, const char *output_path);
126
127 void collate_element_to (struct linereader *lr, struct localedef_t *locale,
128                          struct token *code, struct charset_t *charset);
129 void collate_element_from (struct linereader *lr,
130                            struct localedef_t *locale, struct token *code,
131                            struct charset_t *charset);
132 void collate_symbol (struct linereader *lr, struct localedef_t *locale,
133                      struct token *code, struct charset_t *charset);
134 void collate_new_order (struct linereader *lr, struct localedef_t *locale,
135                         enum coll_sort_rule sort_rule);
136 void collate_build_arrays (struct linereader *lr,
137                            struct localedef_t *locale);
138 int collate_order_elem (struct linereader *lr, struct localedef_t *locale,
139                         struct token *code, struct charset_t *charset);
140 int collate_weight_bsymbol (struct linereader *lr,
141                             struct localedef_t *locale,
142                             struct token *code, struct charset_t *charset);
143 int collate_next_weight (struct linereader *lr,
144                          struct localedef_t *locale);
145 int collate_simple_weight (struct linereader *lr,
146                            struct localedef_t *locale,
147                            struct token *code, struct charset_t *charset);
148 void collate_end_weight (struct linereader *lr,
149                          struct localedef_t *locale);
150
151
152 /* Handle LC_MONETARY category.  */
153
154 void monetary_startup (struct linereader *lr, struct localedef_t *locale,
155                        struct charset_t *charset);
156
157 void monetary_finish (struct localedef_t *locale);
158
159 void monetary_output (struct localedef_t *locale, const char *output_path);
160
161 void monetary_add (struct linereader *lr, struct localedef_t *locale,
162                    enum token_t tok, struct token *code,
163                    struct charset_t *charset);
164
165
166 /* Handle LC_NUMERIC category.  */
167
168 void numeric_startup (struct linereader *lr, struct localedef_t *locale,
169                       struct charset_t *charset);
170
171 void numeric_finish (struct localedef_t *locale);
172
173 void numeric_output (struct localedef_t *locale, const char *output_path);
174
175 void numeric_add (struct linereader *lr, struct localedef_t *locale,
176                   enum token_t tok, struct token *code,
177                   struct charset_t *charset);
178
179
180 /* Handle LC_TIME category.  */
181
182 void time_startup (struct linereader *lr, struct localedef_t *locale,
183                    struct charset_t *charset);
184
185 void time_finish (struct localedef_t *locale);
186
187 void time_output (struct localedef_t *locale, const char *output_path);
188
189 void time_add (struct linereader *lr, struct localedef_t *locale,
190                enum token_t tok, struct token *code,
191                struct charset_t *charset);
192
193
194 /* Handle LC_MESSAGES category.  */
195
196 void messages_startup (struct linereader *lr, struct localedef_t *locale,
197                        struct charset_t *charset);
198
199 void messages_finish (struct localedef_t *locale);
200
201 void messages_output (struct localedef_t *locale, const char *output_path);
202
203 void messages_add (struct linereader *lr, struct localedef_t *locale,
204                    enum token_t tok, struct token *code,
205                    struct charset_t *charset);
206
207
208 #endif /* locales.h */