2 * Standard I/O definitions.
4 * Derived from the mingw header written by Colin Peters.
5 * Modified for Wine use by Jon Griffiths and Francois Gouget.
6 * This file is in the public domain.
11 #include <corecrt_wstdio.h>
13 /* file._flag flags */
14 #define _IOREAD 0x0001
16 #define _IOMYBUF 0x0008
19 #define _IOSTRG 0x0040
22 #define STDIN_FILENO 0
23 #define STDOUT_FILENO 1
24 #define STDERR_FILENO 2
26 /* more file._flag flags, but these conflict with Unix */
32 #define FILENAME_MAX 260
33 #define TMP_MAX 0x7fff
45 #ifndef _FPOS_T_DEFINED
46 typedef __int64
DECLSPEC_ALIGN(8) fpos_t;
47 #define _FPOS_T_DEFINED
54 #ifndef _STDIO_DEFINED
56 FILE* __cdecl
__p__iob(void);
57 # define _iob (__p__iob())
59 FILE* __cdecl
__iob_func(void);
60 # define _iob (__iob_func())
62 #endif /* _STDIO_DEFINED */
64 /* return value for _get_output_format */
65 #define _TWO_DIGIT_EXPONENT 0x1
67 #ifndef _STDIO_DEFINED
68 #define _STDIO_DEFINED
69 int __cdecl
_fcloseall(void);
70 FILE* __cdecl
_fdopen(int,const char*);
71 int __cdecl
_fgetchar(void);
72 int __cdecl
_filbuf(FILE*);
73 int __cdecl
_fileno(FILE*);
74 int __cdecl
_flsbuf(int,FILE*);
75 int __cdecl
_flushall(void);
76 int __cdecl
_fputchar(int);
77 FILE* __cdecl
_fsopen(const char*,const char*,int);
78 int __cdecl
_get_printf_count_output(void);
79 int __cdecl
_getmaxstdio(void);
80 int __cdecl
_getw(FILE*);
81 int __cdecl
_pclose(FILE*);
82 FILE* __cdecl
_popen(const char*,const char*);
83 int __cdecl
_putw(int,FILE*);
84 int __cdecl
_rmtmp(void);
85 int __cdecl
_set_printf_count_output(int);
86 int __cdecl
_setmaxstdio(int);
87 char* __cdecl
_tempnam(const char*,const char*);
88 int __cdecl
_unlink(const char*);
90 size_t __cdecl
_fread_nolock(void*,size_t,size_t,FILE*);
91 size_t __cdecl
_fread_nolock_s(void*,size_t,size_t,size_t,FILE*);
92 size_t __cdecl
_fwrite_nolock(const void*,size_t,size_t,FILE*);
93 int __cdecl
_fclose_nolock(FILE*);
94 int __cdecl
_fflush_nolock(FILE*);
95 int __cdecl
_fgetc_nolock(FILE*);
96 int __cdecl
_fputc_nolock(int,FILE*);
97 int __cdecl
_fseek_nolock(FILE*,__msvcrt_long
,int);
98 int __cdecl
_fseeki64_nolock(FILE*,__int64
,int);
99 __msvcrt_long __cdecl
_ftell_nolock(FILE*);
100 __int64 __cdecl
_ftelli64_nolock(FILE*);
101 int __cdecl
_getc_nolock(FILE*);
102 int __cdecl
_putc_nolock(int,FILE*);
103 int __cdecl
_ungetc_nolock(int,FILE*);
105 void __cdecl
clearerr(FILE*);
106 errno_t __cdecl
clearerr_s(FILE*);
107 int __cdecl
fclose(FILE*);
108 int __cdecl
feof(FILE*);
109 int __cdecl
ferror(FILE*);
110 int __cdecl
fflush(FILE*);
111 int __cdecl
fgetc(FILE*);
112 int __cdecl
fgetpos(FILE*,fpos_t*);
113 char* __cdecl
fgets(char*,int,FILE*);
114 FILE* __cdecl
fopen(const char*,const char*);
115 errno_t __cdecl
fopen_s(FILE**,const char*,const char*);
116 int __cdecl
fputc(int,FILE*);
117 int __cdecl
fputs(const char*,FILE*);
118 size_t __cdecl
fread(void*,size_t,size_t,FILE*);
119 size_t __cdecl
fread_s(void*,size_t,size_t,size_t,FILE*);
120 FILE* __cdecl
freopen(const char*,const char*,FILE*);
121 int __cdecl
fseek(FILE*,__msvcrt_long
,int);
122 int __cdecl
_fseeki64(FILE*,__int64
,int);
123 int __cdecl
fsetpos(FILE*,fpos_t*);
124 __msvcrt_long __cdecl
ftell(FILE*);
125 __int64 __cdecl
_ftelli64(FILE*);
126 size_t __cdecl
fwrite(const void*,size_t,size_t,FILE*);
127 int __cdecl
getc(FILE*);
128 int __cdecl
getchar(void);
129 char* __cdecl
gets(char*);
130 void __cdecl
perror(const char*);
131 int __cdecl
putc(int,FILE*);
132 int __cdecl
putchar(int);
133 int __cdecl
puts(const char*);
134 int __cdecl
remove(const char*);
135 int __cdecl
rename(const char*,const char*);
136 void __cdecl
rewind(FILE*);
137 void __cdecl
setbuf(FILE*,char*);
138 int __cdecl
setvbuf(FILE*,char*,int,size_t);
139 FILE* __cdecl
tmpfile(void);
140 char* __cdecl
tmpnam(char*);
141 int __cdecl
ungetc(int,FILE*);
142 unsigned int __cdecl
_get_output_format(void);
143 unsigned int __cdecl
_set_output_format(void);
147 _ACRTIMP
int __cdecl
__stdio_common_vfprintf(unsigned __int64
,FILE*,const char*,_locale_t
,__ms_va_list
);
148 _ACRTIMP
int __cdecl
__stdio_common_vfprintf_s(unsigned __int64
,FILE*,const char*,_locale_t
,__ms_va_list
);
149 _ACRTIMP
int __cdecl
__stdio_common_vsprintf(unsigned __int64
,char*,size_t,const char*,_locale_t
,__ms_va_list
);
150 _ACRTIMP
int __cdecl
__stdio_common_vsprintf_p(unsigned __int64
,char*,size_t,const char*,_locale_t
,__ms_va_list
);
151 _ACRTIMP
int __cdecl
__stdio_common_vsprintf_s(unsigned __int64
,char*,size_t,const char*,_locale_t
,__ms_va_list
);
152 _ACRTIMP
int __cdecl
__stdio_common_vsnprintf_s(unsigned __int64
,char*,size_t,size_t,const char*,_locale_t
,__ms_va_list
);
154 _ACRTIMP
int __cdecl
__stdio_common_vfscanf(unsigned __int64
,FILE*,const char*,_locale_t
,__ms_va_list
);
155 _ACRTIMP
int __cdecl
__stdio_common_vsscanf(unsigned __int64
,char const*,size_t,const char*,_locale_t
,__ms_va_list
);
157 static inline int __cdecl
vsnprintf(char *buffer
, size_t size
, const char *format
, __ms_va_list args
)
159 int ret
= __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
| _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR
,
160 buffer
, size
, format
, NULL
, args
);
161 return ret
< 0 ? -1 : ret
;
164 static inline int __cdecl
_vsnprintf(char *buffer
, size_t size
, const char *format
, __ms_va_list args
)
166 int ret
= __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
| _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
,
167 buffer
, size
, format
, NULL
, args
);
168 return ret
< 0 ? -1 : ret
;
171 static inline int __cdecl
_vsnprintf_s(char *buffer
, size_t size
, size_t count
, const char *format
, __ms_va_list args
)
173 int ret
= __stdio_common_vsnprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, buffer
, size
, count
, format
, NULL
, args
);
174 return ret
< 0 ? -1 : ret
;
177 static inline int WINAPIV
_snprintf_s(char *buffer
, size_t size
, size_t count
, const char *format
, ...)
182 __ms_va_start(args
, format
);
183 ret
= __stdio_common_vsnprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, buffer
, size
, count
, format
, NULL
, args
);
188 static inline int __cdecl
_vscprintf(const char *format
, __ms_va_list args
)
190 int ret
= __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
| _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR
,
191 NULL
, 0, format
, NULL
, args
);
192 return ret
< 0 ? -1 : ret
;
195 static inline int WINAPIV
_scprintf(const char *format
, ...)
200 __ms_va_start(args
, format
);
201 ret
= __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
| _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR
,
202 NULL
, 0, format
, NULL
, args
);
207 static inline int __cdecl
vsprintf(char *buffer
, const char *format
, __ms_va_list args
)
209 int ret
= __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
| _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION
,
210 buffer
, -1, format
, NULL
, args
);
211 return ret
< 0 ? -1 : ret
;
214 static inline int __cdecl
vsprintf_s(char *buffer
, const char *format
, __ms_va_list args
)
216 int ret
= __stdio_common_vsprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, buffer
, -1, format
, NULL
, args
);
217 return ret
< 0 ? -1 : ret
;
220 static inline int WINAPIV
sprintf_s(char *buffer
, size_t size
, size_t count
, const char *format
, ...)
225 __ms_va_start(args
, format
);
226 ret
= __stdio_common_vsprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, buffer
, -1, format
, NULL
, args
);
231 static inline int __cdecl
_vsprintf_p_l(char *buffer
, size_t size
, const char *format
, _locale_t locale
, __ms_va_list args
)
233 int ret
= __stdio_common_vsprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, buffer
, size
, format
, locale
, args
);
234 return ret
< 0 ? -1 : ret
;
237 static inline int __cdecl
vfprintf(FILE *file
, const char *format
, __ms_va_list args
)
239 return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, file
, format
, NULL
, args
);
242 static inline int WINAPIV
fprintf(FILE *file
, const char *format
, ...)
247 __ms_va_start(args
, format
);
248 ret
= __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, file
, format
, NULL
, args
);
253 static inline int __cdecl
vfprintf_s(FILE *file
, const char *format
, __ms_va_list args
)
255 return __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, file
, format
, NULL
, args
);
258 static inline int WINAPIV
fprintf_s(FILE *file
, const char *format
, ...)
263 __ms_va_start(args
, format
);
264 ret
= __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, file
, format
, NULL
, args
);
269 static inline int vprintf(const char *format
, __ms_va_list args
)
271 return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, stdout
, format
, NULL
, args
);
274 static inline int WINAPIV
printf(const char *format
, ...)
279 __ms_va_start(args
, format
);
280 ret
= __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, stdout
, format
, NULL
, args
);
285 static inline int vprintf_s(const char *format
, __ms_va_list args
)
287 return __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, stdout
, format
, NULL
, args
);
290 static inline int WINAPIV
printf_s(const char *format
, ...)
295 __ms_va_start(args
, format
);
296 ret
= __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS
, stdout
, format
, NULL
, args
);
301 static inline int WINAPIV
sscanf(const char *buffer
, const char *format
, ...)
306 __ms_va_start(args
, format
);
307 ret
= __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
, buffer
, -1, format
, NULL
, args
);
312 static inline int WINAPIV
sscanf_s(const char *buffer
, const char *format
, ...)
317 __ms_va_start(args
, format
);
318 ret
= __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
| _CRT_INTERNAL_SCANF_SECURECRT
, buffer
, -1, format
, NULL
, args
);
323 static inline int WINAPIV
_snscanf_l(const char *buffer
, size_t size
, const char *format
, _locale_t locale
, ...)
328 __ms_va_start(args
, locale
);
329 ret
= __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
, buffer
, size
, format
, locale
, args
);
334 static inline int WINAPIV
fscanf(FILE *file
, const char *format
, ...)
339 __ms_va_start(args
, format
);
340 ret
= __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
, file
, format
, NULL
, args
);
345 static inline int WINAPIV
fscanf_s(FILE *file
, const char *format
, ...)
350 __ms_va_start(args
, format
);
351 ret
= __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
| _CRT_INTERNAL_SCANF_SECURECRT
, file
, format
, NULL
, args
);
356 static inline int WINAPIV
scanf(const char *format
, ...)
361 __ms_va_start(args
, format
);
362 ret
= __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
, stdin
, format
, NULL
, args
);
367 static inline int WINAPIV
scanf_s(const char *format
, ...)
372 __ms_va_start(args
, format
);
373 ret
= __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS
| _CRT_INTERNAL_SCANF_SECURECRT
, stdin
, format
, NULL
, args
);
380 _ACRTIMP
int WINAPIV
_scprintf(const char *,...);
381 _ACRTIMP
int WINAPIV
_snprintf_s(char*,size_t,size_t,const char*,...);
382 _ACRTIMP
int __cdecl
_vscprintf(const char*,__ms_va_list
);
383 _ACRTIMP
int __cdecl
_vsnprintf_s(char*,size_t,size_t,const char*,__ms_va_list
);
384 _ACRTIMP
int __cdecl
_vsprintf_p_l(char*,size_t,const char*,_locale_t
,__ms_va_list
);
385 _ACRTIMP
int WINAPIV
fprintf(FILE*,const char*,...);
386 _ACRTIMP
int WINAPIV
fprintf_s(FILE*,const char*,...);
387 _ACRTIMP
int WINAPIV
printf(const char*,...);
388 _ACRTIMP
int WINAPIV
printf_s(const char*,...);
389 _ACRTIMP
int WINAPIV
sprintf_s(char*,size_t,const char*,...);
390 _ACRTIMP
int __cdecl
vfprintf(FILE*,const char*,__ms_va_list
);
391 _ACRTIMP
int __cdecl
vfprintf_s(FILE*,const char*,__ms_va_list
);
392 _ACRTIMP
int __cdecl
vprintf(const char*,__ms_va_list
);
393 _ACRTIMP
int __cdecl
vprintf_s(const char*,__ms_va_list
);
394 _ACRTIMP
int __cdecl
vsprintf(char*,const char*,__ms_va_list
);
395 _ACRTIMP
int __cdecl
vsprintf_s(char*,size_t,const char*,__ms_va_list
);
397 int __cdecl
_vsnprintf(char*,size_t,const char*,__ms_va_list
);
398 static inline int vsnprintf(char *buffer
, size_t size
, const char *format
, __ms_va_list args
) { return _vsnprintf(buffer
,size
,format
,args
); }
400 _ACRTIMP
int WINAPIV
_snscanf_l(const char*,size_t,const char*,_locale_t
,...);
401 _ACRTIMP
int WINAPIV
fscanf(FILE*,const char*,...);
402 _ACRTIMP
int WINAPIV
fscanf_s(FILE*,const char*,...);
403 _ACRTIMP
int WINAPIV
scanf(const char*,...);
404 _ACRTIMP
int WINAPIV
scanf_s(const char*,...);
405 _ACRTIMP
int WINAPIV
sscanf(const char*,const char*,...);
406 _ACRTIMP
int WINAPIV
sscanf_s(const char*,const char*,...);
410 #endif /* _STDIO_DEFINED */
417 static inline FILE* fdopen(int fd
, const char *mode
) { return _fdopen(fd
, mode
); }
418 static inline int fgetchar(void) { return _fgetchar(); }
419 static inline int fileno(FILE* file
) { return _fileno(file
); }
420 static inline int fputchar(int c
) { return _fputchar(c
); }
421 static inline int pclose(FILE* file
) { return _pclose(file
); }
422 static inline FILE* popen(const char* command
, const char* mode
) { return _popen(command
, mode
); }
423 static inline char* tempnam(const char *dir
, const char *prefix
) { return _tempnam(dir
, prefix
); }
424 #ifndef _UNLINK_DEFINED
425 static inline int unlink(const char* path
) { return _unlink(path
); }
426 #define _UNLINK_DEFINED
429 static inline int WINAPIV
snprintf(char *buffer
, size_t size
, const char *format
, ...)
434 __ms_va_start(args
, format
);
435 ret
= vsnprintf(buffer
, size
, format
, args
);
440 static inline int WINAPIV
_snprintf(char *buffer
, size_t size
, const char *format
, ...)
445 __ms_va_start(args
, format
);
446 ret
= _vsnprintf(buffer
, size
, format
, args
);
451 static inline int WINAPIV
sprintf(char *buffer
, const char *format
, ...)
456 __ms_va_start(args
, format
);
457 ret
= _vsnprintf(buffer
, (size_t)_CRT_INT_MAX
, format
, args
);
462 static inline wint_t fgetwchar(void) { return _fgetwchar(); }
463 static inline wint_t fputwchar(wint_t wc
) { return _fputwchar(wc
); }
464 static inline int getw(FILE* file
) { return _getw(file
); }
465 static inline int putw(int val
, FILE* file
) { return _putw(val
, file
); }
466 static inline FILE* wpopen(const wchar_t* command
,const wchar_t* mode
) { return _wpopen(command
, mode
); }
468 #endif /* __WINE_STDIO_H */