Update.
[glibc.git] / locale / programs / locfile.h
blob50a1d7709d47541a774a3a395cde7e17a0161deb
1 /* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.org>, 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 _LOCFILE_H
21 #define _LOCFILE_H 1
23 #include <sys/uio.h>
25 #include "linereader.h"
26 #include "localedef.h"
29 /* Header of the locale data files. */
30 struct locale_file
32 int magic;
33 int n;
37 /* Macros used in the parser. */
38 #define SYNTAX_ERROR(string, args...) \
39 do \
40 { \
41 lr_error (ldfile, string, ## args); \
42 lr_ignore_rest (ldfile, 0); \
43 } \
44 while (0)
47 /* General handling of `copy'. */
48 static inline void
49 handle_copy (struct linereader *ldfile, struct charmap_t *charmap,
50 struct repertoire_t *repertoire, struct localedef_t *result,
51 enum token_t token, int locale, const char *locale_name,
52 int ignore_content)
54 struct token *now;
55 int warned = 0;
57 now = lr_token (ldfile, charmap, NULL);
58 if (now->tok != tok_string)
59 lr_error (ldfile, _("expect string argument for `copy'"));
60 else if (!ignore_content)
62 if (now->val.str.startmb == NULL)
63 lr_error (ldfile, _("\
64 locale name should consist only of portable characters"));
65 else
67 (void) add_to_readlist (locale, now->val.str.startmb,
68 repertoire->name, 1);
69 result->copy_name[locale] = now->val.str.startmb;
73 lr_ignore_rest (ldfile, now->tok == tok_string);
75 /* The rest of the line must be empty and the next keyword must be
76 `END xxx'. */
77 while ((now = lr_token (ldfile, charmap, NULL))->tok != tok_end
78 && now->tok != tok_eof)
80 if (warned == 0)
82 lr_error (ldfile, _("\
83 no other keyword shall be specified when `copy' is used"));
84 warned = 1;
87 lr_ignore_rest (ldfile, 0);
90 if (now->tok != tok_eof)
92 /* Handle `END xxx'. */
93 now = lr_token (ldfile, charmap, NULL);
95 if (now->tok != token)
96 lr_error (ldfile, _("\
97 `%1$s' definition does not end with `END %1$s'"), locale_name);
99 lr_ignore_rest (ldfile, now->tok == token);
101 else
102 /* When we come here we reached the end of the file. */
103 lr_error (ldfile, _("%s: premature end of file"), locale_name);
107 /* Found in locfile.c. */
108 extern int locfile_read (struct localedef_t *result,
109 struct charmap_t *charmap);
111 /* Check validity of all the locale data. */
112 extern void check_all_categories (struct localedef_t *definitions,
113 struct charmap_t *charmap);
115 /* Write out all locale categories. */
116 extern void write_all_categories (struct localedef_t *definitions,
117 struct charmap_t *charmap,
118 const char *output_path);
120 /* Write out the data. */
121 extern void write_locale_data (const char *output_path, const char *category,
122 size_t n_elem, struct iovec *vec);
125 /* Entrypoints for the parsers of the individual categories. */
127 /* Handle LC_CTYPE category. */
128 extern void ctype_read (struct linereader *ldfile,
129 struct localedef_t *result,
130 struct charmap_t *charmap,
131 const char *repertoire_name,
132 int ignore_content);
133 extern void ctype_finish (struct localedef_t *locale,
134 struct charmap_t *charmap);
135 extern void ctype_output (struct localedef_t *locale,
136 struct charmap_t *charmap,
137 const char *output_path);
139 /* Handle LC_COLLATE category. */
140 extern void collate_read (struct linereader *ldfile,
141 struct localedef_t *result,
142 struct charmap_t *charmap,
143 const char *repertoire_name,
144 int ignore_content);
145 extern void collate_finish (struct localedef_t *locale,
146 struct charmap_t *charmap);
147 extern void collate_output (struct localedef_t *locale,
148 struct charmap_t *charmap,
149 const char *output_path);
151 /* Handle LC_MONETARY category. */
152 extern void monetary_read (struct linereader *ldfile,
153 struct localedef_t *result,
154 struct charmap_t *charmap,
155 const char *repertoire_name,
156 int ignore_content);
157 extern void monetary_finish (struct localedef_t *locale,
158 struct charmap_t *charmap);
159 extern void monetary_output (struct localedef_t *locale,
160 struct charmap_t *charmap,
161 const char *output_path);
163 /* Handle LC_NUMERIC category. */
164 extern void numeric_read (struct linereader *ldfile,
165 struct localedef_t *result,
166 struct charmap_t *charmap,
167 const char *repertoire_name,
168 int ignore_content);
169 extern void numeric_finish (struct localedef_t *locale,
170 struct charmap_t *charmap);
171 extern void numeric_output (struct localedef_t *locale,
172 struct charmap_t *charmap,
173 const char *output_path);
175 /* Handle LC_MESSAGES category. */
176 extern void messages_read (struct linereader *ldfile,
177 struct localedef_t *result,
178 struct charmap_t *charmap,
179 const char *repertoire_name,
180 int ignore_content);
181 extern void messages_finish (struct localedef_t *locale,
182 struct charmap_t *charmap);
183 extern void messages_output (struct localedef_t *locale,
184 struct charmap_t *charmap,
185 const char *output_path);
187 /* Handle LC_TIME category. */
188 extern void time_read (struct linereader *ldfile,
189 struct localedef_t *result,
190 struct charmap_t *charmap,
191 const char *repertoire_name,
192 int ignore_content);
193 extern void time_finish (struct localedef_t *locale,
194 struct charmap_t *charmap);
195 extern void time_output (struct localedef_t *locale,
196 struct charmap_t *charmap,
197 const char *output_path);
199 /* Handle LC_PAPER category. */
200 extern void paper_read (struct linereader *ldfile,
201 struct localedef_t *result,
202 struct charmap_t *charmap,
203 const char *repertoire_name,
204 int ignore_content);
205 extern void paper_finish (struct localedef_t *locale,
206 struct charmap_t *charmap);
207 extern void paper_output (struct localedef_t *locale,
208 struct charmap_t *charmap,
209 const char *output_path);
211 /* Handle LC_NAME category. */
212 extern void name_read (struct linereader *ldfile,
213 struct localedef_t *result,
214 struct charmap_t *charmap,
215 const char *repertoire_name,
216 int ignore_content);
217 extern void name_finish (struct localedef_t *locale,
218 struct charmap_t *charmap);
219 extern void name_output (struct localedef_t *locale,
220 struct charmap_t *charmap,
221 const char *output_path);
223 /* Handle LC_ADDRESS category. */
224 extern void address_read (struct linereader *ldfile,
225 struct localedef_t *result,
226 struct charmap_t *charmap,
227 const char *repertoire_name,
228 int ignore_content);
229 extern void address_finish (struct localedef_t *locale,
230 struct charmap_t *charmap);
231 extern void address_output (struct localedef_t *locale,
232 struct charmap_t *charmap,
233 const char *output_path);
235 /* Handle LC_TELEPHONE category. */
236 extern void telephone_read (struct linereader *ldfile,
237 struct localedef_t *result,
238 struct charmap_t *charmap,
239 const char *repertoire_name,
240 int ignore_content);
241 extern void telephone_finish (struct localedef_t *locale,
242 struct charmap_t *charmap);
243 extern void telephone_output (struct localedef_t *locale,
244 struct charmap_t *charmap,
245 const char *output_path);
247 /* Handle LC_MEASUREMENT category. */
248 extern void measurement_read (struct linereader *ldfile,
249 struct localedef_t *result,
250 struct charmap_t *charmap,
251 const char *repertoire_name,
252 int ignore_content);
253 extern void measurement_finish (struct localedef_t *locale,
254 struct charmap_t *charmap);
255 extern void measurement_output (struct localedef_t *locale,
256 struct charmap_t *charmap,
257 const char *output_path);
259 /* Handle LC_IDENTIFICATION category. */
260 extern void identification_read (struct linereader *ldfile,
261 struct localedef_t *result,
262 struct charmap_t *charmap,
263 const char *repertoire_name,
264 int ignore_content);
265 extern void identification_finish (struct localedef_t *locale,
266 struct charmap_t *charmap);
267 extern void identification_output (struct localedef_t *locale,
268 struct charmap_t *charmap,
269 const char *output_path);
271 #endif /* locfile.h */