| 1 | /* Copyright (C) 1991-2022 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, see |
| 16 | <https://www.gnu.org/licenses/>. */ |
| 17 | |
| 18 | /* |
| 19 | * ISO C99 Standard: 7.11 Localization <locale.h> |
| 20 | */ |
| 21 | |
| 22 | #ifndef _LOCALE_H |
| 23 | #define _LOCALE_H 1 |
| 24 | |
| 25 | #include <features.h> |
| 26 | |
| 27 | #define __need_NULL |
| 28 | #include <stddef.h> |
| 29 | #include <bits/locale.h> |
| 30 | |
| 31 | __BEGIN_DECLS |
| 32 | |
| 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 | #define LC_PAPER __LC_PAPER |
| 43 | #define LC_NAME __LC_NAME |
| 44 | #define LC_ADDRESS __LC_ADDRESS |
| 45 | #define LC_TELEPHONE __LC_TELEPHONE |
| 46 | #define LC_MEASUREMENT __LC_MEASUREMENT |
| 47 | #define LC_IDENTIFICATION __LC_IDENTIFICATION |
| 48 | |
| 49 | |
| 50 | /* Structure giving information about numeric and monetary notation. */ |
| 51 | struct lconv |
| 52 | { |
| 53 | /* Numeric (non-monetary) information. */ |
| 54 | |
| 55 | char *decimal_point; /* Decimal point character. */ |
| 56 | char *thousands_sep; /* Thousands separator. */ |
| 57 | /* Each element is the number of digits in each group; |
| 58 | elements with higher indices are farther left. |
| 59 | An element with value CHAR_MAX means that no further grouping is done. |
| 60 | An element with value 0 means that the previous element is used |
| 61 | for all groups farther left. */ |
| 62 | char *grouping; |
| 63 | |
| 64 | /* Monetary information. */ |
| 65 | |
| 66 | /* First three chars are a currency symbol from ISO 4217. |
| 67 | Fourth char is the separator. Fifth char is '\0'. */ |
| 68 | char *int_curr_symbol; |
| 69 | char *currency_symbol; /* Local currency symbol. */ |
| 70 | char *mon_decimal_point; /* Decimal point character. */ |
| 71 | char *mon_thousands_sep; /* Thousands separator. */ |
| 72 | char *mon_grouping; /* Like `grouping' element (above). */ |
| 73 | char *positive_sign; /* Sign for positive values. */ |
| 74 | char *negative_sign; /* Sign for negative values. */ |
| 75 | char int_frac_digits; /* Int'l fractional digits. */ |
| 76 | char frac_digits; /* Local fractional digits. */ |
| 77 | /* 1 if currency_symbol precedes a positive value, 0 if succeeds. */ |
| 78 | char p_cs_precedes; |
| 79 | /* 1 iff a space separates currency_symbol from a positive value. */ |
| 80 | char p_sep_by_space; |
| 81 | /* 1 if currency_symbol precedes a negative value, 0 if succeeds. */ |
| 82 | char n_cs_precedes; |
| 83 | /* 1 iff a space separates currency_symbol from a negative value. */ |
| 84 | char n_sep_by_space; |
| 85 | /* Positive and negative sign positions: |
| 86 | 0 Parentheses surround the quantity and currency_symbol. |
| 87 | 1 The sign string precedes the quantity and currency_symbol. |
| 88 | 2 The sign string follows the quantity and currency_symbol. |
| 89 | 3 The sign string immediately precedes the currency_symbol. |
| 90 | 4 The sign string immediately follows the currency_symbol. */ |
| 91 | char p_sign_posn; |
| 92 | char n_sign_posn; |
| 93 | #ifdef __USE_ISOC99 |
| 94 | /* 1 if int_curr_symbol precedes a positive value, 0 if succeeds. */ |
| 95 | char int_p_cs_precedes; |
| 96 | /* 1 iff a space separates int_curr_symbol from a positive value. */ |
| 97 | char int_p_sep_by_space; |
| 98 | /* 1 if int_curr_symbol precedes a negative value, 0 if succeeds. */ |
| 99 | char int_n_cs_precedes; |
| 100 | /* 1 iff a space separates int_curr_symbol from a negative value. */ |
| 101 | char int_n_sep_by_space; |
| 102 | /* Positive and negative sign positions: |
| 103 | 0 Parentheses surround the quantity and int_curr_symbol. |
| 104 | 1 The sign string precedes the quantity and int_curr_symbol. |
| 105 | 2 The sign string follows the quantity and int_curr_symbol. |
| 106 | 3 The sign string immediately precedes the int_curr_symbol. |
| 107 | 4 The sign string immediately follows the int_curr_symbol. */ |
| 108 | char int_p_sign_posn; |
| 109 | char int_n_sign_posn; |
| 110 | #else |
| 111 | char __int_p_cs_precedes; |
| 112 | char __int_p_sep_by_space; |
| 113 | char __int_n_cs_precedes; |
| 114 | char __int_n_sep_by_space; |
| 115 | char __int_p_sign_posn; |
| 116 | char __int_n_sign_posn; |
| 117 | #endif |
| 118 | }; |
| 119 | |
| 120 | |
| 121 | /* Set and/or return the current locale. */ |
| 122 | extern char *setlocale (int __category, const char *__locale) __THROW; |
| 123 | |
| 124 | /* Return the numeric/monetary information for the current locale. */ |
| 125 | extern struct lconv *localeconv (void) __THROW; |
| 126 | |
| 127 | |
| 128 | #ifdef __USE_XOPEN2K8 |
| 129 | /* POSIX.1-2008 extends the locale interface with functions for |
| 130 | explicit creation and manipulation of 'locale_t' objects |
| 131 | representing locale contexts, and a set of parallel |
| 132 | locale-sensitive text processing functions that take a locale_t |
| 133 | argument. This enables applications to work with data from |
| 134 | multiple locales simultaneously and thread-safely. */ |
| 135 | # include <bits/types/locale_t.h> |
| 136 | |
| 137 | /* Return a reference to a data structure representing a set of locale |
| 138 | datasets. Unlike for the CATEGORY parameter for `setlocale' the |
| 139 | CATEGORY_MASK parameter here uses a single bit for each category, |
| 140 | made by OR'ing together LC_*_MASK bits above. */ |
| 141 | extern locale_t newlocale (int __category_mask, const char *__locale, |
| 142 | locale_t __base) __THROW; |
| 143 | |
| 144 | /* These are the bits that can be set in the CATEGORY_MASK argument to |
| 145 | `newlocale'. In the GNU implementation, LC_FOO_MASK has the value |
| 146 | of (1 << LC_FOO), but this is not a part of the interface that |
| 147 | callers can assume will be true. */ |
| 148 | # define LC_CTYPE_MASK (1 << __LC_CTYPE) |
| 149 | # define LC_NUMERIC_MASK (1 << __LC_NUMERIC) |
| 150 | # define LC_TIME_MASK (1 << __LC_TIME) |
| 151 | # define LC_COLLATE_MASK (1 << __LC_COLLATE) |
| 152 | # define LC_MONETARY_MASK (1 << __LC_MONETARY) |
| 153 | # define LC_MESSAGES_MASK (1 << __LC_MESSAGES) |
| 154 | # define LC_PAPER_MASK (1 << __LC_PAPER) |
| 155 | # define LC_NAME_MASK (1 << __LC_NAME) |
| 156 | # define LC_ADDRESS_MASK (1 << __LC_ADDRESS) |
| 157 | # define LC_TELEPHONE_MASK (1 << __LC_TELEPHONE) |
| 158 | # define LC_MEASUREMENT_MASK (1 << __LC_MEASUREMENT) |
| 159 | # define LC_IDENTIFICATION_MASK (1 << __LC_IDENTIFICATION) |
| 160 | # define LC_ALL_MASK (LC_CTYPE_MASK \ |
| 161 | | LC_NUMERIC_MASK \ |
| 162 | | LC_TIME_MASK \ |
| 163 | | LC_COLLATE_MASK \ |
| 164 | | LC_MONETARY_MASK \ |
| 165 | | LC_MESSAGES_MASK \ |
| 166 | | LC_PAPER_MASK \ |
| 167 | | LC_NAME_MASK \ |
| 168 | | LC_ADDRESS_MASK \ |
| 169 | | LC_TELEPHONE_MASK \ |
| 170 | | LC_MEASUREMENT_MASK \ |
| 171 | | LC_IDENTIFICATION_MASK \ |
| 172 | ) |
| 173 | |
| 174 | /* Return a duplicate of the set of locale in DATASET. All usage |
| 175 | counters are increased if necessary. */ |
| 176 | extern locale_t duplocale (locale_t __dataset) __THROW; |
| 177 | |
| 178 | /* Free the data associated with a locale dataset previously returned |
| 179 | by a call to `setlocale_r'. */ |
| 180 | extern void freelocale (locale_t __dataset) __THROW; |
| 181 | |
| 182 | /* Switch the current thread's locale to DATASET. |
| 183 | If DATASET is null, instead just return the current setting. |
| 184 | The special value LC_GLOBAL_LOCALE is the initial setting |
| 185 | for all threads and can also be installed any time, meaning |
| 186 | the thread uses the global settings controlled by `setlocale'. */ |
| 187 | extern locale_t uselocale (locale_t __dataset) __THROW; |
| 188 | |
| 189 | /* This value can be passed to `uselocale' and may be returned by it. |
| 190 | Passing this value to any other function has undefined behavior. */ |
| 191 | # define LC_GLOBAL_LOCALE ((locale_t) -1L) |
| 192 | |
| 193 | #endif |
| 194 | |
| 195 | __END_DECLS |
| 196 | |
| 197 | #endif /* locale.h */ |
| 198 | |