xref: /reactos/sdk/lib/conutils/outstream.h (revision 4aaf54e0)
1 /*
2  * PROJECT:     ReactOS Console Utilities Library
3  * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE:     Provides basic abstraction wrappers around CRT streams or
5  *              Win32 console API I/O functions, to deal with i18n + Unicode
6  *              related problems.
7  * COPYRIGHT:   Copyright 2017-2018 ReactOS Team
8  *              Copyright 2017-2018 Hermes Belusca-Maito
9  */
10 
11 /**
12  * @file    outstream.h
13  * @ingroup ConUtils
14  *
15  * @brief   Console I/O utility API -- Output
16  **/
17 
18 #ifndef __OUTSTREAM_H__
19 #define __OUTSTREAM_H__
20 
21 #pragma once
22 
23 /*
24  * Enable this define if you want to only use CRT functions to output
25  * UNICODE stream to the console, as in the way explained by
26  * http://archives.miloush.net/michkap/archive/2008/03/18/8306597.html
27  */
28 /** NOTE: Experimental! Don't use USE_CRT yet because output to console is a bit broken **/
29 // #define USE_CRT
30 
31 #ifndef _UNICODE
32 #error The ConUtils library at the moment only supports compilation with _UNICODE defined!
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 // Shadow type, implementation-specific
40 typedef struct _CON_STREAM CON_STREAM, *PCON_STREAM;
41 
42 // typedef INT (__stdcall *CON_READ_FUNC)(
43     // IN PCON_STREAM Stream,
44     // OUT PTCHAR szStr,
45     // IN OUT PDWORD len);
46 
47 typedef INT (__stdcall *CON_WRITE_FUNC)(
48     IN PCON_STREAM Stream,
49     IN PCTCH szStr,
50     IN DWORD len);
51 
52 
53 INT
54 __stdcall
55 ConWrite(
56     IN PCON_STREAM Stream,
57     IN PCTCH szStr,
58     IN DWORD len);
59 
60 INT
61 ConStreamWrite(
62     IN PCON_STREAM Stream,
63     IN PCTCH szStr,
64     IN DWORD len);
65 
66 INT
67 ConPuts(
68     IN PCON_STREAM Stream,
69     IN PCWSTR szStr);
70 
71 INT
72 ConPrintfV(
73     IN PCON_STREAM Stream,
74     IN PCWSTR  szStr,
75     IN va_list args);
76 
77 INT
78 __cdecl
79 ConPrintf(
80     IN PCON_STREAM Stream,
81     IN PCWSTR szStr,
82     ...);
83 
84 INT
85 ConResPutsEx(
86     IN PCON_STREAM Stream,
87     IN HINSTANCE hInstance OPTIONAL,
88     IN UINT   uID,
89     IN LANGID LanguageId);
90 
91 INT
92 ConResPuts(
93     IN PCON_STREAM Stream,
94     IN UINT uID);
95 
96 INT
97 ConResPrintfExV(
98     IN PCON_STREAM Stream,
99     IN HINSTANCE hInstance OPTIONAL,
100     IN UINT    uID,
101     IN LANGID  LanguageId,
102     IN va_list args);
103 
104 INT
105 ConResPrintfV(
106     IN PCON_STREAM Stream,
107     IN UINT    uID,
108     IN va_list args);
109 
110 INT
111 __cdecl
112 ConResPrintfEx(
113     IN PCON_STREAM Stream,
114     IN HINSTANCE hInstance OPTIONAL,
115     IN UINT   uID,
116     IN LANGID LanguageId,
117     ...);
118 
119 INT
120 __cdecl
121 ConResPrintf(
122     IN PCON_STREAM Stream,
123     IN UINT uID,
124     ...);
125 
126 INT
127 ConMsgPuts(
128     IN PCON_STREAM Stream,
129     IN DWORD   dwFlags,
130     IN LPCVOID lpSource OPTIONAL,
131     IN DWORD   dwMessageId,
132     IN DWORD   dwLanguageId);
133 
134 INT
135 ConMsgPrintf2V(
136     IN PCON_STREAM Stream,
137     IN DWORD   dwFlags,
138     IN LPCVOID lpSource OPTIONAL,
139     IN DWORD   dwMessageId,
140     IN DWORD   dwLanguageId,
141     IN va_list args);
142 
143 INT
144 ConMsgPrintfV(
145     IN PCON_STREAM Stream,
146     IN DWORD   dwFlags,
147     IN LPCVOID lpSource OPTIONAL,
148     IN DWORD   dwMessageId,
149     IN DWORD   dwLanguageId,
150     IN va_list *Arguments OPTIONAL);
151 
152 INT
153 __cdecl
154 ConMsgPrintf(
155     IN PCON_STREAM Stream,
156     IN DWORD   dwFlags,
157     IN LPCVOID lpSource OPTIONAL,
158     IN DWORD   dwMessageId,
159     IN DWORD   dwLanguageId,
160     ...);
161 
162 INT
163 ConResMsgPrintfExV(
164     IN PCON_STREAM Stream,
165     IN HINSTANCE hInstance OPTIONAL,
166     IN DWORD   dwFlags,
167     IN UINT    uID,
168     IN LANGID  LanguageId,
169     IN va_list *Arguments OPTIONAL);
170 
171 INT
172 ConResMsgPrintfV(
173     IN PCON_STREAM Stream,
174     IN DWORD   dwFlags,
175     IN UINT    uID,
176     IN va_list *Arguments OPTIONAL);
177 
178 INT
179 __cdecl
180 ConResMsgPrintfEx(
181     IN PCON_STREAM Stream,
182     IN HINSTANCE hInstance OPTIONAL,
183     IN DWORD  dwFlags,
184     IN UINT   uID,
185     IN LANGID LanguageId,
186     ...);
187 
188 INT
189 __cdecl
190 ConResMsgPrintf(
191     IN PCON_STREAM Stream,
192     IN DWORD dwFlags,
193     IN UINT  uID,
194     ...);
195 
196 
197 
198 VOID
199 ConClearLine(IN PCON_STREAM Stream);
200 
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif  /* __OUTSTREAM_H__ */
207 
208 /* EOF */
209