| 1 |
/** |
| 2 |
* D header file for C99 <stdio.h> |
| 3 |
* |
| 4 |
* $(C_HEADER_DESCRIPTION pubs.opengroup.org/onlinepubs/009695399/basedefs/_stdio.h.html, _stdio.h) |
| 5 |
* |
| 6 |
* Copyright: Copyright Sean Kelly 2005 - 2009. |
| 7 |
* License: Distributed under the |
| 8 |
* $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0). |
| 9 |
* (See accompanying file LICENSE) |
| 10 |
* Authors: Sean Kelly, |
| 11 |
* Alex Rønne Petersen |
| 12 |
* Source: $(DRUNTIMESRC core/stdc/_stdio.d) |
| 13 |
* Standards: ISO/IEC 9899:1999 (E) |
| 14 |
*/ |
| 15 |
|
| 16 |
module core.stdc.stdio; |
| 17 |
|
| 18 |
version (OSX) |
| 19 |
version = Darwin; |
| 20 |
else version (iOS) |
| 21 |
version = Darwin; |
| 22 |
else version (TVOS) |
| 23 |
version = Darwin; |
| 24 |
else version (WatchOS) |
| 25 |
version = Darwin; |
| 26 |
|
| 27 |
private |
| 28 |
{ |
| 29 |
import core.stdc.config; |
| 30 |
import core.stdc.stdarg; // for va_list |
| 31 |
import core.stdc.stdint : intptr_t; |
| 32 |
|
| 33 |
version (FreeBSD) |
| 34 |
{ |
| 35 |
import core.sys.posix.sys.types; |
| 36 |
} |
| 37 |
else version (OpenBSD) |
| 38 |
{ |
| 39 |
import core.sys.posix.sys.types; |
| 40 |
} |
| 41 |
version (NetBSD) |
| 42 |
{ |
| 43 |
import core.sys.posix.sys.types; |
| 44 |
} |
| 45 |
version (DragonFlyBSD) |
| 46 |
{ |
| 47 |
import core.sys.posix.sys.types; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
extern (C): |
| 52 |
nothrow: |
| 53 |
@nogc: |
| 54 |
|
| 55 |
version (CRuntime_Microsoft) |
| 56 |
{ |
| 57 |
enum |
| 58 |
{ |
| 59 |
/// |
| 60 |
BUFSIZ = 512, |
| 61 |
/// |
| 62 |
EOF = -1, |
| 63 |
/// |
| 64 |
FOPEN_MAX = 20, |
| 65 |
/// |
| 66 |
FILENAME_MAX = 260, |
| 67 |
/// Actually int.max since Visual Studio 2015. |
| 68 |
TMP_MAX = 32767, |
| 69 |
/// |
| 70 |
_SYS_OPEN = 20, // non-standard |
| 71 |
} |
| 72 |
|
| 73 |
/// |
| 74 |
enum int _NFILE = 512; // non-standard |
| 75 |
/// Removed since Visual Studio 2015. |
| 76 |
enum string _P_tmpdir = "\\"; // non-standard |
| 77 |
/// Removed since Visual Studio 2015. |
| 78 |
enum wstring _wP_tmpdir = "\\"; // non-standard |
| 79 |
/// Actually 260 since Visual Studio 2015. |
| 80 |
enum int L_tmpnam = _P_tmpdir.length + 12; |
| 81 |
} |
| 82 |
else version (CRuntime_Glibc) |
| 83 |
{ |
| 84 |
enum |
| 85 |
{ |
| 86 |
/// |
| 87 |
BUFSIZ = 8192, |
| 88 |
/// |
| 89 |
EOF = -1, |
| 90 |
/// |
| 91 |
FOPEN_MAX = 16, |
| 92 |
/// |
| 93 |
FILENAME_MAX = 4095, |
| 94 |
/// |
| 95 |
TMP_MAX = 238328, |
| 96 |
/// |
| 97 |
L_tmpnam = 20 |
| 98 |
} |
| 99 |
} |
| 100 |
else version (CRuntime_Musl) |
| 101 |
{ |
| 102 |
enum |
| 103 |
{ |
| 104 |
/// |
| 105 |
BUFSIZ = 1024, |
| 106 |
/// |
| 107 |
EOF = -1, |
| 108 |
/// |
| 109 |
FOPEN_MAX = 1000, |
| 110 |
/// |
| 111 |
FILENAME_MAX = 4096, |
| 112 |
/// |
| 113 |
TMP_MAX = 10000, |
| 114 |
/// |
| 115 |
L_tmpnam = 20 |
| 116 |
} |
| 117 |
} |
| 118 |
else version (Darwin) |
| 119 |
{ |
| 120 |
enum |
| 121 |
{ |
| 122 |
/// |
| 123 |
BUFSIZ = 1024, |
| 124 |
/// |
| 125 |
EOF = -1, |
| 126 |
/// |
| 127 |
FOPEN_MAX = 20, |
| 128 |
/// |
| 129 |
FILENAME_MAX = 1024, |
| 130 |
/// |
| 131 |
TMP_MAX = 308915776, |
| 132 |
/// |
| 133 |
L_tmpnam = 1024, |
| 134 |
} |
| 135 |
|
| 136 |
private |
| 137 |
{ |
| 138 |
struct __sbuf |
| 139 |
{ |
| 140 |
ubyte* _base; |
| 141 |
int _size; |
| 142 |
} |
| 143 |
|
| 144 |
struct __sFILEX |
| 145 |
{ |
| 146 |
|
| 147 |
} |
| 148 |
} |
| 149 |
} |
| 150 |
else version (FreeBSD) |
| 151 |
{ |
| 152 |
enum |
| 153 |
{ |
| 154 |
/// |
| 155 |
BUFSIZ = 1024, |
| 156 |
/// |
| 157 |
EOF = -1, |
| 158 |
/// |
| 159 |
FOPEN_MAX = 20, |
| 160 |
/// |
| 161 |
FILENAME_MAX = 1024, |
| 162 |
/// |
| 163 |
TMP_MAX = 308915776, |
| 164 |
/// |
| 165 |
L_tmpnam = 1024 |
| 166 |
} |
| 167 |
|
| 168 |
struct __sbuf |
| 169 |
{ |
| 170 |
ubyte *_base; |
| 171 |
int _size; |
| 172 |
} |
| 173 |
} |
| 174 |
else version (NetBSD) |
| 175 |
{ |
| 176 |
enum |
| 177 |
{ |
| 178 |
/// |
| 179 |
BUFSIZ = 1024, |
| 180 |
/// |
| 181 |
EOF = -1, |
| 182 |
/// |
| 183 |
FOPEN_MAX = 20, |
| 184 |
/// |
| 185 |
FILENAME_MAX = 1024, |
| 186 |
/// |
| 187 |
TMP_MAX = 308915776, |
| 188 |
/// |
| 189 |
L_tmpnam = 1024 |
| 190 |
} |
| 191 |
|
| 192 |
struct __sbuf |
| 193 |
{ |
| 194 |
ubyte *_base; |
| 195 |
int _size; |
| 196 |
} |
| 197 |
} |
| 198 |
else version (OpenBSD) |
| 199 |
{ |
| 200 |
enum |
| 201 |
{ |
| 202 |
/// |
| 203 |
BUFSIZ = 1024, |
| 204 |
/// |
| 205 |
EOF = -1, |
| 206 |
/// |
| 207 |
FOPEN_MAX = 20, |
| 208 |
/// |
| 209 |
FILENAME_MAX = 1024, |
| 210 |
/// |
| 211 |
TMP_MAX = 0x7fffffff, |
| 212 |
/// |
| 213 |
L_tmpnam = 1024 |
| 214 |
} |
| 215 |
|
| 216 |
struct __sbuf |
| 217 |
{ |
| 218 |
ubyte *_base; |
| 219 |
int _size; |
| 220 |
} |
| 221 |
} |
| 222 |
else version (DragonFlyBSD) |
| 223 |
{ |
| 224 |
enum |
| 225 |
{ |
| 226 |
BUFSIZ = 1024, |
| 227 |
EOF = -1, |
| 228 |
FOPEN_MAX = 20, |
| 229 |
FILENAME_MAX = 1024, |
| 230 |
TMP_MAX = 308915776, |
| 231 |
L_tmpnam = 1024 |
| 232 |
} |
| 233 |
|
| 234 |
struct __sbuf { // <sys/sbuf.h> |
| 235 |
byte* s_buf; // storage buffer |
| 236 |
int function(void *, const char *, int) sbuf_drain_func; |
| 237 |
void* s_drain_arg; // user-supplied drain argument |
| 238 |
int s_error; // current error code |
| 239 |
ssize_t s_size; // size of storage buffer |
| 240 |
ssize_t s_len; // current length of string |
| 241 |
int s_flags; // flags |
| 242 |
ssize_t s_sect_len; // current length of section |
| 243 |
} |
| 244 |
|
| 245 |
enum { |
| 246 |
SBUF_FIXEDLEN = 0x00000000, // fixed length buffer (default) |
| 247 |
SBUF_AUTOEXTEND = 0x00000001, // automatically extend buffer |
| 248 |
SBUF_USRFLAGMSK = 0x0000ffff, // mask of flags the user may specify |
| 249 |
SBUF_DYNAMIC = 0x00010000, // s_buf must be freed |
| 250 |
SBUF_FINISHED = 0x00020000, // set by sbuf_finish() |
| 251 |
SBUF_DYNSTRUCT = 0x00080000, // sbuf must be freed |
| 252 |
SBUF_INSECTION = 0x00100000, // set by sbuf_start_section() |
| 253 |
} |
| 254 |
} |
| 255 |
else version (Solaris) |
| 256 |
{ |
| 257 |
enum |
| 258 |
{ |
| 259 |
/// |
| 260 |
BUFSIZ = 1024, |
| 261 |
/// |
| 262 |
EOF = -1, |
| 263 |
/// |
| 264 |
FOPEN_MAX = _NFILE, |
| 265 |
/// |
| 266 |
FILENAME_MAX = 1024, |
| 267 |
/// |
| 268 |
TMP_MAX = 17576, |
| 269 |
/// |
| 270 |
L_tmpnam = 25, |
| 271 |
} |
| 272 |
|
| 273 |
version (X86) |
| 274 |
/// |
| 275 |
enum int _NFILE = 60; |
| 276 |
else |
| 277 |
/// |
| 278 |
enum int _NFILE = 20; |
| 279 |
} |
| 280 |
else version (CRuntime_Bionic) |
| 281 |
{ |
| 282 |
enum |
| 283 |
{ |
| 284 |
/// |
| 285 |
BUFSIZ = 1024, |
| 286 |
/// |
| 287 |
EOF = -1, |
| 288 |
/// |
| 289 |
FOPEN_MAX = 20, |
| 290 |
/// |
| 291 |
FILENAME_MAX = 1024, |
| 292 |
/// |
| 293 |
TMP_MAX = 308915776, |
| 294 |
/// |
| 295 |
L_tmpnam = 1024 |
| 296 |
} |
| 297 |
|
| 298 |
struct __sbuf |
| 299 |
{ |
| 300 |
ubyte* _base; |
| 301 |
int _size; |
| 302 |
} |
| 303 |
} |
| 304 |
else version (CRuntime_Newlib) |
| 305 |
{ |
| 306 |
enum |
| 307 |
{ |
| 308 |
/// |
| 309 |
BUFSIZ = 1024, |
| 310 |
/// |
| 311 |
EOF = -1, |
| 312 |
/// |
| 313 |
FOPEN_MAX = 20, |
| 314 |
/// |
| 315 |
FILENAME_MAX = 1024, |
| 316 |
/// |
| 317 |
TMP_MAX = 26, |
| 318 |
/// |
| 319 |
L_tmpnam = 1024 |
| 320 |
} |
| 321 |
|
| 322 |
struct __sbuf |
| 323 |
{ |
| 324 |
ubyte* _base; |
| 325 |
int _size; |
| 326 |
} |
| 327 |
} |
| 328 |
else version (CRuntime_UClibc) |
| 329 |
{ |
| 330 |
enum |
| 331 |
{ |
| 332 |
/// |
| 333 |
BUFSIZ = 4096, |
| 334 |
/// |
| 335 |
EOF = -1, |
| 336 |
/// |
| 337 |
FOPEN_MAX = 16, |
| 338 |
/// |
| 339 |
FILENAME_MAX = 4095, |
| 340 |
/// |
| 341 |
TMP_MAX = 238328, |
| 342 |
/// |
| 343 |
L_tmpnam = 20 |
| 344 |
} |
| 345 |
} |
| 346 |
else version (WASI) |
| 347 |
{ |
| 348 |
enum |
| 349 |
{ |
| 350 |
/// |
| 351 |
BUFSIZ = 1024, |
| 352 |
/// |
| 353 |
EOF = -1, |
| 354 |
/// |
| 355 |
FOPEN_MAX = 1000, |
| 356 |
/// |
| 357 |
FILENAME_MAX = 4096, |
| 358 |
/// |
| 359 |
TMP_MAX = 10000, |
| 360 |
/// |
| 361 |
L_tmpnam = 20 |
| 362 |
} |
| 363 |
} |
| 364 |
else |
| 365 |
{ |
| 366 |
static assert( false, "Unsupported platform" ); |
| 367 |
} |
| 368 |
|
| 369 |
enum |
| 370 |
{ |
| 371 |
/// Offset is relative to the beginning |
| 372 |
SEEK_SET, |
| 373 |
/// Offset is relative to the current position |
| 374 |
SEEK_CUR, |
| 375 |
/// Offset is relative to the end |
| 376 |
SEEK_END |
| 377 |
} |
| 378 |
|
| 379 |
version (CRuntime_Microsoft) |
| 380 |
{ |
| 381 |
/// |
| 382 |
alias long fpos_t; |
| 383 |
|
| 384 |
/// |
| 385 |
struct _iobuf |
| 386 |
{ |
| 387 |
void* undefined; |
| 388 |
} |
| 389 |
|
| 390 |
/// |
| 391 |
alias shared(_iobuf) FILE; |
| 392 |
} |
| 393 |
else version (CRuntime_Glibc) |
| 394 |
{ |
| 395 |
import core.stdc.wchar_ : mbstate_t; |
| 396 |
/// |
| 397 |
struct fpos_t |
| 398 |
{ |
| 399 |
long __pos; // couldn't use off_t because of static if issue |
| 400 |
mbstate_t __state; |
| 401 |
} |
| 402 |
|
| 403 |
/// |
| 404 |
struct _IO_FILE |
| 405 |
{ |
| 406 |
int _flags; |
| 407 |
char* _read_ptr; |
| 408 |
char* _read_end; |
| 409 |
char* _read_base; |
| 410 |
char* _write_base; |
| 411 |
char* _write_ptr; |
| 412 |
char* _write_end; |
| 413 |
char* _buf_base; |
| 414 |
char* _buf_end; |
| 415 |
char* _save_base; |
| 416 |
char* _backup_base; |
| 417 |
char* _save_end; |
| 418 |
void* _markers; |
| 419 |
_IO_FILE* _chain; |
| 420 |
int _fileno; |
| 421 |
int _flags2; |
| 422 |
ptrdiff_t _old_offset; |
| 423 |
ushort _cur_column; |
| 424 |
byte _vtable_offset; |
| 425 |
char[1] _shortbuf = 0; |
| 426 |
void* _lock; |
| 427 |
|
| 428 |
ptrdiff_t _offset; |
| 429 |
|
| 430 |
/*_IO_codecvt*/ void* _codecvt; |
| 431 |
/*_IO_wide_data*/ void* _wide_data; |
| 432 |
_IO_FILE *_freeres_list; |
| 433 |
void *_freeres_buf; |
| 434 |
size_t __pad5; |
| 435 |
int _mode; |
| 436 |
|
| 437 |
char[15 * int.sizeof - 4 * (void*).sizeof - size_t.sizeof] _unused2; |
| 438 |
} |
| 439 |
|
| 440 |
/// |
| 441 |
alias _IO_FILE _iobuf; |
| 442 |
/// |
| 443 |
alias shared(_IO_FILE) FILE; |
| 444 |
} |
| 445 |
else version (WASI) |
| 446 |
{ |
| 447 |
union fpos_t |
| 448 |
{ |
| 449 |
char[16] __opaque = 0; |
| 450 |
double __align; |
| 451 |
} |
| 452 |
struct _IO_FILE; |
| 453 |
|
| 454 |
/// |
| 455 |
alias _IO_FILE _iobuf; // needed for phobos |
| 456 |
/// |
| 457 |
alias shared(_IO_FILE) FILE; |
| 458 |
} |
| 459 |
else version (CRuntime_Musl) |
| 460 |
{ |
| 461 |
union fpos_t |
| 462 |
{ |
| 463 |
char[16] __opaque = 0; |
| 464 |
double __align; |
| 465 |
} |
| 466 |
struct _IO_FILE; |
| 467 |
|
| 468 |
/// |
| 469 |
alias _IO_FILE _iobuf; // needed for phobos |
| 470 |
/// |
| 471 |
alias shared(_IO_FILE) FILE; |
| 472 |
} |
| 473 |
else version (Darwin) |
| 474 |
{ |
| 475 |
/// |
| 476 |
alias long fpos_t; |
| 477 |
|
| 478 |
/// |
| 479 |
struct __sFILE |
| 480 |
{ |
| 481 |
ubyte* _p; |
| 482 |
int _r; |
| 483 |
int _w; |
| 484 |
short _flags; |
| 485 |
short _file; |
| 486 |
__sbuf _bf; |
| 487 |
int _lbfsize; |
| 488 |
|
| 489 |
void* _cookie; |
| 490 |
int function(void*) _close; |
| 491 |
int function(void*, char*, int) _read; |
| 492 |
fpos_t function(void*, fpos_t, int) _seek; |
| 493 |
int function(void*, char *, int) _write; |
| 494 |
|
| 495 |
__sbuf _ub; |
| 496 |
__sFILEX* _extra; |
| 497 |
int _ur; |
| 498 |
|
| 499 |
ubyte[3] _ubuf; |
| 500 |
ubyte[1] _nbuf; |
| 501 |
|
| 502 |
__sbuf _lb; |
| 503 |
|
| 504 |
int _blksize; |
| 505 |
fpos_t _offset; |
| 506 |
} |
| 507 |
|
| 508 |
/// |
| 509 |
alias __sFILE _iobuf; |
| 510 |
/// |
| 511 |
alias shared(__sFILE) FILE; |
| 512 |
} |
| 513 |
else version (FreeBSD) |
| 514 |
{ |
| 515 |
// Need to import wchar_ now since __mbstate_t now resides there |
| 516 |
import core.stdc.wchar_ : mbstate_t; |
| 517 |
|
| 518 |
/// |
| 519 |
alias off_t fpos_t; |
| 520 |
|
| 521 |
/// |
| 522 |
struct __sFILE |
| 523 |
{ |
| 524 |
ubyte* _p; |
| 525 |
int _r; |
| 526 |
int _w; |
| 527 |
short _flags; |
| 528 |
short _file; |
| 529 |
__sbuf _bf; |
| 530 |
int _lbfsize; |
| 531 |
|
| 532 |
void* _cookie; |
| 533 |
int function(void*) _close; |
| 534 |
int function(void*, char*, int) _read; |
| 535 |
fpos_t function(void*, fpos_t, int) _seek; |
| 536 |
int function(void*, const scope char*, int) _write; |
| 537 |
|
| 538 |
__sbuf _ub; |
| 539 |
ubyte* _up; |
| 540 |
int _ur; |
| 541 |
|
| 542 |
ubyte[3] _ubuf; |
| 543 |
ubyte[1] _nbuf; |
| 544 |
|
| 545 |
__sbuf _lb; |
| 546 |
|
| 547 |
int _blksize; |
| 548 |
fpos_t _offset; |
| 549 |
|
| 550 |
pthread_mutex_t _fl_mutex; |
| 551 |
pthread_t _fl_owner; |
| 552 |
int _fl_count; |
| 553 |
int _orientation; |
| 554 |
mbstate_t _mbstate; |
| 555 |
} |
| 556 |
|
| 557 |
/// |
| 558 |
alias __sFILE _iobuf; |
| 559 |
/// |
| 560 |
alias shared(__sFILE) FILE; |
| 561 |
} |
| 562 |
else version (NetBSD) |
| 563 |
{ |
| 564 |
/// |
| 565 |
alias off_t fpos_t; |
| 566 |
|
| 567 |
/// |
| 568 |
struct __sFILE |
| 569 |
{ |
| 570 |
ubyte* _p; |
| 571 |
int _r; |
| 572 |
int _w; |
| 573 |
ushort _flags; |
| 574 |
short _file; |
| 575 |
__sbuf _bf; |
| 576 |
int _lbfsize; |
| 577 |
|
| 578 |
void* _cookie; |
| 579 |
int function(void*) _close; |
| 580 |
ssize_t function(void*, char*, size_t) _read; |
| 581 |
fpos_t function(void*, fpos_t, int) _seek; |
| 582 |
ssize_t function(void*, const scope char*, size_t) _write; |
| 583 |
|
| 584 |
__sbuf _ub; |
| 585 |
ubyte* _up; |
| 586 |
int _ur; |
| 587 |
|
| 588 |
ubyte[3] _ubuf; |
| 589 |
ubyte[1] _nbuf; |
| 590 |
|
| 591 |
int function(void *) _flush; |
| 592 |
/* Formerly used by fgetln/fgetwln; kept for binary compatibility */ |
| 593 |
char[__sbuf.sizeof - _flush.sizeof] _lb_unused = void; |
| 594 |
|
| 595 |
|
| 596 |
int _blksize; |
| 597 |
off_t _offset; |
| 598 |
static assert(off_t.sizeof==8); |
| 599 |
} |
| 600 |
|
| 601 |
/// |
| 602 |
alias __sFILE _iobuf; |
| 603 |
/// |
| 604 |
alias shared(__sFILE) FILE; |
| 605 |
} |
| 606 |
else version (OpenBSD) |
| 607 |
{ |
| 608 |
/// |
| 609 |
alias fpos_t = off_t; |
| 610 |
|
| 611 |
/// |
| 612 |
struct __sFILE |
| 613 |
{ |
| 614 |
ubyte* _p; |
| 615 |
int _r; |
| 616 |
int _w; |
| 617 |
short _flags; |
| 618 |
short _file; |
| 619 |
__sbuf _bf; |
| 620 |
int _lbfsize; |
| 621 |
|
| 622 |
void* _cookie; |
| 623 |
int function(void*) _close; |
| 624 |
int function(void*, scope char*, int) _read; |
| 625 |
fpos_t function(void*, fpos_t, int) _seek; |
| 626 |
int function(void*, scope const char*, int) _write; |
| 627 |
|
| 628 |
__sbuf _ext; |
| 629 |
ubyte* _up; |
| 630 |
int _ur; |
| 631 |
|
| 632 |
ubyte[3] _ubuf; |
| 633 |
ubyte[1] _nbuf; |
| 634 |
|
| 635 |
__sbuf _lb; |
| 636 |
|
| 637 |
int _blksize; |
| 638 |
fpos_t _offset; |
| 639 |
} |
| 640 |
|
| 641 |
/// |
| 642 |
alias __sFILE _iobuf; |
| 643 |
/// |
| 644 |
alias shared(__sFILE) FILE; |
| 645 |
} |
| 646 |
else version (DragonFlyBSD) |
| 647 |
{ |
| 648 |
alias off_t fpos_t; |
| 649 |
|
| 650 |
/// See /usr/include/stdio.h |
| 651 |
struct __FILE_public |
| 652 |
{ |
| 653 |
ubyte* *_p; /* current position in (some) buffer */ |
| 654 |
int _flags; /* flags, below; this FILE is free if 0 */ |
| 655 |
int _fileno; /* fileno, if Unix descriptor, else -1 */ |
| 656 |
ssize_t _r; /* read space left for getc() */ |
| 657 |
ssize_t _w; /* write space left for putc() */ |
| 658 |
ssize_t _lbfsize; /* 0 or -_bf._size, for inline putc */ |
| 659 |
} |
| 660 |
|
| 661 |
alias __FILE_public _iobuf; |
| 662 |
alias shared(__FILE_public) FILE; |
| 663 |
} |
| 664 |
else version (Solaris) |
| 665 |
{ |
| 666 |
import core.stdc.wchar_ : mbstate_t; |
| 667 |
|
| 668 |
/// |
| 669 |
alias c_long fpos_t; |
| 670 |
|
| 671 |
version (D_LP64) |
| 672 |
{ |
| 673 |
/// |
| 674 |
struct _iobuf |
| 675 |
{ |
| 676 |
char* _ptr; /* next character from/to here in buffer */ |
| 677 |
char* _base; /* the buffer */ |
| 678 |
char* _end; /* the end of the buffer */ |
| 679 |
size_t _cnt; /* number of available characters in buffer */ |
| 680 |
int _file; /* UNIX System file descriptor */ |
| 681 |
int _flag; /* the state of the stream */ |
| 682 |
ubyte[24] _lock; //rmutex_t _lock; /* lock for this structure */ |
| 683 |
mbstate_t _state; /* mbstate_t */ |
| 684 |
ubyte[32] __fill; /* filler to bring size to 128 bytes */ |
| 685 |
} |
| 686 |
} |
| 687 |
else |
| 688 |
{ |
| 689 |
/// |
| 690 |
struct _iobuf |
| 691 |
{ |
| 692 |
char* _ptr; |
| 693 |
int _cnt; |
| 694 |
char* _base; |
| 695 |
char _flag = 0; |
| 696 |
char _magic = 0; |
| 697 |
ushort __flags; // __orientation:2 |
| 698 |
// __ionolock:1 |
| 699 |
// __seekable:1 |
| 700 |
// __extendedfd:1 |
| 701 |
// __xf_nocheck:1 |
| 702 |
// __filler:10 |
| 703 |
} |
| 704 |
} |
| 705 |
/// |
| 706 |
alias shared(_iobuf) FILE; |
| 707 |
} |
| 708 |
else version (CRuntime_Bionic) |
| 709 |
{ |
| 710 |
/// |
| 711 |
alias c_long fpos_t; // couldn't use off_t because of static if issue |
| 712 |
|
| 713 |
/// |
| 714 |
struct __sFILE |
| 715 |
{ |
| 716 |
ubyte* _p; |
| 717 |
int _r; |
| 718 |
int _w; |
| 719 |
short _flags; |
| 720 |
short _file; |
| 721 |
__sbuf _bf; |
| 722 |
int _lbfsize; |
| 723 |
|
| 724 |
void* _cookie; |
| 725 |
int function(void*) _close; |
| 726 |
int function(void*, scope char*, int) _read; |
| 727 |
fpos_t function(void*, fpos_t, int) _seek; |
| 728 |
int function(void*, scope const char*, int) _write; |
| 729 |
|
| 730 |
__sbuf _ext; |
| 731 |
ubyte* _up; |
| 732 |
int _ur; |
| 733 |
|
| 734 |
ubyte[3] _ubuf; |
| 735 |
ubyte[1] _nbuf; |
| 736 |
|
| 737 |
__sbuf _lb; |
| 738 |
|
| 739 |
int _blksize; |
| 740 |
fpos_t _offset; |
| 741 |
} |
| 742 |
|
| 743 |
/// |
| 744 |
alias __sFILE _iobuf; |
| 745 |
/// |
| 746 |
alias shared(__sFILE) FILE; |
| 747 |
} |
| 748 |
else version (CRuntime_Newlib) |
| 749 |
{ |
| 750 |
import core.sys.posix.sys.types : ssize_t; |
| 751 |
import core.stdc.wchar_ : mbstate_t; |
| 752 |
|
| 753 |
/// |
| 754 |
alias fpos_t = c_long; |
| 755 |
|
| 756 |
/// |
| 757 |
struct __sFILE |
| 758 |
{ |
| 759 |
ubyte* _p; |
| 760 |
int _r; |
| 761 |
int _w; |
| 762 |
short _flags; |
| 763 |
short _file; |
| 764 |
__sbuf _bf; |
| 765 |
int _lbfsize; |
| 766 |
|
| 767 |
void* _data; |
| 768 |
void* _cookie; |
| 769 |
|
| 770 |
ssize_t function(void*, void*, scope char*, size_t) _read; |
| 771 |
ssize_t function(void*, void*, scope const char*, size_t) _write; |
| 772 |
fpos_t function(void*, void*, fpos_t, int) _seek; |
| 773 |
int function(void*, void*) _close; |
| 774 |
|
| 775 |
__sbuf _ub; |
| 776 |
ubyte* _up; |
| 777 |
int _ur; |
| 778 |
|
| 779 |
ubyte[3] _ubuf; |
| 780 |
ubyte[1] _nbuf; |
| 781 |
|
| 782 |
__sbuf _lb; |
| 783 |
|
| 784 |
int _blksize; |
| 785 |
int _flags2; |
| 786 |
|
| 787 |
long _offset; |
| 788 |
void* _unused; |
| 789 |
|
| 790 |
void* _lock; |
| 791 |
mbstate_t _mbstate; |
| 792 |
} |
| 793 |
|
| 794 |
/// |
| 795 |
alias __sFILE _iobuf; // needed for phobos |
| 796 |
/// |
| 797 |
alias shared(__sFILE) FILE; |
| 798 |
} |
| 799 |
else version (CRuntime_UClibc) |
| 800 |
{ |
| 801 |
import core.stdc.wchar_ : mbstate_t; |
| 802 |
import core.stdc.stddef : wchar_t; |
| 803 |
import core.sys.posix.sys.types : ssize_t, pthread_mutex_t; |
| 804 |
|
| 805 |
/// |
| 806 |
struct fpos_t |
| 807 |
{ |
| 808 |
long __pos; // couldn't use off_t because of static if issue |
| 809 |
mbstate_t __state; |
| 810 |
int __mblen_pending; |
| 811 |
} |
| 812 |
|
| 813 |
struct _IO_cookie_io_functions_t |
| 814 |
{ |
| 815 |
ssize_t function(void* __cookie, char* __buf, size_t __bufsize) read; |
| 816 |
ssize_t function(void* __cookie, const char* __buf, size_t __bufsize) write; |
| 817 |
int function(void* __cookie, long* __pos, int __whence) seek; |
| 818 |
int function(void* __cookie) close; |
| 819 |
} |
| 820 |
|
| 821 |
alias _IO_cookie_io_functions_t cookie_io_functions_t; |
| 822 |
|
| 823 |
/// |
| 824 |
struct __STDIO_FILE_STRUCT |
| 825 |
{ |
| 826 |
ushort __modeflags; |
| 827 |
char[2] __ungot_width = 0; |
| 828 |
int __filedes; |
| 829 |
char* __bufstart; |
| 830 |
char* __bufend; |
| 831 |
char* __bufpos; |
| 832 |
char* __bufread; |
| 833 |
char* __bufgetc_u; |
| 834 |
char*__bufputc_u; |
| 835 |
__STDIO_FILE_STRUCT* __nextopen; |
| 836 |
void *__cookie; |
| 837 |
_IO_cookie_io_functions_t __gcs; |
| 838 |
wchar_t[2] __ungot = 0; |
| 839 |
mbstate_t __state; |
| 840 |
void *__unused; |
| 841 |
int __user_locking; |
| 842 |
pthread_mutex_t __lock; |
| 843 |
} |
| 844 |
|
| 845 |
/// |
| 846 |
alias __STDIO_FILE_STRUCT _iobuf; |
| 847 |
/// |
| 848 |
alias shared(__STDIO_FILE_STRUCT) FILE; |
| 849 |
} |
| 850 |
else |
| 851 |
{ |
| 852 |
static assert( false, "Unsupported platform" ); |
| 853 |
} |
| 854 |
|
| 855 |
enum |
| 856 |
{ |
| 857 |
/// |
| 858 |
_F_RDWR = 0x0003, // non-standard |
| 859 |
/// |
| 860 |
_F_READ = 0x0001, // non-standard |
| 861 |
/// |
| 862 |
_F_WRIT = 0x0002, // non-standard |
| 863 |
/// |
| 864 |
_F_BUF = 0x0004, // non-standard |
| 865 |
/// |
| 866 |
_F_LBUF = 0x0008, // non-standard |
| 867 |
/// |
| 868 |
_F_ERR = 0x0010, // non-standard |
| 869 |
/// |
| 870 |
_F_EOF = 0x0020, // non-standard |
| 871 |
/// |
| 872 |
_F_BIN = 0x0040, // non-standard |
| 873 |
/// |
| 874 |
_F_IN = 0x0080, // non-standard |
| 875 |
/// |
| 876 |
_F_OUT = 0x0100, // non-standard |
| 877 |
/// |
| 878 |
_F_TERM = 0x0200, // non-standard |
| 879 |
} |
| 880 |
|
| 881 |
version (CRuntime_Microsoft) |
| 882 |
{ |
| 883 |
enum |
| 884 |
{ |
| 885 |
/// |
| 886 |
_IOFBF = 0, |
| 887 |
/// |
| 888 |
_IOLBF = 0x40, |
| 889 |
/// |
| 890 |
_IONBF = 4, |
| 891 |
/// Removed since Visual Studio 2015. |
| 892 |
_IOREAD = 1, // non-standard |
| 893 |
/// Removed since Visual Studio 2015. |
| 894 |
_IOWRT = 2, // non-standard |
| 895 |
/// Removed since Visual Studio 2015. |
| 896 |
_IOMYBUF = 8, // non-standard |
| 897 |
/// Removed since Visual Studio 2015. |
| 898 |
_IOEOF = 0x10, // non-standard |
| 899 |
/// Removed since Visual Studio 2015. |
| 900 |
_IOERR = 0x20, // non-standard |
| 901 |
/// Removed since Visual Studio 2015. |
| 902 |
_IOSTRG = 0x40, // non-standard |
| 903 |
/// Removed since Visual Studio 2015. |
| 904 |
_IORW = 0x80, // non-standard |
| 905 |
/// Removed since Visual Studio 2015. |
| 906 |
_IOAPP = 0x200, // non-standard |
| 907 |
/// Removed since Visual Studio 2015. |
| 908 |
_IOAPPEND = 0x200, // non-standard |
| 909 |
} |
| 910 |
|
| 911 |
extern shared void function() _fcloseallp; |
| 912 |
|
| 913 |
FILE* __acrt_iob_func(int hnd); // VS2015+, reimplemented in msvc.d for VS2013- |
| 914 |
|
| 915 |
/// |
| 916 |
FILE* stdin()() { return __acrt_iob_func(0); } |
| 917 |
/// |
| 918 |
FILE* stdout()() { return __acrt_iob_func(1); } |
| 919 |
/// |
| 920 |
FILE* stderr()() { return __acrt_iob_func(2); } |
| 921 |
} |
| 922 |
else version (CRuntime_Glibc) |
| 923 |
{ |
| 924 |
enum |
| 925 |
{ |
| 926 |
/// |
| 927 |
_IOFBF = 0, |
| 928 |
/// |
| 929 |
_IOLBF = 1, |
| 930 |
/// |
| 931 |
_IONBF = 2, |
| 932 |
} |
| 933 |
|
| 934 |
/// |
| 935 |
extern shared FILE* stdin; |
| 936 |
/// |
| 937 |
extern shared FILE* stdout; |
| 938 |
/// |
| 939 |
extern shared FILE* stderr; |
| 940 |
} |
| 941 |
else version (Darwin) |
| 942 |
{ |
| 943 |
enum |
| 944 |
{ |
| 945 |
/// |
| 946 |
_IOFBF = 0, |
| 947 |
/// |
| 948 |
_IOLBF = 1, |
| 949 |
/// |
| 950 |
_IONBF = 2, |
| 951 |
} |
| 952 |
|
| 953 |
private extern shared FILE* __stdinp; |
| 954 |
private extern shared FILE* __stdoutp; |
| 955 |
private extern shared FILE* __stderrp; |
| 956 |
|
| 957 |
/// |
| 958 |
alias __stdinp stdin; |
| 959 |
/// |
| 960 |
alias __stdoutp stdout; |
| 961 |
/// |
| 962 |
alias __stderrp stderr; |
| 963 |
} |
| 964 |
else version (FreeBSD) |
| 965 |
{ |
| 966 |
enum |
| 967 |
{ |
| 968 |
/// |
| 969 |
_IOFBF = 0, |
| 970 |
/// |
| 971 |
_IOLBF = 1, |
| 972 |
/// |
| 973 |
_IONBF = 2, |
| 974 |
} |
| 975 |
|
| 976 |
private extern shared FILE* __stdinp; |
| 977 |
private extern shared FILE* __stdoutp; |
| 978 |
private extern shared FILE* __stderrp; |
| 979 |
|
| 980 |
/// |
| 981 |
alias __stdinp stdin; |
| 982 |
/// |
| 983 |
alias __stdoutp stdout; |
| 984 |
/// |
| 985 |
alias __stderrp stderr; |
| 986 |
} |
| 987 |
else version (NetBSD) |
| 988 |
{ |
| 989 |
enum |
| 990 |
{ |
| 991 |
/// |
| 992 |
_IOFBF = 0, |
| 993 |
/// |
| 994 |
_IOLBF = 1, |
| 995 |
/// |
| 996 |
_IONBF = 2, |
| 997 |
} |
| 998 |
|
| 999 |
private extern shared FILE[3] __sF; |
| 1000 |
@property auto __stdin()() { return &__sF[0]; } |
| 1001 |
@property auto __stdout()() { return &__sF[1]; } |
| 1002 |
@property auto __stderr()() { return &__sF[2]; } |
| 1003 |
/// |
| 1004 |
alias __stdin stdin; |
| 1005 |
/// |
| 1006 |
alias __stdout stdout; |
| 1007 |
/// |
| 1008 |
alias __stderr stderr; |
| 1009 |
} |
| 1010 |
else version (OpenBSD) |
| 1011 |
{ |
| 1012 |
enum |
| 1013 |
{ |
| 1014 |
/// |
| 1015 |
_IOFBF = 0, |
| 1016 |
/// |
| 1017 |
_IOLBF = 1, |
| 1018 |
/// |
| 1019 |
_IONBF = 2, |
| 1020 |
} |
| 1021 |
|
| 1022 |
private extern shared FILE[3] __sF; |
| 1023 |
@property auto __stdin()() { return &__sF[0]; } |
| 1024 |
@property auto __stdout()() { return &__sF[1]; } |
| 1025 |
@property auto __stderr()() { return &__sF[2]; } |
| 1026 |
/// |
| 1027 |
alias __stdin stdin; |
| 1028 |
/// |
| 1029 |
alias __stdout stdout; |
| 1030 |
/// |
| 1031 |
alias __stderr stderr; |
| 1032 |
} |
| 1033 |
else version (DragonFlyBSD) |
| 1034 |
{ |
| 1035 |
enum |
| 1036 |
{ |
| 1037 |
_IOFBF = 0, |
| 1038 |
_IOLBF = 1, |
| 1039 |
_IONBF = 2, |
| 1040 |
} |
| 1041 |
|
| 1042 |
private extern shared FILE* __stdinp; |
| 1043 |
private extern shared FILE* __stdoutp; |
| 1044 |
private extern shared FILE* __stderrp; |
| 1045 |
|
| 1046 |
alias __stdinp stdin; |
| 1047 |
alias __stdoutp stdout; |
| 1048 |
alias __stderrp stderr; |
| 1049 |
} |
| 1050 |
else version (Solaris) |
| 1051 |
{ |
| 1052 |
enum |
| 1053 |
{ |
| 1054 |
/// |
| 1055 |
_IOFBF = 0x00, |
| 1056 |
/// |
| 1057 |
_IOLBF = 0x40, |
| 1058 |
/// |
| 1059 |
_IONBF = 0x04, |
| 1060 |
/// |
| 1061 |
_IOEOF = 0x20, |
| 1062 |
/// |
| 1063 |
_IOERR = 0x40, |
| 1064 |
/// |
| 1065 |
_IOREAD = 0x01, |
| 1066 |
/// |
| 1067 |
_IOWRT = 0x02, |
| 1068 |
/// |
| 1069 |
_IORW = 0x80, |
| 1070 |
/// |
| 1071 |
_IOMYBUF = 0x08, |
| 1072 |
} |
| 1073 |
|
| 1074 |
private extern shared FILE[_NFILE] __iob; |
| 1075 |
|
| 1076 |
/// |
| 1077 |
@property auto stdin()() { return &__iob[0]; } |
| 1078 |
/// |
| 1079 |
@property auto stdout()() { return &__iob[1]; } |
| 1080 |
/// |
| 1081 |
@property auto stderr()() { return &__iob[2]; } |
| 1082 |
} |
| 1083 |
else version (CRuntime_Bionic) |
| 1084 |
{ |
| 1085 |
enum |
| 1086 |
{ |
| 1087 |
/// |
| 1088 |
_IOFBF = 0, |
| 1089 |
/// |
| 1090 |
_IOLBF = 1, |
| 1091 |
/// |
| 1092 |
_IONBF = 2, |
| 1093 |
} |
| 1094 |
|
| 1095 |
private extern shared FILE[3] __sF; |
| 1096 |
|
| 1097 |
/// |
| 1098 |
@property auto stdin()() { return &__sF[0]; } |
| 1099 |
/// |
| 1100 |
@property auto stdout()() { return &__sF[1]; } |
| 1101 |
/// |
| 1102 |
@property auto stderr()() { return &__sF[2]; } |
| 1103 |
} |
| 1104 |
else version (CRuntime_Musl) |
| 1105 |
{ |
| 1106 |
// needs tail const |
| 1107 |
extern shared FILE* stdin; |
| 1108 |
/// |
| 1109 |
extern shared FILE* stdout; |
| 1110 |
/// |
| 1111 |
extern shared FILE* stderr; |
| 1112 |
enum |
| 1113 |
{ |
| 1114 |
/// |
| 1115 |
_IOFBF = 0, |
| 1116 |
/// |
| 1117 |
_IOLBF = 1, |
| 1118 |
/// |
| 1119 |
_IONBF = 2, |
| 1120 |
} |
| 1121 |
} |
| 1122 |
else version (CRuntime_Newlib) |
| 1123 |
{ |
| 1124 |
enum |
| 1125 |
{ |
| 1126 |
/// |
| 1127 |
_IOFBF = 0, |
| 1128 |
/// |
| 1129 |
_IOLBF = 1, |
| 1130 |
/// |
| 1131 |
_IONBF = 2, |
| 1132 |
} |
| 1133 |
|
| 1134 |
private |
| 1135 |
{ |
| 1136 |
shared struct _reent |
| 1137 |
{ |
| 1138 |
int _errno; |
| 1139 |
__sFILE* _stdin; |
| 1140 |
__sFILE* _stdout; |
| 1141 |
__sFILE* _stderr; |
| 1142 |
} |
| 1143 |
_reent* __getreent(); |
| 1144 |
} |
| 1145 |
|
| 1146 |
pragma(inline, true) |
| 1147 |
{ |
| 1148 |
/// |
| 1149 |
@property auto stdin()() { return __getreent()._stdin; } |
| 1150 |
/// |
| 1151 |
@property auto stdout()() { return __getreent()._stdout; } |
| 1152 |
/// |
| 1153 |
@property auto stderr()() { return __getreent()._stderr; } |
| 1154 |
} |
| 1155 |
} |
| 1156 |
else version (CRuntime_UClibc) |
| 1157 |
{ |
| 1158 |
enum |
| 1159 |
{ |
| 1160 |
/// |
| 1161 |
_IOFBF = 0, |
| 1162 |
/// |
| 1163 |
_IOLBF = 1, |
| 1164 |
/// |
| 1165 |
_IONBF = 2, |
| 1166 |
} |
| 1167 |
|
| 1168 |
/// |
| 1169 |
extern shared FILE* stdin; |
| 1170 |
/// |
| 1171 |
extern shared FILE* stdout; |
| 1172 |
/// |
| 1173 |
extern shared FILE* stderr; |
| 1174 |
} |
| 1175 |
else version (WASI) |
| 1176 |
{ |
| 1177 |
// needs tail const |
| 1178 |
extern shared FILE* stdin; |
| 1179 |
/// |
| 1180 |
extern shared FILE* stdout; |
| 1181 |
/// |
| 1182 |
extern shared FILE* stderr; |
| 1183 |
enum |
| 1184 |
{ |
| 1185 |
/// |
| 1186 |
_IOFBF = 0, |
| 1187 |
/// |
| 1188 |
_IOLBF = 1, |
| 1189 |
/// |
| 1190 |
_IONBF = 2, |
| 1191 |
} |
| 1192 |
} |
| 1193 |
else |
| 1194 |
{ |
| 1195 |
static assert( false, "Unsupported platform" ); |
| 1196 |
} |
| 1197 |
|
| 1198 |
/// |
| 1199 |
int remove(scope const char* filename); |
| 1200 |
/// |
| 1201 |
int rename(scope const char* from, scope const char* to); |
| 1202 |
|
| 1203 |
/// |
| 1204 |
@trusted FILE* tmpfile(); // No unsafe pointer manipulation. |
| 1205 |
/// |
| 1206 |
char* tmpnam(char* s); |
| 1207 |
|
| 1208 |
/// |
| 1209 |
int fclose(FILE* stream); |
| 1210 |
|
| 1211 |
// No unsafe pointer manipulation. |
| 1212 |
@trusted |
| 1213 |
{ |
| 1214 |
/// |
| 1215 |
int fflush(FILE* stream); |
| 1216 |
} |
| 1217 |
|
| 1218 |
/// |
| 1219 |
FILE* fopen(scope const char* filename, scope const char* mode); |
| 1220 |
/// |
| 1221 |
FILE* freopen(scope const char* filename, scope const char* mode, FILE* stream); |
| 1222 |
|
| 1223 |
/// |
| 1224 |
void setbuf(FILE* stream, char* buf); |
| 1225 |
/// |
| 1226 |
int setvbuf(FILE* stream, char* buf, int mode, size_t size); |
| 1227 |
|
| 1228 |
version (MinGW) |
| 1229 |
{ |
| 1230 |
// Prefer the MinGW versions over the MSVC ones, as the latter don't handle |
| 1231 |
// reals at all. |
| 1232 |
/// |
| 1233 |
pragma(printf) |
| 1234 |
int __mingw_fprintf(FILE* stream, scope const char* format, scope const ...); |
| 1235 |
/// |
| 1236 |
alias __mingw_fprintf fprintf; |
| 1237 |
|
| 1238 |
/// |
| 1239 |
pragma(scanf) |
| 1240 |
int __mingw_fscanf(FILE* stream, scope const char* format, scope ...); |
| 1241 |
/// |
| 1242 |
alias __mingw_fscanf fscanf; |
| 1243 |
|
| 1244 |
/// |
| 1245 |
pragma(printf) |
| 1246 |
int __mingw_sprintf(scope char* s, scope const char* format, scope const ...); |
| 1247 |
/// |
| 1248 |
alias __mingw_sprintf sprintf; |
| 1249 |
|
| 1250 |
/// |
| 1251 |
pragma(scanf) |
| 1252 |
int __mingw_sscanf(scope const char* s, scope const char* format, scope ...); |
| 1253 |
/// |
| 1254 |
alias __mingw_sscanf sscanf; |
| 1255 |
|
| 1256 |
/// |
| 1257 |
pragma(printf) |
| 1258 |
int __mingw_vfprintf(FILE* stream, scope const char* format, va_list arg); |
| 1259 |
/// |
| 1260 |
alias __mingw_vfprintf vfprintf; |
| 1261 |
|
| 1262 |
/// |
| 1263 |
pragma(scanf) |
| 1264 |
int __mingw_vfscanf(FILE* stream, scope const char* format, va_list arg); |
| 1265 |
/// |
| 1266 |
alias __mingw_vfscanf vfscanf; |
| 1267 |
|
| 1268 |
/// |
| 1269 |
pragma(printf) |
| 1270 |
int __mingw_vsprintf(scope char* s, scope const char* format, va_list arg); |
| 1271 |
/// |
| 1272 |
alias __mingw_vsprintf vsprintf; |
| 1273 |
|
| 1274 |
/// |
| 1275 |
pragma(scanf) |
| 1276 |
int __mingw_vsscanf(scope const char* s, scope const char* format, va_list arg); |
| 1277 |
/// |
| 1278 |
alias __mingw_vsscanf vsscanf; |
| 1279 |
|
| 1280 |
/// |
| 1281 |
pragma(printf) |
| 1282 |
int __mingw_vprintf(scope const char* format, va_list arg); |
| 1283 |
/// |
| 1284 |
alias __mingw_vprintf vprintf; |
| 1285 |
|
| 1286 |
/// |
| 1287 |
pragma(scanf) |
| 1288 |
int __mingw_vscanf(scope const char* format, va_list arg); |
| 1289 |
/// |
| 1290 |
alias __mingw_vscanf vscanf; |
| 1291 |
|
| 1292 |
/// |
| 1293 |
pragma(printf) |
| 1294 |
int __mingw_printf(scope const char* format, scope const ...); |
| 1295 |
/// |
| 1296 |
alias __mingw_printf printf; |
| 1297 |
|
| 1298 |
/// |
| 1299 |
pragma(scanf) |
| 1300 |
int __mingw_scanf(scope const char* format, scope ...); |
| 1301 |
/// |
| 1302 |
alias __mingw_scanf scanf; |
| 1303 |
} |
| 1304 |
else version (CRuntime_Glibc) |
| 1305 |
{ |
| 1306 |
static if (PPCUseIEEE128) |
| 1307 |
{ |
| 1308 |
/// |
| 1309 |
pragma(printf) |
| 1310 |
int __fprintfieee128(FILE* stream, scope const char* format, scope const ...); |
| 1311 |
/// |
| 1312 |
alias fprintf = __fprintfieee128; |
| 1313 |
/// |
| 1314 |
pragma(scanf) |
| 1315 |
int __isoc99_fscanfieee128(FILE* stream, scope const char* format, scope ...); |
| 1316 |
/// |
| 1317 |
alias fscanf = __isoc99_fscanfieee128; |
| 1318 |
/// |
| 1319 |
pragma(printf) |
| 1320 |
int __sprintfieee128(scope char* s, scope const char* format, scope const ...); |
| 1321 |
/// |
| 1322 |
alias sprintf = __sprintfieee128; |
| 1323 |
/// |
| 1324 |
pragma(scanf) |
| 1325 |
int __isoc99_sscanfieee128(scope const char* s, scope const char* format, scope ...); |
| 1326 |
/// |
| 1327 |
alias sscanf = __isoc99_sscanfieee128; |
| 1328 |
/// |
| 1329 |
pragma(printf) |
| 1330 |
int vfprintf(FILE* stream, scope const char* format, va_list arg); |
| 1331 |
/// |
| 1332 |
pragma(scanf) |
| 1333 |
int __isoc99_vfscanfieee128(FILE* stream, scope const char* format, va_list arg); |
| 1334 |
/// |
| 1335 |
alias vfscanf = __isoc99_vfscanfieee128; |
| 1336 |
/// |
| 1337 |
pragma(printf) |
| 1338 |
int __vsprintfieee128(scope char* s, scope const char* format, va_list arg); |
| 1339 |
/// |
| 1340 |
alias vsprintf = __vsprintfieee128; |
| 1341 |
/// |
| 1342 |
pragma(scanf) |
| 1343 |
int __isoc99_vsscanfieee128(scope const char* s, scope const char* format, va_list arg); |
| 1344 |
/// |
| 1345 |
alias vsscanf = __isoc99_vsscanfieee128; |
| 1346 |
/// |
| 1347 |
pragma(printf) |
| 1348 |
int __vprintfieee128(scope const char* format, va_list arg); |
| 1349 |
/// |
| 1350 |
alias vprintf = __vprintfieee128; |
| 1351 |
/// |
| 1352 |
pragma(scanf) |
| 1353 |
int __isoc99_vfscanfieee128(scope const char* format, va_list arg); |
| 1354 |
/// |
| 1355 |
alias vscanf = __isoc99_vfscanfieee128; |
| 1356 |
/// |
| 1357 |
pragma(printf) |
| 1358 |
int __printfieee128(scope const char* format, scope const ...); |
| 1359 |
/// |
| 1360 |
alias printf = __printfieee128; |
| 1361 |
/// |
| 1362 |
pragma(scanf) |
| 1363 |
int __isoc99_scanfieee128(scope const char* format, scope ...); |
| 1364 |
/// |
| 1365 |
alias scanf = __isoc99_scanfieee128; |
| 1366 |
} |
| 1367 |
else |
| 1368 |
{ |
| 1369 |
/// |
| 1370 |
pragma(printf) |
| 1371 |
int fprintf(FILE* stream, scope const char* format, scope const ...); |
| 1372 |
/// |
| 1373 |
pragma(scanf) |
| 1374 |
int __isoc99_fscanf(FILE* stream, scope const char* format, scope ...); |
| 1375 |
/// |
| 1376 |
alias fscanf = __isoc99_fscanf; |
| 1377 |
/// |
| 1378 |
pragma(printf) |
| 1379 |
int sprintf(scope char* s, scope const char* format, scope const ...); |
| 1380 |
/// |
| 1381 |
pragma(scanf) |
| 1382 |
int __isoc99_sscanf(scope const char* s, scope const char* format, scope ...); |
| 1383 |
/// |
| 1384 |
alias sscanf = __isoc99_sscanf; |
| 1385 |
/// |
| 1386 |
pragma(printf) |
| 1387 |
int vfprintf(FILE* stream, scope const char* format, va_list arg); |
| 1388 |
/// |
| 1389 |
pragma(scanf) |
| 1390 |
int __isoc99_vfscanf(FILE* stream, scope const char* format, va_list arg); |
| 1391 |
/// |
| 1392 |
alias vfscanf = __isoc99_vfscanf; |
| 1393 |
/// |
| 1394 |
pragma(printf) |
| 1395 |
int vsprintf(scope char* s, scope const char* format, va_list arg); |
| 1396 |
/// |
| 1397 |
pragma(scanf) |
| 1398 |
int __isoc99_vsscanf(scope const char* s, scope const char* format, va_list arg); |
| 1399 |
/// |
| 1400 |
alias vsscanf = __isoc99_vsscanf; |
| 1401 |
/// |
| 1402 |
pragma(printf) |
| 1403 |
int vprintf(scope const char* format, va_list arg); |
| 1404 |
/// |
| 1405 |
pragma(scanf) |
| 1406 |
int __isoc99_vscanf(scope const char* format, va_list arg); |
| 1407 |
/// |
| 1408 |
alias vscanf = __isoc99_vscanf; |
| 1409 |
/// |
| 1410 |
pragma(printf) |
| 1411 |
int printf(scope const char* format, scope const ...); |
| 1412 |
/// |
| 1413 |
pragma(scanf) |
| 1414 |
int __isoc99_scanf(scope const char* format, scope ...); |
| 1415 |
/// |
| 1416 |
alias scanf = __isoc99_scanf; |
| 1417 |
} |
| 1418 |
} |
| 1419 |
else |
| 1420 |
{ |
| 1421 |
/// |
| 1422 |
pragma(printf) |
| 1423 |
int fprintf(FILE* stream, scope const char* format, scope const ...); |
| 1424 |
/// |
| 1425 |
pragma(scanf) |
| 1426 |
int fscanf(FILE* stream, scope const char* format, scope ...); |
| 1427 |
/// |
| 1428 |
pragma(printf) |
| 1429 |
int sprintf(scope char* s, scope const char* format, scope const ...); |
| 1430 |
/// |
| 1431 |
pragma(scanf) |
| 1432 |
int sscanf(scope const char* s, scope const char* format, scope ...); |
| 1433 |
/// |
| 1434 |
pragma(printf) |
| 1435 |
int vfprintf(FILE* stream, scope const char* format, va_list arg); |
| 1436 |
/// |
| 1437 |
pragma(scanf) |
| 1438 |
int vfscanf(FILE* stream, scope const char* format, va_list arg); |
| 1439 |
/// |
| 1440 |
pragma(printf) |
| 1441 |
int vsprintf(scope char* s, scope const char* format, va_list arg); |
| 1442 |
/// |
| 1443 |
pragma(scanf) |
| 1444 |
int vsscanf(scope const char* s, scope const char* format, va_list arg); |
| 1445 |
/// |
| 1446 |
pragma(printf) |
| 1447 |
int vprintf(scope const char* format, va_list arg); |
| 1448 |
/// |
| 1449 |
pragma(scanf) |
| 1450 |
int vscanf(scope const char* format, va_list arg); |
| 1451 |
/// |
| 1452 |
pragma(printf) |
| 1453 |
int printf(scope const char* format, scope const ...); |
| 1454 |
/// |
| 1455 |
pragma(scanf) |
| 1456 |
int scanf(scope const char* format, scope ...); |
| 1457 |
} |
| 1458 |
|
| 1459 |
// No unsafe pointer manipulation. |
| 1460 |
@trusted |
| 1461 |
{ |
| 1462 |
/// |
| 1463 |
int fgetc(FILE* stream); |
| 1464 |
/// |
| 1465 |
int fputc(int c, FILE* stream); |
| 1466 |
} |
| 1467 |
|
| 1468 |
/// |
| 1469 |
char* fgets(char* s, int n, FILE* stream); |
| 1470 |
/// |
| 1471 |
int fputs(scope const char* s, FILE* stream); |
| 1472 |
/// |
| 1473 |
char* gets(char* s); |
| 1474 |
/// |
| 1475 |
int puts(scope const char* s); |
| 1476 |
|
| 1477 |
// No unsafe pointer manipulation. |
| 1478 |
extern (D) @trusted |
| 1479 |
{ |
| 1480 |
/// |
| 1481 |
int getchar()() { return getc(stdin); } |
| 1482 |
/// |
| 1483 |
int putchar()(int c) { return putc(c,stdout); } |
| 1484 |
} |
| 1485 |
|
| 1486 |
/// |
| 1487 |
alias getc = fgetc; |
| 1488 |
/// |
| 1489 |
alias putc = fputc; |
| 1490 |
|
| 1491 |
/// |
| 1492 |
@trusted int ungetc(int c, FILE* stream); // No unsafe pointer manipulation. |
| 1493 |
|
| 1494 |
/// |
| 1495 |
size_t fread(scope void* ptr, size_t size, size_t nmemb, FILE* stream); |
| 1496 |
/// |
| 1497 |
size_t fwrite(scope const void* ptr, size_t size, size_t nmemb, FILE* stream); |
| 1498 |
|
| 1499 |
// No unsafe pointer manipulation. |
| 1500 |
@trusted |
| 1501 |
{ |
| 1502 |
/// |
| 1503 |
int fgetpos(FILE* stream, scope fpos_t * pos); |
| 1504 |
/// |
| 1505 |
int fsetpos(FILE* stream, scope const fpos_t* pos); |
| 1506 |
|
| 1507 |
/// |
| 1508 |
int fseek(FILE* stream, c_long offset, int whence); |
| 1509 |
/// |
| 1510 |
c_long ftell(FILE* stream); |
| 1511 |
} |
| 1512 |
|
| 1513 |
version (CRuntime_Microsoft) |
| 1514 |
{ |
| 1515 |
// No unsafe pointer manipulation. |
| 1516 |
@trusted |
| 1517 |
{ |
| 1518 |
/// |
| 1519 |
void rewind(FILE* stream); |
| 1520 |
/// |
| 1521 |
pure void clearerr(FILE* stream); |
| 1522 |
/// |
| 1523 |
pure int feof(FILE* stream); |
| 1524 |
/// |
| 1525 |
pure int ferror(FILE* stream); |
| 1526 |
/// |
| 1527 |
pure int fileno(FILE* stream); |
| 1528 |
} |
| 1529 |
|
| 1530 |
version (MinGW) |
| 1531 |
{ |
| 1532 |
pragma(printf) |
| 1533 |
int __mingw_snprintf(scope char* s, size_t n, scope const char* fmt, scope const ...); |
| 1534 |
/// |
| 1535 |
alias __mingw_snprintf _snprintf; |
| 1536 |
/// |
| 1537 |
alias __mingw_snprintf snprintf; |
| 1538 |
|
| 1539 |
/// |
| 1540 |
pragma(printf) |
| 1541 |
int __mingw_vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1542 |
/// |
| 1543 |
alias __mingw_vsnprintf _vsnprintf; |
| 1544 |
/// |
| 1545 |
alias __mingw_vsnprintf vsnprintf; |
| 1546 |
} |
| 1547 |
else |
| 1548 |
{ |
| 1549 |
/// |
| 1550 |
pragma(printf) |
| 1551 |
int _snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1552 |
/// |
| 1553 |
pragma(printf) |
| 1554 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1555 |
|
| 1556 |
/// |
| 1557 |
pragma(printf) |
| 1558 |
int _vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1559 |
/// |
| 1560 |
pragma(printf) |
| 1561 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1562 |
} |
| 1563 |
|
| 1564 |
// |
| 1565 |
// Microsoft under-the-hood C I/O functions. Uses _iobuf* for the unshared |
| 1566 |
// version of FILE*, usable when the FILE is locked. |
| 1567 |
// |
| 1568 |
import core.stdc.stddef : wchar_t; |
| 1569 |
import core.stdc.wchar_ : wint_t; |
| 1570 |
|
| 1571 |
/// |
| 1572 |
int _fputc_nolock(int c, _iobuf* fp); |
| 1573 |
/// |
| 1574 |
int _fgetc_nolock(_iobuf* fp); |
| 1575 |
/// |
| 1576 |
wint_t _fputwc_nolock(wchar_t c, _iobuf* fp); |
| 1577 |
/// |
| 1578 |
wint_t _fgetwc_nolock(_iobuf* fp); |
| 1579 |
/// |
| 1580 |
void _lock_file(FILE* fp); |
| 1581 |
/// |
| 1582 |
void _unlock_file(FILE* fp); |
| 1583 |
/// |
| 1584 |
int _setmode(int fd, int mode); |
| 1585 |
/// |
| 1586 |
int _fseeki64(FILE* stream, long offset, int origin); |
| 1587 |
/// |
| 1588 |
long _ftelli64(FILE* stream); |
| 1589 |
/// |
| 1590 |
intptr_t _get_osfhandle(int fd); |
| 1591 |
/// |
| 1592 |
int _open_osfhandle(intptr_t osfhandle, int flags); |
| 1593 |
} |
| 1594 |
else version (CRuntime_Glibc) |
| 1595 |
{ |
| 1596 |
// No unsafe pointer manipulation. |
| 1597 |
@trusted |
| 1598 |
{ |
| 1599 |
/// |
| 1600 |
void rewind(FILE* stream); |
| 1601 |
/// |
| 1602 |
pure void clearerr(FILE* stream); |
| 1603 |
/// |
| 1604 |
pure int feof(FILE* stream); |
| 1605 |
/// |
| 1606 |
pure int ferror(FILE* stream); |
| 1607 |
/// |
| 1608 |
int fileno(FILE *); |
| 1609 |
} |
| 1610 |
|
| 1611 |
static if (PPCUseIEEE128) |
| 1612 |
{ |
| 1613 |
/// |
| 1614 |
pragma(printf) |
| 1615 |
int __snprintfieee128(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1616 |
/// |
| 1617 |
alias snprintf = __snprintfieee128; |
| 1618 |
/// |
| 1619 |
pragma(printf) |
| 1620 |
int __vsnprintfieee128(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1621 |
/// |
| 1622 |
alias vsnprintf = __vsnprintfieee128; |
| 1623 |
} |
| 1624 |
else |
| 1625 |
{ |
| 1626 |
/// |
| 1627 |
pragma(printf) |
| 1628 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1629 |
/// |
| 1630 |
pragma(printf) |
| 1631 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1632 |
} |
| 1633 |
|
| 1634 |
// |
| 1635 |
// Gnu under-the-hood C I/O functions. Uses _iobuf* for the unshared |
| 1636 |
// version of FILE*, usable when the FILE is locked. |
| 1637 |
// See http://gnu.org/software/libc/manual/html_node/I_002fO-on-Streams.html |
| 1638 |
// |
| 1639 |
import core.stdc.wchar_ : wint_t; |
| 1640 |
import core.stdc.stddef : wchar_t; |
| 1641 |
|
| 1642 |
/// |
| 1643 |
int fputc_unlocked(int c, _iobuf* stream); |
| 1644 |
/// |
| 1645 |
int fgetc_unlocked(_iobuf* stream); |
| 1646 |
/// |
| 1647 |
wint_t fputwc_unlocked(wchar_t wc, _iobuf* stream); |
| 1648 |
/// |
| 1649 |
wint_t fgetwc_unlocked(_iobuf* stream); |
| 1650 |
} |
| 1651 |
else version (Darwin) |
| 1652 |
{ |
| 1653 |
// No unsafe pointer manipulation. |
| 1654 |
@trusted |
| 1655 |
{ |
| 1656 |
/// |
| 1657 |
void rewind(FILE*); |
| 1658 |
/// |
| 1659 |
pure void clearerr(FILE*); |
| 1660 |
/// |
| 1661 |
pure int feof(FILE*); |
| 1662 |
/// |
| 1663 |
pure int ferror(FILE*); |
| 1664 |
/// |
| 1665 |
int fileno(FILE*); |
| 1666 |
} |
| 1667 |
|
| 1668 |
/// |
| 1669 |
pragma(printf) |
| 1670 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1671 |
/// |
| 1672 |
pragma(printf) |
| 1673 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1674 |
} |
| 1675 |
else version (FreeBSD) |
| 1676 |
{ |
| 1677 |
// No unsafe pointer manipulation. |
| 1678 |
@trusted |
| 1679 |
{ |
| 1680 |
/// |
| 1681 |
void rewind(FILE*); |
| 1682 |
/// |
| 1683 |
pure void clearerr(FILE*); |
| 1684 |
/// |
| 1685 |
pure int feof(FILE*); |
| 1686 |
/// |
| 1687 |
pure int ferror(FILE*); |
| 1688 |
/// |
| 1689 |
int fileno(FILE*); |
| 1690 |
} |
| 1691 |
|
| 1692 |
/// |
| 1693 |
pragma(printf) |
| 1694 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1695 |
/// |
| 1696 |
pragma(printf) |
| 1697 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1698 |
} |
| 1699 |
else version (NetBSD) |
| 1700 |
{ |
| 1701 |
// No unsafe pointer manipulation. |
| 1702 |
@trusted |
| 1703 |
{ |
| 1704 |
/// |
| 1705 |
void rewind(FILE*); |
| 1706 |
/// |
| 1707 |
pure void clearerr(FILE*); |
| 1708 |
/// |
| 1709 |
pure int feof(FILE*); |
| 1710 |
/// |
| 1711 |
pure int ferror(FILE*); |
| 1712 |
/// |
| 1713 |
int fileno(FILE*); |
| 1714 |
} |
| 1715 |
|
| 1716 |
/// |
| 1717 |
pragma(printf) |
| 1718 |
int snprintf(char* s, size_t n, const scope char* format, scope const ...); |
| 1719 |
/// |
| 1720 |
pragma(printf) |
| 1721 |
int vsnprintf(char* s, size_t n, const scope char* format, va_list arg); |
| 1722 |
} |
| 1723 |
else version (OpenBSD) |
| 1724 |
{ |
| 1725 |
// No unsafe pointer manipulation. |
| 1726 |
@trusted |
| 1727 |
{ |
| 1728 |
/// |
| 1729 |
void rewind(FILE*); |
| 1730 |
} |
| 1731 |
@trusted private |
| 1732 |
{ |
| 1733 |
/// |
| 1734 |
pragma(mangle, "clearerr") |
| 1735 |
pure void __clearerr(FILE*); |
| 1736 |
/// |
| 1737 |
pragma(mangle, "feof") |
| 1738 |
pure int __feof(FILE*); |
| 1739 |
/// |
| 1740 |
pragma(mangle, "ferror") |
| 1741 |
pure int __ferror(FILE*); |
| 1742 |
/// |
| 1743 |
pragma(mangle, "fileno") |
| 1744 |
int __fileno(FILE*); |
| 1745 |
} |
| 1746 |
|
| 1747 |
enum __SLBF = 0x0001; |
| 1748 |
enum __SNBF = 0x0002; |
| 1749 |
enum __SRD = 0x0004; |
| 1750 |
enum __SWR = 0x0008; |
| 1751 |
enum __SRW = 0x0010; |
| 1752 |
enum __SEOF = 0x0020; |
| 1753 |
enum __SERR = 0x0040; |
| 1754 |
enum __SMBF = 0x0080; |
| 1755 |
enum __SAPP = 0x0100; |
| 1756 |
enum __SSTR = 0x0200; |
| 1757 |
enum __SOPT = 0x0400; |
| 1758 |
enum __SNPT = 0x0800; |
| 1759 |
enum __SOFF = 0x1000; |
| 1760 |
enum __SMOD = 0x2000; |
| 1761 |
enum __SALC = 0x4000; |
| 1762 |
enum __SIGN = 0x8000; |
| 1763 |
|
| 1764 |
extern immutable __gshared int __isthreaded; |
| 1765 |
|
| 1766 |
extern (D) @trusted |
| 1767 |
{ |
| 1768 |
void __sclearerr()(FILE* p) |
| 1769 |
{ |
| 1770 |
p._flags = p._flags & ~(__SERR|__SEOF); |
| 1771 |
} |
| 1772 |
|
| 1773 |
int __sfeof()(FILE* p) |
| 1774 |
{ |
| 1775 |
return (p._flags & __SEOF) != 0; |
| 1776 |
} |
| 1777 |
|
| 1778 |
int __sferror()(FILE* p) |
| 1779 |
{ |
| 1780 |
return (p._flags & __SERR) != 0; |
| 1781 |
} |
| 1782 |
|
| 1783 |
int __sfileno()(FILE* p) |
| 1784 |
{ |
| 1785 |
return p._file; |
| 1786 |
} |
| 1787 |
|
| 1788 |
pure void clearerr()(FILE* file) |
| 1789 |
{ |
| 1790 |
!__isthreaded ? __sclearerr(file) : __clearerr(file); |
| 1791 |
} |
| 1792 |
|
| 1793 |
pure int feof()(FILE* file) |
| 1794 |
{ |
| 1795 |
return !__isthreaded ? __sfeof(file) : __feof(file); |
| 1796 |
} |
| 1797 |
|
| 1798 |
pure int ferror()(FILE* file) |
| 1799 |
{ |
| 1800 |
return !__isthreaded ? __sferror(file) : __ferror(file); |
| 1801 |
} |
| 1802 |
|
| 1803 |
int fileno()(FILE* file) |
| 1804 |
{ |
| 1805 |
return !__isthreaded ? __sfileno(file) : __fileno(file); |
| 1806 |
} |
| 1807 |
} |
| 1808 |
|
| 1809 |
/// |
| 1810 |
pragma(printf) |
| 1811 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1812 |
/// |
| 1813 |
pragma(printf) |
| 1814 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1815 |
} |
| 1816 |
else version (DragonFlyBSD) |
| 1817 |
{ |
| 1818 |
// No unsafe pointer manipulation. |
| 1819 |
@trusted |
| 1820 |
{ |
| 1821 |
void rewind(FILE*); |
| 1822 |
pure void clearerr(FILE*); |
| 1823 |
pure int feof(FILE*); |
| 1824 |
pure int ferror(FILE*); |
| 1825 |
int fileno(FILE*); |
| 1826 |
} |
| 1827 |
enum __SLBF = 0x0001; |
| 1828 |
enum __SNBF = 0x0002; |
| 1829 |
enum __SRD = 0x0004; |
| 1830 |
enum __SWR = 0x0008; |
| 1831 |
enum __SRW = 0x0010; |
| 1832 |
enum __SEOF = 0x0020; |
| 1833 |
enum __SERR = 0x0040; |
| 1834 |
enum __SMBF = 0x0080; |
| 1835 |
enum __SAPP = 0x0100; |
| 1836 |
enum __SSTR = 0x0200; |
| 1837 |
enum __SOPT = 0x0400; |
| 1838 |
enum __SNPT = 0x0800; |
| 1839 |
enum __SOFF = 0x1000; |
| 1840 |
enum __SMOD = 0x2000; |
| 1841 |
enum __SALC = 0x4000; |
| 1842 |
enum __SIGN = 0x8000; |
| 1843 |
|
| 1844 |
pragma(printf) |
| 1845 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1846 |
pragma(printf) |
| 1847 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1848 |
} |
| 1849 |
else version (Solaris) |
| 1850 |
{ |
| 1851 |
// No unsafe pointer manipulation. |
| 1852 |
@trusted |
| 1853 |
{ |
| 1854 |
/// |
| 1855 |
void rewind(FILE*); |
| 1856 |
/// |
| 1857 |
pure void clearerr(FILE*); |
| 1858 |
/// |
| 1859 |
pure int feof(FILE*); |
| 1860 |
/// |
| 1861 |
pure int ferror(FILE*); |
| 1862 |
/// |
| 1863 |
int fileno(FILE*); |
| 1864 |
} |
| 1865 |
|
| 1866 |
/// |
| 1867 |
pragma(printf) |
| 1868 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1869 |
/// |
| 1870 |
pragma(printf) |
| 1871 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1872 |
} |
| 1873 |
else version (CRuntime_Bionic) |
| 1874 |
{ |
| 1875 |
// No unsafe pointer manipulation. |
| 1876 |
@trusted |
| 1877 |
{ |
| 1878 |
/// |
| 1879 |
void rewind(FILE*); |
| 1880 |
/// |
| 1881 |
pure void clearerr(FILE*); |
| 1882 |
/// |
| 1883 |
pure int feof(FILE*); |
| 1884 |
/// |
| 1885 |
pure int ferror(FILE*); |
| 1886 |
/// |
| 1887 |
int fileno(FILE*); |
| 1888 |
} |
| 1889 |
|
| 1890 |
/// |
| 1891 |
pragma(printf) |
| 1892 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1893 |
/// |
| 1894 |
pragma(printf) |
| 1895 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1896 |
} |
| 1897 |
else version (CRuntime_Musl) |
| 1898 |
{ |
| 1899 |
@trusted |
| 1900 |
{ |
| 1901 |
/// |
| 1902 |
void rewind(FILE* stream); |
| 1903 |
/// |
| 1904 |
pure void clearerr(FILE* stream); |
| 1905 |
/// |
| 1906 |
pure int feof(FILE* stream); |
| 1907 |
/// |
| 1908 |
pure int ferror(FILE* stream); |
| 1909 |
/// |
| 1910 |
int fileno(FILE *); |
| 1911 |
} |
| 1912 |
|
| 1913 |
/// |
| 1914 |
pragma(printf) |
| 1915 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1916 |
/// |
| 1917 |
pragma(printf) |
| 1918 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1919 |
} |
| 1920 |
else version (CRuntime_Newlib) |
| 1921 |
{ |
| 1922 |
// No unsafe pointer manipulation. |
| 1923 |
@trusted |
| 1924 |
{ |
| 1925 |
/// |
| 1926 |
void rewind(FILE* stream); |
| 1927 |
/// |
| 1928 |
pure void clearerr(FILE* stream); |
| 1929 |
/// |
| 1930 |
pure int feof(FILE* stream); |
| 1931 |
/// |
| 1932 |
pure int ferror(FILE* stream); |
| 1933 |
/// |
| 1934 |
int fileno(FILE *); |
| 1935 |
} |
| 1936 |
|
| 1937 |
/// |
| 1938 |
pragma(printf) |
| 1939 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1940 |
/// |
| 1941 |
pragma(printf) |
| 1942 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1943 |
|
| 1944 |
// |
| 1945 |
// Gnu under-the-hood C I/O functions. Uses _iobuf* for the unshared |
| 1946 |
// version of FILE*, usable when the FILE is locked. |
| 1947 |
// See http://gnu.org/software/libc/manual/html_node/I_002fO-on-Streams.html |
| 1948 |
// |
| 1949 |
import core.stdc.wchar_ : wint_t; |
| 1950 |
import core.stdc.stddef : wchar_t; |
| 1951 |
|
| 1952 |
/// |
| 1953 |
int fputc_unlocked(int c, _iobuf* stream); |
| 1954 |
/// |
| 1955 |
int fgetc_unlocked(_iobuf* stream); |
| 1956 |
/// |
| 1957 |
wint_t fputwc_unlocked(wchar_t wc, _iobuf* stream); |
| 1958 |
/// |
| 1959 |
wint_t fgetwc_unlocked(_iobuf* stream); |
| 1960 |
} |
| 1961 |
else version (CRuntime_UClibc) |
| 1962 |
{ |
| 1963 |
// No unsafe pointer manipulation. |
| 1964 |
@trusted |
| 1965 |
{ |
| 1966 |
/// |
| 1967 |
void rewind(FILE* stream); |
| 1968 |
/// |
| 1969 |
pure void clearerr(FILE* stream); |
| 1970 |
/// |
| 1971 |
pure int feof(FILE* stream); |
| 1972 |
/// |
| 1973 |
pure int ferror(FILE* stream); |
| 1974 |
/// |
| 1975 |
int fileno(FILE *); |
| 1976 |
} |
| 1977 |
|
| 1978 |
/// |
| 1979 |
pragma(printf) |
| 1980 |
int snprintf(scope char* s, size_t n, scope const char* format, scope const ...); |
| 1981 |
/// |
| 1982 |
pragma(printf) |
| 1983 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 1984 |
} |
| 1985 |
else version (WASI) |
| 1986 |
{ |
| 1987 |
// No unsafe pointer manipulation. |
| 1988 |
@trusted |
| 1989 |
{ |
| 1990 |
/// |
| 1991 |
void rewind(FILE* stream); |
| 1992 |
/// |
| 1993 |
pure void clearerr(FILE* stream); |
| 1994 |
/// |
| 1995 |
pure int feof(FILE* stream); |
| 1996 |
/// |
| 1997 |
pure int ferror(FILE* stream); |
| 1998 |
/// |
| 1999 |
int fileno(FILE *); |
| 2000 |
} |
| 2001 |
|
| 2002 |
/// |
| 2003 |
int snprintf(scope char* s, size_t n, scope const char* format, ...); |
| 2004 |
/// |
| 2005 |
int vsnprintf(scope char* s, size_t n, scope const char* format, va_list arg); |
| 2006 |
} |
| 2007 |
else |
| 2008 |
{ |
| 2009 |
static assert( false, "Unsupported platform" ); |
| 2010 |
} |
| 2011 |
|
| 2012 |
/// |
| 2013 |
void perror(scope const char* s); |
| 2014 |
|
| 2015 |
version (CRuntime_Microsoft) |
| 2016 |
{ |
| 2017 |
int _open(scope const char* filename, int oflag, ...); /// |
| 2018 |
int _wopen(scope const wchar* filename, int oflag, ...); /// |
| 2019 |
int _sopen(scope const char* filename, int oflag, int shflag, ...); /// |
| 2020 |
int _wsopen(scope const wchar* filename, int oflag, int shflag, ...); /// |
| 2021 |
int _close(int fd); /// |
| 2022 |
FILE *_fdopen(int fd, scope const(char)* flags); /// |
| 2023 |
FILE *_wfdopen(int fd, scope const(wchar)* flags); /// |
| 2024 |
} |
| 2025 |
|
| 2026 |
version (Windows) |
| 2027 |
{ |
| 2028 |
// file open flags |
| 2029 |
enum |
| 2030 |
{ |
| 2031 |
_O_RDONLY = 0x0000, /// |
| 2032 |
O_RDONLY = _O_RDONLY, /// |
| 2033 |
_O_WRONLY = 0x0001, /// |
| 2034 |
O_WRONLY = _O_WRONLY, /// |
| 2035 |
_O_RDWR = 0x0002, /// |
| 2036 |
O_RDWR = _O_RDWR, /// |
| 2037 |
_O_APPEND = 0x0008, /// |
| 2038 |
O_APPEND = _O_APPEND, /// |
| 2039 |
_O_CREAT = 0x0100, /// |
| 2040 |
O_CREAT = _O_CREAT, /// |
| 2041 |
_O_TRUNC = 0x0200, /// |
| 2042 |
O_TRUNC = _O_TRUNC, /// |
| 2043 |
_O_EXCL = 0x0400, /// |
| 2044 |
O_EXCL = _O_EXCL, /// |
| 2045 |
_O_TEXT = 0x4000, /// |
| 2046 |
O_TEXT = _O_TEXT, /// |
| 2047 |
_O_BINARY = 0x8000, /// |
| 2048 |
O_BINARY = _O_BINARY, /// |
| 2049 |
_O_WTEXT = 0x10000, /// |
| 2050 |
_O_U16TEXT = 0x20000, /// |
| 2051 |
_O_U8TEXT = 0x40000, /// |
| 2052 |
_O_ACCMODE = (_O_RDONLY|_O_WRONLY|_O_RDWR), /// |
| 2053 |
O_ACCMODE = _O_ACCMODE, /// |
| 2054 |
_O_RAW = _O_BINARY, /// |
| 2055 |
O_RAW = _O_BINARY, /// |
| 2056 |
_O_NOINHERIT = 0x0080, /// |
| 2057 |
O_NOINHERIT = _O_NOINHERIT, /// |
| 2058 |
_O_TEMPORARY = 0x0040, /// |
| 2059 |
O_TEMPORARY = _O_TEMPORARY, /// |
| 2060 |
_O_SHORT_LIVED = 0x1000, /// |
| 2061 |
_O_SEQUENTIAL = 0x0020, /// |
| 2062 |
O_SEQUENTIAL = _O_SEQUENTIAL, /// |
| 2063 |
_O_RANDOM = 0x0010, /// |
| 2064 |
O_RANDOM = _O_RANDOM, /// |
| 2065 |
} |
| 2066 |
|
| 2067 |
enum |
| 2068 |
{ |
| 2069 |
_S_IREAD = 0x0100, /// read permission, owner |
| 2070 |
S_IREAD = _S_IREAD, /// read permission, owner |
| 2071 |
_S_IWRITE = 0x0080, /// write permission, owner |
| 2072 |
S_IWRITE = _S_IWRITE, /// write permission, owner |
| 2073 |
} |
| 2074 |
|
| 2075 |
enum |
| 2076 |
{ |
| 2077 |
_SH_DENYRW = 0x10, /// deny read/write mode |
| 2078 |
SH_DENYRW = _SH_DENYRW, /// deny read/write mode |
| 2079 |
_SH_DENYWR = 0x20, /// deny write mode |
| 2080 |
SH_DENYWR = _SH_DENYWR, /// deny write mode |
| 2081 |
_SH_DENYRD = 0x30, /// deny read mode |
| 2082 |
SH_DENYRD = _SH_DENYRD, /// deny read mode |
| 2083 |
_SH_DENYNO = 0x40, /// deny none mode |
| 2084 |
SH_DENYNO = _SH_DENYNO, /// deny none mode |
| 2085 |
} |
| 2086 |
} |