| /* |
| * stdio.h |
| * This file has no copyright assigned and is placed in the Public Domain. |
| * This file is a part of the mingw-runtime package. |
| * No warranty is given; refer to the file DISCLAIMER within the package. |
| * |
| * Definitions of types and prototypes of functions for standard input and |
| * output. |
| * |
| */ |
| |
| #ifndef _STDIO_H_ |
| #define _STDIO_H_ |
| |
| /* All the headers include this file. */ |
| #include <_mingw.h> |
| |
| #ifndef RC_INVOKED |
| #define __need_size_t |
| #define __need_NULL |
| #define __need_wchar_t |
| #define __need_wint_t |
| #include <stddef.h> |
| #define __need___va_list |
| #include <stdarg.h> |
| #endif /* Not RC_INVOKED */ |
| |
| |
| /* Flags for the iobuf structure */ |
| #define _IOREAD 1 /* currently reading */ |
| #define _IOWRT 2 /* currently writing */ |
| #define _IORW 0x0080 /* opened as "r+w" */ |
| |
| #ifndef _UNISTD_H |
| /* |
| * The three standard file descriptors provided by the run time library. |
| * NOTE: These will go to the bit-bucket silently in GUI applications! |
| */ |
| #define STDIN_FILENO 0 |
| #define STDOUT_FILENO 1 |
| #define STDERR_FILENO 2 |
| #endif |
| |
| /* Returned by various functions on end of file condition or error. */ |
| #define EOF (-1) |
| |
| /* |
| * The maximum length of a file name. You should use GetVolumeInformation |
| * instead of this constant. But hey, this works. |
| * Also defined in io.h. |
| */ |
| #ifndef FILENAME_MAX |
| #define FILENAME_MAX (260) |
| #endif |
| |
| #define _IOFBF 0x0000 /* full buffered */ |
| #define _IOLBF 0x0040 /* line buffered */ |
| #define _IONBF 0x0004 /* not buffered */ |
| |
| #define _IOMYBUF 0x0008 /* stdio malloc()'d buffer */ |
| #define _IOEOF 0x0010 /* EOF reached on read */ |
| #define _IOERR 0x0020 /* I/O error from system */ |
| #define _IOSTRG 0x0040 /* Strange or no file descriptor */ |
| #ifdef _POSIX_SOURCE |
| # define _IOAPPEND 0x0200 |
| #endif |
| /* |
| * The buffer size as used by setbuf such that it is equivalent to |
| * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ). |
| */ |
| #define BUFSIZ 512 |
| |
| /* Constants for nOrigin indicating the position relative to which fseek |
| * sets the file position. Defined unconditionally since ISO and POSIX |
| * say they are defined here. */ |
| #define SEEK_SET 0 |
| #define SEEK_CUR 1 |
| #define SEEK_END 2 |
| |
| #ifndef RC_INVOKED |
| |
| #ifndef __VALIST |
| #ifdef __GNUC__ |
| #define __VALIST __gnuc_va_list |
| #else |
| #define __VALIST char* |
| #endif |
| #endif /* defined __VALIST */ |
| |
| /* |
| * The structure underlying the FILE type. |
| * |
| * Some believe that nobody in their right mind should make use of the |
| * internals of this structure. Provided by Pedro A. Aranda Gutiirrez |
| * <paag@tid.es>. |
| */ |
| #ifndef _FILE_DEFINED |
| #define _FILE_DEFINED |
| typedef struct _iobuf |
| { |
| char* _ptr; |
| int _cnt; |
| char* _base; |
| int _flag; |
| int _file; |
| int _charbuf; |
| int _bufsiz; |
| char* _tmpfname; |
| } FILE; |
| #endif /* Not _FILE_DEFINED */ |
| |
| __MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */ |
| |
| #define stdin (_iob) |
| #define stdout (_iob+1) |
| #define stderr (_iob+2) |
| |
| #ifdef __cplusplus |
| extern "C" { |
| #endif |
| |
| /* |
| * File Operations |
| */ |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW fopen (const char*, const char*); |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW freopen (const char*, const char*, FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fflush (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fclose (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*); |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW tmpfile (void); |
| _CRTIMP char* __cdecl __MINGW_NOTHROW tmpnam (char*); |
| _CRTIMP char* __cdecl __MINGW_NOTHROW tempnam (const char*, const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW rmtmp(void); |
| _CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW setvbuf (FILE*, char*, int, size_t); |
| _CRTIMP void __cdecl __MINGW_NOTHROW setbuf (FILE*, char*); |
| |
| /* |
| * Formatted Output |
| */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW fprintf (FILE*, const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW printf (const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW sprintf (char*, const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _snprintf (char*, size_t, const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW vfprintf (FILE*, const char*, __VALIST); |
| _CRTIMP int __cdecl __MINGW_NOTHROW vprintf (const char*, __VALIST); |
| _CRTIMP int __cdecl __MINGW_NOTHROW vsprintf (char*, const char*, __VALIST); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _vsnprintf (char*, size_t, const char*, __VALIST); |
| |
| /* |
| * Formatted Input |
| */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW fscanf (FILE*, const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW scanf (const char*, ...); |
| _CRTIMP int __cdecl __MINGW_NOTHROW sscanf (const char*, const char*, ...); |
| |
| /* |
| * Character Input and Output Functions |
| */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW fgetc (FILE*); |
| _CRTIMP char* __cdecl __MINGW_NOTHROW fgets (char*, int, FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fputc (int, FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fputs (const char*, FILE*); |
| _CRTIMP char* __cdecl __MINGW_NOTHROW gets (char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW puts (const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW ungetc (int, FILE*); |
| |
| /* Traditionally, getc and putc are defined as macros. but the |
| standard doesn't say that they must be macros. |
| We use inline functions here to allow the fast versions |
| to be used in C++ with namespace qualification, eg., ::getc. |
| |
| _filbuf and _flsbuf are not thread-safe. */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW _filbuf (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _flsbuf (int, FILE*); |
| |
| //#if !defined _MT |
| #if 0 |
| |
| __CRT_INLINE int __cdecl __MINGW_NOTHROW getc (FILE* __F) |
| { |
| return (--__F->_cnt >= 0) |
| ? (int) (unsigned char) *__F->_ptr++ |
| : _filbuf (__F); |
| } |
| |
| __CRT_INLINE int __cdecl __MINGW_NOTHROW putc (int __c, FILE* __F) |
| { |
| return (--__F->_cnt >= 0) |
| ? (int) (unsigned char) (*__F->_ptr++ = (char)__c) |
| : _flsbuf (__c, __F); |
| } |
| |
| __CRT_INLINE int __cdecl __MINGW_NOTHROW getchar (void) |
| { |
| return (--stdin->_cnt >= 0) |
| ? (int) (unsigned char) *stdin->_ptr++ |
| : _filbuf (stdin); |
| } |
| |
| __CRT_INLINE int __cdecl __MINGW_NOTHROW putchar(int __c) |
| { |
| return (--stdout->_cnt >= 0) |
| ? (int) (unsigned char) (*stdout->_ptr++ = (char)__c) |
| : _flsbuf (__c, stdout);} |
| |
| #else /* Use library functions. */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW getc (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW putc (int, FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW getchar (void); |
| _CRTIMP int __cdecl __MINGW_NOTHROW putchar (int); |
| |
| #endif |
| |
| /* |
| * Direct Input and Output Functions |
| */ |
| |
| _CRTIMP size_t __cdecl __MINGW_NOTHROW fread (void*, size_t, size_t, FILE*); |
| _CRTIMP size_t __cdecl __MINGW_NOTHROW fwrite (const void*, size_t, size_t, FILE*); |
| |
| /* |
| * File Positioning Functions |
| */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW fseek (FILE*, long, int); |
| _CRTIMP long __cdecl __MINGW_NOTHROW ftell (FILE*); |
| _CRTIMP void __cdecl __MINGW_NOTHROW rewind (FILE*); |
| |
| /* |
| * An opaque data type used for storing file positions... The contents of |
| * this type are unknown, but we (the compiler) need to know the size |
| * because the programmer using fgetpos and fsetpos will be setting aside |
| * storage for fpos_t structres. Actually I tested using a byte array and |
| * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL). |
| * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in |
| * MSVCRT however, and for now `long long' will do. |
| */ |
| #ifdef __MSVCRT__ |
| typedef long long fpos_t; |
| #else |
| typedef long fpos_t; |
| #endif |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW fgetpos (FILE*, fpos_t*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fsetpos (FILE*, const fpos_t*); |
| |
| /* |
| * Error Functions |
| */ |
| |
| _CRTIMP int __cdecl __MINGW_NOTHROW feof (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW ferror (FILE*); |
| |
| #ifdef __cplusplus |
| inline int __cdecl __MINGW_NOTHROW feof (FILE* __F) |
| { return __F->_flag & _IOEOF; } |
| inline int __cdecl __MINGW_NOTHROW ferror (FILE* __F) |
| { return __F->_flag & _IOERR; } |
| #else |
| #define feof(__F) ((__F)->_flag & _IOEOF) |
| #define ferror(__F) ((__F)->_flag & _IOERR) |
| #endif |
| |
| _CRTIMP void __cdecl __MINGW_NOTHROW clearerr (FILE*); |
| _CRTIMP void __cdecl __MINGW_NOTHROW perror (const char*); |
| |
| |
| #ifndef __STRICT_ANSI__ |
| /* |
| * Pipes |
| */ |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW _popen (const char*, const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _pclose (FILE*); |
| |
| #ifndef NO_OLDNAMES |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW popen (const char*, const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW pclose (FILE*); |
| #endif |
| |
| /* |
| * Other Non ANSI functions |
| */ |
| _CRTIMP int __cdecl __MINGW_NOTHROW _flushall (void); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _fgetchar (void); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _fputchar (int); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _fileno (FILE*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW _fcloseall(void); |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW _fsopen(const char*, const char*, int); |
| |
| _CRTIMP FILE* __cdecl __MINGW_NOTHROW fdopen (int, const char*); |
| _CRTIMP int __cdecl __MINGW_NOTHROW fileno (FILE*); |
| |
| //#define _fileno(__F) ((__F)->_file) |
| |
| #endif /* Not __STRICT_ANSI__ */ |
| |
| #ifdef __cplusplus |
| } |
| #endif |
| |
| #endif /* Not RC_INVOKED */ |
| |
| #endif /* _STDIO_H_ */ |