]> git.ipfire.org Git - thirdparty/glibc.git/blame - locale/localedef.h
Wed Mar 27 14:52:11 1996 Roland McGrath <roland@charlie-brown.gnu.ai.mit.edu>
[thirdparty/glibc.git] / locale / localedef.h
CommitLineData
2b83a2a4
RM
1/* Copyright (C) 1995 Free Software Foundation, Inc.
2
3The GNU C Library is free software; you can redistribute it and/or
4modify it under the terms of the GNU Library General Public License as
5published by the Free Software Foundation; either version 2 of the
6License, or (at your option) any later version.
7
8The GNU C Library is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11Library General Public License for more details.
12
13You should have received a copy of the GNU Library General Public
14License along with the GNU C Library; see the file COPYING.LIB. If
15not, write to the Free Software Foundation, Inc., 675 Mass Ave,
16Cambridge, MA 02139, USA. */
17
18#ifndef _LOCALEDEF_H
19#define _LOCALEDEF_H 1
20
21#define __need_wchar_t
22#include <stddef.h>
23
24#include "config.h"
25
26#include "hash.h"
27
28
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; })
34
35/* Determine number of elements in ARR. */
36#define NELEMS(arr) ((sizeof (arr)) / (sizeof (arr[0])))
37
38/* I simply love these GCC features ... :) */
39#define NO_PAREN(arg, rest...) arg, ##rest
40
41
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. */
44struct charmap
45 {
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;
55 };
56
57/* Data structure for representing charmap database. */
58extern struct charmap charmap_data;
59
60
61/* We can map the types of the entries into four categories. */
62enum value_type { none, string, stringarray, byte, bytearray, integer };
63
64/* Definition of the data structure which represents a category and its
65 items. */
66struct category
67{
68 int cat_id;
69 const char *name;
70 size_t number;
71 struct cat_item
72 {
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;
86};
87
88/* This a the structure which contains all information about all
89 categories. */
90extern struct category category[];
91
92
93/* The function used to load the contents of a charmap file into the
94 the global variable `charmap_data'. */
95void charmap_read (const char *filename);
96
97/* Find a character constant given by its name in the hash table. */
98static inline wchar_t find_char (const char *name, size_t len)
99{
100 wchar_t retval;
101 if (find_entry (&charmap_data.table, name, len, (void **) &retval) != 0)
102 return retval;
103 else
104 return -1;
105}
106
107/* Path to the directory the output files are written in. */
108extern char *output_path;
109
110/* If this is defined be POSIX conform. */
111extern int posix_conformance;
112
113/* If not zero give a lot more messages. */
114extern int verbose;
115
116/* This structure contains all informations about the status of of
117 reading the locale definition file. */
118struct locfile_data
119 {
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;
130 };
131
132/* The status variable. */
133extern struct locfile_data locfile_data;
134
135/* Open the locale definition file. */
136void locfile_open (const char *fname);
137
138/* Return the next token from the locale definition file. */
139int locfile_lex (char **token, int *token_len);
140/* Dito, but check for EOF. */
141int xlocfile_lex (char **token, int *token_len);
142
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. */
145void ignore_to_eol (int token, int warn_flag);
146
147/* Code a character with UTF-8 if the character map has multi-byte
148 characters. */
149int char_to_utf (char *buf, int char_val);
150
151
152/* Read the locale defintion file FNAME and fill the appropriate
153 data structures. */
154void locfile_read (const char *fname);
155
156/* Check categories for consistency. */
157void categories_check (void);
158
159/* Write out the binary representation of the category data. */
160void categories_write (void);
161
162
163/* Treat reading the LC_COLLATE definition. */
164void collate_input (int token);
165
166/* Treat reading the LC_CTYPE definition. */
167void ctype_input (int token);
168void ctype_check (void);
169int ctype_output (void);
170
171/* Treat reading the LC_MONETARY definition. */
172void monetary_check (void);
173
174/* Treat reading the LC_MESSAGES definition. */
175void messages_check (void);
176
177/* Treat reading the LC_NUMERIC definition. */
178void numeric_check (void);
179
180
181/* Print an error message, possibly with NLS. */
182void error (int status, int errnum, const char *format, ...)
183 __attribute__ ((format (printf, 3, 4)));
184
185/* Library functions. */
186void *xmalloc (size_t n);
187void *xcalloc (size_t n, size_t s);
188void *xrealloc (void *p, size_t n);
189
190/*
191 * Local Variables:
192 * mode:c
193 * c-basic-offset:2
194 * End:
195 */
196#endif /* _LOCALEDEF_H */