OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / uClibc / include / locale.h
1 /* Copyright (C) 1991,1992,1995-2002,2007,2009 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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.
8
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.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 /*
20  *      ISO C99 Standard: 7.11 Localization     <locale.h>
21  */
22
23 #ifndef _LOCALE_H
24 #define _LOCALE_H       1
25
26 #include <features.h>
27
28 #define __need_NULL
29 #include <stddef.h>
30 #include <bits/uClibc_locale.h>
31
32 __BEGIN_DECLS
33
34 /* These are the possibilities for the first argument to setlocale.
35    The code assumes that the lowest LC_* symbol has the value zero.  */
36 #define LC_CTYPE          __LC_CTYPE
37 #define LC_NUMERIC        __LC_NUMERIC
38 #define LC_TIME           __LC_TIME
39 #define LC_COLLATE        __LC_COLLATE
40 #define LC_MONETARY       __LC_MONETARY
41 #define LC_MESSAGES       __LC_MESSAGES
42 #define LC_ALL            __LC_ALL
43 #if 0
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 #endif
51
52
53 __BEGIN_NAMESPACE_STD
54
55 /* Structure giving information about numeric and monetary notation.  */
56 struct lconv
57 {
58   /* Numeric (non-monetary) information.  */
59
60   char *decimal_point;          /* Decimal point character.  */
61   char *thousands_sep;          /* Thousands separator.  */
62   /* Each element is the number of digits in each group;
63      elements with higher indices are farther left.
64      An element with value CHAR_MAX means that no further grouping is done.
65      An element with value 0 means that the previous element is used
66      for all groups farther left.  */
67   char *grouping;
68
69   /* Monetary information.  */
70
71   /* First three chars are a currency symbol from ISO 4217.
72      Fourth char is the separator.  Fifth char is '\0'.  */
73   char *int_curr_symbol;
74   char *currency_symbol;        /* Local currency symbol.  */
75   char *mon_decimal_point;      /* Decimal point character.  */
76   char *mon_thousands_sep;      /* Thousands separator.  */
77   char *mon_grouping;           /* Like `grouping' element (above).  */
78   char *positive_sign;          /* Sign for positive values.  */
79   char *negative_sign;          /* Sign for negative values.  */
80   char int_frac_digits;         /* Int'l fractional digits.  */
81   char frac_digits;             /* Local fractional digits.  */
82   /* 1 if currency_symbol precedes a positive value, 0 if succeeds.  */
83   char p_cs_precedes;
84   /* 1 iff a space separates currency_symbol from a positive value.  */
85   char p_sep_by_space;
86   /* 1 if currency_symbol precedes a negative value, 0 if succeeds.  */
87   char n_cs_precedes;
88   /* 1 iff a space separates currency_symbol from a negative value.  */
89   char n_sep_by_space;
90   /* Positive and negative sign positions:
91      0 Parentheses surround the quantity and currency_symbol.
92      1 The sign string precedes the quantity and currency_symbol.
93      2 The sign string follows the quantity and currency_symbol.
94      3 The sign string immediately precedes the currency_symbol.
95      4 The sign string immediately follows the currency_symbol.  */
96   char p_sign_posn;
97   char n_sign_posn;
98 #ifdef __USE_ISOC99
99   /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds.  */
100   char int_p_cs_precedes;
101   /* 1 iff a space separates int_curr_symbol from a positive value.  */
102   char int_p_sep_by_space;
103   /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds.  */
104   char int_n_cs_precedes;
105   /* 1 iff a space separates int_curr_symbol from a negative value.  */
106   char int_n_sep_by_space;
107   /* Positive and negative sign positions:
108      0 Parentheses surround the quantity and int_curr_symbol.
109      1 The sign string precedes the quantity and int_curr_symbol.
110      2 The sign string follows the quantity and int_curr_symbol.
111      3 The sign string immediately precedes the int_curr_symbol.
112      4 The sign string immediately follows the int_curr_symbol.  */
113   char int_p_sign_posn;
114   char int_n_sign_posn;
115 #else
116   char __int_p_cs_precedes;
117   char __int_p_sep_by_space;
118   char __int_n_cs_precedes;
119   char __int_n_sep_by_space;
120   char __int_p_sign_posn;
121   char __int_n_sign_posn;
122 #endif
123 };
124
125
126 /* Set and/or return the current locale.  */
127 extern char *setlocale (int __category, __const char *__locale) __THROW;
128
129 /* Return the numeric/monetary information for the current locale.  */
130 extern struct lconv *localeconv (void) __THROW;
131 libc_hidden_proto(localeconv)
132
133 __END_NAMESPACE_STD
134
135
136 #if defined __USE_XOPEN2K8 && defined __UCLIBC_HAS_LOCALE__
137 /* The concept of one static locale per category is not very well
138    thought out.  Many applications will need to process its data using
139    information from several different locales.  Another application is
140    the implementation of the internationalization handling in the
141    upcoming ISO C++ standard library.  To support this another set of
142    the functions using locale data exist which have an additional
143    argument.
144
145    Attention: all these functions are *not* standardized in any form.
146    This is a proof-of-concept implementation.  */
147
148 #ifdef __UCLIBC_HAS_XLOCALE__
149 /* Get locale datatype definition.  */
150 # include <xlocale.h>
151 #endif
152
153 /* POSIX 2008 makes locale_t official.  */
154 typedef __locale_t locale_t;
155
156 /* Return a reference to a data structure representing a set of locale
157    datasets.  Unlike for the CATEGORY parameter for `setlocale' the
158    CATEGORY_MASK parameter here uses a single bit for each category,
159    made by OR'ing together LC_*_MASK bits above.  */
160 extern __locale_t newlocale (int __category_mask, __const char *__locale,
161                              __locale_t __base) __THROW;
162 libc_hidden_proto(newlocale)
163
164 /* These are the bits that can be set in the CATEGORY_MASK argument to
165    `newlocale'.  In the GNU implementation, LC_FOO_MASK has the value
166    of (1 << LC_FOO), but this is not a part of the interface that
167    callers can assume will be true.  */
168 # define LC_CTYPE_MASK          (1 << __LC_CTYPE)
169 # define LC_NUMERIC_MASK        (1 << __LC_NUMERIC)
170 # define LC_TIME_MASK           (1 << __LC_TIME)
171 # define LC_COLLATE_MASK        (1 << __LC_COLLATE)
172 # define LC_MONETARY_MASK       (1 << __LC_MONETARY)
173 # define LC_MESSAGES_MASK       (1 << __LC_MESSAGES)
174 #ifdef LC_PAPER
175 # define LC_PAPER_MASK          (1 << __LC_PAPER)
176 # define LC_NAME_MASK           (1 << __LC_NAME)
177 # define LC_ADDRESS_MASK        (1 << __LC_ADDRESS)
178 # define LC_TELEPHONE_MASK      (1 << __LC_TELEPHONE)
179 # define LC_MEASUREMENT_MASK    (1 << __LC_MEASUREMENT)
180 # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION)
181 # define LC_ALL_MASK            (LC_CTYPE_MASK \
182                                  | LC_NUMERIC_MASK \
183                                  | LC_TIME_MASK \
184                                  | LC_COLLATE_MASK \
185                                  | LC_MONETARY_MASK \
186                                  | LC_MESSAGES_MASK \
187                                  | LC_PAPER_MASK \
188                                  | LC_NAME_MASK \
189                                  | LC_ADDRESS_MASK \
190                                  | LC_TELEPHONE_MASK \
191                                  | LC_MEASUREMENT_MASK \
192                                  | LC_IDENTIFICATION_MASK \
193                                  )
194 #else  /* LC_PAPER */
195 # define LC_ALL_MASK            (LC_CTYPE_MASK \
196                                  | LC_NUMERIC_MASK \
197                                  | LC_TIME_MASK \
198                                  | LC_COLLATE_MASK \
199                                  | LC_MONETARY_MASK \
200                                  | LC_MESSAGES_MASK \
201                                  )
202 #endif /* LC_PAPER */
203
204 /* Return a duplicate of the set of locale in DATASET.  All usage
205    counters are increased if necessary.  */
206 extern __locale_t duplocale (__locale_t __dataset) __THROW;
207
208 /* Free the data associated with a locale dataset previously returned
209    by a call to `setlocale_r'.  */
210 extern void freelocale (__locale_t __dataset) __THROW;
211
212 /* Switch the current thread's locale to DATASET.
213    If DATASET is null, instead just return the current setting.
214    The special value LC_GLOBAL_LOCALE is the initial setting
215    for all threads and can also be installed any time, meaning
216    the thread uses the global settings controlled by `setlocale'.  */
217 extern __locale_t uselocale (__locale_t __dataset) __THROW;
218 libc_hidden_proto(uselocale)
219
220 /* This value can be passed to `uselocale' and may be returned by it.
221    Passing this value to any other function has undefined behavior.  */
222 # define LC_GLOBAL_LOCALE       ((__locale_t) -1L)
223
224 #endif
225
226 __END_DECLS
227
228 #endif /* locale.h  */