ReactOS  0.4.14-dev-49-gfb4591c
console.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ConOutPuts(szStr)   ConPuts(StdOut, (szStr))
 
#define ConErrPuts(szStr)   ConPuts(StdErr, (szStr))
 
#define ConOutResPuts(uID)   ConResPuts(StdOut, (uID))
 
#define ConErrResPuts(uID)   ConResPuts(StdErr, (uID))
 
#define ConOutPrintf(szStr, ...)   ConPrintf(StdOut, (szStr), ##__VA_ARGS__)
 
#define ConErrPrintf(szStr, ...)   ConPrintf(StdErr, (szStr), ##__VA_ARGS__)
 
#define ConOutResPrintf(uID, ...)   ConResPrintf(StdOut, (uID), ##__VA_ARGS__)
 
#define ConErrResPrintf(uID, ...)   ConResPrintf(StdErr, (uID), ##__VA_ARGS__)
 
#define ConOutFormatMessage(MessageId, ...)   ConFormatMessage(StdOut, (MessageId), ##__VA_ARGS__)
 
#define ConErrFormatMessage(MessageId, ...)   ConFormatMessage(StdErr, (MessageId), ##__VA_ARGS__)
 

Functions

VOID ConInDummy (VOID)
 
VOID ConInDisable (VOID)
 
VOID ConInEnable (VOID)
 
VOID ConInFlush (VOID)
 
VOID ConInKey (PINPUT_RECORD)
 
VOID ConInString (LPTSTR, DWORD)
 
VOID ConOutChar (TCHAR)
 
VOID ConErrChar (TCHAR)
 
VOID __cdecl ConFormatMessage (PCON_STREAM Stream, DWORD MessageId,...)
 
BOOL ConPrintfVPaging (PCON_PAGER Pager, BOOL StartPaging, LPTSTR szFormat, va_list arg_ptr)
 
BOOL __cdecl ConOutPrintfPaging (BOOL StartPaging, LPTSTR szFormat,...)
 
VOID ConOutResPaging (BOOL StartPaging, UINT resID)
 
SHORT GetCursorX (VOID)
 
SHORT GetCursorY (VOID)
 
VOID GetCursorXY (PSHORT, PSHORT)
 
VOID SetCursorXY (SHORT, SHORT)
 
VOID GetScreenSize (PSHORT, PSHORT)
 
VOID SetCursorType (BOOL, BOOL)
 
BOOL ConSetTitle (IN LPCTSTR lpConsoleTitle)
 

Variables

UINT InputCodePage
 
UINT OutputCodePage
 
CON_SCREEN StdOutScreen
 
CON_PAGER StdOutPager
 

Macro Definition Documentation

◆ ConErrFormatMessage

#define ConErrFormatMessage (   MessageId,
  ... 
)    ConFormatMessage(StdErr, (MessageId), ##__VA_ARGS__)

Definition at line 57 of file console.h.

◆ ConErrPrintf

#define ConErrPrintf (   szStr,
  ... 
)    ConPrintf(StdErr, (szStr), ##__VA_ARGS__)

Definition at line 45 of file console.h.

◆ ConErrPuts

#define ConErrPuts (   szStr)    ConPuts(StdErr, (szStr))

Definition at line 33 of file console.h.

◆ ConErrResPrintf

#define ConErrResPrintf (   uID,
  ... 
)    ConResPrintf(StdErr, (uID), ##__VA_ARGS__)

Definition at line 51 of file console.h.

◆ ConErrResPuts

#define ConErrResPuts (   uID)    ConResPuts(StdErr, (uID))

Definition at line 39 of file console.h.

◆ ConOutFormatMessage

#define ConOutFormatMessage (   MessageId,
  ... 
)    ConFormatMessage(StdOut, (MessageId), ##__VA_ARGS__)

Definition at line 54 of file console.h.

◆ ConOutPrintf

#define ConOutPrintf (   szStr,
  ... 
)    ConPrintf(StdOut, (szStr), ##__VA_ARGS__)

Definition at line 42 of file console.h.

◆ ConOutPuts

#define ConOutPuts (   szStr)    ConPuts(StdOut, (szStr))

Definition at line 30 of file console.h.

◆ ConOutResPrintf

#define ConOutResPrintf (   uID,
  ... 
)    ConResPrintf(StdOut, (uID), ##__VA_ARGS__)

Definition at line 48 of file console.h.

◆ ConOutResPuts

#define ConOutResPuts (   uID)    ConResPuts(StdOut, (uID))

Definition at line 36 of file console.h.

Function Documentation

◆ ConErrChar()

VOID ConErrChar ( TCHAR  )

Definition at line 128 of file console.c.

129 {
130  ConWrite(StdErr, &c, 1);
131 }
const GLubyte * c
Definition: glext.h:8905
#define StdErr
Definition: stream.h:77
INT __stdcall ConWrite(IN PCON_STREAM Stream, IN PTCHAR szStr, IN DWORD len)
Definition: outstream.c:85

◆ ConFormatMessage()

VOID __cdecl ConFormatMessage ( PCON_STREAM  Stream,
DWORD  MessageId,
  ... 
)

Definition at line 133 of file console.c.

134 {
135  INT Len;
136  va_list arg_ptr;
137 
138  va_start(arg_ptr, MessageId);
141  NULL,
142  MessageId,
144  &arg_ptr);
145  va_end(arg_ptr);
146 
147  if (Len <= 0)
149 }
#define STRING_CONSOLE_ERROR
Definition: resource.h:6
int32_t INT
Definition: typedefs.h:56
INT ConMsgPrintfV(IN PCON_STREAM Stream, IN DWORD dwFlags, IN LPCVOID lpSource OPTIONAL, IN DWORD dwMessageId, IN DWORD dwLanguageId, IN va_list *Arguments OPTIONAL)
Definition: outstream.c:1030
#define va_end(ap)
Definition: acmsvcex.h:90
smooth NULL
Definition: ftsmooth.c:416
char * va_list
Definition: acmsvcex.h:78
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
INT __cdecl ConResPrintf(IN PCON_STREAM Stream, IN UINT uID,...)
Definition: outstream.c:781
#define Len
Definition: deflate.h:82
#define va_start(ap, A)
Definition: acmsvcex.h:91
_Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING Stream
Definition: fltkernel.h:1092
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50

◆ ConInDisable()

VOID ConInDisable ( VOID  )

Definition at line 36 of file console.c.

37 {
39  DWORD dwMode;
40 
41  GetConsoleMode(hInput, &dwMode);
42  dwMode &= ~ENABLE_PROCESSED_INPUT;
43  SetConsoleMode(hInput, dwMode);
44 }
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
#define STD_INPUT_HANDLE
Definition: winbase.h:264
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75

Referenced by FilePromptYN(), FilePromptYNA(), and PagePrompt().

◆ ConInDummy()

VOID ConInDummy ( VOID  )

◆ ConInEnable()

VOID ConInEnable ( VOID  )

Definition at line 46 of file console.c.

47 {
49  DWORD dwMode;
50 
51  GetConsoleMode(hInput, &dwMode);
52  dwMode |= ENABLE_PROCESSED_INPUT;
53  SetConsoleMode(hInput, dwMode);
54 }
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
#define STD_INPUT_HANDLE
Definition: winbase.h:264
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75

Referenced by FilePromptYN(), FilePromptYNA(), and PagePrompt().

◆ ConInFlush()

VOID ConInFlush ( VOID  )

Definition at line 56 of file console.c.

57 {
59 }
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:169
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
#define STD_INPUT_HANDLE
Definition: winbase.h:264

Referenced by CommandChoice().

◆ ConInKey()

VOID ConInKey ( PINPUT_RECORD  )

Definition at line 61 of file console.c.

62 {
64  DWORD dwRead;
65 
66  if (hInput == INVALID_HANDLE_VALUE)
67  WARN ("Invalid input handle!!!\n");
68 
69  do
70  {
71  ReadConsoleInput(hInput, lpBuffer, 1, &dwRead);
72  if (lpBuffer->EventType == KEY_EVENT &&
73  lpBuffer->Event.KeyEvent.bKeyDown)
74  {
75  break;
76  }
77  }
78  while (TRUE);
79 }
#define TRUE
Definition: types.h:120
BOOL WINAPI ReadConsoleInput(IN HANDLE hConsoleInput, OUT PINPUT_RECORD lpBuffer, IN DWORD nLength, OUT LPDWORD lpNumberOfEventsRead)
Definition: console.c:290
#define WARN(fmt,...)
Definition: debug.h:111
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define KEY_EVENT
Definition: wincon.h:122
#define STD_INPUT_HANDLE
Definition: winbase.h:264
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by CommandChoice(), FilePromptYN(), FilePromptYNA(), PagePrompt(), and ReadCommand().

◆ ConInString()

VOID ConInString ( LPTSTR  ,
DWORD   
)

Definition at line 81 of file console.c.

82 {
83  DWORD dwOldMode;
84  DWORD dwRead = 0;
85  HANDLE hFile;
86 
87  LPTSTR p;
88  PCHAR pBuf;
89 
90 #ifdef _UNICODE
91  pBuf = (PCHAR)cmd_alloc(dwLength - 1);
92 #else
93  pBuf = lpInput;
94 #endif
95  ZeroMemory(lpInput, dwLength * sizeof(TCHAR));
97  GetConsoleMode(hFile, &dwOldMode);
98 
100 
101  ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
102 
103 #ifdef _UNICODE
104  MultiByteToWideChar(InputCodePage, 0, pBuf, dwRead, lpInput, dwLength - 1);
105  cmd_free(pBuf);
106 #endif
107  for (p = lpInput; *p; p++)
108  {
109  if (*p == _T('\x0d'))
110  {
111  *p = _T('\0');
112  break;
113  }
114  }
115 
116  SetConsoleMode(hFile, dwOldMode);
117 }
signed char * PCHAR
Definition: retypes.h:7
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1571
#define ZeroMemory
Definition: winbase.h:1635
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define ENABLE_ECHO_INPUT
Definition: wincon.h:77
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1608
smooth NULL
Definition: ftsmooth.c:416
UINT InputCodePage
Definition: console.c:25
#define STD_INPUT_HANDLE
Definition: winbase.h:264
#define PCHAR
Definition: match.c:90
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
static DWORD DWORD * dwLength
Definition: fusion.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
_In_ HANDLE hFile
Definition: mswsock.h:90
#define cmd_alloc(size)
Definition: cmddbg.h:29
#define cmd_free(ptr)
Definition: cmddbg.h:31
#define MultiByteToWideChar
Definition: compat.h:100
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123

◆ ConOutChar()

VOID ConOutChar ( TCHAR  )

Definition at line 123 of file console.c.

124 {
125  ConWrite(StdOut, &c, 1);
126 }
const GLubyte * c
Definition: glext.h:8905
INT __stdcall ConWrite(IN PCON_STREAM Stream, IN PTCHAR szStr, IN DWORD len)
Definition: outstream.c:85
#define StdOut
Definition: stream.h:76

Referenced by Batch(), CheckCtrlBreak(), ClearCommandLine(), cmd_pause(), cmd_set(), cmd_ver(), CommandEcho(), EchoCommand(), FilePromptYN(), FilePromptYNA(), Initialize(), PagePrompt(), PrintCommandList(), PrintPrompt(), ReadCommand(), ReadLine(), and RunInstance().

◆ ConOutPrintfPaging()

BOOL __cdecl ConOutPrintfPaging ( BOOL  StartPaging,
LPTSTR  szFormat,
  ... 
)

Definition at line 171 of file console.c.

172 {
173  BOOL bRet;
174  va_list arg_ptr;
175 
176  va_start(arg_ptr, szFormat);
177  bRet = ConPrintfVPaging(&StdOutPager, StartPaging, szFormat, arg_ptr);
178  va_end(arg_ptr);
179  return bRet;
180 }
#define va_end(ap)
Definition: acmsvcex.h:90
unsigned int BOOL
Definition: ntddk_ex.h:94
char * va_list
Definition: acmsvcex.h:78
#define va_start(ap, A)
Definition: acmsvcex.h:91
CON_PAGER StdOutPager
Definition: console.c:30
BOOL ConPrintfVPaging(PCON_PAGER Pager, BOOL StartPaging, LPTSTR szFormat, va_list arg_ptr)
Definition: console.c:155

Referenced by cmd_type(), and CommandDir().

◆ ConOutResPaging()

VOID ConOutResPaging ( BOOL  StartPaging,
UINT  resID 
)

Definition at line 182 of file console.c.

183 {
184  ConResPaging(&StdOutPager, PagePrompt, StartPaging, resID);
185 }
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
BOOL ConResPaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN UINT uID)
Definition: pager.c:155
CON_PAGER StdOutPager
Definition: console.c:30

Referenced by cmd_beep(), cmd_call(), cmd_chdir(), cmd_cls(), cmd_copy(), cmd_ctty(), cmd_date(), cmd_for(), cmd_goto(), cmd_if(), cmd_mkdir(), cmd_move(), cmd_path(), cmd_pause(), cmd_prompt(), cmd_rename(), cmd_replace(), cmd_rmdir(), cmd_set(), cmd_shift(), cmd_start(), cmd_time(), cmd_title(), cmd_type(), cmd_ver(), cmd_verify(), cmd_vol(), CommandAlias(), CommandAssoc(), CommandChoice(), CommandColor(), CommandDelay(), CommandDelete(), CommandEcho(), CommandExit(), CommandFree(), CommandMemory(), CommandRem(), CommandScreen(), DirHelp(), Initialize(), invalid_switch(), and replace().

◆ ConPrintfVPaging()

BOOL ConPrintfVPaging ( PCON_PAGER  Pager,
BOOL  StartPaging,
LPTSTR  szFormat,
va_list  arg_ptr 
)

Definition at line 155 of file console.c.

156 {
157  // INT len;
158  TCHAR szOut[OUTPUT_BUFFER_SIZE];
159 
160  /* Return if no string has been given */
161  if (szFormat == NULL)
162  return TRUE;
163 
164  /*len =*/ _vstprintf(szOut, szFormat, arg_ptr);
165 
166  // return ConPutsPaging(Pager, PagePrompt, StartPaging, szOut);
167  return ConWritePaging(Pager, PagePrompt, StartPaging,
168  szOut, wcslen(szOut));
169 }
#define TRUE
Definition: types.h:120
static BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: more.c:51
#define _vstprintf
Definition: tchar.h:540
#define OUTPUT_BUFFER_SIZE
Definition: console.c:22
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
BOOL ConWritePaging(IN PCON_PAGER Pager, IN PAGE_PROMPT PagePrompt, IN BOOL StartPaging, IN PTCHAR szStr, IN DWORD len)
Definition: pager.c:38
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ConOutPrintfPaging(), and DirPrintf().

◆ ConSetTitle()

BOOL ConSetTitle ( IN LPCTSTR  lpConsoleTitle)

Definition at line 280 of file console.c.

281 {
282  /* Now really set the console title */
283  return SetConsoleTitle(lpConsoleTitle);
284 }
#define SetConsoleTitle
Definition: wincon.h:771

Referenced by cmd_title(), ResetConTitle(), and SetConTitle().

◆ GetCursorX()

SHORT GetCursorX ( VOID  )

Definition at line 210 of file console.c.

211 {
213 
215  return csbi.dwCursorPosition.X;
216 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
ULONG X
Definition: bl.h:1340
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265

Referenced by ReadCommand().

◆ GetCursorXY()

VOID GetCursorXY ( PSHORT  ,
PSHORT   
)

Definition at line 200 of file console.c.

201 {
203 
205 
206  *x = csbi.dwCursorPosition.X;
207  *y = csbi.dwCursorPosition.Y;
208 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
ULONG X
Definition: bl.h:1340
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
ULONG Y
Definition: bl.h:1341

Referenced by ReadCommand().

◆ GetCursorY()

SHORT GetCursorY ( VOID  )

Definition at line 218 of file console.c.

219 {
221 
223  return csbi.dwCursorPosition.Y;
224 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
ULONG Y
Definition: bl.h:1341

Referenced by PagePrompt(), and ReadCommand().

◆ GetScreenSize()

VOID GetScreenSize ( PSHORT  ,
PSHORT   
)

Definition at line 236 of file console.c.

237 {
239 
241  {
242  csbi.dwSize.X = 80;
243  csbi.dwSize.Y = 25;
244  }
245 
246  if (maxx) *maxx = csbi.dwSize.X;
247  if (maxy) *maxy = csbi.dwSize.Y;
248 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
SHORT maxy
Definition: cmdinput.c:116
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:544
ULONG X
Definition: bl.h:1340
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
SHORT maxx
Definition: cmdinput.c:115
ULONG Y
Definition: bl.h:1341

Referenced by CommandScreen(), DirPrintWideList(), and PagePrompt().

◆ SetCursorType()

VOID SetCursorType ( BOOL  ,
BOOL   
)

Definition at line 226 of file console.c.

227 {
229 
230  cci.dwSize = bInsert ? 10 : 99;
231  cci.bVisible = bVisible;
232 
234 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
BOOLEAN bVisible
Definition: blue.h:41
BOOL WINAPI SetConsoleCursorInfo(IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
Definition: console.c:567
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
static BOOL bInsert
Definition: cmdinput.c:121

Referenced by ReadCommand().

◆ SetCursorXY()

VOID SetCursorXY ( SHORT  ,
SHORT   
)

Definition at line 191 of file console.c.

192 {
193  COORD coPos;
194 
195  coPos.X = x;
196  coPos.Y = y;
198 }
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:152
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:590
ULONG X
Definition: bl.h:1340
#define STD_OUTPUT_HANDLE
Definition: winbase.h:265
Definition: bl.h:1338
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
ULONG Y
Definition: bl.h:1341

Referenced by ClearCommandLine(), CommandScreen(), PagePrompt(), and ReadCommand().

Variable Documentation

◆ InputCodePage

UINT InputCodePage

Definition at line 25 of file console.c.

Referenced by _tmain(), cmd_start(), ConInString(), Execute(), and ReadCommand().

◆ OutputCodePage

UINT OutputCodePage

Definition at line 26 of file console.c.

Referenced by _tmain(), BatchGetString(), cmd_start(), Execute(), FileGetString(), and Initialize().

◆ StdOutPager

CON_PAGER StdOutPager

Definition at line 30 of file console.c.

Referenced by ConOutPrintfPaging(), ConOutResPaging(), and DirPrintf().

◆ StdOutScreen

CON_SCREEN StdOutScreen

Definition at line 47 of file attrib.c.

Referenced by cmd_cls().