This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 424
/
wchar_.d
251 lines (233 loc) · 6 KB
/
wchar_.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/**
* D header file for C99.
*
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_wchar.h.html, _wchar.h)
*
* Copyright: Copyright Sean Kelly 2005 - 2009.
* License: Distributed under the
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0).
* (See accompanying file LICENSE)
* Authors: Sean Kelly
* Source: $(DRUNTIMESRC core/stdc/_wchar_.d)
* Standards: ISO/IEC 9899:1999 (E)
*/
module core.stdc.wchar_;
private import core.stdc.config;
private import core.stdc.stdarg; // for va_list
private import core.stdc.stdio; // for FILE, not exposed per spec
public import core.stdc.stddef; // for wchar_t
public import core.stdc.time; // for tm
public import core.stdc.stdint; // for WCHAR_MIN, WCHAR_MAX
extern (C):
@system:
nothrow:
@nogc:
version( CRuntime_Glibc )
{
///
struct mbstate_t
{
int __count;
union ___value
{
wint_t __wch;
char[4] __wchb;
}
___value __value;
}
}
else version (OpenBSD)
{
union __mbstate_t
{
char[128] __mbstate8;
int64_t __mbstateL;
}
alias mbstate_t = __mbstate_t;
}
else version (Solaris)
{
///
struct __mbstate_t
{
version (D_LP64)
{
long[4] __filler;
}
else
{
int[6] __filler;
}
}
}
else version( CRuntime_UClibc )
{
///
struct mbstate_t
{
wchar_t __mask;
wchar_t __wc;
}
}
else
{
///
alias int mbstate_t;
}
///
alias wchar_t wint_t;
///
enum wchar_t WEOF = 0xFFFF;
///
int fwprintf(FILE* stream, in wchar_t* format, ...);
///
int fwscanf(FILE* stream, in wchar_t* format, ...);
///
int swprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
///
int swscanf(in wchar_t* s, in wchar_t* format, ...);
///
int vfwprintf(FILE* stream, in wchar_t* format, va_list arg);
///
int vfwscanf(FILE* stream, in wchar_t* format, va_list arg);
///
int vswprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
///
int vswscanf(in wchar_t* s, in wchar_t* format, va_list arg);
///
int vwprintf(in wchar_t* format, va_list arg);
///
int vwscanf(in wchar_t* format, va_list arg);
///
int wprintf(in wchar_t* format, ...);
///
int wscanf(in wchar_t* format, ...);
// No unsafe pointer manipulation.
@trusted
{
///
wint_t fgetwc(FILE* stream);
///
wint_t fputwc(wchar_t c, FILE* stream);
}
///
wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
///
int fputws(in wchar_t* s, FILE* stream);
// No unsafe pointer manipulation.
extern (D) @trusted
{
///
wint_t getwchar() { return fgetwc(stdin); }
///
wint_t putwchar(wchar_t c) { return fputwc(c,stdout); }
///
wint_t getwc(FILE* stream) { return fgetwc(stream); }
///
wint_t putwc(wchar_t c, FILE* stream) { return fputwc(c, stream); }
}
// No unsafe pointer manipulation.
@trusted
{
///
wint_t ungetwc(wint_t c, FILE* stream);
///
version( CRuntime_Microsoft )
{
// MSVC defines this as an inline function.
int fwide(FILE* stream, int mode) { return mode; }
}
else
{
int fwide(FILE* stream, int mode);
}
}
///
double wcstod(in wchar_t* nptr, wchar_t** endptr);
///
float wcstof(in wchar_t* nptr, wchar_t** endptr);
///
real wcstold(in wchar_t* nptr, wchar_t** endptr);
///
c_long wcstol(in wchar_t* nptr, wchar_t** endptr, int base);
///
long wcstoll(in wchar_t* nptr, wchar_t** endptr, int base);
///
c_ulong wcstoul(in wchar_t* nptr, wchar_t** endptr, int base);
///
ulong wcstoull(in wchar_t* nptr, wchar_t** endptr, int base);
///
pure wchar_t* wcscpy(return wchar_t* s1, scope const wchar_t* s2);
///
pure wchar_t* wcsncpy(return wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure wchar_t* wcscat(return wchar_t* s1, scope const wchar_t* s2);
///
pure wchar_t* wcsncat(return wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure int wcscmp(scope const wchar_t* s1, scope const wchar_t* s2);
///
int wcscoll(scope const wchar_t* s1, scope const wchar_t* s2);
///
pure int wcsncmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n);
///
size_t wcsxfrm(scope wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure inout(wchar_t)* wcschr(return inout(wchar_t)* s, wchar_t c);
///
pure size_t wcscspn(scope const wchar_t* s1, scope const wchar_t* s2);
///
pure inout(wchar_t)* wcspbrk(return inout(wchar_t)* s1, scope const wchar_t* s2);
///
pure inout(wchar_t)* wcsrchr(return inout(wchar_t)* s, wchar_t c);
///
pure size_t wcsspn(scope const wchar_t* s1, scope const wchar_t* s2);
///
pure inout(wchar_t)* wcsstr(return inout(wchar_t)* s1, scope const wchar_t* s2);
///
wchar_t* wcstok(return wchar_t* s1, scope const wchar_t* s2, wchar_t** ptr);
///
pure size_t wcslen(scope const wchar_t* s);
///
pure wchar_t* wmemchr(return const wchar_t* s, wchar_t c, size_t n);
///
pure int wmemcmp(scope const wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure wchar_t* wmemcpy(return wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure wchar_t* wmemmove(return wchar_t* s1, scope const wchar_t* s2, size_t n);
///
pure wchar_t* wmemset(return wchar_t* s, wchar_t c, size_t n);
///
size_t wcsftime(wchar_t* s, size_t maxsize, in wchar_t* format, in tm* timeptr);
version( Windows )
{
///
wchar_t* _wasctime(tm*); // non-standard
///
wchar_t* _wctime(time_t*); // non-standard
///
wchar_t* _wstrdate(wchar_t*); // non-standard
///
wchar_t* _wstrtime(wchar_t*); // non-standard
}
// No unsafe pointer manipulation.
@trusted
{
///
wint_t btowc(int c);
///
int wctob(wint_t c);
}
///
int mbsinit(in mbstate_t* ps);
///
size_t mbrlen(in char* s, size_t n, mbstate_t* ps);
///
size_t mbrtowc(wchar_t* pwc, in char* s, size_t n, mbstate_t* ps);
///
size_t wcrtomb(char* s, wchar_t wc, mbstate_t* ps);
///
size_t mbsrtowcs(wchar_t* dst, in char** src, size_t len, mbstate_t* ps);
///
size_t wcsrtombs(char* dst, in wchar_t** src, size_t len, mbstate_t* ps);