2 * D header file for C99.
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly, Walter Bright
7 * Standards: ISO/IEC 9899:1999 (E)
9 module core.stdc.stdio;
13 import core.stdc.stdarg;
14 import core.stdc.stddef;
15 import core.stdc.config;
22 const int BUFSIZ = 0x4000;
24 const int FOPEN_MAX = 20;
25 const int FILENAME_MAX = 256; // 255 plus NULL
26 const int TMP_MAX = 32767;
27 const int _SYS_OPEN = 20;
28 const int SYS_OPEN = _SYS_OPEN;
30 const int _NFILE = 60;
31 const char[] _P_tmpdir = "\\";
32 const wchar[] _wP_tmpdir = "\\";
33 const int L_tmpnam = _P_tmpdir.length + 12;
37 //const int BUFSIZ = 0x4000;
39 const int FOPEN_MAX = 16;
40 const int FILENAME_MAX = 4095;
41 const int TMP_MAX = 238328;
42 const int L_tmpnam = 20;
44 else version( darwin )
47 const int FOPEN_MAX = 20;
48 const int FILENAME_MAX = 1024;
49 const int TMP_MAX = 308915776;
50 const int L_tmpnam = 1024;
66 else version ( freebsd )
69 const int FOPEN_MAX = 20;
70 const int FILENAME_MAX = 1024;
71 const int TMP_MAX = 308915776;
72 const int L_tmpnam = 1024;
88 static assert( false );
112 else version( linux )
135 else version( darwin )
145 int* function(void*) _close;
146 int* function(void*, char*, int) _read;
147 fpos_t* function(void*, fpos_t, int) _seek;
148 int* function(void*, char *, int) _write;
162 else version( freebsd )
172 void* function() _cookie;
173 int* function(void*) _close;
174 int* function(void*, char*, int) _read;
175 fpos_t* function(void*, fpos_t, int) _seek;
176 int* function(void*, char *, int) _write;
192 static assert( false );
231 extern void function() _fcloseallp;
235 extern FILE[_NFILE]* _imp___iob;
245 stdin = &(*_imp___iob)[0];
246 stdout = &(*_imp___iob)[1];
247 stderr = &(*_imp___iob)[2];
248 stdaux = &(*_imp___iob)[3];
249 stdprn = &(*_imp___iob)[4];
254 extern FILE[_NFILE] _iob;
256 auto FILE* stdin = &_iob[0];
257 auto FILE* stdout = &_iob[1];
258 auto FILE* stderr = &_iob[2];
259 auto FILE* stdaux = &_iob[3];
260 auto FILE* stdprn = &_iob[4];
263 else version( linux )
276 else version( darwin )
278 extern FILE* __stdinp;
279 extern FILE* __stdoutp;
280 extern FILE* __stderrp;
293 else version( freebsd )
297 auto FILE* stdin = &__sF[0];
298 auto FILE* stdout = &__sF[1];
299 auto FILE* stderr = &__sF[2];
303 static assert( false );
308 int remove(in char* filename);
309 int rename(in char* from, in char* to);
312 char* tmpnam(char* s);
314 int fclose(FILE* stream);
315 int fflush(FILE* stream);
316 FILE* fopen(in char* filename, in char* mode);
317 FILE* freopen(in char* filename, in char* mode, FILE* stream);
319 void setbuf(FILE* stream, char* buf);
320 int setvbuf(FILE* stream, char* buf, int mode, size_t size);
322 int fprintf(FILE* stream, in char* format, ...);
323 int fscanf(FILE* stream, in char* format, ...);
324 int sprintf(char* s, in char* format, ...);
325 int sscanf(in char* s, in char* format, ...);
326 int vfprintf(FILE* stream, in char* format, va_list arg);
327 int vfscanf(FILE* stream, in char* format, va_list arg);
328 int vsprintf(char* s, in char* format, va_list arg);
329 int vsscanf(in char* s, in char* format, va_list arg);
330 int vprintf(in char* format, va_list arg);
331 int vscanf(in char* format, va_list arg);
332 int printf(in char* format, ...);
333 int scanf(in char* format, ...);
335 int fgetc(FILE* stream);
336 int fputc(int c, FILE* stream);
338 char* fgets(char* s, int n, FILE* stream);
339 int fputs(in char* s, FILE* stream);
341 int puts(in char* s);
345 int getchar() { return getc(stdin); }
346 int putchar(int c) { return putc(c,stdout); }
347 int getc(FILE* stream) { return fgetc(stream); }
348 int putc(int c, FILE* stream) { return fputc(c,stream); }
351 int ungetc(int c, FILE* stream);
353 size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream);
354 size_t fwrite(in void* ptr, size_t size, size_t nmemb, FILE* stream);
356 int fgetpos(FILE* stream, fpos_t * pos);
357 int fsetpos(FILE* stream, in fpos_t* pos);
359 int fseek(FILE* stream, c_long offset, int whence);
360 c_long ftell(FILE* stream);
366 void rewind(FILE* stream) { fseek(stream,0L,SEEK_SET); stream._flag&=~_IOERR; }
367 void clearerr(FILE* stream) { stream._flag &= ~(_IOERR|_IOEOF); }
368 int feof(FILE* stream) { return stream._flag&_IOEOF; }
369 int ferror(FILE* stream) { return stream._flag&_IOERR; }
371 int _snprintf(char* s, size_t n, in char* fmt, ...);
372 alias _snprintf snprintf;
374 int _vsnprintf(char* s, size_t n, in char* format, va_list arg);
375 alias _vsnprintf vsnprintf;
377 else version( linux )
379 void rewind(FILE* stream);
380 void clearerr(FILE* stream);
381 int feof(FILE* stream);
382 int ferror(FILE* stream);
385 int snprintf(char* s, size_t n, in char* format, ...);
386 int vsnprintf(char* s, size_t n, in char* format, va_list arg);
388 else version( darwin )
391 void clearerr(FILE*);
396 int snprintf(char* s, size_t n, in char* format, ...);
397 int vsnprintf(char* s, size_t n, in char* format, va_list arg);
399 else version( freebsd )
402 void clearerr(FILE*);
407 int snprintf(char* s, size_t n, in char* format, ...);
408 int vsnprintf(char* s, size_t n, in char* format, va_list arg);
412 static assert( false );
415 void perror(in char* s);
417 int fwprintf(FILE* stream, in wchar_t* format, ...);
418 int fwscanf(FILE* stream, in wchar_t* format, ...);
419 int swprintf(wchar_t* s, size_t n, in wchar_t* format, ...);
420 int swscanf(in wchar_t* s, in wchar_t* format, ...);
421 int vfwprintf(FILE* stream, in wchar_t* format, va_list arg);
422 int vfwscanf(FILE* stream, in wchar_t* format, va_list arg);
423 int vswprintf(wchar_t* s, size_t n, in wchar_t* format, va_list arg);
424 int vswscanf(in wchar_t* s, in wchar_t* format, va_list arg);
425 int vwprintf(in wchar_t* format, va_list arg);
426 int vwscanf(in wchar_t* format, va_list arg);
427 int wprintf(in wchar_t* format, ...);
428 int wscanf(in wchar_t* format, ...);
430 wint_t fgetwc(FILE* stream);
431 wint_t fputwc(wchar_t c, FILE* stream);
433 wchar_t* fgetws(wchar_t* s, int n, FILE* stream);
434 int fputws(in wchar_t* s, FILE* stream);
438 wint_t getwchar() { return fgetwc(stdin); }
439 wint_t putwchar(wchar_t c) { return fputwc(c,stdout); }
440 wint_t getwc(FILE* stream) { return fgetwc(stream); }
441 wint_t putwc(wchar_t c, FILE* stream) { return fputwc(c, stream); }
444 wint_t ungetwc(wint_t c, FILE* stream);
445 int fwide(FILE* stream, int mode);