gdiplus: Use wide-char string literals.
[wine.git] / include / msvcrt / stdio.h
blobf2aef46e6ffa42345ba8825464b8097f8aea7a11
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 FOPEN_MAX 20
35 #define L_tmpnam 260
37 #define BUFSIZ 512
39 #ifndef SEEK_SET
40 #define SEEK_SET 0
41 #define SEEK_CUR 1
42 #define SEEK_END 2
43 #endif
45 #ifndef _FPOS_T_DEFINED
46 typedef __int64 DECLSPEC_ALIGN(8) fpos_t;
47 #define _FPOS_T_DEFINED
48 #endif
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
54 #ifndef _STDIO_DEFINED
55 # ifdef __i386__
56 FILE* __cdecl __p__iob(void);
57 # define _iob (__p__iob())
58 # else
59 FILE* __cdecl __iob_func(void);
60 # define _iob (__iob_func())
61 # endif
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);
145 #ifdef _UCRT
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, ...)
179 int ret;
180 __ms_va_list args;
182 __ms_va_start(args, format);
183 ret = __stdio_common_vsnprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, size, count, format, NULL, args);
184 __ms_va_end(args);
185 return ret;
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, ...)
197 int ret;
198 __ms_va_list args;
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);
203 __ms_va_end(args);
204 return ret;
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, ...)
222 int ret;
223 __ms_va_list args;
225 __ms_va_start(args, format);
226 ret = __stdio_common_vsprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, buffer, -1, format, NULL, args);
227 __ms_va_end(args);
228 return ret;
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, ...)
244 int ret;
245 __ms_va_list args;
247 __ms_va_start(args, format);
248 ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
249 __ms_va_end(args);
250 return ret;
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, ...)
260 int ret;
261 __ms_va_list args;
263 __ms_va_start(args, format);
264 ret = __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, args);
265 __ms_va_end(args);
266 return ret;
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, ...)
276 int ret;
277 __ms_va_list args;
279 __ms_va_start(args, format);
280 ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
281 __ms_va_end(args);
282 return ret;
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, ...)
292 int ret;
293 __ms_va_list args;
295 __ms_va_start(args, format);
296 ret = __stdio_common_vfprintf_s(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, format, NULL, args);
297 __ms_va_end(args);
298 return ret;
301 static inline int WINAPIV sscanf(const char *buffer, const char *format, ...)
303 int ret;
304 __ms_va_list args;
306 __ms_va_start(args, format);
307 ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, buffer, -1, format, NULL, args);
308 __ms_va_end(args);
309 return ret;
312 static inline int WINAPIV sscanf_s(const char *buffer, const char *format, ...)
314 int ret;
315 __ms_va_list args;
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);
319 __ms_va_end(args);
320 return ret;
323 static inline int WINAPIV _snscanf_l(const char *buffer, size_t size, const char *format, _locale_t locale, ...)
325 int ret;
326 __ms_va_list args;
328 __ms_va_start(args, locale);
329 ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, buffer, size, format, locale, args);
330 __ms_va_end(args);
331 return ret;
334 static inline int WINAPIV fscanf(FILE *file, const char *format, ...)
336 int ret;
337 __ms_va_list args;
339 __ms_va_start(args, format);
340 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, file, format, NULL, args);
341 __ms_va_end(args);
342 return ret;
345 static inline int WINAPIV fscanf_s(FILE *file, const char *format, ...)
347 int ret;
348 __ms_va_list args;
350 __ms_va_start(args, format);
351 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS | _CRT_INTERNAL_SCANF_SECURECRT, file, format, NULL, args);
352 __ms_va_end(args);
353 return ret;
356 static inline int WINAPIV scanf(const char *format, ...)
358 int ret;
359 __ms_va_list args;
361 __ms_va_start(args, format);
362 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, format, NULL, args);
363 __ms_va_end(args);
364 return ret;
367 static inline int WINAPIV scanf_s(const char *format, ...)
369 int ret;
370 __ms_va_list args;
372 __ms_va_start(args, format);
373 ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS | _CRT_INTERNAL_SCANF_SECURECRT, stdin, format, NULL, args);
374 __ms_va_end(args);
375 return ret;
378 #else /* _UCRT */
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*,...);
408 #endif /* _UCRT */
410 #endif /* _STDIO_DEFINED */
412 #ifdef __cplusplus
414 #endif
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
427 #endif
429 static inline int WINAPIV snprintf(char *buffer, size_t size, const char *format, ...)
431 int ret;
432 __ms_va_list args;
434 __ms_va_start(args, format);
435 ret = vsnprintf(buffer, size, format, args);
436 __ms_va_end(args);
437 return ret;
440 static inline int WINAPIV _snprintf(char *buffer, size_t size, const char *format, ...)
442 int ret;
443 __ms_va_list args;
445 __ms_va_start(args, format);
446 ret = _vsnprintf(buffer, size, format, args);
447 __ms_va_end(args);
448 return ret;
451 static inline int WINAPIV sprintf(char *buffer, const char *format, ...)
453 int ret;
454 __ms_va_list args;
456 __ms_va_start(args, format);
457 ret = _vsnprintf(buffer, (size_t)_CRT_INT_MAX, format, args);
458 __ms_va_end(args);
459 return ret;
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 */