blob: 93aac0ad40633fbe52711c1b60260ce1b21845e7 [file] [log] [blame]
Vishal Bhoj82c80712015-12-15 21:13:33 +05301/** @file
2 Localization functions and macros.
3
4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 * Copyright (c) 1991, 1993
14 * The Regents of the University of California. All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 * SUCH DAMAGE.
39 *
40 * @(#)locale.h 8.1 (Berkeley) 6/2/93
41 * $NetBSD: locale.h,v 1.14 2005/02/03 04:39:32 perry Exp
42**/
43
44#ifndef _LOCALE_H_
45#define _LOCALE_H_
46
47/** This is a structure containing members pertaining to the formatting and display of numeric values.
48 Each member of this structure is commented with its value in the "C" locale.
49
50 The decimal_point member must point to a string with a length greater than zero.
51 All other pointer members may point to "" in order to indicate that the value is not available
52 in the current locale, or that it is of zero length. Except for grouping and mon_grouping, the
53 strings start and end in the initial shift state.
54
55 The remaining members, of type char, are non-negative numbers or CHAR_MAX, which indicates that
56 the value is not available in the current locale.
57
58 Members grouping and mon_grouping point to strings where each element (character) of the string
59 indicates the size of the corresponding group of digits and is interpreted as follows:
60 - CHAR_MAX No further grouping is to be performed.
61 - 0 The previous element is to be repeatedly used for the remainder of the digits.
62 - other The ISO specification states: "The integer value is the number of digits that
63 compose the current group. The next element is examined to determine the size
64 of the next group of digits before the current group." The EDK II implementation
65 interprets this to mean that the groups are specified left-to-right.
66
67 The *_sep_by_space members are interpreted as follows:
68 - 0 No space separates the currency symbol and value.
69 - 1 If the currency symbol and sign string are adjacent, a space separates them from the
70 value; otherwise, a space separates the currency symbol from the value.
71 - 2 If the currency symbol and sign string are adjacent, a space separates them;
72 otherwise, a space separates the sign string from the value.
73 For int_p_sep_by_space and int_n_sep_by_space, the fourth character of int_curr_symbol is
74 used instead of a space.
75
76 The values of the *_sign_posn members are interpreted as follows:
77 - 0 Parentheses surround the quantity and currency symbol.
78 - 1 The sign string precedes the quantity and currency symbol.
79 - 2 The sign string succeeds the quantity and currency symbol.
80 - 3 The sign string immediately precedes the currency symbol.
81 - 4 The sign string immediately succeeds the currency symbol.
82**/
83struct lconv {
84 char *decimal_point; /**< "." Non-monetary decimal-point. */
85 char *thousands_sep; /**< "" Separates groups of digits before the decimal-point */
86 char *grouping; /**< "" A string whose elements (characters) indicate the size
87 of each group of digits in formatted nonmonetary quantities. */
88 char *int_curr_symbol; /**< "" A 4-character string providing the international currency
89 symbol. The first three characters contain the alphabetic
90 international currency symbol in accordance with those
91 specified in ISO 4217. The fourth character, immediately
92 preceding the null character, is the character used to separate
93 the international currency symbol from the monetary quantity. */
94 char *currency_symbol; /**< "" The local currency symbol for the current locale. */
95 char *mon_decimal_point; /**< "" The decimal point used for monetary values. */
96 char *mon_thousands_sep; /**< "" The separator for digit groups preceeding the decimal-point. */
97 char *mon_grouping; /**< "" A string, like grouping, for monetary values. */
98 char *positive_sign; /**< "" A string to indicate a non-negative monetary value. */
99 char *negative_sign; /**< "" A string to indicate a negative monetary value. */
100 char int_frac_digits; /**< CHAR_MAX The number of digits after the decimal-point for international
101 monetary values. */
102 char frac_digits; /**< CHAR_MAX The number of digits after the decimal-point for local
103 monetary values. */
104 char p_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
105 succeeds the value for non-negative local monetary values. */
106 char p_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
107 the sign string, and the value for non-negative local values. */
108 char n_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
109 succeeds the value for negative local monetary values. */
110 char n_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
111 the sign string, and the value for negative local values. */
112 char p_sign_posn; /**< CHAR_MAX Value specifying the positioning of the positive_sign for a
113 non-negative local monetary quantity. */
114 char n_sign_posn; /**< CHAR_MAX Value specifying the positioning of the negative_sign for a
115 negative local monetary quantity. */
116 char int_p_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
117 succeeds the value for non-negative international monetary values. */
118 char int_n_cs_precedes; /**< CHAR_MAX Set to 1 or 0 if the currency_symbol respectively precedes or
119 succeeds the value for negative international monetary values. */
120 char int_p_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
121 the sign string, and the value for non-negative international values. */
122 char int_n_sep_by_space; /**< CHAR_MAX Value specifying the separation between the currency_symbol,
123 the sign string, and the value for negative international values. */
124 char int_p_sign_posn; /**< CHAR_MAX Value specifying the positioning of the positive_sign for a
125 non-negative international monetary quantity. */
126 char int_n_sign_posn; /**< CHAR_MAX Value specifying the positioning of the negative_sign for a
127 negative international monetary quantity. */
128};
129
130/** @{
131 These macros expand to integer expressions suitable for use as the first
132 argument (category) to the setlocale() function.
133
134 Only the first six macros are required by the C language specification.
135 Implementations are free to extend this list, as has been done with LC_MESSAGES,
136 with additional macro definitions, beginning with the characters LC_ and
137 an uppercase letter.
138**/
139#define LC_ALL 0 ///< The application's entire locale.
140#define LC_COLLATE 1 ///< Affects the behavior of the strcoll and strxfrm functions.
141#define LC_CTYPE 2 ///< Affects the behavior of the character handling, multibyte, and wide character functions.
142#define LC_MONETARY 3 ///< Affects monetary formatting information.
143#define LC_NUMERIC 4 ///< Affects the decimal-point character and non-monetary formatting information.
144#define LC_TIME 5 ///< Affects the behavior of the strftime and wcsftime functions.
145#define LC_MESSAGES 6
146#define _LC_LAST 7 ///< Number of defined macros. Marks end.
147/*@}*/
148
149#include <sys/EfiCdefs.h>
150
151/** @fn char *setlocale(int category, const char *locale)
152
153 @brief The setlocale function is used to retrieve or change parts or all of the current locale.
154
155 @details If locale is NULL, or the same as the current locale, this function just retrieves the
156 values for the specified category in the current locale. Otherwise, the specified category
157 in the current locale is set to the corresponding values from the specified locale and a pointer
158 to the new values is returned.
159
160 @param[in] category The portion of the current locale to be affected by this call.
161 The LC_ macros list the supported categories and the meaning of each.
162 @param[in] locale A value of "C" for locale specifies the minimal environment for C translation;
163 A value of "" specifies the native environment, which is "C" for this
164 implementation. If locale is NULL, the current locale is specified.
165
166 @return A pointer to the string associated with the specified category for the new locale,
167 a pointer to the string associated with the category for the current locale,
168 or NULL if category or locale can not be honored. The return value should not be
169 modified by the program, but may be overwritten by subsequent calls to either
170 setlocale or localeconv.
171**/
172
173/** @fn struct lconv *localeconv(void)
174
175 @brief The localeconv function returns a pointer to a lconv structure containing the appropriate
176 values for the current locale.
177
178 @return A pointer to a filled-in lconv structure. The returned structure should not be
179 modified by the program, but may be overwritten by subsequent calls to either
180 setlocale or localeconv.
181**/
182
183__BEGIN_DECLS
184#ifdef __SETLOCALE_SOURCE__
185 char *setlocale(int category, const char *locale);
186 char *__setlocale(int category, const char *locale);
187#else /* !__SETLOCALE_SOURCE__ */
188 char *setlocale(int category, const char *locale) __RENAME(__setlocale_mb_len_max_32);
189#endif /* !__SETLOCALE_SOURCE__ */
190struct lconv *localeconv(void);
191 char *__setlocale_mb_len_max_32(int category, const char *locale);
192__END_DECLS
193
194#endif /* _LOCALE_H_ */