]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
2 | Extended multibyte and wide character utilities.\r | |
3 | \r | |
4 | Within this implementation, multibyte characters are represented using the\r | |
5 | Unicode UTF-8 encoding and wide characters are represented using the\r | |
6 | 16-bit UCS-2 encoding.\r | |
7 | \r | |
8 | Unless explicitly stated otherwise, if the execution of a function declared\r | |
9 | in this file causes copying to take place between objects that overlap, the\r | |
10 | behavior is undefined.\r | |
11 | \r | |
61403bd7 | 12 | The following macros are defined in this file:<BR>\r |
13 | @verbatim\r | |
14 | NULL Actually defined in <sys/EfiCdefs.h>\r | |
15 | WCHAR_MIN Minimum value of a wide char.\r | |
16 | WCHAR_MAX Maximum value of a wide char.\r | |
17 | WEOF Wide char version of end-of-file.\r | |
18 | @endverbatim\r | |
19 | \r | |
20 | The following types are defined in this file:<BR>\r | |
21 | @verbatim\r | |
22 | size_t Unsigned integer type of the result of the sizeof operator.\r | |
23 | wchar_t Type of wide characters.\r | |
24 | wint_t Type capable of holding all wchar_t values and WEOF.\r | |
25 | mbstate_t Type of object holding multibyte conversion state.\r | |
26 | struct tm Incomplete declaration of the broken-down time structure.\r | |
27 | @endverbatim\r | |
28 | \r | |
29 | The following functions are declared in this file:<BR>\r | |
30 | @verbatim\r | |
31 | ############### Formatted Input/Output Functions\r | |
32 | int fwprintf (FILE * __restrict stream,\r | |
33 | const wchar_t * __restrict format, ...);\r | |
34 | int fwscanf (FILE * __restrict stream,\r | |
35 | const wchar_t * __restrict format, ...);\r | |
36 | int swprintf (wchar_t * __restrict s, size_t n,\r | |
37 | const wchar_t * __restrict format, ...);\r | |
38 | int swscanf (const wchar_t * __restrict s,\r | |
39 | const wchar_t * __restrict format, ...);\r | |
40 | int vfwprintf (FILE * __restrict stream,\r | |
41 | const wchar_t * __restrict format, va_list arg);\r | |
42 | int vfwscanf (FILE * __restrict stream,\r | |
43 | const wchar_t * __restrict format, va_list arg);\r | |
44 | int vswprintf (wchar_t * __restrict s, size_t n,\r | |
45 | const wchar_t * __restrict format, va_list arg);\r | |
46 | int vswscanf (const wchar_t * __restrict s,\r | |
47 | const wchar_t * __restrict format, va_list arg);\r | |
48 | int vwprintf (const wchar_t * __restrict format, va_list arg);\r | |
49 | int vwscanf (const wchar_t * __restrict format, va_list arg);\r | |
50 | int wprintf (const wchar_t * __restrict format, ...);\r | |
51 | int wscanf (const wchar_t * __restrict format, ...);\r | |
52 | \r | |
53 | ################### Input/Output Functions\r | |
54 | wint_t fgetwc (FILE *stream);\r | |
55 | wchar_t *fgetws (wchar_t * __restrict S, int n,\r | |
56 | FILE * __restrict stream);\r | |
57 | wint_t fputwc (wchar_t c, FILE *stream);\r | |
58 | int fputws (const wchar_t * __restrict S,\r | |
59 | FILE * __restrict stream);\r | |
60 | int fwide (FILE *stream, int mode);\r | |
61 | wint_t getwc (FILE *stream);\r | |
62 | wint_t getwchar (void);\r | |
63 | wint_t putwc (wchar_t c, FILE *stream);\r | |
64 | wint_t putwchar (wchar_t c);\r | |
65 | wint_t ungetwc (wint_t c, FILE *stream);\r | |
66 | \r | |
67 | ################### Numeric Conversions\r | |
68 | double wcstod (const wchar_t * __restrict nptr,\r | |
69 | wchar_t ** __restrict endptr);\r | |
70 | float wcstof (const wchar_t * __restrict nptr,\r | |
71 | wchar_t ** __restrict endptr);\r | |
72 | long double wcstold (const wchar_t * __restrict nptr,\r | |
73 | wchar_t ** __restrict endptr);\r | |
74 | long int wcstol (const wchar_t * __restrict nptr,\r | |
75 | wchar_t ** __restrict endptr, int base);\r | |
76 | long long int wcstoll (const wchar_t * __restrict nptr,\r | |
77 | wchar_t ** __restrict endptr, int base);\r | |
78 | unsigned long int wcstoul (const wchar_t * __restrict nptr,\r | |
79 | wchar_t ** __restrict endptr, int base);\r | |
80 | unsigned long long int wcstoull (const wchar_t * __restrict nptr,\r | |
81 | wchar_t ** __restrict endptr, int base);\r | |
82 | \r | |
83 | ####################### String Copying\r | |
84 | wchar_t *wcscpy (wchar_t * __restrict s1,\r | |
85 | const wchar_t * __restrict s2);\r | |
86 | wchar_t *wcsncpy (wchar_t * __restrict s1,\r | |
87 | const wchar_t * __restrict s2, size_t n);\r | |
88 | wchar_t *wmemcpy (wchar_t * __restrict s1,\r | |
89 | const wchar_t * __restrict s2, size_t n);\r | |
90 | wchar_t *wmemmove (wchar_t *s1, const wchar_t *s2, size_t n);\r | |
91 | \r | |
92 | ################### String Concatenation\r | |
93 | wchar_t *wcscat (wchar_t * __restrict s1,\r | |
94 | const wchar_t * __restrict s2);\r | |
95 | wchar_t *wcsncat (wchar_t * __restrict s1,\r | |
96 | const wchar_t * __restrict s2, size_t n);\r | |
97 | \r | |
98 | ##################### String Comparison\r | |
99 | int wcscmp (const wchar_t *s1, const wchar_t *s2);\r | |
100 | int wcscoll (const wchar_t *s1, const wchar_t *s2);\r | |
101 | int wcsncmp (const wchar_t *s1, const wchar_t *s2, size_t n);\r | |
102 | size_t wcsxfrm (wchar_t * __restrict s1,\r | |
103 | const wchar_t * __restrict s2, size_t n);\r | |
104 | int wmemcmp (const wchar_t *s1, const wchar_t *s2, size_t n);\r | |
105 | \r | |
106 | ##################### String Searching\r | |
107 | wchar_t *wcschr (const wchar_t *S, wchar_t c);\r | |
108 | size_t wcscspn (const wchar_t *s1, const wchar_t *s2);\r | |
109 | wchar_t *wcspbrk (const wchar_t *s1, const wchar_t *s2);\r | |
110 | wchar_t *wcsrchr (const wchar_t *S, wchar_t c);\r | |
111 | size_t wcsspn (const wchar_t *s1, const wchar_t *s2);\r | |
112 | wchar_t *wcsstr (const wchar_t *s1, const wchar_t *s2);\r | |
113 | wchar_t *wcstok (wchar_t * __restrict s1,\r | |
114 | const wchar_t * __restrict s2,\r | |
115 | wchar_t ** __restrict ptr);\r | |
116 | wchar_t *wmemchr (const wchar_t *S, wchar_t c, size_t n);\r | |
117 | \r | |
118 | ################### String Manipulation\r | |
119 | size_t wcslen (const wchar_t *S);\r | |
120 | wchar_t *wmemset (wchar_t *S, wchar_t c, size_t n);\r | |
121 | \r | |
122 | ################# Date and Time Conversion\r | |
123 | size_t wcsftime (wchar_t * __restrict S, size_t maxsize,\r | |
124 | const wchar_t * __restrict format,\r | |
125 | const struct tm * __restrict timeptr);\r | |
126 | \r | |
127 | ############# Multibyte <--> Wide Character Conversion\r | |
128 | wint_t btowc (int c);\r | |
129 | int wctob (wint_t c);\r | |
130 | int mbsinit (const mbstate_t *ps);\r | |
131 | \r | |
132 | ####### Restartable Multibyte <--> Wide Character Conversion\r | |
133 | size_t mbrlen (const char * __restrict S, size_t n,\r | |
134 | mbstate_t * __restrict ps);\r | |
135 | size_t mbrtowc (wchar_t * __restrict pwc, const char * __restrict S,\r | |
136 | size_t n, mbstate_t * __restrict ps);\r | |
137 | size_t wcrtomb (char * __restrict S, wchar_t wc,\r | |
138 | mbstate_t * __restrict ps);\r | |
139 | size_t mbsrtowcs (wchar_t * __restrict dst,\r | |
140 | const char ** __restrict src, size_t len,\r | |
141 | mbstate_t * __restrict ps);\r | |
142 | size_t wcsrtombs (char * __restrict dst,\r | |
143 | const wchar_t ** __restrict src,\r | |
144 | size_t len, mbstate_t * __restrict ps);\r | |
145 | @endverbatim\r | |
146 | \r | |
147 | @note Properly constructed programs will take the following into consideration:\r | |
148 | - wchar_t and wint_t may be the same integer type.\r | |
149 | - WEOF might be a different value than that of EOF.\r | |
150 | - WEOF might not be negative.\r | |
151 | - mbstate_t objects are not intended to be inspected by programs.\r | |
152 | \r | |
153 | Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r | |
2aa62f2b | 154 | This program and the accompanying materials are licensed and made available under\r |
155 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
156 | The full text of the license may be found at\r | |
61403bd7 | 157 | http://opensource.org/licenses/bsd-license.\r |
2aa62f2b | 158 | \r |
159 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
160 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
2aa62f2b | 161 | **/\r |
162 | #ifndef _WCHAR_H\r | |
163 | #define _WCHAR_H\r | |
164 | #include <sys/EfiCdefs.h>\r | |
165 | #include <machine/ansi.h>\r | |
166 | #include <machine/limits.h>\r | |
167 | #include <stdarg.h>\r | |
168 | #include <stdio.h>\r | |
169 | \r | |
170 | #if defined(_MSC_VER)\r | |
171 | #pragma warning ( disable : 4142 )\r | |
172 | #endif\r | |
173 | \r | |
174 | #ifdef _EFI_SIZE_T_\r | |
61403bd7 | 175 | typedef _EFI_SIZE_T_ size_t; /**< Unsigned integer type of the result of the sizeof operator. */\r |
2aa62f2b | 176 | #undef _BSD_SIZE_T_\r |
177 | #undef _EFI_SIZE_T_\r | |
178 | #endif\r | |
179 | \r | |
180 | #ifndef __cplusplus\r | |
181 | #ifdef _EFI_WCHAR_T\r | |
61403bd7 | 182 | /** An integer type capable of representing all distinct codes in the\r |
183 | UCS-2 encoding supported by UEFI.\r | |
184 | **/\r | |
185 | typedef _EFI_WCHAR_T wchar_t;\r | |
2aa62f2b | 186 | #undef _BSD_WCHAR_T_\r |
187 | #undef _EFI_WCHAR_T\r | |
188 | #endif\r | |
189 | #endif\r | |
190 | \r | |
2aa62f2b | 191 | #ifdef _BSD_MBSTATE_T_\r |
61403bd7 | 192 | /** mbstate_t is an opaque object, that is not an array type, used to keep\r |
193 | conversion state during multibyte stream conversions.\r | |
194 | */\r | |
2aa62f2b | 195 | typedef _BSD_MBSTATE_T_ mbstate_t;\r |
196 | #undef _BSD_MBSTATE_T_\r | |
197 | #endif\r | |
198 | \r | |
2aa62f2b | 199 | #ifdef _EFI_WINT_T\r |
61403bd7 | 200 | /** wint_t is an integer type unchanged by default argument promotions that can\r |
201 | hold any value corresponding to members of the extended character set, as\r | |
202 | well as at least one value that does not correspond to any member of the\r | |
203 | extended character set: WEOF.\r | |
204 | */\r | |
205 | typedef _EFI_WINT_T wint_t;\r | |
2aa62f2b | 206 | #undef _BSD_WINT_T_\r |
207 | #undef _EFI_WINT_T\r | |
208 | #endif\r | |
209 | \r | |
2aa62f2b | 210 | #ifndef WCHAR_MIN\r |
61403bd7 | 211 | /** @{\r |
212 | Since wchar_t is an unsigned 16-bit value, it has a minimum value of 0, and\r | |
213 | a maximum value defined by __USHRT_MAX (65535 on IA processors).\r | |
214 | */\r | |
215 | #define WCHAR_MIN 0\r | |
216 | #define WCHAR_MAX __USHRT_MAX\r | |
217 | /*@}*/\r | |
2aa62f2b | 218 | #endif\r |
219 | \r | |
2aa62f2b | 220 | #ifndef WEOF\r |
61403bd7 | 221 | /** WEOF expands to a constant expression of type wint_t whose value does not\r |
222 | correspond to any member of the extended character set. It is accepted\r | |
223 | (and returned) by several functions, declared in this file, to indicate\r | |
224 | end-of-file, that is, no more input from a stream. It is also used as a\r | |
225 | wide character value that does not correspond to any member of the\r | |
226 | extended character set.\r | |
227 | */\r | |
2aa62f2b | 228 | #define WEOF ((wint_t)-1)\r |
229 | #endif\r | |
230 | \r | |
61403bd7 | 231 | /* limits of wint_t -- These are NOT specified by ISO/IEC 9899 */\r |
232 | #ifndef WINT_MIN\r | |
233 | #define WINT_MIN _EFI_WINT_MIN /* wint_t */\r | |
234 | #define WINT_MAX _EFI_WINT_MAX /* wint_t */\r | |
235 | #endif\r | |
236 | \r | |
237 | /** Type struct tm is declared here as an incomplete structure type for use as an argument\r | |
238 | type by the wcsftime function. The full structure declaration is in <time.h>.\r | |
2aa62f2b | 239 | */\r |
240 | struct tm;\r | |
241 | \r | |
242 | /* ############### Formatted Input/Output Functions ##################### */\r | |
243 | \r | |
61403bd7 | 244 | /** The fwprintf function writes output to the stream pointed to by stream,\r |
245 | under control of the wide string pointed to by format that specifies how\r | |
246 | subsequent arguments are converted for output. If there are insufficient\r | |
247 | arguments for the format, the behavior is undefined. If the format is\r | |
248 | exhausted while arguments remain, the excess arguments are evaluated\r | |
249 | (as always) but are otherwise ignored. The fwprintf function returns\r | |
250 | when the end of the format string is encountered.\r | |
251 | \r | |
252 | The format is composed of zero or more directives: ordinary wide characters\r | |
253 | (not %), which are copied unchanged to the output stream; and conversion\r | |
254 | specifications, each of which results in fetching zero or more subsequent\r | |
255 | arguments, converting them, if applicable, according to the corresponding\r | |
256 | conversion specifier, and then writing the result to the output stream.\r | |
257 | \r | |
258 | Each conversion specification is introduced by the wide character %. After\r | |
259 | the %, the following appear in sequence:\r | |
260 |