3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
7 * Definitions of types and prototypes of functions for standard input and
10 * NOTE: The file manipulation functions provided by Microsoft seem to
11 * work with either slash (/) or backslash (\) as the directory separator.
18 /* All the headers include this file. */
24 #define __need_wchar_t
27 #define __need___va_list
29 #endif /* Not RC_INVOKED */
32 /* Flags for the iobuf structure */
33 #define _IOREAD 0x0001 /* currently reading */
34 #define _IOWRT 0x0002 /* currently writing */
35 #define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */
36 #define _IOEOF 0x0010 /* EOF reached on read */
37 #define _IOERR 0x0020 /* I/O error from system */
38 #define _IOSTRG 0x0040 /* Strange or no file descriptor */
39 #define _IORW 0x0080 /* opened as "r+w" */
41 # define _IOAPPEND 0x0200
46 * The three standard file pointers provided by the run time library.
47 * NOTE: These will go to the bit-bucket silently in GUI applications!
49 #define STDIN_FILENO 0
50 #define STDOUT_FILENO 1
51 #define STDERR_FILENO 2
53 /* Returned by various functions on end of file condition or error. */
57 * The maximum length of a file name. You should use GetVolumeInformation
58 * instead of this constant. But hey, this works.
59 * Also defined in io.h.
62 #define FILENAME_MAX (260)
66 * The maximum number of files that may be open at once. I have set this to
67 * a conservative number. The actual value may be higher.
69 #define FOPEN_MAX (20)
71 /* After creating this many names, tmpnam and tmpfile return NULL */
74 * Tmpnam, tmpfile and, sometimes, _tempnam try to create
75 * temp files in the root directory of the current drive
76 * (not in pwd, as suggested by some older MS doc's).
77 * Redefining these macros does not effect the CRT functions.
79 #define _P_tmpdir "\\"
80 #ifndef __STRICT_ANSI__
81 #define P_tmpdir _P_tmpdir
83 #define _wP_tmpdir L"\\"
86 * The maximum size of name (including NUL) that will be put in the user
87 * supplied buffer caName for tmpnam.
88 * Inferred from the size of the static buffer returned by tmpnam
89 * when passed a NULL argument. May actually be smaller.
93 #define _IOFBF 0x0000 /* full buffered */
94 #define _IOLBF 0x0040 /* line buffered */
95 #define _IONBF 0x0004 /* not buffered */
98 * The buffer size as used by setbuf such that it is equivalent to
99 * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
103 /* Constants for nOrigin indicating the position relative to which fseek
104 * sets the file position. Defined unconditionally since ISO and POSIX
105 * say they are defined here. */
114 #define __VALIST __gnuc_va_list
116 #define __VALIST char*
118 #endif /* defined __VALIST */
121 * The structure underlying the FILE type.
123 * Some believe that nobody in their right mind should make use of the
124 * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
127 #ifndef _FILE_DEFINED
128 #define _FILE_DEFINED
129 typedef struct _iobuf
140 #endif /* Not _FILE_DEFINED */
144 * The standard file handles
146 #ifndef __DECLSPEC_SUPPORTED
148 extern FILE (*_imp___iob
)[]; /* A pointer to an array of FILE */
150 #define _iob (*_imp___iob) /* An array of FILE */
152 #else /* __DECLSPEC_SUPPORTED */
154 __MINGW_IMPORT
FILE _iob
[]; /* An array of FILE imported from DLL. */
156 #endif /* __DECLSPEC_SUPPORTED */
158 #define stdin (&_iob[STDIN_FILENO])
159 #define stdout (&_iob[STDOUT_FILENO])
160 #define stderr (&_iob[STDERR_FILENO])
169 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
fopen (const char*, const char*);
170 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
freopen (const char*, const char*, FILE*);
171 _CRTIMP
int __cdecl __MINGW_NOTHROW
fflush (FILE*);
172 _CRTIMP
int __cdecl __MINGW_NOTHROW
fclose (FILE*);
173 /* MS puts remove & rename (but not wide versions) in io.h also */
174 _CRTIMP
int __cdecl __MINGW_NOTHROW
remove (const char*);
175 _CRTIMP
int __cdecl __MINGW_NOTHROW
rename (const char*, const char*);
176 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
tmpfile (void);
177 _CRTIMP
char* __cdecl __MINGW_NOTHROW
tmpnam (char*);
179 #ifndef __STRICT_ANSI__
180 _CRTIMP
char* __cdecl __MINGW_NOTHROW
_tempnam (const char*, const char*);
181 _CRTIMP
int __cdecl __MINGW_NOTHROW
_rmtmp(void);
182 _CRTIMP
int __cdecl __MINGW_NOTHROW
_unlink (const char*);
185 _CRTIMP
char* __cdecl __MINGW_NOTHROW
tempnam (const char*, const char*);
186 _CRTIMP
int __cdecl __MINGW_NOTHROW
rmtmp(void);
187 _CRTIMP
int __cdecl __MINGW_NOTHROW
unlink (const char*);
189 #endif /* __STRICT_ANSI__ */
191 _CRTIMP
int __cdecl __MINGW_NOTHROW
setvbuf (FILE*, char*, int, size_t);
193 _CRTIMP
void __cdecl __MINGW_NOTHROW
setbuf (FILE*, char*);
199 _CRTIMP
int __cdecl __MINGW_NOTHROW
fprintf (FILE*, const char*, ...);
200 _CRTIMP
int __cdecl __MINGW_NOTHROW
printf (const char*, ...);
201 _CRTIMP
int __cdecl __MINGW_NOTHROW
sprintf (char*, const char*, ...);
202 _CRTIMP
int __cdecl __MINGW_NOTHROW
_snprintf (char*, size_t, const char*, ...);
203 _CRTIMP
int __cdecl __MINGW_NOTHROW
vfprintf (FILE*, const char*, __VALIST
);
204 _CRTIMP
int __cdecl __MINGW_NOTHROW
vprintf (const char*, __VALIST
);
205 _CRTIMP
int __cdecl __MINGW_NOTHROW
vsprintf (char*, const char*, __VALIST
);
206 _CRTIMP
int __cdecl __MINGW_NOTHROW
_vsnprintf (char*, size_t, const char*, __VALIST
);
209 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
snprintf(char * s
, size_t n
, const char * f
, ...)
213 __mingw_va_start(a
, f
);
214 r
= _vsnprintf (s
, n
, f
, a
);
219 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
vsnprintf (char * s
, size_t n
, const char * f
, __VALIST a
)
221 return _vsnprintf (s
, n
, f
, a
);
224 int __cdecl __MINGW_NOTHROW
vscanf (const char * __restrict__ f
, __VALIST a
);
225 int __cdecl __MINGW_NOTHROW
vfscanf (FILE * __restrict__ o
, const char * __restrict__ f
,
227 int __cdecl __MINGW_NOTHROW
vsscanf (const char * __restrict__ s
,
228 const char * __restrict__ f
, __VALIST a
);
235 _CRTIMP
int __cdecl __MINGW_NOTHROW
fscanf (FILE*, const char*, ...);
236 _CRTIMP
int __cdecl __MINGW_NOTHROW
scanf (const char*, ...);
237 _CRTIMP
int __cdecl __MINGW_NOTHROW
sscanf (const char*, const char*, ...);
239 * Character Input and Output Functions
242 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetc (FILE*);
243 _CRTIMP
char* __cdecl __MINGW_NOTHROW
fgets (char*, int, FILE*);
244 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputc (int, FILE*);
245 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputs (const char*, FILE*);
246 _CRTIMP
char* __cdecl __MINGW_NOTHROW
gets (char*);
247 _CRTIMP
int __cdecl __MINGW_NOTHROW
puts (const char*);
248 _CRTIMP
int __cdecl __MINGW_NOTHROW
ungetc (int, FILE*);
250 /* Traditionally, getc and putc are defined as macros. but the
251 standard doesn't say that they must be macros.
252 We use inline functions here to allow the fast versions
253 to be used in C++ with namespace qualification, eg., ::getc.
255 _filbuf and _flsbuf are not thread-safe. */
256 _CRTIMP
int __cdecl __MINGW_NOTHROW
_filbuf (FILE*);
257 _CRTIMP
int __cdecl __MINGW_NOTHROW
_flsbuf (int, FILE*);
261 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
getc (FILE* __F
)
263 return (--__F
->_cnt
>= 0)
264 ? (int) (unsigned char) *__F
->_ptr
++
268 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
putc (int __c
, FILE* __F
)
270 return (--__F
->_cnt
>= 0)
271 ? (int) (unsigned char) (*__F
->_ptr
++ = (char)__c
)
272 : _flsbuf (__c
, __F
);
275 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
getchar (void)
277 return (--stdin
->_cnt
>= 0)
278 ? (int) (unsigned char) *stdin
->_ptr
++
282 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
putchar(int __c
)
284 return (--stdout
->_cnt
>= 0)
285 ? (int) (unsigned char) (*stdout
->_ptr
++ = (char)__c
)
286 : _flsbuf (__c
, stdout
);}
288 #else /* Use library functions. */
290 _CRTIMP
int __cdecl __MINGW_NOTHROW
getc (FILE*);
291 _CRTIMP
int __cdecl __MINGW_NOTHROW
putc (int, FILE*);
292 _CRTIMP
int __cdecl __MINGW_NOTHROW
getchar (void);
293 _CRTIMP
int __cdecl __MINGW_NOTHROW
putchar (int);
298 * Direct Input and Output Functions
301 _CRTIMP
size_t __cdecl __MINGW_NOTHROW
fread (void*, size_t, size_t, FILE*);
302 _CRTIMP
size_t __cdecl __MINGW_NOTHROW
fwrite (const void*, size_t, size_t, FILE*);
305 * File Positioning Functions
308 _CRTIMP
int __cdecl __MINGW_NOTHROW
fseek (FILE*, long, int);
309 _CRTIMP
long __cdecl __MINGW_NOTHROW
ftell (FILE*);
310 _CRTIMP
void __cdecl __MINGW_NOTHROW
rewind (FILE*);
312 #if __MSVCRT_VERSION__ >= 0x800
313 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseek_nolock (FILE*, long, int);
314 _CRTIMP
long __cdecl __MINGW_NOTHROW
_ftell_nolock (FILE*);
316 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseeki64 (FILE*, __int64
, int);
317 _CRTIMP __int64 __cdecl __MINGW_NOTHROW
_ftelli64 (FILE*);
318 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseeki64_nolock (FILE*, __int64
, int);
319 _CRTIMP __int64 __cdecl __MINGW_NOTHROW
_ftelli64_nolock (FILE*);
322 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
324 * Workaround for limitations on win9x where a file contents are
325 * not zero'd out if you seek past the end and then write.
328 int __cdecl __MINGW_NOTHROW
__mingw_fseek (FILE *, long, int);
329 size_t __cdecl __MINGW_NOTHROW
__mingw_fwrite (const void*, size_t, size_t, FILE*);
330 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
331 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
332 #endif /* __USE_MINGW_FSEEK */
335 * An opaque data type used for storing file positions... The contents of
336 * this type are unknown, but we (the compiler) need to know the size
337 * because the programmer using fgetpos and fsetpos will be setting aside
338 * storage for fpos_t structres. Actually I tested using a byte array and
339 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
340 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
341 * MSVCRT however, and for now `long long' will do.
344 typedef long long fpos_t;
349 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetpos (FILE*, fpos_t*);
350 _CRTIMP
int __cdecl __MINGW_NOTHROW
fsetpos (FILE*, const fpos_t*);
356 _CRTIMP
int __cdecl __MINGW_NOTHROW
feof (FILE*);
357 _CRTIMP
int __cdecl __MINGW_NOTHROW
ferror (FILE*);
360 inline int __cdecl __MINGW_NOTHROW
feof (FILE* __F
)
361 { return __F
->_flag
& _IOEOF
; }
362 inline int __cdecl __MINGW_NOTHROW
ferror (FILE* __F
)
363 { return __F
->_flag
& _IOERR
; }
365 #define feof(__F) ((__F)->_flag & _IOEOF)
366 #define ferror(__F) ((__F)->_flag & _IOERR)
369 _CRTIMP
void __cdecl __MINGW_NOTHROW
clearerr (FILE*);
370 _CRTIMP
void __cdecl __MINGW_NOTHROW
perror (const char*);
373 #ifndef __STRICT_ANSI__
377 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_popen (const char*, const char*);
378 _CRTIMP
int __cdecl __MINGW_NOTHROW
_pclose (FILE*);
381 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
popen (const char*, const char*);
382 _CRTIMP
int __cdecl __MINGW_NOTHROW
pclose (FILE*);
386 * Other Non ANSI functions
388 _CRTIMP
int __cdecl __MINGW_NOTHROW
_flushall (void);
389 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fgetchar (void);
390 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fputchar (int);
391 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_fdopen (int, const char*);
392 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fileno (FILE*);
393 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fcloseall(void);
394 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_fsopen(const char*, const char*, int);
396 _CRTIMP
int __cdecl __MINGW_NOTHROW
_getmaxstdio(void);
397 _CRTIMP
int __cdecl __MINGW_NOTHROW
_setmaxstdio(int);
400 #if __MSVCRT_VERSION__ >= 0x800
401 _CRTIMP
int __cdecl __MINGW_NOTHROW
_set_printf_count_output(int);
402 _CRTIMP
int __cdecl __MINGW_NOTHROW
_get_printf_count_output(void);
406 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetchar (void);
407 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputchar (int);
408 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
fdopen (int, const char*);
409 _CRTIMP
int __cdecl __MINGW_NOTHROW
fileno (FILE*);
410 #endif /* Not _NO_OLDNAMES */
412 #define _fileno(__F) ((__F)->_file)
414 #define fileno(__F) ((__F)->_file)
417 #if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
418 #include <sys/types.h>
419 __CRT_INLINE
FILE* __cdecl __MINGW_NOTHROW
fopen64 (const char* filename
, const char* mode
)
421 return fopen (filename
, mode
);
424 int __cdecl __MINGW_NOTHROW
fseeko64 (FILE*, off64_t
, int);
426 #ifdef __USE_MINGW_FSEEK
427 int __cdecl __MINGW_NOTHROW
__mingw_fseeko64 (FILE *, off64_t
, int);
428 #define fseeko64(fp, offset, whence) __mingw_fseeko64(fp, offset, whence)
431 __CRT_INLINE off64_t __cdecl __MINGW_NOTHROW
ftello64 (FILE * stream
)
434 if (fgetpos(stream
, &pos
))
437 return ((off64_t
) pos
);
439 #endif /* __NO_MINGW_LFS */
441 #endif /* Not __STRICT_ANSI__ */
445 #ifndef _WSTDIO_DEFINED
446 /* also in wchar.h - keep in sync */
447 _CRTIMP
int __cdecl __MINGW_NOTHROW
fwprintf (FILE*, const wchar_t*, ...);
448 _CRTIMP
int __cdecl __MINGW_NOTHROW
wprintf (const wchar_t*, ...);
449 _CRTIMP
int __cdecl __MINGW_NOTHROW
swprintf (wchar_t*, const wchar_t*, ...);
450 _CRTIMP
int __cdecl __MINGW_NOTHROW
_snwprintf (wchar_t*, size_t, const wchar_t*, ...);
451 _CRTIMP
int __cdecl __MINGW_NOTHROW
vfwprintf (FILE*, const wchar_t*, __VALIST
);
452 _CRTIMP
int __cdecl __MINGW_NOTHROW
vwprintf (const wchar_t*, __VALIST
);
453 _CRTIMP
int __cdecl __MINGW_NOTHROW
vswprintf (wchar_t*, const wchar_t*, __VALIST
);
454 _CRTIMP
int __cdecl __MINGW_NOTHROW
_vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST
);
455 _CRTIMP
int __cdecl __MINGW_NOTHROW
fwscanf (FILE*, const wchar_t*, ...);
456 _CRTIMP
int __cdecl __MINGW_NOTHROW
wscanf (const wchar_t*, ...);
457 _CRTIMP
int __cdecl __MINGW_NOTHROW
swscanf (const wchar_t*, const wchar_t*, ...);
458 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fgetwc (FILE*);
459 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fputwc (wchar_t, FILE*);
460 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
ungetwc (wchar_t, FILE*);
463 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
fgetws (wchar_t*, int, FILE*);
464 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputws (const wchar_t*, FILE*);
465 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
getwc (FILE*);
466 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
getwchar (void);
467 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_getws (wchar_t*);
468 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
putwc (wint_t, FILE*);
469 _CRTIMP
int __cdecl __MINGW_NOTHROW
_putws (const wchar_t*);
470 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
putwchar (wint_t);
471 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfdopen(int, const wchar_t *);
472 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfopen (const wchar_t*, const wchar_t*);
473 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfreopen (const wchar_t*, const wchar_t*, FILE*);
474 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfsopen (const wchar_t*, const wchar_t*, int);
475 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_wtmpnam (wchar_t*);
476 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_wtempnam (const wchar_t*, const wchar_t*);
477 _CRTIMP
int __cdecl __MINGW_NOTHROW
_wrename (const wchar_t*, const wchar_t*);
478 _CRTIMP
int __cdecl __MINGW_NOTHROW
_wremove (const wchar_t*);
479 _CRTIMP
void __cdecl __MINGW_NOTHROW
_wperror (const wchar_t*);
480 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wpopen (const wchar_t*, const wchar_t*);
481 #endif /* __MSVCRT__ */
483 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
484 int __cdecl __MINGW_NOTHROW
snwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, ...);
485 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
486 vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, __VALIST arg
)
487 { return _vsnwprintf ( s
, n
, format
, arg
);}
488 int __cdecl __MINGW_NOTHROW
vwscanf (const wchar_t * __restrict__
, __VALIST
);
489 int __cdecl __MINGW_NOTHROW
vfwscanf (FILE * __restrict__
,
490 const wchar_t * __restrict__
, __VALIST
);
491 int __cdecl __MINGW_NOTHROW
vswscanf (const wchar_t * __restrict__
,
492 const wchar_t * __restrict__
, __VALIST
);
495 #define _WSTDIO_DEFINED
496 #endif /* _WSTDIO_DEFINED */
498 #ifndef __STRICT_ANSI__
501 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
wpopen (const wchar_t*, const wchar_t*);
502 #endif /* not NO_OLDNAMES */
503 #endif /* MSVCRT runtime */
506 * Other Non ANSI wide functions
508 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
_fgetwchar (void);
509 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
_fputwchar (wint_t);
510 _CRTIMP
int __cdecl __MINGW_NOTHROW
_getw (FILE*);
511 _CRTIMP
int __cdecl __MINGW_NOTHROW
_putw (int, FILE*);
514 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fgetwchar (void);
515 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fputwchar (wint_t);
516 _CRTIMP
int __cdecl __MINGW_NOTHROW
getw (FILE*);
517 _CRTIMP
int __cdecl __MINGW_NOTHROW
putw (int, FILE*);
518 #endif /* Not _NO_OLDNAMES */
520 #endif /* __STRICT_ANSI */
526 #endif /* Not RC_INVOKED */
528 #endif /* _STDIO_H_ */