]>
Commit | Line | Data |
---|---|---|
4b10dd6c | 1 | /* General definitions for localedef(1). |
ec09c1c4 | 2 | Copyright (C) 1998-2002,2005,2012 Free Software Foundation, Inc. |
4b10dd6c UD |
3 | This file is part of the GNU C Library. |
4 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. | |
5 | ||
43bc8ac6 | 6 | This program is free software; you can redistribute it and/or modify |
2e2efe65 RM |
7 | it under the terms of the GNU General Public License as published |
8 | by the Free Software Foundation; version 2 of the License, or | |
9 | (at your option) any later version. | |
4b10dd6c | 10 | |
43bc8ac6 | 11 | This program is distributed in the hope that it will be useful, |
4b10dd6c | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
43bc8ac6 UD |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | |
4b10dd6c | 15 | |
43bc8ac6 UD |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software Foundation, | |
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
4b10dd6c UD |
19 | |
20 | #ifndef _LOCALEDEF_H | |
21 | #define _LOCALEDEF_H 1 | |
22 | ||
23 | /* Get the basic locale definitions. */ | |
a7b65cdc | 24 | #include <errno.h> |
4b10dd6c | 25 | #include <locale.h> |
a7b65cdc | 26 | #include <stdbool.h> |
4b10dd6c UD |
27 | #include <stddef.h> |
28 | ||
29 | #include "repertoire.h" | |
a7b65cdc | 30 | #include "../locarchive.h" |
4b10dd6c UD |
31 | |
32 | ||
33 | /* We need a bitmask for the locales. */ | |
34 | enum | |
35 | { | |
36 | CTYPE_LOCALE = 1 << LC_CTYPE, | |
37 | NUMERIC_LOCALE = 1 << LC_NUMERIC, | |
38 | TIME_LOCALE = 1 << LC_TIME, | |
39 | COLLATE_LOCALE = 1 << LC_COLLATE, | |
40 | MONETARY_LOCALE = 1 << LC_MONETARY, | |
41 | MESSAGES_LOCALE = 1 << LC_MESSAGES, | |
42 | PAPER_LOCALE = 1 << LC_PAPER, | |
43 | NAME_LOCALE = 1 << LC_NAME, | |
44 | ADDRESS_LOCALE = 1 << LC_ADDRESS, | |
45 | TELEPHONE_LOCALE = 1 << LC_TELEPHONE, | |
46 | MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT, | |
47 | IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION, | |
48 | ALL_LOCALES = (1 << LC_CTYPE | |
49 | | 1 << LC_NUMERIC | |
50 | | 1 << LC_TIME | |
51 | | 1 << LC_COLLATE | |
52 | | 1 << LC_MONETARY | |
53 | | 1 << LC_MESSAGES | |
54 | | 1 << LC_PAPER | |
55 | | 1 << LC_NAME | |
56 | | 1 << LC_ADDRESS | |
57 | | 1 << LC_TELEPHONE | |
58 | | 1 << LC_MEASUREMENT | |
59 | | 1 << LC_IDENTIFICATION) | |
60 | }; | |
61 | ||
62 | ||
63 | /* Opaque types for the different locales. */ | |
64 | struct locale_ctype_t; | |
65 | struct locale_collate_t; | |
66 | struct locale_monetary_t; | |
67 | struct locale_numeric_t; | |
68 | struct locale_time_t; | |
69 | struct locale_messages_t; | |
70 | struct locale_paper_t; | |
71 | struct locale_name_t; | |
72 | struct locale_address_t; | |
73 | struct locale_telephone_t; | |
74 | struct locale_measurement_t; | |
75 | struct locale_identification_t; | |
76 | ||
77 | ||
78 | /* Definitions for the locale. */ | |
79 | struct localedef_t | |
80 | { | |
81 | struct localedef_t *next; | |
82 | ||
83 | const char *name; | |
84 | ||
85 | int needed; | |
86 | int avail; | |
87 | ||
88 | union | |
89 | { | |
90 | void *generic; | |
91 | struct locale_ctype_t *ctype; | |
92 | struct locale_collate_t *collate; | |
93 | struct locale_monetary_t *monetary; | |
94 | struct locale_numeric_t *numeric; | |
95 | struct locale_time_t *time; | |
96 | struct locale_messages_t *messages; | |
97 | struct locale_paper_t *paper; | |
98 | struct locale_name_t *name; | |
99 | struct locale_address_t *address; | |
100 | struct locale_telephone_t *telephone; | |
101 | struct locale_measurement_t *measurement; | |
102 | struct locale_identification_t *identification; | |
b9eb05d6 | 103 | } categories[__LC_LAST]; |
4b10dd6c | 104 | |
b9eb05d6 UD |
105 | size_t len[__LC_LAST]; |
106 | ||
107 | const char *copy_name[__LC_LAST]; | |
4b10dd6c UD |
108 | |
109 | const char *repertoire_name; | |
110 | }; | |
111 | ||
112 | ||
113 | /* Global variables of the localedef program. */ | |
114 | extern int verbose; | |
115 | extern int be_quiet; | |
ef446144 | 116 | extern int oldstyle_tables; |
4b10dd6c | 117 | extern const char *repertoire_global; |
a7b65cdc UD |
118 | extern int max_locarchive_open_retry; |
119 | extern bool no_archive; | |
cb09a2cd | 120 | extern const char *alias_file; |
4b10dd6c UD |
121 | |
122 | ||
123 | /* Prototypes for a few program-wide used functions. */ | |
ec09c1c4 UD |
124 | extern void *xmalloc (size_t n) |
125 | __attribute_malloc__ __attribute_alloc_size (1); | |
126 | extern void *xcalloc (size_t n, size_t s) | |
127 | __attribute_malloc__ __attribute_alloc_size (1, 2); | |
128 | extern void *xrealloc (void *o, size_t n) | |
129 | __attribute_malloc__ __attribute_alloc_size (2); | |
130 | extern char *xstrdup (const char *) __attribute_malloc__; | |
4b10dd6c UD |
131 | |
132 | ||
f2b98f97 UD |
133 | /* Wrapper to switch LC_CTYPE back to the locale specified in the |
134 | environment for output. */ | |
135 | #define WITH_CUR_LOCALE(stmt) \ | |
136 | do { \ | |
137 | int saved_errno = errno; \ | |
138 | const char *cur_locale_ = setlocale (LC_CTYPE, NULL); \ | |
139 | setlocale (LC_CTYPE, ""); \ | |
140 | errno = saved_errno; \ | |
141 | stmt; \ | |
142 | setlocale (LC_CTYPE, cur_locale_); \ | |
143 | } while (0) | |
144 | ||
145 | ||
4b10dd6c UD |
146 | /* Mark given locale as to be read. */ |
147 | extern struct localedef_t *add_to_readlist (int locale, const char *name, | |
b9eb05d6 | 148 | const char *repertoire_name, |
07dab0c3 UD |
149 | int generate, |
150 | struct localedef_t *copy_locale); | |
4b10dd6c UD |
151 | |
152 | /* Find the information for the locale NAME. */ | |
153 | extern struct localedef_t *find_locale (int locale, const char *name, | |
154 | const char *repertoire_name, | |
47e8b443 | 155 | const struct charmap_t *charmap); |
4b10dd6c | 156 | |
70e51ab9 UD |
157 | /* Load (if necessary) the information for the locale NAME. */ |
158 | extern struct localedef_t *load_locale (int locale, const char *name, | |
159 | const char *repertoire_name, | |
47e8b443 | 160 | const struct charmap_t *charmap, |
07dab0c3 | 161 | struct localedef_t *copy_locale); |
70e51ab9 | 162 | |
a7b65cdc UD |
163 | |
164 | /* Open the locale archive. */ | |
b2bffca2 | 165 | extern void open_archive (struct locarhandle *ah, bool readonly); |
a7b65cdc UD |
166 | |
167 | /* Close the locale archive. */ | |
168 | extern void close_archive (struct locarhandle *ah); | |
169 | ||
170 | /* Add given locale data to the archive. */ | |
171 | extern int add_locale_to_archive (struct locarhandle *ah, const char *name, | |
172 | locale_data_t data, bool replace); | |
173 | ||
174 | /* Add content of named directories to locale archive. */ | |
175 | extern int add_locales_to_archive (size_t nlist, char *list[], bool replace); | |
176 | ||
177 | /* Removed named locales from archive. */ | |
178 | extern int delete_locales_from_archive (size_t nlist, char *list[]); | |
179 | ||
180 | /* List content of locale archive. */ | |
b2bffca2 | 181 | extern void show_archive_content (int verbose); |
a7b65cdc | 182 | |
4b10dd6c | 183 | #endif /* localedef.h */ |