wchar.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <bits/FILE.h>
  8. #include <stdarg.h>
  9. #include <stddef.h>
  10. #include <sys/cdefs.h>
  11. __BEGIN_DECLS
  12. // Note: wint_t is unsigned on gcc, and signed on clang.
  13. #ifndef WEOF
  14. # ifdef __clang__
  15. # define WEOF (-1)
  16. # else
  17. # define WEOF (0xffffffffu)
  18. # endif
  19. #endif
  20. #undef WCHAR_MAX
  21. #undef WCHAR_MIN
  22. #define WCHAR_MAX __WCHAR_MAX__
  23. #ifdef __WCHAR_MIN__
  24. # define WCHAR_MIN __WCHAR_MIN__
  25. #else
  26. // Note: This assumes that wchar_t is a signed type.
  27. # define WCHAR_MIN (-WCHAR_MAX - 1)
  28. #endif
  29. typedef __WINT_TYPE__ wint_t;
  30. typedef unsigned long int wctype_t;
  31. // A zero-initialized mbstate_t struct must be a valid initial state.
  32. typedef struct {
  33. unsigned char bytes[4];
  34. unsigned int stored_bytes;
  35. } mbstate_t;
  36. struct tm;
  37. size_t wcslen(const wchar_t*);
  38. wchar_t* wcscpy(wchar_t*, const wchar_t*);
  39. wchar_t* wcsdup(const wchar_t*);
  40. wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t);
  41. __attribute__((warn_unused_result)) size_t wcslcpy(wchar_t*, const wchar_t*, size_t);
  42. int wcscmp(const wchar_t*, const wchar_t*);
  43. int wcsncmp(const wchar_t*, const wchar_t*, size_t);
  44. wchar_t* wcschr(const wchar_t*, int);
  45. wchar_t* wcsrchr(const wchar_t*, wchar_t);
  46. wchar_t* wcscat(wchar_t*, const wchar_t*);
  47. wchar_t* wcsncat(wchar_t*, const wchar_t*, size_t);
  48. wchar_t* wcstok(wchar_t*, const wchar_t*, wchar_t**);
  49. long wcstol(const wchar_t*, wchar_t**, int);
  50. long long wcstoll(const wchar_t*, wchar_t**, int);
  51. wint_t btowc(int c);
  52. size_t mbrtowc(wchar_t*, const char*, size_t, mbstate_t*);
  53. size_t mbrlen(const char*, size_t, mbstate_t*);
  54. size_t wcrtomb(char*, wchar_t, mbstate_t*);
  55. int wcscoll(const wchar_t*, const wchar_t*);
  56. size_t wcsxfrm(wchar_t*, const wchar_t*, size_t);
  57. int wctob(wint_t);
  58. int mbsinit(const mbstate_t*);
  59. wchar_t* wcspbrk(const wchar_t*, const wchar_t*);
  60. wchar_t* wcsstr(const wchar_t*, const wchar_t*);
  61. wchar_t* wmemchr(const wchar_t*, wchar_t, size_t);
  62. wchar_t* wmemcpy(wchar_t*, const wchar_t*, size_t);
  63. wchar_t* wmemset(wchar_t*, wchar_t, size_t);
  64. wchar_t* wmemmove(wchar_t*, const wchar_t*, size_t);
  65. unsigned long wcstoul(const wchar_t*, wchar_t**, int);
  66. unsigned long long wcstoull(const wchar_t*, wchar_t**, int);
  67. float wcstof(const wchar_t*, wchar_t**);
  68. double wcstod(const wchar_t*, wchar_t**);
  69. long double wcstold(const wchar_t*, wchar_t**);
  70. int wcwidth(wchar_t);
  71. size_t wcsrtombs(char*, const wchar_t**, size_t, mbstate_t*);
  72. size_t mbsrtowcs(wchar_t*, const char**, size_t, mbstate_t*);
  73. int wmemcmp(const wchar_t*, const wchar_t*, size_t);
  74. size_t wcsnrtombs(char*, const wchar_t**, size_t, size_t, mbstate_t*);
  75. size_t mbsnrtowcs(wchar_t*, const char**, size_t, size_t, mbstate_t*);
  76. size_t wcscspn(const wchar_t* wcs, const wchar_t* reject);
  77. size_t wcsspn(const wchar_t* wcs, const wchar_t* accept);
  78. wint_t fgetwc(FILE* stream);
  79. wint_t getwc(FILE* stream);
  80. wint_t getwchar(void);
  81. wint_t fputwc(wchar_t wc, FILE* stream);
  82. wint_t putwc(wchar_t wc, FILE* stream);
  83. wint_t putwchar(wchar_t wc);
  84. wchar_t* fgetws(wchar_t* __restrict ws, int n, FILE* __restrict stream);
  85. int fputws(const wchar_t* __restrict ws, FILE* __restrict stream);
  86. wint_t ungetwc(wint_t wc, FILE* stream);
  87. int fwide(FILE* stream, int mode);
  88. int wprintf(const wchar_t* __restrict format, ...);
  89. int fwprintf(FILE* __restrict stream, const wchar_t* __restrict format, ...);
  90. int swprintf(wchar_t* __restrict wcs, size_t maxlen, const wchar_t* __restrict format, ...);
  91. int vwprintf(const wchar_t* __restrict format, va_list args);
  92. int vfwprintf(FILE* __restrict stream, const wchar_t* __restrict format, va_list args);
  93. int vswprintf(wchar_t* __restrict wcs, size_t maxlen, const wchar_t* __restrict format, va_list args);
  94. int fwscanf(FILE* __restrict stream, const wchar_t* __restrict format, ...);
  95. int swscanf(const wchar_t* __restrict ws, const wchar_t* __restrict format, ...);
  96. int wscanf(const wchar_t* __restrict format, ...);
  97. int vfwscanf(FILE* __restrict stream, const wchar_t* __restrict format, va_list arg);
  98. int vswscanf(const wchar_t* __restrict ws, const wchar_t* __restrict format, va_list arg);
  99. int vwscanf(const wchar_t* __restrict format, va_list arg);
  100. size_t wcsftime(wchar_t* __restrict wcs, size_t maxsize, const wchar_t* __restrict format, const struct tm* __restrict timeptr);
  101. __END_DECLS