malloc: add glibc compat symbols
[uclibc-ng.git] / include / locale.h
blob3cd6f5ef356751eb8d7989ae78cfd97f0febc786
1 /* Copyright (C) 1991,1992,1995-2002,2007,2009 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
19 * ISO C99 Standard: 7.11 Localization <locale.h>
22 #ifndef _LOCALE_H
23 #define _LOCALE_H 1
25 #include <features.h>
27 #define __need_NULL
28 #include <stddef.h>
29 #include <bits/uClibc_locale.h>
31 __BEGIN_DECLS
33 /* These are the possibilities for the first argument to setlocale.
34 The code assumes that the lowest LC_* symbol has the value zero. */
35 #define LC_CTYPE __LC_CTYPE
36 #define LC_NUMERIC __LC_NUMERIC
37 #define LC_TIME __LC_TIME
38 #define LC_COLLATE __LC_COLLATE
39 #define LC_MONETARY __LC_MONETARY
40 #define LC_MESSAGES __LC_MESSAGES
41 #define LC_ALL __LC_ALL
42 #if 0
43 #define LC_PAPER __LC_PAPER
44 #define LC_NAME __LC_NAME
45 #define LC_ADDRESS __LC_ADDRESS
46 #define LC_TELEPHONE __LC_TELEPHONE
47 #define LC_MEASUREMENT __LC_MEASUREMENT
48 #define LC_IDENTIFICATION __LC_IDENTIFICATION
49 #endif
52 __BEGIN_NAMESPACE_STD
54 /* Structure giving information about numeric and monetary notation. */
55 struct lconv
57 /* Numeric (non-monetary) information. */
59 char *decimal_point; /* Decimal point character. */
60 char *thousands_sep; /* Thousands separator. */
61 /* Each element is the number of digits in each group;
62 elements with higher indices are farther left.
63 An element with value CHAR_MAX means that no further grouping is done.
64 An element with value 0 means that the previous element is used
65 for all groups farther left. */
66 char *grouping;
68 /* Monetary information. */
70 /* First three chars are a currency symbol from ISO 4217.
71 Fourth char is the separator. Fifth char is '\0'. */
72 char *int_curr_symbol;
73 char *currency_symbol; /* Local currency symbol. */
74 char *mon_decimal_point; /* Decimal point character. */
75 char *mon_thousands_sep; /* Thousands separator. */
76 char *mon_grouping; /* Like `grouping' element (above). */
77 char *positive_sign; /* Sign for positive values. */
78 char *negative_sign; /* Sign for negative values. */
79 char int_frac_digits; /* Int'l fractional digits. */
80 char frac_digits; /* Local fractional digits. */
81 /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */
82 char p_cs_precedes;
83 /* 1 iff a space separates currency_symbol from a positive value. */
84 char p_sep_by_space;
85 /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */
86 char n_cs_precedes;
87 /* 1 iff a space separates currency_symbol from a negative value. */
88 char n_sep_by_space;
89 /* Positive and negative sign positions:
90 0 Parentheses surround the quantity and currency_symbol.
91 1 The sign string precedes the quantity and currency_symbol.
92 2 The sign string follows the quantity and currency_symbol.
93 3 The sign string immediately precedes the currency_symbol.
94 4 The sign string immediately follows the currency_symbol. */
95 char p_sign_posn;
96 char n_sign_posn;
97 #ifdef __USE_ISOC99
98 /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */
99 char int_p_cs_precedes;
100 /* 1 iff a space separates int_curr_symbol from a positive value. */
101 char int_p_sep_by_space;
102 /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */
103 char int_n_cs_precedes;
104 /* 1 iff a space separates int_curr_symbol from a negative value. */
105 char int_n_sep_by_space;
106 /* Positive and negative sign positions:
107 0 Parentheses surround the quantity and int_curr_symbol.
108 1 The sign string precedes the quantity and int_curr_symbol.
109 2 The sign string follows the quantity and int_curr_symbol.
110 3 The sign string immediately precedes the int_curr_symbol.
111 4 The sign string immediately follows the int_curr_symbol. */
112 char int_p_sign_posn;
113 char int_n_sign_posn;
114 #else
115 char __int_p_cs_precedes;
116 char __int_p_sep_by_space;
117 char __int_n_cs_precedes;
118 char __int_n_sep_by_space;
119 char __int_p_sign_posn;
120 char __int_n_sign_posn;
121 #endif
125 /* Set and/or return the current locale. */
126 extern char *setlocale (int __category, const char *__locale) __THROW;
128 /* Return the numeric/monetary information for the current locale. */
129 extern struct lconv *localeconv (void) __THROW;
130 libc_hidden_proto(localeconv)
132 __END_NAMESPACE_STD
135 #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_XLOCALE__
136 /* The concept of one static locale per category is not very well
137 thought out. Many applications will need to process its data using
138 information from several different locales. Another application is
139 the implementation of the internationalization handling in the
140 upcoming ISO C++ standard library. To support this another set of
141 the functions using locale data exist which have an additional
142 argument.
144 Attention: all these functions are *not* standardized in any form.
145 This is a proof-of-concept implementation. */
147 /* Get locale datatype definition. */
148 # include <xlocale.h>
150 /* Return a reference to a data structure representing a set of locale
151 datasets. Unlike for the CATEGORY parameter for `setlocale' the
152 CATEGORY_MASK parameter here uses a single bit for each category,
153 made by OR'ing together LC_*_MASK bits above. */
154 extern __locale_t newlocale (int __category_mask, const char *__locale,
155 __locale_t __base) __THROW;
156 libc_hidden_proto(newlocale)
158 /* These are the bits that can be set in the CATEGORY_MASK argument to
159 `newlocale'. In the GNU implementation, LC_FOO_MASK has the value
160 of (1 << LC_FOO), but this is not a part of the interface that
161 callers can assume will be true. */
162 # define LC_CTYPE_MASK (1 << __LC_CTYPE)
163 # define LC_NUMERIC_MASK (1 << __LC_NUMERIC)
164 # define LC_TIME_MASK (1 << __LC_TIME)
165 # define LC_COLLATE_MASK (1 << __LC_COLLATE)
166 # define LC_MONETARY_MASK (1 << __LC_MONETARY)
167 # define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
168 #ifdef LC_PAPER
169 # define LC_PAPER_MASK (1 << __LC_PAPER)
170 # define LC_NAME_MASK (1 << __LC_NAME)
171 # define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
172 # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
173 # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
174 # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
175 # define LC_ALL_MASK (LC_CTYPE_MASK \
176 | LC_NUMERIC_MASK \
177 | LC_TIME_MASK \
178 | LC_COLLATE_MASK \
179 | LC_MONETARY_MASK \
180 | LC_MESSAGES_MASK \
181 | LC_PAPER_MASK \
182 | LC_NAME_MASK \
183 | LC_ADDRESS_MASK \
184 | LC_TELEPHONE_MASK \
185 | LC_MEASUREMENT_MASK \
186 | LC_IDENTIFICATION_MASK \
188 #else /* LC_PAPER */
189 # define LC_ALL_MASK (LC_CTYPE_MASK \
190 | LC_NUMERIC_MASK \
191 | LC_TIME_MASK \
192 | LC_COLLATE_MASK \
193 | LC_MONETARY_MASK \
194 | LC_MESSAGES_MASK \
196 #endif /* LC_PAPER */
198 /* Return a duplicate of the set of locale in DATASET. All usage
199 counters are increased if necessary. */
200 extern __locale_t duplocale (__locale_t __dataset) __THROW;
202 /* Free the data associated with a locale dataset previously returned
203 by a call to `setlocale_r'. */
204 extern void freelocale (__locale_t __dataset) __THROW;
206 /* Switch the current thread's locale to DATASET.
207 If DATASET is null, instead just return the current setting.
208 The special value LC_GLOBAL_LOCALE is the initial setting
209 for all threads and can also be installed any time, meaning
210 the thread uses the global settings controlled by `setlocale'. */
211 extern __locale_t uselocale (__locale_t __dataset) __THROW;
212 libc_hidden_proto(uselocale)
214 /* This value can be passed to `uselocale' and may be returned by it.
215 Passing this value to any other function has undefined behavior. */
216 # define LC_GLOBAL_LOCALE ((__locale_t) -1L)
218 #endif
220 __END_DECLS
222 #endif /* locale.h */