xref: /reactos/sdk/lib/conutils/outstream.h (revision 23373acb)
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)(IN PCON_STREAM, IN PTCHAR, IN DWORD);
43                                         // Stream,         szStr,     len
44 typedef INT (__stdcall *CON_WRITE_FUNC)(IN PCON_STREAM, IN PTCHAR, IN DWORD);
45 
46 
47 INT
48 __stdcall
49 ConWrite(
50     IN PCON_STREAM Stream,
51     IN PTCHAR szStr,
52     IN DWORD  len);
53 
54 INT
55 ConStreamWrite(
56     IN PCON_STREAM Stream,
57     IN PTCHAR szStr,
58     IN DWORD  len);
59 
60 INT
61 ConPuts(
62     IN PCON_STREAM Stream,
63     IN LPWSTR szStr);
64 
65 INT
66 ConPrintfV(
67     IN PCON_STREAM Stream,
68     IN LPWSTR  szStr,
69     IN va_list args);
70 
71 INT
72 __cdecl
73 ConPrintf(
74     IN PCON_STREAM Stream,
75     IN LPWSTR szStr,
76     ...);
77 
78 INT
79 ConResPutsEx(
80     IN PCON_STREAM Stream,
81     IN HINSTANCE hInstance OPTIONAL,
82     IN UINT   uID,
83     IN LANGID LanguageId);
84 
85 INT
86 ConResPuts(
87     IN PCON_STREAM Stream,
88     IN UINT uID);
89 
90 INT
91 ConResPrintfExV(
92     IN PCON_STREAM Stream,
93     IN HINSTANCE hInstance OPTIONAL,
94     IN UINT    uID,
95     IN LANGID  LanguageId,
96     IN va_list args);
97 
98 INT
99 ConResPrintfV(
100     IN PCON_STREAM Stream,
101     IN UINT    uID,
102     IN va_list args);
103 
104 INT
105 __cdecl
106 ConResPrintfEx(
107     IN PCON_STREAM Stream,
108     IN HINSTANCE hInstance OPTIONAL,
109     IN UINT   uID,
110     IN LANGID LanguageId,
111     ...);
112 
113 INT
114 __cdecl
115 ConResPrintf(
116     IN PCON_STREAM Stream,
117     IN UINT uID,
118     ...);
119 
120 INT
121 ConMsgPuts(
122     IN PCON_STREAM Stream,
123     IN DWORD   dwFlags,
124     IN LPCVOID lpSource OPTIONAL,
125     IN DWORD   dwMessageId,
126     IN DWORD   dwLanguageId);
127 
128 INT
129 ConMsgPrintf2V(
130     IN PCON_STREAM Stream,
131     IN DWORD   dwFlags,
132     IN LPCVOID lpSource OPTIONAL,
133     IN DWORD   dwMessageId,
134     IN DWORD   dwLanguageId,
135     IN va_list args);
136 
137 INT
138 ConMsgPrintfV(
139     IN PCON_STREAM Stream,
140     IN DWORD   dwFlags,
141     IN LPCVOID lpSource OPTIONAL,
142     IN DWORD   dwMessageId,
143     IN DWORD   dwLanguageId,
144     IN va_list *Arguments OPTIONAL);
145 
146 INT
147 __cdecl
148 ConMsgPrintf(
149     IN PCON_STREAM Stream,
150     IN DWORD   dwFlags,
151     IN LPCVOID lpSource OPTIONAL,
152     IN DWORD   dwMessageId,
153     IN DWORD   dwLanguageId,
154     ...);
155 
156 INT
157 ConResMsgPrintfExV(
158     IN PCON_STREAM Stream,
159     IN HINSTANCE hInstance OPTIONAL,
160     IN DWORD   dwFlags,
161     IN UINT    uID,
162     IN LANGID  LanguageId,
163     IN va_list *Arguments OPTIONAL);
164 
165 INT
166 ConResMsgPrintfV(
167     IN PCON_STREAM Stream,
168     IN DWORD   dwFlags,
169     IN UINT    uID,
170     IN va_list *Arguments OPTIONAL);
171 
172 INT
173 __cdecl
174 ConResMsgPrintfEx(
175     IN PCON_STREAM Stream,
176     IN HINSTANCE hInstance OPTIONAL,
177     IN DWORD  dwFlags,
178     IN UINT   uID,
179     IN LANGID LanguageId,
180     ...);
181 
182 INT
183 __cdecl
184 ConResMsgPrintf(
185     IN PCON_STREAM Stream,
186     IN DWORD dwFlags,
187     IN UINT  uID,
188     ...);
189 
190 
191 
192 VOID
193 ConClearLine(IN PCON_STREAM Stream);
194 
195 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif  /* __OUTSTREAM_H__ */
201 
202 /* EOF */
203