]>
Commit | Line | Data |
---|---|---|
4b10dd6c | 1 | /* General definitions for localedef(1). |
b168057a | 2 | Copyright (C) 1998-2015 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 | 16 | You should have received a copy of the GNU General Public License |
59ba27a6 | 17 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
4b10dd6c UD |
18 | |
19 | #ifndef _LOCALEDEF_H | |
20 | #define _LOCALEDEF_H 1 | |
21 | ||
22 | /* Get the basic locale definitions. */ | |
a7b65cdc | 23 | #include <errno.h> |
4b10dd6c | 24 | #include <locale.h> |
a7b65cdc | 25 | #include <stdbool.h> |
4b10dd6c UD |
26 | #include <stddef.h> |
27 | ||
28 | #include "repertoire.h" | |
a7b65cdc | 29 | #include "../locarchive.h" |
4b10dd6c UD |
30 | |
31 | ||
32 | /* We need a bitmask for the locales. */ | |
33 | enum | |
34 | { | |
35 | CTYPE_LOCALE = 1 << LC_CTYPE, | |
36 | NUMERIC_LOCALE = 1 << LC_NUMERIC, | |
37 | TIME_LOCALE = 1 << LC_TIME, | |
38 | COLLATE_LOCALE = 1 << LC_COLLATE, | |
39 | MONETARY_LOCALE = 1 << LC_MONETARY, | |
40 | MESSAGES_LOCALE = 1 << LC_MESSAGES, | |
41 | PAPER_LOCALE = 1 << LC_PAPER, | |
42 | NAME_LOCALE = 1 << LC_NAME, | |
43 | ADDRESS_LOCALE = 1 << LC_ADDRESS, | |
44 | TELEPHONE_LOCALE = 1 << LC_TELEPHONE, | |
45 | MEASUREMENT_LOCALE = 1 << LC_MEASUREMENT, | |
46 | IDENTIFICATION_LOCALE = 1 << LC_IDENTIFICATION, | |
47 | ALL_LOCALES = (1 << LC_CTYPE | |
48 | | 1 << LC_NUMERIC | |
49 | | 1 << LC_TIME | |
50 | | 1 << LC_COLLATE | |
51 | | 1 << LC_MONETARY | |
52 | | 1 << LC_MESSAGES | |
53 | | 1 << LC_PAPER | |
54 | | 1 << LC_NAME | |
55 | | 1 << LC_ADDRESS | |
56 | | 1 << LC_TELEPHONE | |
57 | | 1 << LC_MEASUREMENT | |
58 | | 1 << LC_IDENTIFICATION) | |
59 | }; | |
60 | ||
61 | ||
62 | /* Opaque types for the different locales. */ | |
63 | struct locale_ctype_t; | |
64 | struct locale_collate_t; | |
65 | struct locale_monetary_t; | |
66 | struct locale_numeric_t; | |
67 | struct locale_time_t; | |
68 | struct locale_messages_t; | |
69 | struct locale_paper_t; | |
70 | struct locale_name_t; | |
71 | struct locale_address_t; | |
72 | struct locale_telephone_t; | |
73 | struct locale_measurement_t; | |
74 | struct locale_identification_t; | |
75 | ||
76 | ||
77 | /* Definitions for the locale. */ | |
78 | struct localedef_t | |
79 | { | |
80 | struct localedef_t *next; | |
81 | ||
82 | const char *name; | |
83 | ||
84 | int needed; | |
85 | int avail; | |
86 | ||
87 | union | |
88 | { | |
89 | void *generic; | |
90 | struct locale_ctype_t *ctype; | |
91 | struct locale_collate_t *collate; | |
92 | struct locale_monetary_t *monetary; | |
93 | struct locale_numeric_t *numeric; | |
94 | struct locale_time_t *time; | |
95 | struct locale_messages_t *messages; | |
96 | struct locale_paper_t *paper; | |
97 | struct locale_name_t *name; | |
98 | struct locale_address_t *address; | |
99 | struct locale_telephone_t *telephone; | |
100 | struct locale_measurement_t *measurement; | |
101 | struct locale_identification_t *identification; | |
b9eb05d6 | 102 | } categories[__LC_LAST]; |
4b10dd6c | 103 | |
b9eb05d6 UD |
104 | size_t len[__LC_LAST]; |
105 | ||
106 | const char *copy_name[__LC_LAST]; | |
4b10dd6c UD |
107 | |
108 | const char *repertoire_name; | |
109 | }; | |
110 | ||
111 | ||
112 | /* Global variables of the localedef program. */ | |
113 | extern int verbose; | |
114 | extern int be_quiet; | |
ef446144 | 115 | extern int oldstyle_tables; |
4b10dd6c | 116 | extern const char *repertoire_global; |
a7b65cdc UD |
117 | extern int max_locarchive_open_retry; |
118 | extern bool no_archive; | |
cb09a2cd | 119 | extern const char *alias_file; |
4b10dd6c UD |
120 | |
121 | ||
122 | /* Prototypes for a few program-wide used functions. */ | |
6ff444c4 | 123 | #include <programs/xmalloc.h> |
4b10dd6c UD |
124 | |
125 | ||
f2b98f97 UD |
126 | /* Wrapper to switch LC_CTYPE back to the locale specified in the |
127 | environment for output. */ | |
128 | #define WITH_CUR_LOCALE(stmt) \ | |
129 | do { \ | |
130 | int saved_errno = errno; \ | |
131 | const char *cur_locale_ = setlocale (LC_CTYPE, NULL); \ | |
132 | setlocale (LC_CTYPE, ""); \ | |
133 | errno = saved_errno; \ | |
134 | stmt; \ | |
135 | setlocale (LC_CTYPE, cur_locale_); \ | |
136 | } while (0) | |
137 | ||
138 | ||
4b10dd6c UD |
139 | /* Mark given locale as to be read. */ |
140 | extern struct localedef_t *add_to_readlist (int locale, const char *name, | |
b9eb05d6 | 141 | const char *repertoire_name, |
07dab0c3 UD |
142 | int generate, |
143 | struct localedef_t *copy_locale); | |
4b10dd6c UD |
144 | |
145 | /* Find the information for the locale NAME. */ | |
146 | extern struct localedef_t *find_locale (int locale, const char *name, | |
147 | const char *repertoire_name, | |
47e8b443 | 148 | const struct charmap_t *charmap); |
4b10dd6c | 149 | |
70e51ab9 UD |
150 | /* Load (if necessary) the information for the locale NAME. */ |
151 | extern struct localedef_t *load_locale (int locale, const char *name, | |
152 | const char *repertoire_name, | |
47e8b443 | 153 | const struct charmap_t *charmap, |
07dab0c3 | 154 | struct localedef_t *copy_locale); |
70e51ab9 | 155 | |
a7b65cdc UD |
156 | |
157 | /* Open the locale archive. */ | |
b2bffca2 | 158 | extern void open_archive (struct locarhandle *ah, bool readonly); |
a7b65cdc UD |
159 | |
160 | /* Close the locale archive. */ | |
161 | extern void close_archive (struct locarhandle *ah); | |
162 | ||
163 | /* Add given locale data to the archive. */ | |
164 | extern int add_locale_to_archive (struct locarhandle *ah, const char *name, | |
165 | locale_data_t data, bool replace); | |
166 | ||
167 | /* Add content of named directories to locale archive. */ | |
168 | extern int add_locales_to_archive (size_t nlist, char *list[], bool replace); | |
169 | ||
170 | /* Removed named locales from archive. */ | |
171 | extern int delete_locales_from_archive (size_t nlist, char *list[]); | |
172 | ||
484c12fb CD |
173 | /* List content of locale archive. If FNAME is non-null use that as |
174 | the locale archive to list, otherwise the default. */ | |
175 | extern void show_archive_content (const char *fname, | |
176 | int verbose) __attribute__ ((noreturn)); | |
a7b65cdc | 177 | |
4b10dd6c | 178 | #endif /* localedef.h */ |