wchar.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. /* Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 Standard: 7.24
  16. * Extended multibyte and wide character utilities <wchar.h>
  17. */
  18. #ifndef _WCHAR_H
  19. #ifndef __need_mbstate_t
  20. # define _WCHAR_H 1
  21. # include <features.h>
  22. #endif
  23. #ifndef __UCLIBC_HAS_WCHAR__
  24. #error Attempted to include wchar.h when uClibc built without wide char support.
  25. #endif
  26. #ifdef _WCHAR_H
  27. /* Get FILE definition. */
  28. # define __need___FILE
  29. # ifdef __USE_UNIX98
  30. # define __need_FILE
  31. # endif
  32. # include <stdio.h>
  33. /* Get va_list definition. */
  34. # define __need___va_list
  35. # include <stdarg.h>
  36. /* Get size_t, wchar_t, wint_t and NULL from <stddef.h>. */
  37. # define __need_size_t
  38. # define __need_wchar_t
  39. # define __need_NULL
  40. #endif
  41. #define __need_wint_t
  42. #include <stddef.h>
  43. #include <bits/wchar.h>
  44. /* We try to get wint_t from <stddef.h>, but not all GCC versions define it
  45. there. So define it ourselves if it remains undefined. */
  46. #ifndef _WINT_T
  47. /* Integral type unchanged by default argument promotions that can
  48. hold any value corresponding to members of the extended character
  49. set, as well as at least one value that does not correspond to any
  50. member of the extended character set. */
  51. # define _WINT_T
  52. typedef unsigned int wint_t;
  53. #else
  54. /* Work around problems with the <stddef.h> file which doesn't put
  55. wint_t in the std namespace. */
  56. # if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES \
  57. && defined __WINT_TYPE__
  58. __BEGIN_NAMESPACE_STD
  59. typedef __WINT_TYPE__ wint_t;
  60. __END_NAMESPACE_STD
  61. # endif
  62. #endif
  63. #ifndef __mbstate_t_defined
  64. # define __mbstate_t_defined 1
  65. /* Conversion state information. */
  66. #if 1
  67. typedef struct
  68. {
  69. wchar_t __mask;
  70. wchar_t __wc;
  71. } __mbstate_t;
  72. #else
  73. typedef struct
  74. {
  75. int __count;
  76. union
  77. {
  78. wint_t __wch;
  79. char __wchb[4];
  80. } __value; /* Value so far. */
  81. } __mbstate_t;
  82. #endif
  83. #endif
  84. #undef __need_mbstate_t
  85. /* The rest of the file is only used if used if __need_mbstate_t is not
  86. defined. */
  87. #ifdef _WCHAR_H
  88. __BEGIN_NAMESPACE_C99
  89. /* Public type. */
  90. typedef __mbstate_t mbstate_t;
  91. __END_NAMESPACE_C99
  92. #ifdef __USE_GNU
  93. __USING_NAMESPACE_C99(mbstate_t)
  94. #endif
  95. #ifndef WCHAR_MIN
  96. /* These constants might also be defined in <inttypes.h>. */
  97. # define WCHAR_MIN __WCHAR_MIN
  98. # define WCHAR_MAX __WCHAR_MAX
  99. #endif
  100. #ifndef WEOF
  101. # define WEOF (0xffffffffu)
  102. #endif
  103. /* For XPG4 compliance we have to define the stuff from <wctype.h> here
  104. as well. */
  105. #if defined __USE_XOPEN && !defined __USE_UNIX98
  106. # include <wctype.h>
  107. #endif
  108. __BEGIN_DECLS
  109. __BEGIN_NAMESPACE_STD
  110. /* This incomplete type is defined in <time.h> but needed here because
  111. of `wcsftime'. */
  112. struct tm;
  113. __END_NAMESPACE_STD
  114. /* XXX We have to clean this up at some point. Since tm is in the std
  115. namespace but wcsftime is in __c99 the type wouldn't be found
  116. without inserting it in the global namespace. */
  117. __USING_NAMESPACE_STD(tm)
  118. __BEGIN_NAMESPACE_C99
  119. /* Copy SRC to DEST. */
  120. extern wchar_t *wcscpy (wchar_t *__restrict __dest,
  121. const wchar_t *__restrict __src) __THROW;
  122. /* Copy no more than N wide-characters of SRC to DEST. */
  123. extern wchar_t *wcsncpy (wchar_t *__restrict __dest,
  124. const wchar_t *__restrict __src, size_t __n)
  125. __THROW;
  126. /* Append SRC onto DEST. */
  127. extern wchar_t *wcscat (wchar_t *__restrict __dest,
  128. const wchar_t *__restrict __src) __THROW;
  129. libc_hidden_proto(wcscat)
  130. /* Append no more than N wide-characters of SRC onto DEST. */
  131. extern wchar_t *wcsncat (wchar_t *__restrict __dest,
  132. const wchar_t *__restrict __src, size_t __n)
  133. __THROW;
  134. /* Compare S1 and S2. */
  135. extern int wcscmp (const wchar_t *__s1, const wchar_t *__s2)
  136. __THROW __attribute_pure__;
  137. libc_hidden_proto(wcscmp)
  138. /* Compare N wide-characters of S1 and S2. */
  139. extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
  140. __THROW __attribute_pure__;
  141. __END_NAMESPACE_C99
  142. #ifdef __USE_GNU
  143. /* Compare S1 and S2, ignoring case. */
  144. extern int wcscasecmp (const wchar_t *__s1, const wchar_t *__s2) __THROW;
  145. /* Compare no more than N chars of S1 and S2, ignoring case. */
  146. extern int wcsncasecmp (const wchar_t *__s1, const wchar_t *__s2,
  147. size_t __n) __THROW;
  148. #ifdef __UCLIBC_HAS_XLOCALE__
  149. /* Similar to the two functions above but take the information from
  150. the provided locale and not the global locale. */
  151. # include <xlocale.h>
  152. extern int wcscasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
  153. __locale_t __loc) __THROW;
  154. libc_hidden_proto(wcscasecmp_l)
  155. extern int wcsncasecmp_l (const wchar_t *__s1, const wchar_t *__s2,
  156. size_t __n, __locale_t __loc) __THROW;
  157. libc_hidden_proto(wcsncasecmp_l)
  158. #endif /* __UCLIBC_HAS_XLOCALE__ */
  159. #endif
  160. __BEGIN_NAMESPACE_C99
  161. /* Compare S1 and S2, both interpreted as appropriate to the
  162. LC_COLLATE category of the current locale. */
  163. extern int wcscoll (const wchar_t *__s1, const wchar_t *__s2) __THROW;
  164. libc_hidden_proto(wcscoll)
  165. /* Transform S2 into array pointed to by S1 such that if wcscmp is
  166. applied to two transformed strings the result is the as applying
  167. `wcscoll' to the original strings. */
  168. extern size_t wcsxfrm (wchar_t *__restrict __s1,
  169. const wchar_t *__restrict __s2, size_t __n) __THROW;
  170. __END_NAMESPACE_C99
  171. #ifdef __USE_GNU
  172. #ifdef __UCLIBC_HAS_XLOCALE__
  173. /* Similar to the two functions above but take the information from
  174. the provided locale and not the global locale. */
  175. /* Compare S1 and S2, both interpreted as appropriate to the
  176. LC_COLLATE category of the given locale. */
  177. extern int wcscoll_l (const wchar_t *__s1, const wchar_t *__s2,
  178. __locale_t __loc) __THROW;
  179. libc_hidden_proto(wcscoll_l)
  180. /* Transform S2 into array pointed to by S1 such that if wcscmp is
  181. applied to two transformed strings the result is the as applying
  182. `wcscoll' to the original strings. */
  183. extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
  184. size_t __n, __locale_t __loc) __THROW;
  185. libc_hidden_proto(wcsxfrm_l)
  186. #endif /* __UCLIBC_HAS_XLOCALE__ */
  187. /* Duplicate S, returning an identical malloc'd string. */
  188. extern wchar_t *wcsdup (const wchar_t *__s) __THROW __attribute_malloc__;
  189. #endif
  190. __BEGIN_NAMESPACE_C99
  191. /* Find the first occurrence of WC in WCS. */
  192. extern wchar_t *wcschr (const wchar_t *__wcs, wchar_t __wc)
  193. __THROW __attribute_pure__;
  194. /* Find the last occurrence of WC in WCS. */
  195. extern wchar_t *wcsrchr (const wchar_t *__wcs, wchar_t __wc)
  196. __THROW __attribute_pure__;
  197. __END_NAMESPACE_C99
  198. #ifdef __USE_GNU
  199. /* This function is similar to `wcschr'. But it returns a pointer to
  200. the closing NUL wide character in case C is not found in S. */
  201. extern wchar_t *wcschrnul (const wchar_t *__s, wchar_t __wc)
  202. __THROW __attribute_pure__;
  203. #endif
  204. __BEGIN_NAMESPACE_C99
  205. /* Return the length of the initial segmet of WCS which
  206. consists entirely of wide characters not in REJECT. */
  207. extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
  208. __THROW __attribute_pure__;
  209. /* Return the length of the initial segmet of WCS which
  210. consists entirely of wide characters in ACCEPT. */
  211. extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
  212. __THROW __attribute_pure__;
  213. libc_hidden_proto(wcsspn)
  214. /* Find the first occurrence in WCS of any character in ACCEPT. */
  215. extern wchar_t *wcspbrk (const wchar_t *__wcs, const wchar_t *__accept)
  216. __THROW __attribute_pure__;
  217. libc_hidden_proto(wcspbrk)
  218. /* Find the first occurrence of NEEDLE in HAYSTACK. */
  219. /* SuSv uses restrict keyword, glibc does not */
  220. extern wchar_t *wcsstr (const wchar_t *__restrict __haystack, const wchar_t *__restrict __needle)
  221. __THROW __attribute_pure__;
  222. /* Divide WCS into tokens separated by characters in DELIM. */
  223. extern wchar_t *wcstok (wchar_t *__restrict __s,
  224. const wchar_t *__restrict __delim,
  225. wchar_t **__restrict __ptr) __THROW;
  226. /* Return the number of wide characters in S. */
  227. extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
  228. libc_hidden_proto(wcslen)
  229. __END_NAMESPACE_C99
  230. #if defined __USE_XOPEN && defined __UCLIBC_SUSV3_LEGACY__
  231. /* Another name for `wcsstr' from XPG4. */
  232. /* SuSv3 did not use restrict keyword, probably because it was marked LEGACY
  233. we do to be in sync with wcsstr */
  234. extern wchar_t *wcswcs (const wchar_t *__restrict __haystack, const wchar_t *__restrict __needle)
  235. __THROW __attribute_pure__;
  236. #endif
  237. #ifdef __USE_GNU
  238. /* Return the number of wide characters in S, but at most MAXLEN. */
  239. extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
  240. __THROW __attribute_pure__;
  241. libc_hidden_proto(wcsnlen)
  242. #endif
  243. __BEGIN_NAMESPACE_C99
  244. /* Search N wide characters of S for C. */
  245. extern wchar_t *wmemchr (const wchar_t *__s, wchar_t __c, size_t __n)
  246. __THROW __attribute_pure__;
  247. libc_hidden_proto(wmemchr)
  248. /* Compare N wide characters of S1 and S2. */
  249. /* SuSv4 does not use restrict keyword for S1 and S2, glibc does */
  250. extern int wmemcmp (const wchar_t *__s1,
  251. const wchar_t *__s2, size_t __n)
  252. __THROW __attribute_pure__;
  253. /* Copy N wide characters of SRC to DEST. */
  254. extern wchar_t *wmemcpy (wchar_t *__restrict __s1,
  255. const wchar_t *__restrict __s2, size_t __n) __THROW;
  256. libc_hidden_proto(wmemcpy)
  257. /* Copy N wide characters of SRC to DEST, guaranteeing
  258. correct behavior for overlapping strings. */
  259. extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
  260. __THROW;
  261. /* Set N wide characters of S to C. */
  262. extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
  263. __END_NAMESPACE_C99
  264. #ifdef __USE_GNU
  265. /* Copy N wide characters of SRC to DEST and return pointer to following
  266. wide character. */
  267. extern wchar_t *wmempcpy (wchar_t *__restrict __s1,
  268. const wchar_t *__restrict __s2, size_t __n)
  269. __THROW;
  270. libc_hidden_proto(wmempcpy)
  271. #endif
  272. __BEGIN_NAMESPACE_C99
  273. /* Determine whether C constitutes a valid (one-byte) multibyte
  274. character. */
  275. extern wint_t btowc (int __c) __THROW;
  276. libc_hidden_proto(btowc)
  277. /* Determine whether C corresponds to a member of the extended
  278. character set whose multibyte representation is a single byte. */
  279. extern int wctob (wint_t __c) __THROW;
  280. /* Determine whether PS points to an object representing the initial
  281. state. */
  282. extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
  283. libc_hidden_proto(mbsinit)
  284. /* Write wide character representation of multibyte character pointed
  285. to by S to PWC. */
  286. extern size_t mbrtowc (wchar_t *__restrict __pwc,
  287. const char *__restrict __s, size_t __n,
  288. mbstate_t *__p) __THROW;
  289. libc_hidden_proto(mbrtowc)
  290. /* Write multibyte representation of wide character WC to S. */
  291. extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
  292. mbstate_t *__restrict __ps) __THROW;
  293. libc_hidden_proto(wcrtomb)
  294. /* Return number of bytes in multibyte character pointed to by S. */
  295. #if 0 /* uClibc: disabled */
  296. extern size_t __mbrlen (const char *__restrict __s, size_t __n,
  297. mbstate_t *__restrict __ps) __THROW;
  298. #endif
  299. extern size_t mbrlen (const char *__restrict __s, size_t __n,
  300. mbstate_t *__restrict __ps) __THROW;
  301. libc_hidden_proto(mbrlen)
  302. /* Write wide character representation of multibyte character string
  303. SRC to DST. */
  304. extern size_t mbsrtowcs (wchar_t *__restrict __dst,
  305. const char **__restrict __src, size_t __len,
  306. mbstate_t *__restrict __ps) __THROW;
  307. libc_hidden_proto(mbsrtowcs)
  308. /* Write multibyte character representation of wide character string
  309. SRC to DST. */
  310. extern size_t wcsrtombs (char *__restrict __dst,
  311. const wchar_t **__restrict __src, size_t __len,
  312. mbstate_t *__restrict __ps) __THROW;
  313. libc_hidden_proto(wcsrtombs)
  314. __END_NAMESPACE_C99
  315. #ifdef __USE_GNU
  316. /* Write wide character representation of at most NMC bytes of the
  317. multibyte character string SRC to DST. */
  318. extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
  319. const char **__restrict __src, size_t __nmc,
  320. size_t __len, mbstate_t *__restrict __ps) __THROW;
  321. libc_hidden_proto(mbsnrtowcs)
  322. /* Write multibyte character representation of at most NWC characters
  323. from the wide character string SRC to DST. */
  324. extern size_t wcsnrtombs (char *__restrict __dst,
  325. const wchar_t **__restrict __src,
  326. size_t __nwc, size_t __len,
  327. mbstate_t *__restrict __ps) __THROW;
  328. libc_hidden_proto(wcsnrtombs)
  329. #endif /* use GNU */
  330. /* The following functions are extensions found in X/Open CAE. */
  331. #ifdef __USE_XOPEN
  332. /* Determine number of column positions required for C. */
  333. extern int wcwidth (wchar_t __c) __THROW;
  334. /* Determine number of column positions required for first N wide
  335. characters (or fewer if S ends before this) in S. */
  336. extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
  337. libc_hidden_proto(wcswidth)
  338. #endif /* Use X/Open. */
  339. __BEGIN_NAMESPACE_C99
  340. #ifdef __UCLIBC_HAS_FLOATS__
  341. /* Convert initial portion of the wide string NPTR to `double'
  342. representation. */
  343. extern double wcstod (const wchar_t *__restrict __nptr,
  344. wchar_t **__restrict __endptr) __THROW;
  345. #ifdef __USE_ISOC99
  346. /* Likewise for `float' and `long double' sizes of floating-point numbers. */
  347. extern float wcstof (const wchar_t *__restrict __nptr,
  348. wchar_t **__restrict __endptr) __THROW;
  349. extern long double wcstold (const wchar_t *__restrict __nptr,
  350. wchar_t **__restrict __endptr) __THROW;
  351. #endif /* C99 */
  352. #endif /* __UCLIBC_HAS_FLOATS__ */
  353. /* Convert initial portion of wide string NPTR to `long int'
  354. representation. */
  355. extern long int wcstol (const wchar_t *__restrict __nptr,
  356. wchar_t **__restrict __endptr, int __base) __THROW;
  357. /* Convert initial portion of wide string NPTR to `unsigned long int'
  358. representation. */
  359. extern unsigned long int wcstoul (const wchar_t *__restrict __nptr,
  360. wchar_t **__restrict __endptr, int __base)
  361. __THROW;
  362. #if defined __USE_ISOC99 || (defined __GNUC__ && defined __USE_GNU)
  363. /* Convert initial portion of wide string NPTR to `long long int'
  364. representation. */
  365. __extension__
  366. extern long long int wcstoll (const wchar_t *__restrict __nptr,
  367. wchar_t **__restrict __endptr, int __base)
  368. __THROW;
  369. /* Convert initial portion of wide string NPTR to `unsigned long long int'
  370. representation. */
  371. __extension__
  372. extern unsigned long long int wcstoull (const wchar_t *__restrict __nptr,
  373. wchar_t **__restrict __endptr,
  374. int __base) __THROW;
  375. #endif /* ISO C99 or GCC and GNU. */
  376. __END_NAMESPACE_C99
  377. #if defined __GNUC__ && defined __USE_GNU
  378. /* Convert initial portion of wide string NPTR to `long long int'
  379. representation. */
  380. __extension__
  381. extern long long int wcstoq (const wchar_t *__restrict __nptr,
  382. wchar_t **__restrict __endptr, int __base)
  383. __THROW;
  384. /* Convert initial portion of wide string NPTR to `unsigned long long int'
  385. representation. */
  386. __extension__
  387. extern unsigned long long int wcstouq (const wchar_t *__restrict __nptr,
  388. wchar_t **__restrict __endptr,
  389. int __base) __THROW;
  390. #endif /* GCC and use GNU. */
  391. #ifdef __USE_GNU
  392. #ifdef __UCLIBC_HAS_XLOCALE__
  393. /* The concept of one static locale per category is not very well
  394. thought out. Many applications will need to process its data using
  395. information from several different locales. Another application is
  396. the implementation of the internationalization handling in the
  397. upcoming ISO C++ standard library. To support this another set of
  398. the functions using locale data exist which have an additional
  399. argument.
  400. Attention: all these functions are *not* standardized in any form.
  401. This is a proof-of-concept implementation. */
  402. /* Structure for reentrant locale using functions. This is an
  403. (almost) opaque type for the user level programs. */
  404. # include <xlocale.h>
  405. /* Special versions of the functions above which take the locale to
  406. use as an additional parameter. */
  407. extern long int wcstol_l (const wchar_t *__restrict __nptr,
  408. wchar_t **__restrict __endptr, int __base,
  409. __locale_t __loc) __THROW;
  410. extern unsigned long int wcstoul_l (const wchar_t *__restrict __nptr,
  411. wchar_t **__restrict __endptr,
  412. int __base, __locale_t __loc) __THROW;
  413. __extension__
  414. extern long long int wcstoll_l (const wchar_t *__restrict __nptr,
  415. wchar_t **__restrict __endptr,
  416. int __base, __locale_t __loc) __THROW;
  417. __extension__
  418. extern unsigned long long int wcstoull_l (const wchar_t *__restrict __nptr,
  419. wchar_t **__restrict __endptr,
  420. int __base, __locale_t __loc)
  421. __THROW;
  422. #ifdef __UCLIBC_HAS_FLOATS__
  423. extern double wcstod_l (const wchar_t *__restrict __nptr,
  424. wchar_t **__restrict __endptr, __locale_t __loc)
  425. __THROW;
  426. extern float wcstof_l (const wchar_t *__restrict __nptr,
  427. wchar_t **__restrict __endptr, __locale_t __loc)
  428. __THROW;
  429. extern long double wcstold_l (const wchar_t *__restrict __nptr,
  430. wchar_t **__restrict __endptr,
  431. __locale_t __loc) __THROW;
  432. #endif /* __UCLIBC_HAS_FLOATS__ */
  433. #endif /* __UCLIBC_HAS_XLOCALE__ */
  434. #endif /* GNU */
  435. #ifdef __USE_GNU
  436. /* Copy SRC to DEST, returning the address of the terminating L'\0' in
  437. DEST. */
  438. extern wchar_t *wcpcpy (wchar_t *__dest, const wchar_t *__src) __THROW;
  439. /* Copy no more than N characters of SRC to DEST, returning the address of
  440. the last character written into DEST. */
  441. extern wchar_t *wcpncpy (wchar_t *__dest, const wchar_t *__src, size_t __n)
  442. __THROW;
  443. #endif /* use GNU */
  444. /* Wide character I/O functions. */
  445. #if defined __USE_ISOC99 || defined __USE_UNIX98
  446. __BEGIN_NAMESPACE_C99
  447. /* Select orientation for stream. */
  448. extern int fwide (__FILE *__fp, int __mode) __THROW;
  449. /* Write formatted output to STREAM.
  450. This function is a possible cancellation point and therefore not
  451. marked with __THROW. */
  452. extern int fwprintf (__FILE *__restrict __stream,
  453. const wchar_t *__restrict __format, ...)
  454. /* __attribute__ ((__format__ (__wprintf__, 2, 3))) */;
  455. /* Write formatted output to stdout.
  456. This function is a possible cancellation point and therefore not
  457. marked with __THROW. */
  458. extern int wprintf (const wchar_t *__restrict __format, ...)
  459. /* __attribute__ ((__format__ (__wprintf__, 1, 2))) */;
  460. /* Write formatted output of at most N characters to S. */
  461. extern int swprintf (wchar_t *__restrict __s, size_t __n,
  462. const wchar_t *__restrict __format, ...)
  463. __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 4))) */;
  464. /* Write formatted output to S from argument list ARG.
  465. This function is a possible cancellation point and therefore not
  466. marked with __THROW. */
  467. extern int vfwprintf (__FILE *__restrict __s,
  468. const wchar_t *__restrict __format,
  469. __gnuc_va_list __arg)
  470. /* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
  471. libc_hidden_proto(vfwprintf)
  472. /* Write formatted output to stdout from argument list ARG.
  473. This function is a possible cancellation point and therefore not
  474. marked with __THROW. */
  475. extern int vwprintf (const wchar_t *__restrict __format,
  476. __gnuc_va_list __arg)
  477. /* __attribute__ ((__format__ (__wprintf__, 1, 0))) */;
  478. /* Write formatted output of at most N character to S from argument
  479. list ARG. */
  480. extern int vswprintf (wchar_t *__restrict __s, size_t __n,
  481. const wchar_t *__restrict __format,
  482. __gnuc_va_list __arg)
  483. __THROW /* __attribute__ ((__format__ (__wprintf__, 3, 0))) */;
  484. libc_hidden_proto(vswprintf)
  485. /* Read formatted input from STREAM.
  486. This function is a possible cancellation point and therefore not
  487. marked with __THROW. */
  488. extern int fwscanf (__FILE *__restrict __stream,
  489. const wchar_t *__restrict __format, ...)
  490. /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  491. /* Read formatted input from stdin.
  492. This function is a possible cancellation point and therefore not
  493. marked with __THROW. */
  494. extern int wscanf (const wchar_t *__restrict __format, ...)
  495. /* __attribute__ ((__format__ (__wscanf__, 1, 2))) */;
  496. /* Read formatted input from S. */
  497. extern int swscanf (const wchar_t *__restrict __s,
  498. const wchar_t *__restrict __format, ...)
  499. __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
  500. __END_NAMESPACE_C99
  501. #endif /* Use ISO C99 and Unix98. */
  502. #ifdef __USE_ISOC99
  503. __BEGIN_NAMESPACE_C99
  504. /* Read formatted input from S into argument list ARG.
  505. This function is a possible cancellation point and therefore not
  506. marked with __THROW. */
  507. extern int vfwscanf (__FILE *__restrict __s,
  508. const wchar_t *__restrict __format,
  509. __gnuc_va_list __arg)
  510. /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  511. libc_hidden_proto(vfwscanf)
  512. /* Read formatted input from stdin into argument list ARG.
  513. This function is a possible cancellation point and therefore not
  514. marked with __THROW. */
  515. extern int vwscanf (const wchar_t *__restrict __format,
  516. __gnuc_va_list __arg)
  517. /* __attribute__ ((__format__ (__wscanf__, 1, 0))) */;
  518. /* Read formatted input from S into argument list ARG. */
  519. extern int vswscanf (const wchar_t *__restrict __s,
  520. const wchar_t *__restrict __format,
  521. __gnuc_va_list __arg)
  522. __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 0))) */;
  523. libc_hidden_proto(vswscanf)
  524. __END_NAMESPACE_C99
  525. #endif /* Use ISO C99. */
  526. __BEGIN_NAMESPACE_C99
  527. /* Read a character from STREAM.
  528. These functions are possible cancellation points and therefore not
  529. marked with __THROW. */
  530. extern wint_t fgetwc (__FILE *__stream);
  531. libc_hidden_proto(fgetwc)
  532. extern wint_t getwc (__FILE *__stream);
  533. /* Read a character from stdin.
  534. This function is a possible cancellation point and therefore not
  535. marked with __THROW. */
  536. extern wint_t getwchar (void);
  537. /* Write a character to STREAM.
  538. These functions are possible cancellation points and therefore not
  539. marked with __THROW. */
  540. extern wint_t fputwc (wchar_t __wc, __FILE *__stream);
  541. libc_hidden_proto(fputwc)
  542. extern wint_t putwc (wchar_t __wc, __FILE *__stream);
  543. /* Write a character to stdout.
  544. This function is a possible cancellation point and therefore not
  545. marked with __THROW. */
  546. extern wint_t putwchar (wchar_t __wc);
  547. /* Get a newline-terminated wide character string of finite length
  548. from STREAM.
  549. This function is a possible cancellation point and therefore not
  550. marked with __THROW. */
  551. extern wchar_t *fgetws (wchar_t *__restrict __ws, int __n,
  552. __FILE *__restrict __stream);
  553. /* Write a string to STREAM.
  554. This function is a possible cancellation point and therefore not
  555. marked with __THROW. */
  556. extern int fputws (const wchar_t *__restrict __ws,
  557. __FILE *__restrict __stream);
  558. libc_hidden_proto(fputws)
  559. /* Push a character back onto the input buffer of STREAM.
  560. This function is a possible cancellation point and therefore not
  561. marked with __THROW. */
  562. extern wint_t ungetwc (wint_t __wc, __FILE *__stream);
  563. libc_hidden_proto(ungetwc)
  564. __END_NAMESPACE_C99
  565. #ifdef __USE_GNU
  566. /* These are defined to be equivalent to the `char' functions defined
  567. in POSIX.1:1996.
  568. These functions are not part of POSIX and therefore no official
  569. cancellation point. But due to similarity with an POSIX interface
  570. or due to the implementation they are cancellation points and
  571. therefore not marked with __THROW. */
  572. extern wint_t getwc_unlocked (__FILE *__stream);
  573. extern wint_t getwchar_unlocked (void);
  574. /* This is the wide character version of a GNU extension.
  575. This function is not part of POSIX and therefore no official
  576. cancellation point. But due to similarity with an POSIX interface
  577. or due to the implementation it is a cancellation point and
  578. therefore not marked with __THROW. */
  579. extern wint_t fgetwc_unlocked (__FILE *__stream);
  580. libc_hidden_proto(fgetwc_unlocked)
  581. /* Faster version when locking is not necessary.
  582. This function is not part of POSIX and therefore no official
  583. cancellation point. But due to similarity with an POSIX interface
  584. or due to the implementation it is a cancellation point and
  585. therefore not marked with __THROW. */
  586. extern wint_t fputwc_unlocked (wchar_t __wc, __FILE *__stream);
  587. libc_hidden_proto(fputwc_unlocked)
  588. /* These are defined to be equivalent to the `char' functions defined
  589. in POSIX.1:1996.
  590. These functions are not part of POSIX and therefore no official
  591. cancellation point. But due to similarity with an POSIX interface
  592. or due to the implementation they are cancellation points and
  593. therefore not marked with __THROW. */
  594. extern wint_t putwc_unlocked (wchar_t __wc, __FILE *__stream);
  595. extern wint_t putwchar_unlocked (wchar_t __wc);
  596. /* This function does the same as `fgetws' but does not lock the stream.
  597. This function is not part of POSIX and therefore no official
  598. cancellation point. But due to similarity with an POSIX interface
  599. or due to the implementation it is a cancellation point and
  600. therefore not marked with __THROW. */
  601. extern wchar_t *fgetws_unlocked (wchar_t *__restrict __ws, int __n,
  602. __FILE *__restrict __stream);
  603. libc_hidden_proto(fgetws_unlocked)
  604. /* This function does the same as `fputws' but does not lock the stream.
  605. This function is not part of POSIX and therefore no official
  606. cancellation point. But due to similarity with an POSIX interface
  607. or due to the implementation it is a cancellation point and
  608. therefore not marked with __THROW. */
  609. extern int fputws_unlocked (const wchar_t *__restrict __ws,
  610. __FILE *__restrict __stream);
  611. libc_hidden_proto(fputws_unlocked)
  612. #endif
  613. __BEGIN_NAMESPACE_C99
  614. /* Format TP into S according to FORMAT.
  615. Write no more than MAXSIZE wide characters and return the number
  616. of wide characters written, or 0 if it would exceed MAXSIZE. */
  617. extern size_t wcsftime (wchar_t *__restrict __s, size_t __maxsize,
  618. const wchar_t *__restrict __format,
  619. const struct tm *__restrict __tp) __THROW;
  620. __END_NAMESPACE_C99
  621. # if defined __USE_GNU && defined __UCLIBC_HAS_XLOCALE__
  622. # include <xlocale.h>
  623. /* Similar to `wcsftime' but takes the information from
  624. the provided locale and not the global locale. */
  625. extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
  626. const wchar_t *__restrict __format,
  627. const struct tm *__restrict __tp,
  628. __locale_t __loc) __THROW;
  629. libc_hidden_proto(wcsftime_l)
  630. # endif
  631. /* The X/Open standard demands that most of the functions defined in
  632. the <wctype.h> header must also appear here. This is probably
  633. because some X/Open members wrote their implementation before the
  634. ISO C standard was published and introduced the better solution.
  635. We have to provide these definitions for compliance reasons but we
  636. do this nonsense only if really necessary. */
  637. #if defined __USE_UNIX98 && !defined __USE_GNU
  638. # define __need_iswxxx
  639. # include <wctype.h>
  640. #endif
  641. #ifdef _LIBC
  642. extern size_t __wcslcpy(wchar_t *__restrict dst,
  643. const wchar_t *__restrict src, size_t n) attribute_hidden;
  644. #endif
  645. __END_DECLS
  646. #endif /* _WCHAR_H defined */
  647. #endif /* wchar.h */