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 1 /* currently reading */
34 #define _IOWRT 2 /* currently writing */
35 #define _IORW 0x0080 /* opened as "r+w" */
39 * The three standard file pointers provided by the run time library.
40 * NOTE: These will go to the bit-bucket silently in GUI applications!
42 #define STDIN_FILENO 0
43 #define STDOUT_FILENO 1
44 #define STDERR_FILENO 2
46 /* Returned by various functions on end of file condition or error. */
50 * The maximum length of a file name. You should use GetVolumeInformation
51 * instead of this constant. But hey, this works.
52 * Also defined in io.h.
55 #define FILENAME_MAX (260)
59 * The maximum number of files that may be open at once. I have set this to
60 * a conservative number. The actual value may be higher.
62 #define FOPEN_MAX (20)
64 /* After creating this many names, tmpnam and tmpfile return NULL */
67 * Tmpnam, tmpfile and, sometimes, _tempnam try to create
68 * temp files in the root directory of the current drive
69 * (not in pwd, as suggested by some older MS doc's).
70 * Redefining these macros does not effect the CRT functions.
72 #define _P_tmpdir "\\"
73 #ifndef __STRICT_ANSI__
74 #define P_tmpdir _P_tmpdir
76 #define _wP_tmpdir L"\\"
79 * The maximum size of name (including NUL) that will be put in the user
80 * supplied buffer caName for tmpnam.
81 * Inferred from the size of the static buffer returned by tmpnam
82 * when passed a NULL argument. May actually be smaller.
86 #define _IOFBF 0x0000 /* full buffered */
87 #define _IOLBF 0x0040 /* line buffered */
88 #define _IONBF 0x0004 /* not buffered */
90 #define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */
91 #define _IOEOF 0x0010 /* EOF reached on read */
92 #define _IOERR 0x0020 /* I/O error from system */
93 #define _IOSTRG 0x0040 /* Strange or no file descriptor */
95 # define _IOAPPEND 0x0200
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
fopen (const char*, const char*);
170 _CRTIMP
FILE* __cdecl
freopen (const char*, const char*, FILE*);
171 _CRTIMP
int __cdecl
fflush (FILE*);
172 _CRTIMP
int __cdecl
fclose (FILE*);
173 /* MS puts remove & rename (but not wide versions) in io.h also */
174 _CRTIMP
int __cdecl
remove (const char*);
175 _CRTIMP
int __cdecl
rename (const char*, const char*);
176 _CRTIMP
FILE* __cdecl
tmpfile (void);
177 _CRTIMP
char* __cdecl
tmpnam (char*);
179 #ifndef __STRICT_ANSI__
180 _CRTIMP
char* __cdecl
_tempnam (const char*, const char*);
181 _CRTIMP
int __cdecl
_rmtmp(void);
182 _CRTIMP
int __cdecl
_unlink (const char*);
185 _CRTIMP
char* __cdecl
tempnam (const char*, const char*);
186 _CRTIMP
int __cdecl
rmtmp(void);
187 _CRTIMP
int __cdecl
unlink (const char*);
189 #endif /* __STRICT_ANSI__ */
191 _CRTIMP
int __cdecl
setvbuf (FILE*, char*, int, size_t);
193 _CRTIMP
void __cdecl
setbuf (FILE*, char*);
199 _CRTIMP
int __cdecl
fprintf (FILE*, const char*, ...);
200 _CRTIMP
int __cdecl
printf (const char*, ...);
201 _CRTIMP
int __cdecl
sprintf (char*, const char*, ...);
202 _CRTIMP
int __cdecl
_snprintf (char*, size_t, const char*, ...);
203 _CRTIMP
int __cdecl
vfprintf (FILE*, const char*, __VALIST
);
204 _CRTIMP
int __cdecl
vprintf (const char*, __VALIST
);
205 _CRTIMP
int __cdecl
vsprintf (char*, const char*, __VALIST
);
206 _CRTIMP
int __cdecl
_vsnprintf (char*, size_t, const char*, __VALIST
);
208 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
209 int __cdecl
snprintf(char* s
, size_t n
, const char* format
, ...);
210 __CRT_INLINE
int __cdecl
211 vsnprintf (char* s
, size_t n
, const char* format
, __VALIST arg
)
212 { return _vsnprintf ( s
, n
, format
, arg
); }
213 int __cdecl
vscanf (const char * __restrict__
, __VALIST
);
214 int __cdecl
vfscanf (FILE * __restrict__
, const char * __restrict__
,
216 int __cdecl
vsscanf (const char * __restrict__
,
217 const char * __restrict__
, __VALIST
);
224 _CRTIMP
int __cdecl
fscanf (FILE*, const char*, ...);
225 _CRTIMP
int __cdecl
scanf (const char*, ...);
226 _CRTIMP
int __cdecl
sscanf (const char*, const char*, ...);
228 * Character Input and Output Functions
231 _CRTIMP
int __cdecl
fgetc (FILE*);
232 _CRTIMP
char* __cdecl
fgets (char*, int, FILE*);
233 _CRTIMP
int __cdecl
fputc (int, FILE*);
234 _CRTIMP
int __cdecl
fputs (const char*, FILE*);
235 _CRTIMP
char* __cdecl
gets (char*);
236 _CRTIMP
int __cdecl
puts (const char*);
237 _CRTIMP
int __cdecl
ungetc (int, FILE*);
239 /* Traditionally, getc and putc are defined as macros. but the
240 standard doesn't say that they must be macros.
241 We use inline functions here to allow the fast versions
242 to be used in C++ with namespace qualification, eg., ::getc.
244 _filbuf and _flsbuf are not thread-safe. */
245 _CRTIMP
int __cdecl
_filbuf (FILE*);
246 _CRTIMP
int __cdecl
_flsbuf (int, FILE*);
250 __CRT_INLINE
int __cdecl
getc (FILE* __F
)
252 return (--__F
->_cnt
>= 0)
253 ? (int) (unsigned char) *__F
->_ptr
++
257 __CRT_INLINE
int __cdecl
putc (int __c
, FILE* __F
)
259 return (--__F
->_cnt
>= 0)
260 ? (int) (unsigned char) (*__F
->_ptr
++ = (char)__c
)
261 : _flsbuf (__c
, __F
);
264 __CRT_INLINE
int __cdecl
getchar (void)
266 return (--stdin
->_cnt
>= 0)
267 ? (int) (unsigned char) *stdin
->_ptr
++
271 __CRT_INLINE
int __cdecl
putchar(int __c
)
273 return (--stdout
->_cnt
>= 0)
274 ? (int) (unsigned char) (*stdout
->_ptr
++ = (char)__c
)
275 : _flsbuf (__c
, stdout
);}
277 #else /* Use library functions. */
279 _CRTIMP
int __cdecl
getc (FILE*);
280 _CRTIMP
int __cdecl
putc (int, FILE*);
281 _CRTIMP
int __cdecl
getchar (void);
282 _CRTIMP
int __cdecl
putchar (int);
287 * Direct Input and Output Functions
290 _CRTIMP
size_t __cdecl
fread (void*, size_t, size_t, FILE*);
291 _CRTIMP
size_t __cdecl
fwrite (const void*, size_t, size_t, FILE*);
294 * File Positioning Functions
297 _CRTIMP
int __cdecl
fseek (FILE*, long, int);
298 _CRTIMP
long __cdecl
ftell (FILE*);
299 _CRTIMP
void __cdecl
rewind (FILE*);
301 #if __MSVCRT_VERSION__ >= 0x800
302 _CRTIMP
int __cdecl
_fseek_nolock (FILE*, long, int);
303 _CRTIMP
long __cdecl
_ftell_nolock (FILE*);
305 _CRTIMP
int __cdecl
_fseeki64 (FILE*, __int64
, int);
306 _CRTIMP __int64 __cdecl
_ftelli64 (FILE*);
307 _CRTIMP
int __cdecl
_fseeki64_nolock (FILE*, __int64
, int);
308 _CRTIMP __int64 __cdecl
_ftelli64_nolock (FILE*);
311 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
313 * Workaround for limitations on win9x where a file contents are
314 * not zero'd out if you seek past the end and then write.
317 int __cdecl
__mingw_fseek (FILE *, long, int);
318 size_t __cdecl
__mingw_fwrite (const void*, size_t, size_t, FILE*);
319 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
320 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
321 #endif /* __USE_MINGW_FSEEK */
324 * An opaque data type used for storing file positions... The contents of
325 * this type are unknown, but we (the compiler) need to know the size
326 * because the programmer using fgetpos and fsetpos will be setting aside
327 * storage for fpos_t structres. Actually I tested using a byte array and
328 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
329 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
330 * MSVCRT however, and for now `long long' will do.
333 typedef long long fpos_t;
338 _CRTIMP
int __cdecl
fgetpos (FILE*, fpos_t*);
339 _CRTIMP
int __cdecl
fsetpos (FILE*, const fpos_t*);
345 _CRTIMP
int __cdecl
feof (FILE*);
346 _CRTIMP
int __cdecl
ferror (FILE*);
349 inline int __cdecl
feof (FILE* __F
)
350 { return __F
->_flag
& _IOEOF
; }
351 inline int __cdecl
ferror (FILE* __F
)
352 { return __F
->_flag
& _IOERR
; }
354 #define feof(__F) ((__F)->_flag & _IOEOF)
355 #define ferror(__F) ((__F)->_flag & _IOERR)
358 _CRTIMP
void __cdecl
clearerr (FILE*);
359 _CRTIMP
void __cdecl
perror (const char*);
362 #ifndef __STRICT_ANSI__
366 _CRTIMP
FILE* __cdecl
_popen (const char*, const char*);
367 _CRTIMP
int __cdecl
_pclose (FILE*);
370 _CRTIMP
FILE* __cdecl
popen (const char*, const char*);
371 _CRTIMP
int __cdecl
pclose (FILE*);
375 * Other Non ANSI functions
377 _CRTIMP
int __cdecl
_flushall (void);
378 _CRTIMP
int __cdecl
_fgetchar (void);
379 _CRTIMP
int __cdecl
_fputchar (int);
380 _CRTIMP
FILE* __cdecl
_fdopen (int, const char*);
381 _CRTIMP
int __cdecl
_fileno (FILE*);
382 _CRTIMP
int __cdecl
_fcloseall(void);
383 _CRTIMP
FILE* __cdecl
_fsopen(const char*, const char*, int);
385 _CRTIMP
int __cdecl
_getmaxstdio(void);
386 _CRTIMP
int __cdecl
_setmaxstdio(int);
389 #if __MSVCRT_VERSION__ >= 0x800
390 _CRTIMP
int __cdecl
_set_printf_count_output(int);
391 _CRTIMP
int __cdecl
_get_printf_count_output(void);
395 _CRTIMP
int __cdecl
fgetchar (void);
396 _CRTIMP
int __cdecl
fputchar (int);
397 _CRTIMP
FILE* __cdecl
fdopen (int, const char*);
398 _CRTIMP
int __cdecl
fileno (FILE*);
399 #endif /* Not _NO_OLDNAMES */
401 #define _fileno(__F) ((__F)->_file)
403 #define fileno(__F) ((__F)->_file)
406 #if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
407 #include <sys/types.h>
408 __CRT_INLINE
FILE* __cdecl
fopen64 (const char* filename
, const char* mode
)
410 return fopen (filename
, mode
);
413 int __cdecl
fseeko64 (FILE*, off64_t
, int);
415 #ifdef __USE_MINGW_FSEEK
416 int __cdecl
__mingw_fseeko64 (FILE *, off64_t
, int);
417 #define fseeko64(fp, offset, whence) __mingw_fseeko64(fp, offset, whence)
420 __CRT_INLINE off64_t __cdecl
ftello64 (FILE * stream
)
423 if (fgetpos(stream
, &pos
))
426 return ((off64_t
) pos
);
428 #endif /* __NO_MINGW_LFS */
430 #endif /* Not __STRICT_ANSI__ */
434 #ifndef _WSTDIO_DEFINED
435 /* also in wchar.h - keep in sync */
436 _CRTIMP
int __cdecl
fwprintf (FILE*, const wchar_t*, ...);
437 _CRTIMP
int __cdecl
wprintf (const wchar_t*, ...);
438 _CRTIMP
int __cdecl
swprintf (wchar_t*, const wchar_t*, ...);
439 _CRTIMP
int __cdecl
_snwprintf (wchar_t*, size_t, const wchar_t*, ...);
440 _CRTIMP
int __cdecl
vfwprintf (FILE*, const wchar_t*, __VALIST
);
441 _CRTIMP
int __cdecl
vwprintf (const wchar_t*, __VALIST
);
442 _CRTIMP
int __cdecl
vswprintf (wchar_t*, const wchar_t*, __VALIST
);
443 _CRTIMP
int __cdecl
_vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST
);
444 _CRTIMP
int __cdecl
fwscanf (FILE*, const wchar_t*, ...);
445 _CRTIMP
int __cdecl
wscanf (const wchar_t*, ...);
446 _CRTIMP
int __cdecl
swscanf (const wchar_t*, const wchar_t*, ...);
447 _CRTIMP
wint_t __cdecl
fgetwc (FILE*);
448 _CRTIMP
wint_t __cdecl
fputwc (wchar_t, FILE*);
449 _CRTIMP
wint_t __cdecl
ungetwc (wchar_t, FILE*);
452 _CRTIMP
wchar_t* __cdecl
fgetws (wchar_t*, int, FILE*);
453 _CRTIMP
int __cdecl
fputws (const wchar_t*, FILE*);
454 _CRTIMP
wint_t __cdecl
getwc (FILE*);
455 _CRTIMP
wint_t __cdecl
getwchar (void);
456 _CRTIMP
wchar_t* __cdecl
_getws (wchar_t*);
457 _CRTIMP
wint_t __cdecl
putwc (wint_t, FILE*);
458 _CRTIMP
int __cdecl
_putws (const wchar_t*);
459 _CRTIMP
wint_t __cdecl
putwchar (wint_t);
460 _CRTIMP
FILE* __cdecl
_wfdopen(int, wchar_t *);
461 _CRTIMP
FILE* __cdecl
_wfopen (const wchar_t*, const wchar_t*);
462 _CRTIMP
FILE* __cdecl
_wfreopen (const wchar_t*, const wchar_t*, FILE*);
463 _CRTIMP
FILE* __cdecl
_wfsopen (const wchar_t*, const wchar_t*, int);
464 _CRTIMP
wchar_t* __cdecl
_wtmpnam (wchar_t*);
465 _CRTIMP
wchar_t* __cdecl
_wtempnam (const wchar_t*, const wchar_t*);
466 _CRTIMP
int __cdecl
_wrename (const wchar_t*, const wchar_t*);
467 _CRTIMP
int __cdecl
_wremove (const wchar_t*);
468 _CRTIMP
void __cdecl
_wperror (const wchar_t*);
469 _CRTIMP
FILE* __cdecl
_wpopen (const wchar_t*, const wchar_t*);
470 #endif /* __MSVCRT__ */
472 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
473 int __cdecl
snwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, ...);
474 __CRT_INLINE
int __cdecl
475 vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, __VALIST arg
)
476 { return _vsnwprintf ( s
, n
, format
, arg
);}
477 int __cdecl
vwscanf (const wchar_t * __restrict__
, __VALIST
);
478 int __cdecl
vfwscanf (FILE * __restrict__
,
479 const wchar_t * __restrict__
, __VALIST
);
480 int __cdecl
vswscanf (const wchar_t * __restrict__
,
481 const wchar_t * __restrict__
, __VALIST
);
484 #define _WSTDIO_DEFINED
485 #endif /* _WSTDIO_DEFINED */
487 #ifndef __STRICT_ANSI__
490 _CRTIMP
FILE* __cdecl
wpopen (const wchar_t*, const wchar_t*);
491 #endif /* not NO_OLDNAMES */
492 #endif /* MSVCRT runtime */
495 * Other Non ANSI wide functions
497 _CRTIMP
wint_t __cdecl
_fgetwchar (void);
498 _CRTIMP
wint_t __cdecl
_fputwchar (wint_t);
499 _CRTIMP
int __cdecl
_getw (FILE*);
500 _CRTIMP
int __cdecl
_putw (int, FILE*);
503 _CRTIMP
wint_t __cdecl
fgetwchar (void);
504 _CRTIMP
wint_t __cdecl
fputwchar (wint_t);
505 _CRTIMP
int __cdecl
getw (FILE*);
506 _CRTIMP
int __cdecl
putw (int, FILE*);
507 #endif /* Not _NO_OLDNAMES */
509 #endif /* __STRICT_ANSI */
515 #endif /* Not RC_INVOKED */
517 #endif /* _STDIO_H_ */