.
[glibc/history.git] / locale / localedef.h
blob5958a9c5d218c28d4dd8adacb8afb1fe738129d0
1 /* Copyright (C) 1995 Free Software Foundation, Inc.
3 The GNU C Library is free software; you can redistribute it and/or
4 modify it under the terms of the GNU Library General Public License as
5 published by the Free Software Foundation; either version 2 of the
6 License, or (at your option) any later version.
8 The GNU C Library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public
14 License along with the GNU C Library; see the file COPYING.LIB. If
15 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16 Cambridge, MA 02139, USA. */
18 #ifndef _LOCALEDEF_H
19 #define _LOCALEDEF_H 1
21 #define __need_wchar_t
22 #include <stddef.h>
24 #include "config.h"
26 #include "hash.h"
29 /* Needed always. */
30 #define MAX(a, b) ({typeof (a) _a = (a); typeof (b) _b = (b); \
31 _a > _b ? _a : _b; })
32 #define MIN(a, b) ({typeof (a) _a = (a); typeof (b) _b = (b); \
33 _a < _b ? _a : _b; })
35 /* Determine number of elements in ARR. */
36 #define NELEMS(arr) ((sizeof (arr)) / (sizeof (arr[0])))
38 /* I simply love these GCC features ... :) */
39 #define NO_PAREN(arg, rest...) arg, ##rest
42 /* The character set used in the locale is defined in a character map file.
43 The information of the file is stored in the following struct. */
44 struct charmap
46 char *filename;
47 char *codeset_name;
48 int mb_cur_min;
49 int mb_cur_max;
50 char escape_char;
51 char comment_char;
52 hash_table table;
53 int hash_size;
54 int hash_layers;
57 /* Data structure for representing charmap database. */
58 extern struct charmap charmap_data;
61 /* We can map the types of the entries into four categories. */
62 enum value_type { none, string, stringarray, byte, bytearray, integer };
64 /* Definition of the data structure which represents a category and its
65 items. */
66 struct category
68 int cat_id;
69 const char *name;
70 size_t number;
71 struct cat_item
73 int item_id;
74 const char *name;
75 enum { std, opt } status;
76 enum value_type value_type;
77 int min;
78 int max;
79 } *item_desc;
80 char **item_value;
81 void (*infct)(int);
82 void (*checkfct)(void);
83 int (*outfct)(void);
84 int filled;
85 char *copy_locale;
88 /* This a the structure which contains all information about all
89 categories. */
90 extern struct category category[];
93 /* The function used to load the contents of a charmap file into the
94 the global variable `charmap_data'. */
95 void charmap_read (const char *filename);
97 /* Find a character constant given by its name in the hash table. */
98 static inline wchar_t find_char (const char *name, size_t len)
100 wchar_t retval;
101 if (find_entry (&charmap_data.table, name, len, (void **) &retval) != 0)
102 return retval;
103 else
104 return -1;
107 /* Path to the directory the output files are written in. */
108 extern char *output_path;
110 /* If this is defined be POSIX conform. */
111 extern int posix_conformance;
113 /* If not zero give a lot more messages. */
114 extern int verbose;
116 /* This structure contains all informations about the status of of
117 reading the locale definition file. */
118 struct locfile_data
120 const char *filename;
121 char escape_char;
122 char comment_char;
123 size_t bufsize;
124 char *buf;
125 char *strbuf;
126 size_t buf_ptr;
127 int continue_line;
128 size_t returned_tokens;
129 size_t line_no;
132 /* The status variable. */
133 extern struct locfile_data locfile_data;
135 /* Open the locale definition file. */
136 void locfile_open (const char *fname);
138 /* Return the next token from the locale definition file. */
139 int locfile_lex (char **token, int *token_len);
140 /* Dito, but check for EOF. */
141 int xlocfile_lex (char **token, int *token_len);
143 /* Ignore the rest of the line. First TOKEN given if != 0. Warn about
144 anything other than end of line if WARN_FLAG nonzero. */
145 void ignore_to_eol (int token, int warn_flag);
147 /* Code a character with UTF-8 if the character map has multi-byte
148 characters. */
149 int char_to_utf (char *buf, int char_val);
152 /* Read the locale defintion file FNAME and fill the appropriate
153 data structures. */
154 void locfile_read (const char *fname);
156 /* Check categories for consistency. */
157 void categories_check (void);
159 /* Write out the binary representation of the category data. */
160 void categories_write (void);
163 /* Treat reading the LC_COLLATE definition. */
164 void collate_input (int token);
166 /* Treat reading the LC_CTYPE definition. */
167 void ctype_input (int token);
168 void ctype_check (void);
169 int ctype_output (void);
171 /* Treat reading the LC_MONETARY definition. */
172 void monetary_check (void);
174 /* Treat reading the LC_MESSAGES definition. */
175 void messages_check (void);
177 /* Treat reading the LC_NUMERIC definition. */
178 void numeric_check (void);
181 /* Print an error message, possibly with NLS. */
182 void error (int status, int errnum, const char *format, ...)
183 __attribute__ ((format (printf, 3, 4)));
185 /* Library functions. */
186 void *xmalloc (size_t n);
187 void *xcalloc (size_t n, size_t s);
188 void *xrealloc (void *p, size_t n);
191 * Local Variables:
192 * mode:c
193 * c-basic-offset:2
194 * End:
196 #endif /* _LOCALEDEF_H */