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
);
208 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
209 int __cdecl __MINGW_NOTHROW
snprintf(char *, size_t, const char *, ...);
210 int __cdecl __MINGW_NOTHROW
vsnprintf (char *, size_t, const char *, __VALIST
);
212 int __cdecl __MINGW_NOTHROW
vscanf (const char * __restrict__
, __VALIST
);
213 int __cdecl __MINGW_NOTHROW
vfscanf (FILE * __restrict__
, const char * __restrict__
,
215 int __cdecl __MINGW_NOTHROW
vsscanf (const char * __restrict__
,
216 const char * __restrict__
, __VALIST
);
223 _CRTIMP
int __cdecl __MINGW_NOTHROW
fscanf (FILE*, const char*, ...);
224 _CRTIMP
int __cdecl __MINGW_NOTHROW
scanf (const char*, ...);
225 _CRTIMP
int __cdecl __MINGW_NOTHROW
sscanf (const char*, const char*, ...);
227 * Character Input and Output Functions
230 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetc (FILE*);
231 _CRTIMP
char* __cdecl __MINGW_NOTHROW
fgets (char*, int, FILE*);
232 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputc (int, FILE*);
233 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputs (const char*, FILE*);
234 _CRTIMP
char* __cdecl __MINGW_NOTHROW
gets (char*);
235 _CRTIMP
int __cdecl __MINGW_NOTHROW
puts (const char*);
236 _CRTIMP
int __cdecl __MINGW_NOTHROW
ungetc (int, FILE*);
238 /* Traditionally, getc and putc are defined as macros. but the
239 standard doesn't say that they must be macros.
240 We use inline functions here to allow the fast versions
241 to be used in C++ with namespace qualification, eg., ::getc.
243 _filbuf and _flsbuf are not thread-safe. */
244 _CRTIMP
int __cdecl __MINGW_NOTHROW
_filbuf (FILE*);
245 _CRTIMP
int __cdecl __MINGW_NOTHROW
_flsbuf (int, FILE*);
249 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
getc (FILE* __F
)
251 return (--__F
->_cnt
>= 0)
252 ? (int) (unsigned char) *__F
->_ptr
++
256 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
putc (int __c
, FILE* __F
)
258 return (--__F
->_cnt
>= 0)
259 ? (int) (unsigned char) (*__F
->_ptr
++ = (char)__c
)
260 : _flsbuf (__c
, __F
);
263 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
getchar (void)
265 return (--stdin
->_cnt
>= 0)
266 ? (int) (unsigned char) *stdin
->_ptr
++
270 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
putchar(int __c
)
272 return (--stdout
->_cnt
>= 0)
273 ? (int) (unsigned char) (*stdout
->_ptr
++ = (char)__c
)
274 : _flsbuf (__c
, stdout
);}
276 #else /* Use library functions. */
278 _CRTIMP
int __cdecl __MINGW_NOTHROW
getc (FILE*);
279 _CRTIMP
int __cdecl __MINGW_NOTHROW
putc (int, FILE*);
280 _CRTIMP
int __cdecl __MINGW_NOTHROW
getchar (void);
281 _CRTIMP
int __cdecl __MINGW_NOTHROW
putchar (int);
286 * Direct Input and Output Functions
289 _CRTIMP
size_t __cdecl __MINGW_NOTHROW
fread (void*, size_t, size_t, FILE*);
290 _CRTIMP
size_t __cdecl __MINGW_NOTHROW
fwrite (const void*, size_t, size_t, FILE*);
293 * File Positioning Functions
296 _CRTIMP
int __cdecl __MINGW_NOTHROW
fseek (FILE*, long, int);
297 _CRTIMP
long __cdecl __MINGW_NOTHROW
ftell (FILE*);
298 _CRTIMP
void __cdecl __MINGW_NOTHROW
rewind (FILE*);
300 #if __MSVCRT_VERSION__ >= 0x800
301 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseek_nolock (FILE*, long, int);
302 _CRTIMP
long __cdecl __MINGW_NOTHROW
_ftell_nolock (FILE*);
304 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseeki64 (FILE*, __int64
, int);
305 _CRTIMP __int64 __cdecl __MINGW_NOTHROW
_ftelli64 (FILE*);
306 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fseeki64_nolock (FILE*, __int64
, int);
307 _CRTIMP __int64 __cdecl __MINGW_NOTHROW
_ftelli64_nolock (FILE*);
310 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
312 * Workaround for limitations on win9x where a file contents are
313 * not zero'd out if you seek past the end and then write.
316 int __cdecl __MINGW_NOTHROW
__mingw_fseek (FILE *, long, int);
317 size_t __cdecl __MINGW_NOTHROW
__mingw_fwrite (const void*, size_t, size_t, FILE*);
318 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
319 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
320 #endif /* __USE_MINGW_FSEEK */
323 * An opaque data type used for storing file positions... The contents of
324 * this type are unknown, but we (the compiler) need to know the size
325 * because the programmer using fgetpos and fsetpos will be setting aside
326 * storage for fpos_t structres. Actually I tested using a byte array and
327 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
328 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
329 * MSVCRT however, and for now `long long' will do.
332 typedef long long fpos_t;
337 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetpos (FILE*, fpos_t*);
338 _CRTIMP
int __cdecl __MINGW_NOTHROW
fsetpos (FILE*, const fpos_t*);
344 _CRTIMP
int __cdecl __MINGW_NOTHROW
feof (FILE*);
345 _CRTIMP
int __cdecl __MINGW_NOTHROW
ferror (FILE*);
348 inline int __cdecl __MINGW_NOTHROW
feof (FILE* __F
)
349 { return __F
->_flag
& _IOEOF
; }
350 inline int __cdecl __MINGW_NOTHROW
ferror (FILE* __F
)
351 { return __F
->_flag
& _IOERR
; }
353 #define feof(__F) ((__F)->_flag & _IOEOF)
354 #define ferror(__F) ((__F)->_flag & _IOERR)
357 _CRTIMP
void __cdecl __MINGW_NOTHROW
clearerr (FILE*);
358 _CRTIMP
void __cdecl __MINGW_NOTHROW
perror (const char*);
361 #ifndef __STRICT_ANSI__
365 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_popen (const char*, const char*);
366 _CRTIMP
int __cdecl __MINGW_NOTHROW
_pclose (FILE*);
369 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
popen (const char*, const char*);
370 _CRTIMP
int __cdecl __MINGW_NOTHROW
pclose (FILE*);
374 * Other Non ANSI functions
376 _CRTIMP
int __cdecl __MINGW_NOTHROW
_flushall (void);
377 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fgetchar (void);
378 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fputchar (int);
379 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_fdopen (int, const char*);
380 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fileno (FILE*);
381 _CRTIMP
int __cdecl __MINGW_NOTHROW
_fcloseall(void);
382 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_fsopen(const char*, const char*, int);
384 _CRTIMP
int __cdecl __MINGW_NOTHROW
_getmaxstdio(void);
385 _CRTIMP
int __cdecl __MINGW_NOTHROW
_setmaxstdio(int);
388 #if __MSVCRT_VERSION__ >= 0x800
389 _CRTIMP
int __cdecl __MINGW_NOTHROW
_set_printf_count_output(int);
390 _CRTIMP
int __cdecl __MINGW_NOTHROW
_get_printf_count_output(void);
394 _CRTIMP
int __cdecl __MINGW_NOTHROW
fgetchar (void);
395 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputchar (int);
396 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
fdopen (int, const char*);
397 _CRTIMP
int __cdecl __MINGW_NOTHROW
fileno (FILE*);
398 #endif /* Not _NO_OLDNAMES */
400 #define _fileno(__F) ((__F)->_file)
402 #define fileno(__F) ((__F)->_file)
405 #if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
406 #include <sys/types.h>
407 __CRT_INLINE
FILE* __cdecl __MINGW_NOTHROW
fopen64 (const char* filename
, const char* mode
)
409 return fopen (filename
, mode
);
412 int __cdecl __MINGW_NOTHROW
fseeko64 (FILE*, off64_t
, int);
414 #ifdef __USE_MINGW_FSEEK
415 int __cdecl __MINGW_NOTHROW
__mingw_fseeko64 (FILE *, off64_t
, int);
416 #define fseeko64(fp, offset, whence) __mingw_fseeko64(fp, offset, whence)
419 __CRT_INLINE off64_t __cdecl __MINGW_NOTHROW
ftello64 (FILE * stream
)
422 if (fgetpos(stream
, &pos
))
425 return ((off64_t
) pos
);
427 #endif /* __NO_MINGW_LFS */
429 #endif /* Not __STRICT_ANSI__ */
433 #ifndef _WSTDIO_DEFINED
434 /* also in wchar.h - keep in sync */
435 _CRTIMP
int __cdecl __MINGW_NOTHROW
fwprintf (FILE*, const wchar_t*, ...);
436 _CRTIMP
int __cdecl __MINGW_NOTHROW
wprintf (const wchar_t*, ...);
437 _CRTIMP
int __cdecl __MINGW_NOTHROW
swprintf (wchar_t*, const wchar_t*, ...);
438 _CRTIMP
int __cdecl __MINGW_NOTHROW
_snwprintf (wchar_t*, size_t, const wchar_t*, ...);
439 _CRTIMP
int __cdecl __MINGW_NOTHROW
vfwprintf (FILE*, const wchar_t*, __VALIST
);
440 _CRTIMP
int __cdecl __MINGW_NOTHROW
vwprintf (const wchar_t*, __VALIST
);
441 _CRTIMP
int __cdecl __MINGW_NOTHROW
vswprintf (wchar_t*, const wchar_t*, __VALIST
);
442 _CRTIMP
int __cdecl __MINGW_NOTHROW
_vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST
);
443 _CRTIMP
int __cdecl __MINGW_NOTHROW
fwscanf (FILE*, const wchar_t*, ...);
444 _CRTIMP
int __cdecl __MINGW_NOTHROW
wscanf (const wchar_t*, ...);
445 _CRTIMP
int __cdecl __MINGW_NOTHROW
swscanf (const wchar_t*, const wchar_t*, ...);
446 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fgetwc (FILE*);
447 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fputwc (wchar_t, FILE*);
448 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
ungetwc (wchar_t, FILE*);
451 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
fgetws (wchar_t*, int, FILE*);
452 _CRTIMP
int __cdecl __MINGW_NOTHROW
fputws (const wchar_t*, FILE*);
453 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
getwc (FILE*);
454 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
getwchar (void);
455 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_getws (wchar_t*);
456 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
putwc (wint_t, FILE*);
457 _CRTIMP
int __cdecl __MINGW_NOTHROW
_putws (const wchar_t*);
458 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
putwchar (wint_t);
459 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfdopen(int, const wchar_t *);
460 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfopen (const wchar_t*, const wchar_t*);
461 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfreopen (const wchar_t*, const wchar_t*, FILE*);
462 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wfsopen (const wchar_t*, const wchar_t*, int);
463 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_wtmpnam (wchar_t*);
464 _CRTIMP
wchar_t* __cdecl __MINGW_NOTHROW
_wtempnam (const wchar_t*, const wchar_t*);
465 _CRTIMP
int __cdecl __MINGW_NOTHROW
_wrename (const wchar_t*, const wchar_t*);
466 _CRTIMP
int __cdecl __MINGW_NOTHROW
_wremove (const wchar_t*);
467 _CRTIMP
void __cdecl __MINGW_NOTHROW
_wperror (const wchar_t*);
468 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
_wpopen (const wchar_t*, const wchar_t*);
469 #endif /* __MSVCRT__ */
471 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
472 int __cdecl __MINGW_NOTHROW
snwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, ...);
473 __CRT_INLINE
int __cdecl __MINGW_NOTHROW
474 vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, __VALIST arg
)
475 { return _vsnwprintf ( s
, n
, format
, arg
);}
476 int __cdecl __MINGW_NOTHROW
vwscanf (const wchar_t * __restrict__
, __VALIST
);
477 int __cdecl __MINGW_NOTHROW
vfwscanf (FILE * __restrict__
,
478 const wchar_t * __restrict__
, __VALIST
);
479 int __cdecl __MINGW_NOTHROW
vswscanf (const wchar_t * __restrict__
,
480 const wchar_t * __restrict__
, __VALIST
);
483 #define _WSTDIO_DEFINED
484 #endif /* _WSTDIO_DEFINED */
486 #ifndef __STRICT_ANSI__
489 _CRTIMP
FILE* __cdecl __MINGW_NOTHROW
wpopen (const wchar_t*, const wchar_t*);
490 #endif /* not NO_OLDNAMES */
491 #endif /* MSVCRT runtime */
494 * Other Non ANSI wide functions
496 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
_fgetwchar (void);
497 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
_fputwchar (wint_t);
498 _CRTIMP
int __cdecl __MINGW_NOTHROW
_getw (FILE*);
499 _CRTIMP
int __cdecl __MINGW_NOTHROW
_putw (int, FILE*);
502 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fgetwchar (void);
503 _CRTIMP
wint_t __cdecl __MINGW_NOTHROW
fputwchar (wint_t);
504 _CRTIMP
int __cdecl __MINGW_NOTHROW
getw (FILE*);
505 _CRTIMP
int __cdecl __MINGW_NOTHROW
putw (int, FILE*);
506 #endif /* Not _NO_OLDNAMES */
508 #endif /* __STRICT_ANSI */
514 #endif /* Not RC_INVOKED */
516 #endif /* _STDIO_H_ */