1 | /*
|
---|
2 | * Copyright (c) 2025 Jiří Zárevúcky
|
---|
3 | * All rights reserved.
|
---|
4 | *
|
---|
5 | * Redistribution and use in source and binary forms, with or without
|
---|
6 | * modification, are permitted provided that the following conditions
|
---|
7 | * are met:
|
---|
8 | *
|
---|
9 | * - Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * - The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission.
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | #ifndef _LIBC_WCHAR_H_
|
---|
30 | #define _LIBC_WCHAR_H_
|
---|
31 |
|
---|
32 | #include <_bits/NULL.h>
|
---|
33 | #include <_bits/WEOF.h>
|
---|
34 | #include <_bits/mbstate_t.h>
|
---|
35 | #include <_bits/size_t.h>
|
---|
36 | #include <_bits/wchar_limits.h>
|
---|
37 | #include <_bits/wchar_t.h>
|
---|
38 | #include <_bits/wint_t.h>
|
---|
39 | #include <stdarg.h>
|
---|
40 |
|
---|
41 | /* Forward declarations for types. */
|
---|
42 | typedef struct _IO_FILE FILE;
|
---|
43 | struct tm;
|
---|
44 |
|
---|
45 | /*
|
---|
46 | * Complete list of functions straight out of ISO/IEC 9899:2023 (N3096 draft).
|
---|
47 | * Only some of these are implemented, but keep all standard prototypes here
|
---|
48 | * for less pain in libposix etc.
|
---|
49 | */
|
---|
50 |
|
---|
51 | int fputws(const wchar_t *__restrict__, FILE *__restrict__);
|
---|
52 | int fwide(FILE *, int mode);
|
---|
53 | int fwprintf(FILE *__restrict__, const wchar_t *__restrict__, ...);
|
---|
54 | int fwscanf(FILE *__restrict__, const wchar_t *__restrict__, ...);
|
---|
55 | int mbsinit(const mbstate_t *);
|
---|
56 | int swprintf(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, ...);
|
---|
57 | int swscanf(const wchar_t *__restrict__, const wchar_t *__restrict__, ...);
|
---|
58 | int vfwprintf(FILE *__restrict__, const wchar_t *__restrict__, va_list);
|
---|
59 | int vfwscanf(FILE *__restrict__, const wchar_t *__restrict__, va_list);
|
---|
60 | int vswprintf(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list);
|
---|
61 | int vswscanf(const wchar_t *__restrict__, const wchar_t *__restrict__, va_list);
|
---|
62 | int vwprintf(const wchar_t *__restrict__, va_list);
|
---|
63 | int vwscanf(const wchar_t *__restrict__, va_list);
|
---|
64 | int wcscmp(const wchar_t *, const wchar_t *);
|
---|
65 | int wcscoll(const wchar_t *, const wchar_t *);
|
---|
66 | int wcsncmp(const wchar_t *, const wchar_t *, size_t);
|
---|
67 | int wctob(wint_t);
|
---|
68 | int wmemcmp(const wchar_t *, const wchar_t *, size_t);
|
---|
69 | int wprintf(const wchar_t *__restrict__, ...);
|
---|
70 | int wscanf(const wchar_t *__restrict__, ...);
|
---|
71 | long int wcstol(const wchar_t *__restrict__, wchar_t **__restrict__, int);
|
---|
72 | long long int wcstoll(const wchar_t *__restrict__, wchar_t **__restrict__, int);
|
---|
73 | size_t mbrlen(const char *__restrict__, size_t, mbstate_t *__restrict__);
|
---|
74 | size_t mbrtowc(wchar_t *__restrict__ pwc, const char *__restrict__, size_t, mbstate_t *__restrict__);
|
---|
75 | size_t mbsrtowcs(wchar_t *__restrict__ dst, const char **__restrict__ src, size_t, mbstate_t *__restrict__);
|
---|
76 | size_t wcrtomb(char *__restrict__, wchar_t wc, mbstate_t *__restrict__);
|
---|
77 | size_t wcscspn(const wchar_t *, const wchar_t *);
|
---|
78 | size_t wcsftime(wchar_t *__restrict__, size_t maxsize, const wchar_t *__restrict__, const struct tm *__restrict__ timeptr);
|
---|
79 | size_t wcslen(const wchar_t *);
|
---|
80 | size_t wcsrtombs(char *__restrict__ dst, const wchar_t **__restrict__ src, size_t, mbstate_t *__restrict__);
|
---|
81 | size_t wcsspn(const wchar_t *, const wchar_t *);
|
---|
82 | size_t wcsxfrm(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
|
---|
83 | unsigned long int wcstoul(const wchar_t *__restrict__, wchar_t **__restrict__, int);
|
---|
84 | unsigned long long int wcstoull(const wchar_t *__restrict__, wchar_t **__restrict__, int);
|
---|
85 | wchar_t *fgetws(wchar_t *__restrict__, int, FILE *__restrict__);
|
---|
86 | wchar_t *wcscat(wchar_t *__restrict__, const wchar_t *__restrict__);
|
---|
87 | wchar_t *wcscpy(wchar_t *__restrict__, const wchar_t *__restrict__);
|
---|
88 | wchar_t *wcsncat(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
|
---|
89 | wchar_t *wcsncpy(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
|
---|
90 | wchar_t *wcstok(wchar_t *__restrict__, const wchar_t *__restrict__, wchar_t **__restrict__);
|
---|
91 | wchar_t *wmemcpy(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
|
---|
92 | wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
|
---|
93 | wchar_t *wmemset(wchar_t *, wchar_t, size_t);
|
---|
94 | wint_t btowc(int);
|
---|
95 | wint_t fgetwc(FILE *);
|
---|
96 | wint_t fputwc(wchar_t, FILE *);
|
---|
97 | wint_t getwc(FILE *);
|
---|
98 | wint_t getwchar(void);
|
---|
99 | wint_t putwc(wchar_t, FILE *);
|
---|
100 | wint_t putwchar(wchar_t);
|
---|
101 | wint_t ungetwc(wint_t, FILE *);
|
---|
102 |
|
---|
103 | // TODO: In C23, these functions have generic macro definitions for correct
|
---|
104 | // const handling.
|
---|
105 | wchar_t *wcschr(const wchar_t *, wchar_t);
|
---|
106 | wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
|
---|
107 | wchar_t *wcsrchr(const wchar_t *, wchar_t);
|
---|
108 | wchar_t *wcsstr(const wchar_t *, const wchar_t *);
|
---|
109 | wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
|
---|
110 |
|
---|
111 | #endif /* _LIBC_WCHAR_H_ */
|
---|