Sync to trunk (r44371)
[reactos.git] / reactos / include / crt / stdio.h
index 8e12777..8c4e5be 100644 (file)
-/*
- * 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.
- *
- * NOTE: The file manipulation functions provided by Microsoft seem to
- * work with either slash (/) or backslash (\) as the directory separator.
- *
+ * This file is part of the w64 mingw-runtime package.
+ * No warranty is given; refer to the file DISCLAIMER within this package.
  */
+#ifndef _INC_STDIO
+#define _INC_STDIO
 
-#ifndef _STDIO_H_
-#define        _STDIO_H_
+#include <crtdefs.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" */
 
+#pragma pack(push,_CRT_PACKING)
 
-/*
- * The three standard file pointers 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
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-/* Returned by various functions on end of file condition or error. */
-#define        EOF     (-1)
+#define BUFSIZ 512
+#define _NFILE _NSTREAM_
+#define _NSTREAM_ 512
+#define _IOB_ENTRIES 20
+#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)
+#ifndef _FILE_DEFINED
+  struct _iobuf {
+    char *_ptr;
+    int _cnt;
+    char *_base;
+    int _flag;
+    int _file;
+    int _charbuf;
+    int _bufsiz;
+    char *_tmpfname;
+  };
+  typedef struct _iobuf FILE;
+#define _FILE_DEFINED
 #endif
 
-/*
- * The maximum number of files that may be open at once. I have set this to
- * a conservative number. The actual value may be higher.
- */
-#define FOPEN_MAX      (20)
-
-/* After creating this many names, tmpnam and tmpfile return NULL */
-#define TMP_MAX        32767
-/*
- * Tmpnam, tmpfile and, sometimes, _tempnam try to create
- * temp files in the root directory of the current drive
- * (not in pwd, as suggested by some older MS doc's).
- * Redefining these macros does not effect the CRT functions.
- */
-#define _P_tmpdir   "\\"
-#ifndef __STRICT_ANSI__
-#define P_tmpdir _P_tmpdir
+#ifdef _POSIX_
+#define _P_tmpdir "/"
+#define _wP_tmpdir L"/"
+#else
+#define _P_tmpdir "\\"
+#define _wP_tmpdir L"\\"
 #endif
-#define _wP_tmpdir  L"\\"
 
-/*
- * The maximum size of name (including NUL) that will be put in the user
- * supplied buffer caName for tmpnam.
- * Inferred from the size of the static buffer returned by tmpnam
- * when passed a NULL argument. May actually be smaller.
- */
-#define L_tmpnam (16)
-
-#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
+#define L_tmpnam (sizeof(_P_tmpdir) + 12)
+
+#ifdef _POSIX_
+#define L_ctermid 9
+#define L_cuserid 32
+#endif
 
-/* 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
+#define SEEK_SET 0
 
-#ifndef        RC_INVOKED
+#define        STDIN_FILENO    0
+#define        STDOUT_FILENO   1
+#define        STDERR_FILENO   2
+
+#define FILENAME_MAX 260
+#define FOPEN_MAX 20
+#define _SYS_OPEN 20
+#define TMP_MAX 32767
 
-#ifndef __VALIST
-#ifdef __GNUC__
-#define __VALIST __gnuc_va_list
+#ifndef NULL
+#ifdef __cplusplus
+#define NULL 0
 #else
-#define __VALIST char*
+#define NULL ((void *)0)
+#endif
 #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 */
-
-
-/*
- * The standard file handles
- */
-#ifndef __DECLSPEC_SUPPORTED
-
-extern FILE (*_imp___iob)[];   /* A pointer to an array of FILE */
-
-#define _iob   (*_imp___iob)   /* An array of FILE */
-
-#else /* __DECLSPEC_SUPPORTED */
-
-__MINGW_IMPORT FILE _iob[];    /* An array of FILE imported from DLL. */
-
-#endif /* __DECLSPEC_SUPPORTED */
 
-#define stdin  (&_iob[STDIN_FILENO])
-#define stdout (&_iob[STDOUT_FILENO])
-#define stderr (&_iob[STDERR_FILENO])
+#ifndef _OFF_T_DEFINED
+#define _OFF_T_DEFINED
+#ifndef _OFF_T_
+#define _OFF_T_
+  typedef long _off_t;
+#if !defined(NO_OLDNAMES) || defined(_POSIX)
+  typedef long off_t;
+#endif
+#endif
+#endif
 
-#ifdef __cplusplus
-extern "C" {
+#ifndef _OFF64_T_DEFINED
+#define _OFF64_T_DEFINED
+  typedef long long _off64_t;
+#if !defined(NO_OLDNAMES) || defined(_POSIX)
+  typedef long long off64_t;
+#endif
 #endif
 
-/*
- * File Operations
- */
-_CRTIMP FILE* __cdecl fopen (const char*, const char*);
-_CRTIMP FILE* __cdecl  freopen (const char*, const char*, FILE*);
-_CRTIMP int __cdecl    fflush (FILE*);
-_CRTIMP int __cdecl    fclose (FILE*);
-/* MS puts remove & rename (but not wide versions) in io.h  also */
-_CRTIMP int __cdecl    remove (const char*);
-_CRTIMP int __cdecl    rename (const char*, const char*);
-_CRTIMP FILE* __cdecl  tmpfile (void);
-_CRTIMP char* __cdecl  tmpnam (char*);
-
-#ifndef __STRICT_ANSI__
-_CRTIMP char* __cdecl  _tempnam (const char*, const char*);
-_CRTIMP int __cdecl    _rmtmp(void);
-_CRTIMP int __cdecl    _unlink (const char*);
-
-#ifndef        NO_OLDNAMES
-_CRTIMP char* __cdecl  tempnam (const char*, const char*);
-_CRTIMP int __cdecl    rmtmp(void);
-_CRTIMP int __cdecl    unlink (const char*);
-#endif
-#endif /* __STRICT_ANSI__ */
-
-_CRTIMP int __cdecl    setvbuf (FILE*, char*, int, size_t);
-
-_CRTIMP void __cdecl   setbuf (FILE*, char*);
-
-/*
- * Formatted Output
- */
+#ifndef _STDIO_DEFINED
+  _CRTIMP FILE *__cdecl __iob_func(void);
+  _CRTDATA(extern FILE _iob[];)
+#ifdef _M_CEE_PURE
+#define _iob __iob_func()
+#endif
+#endif
 
-_CRTIMP int __cdecl    fprintf (FILE*, const char*, ...);
-_CRTIMP int __cdecl    printf (const char*, ...);
-_CRTIMP int __cdecl    sprintf (char*, const char*, ...);
-_CRTIMP int __cdecl    _snprintf (char*, size_t, const char*, ...);
-_CRTIMP int __cdecl    vfprintf (FILE*, const char*, __VALIST);
-_CRTIMP int __cdecl    vprintf (const char*, __VALIST);
-_CRTIMP int __cdecl    vsprintf (char*, const char*, __VALIST);
-_CRTIMP int __cdecl    _vsnprintf (char*, size_t, const char*, __VALIST);
+#ifndef _FPOS_T_DEFINED
+#define _FPOS_T_DEFINED
+#undef _FPOSOFF
 
-#ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
-int __cdecl snprintf(char* s, size_t n, const char*  format, ...);
-__CRT_INLINE int __cdecl
-vsnprintf (char* s, size_t n, const char* format, __VALIST arg)
-  { return _vsnprintf ( s, n, format, arg); }
-int __cdecl vscanf (const char * __restrict__, __VALIST);
-int __cdecl vfscanf (FILE * __restrict__, const char * __restrict__,
-                    __VALIST);
-int __cdecl vsscanf (const char * __restrict__,
-                    const char * __restrict__, __VALIST);
-#endif
-
-/*
- * Formatted Input
- */
+#if (!defined(NO_OLDNAMES) || defined(__GNUC__)) && _INTEGRAL_MAX_BITS >= 64
+  typedef __int64 fpos_t;
+#define _FPOSOFF(fp) ((long)(fp))
+#else
+  typedef long long fpos_t;
+#define _FPOSOFF(fp) ((long)(fp))
+#endif
 
-_CRTIMP int __cdecl    fscanf (FILE*, const char*, ...);
-_CRTIMP int __cdecl    scanf (const char*, ...);
-_CRTIMP int __cdecl    sscanf (const char*, const char*, ...);
-/*
- * Character Input and Output Functions
- */
+#endif
 
-_CRTIMP int __cdecl    fgetc (FILE*);
-_CRTIMP char* __cdecl  fgets (char*, int, FILE*);
-_CRTIMP int __cdecl    fputc (int, FILE*);
-_CRTIMP int __cdecl    fputs (const char*, FILE*);
-_CRTIMP char* __cdecl  gets (char*);
-_CRTIMP int __cdecl    puts (const char*);
-_CRTIMP int __cdecl    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    _filbuf (FILE*);
-_CRTIMP int __cdecl    _flsbuf (int, FILE*);
-
-#if !defined _MT
-
-__CRT_INLINE int __cdecl getc (FILE* __F)
-{
-  return (--__F->_cnt >= 0)
-    ?  (int) (unsigned char) *__F->_ptr++
-    : _filbuf (__F);
-}
+#ifndef _STDSTREAM_DEFINED
+#define _STDSTREAM_DEFINED
+#define stdin (&_iob[0])
+#define stdout (&_iob[1])
+#define stderr (&_iob[1])
+#endif /* !_STDSTREAM_DEFINED */
 
-__CRT_INLINE int __cdecl putc (int __c, FILE* __F)
-{
-  return (--__F->_cnt >= 0)
-    ?  (int) (unsigned char) (*__F->_ptr++ = (char)__c)
-    :  _flsbuf (__c, __F);
-}
+#define _IOREAD 0x0001
+#define _IOWRT 0x0002
 
-__CRT_INLINE int __cdecl getchar (void)
-{
-  return (--stdin->_cnt >= 0)
-    ?  (int) (unsigned char) *stdin->_ptr++
-    : _filbuf (stdin);
-}
+#define _IOFBF 0x0000
+#define _IOLBF 0x0040
+#define _IONBF 0x0004
 
-__CRT_INLINE int __cdecl putchar(int __c)
-{
-  return (--stdout->_cnt >= 0)
-    ?  (int) (unsigned char) (*stdout->_ptr++ = (char)__c)
-    :  _flsbuf (__c, stdout);}
+#define _IOMYBUF 0x0008
+#define _IOEOF 0x0010
+#define _IOERR 0x0020
+#define _IOSTRG 0x0040
+#define _IORW 0x0080
 
-#else  /* Use library functions.  */
+#define _TWO_DIGIT_EXPONENT 0x1
 
-_CRTIMP int __cdecl    getc (FILE*);
-_CRTIMP int __cdecl    putc (int, FILE*);
-_CRTIMP int __cdecl    getchar (void);
-_CRTIMP int __cdecl    putchar (int);
+#ifndef _STDIO_DEFINED
 
+  _CRTIMP int __cdecl _filbuf(FILE *_File);
+  _CRTIMP int __cdecl _flsbuf(int _Ch,FILE *_File);
+#ifdef _POSIX_
+  _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode);
+#else
+  _CRTIMP FILE *__cdecl _fsopen(const char *_Filename,const char *_Mode,int _ShFlag);
 #endif
-
-/*
- * Direct Input and Output Functions
- */
-
-_CRTIMP size_t __cdecl fread (void*, size_t, size_t, FILE*);
-_CRTIMP size_t __cdecl fwrite (const void*, size_t, size_t, FILE*);
-
-/*
- * File Positioning Functions
- */
-
-_CRTIMP int __cdecl    fseek (FILE*, long, int);
-_CRTIMP long __cdecl   ftell (FILE*);
-_CRTIMP void __cdecl   rewind (FILE*);
-
-#if __MSVCRT_VERSION__ >= 0x800
-_CRTIMP int __cdecl    _fseek_nolock (FILE*, long, int);
-_CRTIMP long __cdecl   _ftell_nolock (FILE*);
-
-_CRTIMP int __cdecl    _fseeki64 (FILE*, __int64, int);
-_CRTIMP __int64 __cdecl        _ftelli64 (FILE*);
-_CRTIMP int __cdecl    _fseeki64_nolock (FILE*, __int64, int);
-_CRTIMP __int64 __cdecl        _ftelli64_nolock (FILE*);
+  _CRTIMP void __cdecl clearerr(FILE *_File);
+  _CRTIMP int __cdecl fclose(FILE *_File);
+  _CRTIMP int __cdecl _fcloseall(void);
+#ifdef _POSIX_
+  FILE *__cdecl fdopen(int _FileHandle,const char *_Mode);
+#else
+  _CRTIMP FILE *__cdecl _fdopen(int _FileHandle,const char *_Mode);
 #endif
-
-#ifdef __USE_MINGW_FSEEK  /* These are in libmingwex.a */
-/*
- * Workaround for limitations on win9x where a file contents are
- * not zero'd out if you seek past the end and then write.
- */
-
-int __cdecl __mingw_fseek (FILE *, long, int);
-size_t __cdecl __mingw_fwrite (const void*, size_t, size_t, FILE*);
-#define fseek(fp, offset, whence)  __mingw_fseek(fp, offset, whence)
-#define fwrite(buffer, size, count, fp)  __mingw_fwrite(buffer, size, count, fp)
-#endif /* __USE_MINGW_FSEEK */
-
-/*
- * 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;
+  _CRTIMP int __cdecl feof(FILE *_File);
+  _CRTIMP int __cdecl ferror(FILE *_File);
+  _CRTIMP int __cdecl fflush(FILE *_File);
+  _CRTIMP int __cdecl fgetc(FILE *_File);
+  _CRTIMP int __cdecl _fgetchar(void);
+  _CRTIMP int __cdecl fgetpos(FILE *_File ,fpos_t *_Pos);
+  _CRTIMP char *__cdecl fgets(char *_Buf,int _MaxCount,FILE *_File);
+#ifdef _POSIX_
+  int __cdecl fileno(FILE *_File);
 #else
-typedef long   fpos_t;
+  _CRTIMP int __cdecl _fileno(FILE *_File);
+#endif
+  _CRTIMP char *__cdecl _tempnam(const char *_DirName,const char *_FilePrefix);
+  _CRTIMP int __cdecl _flushall(void);
+  _CRTIMP FILE *__cdecl fopen(const char *_Filename,const char *_Mode);
+  _CRTIMP int __cdecl fprintf(FILE *_File,const char *_Format,...);
+  _CRTIMP int __cdecl fputc(int _Ch,FILE *_File);
+  _CRTIMP int __cdecl _fputchar(int _Ch);
+  _CRTIMP int __cdecl fputs(const char *_Str,FILE *_File);
+  _CRTIMP size_t __cdecl fread(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
+  _CRTIMP _CRT_INSECURE_DEPRECATE(freopen_s) FILE *__cdecl freopen(const char *_Filename,const char *_Mode,FILE *_File);
+  _CRTIMP _CRT_INSECURE_DEPRECATE(fscanf_s) int __cdecl fscanf(FILE *_File,const char *_Format,...);
+  _CRTIMP int __cdecl fsetpos(FILE *_File,const fpos_t *_Pos);
+  _CRTIMP int __cdecl fseek(FILE *_File,long _Offset,int _Origin);
+  _CRTIMP long __cdecl ftell(FILE *_File);
+  _CRTIMP int __cdecl _fseeki64(FILE *_File,__int64 _Offset,int _Origin);
+  _CRTIMP __int64 __cdecl _ftelli64(FILE *_File);
+  _CRTIMP size_t __cdecl fwrite(const void *_Str,size_t _Size,size_t _Count,FILE *_File);
+  _CRTIMP int __cdecl getc(FILE *_File);
+  _CRTIMP int __cdecl getchar(void);
+  _CRTIMP int __cdecl _getmaxstdio(void);
+  _CRTIMP char *__cdecl gets(char *_Buffer); // FIXME: non-standard
+  _CRTIMP int __cdecl _getw(FILE *_File);
+#ifndef _CRT_PERROR_DEFINED
+#define _CRT_PERROR_DEFINED
+  _CRTIMP void __cdecl perror(const char *_ErrMsg);
+#endif
+  _CRTIMP int __cdecl _pclose(FILE *_File);
+  _CRTIMP FILE *__cdecl _popen(const char *_Command,const char *_Mode);
+  _CRTIMP int __cdecl printf(const char *_Format,...);
+  _CRTIMP int __cdecl putc(int _Ch,FILE *_File);
+  _CRTIMP int __cdecl putchar(int _Ch);
+  _CRTIMP int __cdecl puts(const char *_Str);
+  _CRTIMP int __cdecl _putw(int _Word,FILE *_File);
+#ifndef _CRT_DIRECTORY_DEFINED
+#define _CRT_DIRECTORY_DEFINED
+  _CRTIMP int __cdecl remove(const char *_Filename);
+  _CRTIMP int __cdecl rename(const char *_OldFilename,const char *_NewFilename);
+  _CRTIMP int __cdecl _unlink(const char *_Filename);
+#ifndef NO_OLDNAMES
+  _CRTIMP _CRT_NONSTDC_DEPRECATE(_unlink) int __cdecl unlink(const char *_Filename);
+#endif
+#endif
+  _CRTIMP void __cdecl rewind(FILE *_File);
+  _CRTIMP int __cdecl _rmtmp(void);
+  _CRTIMP _CRT_INSECURE_DEPRECATE_CORE(scanf_s) int __cdecl scanf(const char *_Format,...);
+  _CRTIMP _CRT_INSECURE_DEPRECATE(setvbuf) void __cdecl setbuf(FILE *_File,char *_Buffer);
+  _CRTIMP int __cdecl _setmaxstdio(int _Max);
+  _CRTIMP unsigned int __cdecl _set_output_format(unsigned int _Format);
+  _CRTIMP unsigned int __cdecl _get_output_format(void);
+  _CRTIMP int __cdecl setvbuf(FILE *_File,char *_Buf,int _Mode,size_t _Size);
+  _CRTIMP int __cdecl _scprintf(const char *_Format,...);
+  _CRTIMP _CRT_INSECURE_DEPRECATE_CORE(sscanf_s) int __cdecl sscanf(const char *_Src,const char *_Format,...);
+  _CRTIMP _CRT_INSECURE_DEPRECATE_CORE(_snscanf_s) int __cdecl _snscanf(const char *_Src,size_t _MaxCount,const char *_Format,...);
+  _CRTIMP _CRT_INSECURE_DEPRECATE(tmpfile_s) FILE *__cdecl tmpfile(void);
+  _CRTIMP char *__cdecl tmpnam(char *_Buffer);
+  _CRTIMP_ALT int __cdecl ungetc(int _Ch,FILE *_File);
+  _CRTIMP int __cdecl vfprintf(FILE *_File,const char *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl vprintf(const char *_Format,va_list _ArgList);
+  /* Make sure macros are not defined.  */
+#if __MINGW_GNUC_PREREQ(4,4)
+#pragma push_macro("vsnprintf")
+#pragma push_macro("snprintf")
+#endif
+  #undef vsnprintf
+  #undef snprintf
+  _CRTIMP _CRT_INSECURE_DEPRECATE(vsnprintf_s) int __cdecl vsnprintf(char *_DstBuf,size_t _MaxCount,const char *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl _snprintf(char *_Dest,size_t _Count,const char *_Format,...);
+  _CRTIMP int __cdecl _vsnprintf(char *_Dest,size_t _Count,const char *_Format,va_list _Args);
+  int __cdecl sprintf(char *_Dest,const char *_Format,...);
+  int __cdecl vsprintf(char *_Dest,const char *_Format,va_list _Args);
+#ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
+  int __cdecl snprintf(char* s, size_t n, const char*  format, ...);
+  int __cdecl vscanf(const char * __restrict__ Format, va_list argp);
+  int __cdecl vfscanf (FILE * __restrict__ fp, const char * Format,va_list argp);
+  int __cdecl vsscanf (const char * __restrict__ _Str,const char * __restrict__ Format,va_list argp);
+#endif
+/* Restore may prior defined macros snprintf/vsnprintf.  */
+#if __MINGW_GNUC_PREREQ(4,4)
+#pragma pop_macro("snprintf")
+#pragma pop_macro("vsnprintf")
 #endif
 
-_CRTIMP int __cdecl    fgetpos (FILE*, fpos_t*);
-_CRTIMP int __cdecl    fsetpos (FILE*, const fpos_t*);
-
-/*
- * Error Functions
- */
-
-_CRTIMP int __cdecl    feof (FILE*);
-_CRTIMP int __cdecl    ferror (FILE*);
+#ifndef vsnprintf
+  #define vsnprintf _vsnprintf
+#endif
+#ifndef snprintf
+  #define snprintf _snprintf
+#endif
 
-#ifdef __cplusplus
-inline int __cdecl feof (FILE* __F)
-  { return __F->_flag & _IOEOF; }
-inline int __cdecl ferror (FILE* __F)
-  { return __F->_flag & _IOERR; }
+  _CRTIMP int __cdecl _vscprintf(const char *_Format,va_list _ArgList);
+#ifdef _SAFECRT_IMPL
+#define _set_printf_count_output(i)
+#define _get_printf_count_output() (FALSE)
 #else
-#define feof(__F)     ((__F)->_flag & _IOEOF)
-#define ferror(__F)   ((__F)->_flag & _IOERR)
+  _CRTIMP int __cdecl _set_printf_count_output(int _Value);
+  _CRTIMP int __cdecl _get_printf_count_output(void);
 #endif
 
-_CRTIMP void __cdecl   clearerr (FILE*);
-_CRTIMP void __cdecl   perror (const char*);
-
-
-#ifndef __STRICT_ANSI__
-/*
- * Pipes
- */
-_CRTIMP FILE* __cdecl  _popen (const char*, const char*);
-_CRTIMP int __cdecl    _pclose (FILE*);
+#ifndef _WSTDIO_DEFINED
 
-#ifndef NO_OLDNAMES
-_CRTIMP FILE* __cdecl  popen (const char*, const char*);
-_CRTIMP int __cdecl    pclose (FILE*);
+#ifndef WEOF
+#define WEOF (wint_t)(0xFFFF)
 #endif
 
-/*
- * Other Non ANSI functions
- */
-_CRTIMP int __cdecl    _flushall (void);
-_CRTIMP int __cdecl    _fgetchar (void);
-_CRTIMP int __cdecl    _fputchar (int);
-_CRTIMP FILE* __cdecl  _fdopen (int, const char*);
-_CRTIMP int __cdecl    _fileno (FILE*);
-_CRTIMP int __cdecl    _fcloseall(void);
-_CRTIMP FILE* __cdecl  _fsopen(const char*, const char*, int);
-#ifdef __MSVCRT__
-_CRTIMP int __cdecl    _getmaxstdio(void);
-_CRTIMP int __cdecl    _setmaxstdio(int);
-#endif
-
-#if __MSVCRT_VERSION__ >= 0x800
-_CRTIMP int __cdecl _set_printf_count_output(int);
-_CRTIMP int __cdecl _get_printf_count_output(void);
-#endif
-
-#ifndef _NO_OLDNAMES
-_CRTIMP int __cdecl    fgetchar (void);
-_CRTIMP int __cdecl    fputchar (int);
-_CRTIMP FILE* __cdecl  fdopen (int, const char*);
-_CRTIMP int __cdecl    fileno (FILE*);
-#endif /* Not _NO_OLDNAMES */
-
-#define _fileno(__F) ((__F)->_file)
-#ifndef _NO_OLDNAMES
-#define fileno(__F) ((__F)->_file)
-#endif
-
-#if defined (__MSVCRT__) && !defined (__NO_MINGW_LFS)
-#include <sys/types.h>
-__CRT_INLINE FILE* __cdecl fopen64 (const char* filename, const char* mode)
-{
-  return fopen (filename, mode);
-}
-
-int __cdecl fseeko64 (FILE*, off64_t, int);
-
-#ifdef __USE_MINGW_FSEEK
-int __cdecl __mingw_fseeko64 (FILE *, off64_t, int);
-#define fseeko64(fp, offset, whence)  __mingw_fseeko64(fp, offset, whence)
+#ifdef _POSIX_
+  _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode);
+#else
+  _CRTIMP FILE *__cdecl _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag);
 #endif
+  _CRTIMP wint_t __cdecl fgetwc(FILE *_File);
+  _CRTIMP wint_t __cdecl _fgetwchar(void);
+  _CRTIMP wint_t __cdecl fputwc(wchar_t _Ch,FILE *_File);
+  _CRTIMP wint_t __cdecl _fputwchar(wchar_t _Ch);
+  _CRTIMP wint_t __cdecl getwc(FILE *_File);
+  _CRTIMP wint_t __cdecl getwchar(void);
+  _CRTIMP wint_t __cdecl putwc(wchar_t _Ch,FILE *_File);
+  _CRTIMP wint_t __cdecl putwchar(wchar_t _Ch);
+  _CRTIMP wint_t __cdecl ungetwc(wint_t _Ch,FILE *_File);
+  _CRTIMP wchar_t *__cdecl fgetws(wchar_t *_Dst,int _SizeInWords,FILE *_File);
+  _CRTIMP int __cdecl fputws(const wchar_t *_Str,FILE *_File);
+  _CRTIMP wchar_t *__cdecl _getws(wchar_t *_String);
+  _CRTIMP int __cdecl _putws(const wchar_t *_Str);
+  _CRTIMP int __cdecl fwprintf(FILE *_File,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl wprintf(const wchar_t *_Format,...);
+  _CRTIMP int __cdecl _scwprintf(const wchar_t *_Format,...);
+  _CRTIMP int __cdecl vfwprintf(FILE *_File,const wchar_t *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl vwprintf(const wchar_t *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl swprintf(wchar_t*, const wchar_t*, ...);
+  _CRTIMP int __cdecl vswprintf(wchar_t*, const wchar_t*,va_list);
+  _CRTIMP int __cdecl _swprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl _vswprintf_c(wchar_t *_DstBuf,size_t _SizeInWords,const wchar_t *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl _snwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl _vsnwprintf(wchar_t *_Dest,size_t _Count,const wchar_t *_Format,va_list _Args);
+#ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
+  _CRTIMP int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t*  format, ...);
+  __CRT_INLINE int __cdecl vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, va_list arg) { return _vsnwprintf(s,n,format,arg); }
+  _CRTIMP int __cdecl vwscanf (const wchar_t *, va_list);
+  _CRTIMP int __cdecl vfwscanf (FILE *,const wchar_t *,va_list);
+  _CRTIMP int __cdecl vswscanf (const wchar_t *,const wchar_t *,va_list);
+#endif
+  _CRTIMP int __cdecl _swprintf(wchar_t *_Dest,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl _vswprintf(wchar_t *_Dest,const wchar_t *_Format,va_list _Args);
 
-__CRT_INLINE off64_t __cdecl ftello64 (FILE * stream)
-{
-  fpos_t pos;
-  if (fgetpos(stream, &pos))
-    return  -1LL;
-  else
-   return ((off64_t) pos);
-}
-#endif /* __NO_MINGW_LFS */
-
-#endif /* Not __STRICT_ANSI__ */
-
-/* Wide  versions */
+#ifndef RC_INVOKED
+#include <vadefs.h>
+#endif
 
-#ifndef _WSTDIO_DEFINED
-/*  also in wchar.h - keep in sync */
-_CRTIMP int __cdecl    fwprintf (FILE*, const wchar_t*, ...);
-_CRTIMP int __cdecl    wprintf (const wchar_t*, ...);
-_CRTIMP int __cdecl    swprintf (wchar_t*, const wchar_t*, ...);
-_CRTIMP int __cdecl    _snwprintf (wchar_t*, size_t, const wchar_t*, ...);
-_CRTIMP int __cdecl    vfwprintf (FILE*, const wchar_t*, __VALIST);
-_CRTIMP int __cdecl    vwprintf (const wchar_t*, __VALIST);
-_CRTIMP int __cdecl    vswprintf (wchar_t*, const wchar_t*, __VALIST);
-_CRTIMP int __cdecl    _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST);
-_CRTIMP int __cdecl    fwscanf (FILE*, const wchar_t*, ...);
-_CRTIMP int __cdecl    wscanf (const wchar_t*, ...);
-_CRTIMP int __cdecl    swscanf (const wchar_t*, const wchar_t*, ...);
-_CRTIMP wint_t __cdecl fgetwc (FILE*);
-_CRTIMP wint_t __cdecl fputwc (wchar_t, FILE*);
-_CRTIMP wint_t __cdecl ungetwc (wchar_t, FILE*);
-
-#ifdef __MSVCRT__
-_CRTIMP wchar_t* __cdecl fgetws (wchar_t*, int, FILE*);
-_CRTIMP int __cdecl    fputws (const wchar_t*, FILE*);
-_CRTIMP wint_t __cdecl getwc (FILE*);
-_CRTIMP wint_t __cdecl getwchar (void);
-_CRTIMP wchar_t* __cdecl _getws (wchar_t*);
-_CRTIMP wint_t __cdecl putwc (wint_t, FILE*);
-_CRTIMP int __cdecl    _putws (const wchar_t*);
-_CRTIMP wint_t __cdecl putwchar (wint_t);
-_CRTIMP FILE* __cdecl  _wfdopen(int, wchar_t *);
-_CRTIMP FILE* __cdecl  _wfopen (const wchar_t*, const wchar_t*);
-_CRTIMP FILE* __cdecl  _wfreopen (const wchar_t*, const wchar_t*, FILE*);
-_CRTIMP FILE* __cdecl  _wfsopen (const wchar_t*, const wchar_t*, int);
-_CRTIMP wchar_t* __cdecl _wtmpnam (wchar_t*);
-_CRTIMP wchar_t* __cdecl _wtempnam (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl    _wrename (const wchar_t*, const wchar_t*);
-_CRTIMP int __cdecl    _wremove (const wchar_t*);
-_CRTIMP void __cdecl   _wperror (const wchar_t*);
-_CRTIMP FILE* __cdecl  _wpopen (const wchar_t*, const wchar_t*);
-#endif /* __MSVCRT__ */
+#ifdef _CRT_NON_CONFORMING_SWPRINTFS
+#ifndef __cplusplus
+#define swprintf _swprintf
+#define vswprintf _vswprintf
+#define _swprintf_l __swprintf_l
+#define _vswprintf_l __vswprintf_l
+#endif
+#endif
 
-#ifndef __NO_ISOCEXT  /* externs in libmingwex.a */
-int __cdecl snwprintf (wchar_t* s, size_t n, const wchar_t*  format, ...);
-__CRT_INLINE int __cdecl
-vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg)
-  { return _vsnwprintf ( s, n, format, arg);}
-int __cdecl vwscanf (const wchar_t * __restrict__, __VALIST);
-int __cdecl vfwscanf (FILE * __restrict__,
-                      const wchar_t * __restrict__, __VALIST);
-int __cdecl vswscanf (const wchar_t * __restrict__,
-                      const wchar_t * __restrict__, __VALIST);
+  _CRTIMP wchar_t *__cdecl _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix);
+  _CRTIMP int __cdecl _vscwprintf(const wchar_t *_Format,va_list _ArgList);
+  _CRTIMP int __cdecl fwscanf(FILE *_File,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl swscanf(const wchar_t *_Src,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl _snwscanf(const wchar_t *_Src,size_t _MaxCount,const wchar_t *_Format,...);
+  _CRTIMP int __cdecl wscanf(const wchar_t *_Format,...);
+  _CRTIMP FILE *__cdecl _wfdopen(int _FileHandle ,const wchar_t *_Mode);
+  _CRTIMP FILE *__cdecl _wfopen(const wchar_t *_Filename,const wchar_t *_Mode);
+  _CRTIMP FILE *__cdecl _wfreopen(const wchar_t *_Filename,const wchar_t *_Mode,FILE *_OldFile);
+#ifndef _CRT_WPERROR_DEFINED
+#define _CRT_WPERROR_DEFINED
+  _CRTIMP void __cdecl _wperror(const wchar_t *_ErrMsg);
 #endif
+  _CRTIMP FILE *__cdecl _wpopen(const wchar_t *_Command,const wchar_t *_Mode);
+#if !defined(NO_OLDNAMES) && !defined(wpopen)
+#define wpopen _wpopen
+#endif
+  _CRTIMP int __cdecl _wremove(const wchar_t *_Filename);
+  _CRTIMP wchar_t *__cdecl _wtmpnam(wchar_t *_Buffer);
+  _CRTIMP wint_t __cdecl _fgetwc_nolock(FILE *_File);
+  _CRTIMP wint_t __cdecl _fputwc_nolock(wchar_t _Ch,FILE *_File);
+  _CRTIMP wint_t __cdecl _ungetwc_nolock(wint_t _Ch,FILE *_File);
 
-#define _WSTDIO_DEFINED
-#endif /* _WSTDIO_DEFINED */
+#undef _CRT_GETPUTWCHAR_NOINLINE
 
-#ifndef __STRICT_ANSI__
-#ifdef __MSVCRT__
-#ifndef NO_OLDNAMES
-_CRTIMP FILE* __cdecl  wpopen (const wchar_t*, const wchar_t*);
-#endif /* not NO_OLDNAMES */
-#endif /* MSVCRT runtime */
+#if !defined(__cplusplus) || defined(_CRT_GETPUTWCHAR_NOINLINE)
+#define getwchar() fgetwc(stdin)
+#define putwchar(_c) fputwc((_c),stdout)
+#else
+  __CRT_INLINE wint_t __cdecl getwchar() { return (fgetwc(stdin)); }
+  __CRT_INLINE wint_t __cdecl putwchar(wchar_t _C) { return (fputwc(_C,stdout)); }
+#endif
 
-/*
- * Other Non ANSI wide functions
- */
-_CRTIMP wint_t __cdecl _fgetwchar (void);
-_CRTIMP wint_t __cdecl _fputwchar (wint_t);
-_CRTIMP int __cdecl    _getw (FILE*);
-_CRTIMP int __cdecl    _putw (int, FILE*);
+#define getwc(_stm) fgetwc(_stm)
+#define putwc(_c,_stm) fputwc(_c,_stm)
+#define _putwc_nolock(_c,_stm) _fputwc_nolock(_c,_stm)
+#define _getwc_nolock(_stm) _fgetwc_nolock(_stm)
 
-#ifndef _NO_OLDNAMES
-_CRTIMP wint_t __cdecl fgetwchar (void);
-_CRTIMP wint_t __cdecl fputwchar (wint_t);
-_CRTIMP int __cdecl    getw (FILE*);
-_CRTIMP int __cdecl    putw (int, FILE*);
-#endif /* Not _NO_OLDNAMES */
+#define _WSTDIO_DEFINED
+#endif
 
-#endif /* __STRICT_ANSI */
+#define _STDIO_DEFINED
+#endif // !_STDIO_DEFINED
+
+#define _fgetc_nolock(_stream) (--(_stream)->_cnt >= 0 ? 0xff & *(_stream)->_ptr++ : _filbuf(_stream))
+#define _fputc_nolock(_c,_stream) (--(_stream)->_cnt >= 0 ? 0xff & (*(_stream)->_ptr++ = (char)(_c)) : _flsbuf((_c),(_stream)))
+#define _getc_nolock(_stream) _fgetc_nolock(_stream)
+#define _putc_nolock(_c,_stream) _fputc_nolock(_c,_stream)
+#define _getchar_nolock() _getc_nolock(stdin)
+#define _putchar_nolock(_c) _putc_nolock((_c),stdout)
+#define _getwchar_nolock() _getwc_nolock(stdin)
+#define _putwchar_nolock(_c) _putwc_nolock((_c),stdout)
+
+  _CRTIMP void __cdecl _lock_file(FILE *_File);
+  _CRTIMP void __cdecl _unlock_file(FILE *_File);
+  _CRTIMP int __cdecl _fclose_nolock(FILE *_File);
+  _CRTIMP int __cdecl _fflush_nolock(FILE *_File);
+  _CRTIMP size_t __cdecl _fread_nolock(void *_DstBuf,size_t _ElementSize,size_t _Count,FILE *_File);
+  _CRTIMP int __cdecl _fseek_nolock(FILE *_File,long _Offset,int _Origin);
+  _CRTIMP long __cdecl _ftell_nolock(FILE *_File);
+  _CRTIMP int __cdecl _fseeki64_nolock(FILE *_File,__int64 _Offset,int _Origin);
+  _CRTIMP __int64 __cdecl _ftelli64_nolock(FILE *_File);
+  _CRTIMP size_t __cdecl _fwrite_nolock(const void *_DstBuf,size_t _Size,size_t _Count,FILE *_File);
+  _CRTIMP int __cdecl _ungetc_nolock(int _Ch,FILE *_File);
+
+#if !defined(NO_OLDNAMES) || !defined(_POSIX)
+#define P_tmpdir _P_tmpdir
+#define SYS_OPEN _SYS_OPEN
+
+  _CRTIMP char *__cdecl tempnam(const char *_Directory,const char *_FilePrefix);
+  _CRTIMP int __cdecl fcloseall(void);
+  _CRTIMP FILE *__cdecl fdopen(int _FileHandle,const char *_Format);
+  _CRTIMP int __cdecl fgetchar(void);
+  _CRTIMP int __cdecl fileno(FILE *_File);
+  _CRTIMP int __cdecl flushall(void);
+  _CRTIMP int __cdecl fputchar(int _Ch);
+  _CRTIMP int __cdecl getw(FILE *_File);
+  _CRTIMP int __cdecl putw(int _Ch,FILE *_File);
+  _CRTIMP int __cdecl rmtmp(void);
+#endif
 
 #ifdef __cplusplus
 }
 #endif
 
-#endif /* Not RC_INVOKED */
+#pragma pack(pop)
+
+#include <sec_api/stdio_s.h>
 
-#endif /* _STDIO_H_ */
+#endif