OSDN Git Service

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