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