1 /**
2  * This file has no copyright assigned and is placed in the Public Domain.
3  * This file is part of the mingw-w64 runtime package.
4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5  */
6 #ifndef _INC_CONIO
7 #define _INC_CONIO
8 
9 #include <crtdefs.h>
10 
11 #if !defined(_UCRTBASE_STDIO_DEFINED) && __MSVCRT_VERSION__ >= 0x1400
12 #define _UCRTBASE_STDIO_DEFINED
13 
14 #define UCRTBASE_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION (0x0001)
15 #define UCRTBASE_PRINTF_STANDARD_SNPRINTF_BEHAVIOUR      (0x0002)
16 #define UCRTBASE_PRINTF_LEGACY_WIDE_SPECIFIERS           (0x0004)
17 #define UCRTBASE_PRINTF_LEGACY_MSVCRT_COMPATIBILITY      (0x0008)
18 #define UCRTBASE_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS     (0x0010)
19 
20 #define UCRTBASE_SCANF_SECURECRT                         (0x0001)
21 #define UCRTBASE_SCANF_LEGACY_WIDE_SPECIFIERS            (0x0002)
22 #define UCRTBASE_SCANF_LEGACY_MSVCRT_COMPATIBILITY       (0x0004)
23 
24 // Default wide printfs and scanfs to the standard mode
25 #ifndef UCRTBASE_PRINTF_DEFAULT_WIDE
26 #define UCRTBASE_PRINTF_DEFAULT_WIDE 0
27 #endif
28 #ifndef UCRTBASE_SCANF_DEFAULT_WIDE
29 #define UCRTBASE_SCANF_DEFAULT_WIDE 0
30 #endif
31 #endif
32 
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38   _CRTIMP char *_cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
39   _CRTIMP int __cdecl _cputs(const char *_Str);
40   _CRTIMP int __cdecl _getch(void);
41   _CRTIMP int __cdecl _getche(void);
42   _CRTIMP int __cdecl _kbhit(void);
43 
44 #if __MSVCRT_VERSION__ >= 0x1400
45   int __cdecl __conio_common_vcprintf(unsigned __int64 _Options, const char *_Format, _locale_t _Locale, va_list _ArgList);
46   int __cdecl __conio_common_vcprintf_p(unsigned __int64 _Options, const char *_Format, _locale_t _Locale, va_list _ArgList);
47   int __cdecl __conio_common_vcprintf_s(unsigned __int64 _Options, const char *_Format, _locale_t _Locale, va_list _ArgList);
48   int __cdecl __conio_common_vcscanf(unsigned __int64 _Options, const char *_Format, _locale_t _Locale, va_list _ArgList);
49 
_vcprintf(const char * __restrict__ _Format,va_list _ArgList)50   __mingw_ovr int __cdecl _vcprintf(const char * __restrict__ _Format,va_list _ArgList)
51   {
52     return __conio_common_vcprintf(0, _Format, NULL, _ArgList);
53   }
_cprintf(const char * __restrict__ _Format,...)54   __mingw_ovr int __cdecl _cprintf(const char * __restrict__ _Format,...)
55   {
56     __builtin_va_list _ArgList;
57     int _Ret;
58     __builtin_va_start(_ArgList, _Format);
59     _Ret = _vcprintf(_Format, _ArgList);
60     __builtin_va_end(_ArgList);
61     return _Ret;
62   }
_cscanf(const char * __restrict__ _Format,...)63   __mingw_ovr int __cdecl _cscanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
64   {
65     __builtin_va_list _ArgList;
66     int _Ret;
67     __builtin_va_start(_ArgList, _Format);
68     _Ret = __conio_common_vcscanf(0, _Format, NULL, _ArgList);
69     __builtin_va_end(_ArgList);
70     return _Ret;
71   }
_cscanf_l(const char * __restrict__ _Format,_locale_t _Locale,...)72   __mingw_ovr int __cdecl _cscanf_l(const char * __restrict__ _Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
73   {
74     __builtin_va_list _ArgList;
75     int _Ret;
76     __builtin_va_start(_ArgList, _Locale);
77     _Ret = __conio_common_vcscanf(0, _Format, _Locale, _ArgList);
78     __builtin_va_end(_ArgList);
79     return _Ret;
80   }
81 
_vcprintf_p(const char * __restrict__ _Format,va_list _ArgList)82   __mingw_ovr int __cdecl _vcprintf_p(const char * __restrict__ _Format,va_list _ArgList)
83   {
84     return __conio_common_vcprintf_p(0, _Format, NULL, _ArgList);
85   }
_cprintf_p(const char * __restrict__ _Format,...)86   __mingw_ovr int __cdecl _cprintf_p(const char * __restrict__ _Format,...)
87   {
88     __builtin_va_list _ArgList;
89     int _Ret;
90     __builtin_va_start(_ArgList, _Format);
91     _Ret = _vcprintf_p(_Format, _ArgList);
92     __builtin_va_end(_ArgList);
93     return _Ret;
94   }
_vcprintf_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)95   __mingw_ovr int __cdecl _vcprintf_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)
96   {
97     return __conio_common_vcprintf(0, _Format, _Locale, _ArgList);
98   }
_cprintf_l(const char * __restrict__ _Format,_locale_t _Locale,...)99   __mingw_ovr int __cdecl _cprintf_l(const char * __restrict__ _Format,_locale_t _Locale,...)
100   {
101     __builtin_va_list _ArgList;
102     int _Ret;
103     __builtin_va_start(_ArgList, _Locale);
104     _Ret = _vcprintf_l(_Format, _Locale, _ArgList);
105     __builtin_va_end(_ArgList);
106     return _Ret;
107   }
_vcprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)108   __mingw_ovr int __cdecl _vcprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)
109   {
110     return __conio_common_vcprintf_p(0, _Format, _Locale, _ArgList);
111   }
_cprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,...)112   __mingw_ovr int __cdecl _cprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,...)
113   {
114     __builtin_va_list _ArgList;
115     int _Ret;
116     __builtin_va_start(_ArgList, _Locale);
117     _Ret = _vcprintf_p_l(_Format, _Locale, _ArgList);
118     __builtin_va_end(_ArgList);
119     return _Ret;
120   }
121 #else
122   _CRTIMP int __cdecl _cprintf(const char * __restrict__ _Format,...);
123   _CRTIMP int __cdecl _cscanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
124   _CRTIMP int __cdecl _cscanf_l(const char * __restrict__ _Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
125 
126   _CRTIMP int __cdecl _vcprintf(const char * __restrict__ _Format,va_list _ArgList);
127   _CRTIMP int __cdecl _cprintf_p(const char * __restrict__ _Format,...);
128   _CRTIMP int __cdecl _vcprintf_p(const char * __restrict__ _Format,va_list _ArgList);
129   _CRTIMP int __cdecl _cprintf_l(const char * __restrict__ _Format,_locale_t _Locale,...);
130   _CRTIMP int __cdecl _vcprintf_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList);
131   _CRTIMP int __cdecl _cprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,...);
132   _CRTIMP int __cdecl _vcprintf_p_l(const char * __restrict__ _Format,_locale_t _Locale,va_list _ArgList);
133 #endif
134 
135 #if defined(_X86_) && !defined(__x86_64)
136   int __cdecl _inp(unsigned short);
137   unsigned short __cdecl _inpw(unsigned short);
138   unsigned long __cdecl _inpd(unsigned short);
139   int __cdecl _outp(unsigned short,int);
140   unsigned short __cdecl _outpw(unsigned short,unsigned short);
141   unsigned long __cdecl _outpd(unsigned short,unsigned long);
142 #endif
143 
144   _CRTIMP int __cdecl _putch(int _Ch);
145   _CRTIMP int __cdecl _ungetch(int _Ch);
146   _CRTIMP int __cdecl _getch_nolock(void);
147   _CRTIMP int __cdecl _getche_nolock(void);
148   _CRTIMP int __cdecl _putch_nolock(int _Ch);
149   _CRTIMP int __cdecl _ungetch_nolock(int _Ch);
150 
151 #ifndef _WCONIO_DEFINED
152 #define _WCONIO_DEFINED
153 
154 #ifndef WEOF
155 #define WEOF (wint_t)(0xFFFF)
156 #endif
157 
158   _CRTIMP wchar_t *_cgetws(wchar_t *_Buffer) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
159   _CRTIMP wint_t __cdecl _getwch(void);
160   _CRTIMP wint_t __cdecl _getwche(void);
161   _CRTIMP wint_t __cdecl _putwch(wchar_t _WCh);
162   _CRTIMP wint_t __cdecl _ungetwch(wint_t _WCh);
163   _CRTIMP int __cdecl _cputws(const wchar_t *_String);
164 #if __MSVCRT_VERSION__ >= 0x1400
165   int __cdecl __conio_common_vcwprintf(unsigned __int64 _Options, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
166   int __cdecl __conio_common_vcwprintf_p(unsigned __int64 _Options, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
167   int __cdecl __conio_common_vcwprintf_s(unsigned __int64 _Options, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
168   int __cdecl __conio_common_vcwscanf(unsigned __int64 _Options, const wchar_t *_Format, _locale_t _Locale, va_list _ArgList);
169 
_vcwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList)170   __mingw_ovr int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList)
171   {
172     return __conio_common_vcwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _Format, NULL, _ArgList);
173   }
_cwprintf(const wchar_t * __restrict__ _Format,...)174   __mingw_ovr int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...)
175   {
176     __builtin_va_list _ArgList;
177     int _Ret;
178     __builtin_va_start(_ArgList, _Format);
179     _Ret = _vcwprintf(_Format, _ArgList);
180     __builtin_va_end(_ArgList);
181     return _Ret;
182   }
_cwscanf(const wchar_t * __restrict__ _Format,...)183   __mingw_ovr int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
184   {
185     __builtin_va_list _ArgList;
186     int _Ret;
187     __builtin_va_start(_ArgList, _Format);
188     _Ret = __conio_common_vcwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, _Format, NULL, _ArgList);
189     __builtin_va_end(_ArgList);
190     return _Ret;
191   }
_cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...)192   __mingw_ovr int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN
193   {
194     __builtin_va_list _ArgList;
195     int _Ret;
196     __builtin_va_start(_ArgList, _Locale);
197     _Ret = __conio_common_vcwscanf(UCRTBASE_SCANF_DEFAULT_WIDE, _Format, _Locale, _ArgList);
198     __builtin_va_end(_ArgList);
199     return _Ret;
200   }
_vcwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList)201   __mingw_ovr int __cdecl _vcwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList)
202   {
203     return __conio_common_vcwprintf_p(UCRTBASE_PRINTF_DEFAULT_WIDE, _Format, NULL, _ArgList);
204   }
_cwprintf_p(const wchar_t * __restrict__ _Format,...)205   __mingw_ovr int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...)
206   {
207     __builtin_va_list _ArgList;
208     int _Ret;
209     __builtin_va_start(_ArgList, _Format);
210     _Ret = _vcwprintf_p(_Format, _ArgList);
211     __builtin_va_end(_ArgList);
212     return _Ret;
213   }
_vcwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)214   __mingw_ovr int __cdecl _vcwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)
215   {
216     return __conio_common_vcwprintf(UCRTBASE_PRINTF_DEFAULT_WIDE, _Format, _Locale, _ArgList);
217   }
_cwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...)218   __mingw_ovr int __cdecl _cwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...)
219   {
220     __builtin_va_list _ArgList;
221     int _Ret;
222     __builtin_va_start(_ArgList, _Locale);
223     _Ret = _vcwprintf_l(_Format, _Locale, _ArgList);
224     __builtin_va_end(_ArgList);
225     return _Ret;
226   }
_vcwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)227   __mingw_ovr int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList)
228   {
229     return __conio_common_vcwprintf_p(UCRTBASE_PRINTF_DEFAULT_WIDE, _Format, _Locale, _ArgList);
230   }
_cwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...)231   __mingw_ovr int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...)
232   {
233     __builtin_va_list _ArgList;
234     int _Ret;
235     __builtin_va_start(_ArgList, _Locale);
236     _Ret = _vcwprintf_p_l(_Format, _Locale, _ArgList);
237     __builtin_va_end(_ArgList);
238     return _Ret;
239   }
240 #else
241   _CRTIMP int __cdecl _cwprintf(const wchar_t * __restrict__ _Format,...);
242   _CRTIMP int __cdecl _cwscanf(const wchar_t * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
243   _CRTIMP int __cdecl _cwscanf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
244   _CRTIMP int __cdecl _vcwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList);
245   _CRTIMP int __cdecl _cwprintf_p(const wchar_t * __restrict__ _Format,...);
246   _CRTIMP int __cdecl _vcwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList);
247   _CRTIMP int __cdecl _cwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...);
248   _CRTIMP int __cdecl _vcwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList);
249   _CRTIMP int __cdecl _cwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...);
250   _CRTIMP int __cdecl _vcwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList);
251 #endif
252   _CRTIMP wint_t __cdecl _putwch_nolock(wchar_t _WCh);
253   _CRTIMP wint_t __cdecl _getwch_nolock(void);
254   _CRTIMP wint_t __cdecl _getwche_nolock(void);
255   _CRTIMP wint_t __cdecl _ungetwch_nolock(wint_t _WCh);
256 #endif
257 
258 #ifndef	NO_OLDNAMES
259   char *__cdecl cgets(char *_Buffer) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
260 
261 #if __MSVCRT_VERSION__ >= 0x1400
cprintf(const char * __restrict__ _Format,...)262   __mingw_ovr int __cdecl cprintf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005
263   {
264     __builtin_va_list _ArgList;
265     int _Ret;
266     __builtin_va_start(_ArgList, _Format);
267     _Ret = _vcprintf(_Format, _ArgList);
268     __builtin_va_end(_ArgList);
269     return _Ret;
270   }
cscanf(const char * __restrict__ _Format,...)271   __mingw_ovr int __cdecl cscanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005
272   {
273     __builtin_va_list _ArgList;
274     int _Ret;
275     __builtin_va_start(_ArgList, _Format);
276     _Ret = __conio_common_vcscanf(0, _Format, NULL, _ArgList);
277     __builtin_va_end(_ArgList);
278     return _Ret;
279   }
280 #else
281   int __cdecl cprintf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
282   int __cdecl cscanf(const char * __restrict__ _Format,...) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
283 #endif
284   int __cdecl cputs(const char *_Str) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
285   int __cdecl getch(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
286   int __cdecl getche(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
287   int __cdecl kbhit(void) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
288   int __cdecl putch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
289   int __cdecl ungetch(int _Ch) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
290 
291 #if (defined(_X86_) && !defined(__x86_64))
292   int __cdecl inp(unsigned short) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
293   unsigned short __cdecl inpw(unsigned short) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
294   int __cdecl outp(unsigned short,int) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
295   unsigned short __cdecl outpw(unsigned short,unsigned short) __MINGW_ATTRIB_DEPRECATED_MSVC2005;
296 #endif
297 
298     /* __cpuid moved to intrin.h per msdn */
299     /* __inbyte moved to intrin.h per msdn */
300     /* __inbytestring moved to intrin.h per msdn */
301     /* __indword moved to intrin.h per msdn */
302     /* __indwordstring moved to intrin.h per msdn */
303     /* __inword moved to intrin.h per msdn */
304     /* __inwordstring moved to intrin.h per msdn */
305     /* __outbyte moved to intrin.h per msdn */
306     /* __outbytestring moved to intrin.h per msdn */
307     /* __outdword moved to intrin.h per msdn */
308     /* __outdwordstring moved to intrin.h per msdn */
309     /* __outword moved to intrin.h per msdn */
310     /* __outwordstring moved to intrin.h per msdn */
311     /* __readcr0 moved to intrin.h per msdn */
312     /* __readcr2 moved to intrin.h per msdn */
313     /* __readcr3 moved to intrin.h per msdn */
314     /* __readcr4 moved to intrin.h per msdn */
315     /* __readcr8 moved to intrin.h per msdn */
316     /* __readmsr moved to intrin.h per msdn */
317     /* __writecr0 moved to intrin.h per msdn */
318     /* __writecr2 moved to intrin.h per msdn */
319     /* __writecr3 moved to intrin.h per msdn */
320     /* __writecr4 moved to intrin.h per msdn */
321     /* __writecr8 moved to intrin.h per msdn */
322     /* __writemsr moved to intrin.h per msdn */
323 #endif
324 
325 #ifdef __cplusplus
326 }
327 #endif
328 
329 #include <sec_api/conio_s.h>
330 
331 #endif
332