]> git.ipfire.org Git - thirdparty/glibc.git/blob - locale/locale.h
Remove pre-ISO C support
[thirdparty/glibc.git] / locale / locale.h
1 /* Copyright (C) 1991,1992,1995-2002,2007,2009,2012
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 /*
21 * ISO C99 Standard: 7.11 Localization <locale.h>
22 */
23
24 #ifndef _LOCALE_H
25 #define _LOCALE_H 1
26
27 #include <features.h>
28
29 #define __need_NULL
30 #include <stddef.h>
31 #include <bits/locale.h>
32
33 __BEGIN_DECLS
34
35 /* These are the possibilities for the first argument to setlocale.
36 The code assumes that the lowest LC_* symbol has the value zero. */
37 #define LC_CTYPE __LC_CTYPE
38 #define LC_NUMERIC __LC_NUMERIC
39 #define LC_TIME __LC_TIME
40 #define LC_COLLATE __LC_COLLATE
41 #define LC_MONETARY __LC_MONETARY
42 #define LC_MESSAGES __LC_MESSAGES
43 #define LC_ALL __LC_ALL
44 #define LC_PAPER __LC_PAPER
45 #define LC_NAME __LC_NAME
46 #define LC_ADDRESS __LC_ADDRESS
47 #define LC_TELEPHONE __LC_TELEPHONE
48 #define LC_MEASUREMENT __LC_MEASUREMENT
49 #define LC_IDENTIFICATION __LC_IDENTIFICATION
50
51
52 __BEGIN_NAMESPACE_STD
53
54 /* Structure giving information about numeric and monetary notation. */
55 struct lconv
56 {
57 /* Numeric (non-monetary) information. */
58
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;
67
68 /* Monetary information. */
69
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
122 };
123
124
125 /* Set and/or return the current locale. */
126 extern char *setlocale (int __category, const char *__locale) __THROW;
127
128 /* Return the numeric/monetary information for the current locale. */
129 extern struct lconv *localeconv (void) __THROW;
130
131 __END_NAMESPACE_STD
132
133
134 #ifdef __USE_XOPEN2K8
135 /* The concept of one static locale per category is not very well
136 thought out. Many applications will need to process its data using
137 information from several different locales. Another application is
138 the implementation of the internationalization handling in the
139 upcoming ISO C++ standard library. To support this another set of
140 the functions using locale data exist which have an additional
141 argument.
142
143 Attention: all these functions are *not* standardized in any form.
144 This is a proof-of-concept implementation. */
145
146 /* Get locale datatype definition. */
147 # include <xlocale.h>
148
149 /* Return a reference to a data structure representing a set of locale
150 datasets. Unlike for the CATEGORY parameter for `setlocale' the
151 CATEGORY_MASK parameter here uses a single bit for each category,
152 made by OR'ing together LC_*_MASK bits above. */
153 extern __locale_t newlocale (int __category_mask, const char *__locale,
154 __locale_t __base) __THROW;
155
156 /* These are the bits that can be set in the CATEGORY_MASK argument to
157 `newlocale'. In the GNU implementation, LC_FOO_MASK has the value
158 of (1 << LC_FOO), but this is not a part of the interface that
159 callers can assume will be true. */
160 # define LC_CTYPE_MASK (1 << __LC_CTYPE)
161 # define LC_NUMERIC_MASK (1 << __LC_NUMERIC)
162 # define LC_TIME_MASK (1 << __LC_TIME)
163 # define LC_COLLATE_MASK (1 << __LC_COLLATE)
164 # define LC_MONETARY_MASK (1 << __LC_MONETARY)
165 # define LC_MESSAGES_MASK (1 << __LC_MESSAGES)
166 # define LC_PAPER_MASK (1 << __LC_PAPER)
167 # define LC_NAME_MASK (1 << __LC_NAME)
168 # define LC_ADDRESS_MASK (1 << __LC_ADDRESS)
169 # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE)
170 # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT)
171 # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
172 # define LC_ALL_MASK (LC_CTYPE_MASK \
173 | LC_NUMERIC_MASK \
174 | LC_TIME_MASK \
175 | LC_COLLATE_MASK \
176 | LC_MONETARY_MASK \
177 | LC_MESSAGES_MASK \
178 | LC_PAPER_MASK \
179 | LC_NAME_MASK \
180 | LC_ADDRESS_MASK \
181 | LC_TELEPHONE_MASK \
182 | LC_MEASUREMENT_MASK \
183 | LC_IDENTIFICATION_MASK \
184 )
185
186 /* Return a duplicate of the set of locale in DATASET. All usage
187 counters are increased if necessary. */
188 extern __locale_t duplocale (__locale_t __dataset) __THROW;
189
190 /* Free the data associated with a locale dataset previously returned
191 by a call to `setlocale_r'. */
192 extern void freelocale (__locale_t __dataset) __THROW;
193
194 /* Switch the current thread's locale to DATASET.
195 If DATASET is null, instead just return the current setting.
196 The special value LC_GLOBAL_LOCALE is the initial setting
197 for all threads and can also be installed any time, meaning
198 the thread uses the global settings controlled by `setlocale'. */
199 extern __locale_t uselocale (__locale_t __dataset) __THROW;
200
201 /* This value can be passed to `uselocale' and may be returned by it.
202 Passing this value to any other function has undefined behavior. */
203 # define LC_GLOBAL_LOCALE ((__locale_t) -1L)
204
205 #endif
206
207 __END_DECLS
208
209 #endif /* locale.h */