OSDN Git Service

Redo the filters based on assumptions discussed in mingw-dvlpr list.
[mingw/mingw-org-wsl.git] / include / stdio.h
1 /**
2  * @file stdio.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 #ifndef _STDIO_H
25 #define _STDIO_H
26 #pragma GCC system_header
27
28 /* All the headers include this file. */
29 #include <_mingw.h>
30
31 #ifndef RC_INVOKED
32 #define __need_size_t
33 #define __need_NULL
34 #define __need_wchar_t
35 #define __need_wint_t
36 #include <stddef.h>
37 #define __need___va_list
38 #include <stdarg.h>
39 #endif  /* Not RC_INVOKED */
40
41
42 /* Flags for the iobuf structure  */
43 #define _IOREAD 1 /* currently reading */
44 #define _IOWRT  2 /* currently writing */
45 #define _IORW   0x0080 /* opened as "r+w" */
46
47
48 /*
49  * The three standard file pointers provided by the run time library.
50  * NOTE: These will go to the bit-bucket silently in GUI applications!
51  */
52 #define STDIN_FILENO    0
53 #define STDOUT_FILENO   1
54 #define STDERR_FILENO   2
55
56 /* Returned by various functions on end of file condition or error. */
57 #define EOF     (-1)
58
59 /*
60  * The maximum length of a file name. You should use GetVolumeInformation
61  * instead of this constant. But hey, this works.
62  * Also defined in io.h.
63  */
64 #ifndef FILENAME_MAX
65 #define FILENAME_MAX    (260)
66 #endif
67
68 /*
69  * The maximum number of files that may be open at once. I have set this to
70  * a conservative number. The actual value may be higher.
71  */
72 #define FOPEN_MAX       (20)
73
74 /* After creating this many names, tmpnam and tmpfile return NULL */
75 #define TMP_MAX 32767
76 /*
77  * Tmpnam, tmpfile and, sometimes, _tempnam try to create
78  * temp files in the root directory of the current drive
79  * (not in pwd, as suggested by some older MS doc's).
80  * Redefining these macros does not effect the CRT functions.
81  */
82 #define _P_tmpdir   "\\"
83 #ifndef __STRICT_ANSI__
84 #define P_tmpdir _P_tmpdir
85 #endif
86 #define _wP_tmpdir  L"\\"
87
88 /*
89  * The maximum size of name (including NUL) that will be put in the user
90  * supplied buffer caName for tmpnam.
91  * Inferred from the size of the static buffer returned by tmpnam
92  * when passed a NULL argument. May actually be smaller.
93  */
94 #define L_tmpnam (16)
95
96 #define _IOFBF    0x0000  /* full buffered */
97 #define _IOLBF    0x0040  /* line buffered */
98 #define _IONBF    0x0004  /* not buffered */
99
100 #define _IOMYBUF  0x0008  /* stdio malloc()'d buffer */
101 #define _IOEOF    0x0010  /* EOF reached on read */
102 #define _IOERR    0x0020  /* I/O error from system */
103 #define _IOSTRG   0x0040  /* Strange or no file descriptor */
104 #ifdef _POSIX_SOURCE
105 # define _IOAPPEND 0x0200
106 #endif
107 /*
108  * The buffer size as used by setbuf such that it is equivalent to
109  * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ).
110  */
111 #define BUFSIZ  512
112
113 /* Constants for nOrigin indicating the position relative to which fseek
114  * sets the file position.  Defined unconditionally since ISO and POSIX
115  * say they are defined here.  */
116 #define SEEK_SET 0
117 #define SEEK_CUR 1
118 #define SEEK_END 2
119
120 #ifndef RC_INVOKED
121
122 #ifndef __VALIST
123 #ifdef __GNUC__
124 #define __VALIST __gnuc_va_list
125 #else
126 #define __VALIST char*
127 #endif
128 #endif /* defined __VALIST  */
129
130 /*
131  * The structure underlying the FILE type.
132  *
133  * Some believe that nobody in their right mind should make use of the
134  * internals of this structure. Provided by Pedro A. Aranda Gutiirrez
135  * <paag@tid.es>.
136  */
137 #ifndef _FILE_DEFINED
138 #define _FILE_DEFINED
139 typedef struct _iobuf
140 {
141         char*   _ptr;
142         int     _cnt;
143         char*   _base;
144         int     _flag;
145         int     _file;
146         int     _charbuf;
147         int     _bufsiz;
148         char*   _tmpfname;
149 } FILE;
150 #endif  /* Not _FILE_DEFINED */
151
152
153 /*
154  * The standard file handles
155  */
156 __MINGW_IMPORT FILE _iob[];     /* An array of FILE imported from DLL. */
157
158 #define stdin   (&_iob[STDIN_FILENO])
159 #define stdout  (&_iob[STDOUT_FILENO])
160 #define stderr  (&_iob[STDERR_FILENO])
161
162 #ifdef __cplusplus
163 extern "C" {
164 #endif
165
166 /*
167  * File Operations
168  */
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*);
178
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*);
183
184 #ifndef NO_OLDNAMES
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*);
188 #endif
189 #endif /* __STRICT_ANSI__ */
190
191 _CRTIMP int __cdecl __MINGW_NOTHROW     setvbuf (FILE*, char*, int, size_t);
192
193 _CRTIMP void __cdecl __MINGW_NOTHROW    setbuf (FILE*, char*);
194
195 /*
196  * Formatted Output
197  *
198  * MSVCRT implementations are not ANSI C99 conformant...
199  * we offer these conforming alternatives from libmingwex.a
200  */
201 #undef  __mingw_stdio_redirect__
202 #define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __mingw_##F
203
204 extern int __mingw_stdio_redirect__(fprintf)(FILE*, const char*, ...);
205 extern int __mingw_stdio_redirect__(printf)(const char*, ...);
206 extern int __mingw_stdio_redirect__(sprintf)(char*, const char*, ...);
207 extern int __mingw_stdio_redirect__(snprintf)(char*, size_t, const char*, ...);
208 extern int __mingw_stdio_redirect__(vfprintf)(FILE*, const char*, __VALIST);
209 extern int __mingw_stdio_redirect__(vprintf)(const char*, __VALIST);
210 extern int __mingw_stdio_redirect__(vsprintf)(char*, const char*, __VALIST);
211 extern int __mingw_stdio_redirect__(vsnprintf)(char*, size_t, const char*, __VALIST);
212
213 #if __USE_MINGW_ANSI_STDIO
214 /*
215  * User has expressed a preference for C99 conformance...
216  */
217 # undef __mingw_stdio_redirect__
218 # ifdef __cplusplus
219 /*
220  * For C++ we use inline implementations, to avoid interference
221  * with namespace qualification, which may result from using #defines.
222  */
223 #  define __mingw_stdio_redirect__  inline __cdecl __MINGW_NOTHROW
224
225 # elif defined __GNUC__
226 /*
227  * FIXME: Is there any GCC version prerequisite here?
228  *
229  * We also prefer inline implementations for C, when we can be confident
230  * that the GNU specific __inline__ mechanism is supported.
231  */
232 #  define __mingw_stdio_redirect__  static __inline__ __cdecl __MINGW_NOTHROW
233
234 # else
235 /*
236  * Can't use inlines; fall back on module local static stubs.
237  */
238 #  define __mingw_stdio_redirect__  static __cdecl __MINGW_NOTHROW
239 # endif
240
241 __mingw_stdio_redirect__
242 int fprintf (FILE *__stream, const char *__format, ...)
243 {
244   register int __retval;
245   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
246   __retval = __mingw_vfprintf( __stream, __format, __local_argv );
247   __builtin_va_end( __local_argv );
248   return __retval;
249 }
250
251 __mingw_stdio_redirect__
252 int printf (const char *__format, ...)
253 {
254   register int __retval;
255   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
256   __retval = __mingw_vprintf( __format, __local_argv );
257   __builtin_va_end( __local_argv );
258   return __retval;
259 }
260
261 __mingw_stdio_redirect__
262 int sprintf (char *__stream, const char *__format, ...)
263 {
264   register int __retval;
265   __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
266   __retval = __mingw_vsprintf( __stream, __format, __local_argv );
267   __builtin_va_end( __local_argv );
268   return __retval;
269 }
270
271 __mingw_stdio_redirect__
272 int vfprintf (FILE *__stream, const char *__format, __VALIST __local_argv)
273 {
274   return __mingw_vfprintf( __stream, __format, __local_argv );
275 }
276
277 __mingw_stdio_redirect__
278 int vprintf (const char *__format, __VALIST __local_argv)
279 {
280   return __mingw_vprintf( __format, __local_argv );
281 }
282
283 __mingw_stdio_redirect__
284 int vsprintf (char *__stream, const char *__format, __VALIST __local_argv)
285 {
286   return __mingw_vsprintf( __stream, __format, __local_argv );
287 }
288
289 #else
290 /*
291  * Default configuration: simply direct all calls to MSVCRT...
292  */
293 _CRTIMP int __cdecl __MINGW_NOTHROW fprintf (FILE*, const char*, ...);
294 _CRTIMP int __cdecl __MINGW_NOTHROW printf (const char*, ...);
295 _CRTIMP int __cdecl __MINGW_NOTHROW sprintf (char*, const char*, ...);
296 _CRTIMP int __cdecl __MINGW_NOTHROW vfprintf (FILE*, const char*, __VALIST);
297 _CRTIMP int __cdecl __MINGW_NOTHROW vprintf (const char*, __VALIST);
298 _CRTIMP int __cdecl __MINGW_NOTHROW vsprintf (char*, const char*, __VALIST);
299
300 #endif
301 /*
302  * Regardless of user preference, always offer these alternative
303  * entry points, for direct access to the MSVCRT implementations.
304  */
305 #undef  __mingw_stdio_redirect__
306 #define __mingw_stdio_redirect__(F) __cdecl __MINGW_NOTHROW __msvcrt_##F
307
308 _CRTIMP int __mingw_stdio_redirect__(fprintf)(FILE*, const char*, ...);
309 _CRTIMP int __mingw_stdio_redirect__(printf)(const char*, ...);
310 _CRTIMP int __mingw_stdio_redirect__(sprintf)(char*, const char*, ...);
311 _CRTIMP int __mingw_stdio_redirect__(vfprintf)(FILE*, const char*, __VALIST);
312 _CRTIMP int __mingw_stdio_redirect__(vprintf)(const char*, __VALIST);
313 _CRTIMP int __mingw_stdio_redirect__(vsprintf)(char*, const char*, __VALIST);
314
315 #undef  __mingw_stdio_redirect__
316
317 /* The following pair ALWAYS refer to the MSVCRT implementations...
318  */
319 _CRTIMP int __cdecl __MINGW_NOTHROW _snprintf (char*, size_t, const char*, ...);
320 _CRTIMP int __cdecl __MINGW_NOTHROW _vsnprintf (char*, size_t, const char*, __VALIST);
321 _CRTIMP int __cdecl __MINGW_NOTHROW _vscprintf (const char*, __VALIST);
322
323 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
324 /*
325  * Microsoft does not provide implementations for the following,
326  * which are required by C99.  Note in particular that the corresponding
327  * Microsoft implementations of _snprintf() and _vsnprintf() are *not*
328  * compatible with C99, but the following are; if you want the MSVCRT
329  * behaviour, you *must* use the Microsoft uglified names.
330  */
331 int __cdecl __MINGW_NOTHROW snprintf (char *, size_t, const char *, ...);
332 int __cdecl __MINGW_NOTHROW vsnprintf (char *, size_t, const char *, __VALIST);
333
334 int __cdecl __MINGW_NOTHROW vscanf (const char * __restrict__, __VALIST);
335 int __cdecl __MINGW_NOTHROW vfscanf (FILE * __restrict__, const char * __restrict__,
336                      __VALIST);
337 int __cdecl __MINGW_NOTHROW vsscanf (const char * __restrict__,
338                      const char * __restrict__, __VALIST);
339
340 #endif  /* !__NO_ISOCEXT */
341
342 /*
343  * Formatted Input
344  */
345
346 _CRTIMP int __cdecl __MINGW_NOTHROW     fscanf (FILE*, const char*, ...);
347 _CRTIMP int __cdecl __MINGW_NOTHROW     scanf (const char*, ...);
348 _CRTIMP int __cdecl __MINGW_NOTHROW     sscanf (const char*, const char*, ...);
349 /*
350  * Character Input and Output Functions
351  */
352
353 _CRTIMP int __cdecl __MINGW_NOTHROW     fgetc (FILE*);
354 _CRTIMP char* __cdecl __MINGW_NOTHROW   fgets (char*, int, FILE*);
355 _CRTIMP int __cdecl __MINGW_NOTHROW     fputc (int, FILE*);
356 _CRTIMP int __cdecl __MINGW_NOTHROW     fputs (const char*, FILE*);
357 _CRTIMP char* __cdecl __MINGW_NOTHROW   gets (char*);
358 _CRTIMP int __cdecl __MINGW_NOTHROW     puts (const char*);
359 _CRTIMP int __cdecl __MINGW_NOTHROW     ungetc (int, FILE*);
360
361 /* Traditionally, getc and putc are defined as macros. but the
362    standard doesn't say that they must be macros.
363    We use inline functions here to allow the fast versions
364    to be used in C++ with namespace qualification, eg., ::getc.
365
366    _filbuf and _flsbuf  are not thread-safe. */
367 _CRTIMP int __cdecl __MINGW_NOTHROW     _filbuf (FILE*);
368 _CRTIMP int __cdecl __MINGW_NOTHROW     _flsbuf (int, FILE*);
369
370 #if !defined _MT
371
372 __CRT_INLINE int __cdecl __MINGW_NOTHROW getc (FILE*);
373 __CRT_INLINE int __cdecl __MINGW_NOTHROW getc (FILE* __F)
374 {
375   return (--__F->_cnt >= 0)
376     ?  (int) (unsigned char) *__F->_ptr++
377     : _filbuf (__F);
378 }
379
380 __CRT_INLINE int __cdecl __MINGW_NOTHROW putc (int, FILE*);
381 __CRT_INLINE int __cdecl __MINGW_NOTHROW putc (int __c, FILE* __F)
382 {
383   return (--__F->_cnt >= 0)
384     ?  (int) (unsigned char) (*__F->_ptr++ = (char)__c)
385     :  _flsbuf (__c, __F);
386 }
387
388 __CRT_INLINE int __cdecl __MINGW_NOTHROW getchar (void);
389 __CRT_INLINE int __cdecl __MINGW_NOTHROW getchar (void)
390 {
391   return (--stdin->_cnt >= 0)
392     ?  (int) (unsigned char) *stdin->_ptr++
393     : _filbuf (stdin);
394 }
395
396 __CRT_INLINE int __cdecl __MINGW_NOTHROW putchar(int);
397 __CRT_INLINE int __cdecl __MINGW_NOTHROW putchar(int __c)
398 {
399   return (--stdout->_cnt >= 0)
400     ?  (int) (unsigned char) (*stdout->_ptr++ = (char)__c)
401     :  _flsbuf (__c, stdout);}
402
403 #else  /* Use library functions.  */
404
405 _CRTIMP int __cdecl __MINGW_NOTHROW     getc (FILE*);
406 _CRTIMP int __cdecl __MINGW_NOTHROW     putc (int, FILE*);
407 _CRTIMP int __cdecl __MINGW_NOTHROW     getchar (void);
408 _CRTIMP int __cdecl __MINGW_NOTHROW     putchar (int);
409
410 #endif
411
412 /*
413  * Direct Input and Output Functions
414  */
415
416 _CRTIMP size_t __cdecl __MINGW_NOTHROW  fread (void*, size_t, size_t, FILE*);
417 _CRTIMP size_t __cdecl __MINGW_NOTHROW  fwrite (const void*, size_t, size_t, FILE*);
418
419 /*
420  * File Positioning Functions
421  */
422
423 _CRTIMP int __cdecl __MINGW_NOTHROW     fseek (FILE*, long, int);
424 _CRTIMP long __cdecl __MINGW_NOTHROW    ftell (FILE*);
425 _CRTIMP void __cdecl __MINGW_NOTHROW    rewind (FILE*);
426
427 #if __MSVCRT_VERSION__ >= 0x800
428 _CRTIMP int __cdecl __MINGW_NOTHROW     _fseek_nolock (FILE*, long, int);
429 _CRTIMP long __cdecl __MINGW_NOTHROW    _ftell_nolock (FILE*);
430
431 _CRTIMP int __cdecl __MINGW_NOTHROW     _fseeki64 (FILE*, __int64, int);
432 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _ftelli64 (FILE*);
433 _CRTIMP int __cdecl __MINGW_NOTHROW     _fseeki64_nolock (FILE*, __int64, int);
434 _CRTIMP __int64 __cdecl __MINGW_NOTHROW _ftelli64_nolock (FILE*);
435 #endif
436
437 #ifdef __USE_MINGW_FSEEK  /* These are in libmingwex.a */
438 /*
439  * Workaround for limitations on win9x where a file contents are
440  * not zero'd out if you seek past the end and then write.
441  */
442
443 int __cdecl __MINGW_NOTHROW __mingw_fseek (FILE *, long, int);
444 size_t __cdecl __MINGW_NOTHROW __mingw_fwrite (const void*, size_t, size_t, FILE*);
445 #define fseek(fp, offset, whence)  __mingw_fseek(fp, offset, whence)
446 #define fwrite(buffer, size, count, fp)  __mingw_fwrite(buffer, size, count, fp)
447 #endif /* __USE_MINGW_FSEEK */
448
449 /*
450  * An opaque data type used for storing file positions... The contents of
451  * this type are unknown, but we (the compiler) need to know the size
452  * because the programmer using fgetpos and fsetpos will be setting aside
453  * storage for fpos_t structres. Actually I tested using a byte array and
454  * it is fairly evident that the fpos_t it's a 64-bit number in
455  * MSVCRT however, and for now `long long' will do.
456  */
457 typedef long long fpos_t;
458
459 _CRTIMP int __cdecl __MINGW_NOTHROW     fgetpos (FILE*, fpos_t*);
460 _CRTIMP int __cdecl __MINGW_NOTHROW     fsetpos (FILE*, const fpos_t*);
461
462 /*
463  * Error Functions
464  */
465
466 _CRTIMP int __cdecl __MINGW_NOTHROW     feof (FILE*);
467 _CRTIMP int __cdecl __MINGW_NOTHROW     ferror (FILE*);
468
469 #ifdef __cplusplus
470 inline int __cdecl __MINGW_NOTHROW feof (FILE* __F)
471   { return __F->_flag & _IOEOF; }
472 inline int __cdecl __MINGW_NOTHROW ferror (FILE* __F)
473   { return __F->_flag & _IOERR; }
474 #else
475 #define feof(__F)     ((__F)->_flag & _IOEOF)
476 #define ferror(__F)   ((__F)->_flag & _IOERR)
477 #endif
478
479 _CRTIMP void __cdecl __MINGW_NOTHROW    clearerr (FILE*);
480 _CRTIMP void __cdecl __MINGW_NOTHROW    perror (const char*);
481
482
483 #ifndef __STRICT_ANSI__
484 /*
485  * Pipes
486  */
487 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _popen (const char*, const char*);
488 _CRTIMP int __cdecl __MINGW_NOTHROW     _pclose (FILE*);
489
490 #ifndef NO_OLDNAMES
491 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   popen (const char*, const char*);
492 _CRTIMP int __cdecl __MINGW_NOTHROW     pclose (FILE*);
493 #endif
494
495 /*
496  * Other Non ANSI functions
497  */
498 _CRTIMP int __cdecl __MINGW_NOTHROW     _flushall (void);
499 _CRTIMP int __cdecl __MINGW_NOTHROW     _fgetchar (void);
500 _CRTIMP int __cdecl __MINGW_NOTHROW     _fputchar (int);
501 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _fdopen (int, const char*);
502 _CRTIMP int __cdecl __MINGW_NOTHROW     _fileno (FILE*);
503 _CRTIMP int __cdecl __MINGW_NOTHROW     _fcloseall (void);
504 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _fsopen (const char*, const char*, int);
505 _CRTIMP int __cdecl __MINGW_NOTHROW     _getmaxstdio (void);
506 _CRTIMP int __cdecl __MINGW_NOTHROW     _setmaxstdio (int);
507
508 #if __MSVCRT_VERSION__ >= 0x800
509 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _get_output_format (void);
510 _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _set_output_format (unsigned int);
511
512 #define _TWO_DIGIT_EXPONENT  1
513
514 _CRTIMP int __cdecl __MINGW_NOTHROW _get_printf_count_output (void);
515 _CRTIMP int __cdecl __MINGW_NOTHROW _set_printf_count_output (int);
516 #endif
517
518 #ifndef _NO_OLDNAMES
519 _CRTIMP int __cdecl __MINGW_NOTHROW     fgetchar (void);
520 _CRTIMP int __cdecl __MINGW_NOTHROW     fputchar (int);
521 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   fdopen (int, const char*);
522 _CRTIMP int __cdecl __MINGW_NOTHROW     fileno (FILE*);
523 #endif  /* Not _NO_OLDNAMES */
524
525 #define _fileno(__F) ((__F)->_file)
526 #ifndef _NO_OLDNAMES
527 #define fileno(__F) ((__F)->_file)
528 #endif
529
530 #if !defined (__NO_MINGW_LFS)
531 #include <sys/types.h>
532 __CRT_INLINE FILE* __cdecl __MINGW_NOTHROW fopen64 (const char*, const char*);
533 __CRT_INLINE FILE* __cdecl __MINGW_NOTHROW fopen64 (const char* filename, const char* mode)
534 {
535   return fopen (filename, mode); 
536 }
537
538 int __cdecl __MINGW_NOTHROW fseeko64 (FILE*, off64_t, int);
539
540 #ifdef __USE_MINGW_FSEEK
541 int __cdecl __MINGW_NOTHROW __mingw_fseeko64 (FILE *, off64_t, int);
542 #define fseeko64(fp, offset, whence)  __mingw_fseeko64(fp, offset, whence)
543 #endif /* __USER_MINGW_FSEEK */
544
545 __CRT_INLINE off64_t __cdecl __MINGW_NOTHROW ftello64 (FILE *);
546 __CRT_INLINE off64_t __cdecl __MINGW_NOTHROW ftello64 (FILE * stream)
547 {
548   fpos_t pos;
549   if (fgetpos(stream, &pos))
550     return  -1LL;
551   else
552    return ((off64_t) pos);
553 }
554 #endif /* __NO_MINGW_LFS */
555
556 #endif  /* Not __STRICT_ANSI__ */
557
558 /* Wide  versions */
559
560 #ifndef _WSTDIO_DEFINED
561 /*  also in wchar.h - keep in sync */
562 _CRTIMP int __cdecl __MINGW_NOTHROW     fwprintf (FILE*, const wchar_t*, ...);
563 _CRTIMP int __cdecl __MINGW_NOTHROW     wprintf (const wchar_t*, ...);
564 _CRTIMP int __cdecl __MINGW_NOTHROW     _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
565 _CRTIMP int __cdecl __MINGW_NOTHROW     vfwprintf (FILE*, const wchar_t*, __VALIST);
566 _CRTIMP int __cdecl __MINGW_NOTHROW     vwprintf (const wchar_t*, __VALIST);
567 _CRTIMP int __cdecl __MINGW_NOTHROW     _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
568 _CRTIMP int __cdecl __MINGW_NOTHROW     _vscwprintf (const wchar_t*, __VALIST);
569 _CRTIMP int __cdecl __MINGW_NOTHROW     fwscanf (FILE*, const wchar_t*, ...);
570 _CRTIMP int __cdecl __MINGW_NOTHROW     wscanf (const wchar_t*, ...);
571 _CRTIMP int __cdecl __MINGW_NOTHROW     swscanf (const wchar_t*, const wchar_t*, ...);
572 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  fgetwc (FILE*);
573 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  fputwc (wchar_t, FILE*);
574 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  ungetwc (wchar_t, FILE*);
575
576 /* These differ from the ISO C prototypes, which have a maxlen parameter (like snprintf).  */
577 #ifndef __STRICT_ANSI__
578 _CRTIMP int __cdecl __MINGW_NOTHROW     swprintf (wchar_t*, const wchar_t*, ...);
579 _CRTIMP int __cdecl __MINGW_NOTHROW     vswprintf (wchar_t*, const wchar_t*, __VALIST);
580 #endif
581
582 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW fgetws (wchar_t*, int, FILE*);
583 _CRTIMP int __cdecl __MINGW_NOTHROW     fputws (const wchar_t*, FILE*);
584 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  getwc (FILE*);
585 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  getwchar (void);
586 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  putwc (wint_t, FILE*);
587 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  putwchar (wint_t);
588 #ifndef __STRICT_ANSI__
589 _CRTIMP void __cdecl __MINGW_NOTHROW _lock_file(FILE*);
590 _CRTIMP void __cdecl __MINGW_NOTHROW _unlock_file(FILE*);
591 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _getws (wchar_t*);
592 _CRTIMP int __cdecl __MINGW_NOTHROW     _putws (const wchar_t*);
593 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _wfdopen(int, const wchar_t *);
594 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _wfopen (const wchar_t*, const wchar_t*);
595 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _wfreopen (const wchar_t*, const wchar_t*, FILE*);
596 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _wfsopen (const wchar_t*, const wchar_t*, int);
597 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wtmpnam (wchar_t*);
598 _CRTIMP wchar_t* __cdecl __MINGW_NOTHROW _wtempnam (const wchar_t*, const wchar_t*);
599 _CRTIMP int __cdecl __MINGW_NOTHROW     _wrename (const wchar_t*, const wchar_t*);
600 _CRTIMP int __cdecl __MINGW_NOTHROW     _wremove (const wchar_t*);
601 _CRTIMP void __cdecl __MINGW_NOTHROW    _wperror (const wchar_t*);
602 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   _wpopen (const wchar_t*, const wchar_t*);
603 #endif  /* __STRICT_ANSI__ */
604
605 #ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
606 int __cdecl __MINGW_NOTHROW snwprintf (wchar_t* s, size_t n, const wchar_t*  format, ...);
607 int __cdecl __MINGW_NOTHROW vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg);
608 #ifndef __NO_INLINE__
609 __CRT_INLINE int __cdecl __MINGW_NOTHROW
610 vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg)
611   { return _vsnwprintf ( s, n, format, arg);}
612 #endif
613 int __cdecl __MINGW_NOTHROW vwscanf (const wchar_t * __restrict__, __VALIST);
614 int __cdecl __MINGW_NOTHROW vfwscanf (FILE * __restrict__,
615                        const wchar_t * __restrict__, __VALIST);
616 int __cdecl __MINGW_NOTHROW vswscanf (const wchar_t * __restrict__,
617                        const wchar_t * __restrict__, __VALIST);
618 #endif
619
620 #define _WSTDIO_DEFINED
621 #endif /* _WSTDIO_DEFINED */
622
623 #ifndef __STRICT_ANSI__
624 #ifndef NO_OLDNAMES
625 _CRTIMP FILE* __cdecl __MINGW_NOTHROW   wpopen (const wchar_t*, const wchar_t*);
626 #endif /* not NO_OLDNAMES */
627
628 /*
629  * Other Non ANSI wide functions
630  */
631 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  _fgetwchar (void);
632 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  _fputwchar (wint_t);
633 _CRTIMP int __cdecl __MINGW_NOTHROW     _getw (FILE*);
634 _CRTIMP int __cdecl __MINGW_NOTHROW     _putw (int, FILE*);
635
636 #ifndef _NO_OLDNAMES
637 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  fgetwchar (void);
638 _CRTIMP wint_t __cdecl __MINGW_NOTHROW  fputwchar (wint_t);
639 _CRTIMP int __cdecl __MINGW_NOTHROW     getw (FILE*);
640 _CRTIMP int __cdecl __MINGW_NOTHROW     putw (int, FILE*);
641 #endif  /* Not _NO_OLDNAMES */
642
643 #endif /* __STRICT_ANSI */
644
645 #ifdef __cplusplus
646 }
647 #endif
648
649 #endif  /* Not RC_INVOKED */
650 #endif /* _STDIO_H */