ReactOS 0.4.16-dev-306-g647d351
replace.h File Reference
#include <windows.h>
#include <tchar.h>
#include <stdlib.h>
#include <conutils.h>
#include "resource.h"
Include dependency graph for replace.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define RC_STRING_MAX_SIZE   3072
 
#define PROMPT_NO   0
 
#define PROMPT_YES   1
 
#define PROMPT_ALL   2
 
#define PROMPT_BREAK   3
 
#define BUFF_SIZE   16384
 
#define ConOutResPuts(uID)    ConResPuts(StdOut, (uID))
 
#define ConOutResPrintf(uID, ...)    ConResPrintf(StdOut, (uID), ##__VA_ARGS__)
 
#define ConOutFormatMessage(MessageId, ...)    ConFormatMessage(StdOut, (MessageId), ##__VA_ARGS__)
 

Functions

VOID ConInString (LPTSTR lpInput, DWORD dwLength)
 
VOID __cdecl ConFormatMessage (PCON_STREAM Stream, DWORD MessageId,...)
 
VOID ConOutChar (TCHAR c)
 
VOID GetPathCase (TCHAR *Path, TCHAR *OutPath)
 
BOOL IsExistingFile (IN LPCTSTR pszPath)
 
BOOL IsExistingDirectory (IN LPCTSTR pszPath)
 
INT FilePromptYNA (UINT resID)
 
VOID msg_pause (VOID)
 
TCHAR cgetchar (VOID)
 
INT GetRootPath (IN LPCTSTR InPath, OUT LPTSTR OutPath, IN INT size)
 

Variables

BOOL bCtrlBreak
 

Macro Definition Documentation

◆ BUFF_SIZE

#define BUFF_SIZE   16384

Definition at line 26 of file replace.h.

◆ ConOutFormatMessage

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

Definition at line 34 of file replace.h.

◆ ConOutResPrintf

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

Definition at line 31 of file replace.h.

◆ ConOutResPuts

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

Definition at line 28 of file replace.h.

◆ PROMPT_ALL

#define PROMPT_ALL   2

Definition at line 22 of file replace.h.

◆ PROMPT_BREAK

#define PROMPT_BREAK   3

Definition at line 23 of file replace.h.

◆ PROMPT_NO

#define PROMPT_NO   0

Definition at line 20 of file replace.h.

◆ PROMPT_YES

#define PROMPT_YES   1

Definition at line 21 of file replace.h.

◆ RC_STRING_MAX_SIZE

#define RC_STRING_MAX_SIZE   3072

Definition at line 18 of file replace.h.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 11 of file replace.h.

Function Documentation

◆ cgetchar()

TCHAR cgetchar ( VOID  )

Definition at line 242 of file util.c.

243{
245 INPUT_RECORD irBuffer;
246 DWORD dwRead;
247
248 do
249 {
250 ReadConsoleInput (hInput, &irBuffer, 1, &dwRead);
251 if ((irBuffer.EventType == KEY_EVENT) &&
252 (irBuffer.Event.KeyEvent.bKeyDown != FALSE))
253 {
254 if (irBuffer.Event.KeyEvent.dwControlKeyState &
256 {
257 if (irBuffer.Event.KeyEvent.wVirtualKeyCode == 'C')
258 {
260 break;
261 }
262 }
263 else if ((irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
264 (irBuffer.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
266 {
267 // Nothing to do
268 }
269 else
270 {
271 break;
272 }
273 }
274 }
275 while (TRUE);
276
277#ifndef _UNICODE
278 return irBuffer.Event.KeyEvent.uChar.AsciiChar;
279#else
280 return irBuffer.Event.KeyEvent.uChar.UnicodeChar;
281#endif /* _UNICODE */
282}
BOOL bCtrlBreak
Definition: util.c:11
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
union _INPUT_RECORD::@3286 Event
WORD EventType
Definition: wincon.h:273
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:275
union _KEY_EVENT_RECORD::@3285 uChar
DWORD dwControlKeyState
Definition: wincon.h:248
WORD wVirtualKeyCode
Definition: wincon.h:242
WCHAR UnicodeChar
Definition: wincon.h:245
#define STD_INPUT_HANDLE
Definition: winbase.h:293
#define LEFT_CTRL_PRESSED
Definition: wincon.h:140
#define ReadConsoleInput
Definition: wincon.h:778
#define KEY_EVENT
Definition: wincon.h:128
#define RIGHT_CTRL_PRESSED
Definition: wincon.h:139
#define VK_CONTROL
Definition: winuser.h:2206
#define VK_SHIFT
Definition: winuser.h:2205
#define VK_MENU
Definition: winuser.h:2207

Referenced by cmd_pause(), and cmd_replace().

◆ ConFormatMessage()

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

Definition at line 215 of file util.c.

216{
217 INT Len;
218 va_list arg_ptr;
219
220 va_start(arg_ptr, MessageId);
223 NULL,
224 MessageId,
226 &arg_ptr);
227 va_end(arg_ptr);
228
229 if (Len <= 0)
231}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define STRING_CONSOLE_ERROR
Definition: resource.h:6
void ConResPrintf(FILE *fp, UINT nID,...)
Definition: fc.c:33
#define Len
Definition: deflate.h:82
#define NULL
Definition: types.h:112
static IStream Stream
Definition: htmldoc.c:1115
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 LANG_USER_DEFAULT
Definition: tnerror.cpp:50
int32_t INT
Definition: typedefs.h:58
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449

◆ ConInString()

VOID ConInString ( LPTSTR  lpInput,
DWORD  dwLength 
)

Definition at line 172 of file util.c.

173{
174 DWORD dwOldMode;
175 DWORD dwRead = 0;
177
178 LPTSTR p;
179 PCHAR pBuf;
180
181#ifdef _UNICODE
182 pBuf = (PCHAR)malloc(dwLength - 1);
183#else
184 pBuf = lpInput;
185#endif
186 ZeroMemory(lpInput, dwLength * sizeof(TCHAR));
188 GetConsoleMode(hFile, &dwOldMode);
189
191
192 ReadFile(hFile, (PVOID)pBuf, dwLength - 1, &dwRead, NULL);
193
194#ifdef _UNICODE
195 MultiByteToWideChar(GetConsoleCP(), 0, pBuf, dwRead, lpInput, dwLength - 1);
196 free(pBuf);
197#endif
198 for (p = lpInput; *p; p++)
199 {
200 if (*p == _T('\r')) // Terminate at the carriage-return.
201 {
202 *p = _T('\0');
203 break;
204 }
205 }
206
207 SetConsoleMode(hFile, dwOldMode);
208}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define MultiByteToWideChar
Definition: compat.h:110
static DWORD DWORD * dwLength
Definition: fusion.c:86
BOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode)
Definition: console.c:1569
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode)
Definition: console.c:1606
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleCP(VOID)
Definition: console.c:2391
GLfloat GLfloat p
Definition: glext.h:8902
#define PCHAR
Definition: match.c:90
_In_ HANDLE hFile
Definition: mswsock.h:90
char * PCHAR
Definition: typedefs.h:51
#define _T(x)
Definition: vfdio.h:22
#define ZeroMemory
Definition: winbase.h:1737
#define ENABLE_ECHO_INPUT
Definition: wincon.h:80
#define ENABLE_LINE_INPUT
Definition: wincon.h:79
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:78
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192

◆ ConOutChar()

VOID ConOutChar ( TCHAR  c)

Definition at line 233 of file util.c.

234{
235 ConWrite(StdOut, &c, 1);
236}
#define StdOut
Definition: fc.c:14
const GLubyte * c
Definition: glext.h:8905
INT __stdcall ConWrite(IN PCON_STREAM Stream, IN PCTCH szStr, IN DWORD len)
Definition: outstream.c:85

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

◆ FilePromptYNA()

INT FilePromptYNA ( UINT  resID)

Definition at line 110 of file util.c.

111{
113// TCHAR cKey = 0;
114// LPTSTR szKeys = _T("yna");
115
116 TCHAR szIn[10];
117 LPTSTR p;
118
119 if (resID != 0)
120 ConOutResPrintf (resID);
121
122 /* preliminary fix */
123 ConInString(szIn, 10);
124
125 _tcsupr (szIn);
126 for (p = szIn; _istspace (*p); p++)
127 ;
128
130
131 if (_tcsncmp(p, &szMsg[0], 1) == 0)
132 return PROMPT_YES;
133 else if (_tcsncmp(p, &szMsg[1], 1) == 0)
134 return PROMPT_NO;
135 else if (_tcsncmp(p, &szMsg[2], 1) == 0)
136 return PROMPT_ALL;
137#if 0
138 else if (*p == _T('\03'))
139 return PROMPT_BREAK;
140#endif
141
142 return PROMPT_NO;
143
144 /* unfinished solution */
145#if 0
147 ConInDisable();
148
149 do
150 {
151 ConInKey (&ir);
152 cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar);
153 if (_tcschr (szKeys, cKey[0]) == NULL)
154 cKey = 0;
155 }
156 while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
157 (ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
158 (ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
159
161 ConInEnable();
162
163 if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
164 ((ir.Event.KeyEvent.wVirtualKeyCode == _T('C')) &&
165 (ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
166 return PROMPT_BREAK;
167
168 return PROMPT_YES;
169#endif
170}
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
#define STRING_COPY_OPTION
Definition: resource.h:22
VOID ConInString(LPTSTR lpInput, DWORD dwLength)
Definition: util.c:172
VOID AddBreakHandler(VOID)
Definition: cmd.c:1844
VOID RemoveBreakHandler(VOID)
Definition: cmd.c:1850
VOID ConInDisable(VOID)
Definition: console.c:36
VOID ConInEnable(VOID)
Definition: console.c:46
VOID ConInKey(PINPUT_RECORD lpBuffer)
Definition: console.c:61
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define _istspace
Definition: tchar.h:1504
#define _tcsupr
Definition: tchar.h:1467
#define _tcsncmp
Definition: tchar.h:1428
#define _tcschr
Definition: tchar.h:1406
#define _totlower
Definition: tchar.h:1511
#define ConOutResPrintf(uID,...)
Definition: replace.h:31
#define PROMPT_YES
Definition: replace.h:21
#define PROMPT_NO
Definition: replace.h:20
#define PROMPT_ALL
Definition: replace.h:22
#define PROMPT_BREAK
Definition: replace.h:23
#define LoadString
Definition: winuser.h:5831
#define VK_ESCAPE
Definition: winuser.h:2217

Referenced by cmd_rmdir(), CopyOverwrite(), DeleteFiles(), MoveOverwrite(), and replace().

◆ GetPathCase()

VOID GetPathCase ( TCHAR Path,
TCHAR OutPath 
)

Definition at line 53 of file util.c.

54{
55 UINT i = 0;
56 TCHAR TempPath[MAX_PATH];
57 WIN32_FIND_DATA FindFileData;
58 HANDLE hFind;
59 _tcscpy(TempPath, _T(""));
60 _tcscpy(OutPath, _T(""));
61
62 for(i = 0; i < _tcslen(Path); i++)
63 {
64 if (Path[i] != _T('\\'))
65 {
66 _tcsncat(TempPath, &Path[i], 1);
67 if (i != _tcslen(Path) - 1)
68 continue;
69 }
70 /* Handle the base part of the path different.
71 Because if you put it into findfirstfile, it will
72 return your current folder */
73 if (_tcslen(TempPath) == 2 && TempPath[1] == _T(':'))
74 {
75 _tcscat(OutPath, TempPath);
76 _tcscat(OutPath, _T("\\"));
77 _tcscat(TempPath, _T("\\"));
78 }
79 else
80 {
81 hFind = FindFirstFile(TempPath,&FindFileData);
82 if (hFind == INVALID_HANDLE_VALUE)
83 {
84 _tcscpy(OutPath, Path);
85 return;
86 }
87 _tcscat(TempPath, _T("\\"));
88 _tcscat(OutPath, FindFileData.cFileName);
89 _tcscat(OutPath, _T("\\"));
90 FindClose(hFind);
91 }
92 }
93}
PRTL_UNICODE_STRING_BUFFER Path
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define _tcscat
Definition: tchar.h:622
#define _tcscpy
Definition: tchar.h:623
#define _tcsncat
Definition: tchar.h:1408
unsigned int UINT
Definition: ndis.h:50
#define FindFirstFile
Definition: winbase.h:3807
#define _tcslen
Definition: xmlstorage.h:198

Referenced by replace(), and SetRootPath().

◆ GetRootPath()

INT GetRootPath ( IN LPCTSTR  InPath,
OUT LPTSTR  OutPath,
IN INT  size 
)

Definition at line 21 of file util.c.

25{
26 if (InPath[0] && InPath[1] == _T(':'))
27 {
28 INT t = 0;
29
30 if ((InPath[0] >= _T('0')) && (InPath[0] <= _T('9')))
31 {
32 t = (InPath[0] - _T('0')) + 28;
33 }
34 else if ((InPath[0] >= _T('a')) && (InPath[0] <= _T('z')))
35 {
36 t = (InPath[0] - _T('a')) + 1;
37 }
38 else if ((InPath[0] >= _T('A')) && (InPath[0] <= _T('Z')))
39 {
40 t = (InPath[0] - _T('A')) + 1;
41 }
42
43 return (_tgetdcwd(t, OutPath, size) == NULL);
44 }
45
46 /* Get current directory */
47 return !GetCurrentDirectory(size, OutPath);
48}
GLdouble GLdouble t
Definition: gl.h:2047
GLsizeiptr size
Definition: glext.h:5919
#define _tgetdcwd
Definition: tchar.h:674
#define GetCurrentDirectory
Definition: winbase.h:3830

Referenced by cmd_copy(), cmd_replace(), CommandDelete(), GetDirectory(), and getPath().

◆ IsExistingDirectory()

BOOL IsExistingDirectory ( IN LPCTSTR  pszPath)

Definition at line 104 of file util.c.

105{
106 DWORD attr = GetFileAttributes(pszPath);
108}
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
Definition: cookie.c:202
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GetFileAttributes
Definition: winbase.h:3840

Referenced by cmd_copy(), cmd_move(), cmd_replace(), DeleteFiles(), GetDirectory(), ProcessDirectory(), recFindSubDirs(), and ResolvePattern().

◆ IsExistingFile()

BOOL IsExistingFile ( IN LPCTSTR  pszPath)

◆ msg_pause()

VOID msg_pause ( VOID  )

Definition at line 210 of file util.c.

211{
213}
#define STRING_ERROR_D_PAUSEMSG
Definition: resource.h:27
#define ConOutResPuts(uID)
Definition: replace.h:28

Referenced by cmd_pause(), and cmd_replace().

Variable Documentation

◆ bCtrlBreak