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