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. */
19 #define _LOCALEDEF_H 1
21 #define __need_wchar_t
30 #define MAX(a, b) ({typeof (a) _a = (a); typeof (b) _b = (b); \
32 #define MIN(a, b) ({typeof (a) _a = (a); typeof (b) _b = (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. */
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
75 enum { std
, opt
} status
;
76 enum value_type value_type
;
82 void (*checkfct
)(void);
88 /* This a the structure which contains all information about all
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
)
101 if (find_entry (&charmap_data
.table
, name
, len
, (void **) &retval
) != 0)
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. */
116 /* This structure contains all informations about the status of of
117 reading the locale definition file. */
120 const char *filename
;
128 size_t returned_tokens
;
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
149 int char_to_utf (char *buf
, int char_val
);
152 /* Read the locale defintion file FNAME and fill the appropriate
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
);
196 #endif /* _LOCALEDEF_H */