winemac.drv: Don't filter non active displays out.
[wine/zf.git] / include / msvcrt / stdio.h
blobf78e3b36f2bcdc7cfafe2671bf8d6739b8e8d432
1 /*
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.
7 */
8 #ifndef __WINE_STDIO_H
9 #define __WINE_STDIO_H
11 #include <corecrt_wstdio.h>
13 /* file._flag flags */
14 #define _IOREAD 0x0001
15 #define _IOWRT 0x0002
16 #define _IOMYBUF 0x0008
17 #define _IOEOF 0x0010
18 #define _IOERR 0x0020
19 #define _IOSTRG 0x0040
20 #define _IORW 0x0080
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 */
27 #define _IOFBF 0x0000
28 #define _IONBF 0x0004
29 #define _IOLBF 0x0040
31 #define EOF (-1)
32 #define FILENAME_MAX 260
33 #define TMP_MAX 0x7fff
34 #define TMP_MAX_S 0x7fffffff
35 #define FOPEN_MAX 20
36 #define L_tmpnam 260
38 #define BUFSIZ 512
40 #ifndef SEEK_SET
41 #define SEEK_SET 0
42 #define SEEK_CUR 1
43 #define SEEK_END 2
44 #endif
46 #ifndef _FPOS_T_DEFINED
47 typedef __int64 DECLSPEC_ALIGN(8) fpos_t;
48 #define _FPOS_T_DEFINED
49 #endif
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
55 #ifndef _STDIO_DEFINED
56 # ifdef __i386__
57 _ACRTIMP FILE* __cdecl __p__iob(void);
58 # define _iob (__p__iob())
59 # else
60 _ACRTIMP FILE* __cdecl __iob_func(void);
61 # define _iob (__iob_func())
62 # endif
63 #endif /* _STDIO_DEFINED */
65 /* return value for _get_output_format */
66 #define _TWO_DIGIT_EXPONENT 0x1
68 #ifndef _STDIO_DEFINED
69 #define _STDIO_DEFINED
70 _ACRTIMP int __cdecl _fcloseall(void);
71 _ACRTIMP FILE* __cdecl _fdopen(int,const char*);
72 _ACRTIMP int __cdecl _fgetchar(void);
73 _ACRTIMP int __cdecl _filbuf(FILE*);
74 _ACRTIMP int __cdecl _fileno(FILE*);
75 _ACRTIMP int __cdecl _flsbuf(int,FILE*);
76 _ACRTIMP int __cdecl _flushall(void);
77 _ACRTIMP int __cdecl _fputchar(int);
78 _ACRTIMP FILE* __cdecl _fsopen(const char*,const char*,int);
79 _ACRTIMP int __cdecl _get_printf_count_output(void);
80 _ACRTIMP int __cdecl _getmaxstdio(void);
81 _ACRTIMP int __cdecl _getw(FILE*);
82 _ACRTIMP int __cdecl _pclose(FILE*);
83 _ACRTIMP FILE* __cdecl _popen(const char*,const char*);
84 _ACRTIMP int __cdecl _putw(int,FILE*);
85 _ACRTIMP int __cdecl _rmtmp(void);
86 _ACRTIMP int __cdecl _set_printf_count_output(int);
87 _ACRTIMP int __cdecl _setmaxstdio(int);
88 _ACRTIMP char* __cdecl _tempnam(const char*,const char*);
89 _ACRTIMP int __cdecl _unlink(const char*);
91 _ACRTIMP void __cdecl _lock_file(FILE*);
92 _ACRTIMP void __cdecl _unlock_file(FILE*);
93 _ACRTIMP size_t __cdecl _fread_nolock(void*,size_t,size_t,FILE*);
94 _ACRTIMP size_t __cdecl _fread_nolock_s(void*,size_t,size_t,size_t,FILE*);
95 _ACRTIMP size_t __cdecl _fwrite_nolock(const void*,size_t,size_t,FILE*);
96 _ACRTIMP int __cdecl _fclose_nolock(FILE*);
97 _ACRTIMP int __cdecl _fflush_nolock(FILE*);
98 _ACRTIMP int __cdecl _fgetc_nolock(FILE*);
99 _ACRTIMP int __cdecl _fputc_nolock(int,FILE*);
100 _ACRTIMP int __cdecl _fseek_nolock(FILE*,__msvcrt_long,int);
101 _ACRTIMP int __cdecl _fseeki64_nolock(FILE*,__int64,int);
102 _ACRTIMP __msvcrt_long __cdecl _ftell_nolock(FILE*);
103 _ACRTIMP __int64 __cdecl _ftelli64_nolock(FILE*);
104 _ACRTIMP int __cdecl _getc_nolock(FILE*);
105 _ACRTIMP int __cdecl _putc_nolock(int,FILE*);
106 _ACRTIMP int __cdecl _ungetc_nolock(int,FILE*);
108 _ACRTIMP void __cdecl clearerr(FILE*);
109 _ACRTIMP errno_t __cdecl clearerr_s(FILE*);
110 _ACRTIMP int __cdecl fclose(FILE*);
111 _ACRTIMP int __cdecl feof(FILE*);
112 _ACRTIMP int __cdecl ferror(FILE*);
113 _ACRTIMP int __cdecl fflush(FILE*);
114 _ACRTIMP int __cdecl fgetc(FILE*);
115 _ACRTIMP int __cdecl fgetpos(FILE*,fpos_t*);
116 _ACRTIMP char* __cdecl fgets(char*,int,FILE*);
117 _ACRTIMP FILE* __cdecl fopen(const char*,const char*);
118 _ACRTIMP errno_t __cdecl fopen_s(FILE**,const char*,const char*);
119 _ACRTIMP int __cdecl fputc(int,FILE*);
120 _ACRTIMP int __cdecl fputs(const char*,FILE*);
121 _ACRTIMP size_t __cdecl fread(void*,size_t,size_t,FILE*);
122 _ACRTIMP size_t __cdecl fread_s(void*,size_t,size_t,size_t,FILE*);
123 _ACRTIMP FILE* __cdecl freopen(const char*,const char*,FILE*);
124 _ACRTIMP int __cdecl fseek(FILE*,__msvcrt_long,int);
125 _ACRTIMP int __cdecl _fseeki64(FILE*,__int64,int);
126 _ACRTIMP int __cdecl fsetpos(FILE*,fpos_t*);
127 _ACRTIMP __msvcrt_long __cdecl ftell(FILE*);
128 _ACRTIMP __int64 __cdecl _ftelli64(FILE*);
129 _ACRTIMP size_t __cdecl fwrite(const void*,size_t,size_t,FILE*);
130 _ACRTIMP int __cdecl getc(FILE*);
131 _ACRTIMP int __cdecl getchar(void);
132 _ACRTIMP char* __cdecl gets(char*);
133 _ACRTIMP void __cdecl perror(const char*);
134 _ACRTIMP int __cdecl putc(int,FILE*);
135 _ACRTIMP int __cdecl putchar(int);
136 _ACRTIMP int __cdecl puts(const char*);
137 _ACRTIMP int __cdecl remove(const char*);
138 _ACRTIMP int __cdecl rename(const char*,const char*);
139 _ACRTIMP void __cdecl rewind(FILE*);
140 _ACRTIMP void __cdecl setbuf(FILE*,char*);
141 _ACRTIMP int __cdecl setvbuf(FILE*,char*,int,size_t);
142 _ACRTIMP FILE* __cdecl tmpfile(void);
143 _ACRTIMP char* __cdecl tmpnam(char*);
144 _ACRTIMP int __cdecl ungetc(int,FILE*);
145 _ACRTIMP unsigned int __cdecl _get_output_format(void);
146 _ACRTIMP unsigned int __cdecl _set_output_format(unsigned int);
148 #ifdef _UCRT
150 _ACRTIMP int __cdecl __stdio_common_vfprintf(unsigned __int64,FILE*,const char*,_locale_t,__ms_va_list);
151 _ACRTIMP int __cdecl __stdio_common_vfprintf_s(unsigned __int64,FILE*,const char*,_locale_t,__ms_va_list);
152 _ACRTIMP int __cdecl __stdio_common_vsprintf(unsigned __int64,char*,size_t,const char*,_locale_t,__ms_va_list);
153 _ACRTIMP int __cdecl __stdio_common_vsprintf_p(unsigned __int64,char*,size_t,const char*,_locale_t,__ms_va_list);
154 _ACRTIMP int __cdecl __stdio_common_vsprintf_s(unsigned __int64,char*,size_t,const char*,_locale_t,__ms_va_list);
155 _ACRTIMP int __cdecl __stdio_common_vsnprintf_s(unsigned __int64,char*,size_t,size_t,const char*,_locale_t,__ms_va_list);
157 _ACRTIMP int __cdecl __stdio_common_vfscanf(unsigned __int64,FILE*,const char*,_locale_t,__ms_va_list);
158 _ACRTIMP int __cdecl __stdio_common_vsscanf(unsigned __int64,char const*,size_t,const char*,_locale_t,__ms_va_list);
160 #endif /* _UCRT */
162 #if defined(_UCRT) && !defined(_NO_CRT_STDIO_INLINE)
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_STANDARD_SNPRINTF_BEHAVIOR,
167 buffer, size, format, NULL, args);
168 return ret < 0 ? -1 : ret;
171 static inline int __cdecl _vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args)
173 int ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
174 buffer, size, format, NULL, args);
175 return ret < 0 ? -1 : ret;
178 static inline int __cdecl _vsnprintf_s(char *buffer, size_t size, size_t count, const char *format, __ms_va_list args)
180 int ret = __stdio_common_vsnprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, count, format, NULL, args);
181 return ret < 0 ? -1 : ret;
184 static inline int WINAPIV _snprintf_s(char *buffer, size_t size, size_t count, const char *format, ...)
186 int ret;
187 __ms_va_list args;
189 __ms_va_start(args, format);
190 ret = __stdio_common_vsnprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, count, format, NULL, args);
191 __ms_va_end(args);
192 return ret;
195 static inline int __cdecl _vscprintf(const char *format, __ms_va_list args)
197 int ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,
198 NULL, 0, format, NULL, args);
199 return ret < 0 ? -1 : ret;
202 static inline int WINAPIV _scprintf(const char *format, ...)
204 int ret;
205 __ms_va_list args;
207 __ms_va_start(args, format);
208 ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,
209 NULL, 0, format, NULL, args);
210 __ms_va_end(args);
211 return ret;
214 static inline int __cdecl vsprintf(char *buffer, const char *format, __ms_va_list args)
216 int ret = __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION,
217 buffer, -1, format, NULL, args);
218 return ret < 0 ? -1 : ret;
221 static inline int __cdecl vsprintf_s(char *buffer, size_t size, const char *format, __ms_va_list args)
223 int ret = __stdio_common_vsprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, format, NULL, args);
224 return ret < 0 ? -1 : ret;
227 static inline int WINAPIV sprintf_s(char *buffer, size_t size, const char *format, ...)
229 int ret;
230 __ms_va_list args;
232 __ms_va_start(args, format);
233 ret = __stdio_common_vsprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, format, NULL, args);
234 __ms_va_end(args);
235 return ret;
238 static inline int __cdecl _vsprintf_p_l(char *buffer, size_t size, const char *format, _locale_t locale, __ms_va_list args)
240 int ret = __stdio_common_vsprintf_p(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, format, locale, args);
241 return ret < 0 ? -1 : ret;
244 static inline int __cdecl vfprintf(FILE *file, const char *format, __ms_va_list args)
246 return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
249 static inline int WINAPIV fprintf(FILE *file, const char *format, ...)
251 int ret;
252 __ms_va_list args;
254 __ms_va_start(args, format);
255 ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
256 __ms_va_end(args);
257 return ret;
260 static inline int __cdecl vfprintf_s(FILE *file, const char *format, __ms_va_list args)
262 return __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
265 static inline int WINAPIV fprintf_s(FILE *file, const char *format, ...)
267 int ret;
268 __ms_va_list args;
270 __ms_va_start(args, format);
271 ret = __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
272 __ms_va_end(args);
273 return ret;
276 static inline int vprintf(const char *format, __ms_va_list args)
278 return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
281 static inline int WINAPIV printf(const char *format, ...)
283 int ret;
284 __ms_va_list args;
286 __ms_va_start(args, format);
287 ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
288 __ms_va_end(args);
289 return ret;
292 static inline int vprintf_s(const char *format, __ms_va_list args)
294 return __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
297 static inline int WINAPIV printf_s(const char *format, ...)
299 int ret;
300 __ms_va_list args;
302 __ms_va_start(args, format);
303 ret = __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
304 __ms_va_end(args);
305 return ret;
308 static inline int WINAPIV sscanf(const char *buffer, const char *format, ...)
310 int ret;
311 __ms_va_list args;
313 __ms_va_start(args, format);
314 ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, buffer, -1, format, NULL, args);
315 __ms_va_end(args);
316 return ret;
319 static inline int WINAPIV sscanf_s(const char *buffer, const char *format, ...)
321 int ret;
322 __ms_va_list args;
324 __ms_va_start(args, format);
325 ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS | _CRT_INTERNAL_SCANF_SECURECRT, buffer, -1, format, NULL, args);
326 __ms_va_end(args);
327 return ret;
330 static inline int WINAPIV _snscanf_l(const char *buffer, size_t size, const char *format, _locale_t locale, ...)
332 int ret;
333 __ms_va_list args;
335 __ms_va_start(args, locale);
336 ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, buffer, size, format, locale, args);
337 __ms_va_end(args);
338 return ret;
341 static inline int WINAPIV fscanf(FILE *file, const char *format, ...)
343 int ret;
344 __ms_va_list args;
346 __ms_va_start(args, format);
347 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, file, format, NULL, args);
348 __ms_va_end(args);
349 return ret;
352 static inline int WINAPIV fscanf_s(FILE *file, const char *format, ...)
354 int ret;
355 __ms_va_list args;
357 __ms_va_start(args, format);
358 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS | _CRT_INTERNAL_SCANF_SECURECRT, file, format, NULL, args);
359 __ms_va_end(args);
360 return ret;
363 static inline int WINAPIV scanf(const char *format, ...)
365 int ret;
366 __ms_va_list args;
368 __ms_va_start(args, format);
369 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, format, NULL, args);
370 __ms_va_end(args);
371 return ret;
374 static inline int WINAPIV scanf_s(const char *format, ...)
376 int ret;
377 __ms_va_list args;
379 __ms_va_start(args, format);
380 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS | _CRT_INTERNAL_SCANF_SECURECRT, stdin, format, NULL, args);
381 __ms_va_end(args);
382 return ret;
385 #else /* _UCRT && !_NO_CRT_STDIO_INLINE */
387 _ACRTIMP int WINAPIV _scprintf(const char *,...);
388 _ACRTIMP int WINAPIV _snprintf_s(char*,size_t,size_t,const char*,...);
389 _ACRTIMP int __cdecl _vscprintf(const char*,__ms_va_list);
390 _ACRTIMP int __cdecl _vsnprintf_s(char*,size_t,size_t,const char*,__ms_va_list);
391 _ACRTIMP int __cdecl _vsprintf_p_l(char*,size_t,const char*,_locale_t,__ms_va_list);
392 _ACRTIMP int WINAPIV fprintf(FILE*,const char*,...);
393 _ACRTIMP int WINAPIV fprintf_s(FILE*,const char*,...);
394 _ACRTIMP int WINAPIV printf(const char*,...);
395 _ACRTIMP int WINAPIV printf_s(const char*,...);
396 _ACRTIMP int WINAPIV sprintf_s(char*,size_t,const char*,...);
397 _ACRTIMP int __cdecl vfprintf(FILE*,const char*,__ms_va_list);
398 _ACRTIMP int __cdecl vfprintf_s(FILE*,const char*,__ms_va_list);
399 _ACRTIMP int __cdecl vprintf(const char*,__ms_va_list);
400 _ACRTIMP int __cdecl vprintf_s(const char*,__ms_va_list);
401 _ACRTIMP int __cdecl vsprintf(char*,const char*,__ms_va_list);
402 _ACRTIMP int __cdecl vsprintf_s(char*,size_t,const char*,__ms_va_list);
404 _ACRTIMP int __cdecl _vsnprintf(char*,size_t,const char*,__ms_va_list);
405 static inline int vsnprintf(char *buffer, size_t size, const char *format, __ms_va_list args) { return _vsnprintf(buffer,size,format,args); }
407 _ACRTIMP int WINAPIV _snscanf_l(const char*,size_t,const char*,_locale_t,...);
408 _ACRTIMP int WINAPIV fscanf(FILE*,const char*,...);
409 _ACRTIMP int WINAPIV fscanf_s(FILE*,const char*,...);
410 _ACRTIMP int WINAPIV scanf(const char*,...);
411 _ACRTIMP int WINAPIV scanf_s(const char*,...);
412 _ACRTIMP int WINAPIV sscanf(const char*,const char*,...);
413 _ACRTIMP int WINAPIV sscanf_s(const char*,const char*,...);
415 #endif /* _UCRT && !_NO_CRT_STDIO_INLINE */
417 #endif /* _STDIO_DEFINED */
419 #ifdef __cplusplus
421 #endif
424 static inline FILE* fdopen(int fd, const char *mode) { return _fdopen(fd, mode); }
425 static inline int fgetchar(void) { return _fgetchar(); }
426 static inline int fileno(FILE* file) { return _fileno(file); }
427 static inline int fputchar(int c) { return _fputchar(c); }
428 static inline int pclose(FILE* file) { return _pclose(file); }
429 static inline FILE* popen(const char* command, const char* mode) { return _popen(command, mode); }
430 static inline char* tempnam(const char *dir, const char *prefix) { return _tempnam(dir, prefix); }
431 #ifndef _UNLINK_DEFINED
432 static inline int unlink(const char* path) { return _unlink(path); }
433 #define _UNLINK_DEFINED
434 #endif
436 #if !defined(_NO_CRT_STDIO_INLINE)
438 static inline int WINAPIV snprintf(char *buffer, size_t size, const char *format, ...)
440 int ret;
441 __ms_va_list args;
443 __ms_va_start(args, format);
444 ret = vsnprintf(buffer, size, format, args);
445 __ms_va_end(args);
446 return ret;
449 static inline int WINAPIV _snprintf(char *buffer, size_t size, const char *format, ...)
451 int ret;
452 __ms_va_list args;
454 __ms_va_start(args, format);
455 ret = _vsnprintf(buffer, size, format, args);
456 __ms_va_end(args);
457 return ret;
460 static inline int WINAPIV sprintf(char *buffer, const char *format, ...)
462 int ret;
463 __ms_va_list args;
465 __ms_va_start(args, format);
466 ret = _vsnprintf(buffer, (size_t)_CRT_INT_MAX, format, args);
467 __ms_va_end(args);
468 return ret;
471 #else /* !_NO_CRT_STDIO_INLINE */
473 _ACRTIMP int WINAPIV snprintf(char*,size_t,const char*,...);
474 _ACRTIMP int WINAPIV _snprintf(char*,size_t,const char*,...);
475 _ACRTIMP int WINAPIV sprintf(char*,const char*,...);
477 #endif /* !_NO_CRT_STDIO_INLINE */
479 static inline wint_t fgetwchar(void) { return _fgetwchar(); }
480 static inline wint_t fputwchar(wint_t wc) { return _fputwchar(wc); }
481 static inline int getw(FILE* file) { return _getw(file); }
482 static inline int putw(int val, FILE* file) { return _putw(val, file); }
483 static inline FILE* wpopen(const wchar_t* command,const wchar_t* mode) { return _wpopen(command, mode); }
485 #endif /* __WINE_STDIO_H */