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