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. Enclosed in ifdefs because io.h could also
105 * define them. (Though not anymore since io.h includes this file now.) */
123 #define __VALIST __gnuc_va_list
125 #define __VALIST char*
127 #endif /* defined __VALIST */
130 * The structure underlying the FILE type.
132 * Some believe that nobody in their right mind should make use of the
133 * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
136 #ifndef _FILE_DEFINED
137 #define _FILE_DEFINED
138 typedef struct _iobuf
149 #endif /* Not _FILE_DEFINED */
153 * The standard file handles
155 #ifndef __DECLSPEC_SUPPORTED
157 extern FILE (*_imp___iob
)[]; /* A pointer to an array of FILE */
159 #define _iob (*_imp___iob) /* An array of FILE */
161 #else /* __DECLSPEC_SUPPORTED */
163 __MINGW_IMPORT
FILE _iob
[]; /* An array of FILE imported from DLL. */
165 #endif /* __DECLSPEC_SUPPORTED */
167 #define stdin (&_iob[STDIN_FILENO])
168 #define stdout (&_iob[STDOUT_FILENO])
169 #define stderr (&_iob[STDERR_FILENO])
178 _CRTIMP
FILE* __cdecl
fopen (const char*, const char*);
179 _CRTIMP
FILE* __cdecl
freopen (const char*, const char*, FILE*);
180 _CRTIMP
int __cdecl
fflush (FILE*);
181 _CRTIMP
int __cdecl
fclose (FILE*);
182 /* MS puts remove & rename (but not wide versions) in io.h also */
183 _CRTIMP
int __cdecl
remove (const char*);
184 _CRTIMP
int __cdecl
rename (const char*, const char*);
185 _CRTIMP
FILE* __cdecl
tmpfile (void);
186 _CRTIMP
char* __cdecl
tmpnam (char*);
188 #ifndef __STRICT_ANSI__
189 _CRTIMP
char* __cdecl
_tempnam (const char*, const char*);
190 _CRTIMP
int __cdecl
_rmtmp(void);
193 _CRTIMP
char* __cdecl
tempnam (const char*, const char*);
194 _CRTIMP
int __cdecl
rmtmp(void);
196 #endif /* __STRICT_ANSI__ */
198 _CRTIMP
int __cdecl
setvbuf (FILE*, char*, int, size_t);
200 _CRTIMP
void __cdecl
setbuf (FILE*, char*);
206 _CRTIMP
int __cdecl
fprintf (FILE*, const char*, ...);
207 _CRTIMP
int __cdecl
printf (const char*, ...);
208 _CRTIMP
int __cdecl
sprintf (char*, const char*, ...);
209 _CRTIMP
int __cdecl
_snprintf (char*, size_t, const char*, ...);
210 _CRTIMP
int __cdecl
vfprintf (FILE*, const char*, __VALIST
);
211 _CRTIMP
int __cdecl
vprintf (const char*, __VALIST
);
212 _CRTIMP
int __cdecl
vsprintf (char*, const char*, __VALIST
);
213 _CRTIMP
int __cdecl
_vsnprintf (char*, size_t, const char*, __VALIST
);
215 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
216 int __cdecl
snprintf(char* s
, size_t n
, const char* format
, ...);
217 __CRT_INLINE
int __cdecl
218 vsnprintf (char* s
, size_t n
, const char* format
, __VALIST arg
)
219 { return _vsnprintf ( s
, n
, format
, arg
); }
220 int __cdecl
vscanf (const char * __restrict__
, __VALIST
);
221 int __cdecl
vfscanf (FILE * __restrict__
, const char * __restrict__
,
223 int __cdecl
vsscanf (const char * __restrict__
,
224 const char * __restrict__
, __VALIST
);
231 _CRTIMP
int __cdecl
fscanf (FILE*, const char*, ...);
232 _CRTIMP
int __cdecl
scanf (const char*, ...);
233 _CRTIMP
int __cdecl
sscanf (const char*, const char*, ...);
235 * Character Input and Output Functions
238 _CRTIMP
int __cdecl
fgetc (FILE*);
239 _CRTIMP
char* __cdecl
fgets (char*, int, FILE*);
240 _CRTIMP
int __cdecl
fputc (int, FILE*);
241 _CRTIMP
int __cdecl
fputs (const char*, FILE*);
242 _CRTIMP
char* __cdecl
gets (char*);
243 _CRTIMP
int __cdecl
puts (const char*);
244 _CRTIMP
int __cdecl
ungetc (int, FILE*);
246 /* Traditionally, getc and putc are defined as macros. but the
247 standard doesn't say that they must be macros.
248 We use inline functions here to allow the fast versions
249 to be used in C++ with namespace qualification, eg., ::getc.
251 _filbuf and _flsbuf are not thread-safe. */
252 _CRTIMP
int __cdecl
_filbuf (FILE*);
253 _CRTIMP
int __cdecl
_flsbuf (int, FILE*);
257 __CRT_INLINE
int __cdecl
getc (FILE* __F
)
259 return (--__F
->_cnt
>= 0)
260 ? (int) (unsigned char) *__F
->_ptr
++
264 __CRT_INLINE
int __cdecl
putc (int __c
, FILE* __F
)
266 return (--__F
->_cnt
>= 0)
267 ? (int) (unsigned char) (*__F
->_ptr
++ = (char)__c
)
268 : _flsbuf (__c
, __F
);
271 __CRT_INLINE
int __cdecl
getchar (void)
273 return (--stdin
->_cnt
>= 0)
274 ? (int) (unsigned char) *stdin
->_ptr
++
278 __CRT_INLINE
int __cdecl
putchar(int __c
)
280 return (--stdout
->_cnt
>= 0)
281 ? (int) (unsigned char) (*stdout
->_ptr
++ = (char)__c
)
282 : _flsbuf (__c
, stdout
);}
284 #else /* Use library functions. */
286 _CRTIMP
int __cdecl
getc (FILE*);
287 _CRTIMP
int __cdecl
putc (int, FILE*);
288 _CRTIMP
int __cdecl
getchar (void);
289 _CRTIMP
int __cdecl
putchar (int);
294 * Direct Input and Output Functions
297 _CRTIMP
size_t __cdecl
fread (void*, size_t, size_t, FILE*);
298 _CRTIMP
size_t __cdecl
fwrite (const void*, size_t, size_t, FILE*);
301 * File Positioning Functions
304 _CRTIMP
int __cdecl
fseek (FILE*, long, int);
305 _CRTIMP
long __cdecl
ftell (FILE*);
306 _CRTIMP
void __cdecl
rewind (FILE*);
308 #ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */
310 * Workaround for limitations on win9x where a file contents are
311 * not zero'd out if you seek past the end and then write.
314 int __cdecl
__mingw_fseek (FILE *, long, int);
315 size_t __cdecl
__mingw_fwrite (const void*, size_t, size_t, FILE*);
316 #define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence)
317 #define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp)
318 #endif /* __USE_MINGW_FSEEK */
321 * An opaque data type used for storing file positions... The contents of
322 * this type are unknown, but we (the compiler) need to know the size
323 * because the programmer using fgetpos and fsetpos will be setting aside
324 * storage for fpos_t structres. Actually I tested using a byte array and
325 * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL).
326 * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in
327 * MSVCRT however, and for now `long long' will do.
330 typedef long long fpos_t;
335 _CRTIMP
int __cdecl
fgetpos (FILE*, fpos_t*);
336 _CRTIMP
int __cdecl
fsetpos (FILE*, const fpos_t*);
342 _CRTIMP
int __cdecl
feof (FILE*);
343 _CRTIMP
int __cdecl
ferror (FILE*);
346 inline int __cdecl
feof (FILE* __F
)
347 { return __F
->_flag
& _IOEOF
; }
348 inline int __cdecl
ferror (FILE* __F
)
349 { return __F
->_flag
& _IOERR
; }
351 #define feof(__F) ((__F)->_flag & _IOEOF)
352 #define ferror(__F) ((__F)->_flag & _IOERR)
355 _CRTIMP
void __cdecl
clearerr (FILE*);
356 _CRTIMP
void __cdecl
perror (const char*);
359 #ifndef __STRICT_ANSI__
363 _CRTIMP
FILE* __cdecl
_popen (const char*, const char*);
364 _CRTIMP
int __cdecl
_pclose (FILE*);
367 _CRTIMP
FILE* __cdecl
popen (const char*, const char*);
368 _CRTIMP
int __cdecl
pclose (FILE*);
372 * Other Non ANSI functions
374 _CRTIMP
int __cdecl
_flushall (void);
375 _CRTIMP
int __cdecl
_fgetchar (void);
376 _CRTIMP
int __cdecl
_fputchar (int);
377 _CRTIMP
FILE* __cdecl
_fdopen (int, const char*);
378 _CRTIMP
int __cdecl
_fileno (FILE*);
379 _CRTIMP
int __cdecl
_fcloseall(void);
380 _CRTIMP
FILE* __cdecl
_fsopen(const char*, const char*, int);
382 _CRTIMP
int __cdecl
_getmaxstdio(void);
383 _CRTIMP
int __cdecl
_setmaxstdio(int);
387 _CRTIMP
int __cdecl
fgetchar (void);
388 _CRTIMP
int __cdecl
fputchar (int);
389 _CRTIMP
FILE* __cdecl
fdopen (int, const char*);
390 _CRTIMP
int __cdecl
fileno (FILE*);
391 #endif /* Not _NO_OLDNAMES */
393 #define _fileno(__F) ((__F)->_file)
395 #define fileno(__F) ((__F)->_file)
398 #if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
399 #include <sys/types.h>
400 __CRT_INLINE
FILE* __cdecl
fopen64 (const char* filename
, const char* mode
)
402 return fopen (filename
, mode
);
405 int __cdecl
fseeko64 (FILE*, off64_t
, int);
407 #ifdef __USE_MINGW_FSEEK
408 int __cdecl
__mingw_fseeko64 (FILE *, off64_t
, int);
409 #define fseeko64(fp, offset, whence) __mingw_fseeko64(fp, offset, whence)
412 __CRT_INLINE off64_t __cdecl
ftello64 (FILE * stream
)
415 if (fgetpos(stream
, &pos
))
418 return ((off64_t
) pos
);
420 #endif /* __NO_MINGW_LFS */
422 #endif /* Not __STRICT_ANSI__ */
426 #ifndef _WSTDIO_DEFINED
427 /* also in wchar.h - keep in sync */
428 _CRTIMP
int __cdecl
fwprintf (FILE*, const wchar_t*, ...);
429 _CRTIMP
int __cdecl
wprintf (const wchar_t*, ...);
430 _CRTIMP
int __cdecl
swprintf (wchar_t*, const wchar_t*, ...);
431 _CRTIMP
int __cdecl
_snwprintf (wchar_t*, size_t, const wchar_t*, ...);
432 _CRTIMP
int __cdecl
vfwprintf (FILE*, const wchar_t*, __VALIST
);
433 _CRTIMP
int __cdecl
vwprintf (const wchar_t*, __VALIST
);
434 _CRTIMP
int __cdecl
vswprintf (wchar_t*, const wchar_t*, __VALIST
);
435 _CRTIMP
int __cdecl
_vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST
);
436 _CRTIMP
int __cdecl
fwscanf (FILE*, const wchar_t*, ...);
437 _CRTIMP
int __cdecl
wscanf (const wchar_t*, ...);
438 _CRTIMP
int __cdecl
swscanf (const wchar_t*, const wchar_t*, ...);
439 _CRTIMP
wint_t __cdecl
fgetwc (FILE*);
440 _CRTIMP
wint_t __cdecl
fputwc (wchar_t, FILE*);
441 _CRTIMP
wint_t __cdecl
ungetwc (wchar_t, FILE*);
444 _CRTIMP
wchar_t* __cdecl
fgetws (wchar_t*, int, FILE*);
445 _CRTIMP
int __cdecl
fputws (const wchar_t*, FILE*);
446 _CRTIMP
wint_t __cdecl
getwc (FILE*);
447 _CRTIMP
wint_t __cdecl
getwchar (void);
448 _CRTIMP
wchar_t* __cdecl
_getws (wchar_t*);
449 _CRTIMP
wint_t __cdecl
putwc (wint_t, FILE*);
450 _CRTIMP
int __cdecl
_putws (const wchar_t*);
451 _CRTIMP
wint_t __cdecl
putwchar (wint_t);
452 _CRTIMP
FILE* __cdecl
_wfdopen(int, wchar_t *);
453 _CRTIMP
FILE* __cdecl
_wfopen (const wchar_t*, const wchar_t*);
454 _CRTIMP
FILE* __cdecl
_wfreopen (const wchar_t*, const wchar_t*, FILE*);
455 _CRTIMP
FILE* __cdecl
_wfsopen (const wchar_t*, const wchar_t*, int);
456 _CRTIMP
wchar_t* __cdecl
_wtmpnam (wchar_t*);
457 _CRTIMP
wchar_t* __cdecl
_wtempnam (const wchar_t*, const wchar_t*);
458 _CRTIMP
int __cdecl
_wrename (const wchar_t*, const wchar_t*);
459 _CRTIMP
int __cdecl
_wremove (const wchar_t*);
460 _CRTIMP
void __cdecl
_wperror (const wchar_t*);
461 _CRTIMP
FILE* __cdecl
_wpopen (const wchar_t*, const wchar_t*);
462 #endif /* __MSVCRT__ */
464 #ifndef __NO_ISOCEXT /* externs in libmingwex.a */
465 int __cdecl
snwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, ...);
466 __CRT_INLINE
int __cdecl
467 vsnwprintf (wchar_t* s
, size_t n
, const wchar_t* format
, __VALIST arg
)
468 { return _vsnwprintf ( s
, n
, format
, arg
);}
469 int __cdecl
vwscanf (const wchar_t * __restrict__
, __VALIST
);
470 int __cdecl
vfwscanf (FILE * __restrict__
,
471 const wchar_t * __restrict__
, __VALIST
);
472 int __cdecl
vswscanf (const wchar_t * __restrict__
,
473 const wchar_t * __restrict__
, __VALIST
);
476 #define _WSTDIO_DEFINED
477 #endif /* _WSTDIO_DEFINED */
479 #ifndef __STRICT_ANSI__
482 _CRTIMP
FILE* __cdecl
wpopen (const wchar_t*, const wchar_t*);
483 #endif /* not NO_OLDNAMES */
484 #endif /* MSVCRT runtime */
487 * Other Non ANSI wide functions
489 _CRTIMP
wint_t __cdecl
_fgetwchar (void);
490 _CRTIMP
wint_t __cdecl
_fputwchar (wint_t);
491 _CRTIMP
int __cdecl
_getw (FILE*);
492 _CRTIMP
int __cdecl
_putw (int, FILE*);
495 _CRTIMP
wint_t __cdecl
fgetwchar (void);
496 _CRTIMP
wint_t __cdecl
fputwchar (wint_t);
497 _CRTIMP
int __cdecl
getw (FILE*);
498 _CRTIMP
int __cdecl
putw (int, FILE*);
499 #endif /* Not _NO_OLDNAMES */
501 #endif /* __STRICT_ANSI */
507 #endif /* Not RC_INVOKED */
509 #endif /* _STDIO_H_ */