wchar.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. #ifndef _WCHAR_H_
  2. #define _WCHAR_H_
  3. #include <_ansi.h>
  4. #include <sys/reent.h>
  5. #define __need_size_t
  6. #define __need_wchar_t
  7. #define __need_wint_t
  8. #define __need_NULL
  9. #include <stddef.h>
  10. /* For _mbstate_t definition. */
  11. #include <sys/_types.h>
  12. #include <sys/cdefs.h>
  13. /* For __STDC_ISO_10646__ */
  14. #include <sys/features.h>
  15. /* typedef only __gnuc_va_list, used throughout the header */
  16. #define __need___va_list
  17. #include <stdarg.h>
  18. /* typedef va_list only when required */
  19. #if __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE
  20. #ifdef __GNUC__
  21. #ifndef _VA_LIST_DEFINED
  22. typedef __gnuc_va_list va_list;
  23. #define _VA_LIST_DEFINED
  24. #endif
  25. #else /* !__GNUC__ */
  26. #include <stdarg.h>
  27. #endif
  28. #endif /* __POSIX_VISIBLE >= 200809 || __XSI_VISIBLE */
  29. #if __XSI_VISIBLE /* && __XSI_VISIBLE < 800 */ && !__GNU_VISIBLE
  30. #include <wctype.h>
  31. #endif
  32. #ifndef WEOF
  33. # define WEOF ((wint_t)-1)
  34. #endif
  35. /* This must match definition in <stdint.h> */
  36. #ifndef WCHAR_MIN
  37. #ifdef __WCHAR_MIN__
  38. #define WCHAR_MIN __WCHAR_MIN__
  39. #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
  40. #define WCHAR_MIN (0 + L'\0')
  41. #else
  42. #define WCHAR_MIN (-0x7fffffff - 1 + L'\0')
  43. #endif
  44. #endif
  45. /* This must match definition in <stdint.h> */
  46. #ifndef WCHAR_MAX
  47. #ifdef __WCHAR_MAX__
  48. #define WCHAR_MAX __WCHAR_MAX__
  49. #elif defined(__WCHAR_UNSIGNED__) || (L'\0' - 1 > 0)
  50. #define WCHAR_MAX (0xffffffffu + L'\0')
  51. #else
  52. #define WCHAR_MAX (0x7fffffff + L'\0')
  53. #endif
  54. #endif
  55. #if __POSIX_VISIBLE >= 200809
  56. #include <sys/_locale.h>
  57. #endif
  58. _BEGIN_STD_C
  59. #if __POSIX_VISIBLE >= 200809 || _XSI_VISIBLE
  60. /* As in stdio.h, <sys/reent.h> defines __FILE. */
  61. #if !defined(__FILE_defined)
  62. typedef __FILE FILE;
  63. # define __FILE_defined
  64. #endif
  65. #endif
  66. /* As required by POSIX.1-2008, declare tm as incomplete type.
  67. The actual definition is in time.h. */
  68. struct tm;
  69. #ifndef _MBSTATE_T
  70. #define _MBSTATE_T
  71. typedef _mbstate_t mbstate_t;
  72. #endif /* _MBSTATE_T */
  73. wint_t btowc (int);
  74. int wctob (wint_t);
  75. size_t mbrlen (const char *__restrict, size_t, mbstate_t *__restrict);
  76. size_t mbrtowc (wchar_t *__restrict, const char *__restrict, size_t,
  77. mbstate_t *__restrict);
  78. size_t _mbrtowc_r (struct _reent *, wchar_t * , const char * ,
  79. size_t, mbstate_t *);
  80. int mbsinit (const mbstate_t *);
  81. #if __POSIX_VISIBLE >= 200809
  82. size_t mbsnrtowcs (wchar_t *__restrict, const char **__restrict,
  83. size_t, size_t, mbstate_t *__restrict);
  84. #endif
  85. size_t _mbsnrtowcs_r (struct _reent *, wchar_t * , const char ** ,
  86. size_t, size_t, mbstate_t *);
  87. size_t mbsrtowcs (wchar_t *__restrict, const char **__restrict, size_t,
  88. mbstate_t *__restrict);
  89. size_t _mbsrtowcs_r (struct _reent *, wchar_t * , const char ** , size_t, mbstate_t *);
  90. size_t wcrtomb (char *__restrict, wchar_t, mbstate_t *__restrict);
  91. size_t _wcrtomb_r (struct _reent *, char * , wchar_t, mbstate_t *);
  92. #if __POSIX_VISIBLE >= 200809
  93. size_t wcsnrtombs (char *__restrict, const wchar_t **__restrict,
  94. size_t, size_t, mbstate_t *__restrict);
  95. #endif
  96. size_t _wcsnrtombs_r (struct _reent *, char * , const wchar_t ** ,
  97. size_t, size_t, mbstate_t *);
  98. size_t wcsrtombs (char *__restrict, const wchar_t **__restrict,
  99. size_t, mbstate_t *__restrict);
  100. size_t _wcsrtombs_r (struct _reent *, char * , const wchar_t ** ,
  101. size_t, mbstate_t *);
  102. #if __POSIX_VISIBLE >= 200809
  103. int wcscasecmp (const wchar_t *, const wchar_t *);
  104. #endif
  105. wchar_t *wcscat (wchar_t *__restrict, const wchar_t *__restrict);
  106. wchar_t *wcschr (const wchar_t *, wchar_t);
  107. int wcscmp (const wchar_t *, const wchar_t *);
  108. int wcscoll (const wchar_t *, const wchar_t *);
  109. wchar_t *wcscpy (wchar_t *__restrict, const wchar_t *__restrict);
  110. #if __POSIX_VISIBLE >= 200809
  111. wchar_t *wcpcpy (wchar_t *__restrict,
  112. const wchar_t *__restrict);
  113. wchar_t *wcsdup (const wchar_t *) __malloc_like __result_use_check;
  114. #endif
  115. wchar_t *_wcsdup_r (struct _reent *, const wchar_t * );
  116. size_t wcscspn (const wchar_t *, const wchar_t *);
  117. size_t wcsftime (wchar_t *__restrict, size_t,
  118. const wchar_t *__restrict, const struct tm *__restrict);
  119. #if __GNU_VISIBLE
  120. size_t wcsftime_l (wchar_t *__restrict, size_t, const wchar_t *__restrict,
  121. const struct tm *__restrict, locale_t);
  122. #endif
  123. size_t wcslcat (wchar_t *, const wchar_t *, size_t);
  124. size_t wcslcpy (wchar_t *, const wchar_t *, size_t);
  125. size_t wcslen (const wchar_t *);
  126. #if __POSIX_VISIBLE >= 200809
  127. int wcsncasecmp (const wchar_t *, const wchar_t *, size_t);
  128. #endif
  129. wchar_t *wcsncat (wchar_t *__restrict,
  130. const wchar_t *__restrict, size_t);
  131. int wcsncmp (const wchar_t *, const wchar_t *, size_t);
  132. wchar_t *wcsncpy (wchar_t *__restrict,
  133. const wchar_t *__restrict, size_t);
  134. #if __POSIX_VISIBLE >= 200809
  135. wchar_t *wcpncpy (wchar_t *__restrict,
  136. const wchar_t *__restrict, size_t);
  137. size_t wcsnlen (const wchar_t *, size_t);
  138. #endif
  139. wchar_t *wcspbrk (const wchar_t *, const wchar_t *);
  140. wchar_t *wcsrchr (const wchar_t *, wchar_t);
  141. size_t wcsspn (const wchar_t *, const wchar_t *);
  142. wchar_t *wcsstr (const wchar_t *__restrict,
  143. const wchar_t *__restrict);
  144. wchar_t *wcstok (wchar_t *__restrict, const wchar_t *__restrict,
  145. wchar_t **__restrict);
  146. double wcstod (const wchar_t *__restrict, wchar_t **__restrict);
  147. double _wcstod_r (struct _reent *, const wchar_t *, wchar_t **);
  148. #if __ISO_C_VISIBLE >= 1999
  149. float wcstof (const wchar_t *__restrict, wchar_t **__restrict);
  150. #endif
  151. float _wcstof_r (struct _reent *, const wchar_t *, wchar_t **);
  152. #if __XSI_VISIBLE
  153. int wcswidth (const wchar_t *, size_t);
  154. #endif
  155. size_t wcsxfrm (wchar_t *__restrict, const wchar_t *__restrict,
  156. size_t);
  157. #if __POSIX_VISIBLE >= 200809
  158. extern int wcscasecmp_l (const wchar_t *, const wchar_t *, locale_t);
  159. extern int wcsncasecmp_l (const wchar_t *, const wchar_t *, size_t, locale_t);
  160. extern int wcscoll_l (const wchar_t *, const wchar_t *, locale_t);
  161. extern size_t wcsxfrm_l (wchar_t *__restrict, const wchar_t *__restrict, size_t,
  162. locale_t);
  163. #endif
  164. #if __XSI_VISIBLE
  165. int wcwidth (const wchar_t);
  166. #endif
  167. wchar_t *wmemchr (const wchar_t *, wchar_t, size_t);
  168. int wmemcmp (const wchar_t *, const wchar_t *, size_t);
  169. wchar_t *wmemcpy (wchar_t *__restrict, const wchar_t *__restrict,
  170. size_t);
  171. wchar_t *wmemmove (wchar_t *, const wchar_t *, size_t);
  172. #if __GNU_VISIBLE
  173. wchar_t *wmempcpy (wchar_t *__restrict, const wchar_t *__restrict,
  174. size_t);
  175. #endif
  176. wchar_t *wmemset (wchar_t *, wchar_t, size_t);
  177. long wcstol (const wchar_t *__restrict, wchar_t **__restrict, int);
  178. #if __ISO_C_VISIBLE >= 1999
  179. long long wcstoll (const wchar_t *__restrict, wchar_t **__restrict,
  180. int);
  181. #endif
  182. unsigned long wcstoul (const wchar_t *__restrict, wchar_t **__restrict,
  183. int);
  184. #if __ISO_C_VISIBLE >= 1999
  185. unsigned long long wcstoull (const wchar_t *__restrict,
  186. wchar_t **__restrict, int);
  187. #endif
  188. long _wcstol_r (struct _reent *, const wchar_t *, wchar_t **, int);
  189. long long _wcstoll_r (struct _reent *, const wchar_t *, wchar_t **, int);
  190. unsigned long _wcstoul_r (struct _reent *, const wchar_t *, wchar_t **, int);
  191. unsigned long long _wcstoull_r (struct _reent *, const wchar_t *, wchar_t **, int);
  192. #if __ISO_C_VISIBLE >= 1999
  193. long double wcstold (const wchar_t *, wchar_t **);
  194. #endif
  195. #if __GNU_VISIBLE
  196. long wcstol_l (const wchar_t *__restrict, wchar_t **__restrict, int, locale_t);
  197. long long wcstoll_l (const wchar_t *__restrict, wchar_t **__restrict, int,
  198. locale_t);
  199. unsigned long wcstoul_l (const wchar_t *__restrict, wchar_t **__restrict, int,
  200. locale_t);
  201. unsigned long long wcstoull_l (const wchar_t *__restrict, wchar_t **__restrict,
  202. int, locale_t);
  203. double wcstod_l (const wchar_t *, wchar_t **, locale_t);
  204. float wcstof_l (const wchar_t *, wchar_t **, locale_t);
  205. long double wcstold_l (const wchar_t *, wchar_t **, locale_t);
  206. #endif
  207. wint_t fgetwc (__FILE *);
  208. wchar_t *fgetws (wchar_t *__restrict, int, __FILE *__restrict);
  209. wint_t fputwc (wchar_t, __FILE *);
  210. int fputws (const wchar_t *__restrict, __FILE *__restrict);
  211. #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
  212. int fwide (__FILE *, int);
  213. #endif
  214. wint_t getwc (__FILE *);
  215. wint_t getwchar (void);
  216. wint_t putwc (wchar_t, __FILE *);
  217. wint_t putwchar (wchar_t);
  218. wint_t ungetwc (wint_t wc, __FILE *);
  219. wint_t _fgetwc_r (struct _reent *, __FILE *);
  220. wint_t _fgetwc_unlocked_r (struct _reent *, __FILE *);
  221. wchar_t *_fgetws_r (struct _reent *, wchar_t *, int, __FILE *);
  222. wchar_t *_fgetws_unlocked_r (struct _reent *, wchar_t *, int, __FILE *);
  223. wint_t _fputwc_r (struct _reent *, wchar_t, __FILE *);
  224. wint_t _fputwc_unlocked_r (struct _reent *, wchar_t, __FILE *);
  225. int _fputws_r (struct _reent *, const wchar_t *, __FILE *);
  226. int _fputws_unlocked_r (struct _reent *, const wchar_t *, __FILE *);
  227. int _fwide_r (struct _reent *, __FILE *, int);
  228. wint_t _getwc_r (struct _reent *, __FILE *);
  229. wint_t _getwc_unlocked_r (struct _reent *, __FILE *);
  230. wint_t _getwchar_r (struct _reent *ptr);
  231. wint_t _getwchar_unlocked_r (struct _reent *ptr);
  232. wint_t _putwc_r (struct _reent *, wchar_t, __FILE *);
  233. wint_t _putwc_unlocked_r (struct _reent *, wchar_t, __FILE *);
  234. wint_t _putwchar_r (struct _reent *, wchar_t);
  235. wint_t _putwchar_unlocked_r (struct _reent *, wchar_t);
  236. wint_t _ungetwc_r (struct _reent *, wint_t wc, __FILE *);
  237. #if __GNU_VISIBLE
  238. wint_t fgetwc_unlocked (__FILE *);
  239. wchar_t *fgetws_unlocked (wchar_t *__restrict, int, __FILE *__restrict);
  240. wint_t fputwc_unlocked (wchar_t, __FILE *);
  241. int fputws_unlocked (const wchar_t *__restrict, __FILE *__restrict);
  242. wint_t getwc_unlocked (__FILE *);
  243. wint_t getwchar_unlocked (void);
  244. wint_t putwc_unlocked (wchar_t, __FILE *);
  245. wint_t putwchar_unlocked (wchar_t);
  246. #endif
  247. #if __POSIX_VISIBLE >= 200809
  248. __FILE *open_wmemstream (wchar_t **, size_t *);
  249. #endif
  250. __FILE *_open_wmemstream_r (struct _reent *, wchar_t **, size_t *);
  251. #ifndef __VALIST
  252. #ifdef __GNUC__
  253. #define __VALIST __gnuc_va_list
  254. #else
  255. #define __VALIST char*
  256. #endif
  257. #endif
  258. #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
  259. int fwprintf (__FILE *__restrict, const wchar_t *__restrict, ...);
  260. int swprintf (wchar_t *__restrict, size_t,
  261. const wchar_t *__restrict, ...);
  262. int vfwprintf (__FILE *__restrict, const wchar_t *__restrict,
  263. __VALIST);
  264. int vswprintf (wchar_t *__restrict, size_t,
  265. const wchar_t *__restrict, __VALIST);
  266. int vwprintf (const wchar_t *__restrict, __VALIST);
  267. int wprintf (const wchar_t *__restrict, ...);
  268. #endif
  269. int _fwprintf_r (struct _reent *, __FILE *, const wchar_t *, ...);
  270. int _swprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, ...);
  271. int _vfwprintf_r (struct _reent *, __FILE *, const wchar_t *, __VALIST);
  272. int _vswprintf_r (struct _reent *, wchar_t *, size_t, const wchar_t *, __VALIST);
  273. int _vwprintf_r (struct _reent *, const wchar_t *, __VALIST);
  274. int _wprintf_r (struct _reent *, const wchar_t *, ...);
  275. #if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE >= 500
  276. int fwscanf (__FILE *__restrict, const wchar_t *__restrict, ...);
  277. int swscanf (const wchar_t *__restrict,
  278. const wchar_t *__restrict, ...);
  279. int vfwscanf (__FILE *__restrict, const wchar_t *__restrict,
  280. __VALIST);
  281. int vswscanf (const wchar_t *__restrict, const wchar_t *__restrict,
  282. __VALIST);
  283. int vwscanf (const wchar_t *__restrict, __VALIST);
  284. int wscanf (const wchar_t *__restrict, ...);
  285. #endif
  286. int _fwscanf_r (struct _reent *, __FILE *, const wchar_t *, ...);
  287. int _swscanf_r (struct _reent *, const wchar_t *, const wchar_t *, ...);
  288. int _vfwscanf_r (struct _reent *, __FILE *, const wchar_t *, __VALIST);
  289. int _vswscanf_r (struct _reent *, const wchar_t *, const wchar_t *, __VALIST);
  290. int _vwscanf_r (struct _reent *, const wchar_t *, __VALIST);
  291. int _wscanf_r (struct _reent *, const wchar_t *, ...);
  292. #define getwc(fp) fgetwc(fp)
  293. #define putwc(wc,fp) fputwc((wc), (fp))
  294. #define getwchar() fgetwc(_REENT->_stdin)
  295. #define putwchar(wc) fputwc((wc), _REENT->_stdout)
  296. #if __GNU_VISIBLE
  297. #define getwc_unlocked(fp) fgetwc_unlocked(fp)
  298. #define putwc_unlocked(wc,fp) fputwc_unlocked((wc), (fp))
  299. #define getwchar_unlocked() fgetwc_unlocked(_REENT->_stdin)
  300. #define putwchar_unlocked(wc) fputwc_unlocked((wc), _REENT->_stdout)
  301. #endif
  302. _END_STD_C
  303. #if __SSP_FORTIFY_LEVEL > 0
  304. #include <ssp/wchar.h>
  305. #endif
  306. #endif /* _WCHAR_H_ */