• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *  * Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  *  * Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *    the documentation and/or other materials provided with the
13  *    distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  */
28 #ifndef NDK_ANDROID_SUPPORT_LOCALE_H
29 #define NDK_ANDROID_SUPPORT_LOCALE_H
30 
31 #if defined(__LP64__)
32 #include_next <locale.h>
33 
34 #else
35 
36 #define lconv  __libc_lconv
37 #define localeconv  __libc_localeconv
38 #include_next <locale.h>
39 #undef lconv
40 #undef localeconv
41 #include <xlocale.h>
42 
43 #if !defined(LC_CTYPE)
44 /* Define all LC_XXX to itself.  Sounds silly but libc++ expects it's defined, not in enum */
45 #define LC_CTYPE           LC_CTYPE
46 #define LC_NUMERIC         LC_NUMERIC
47 #define LC_TIME            LC_TIME
48 #define LC_COLLATE         LC_COLLATE
49 #define LC_MONETARY        LC_MONETARY
50 #define LC_MESSAGES        LC_MESSAGES
51 #define LC_ALL             LC_ALL
52 #define LC_PAPER           LC_PAPER
53 #define LC_NAME            LC_NAME
54 #define LC_ADDRESS         LC_ADDRESS
55 #define LC_TELEPHONE       LC_TELEPHONE
56 #define LC_MEASUREMENT     LC_MEASUREMENT
57 #define LC_IDENTIFICATION  LC_IDENTIFICATION
58 #endif
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 #define LC_CTYPE_MASK  (1 << LC_CTYPE)
65 #define LC_NUMERIC_MASK (1 << LC_NUMERIC)
66 #define LC_TIME_MASK (1 << LC_TIME)
67 #define LC_COLLATE_MASK (1 << LC_COLLATE)
68 #define LC_MONETARY_MASK (1 << LC_MONETARY)
69 #define LC_MESSAGES_MASK (1 << LC_MESSAGES)
70 #define LC_PAPER_MASK (1 << LC_PAPER)
71 #define LC_NAME_MASK (1 << LC_NAME)
72 #define LC_ADDRESS_MASK (1 << LC_ADDRESS)
73 #define LC_TELEPHONE_MASK (1 << LC_TELEPHONE)
74 #define LC_MEASUREMENT_MASK (1 << LC_MEASUREMENT)
75 #define LC_IDENTIFICATION_MASK (1 << LC_IDENTIFICATION)
76 
77 #undef LC_ALL_MASK
78 #define LC_ALL_MASK (LC_CTYPE_MASK \
79                      | LC_NUMERIC_MASK \
80                      | LC_TIME_MASK \
81                      | LC_COLLATE_MASK \
82                      | LC_MONETARY_MASK \
83                      | LC_MESSAGES_MASK \
84                      | LC_PAPER_MASK \
85                      | LC_NAME_MASK \
86                      | LC_ADDRESS_MASK \
87                      | LC_TELEPHONE_MASK \
88                      | LC_MEASUREMENT_MASK \
89                      | LC_IDENTIFICATION_MASK \
90                      )
91 
92 extern locale_t newlocale(int, const char*, locale_t);
93 extern locale_t uselocale(locale_t);
94 extern void     freelocale(locale_t);
95 
96 #define LC_GLOBAL_LOCALE    ((locale_t) -1L)
97 
98 struct lconv {
99     char* decimal_point;       /* Decimal point character */
100     char* thousands_sep;       /* Thousands separator */
101     char* grouping;            /* Grouping */
102     char* int_curr_symbol;
103     char* currency_symbol;
104     char* mon_decimal_point;
105     char* mon_thousands_sep;
106     char* mon_grouping;
107     char* positive_sign;
108     char* negative_sign;
109     char  int_frac_digits;
110     char  frac_digits;
111     char  p_cs_precedes;
112     char  p_sep_by_space;
113     char  n_cs_precedes;
114     char  n_sep_by_space;
115     char  p_sign_posn;
116     char  n_sign_posn;
117     /* ISO-C99 */
118     char  int_p_cs_precedes;
119     char  int_p_sep_by_space;
120     char  int_n_cs_precedes;
121     char  int_n_sep_by_space;
122     char  int_p_sign_posn;
123     char  int_n_sign_posn;
124 };
125 
126 struct lconv* localeconv(void);
127 
128 #if 0
129 // Used to implement the std::ctype<char> specialization.
130 extern const char * const __ctype_c_mask_table;
131 // TODO(ajwong): Make this based on some exported bionic constant.
132 const int __ctype_c_mask_table_size = 256;
133 #endif
134 
135 #ifdef __cplusplus
136 }  // extern "C"
137 #endif
138 
139 #endif // !__LP64__
140 
141 #endif  // NDK_ANDROID_SUPPORT_LOCALE_H
142