2 * CMD.H - header file for the modules in CMD.EXE
11 * Moved error messages in here
14 * Moved more error messages here.
16 * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
17 * Added compile date to version.
19 * 26-Feb-1999 (Eric Kohl)
20 * Introduced a new version string.
21 * Thanks to Emanuele Aliberti!
24 #ifndef _CMD_H_INCLUDED_
25 #define _CMD_H_INCLUDED_
36 #define BREAK_BATCHFILE 1
37 #define BREAK_OUTOFBATCH 2
39 #define BREAK_IGNORE 4
41 /* define some error messages */
44 #define D_OFF _T("off")
47 /* command line buffer length */
48 #define CMDLINE_LENGTH 8192
50 /* 16k = max buffer size */
51 #define BUFF_SIZE 16384
53 /* global variables */
56 extern HANDLE hConsole
;
58 extern WORD wDefColor
;
59 extern BOOL bCtrlBreak
;
60 extern BOOL bIgnoreEcho
;
62 extern INT nErrorLevel
;
65 extern OSVERSIONINFO osvi
;
69 /* Prototypes for ALIAS.C */
70 VOID
ExpandAlias (LPTSTR
, INT
);
71 INT
CommandAlias (LPTSTR
, LPTSTR
);
73 /* Prototypes for ATTRIB.C */
74 INT
CommandAttrib (LPTSTR
, LPTSTR
);
77 /* Prototypes for BEEP.C */
78 INT
cmd_beep (LPTSTR
, LPTSTR
);
81 /* Prototypes for CALL.C */
82 INT
cmd_call (LPTSTR
, LPTSTR
);
85 /* Prototypes for CHCP.C */
86 INT
CommandChcp (LPTSTR
, LPTSTR
);
89 /* Prototypes for CHOICE.C */
90 INT
CommandChoice (LPTSTR
, LPTSTR
);
93 /* Prototypes for CLS.C */
94 INT
cmd_cls (LPTSTR
, LPTSTR
);
97 /* Prototypes for CMD.C */
98 INT
ConvertULargeInteger (ULARGE_INTEGER num
, LPTSTR des
, INT len
, BOOL bPutSeperator
);
99 VOID
ParseCommandLine (LPTSTR
);
100 LPCTSTR
GetEnvVarOrSpecial ( LPCTSTR varName
);
101 VOID
AddBreakHandler (VOID
);
102 VOID
RemoveBreakHandler (VOID
);
103 VOID
DoCommand (LPTSTR line
);
104 int cmd_main (int argc
, const TCHAR
*argv
[]);
106 extern HANDLE CMD_ModuleHandle
;
109 /* Prototypes for CMDINPUT.C */
110 VOID
ReadCommand (LPTSTR
, INT
);
113 /* Prototypes for CMDTABLE.C */
114 #define CMD_SPECIAL 1
115 #define CMD_BATCHONLY 2
118 typedef struct tagCOMMAND
122 INT (*func
) (LPTSTR
, LPTSTR
);
123 } COMMAND
, *LPCOMMAND
;
125 extern COMMAND cmds
[]; /* The internal command table */
127 VOID
PrintCommandList (VOID
);
128 VOID
PrintCommandListDetail (VOID
);
131 LPCTSTR
GetParsedEnvVar ( LPCTSTR varName
, UINT
* varNameLen
, BOOL ModeSetA
);
133 /* Prototypes for COLOR.C */
134 VOID
SetScreenColor(WORD wArgColor
, BOOL bFill
);
135 INT
CommandColor (LPTSTR
, LPTSTR
);
137 VOID
ConInDummy (VOID
);
138 VOID
ConInDisable (VOID
);
139 VOID
ConInEnable (VOID
);
140 VOID
ConInFlush (VOID
);
141 VOID
ConInKey (PINPUT_RECORD
);
142 VOID
ConInString (LPTSTR
, DWORD
);
144 VOID
ConOutChar (TCHAR
);
145 VOID
ConOutPuts (LPTSTR
);
146 VOID
ConOutPrintf (LPTSTR
, ...);
147 INT
ConOutPrintfPaging (BOOL NewPage
, LPTSTR
, ...);
148 VOID
ConErrChar (TCHAR
);
149 VOID
ConErrPuts (LPTSTR
);
150 VOID
ConErrPrintf (LPTSTR
, ...);
151 VOID
ConOutFormatMessage (DWORD MessageId
, ...);
152 VOID
ConErrFormatMessage (DWORD MessageId
, ...);
154 SHORT
GetCursorX (VOID
);
155 SHORT
GetCursorY (VOID
);
156 VOID
GetCursorXY (PSHORT
, PSHORT
);
157 VOID
SetCursorXY (SHORT
, SHORT
);
159 VOID
GetScreenSize (PSHORT
, PSHORT
);
160 VOID
SetCursorType (BOOL
, BOOL
);
162 VOID
ConOutResPuts (UINT resID
);
163 VOID
ConErrResPuts (UINT resID
);
164 VOID
ConOutResPaging(BOOL NewPage
, UINT resID
);
166 /* Prototypes for COPY.C */
167 INT
cmd_copy (LPTSTR
, LPTSTR
);
170 /* Prototypes for DATE.C */
171 INT
cmd_date (LPTSTR
, LPTSTR
);
174 /* Prototypes for DEL.C */
175 INT
CommandDelete (LPTSTR
, LPTSTR
);
178 /* Prototypes for DELAY.C */
179 INT
CommandDelay (LPTSTR
, LPTSTR
);
182 /* Prototypes for DIR.C */
183 INT
CommandDir (LPTSTR
, LPTSTR
);
186 /* Prototypes for DIRSTACK.C */
187 VOID
InitDirectoryStack (VOID
);
188 VOID
DestroyDirectoryStack (VOID
);
189 INT
GetDirectoryStackDepth (VOID
);
190 INT
CommandPushd (LPTSTR
, LPTSTR
);
191 INT
CommandPopd (LPTSTR
, LPTSTR
);
192 INT
CommandDirs (LPTSTR
, LPTSTR
);
195 /* Prototypes for ECHO.C */
196 INT
CommandEcho (LPTSTR
, LPTSTR
);
197 INT
CommandEchos (LPTSTR
, LPTSTR
);
198 INT
CommandEchoerr (LPTSTR
, LPTSTR
);
199 INT
CommandEchoserr (LPTSTR
, LPTSTR
);
202 /* Prototypes for ERROR.C */
203 VOID
ErrorMessage (DWORD
, LPTSTR
, ...);
205 VOID
error_no_pipe (VOID
);
206 VOID
error_bad_command (VOID
);
207 VOID
error_invalid_drive (VOID
);
208 VOID
error_req_param_missing (VOID
);
209 VOID
error_sfile_not_found (LPTSTR
);
210 VOID
error_file_not_found (VOID
);
211 VOID
error_path_not_found (VOID
);
212 VOID
error_too_many_parameters (LPTSTR
);
213 VOID
error_parameter_format(TCHAR
);
214 VOID
error_invalid_switch (TCHAR
);
215 VOID
error_invalid_parameter_format (LPTSTR
);
216 VOID
error_out_of_memory (VOID
);
217 VOID
error_syntax (LPTSTR
);
219 VOID
msg_pause (VOID
);
222 /* Prototypes for FILECOMP.C */
223 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
224 VOID
CompleteFilename (LPTSTR
, UINT
);
225 INT
ShowCompletionMatches (LPTSTR
, INT
);
227 #ifdef FEATURE_4NT_FILENAME_COMPLETION
228 VOID
CompleteFilename (LPTSTR
, BOOL
, LPTSTR
, UINT
);
232 /* Prototypes for FOR.C */
233 INT
cmd_for (LPTSTR
, LPTSTR
);
236 /* Prototypes for FREE.C */
237 INT
CommandFree (LPTSTR
, LPTSTR
);
240 /* Prototypes for GOTO.C */
241 INT
cmd_goto (LPTSTR
, LPTSTR
);
244 /* Prototypes for HISTORY.C */
245 #ifdef FEATURE_HISTORY
246 LPCTSTR
PeekHistory(INT
);
247 VOID
History (INT
, LPTSTR
);/*add entries browse history*/
248 VOID
History_move_to_bottom(VOID
);/*F3*/
249 VOID
InitHistory(VOID
);
250 VOID
CleanHistory(VOID
);
251 VOID
History_del_current_entry(LPTSTR str
);/*CTRL-D*/
252 INT
CommandHistory (LPTSTR cmd
, LPTSTR param
);
256 /* Prototypes for INTERNAL.C */
257 VOID
InitLastPath (VOID
);
258 VOID
FreeLastPath (VOID
);
259 INT
cmd_chdir (LPTSTR
, LPTSTR
);
260 INT
cmd_mkdir (LPTSTR
, LPTSTR
);
261 INT
cmd_rmdir (LPTSTR
, LPTSTR
);
262 INT
CommandExit (LPTSTR
, LPTSTR
);
263 INT
CommandRem (LPTSTR
, LPTSTR
);
264 INT
CommandShowCommands (LPTSTR
, LPTSTR
);
265 INT
CommandShowCommandsDetail (LPTSTR
, LPTSTR
);
267 /* Prototypes for LABEL.C */
268 INT
cmd_label (LPTSTR
, LPTSTR
);
271 /* Prototypes for LOCALE.C */
272 extern TCHAR cDateSeparator
;
273 extern INT nDateFormat
;
274 extern TCHAR cTimeSeparator
;
275 extern INT nTimeFormat
;
276 extern TCHAR cThousandSeparator
;
277 extern TCHAR cDecimalSeparator
;
278 extern INT nNumberGroups
;
281 VOID
InitLocale (VOID
);
282 VOID
PrintDate (VOID
);
283 VOID
PrintTime (VOID
);
286 extern UINT InputCodePage
;
287 extern UINT OutputCodePage
;
289 /* Prototypes for MEMORY.C */
290 INT
CommandMemory (LPTSTR
, LPTSTR
);
293 /* Prototypes for MISC.C */
294 INT
GetRootPath(TCHAR
*InPath
,TCHAR
*OutPath
,INT size
);
295 BOOL
SetRootPath(TCHAR
*InPath
);
296 TCHAR
cgetchar (VOID
);
297 BOOL
CheckCtrlBreak (INT
);
298 BOOL
add_entry (LPINT ac
, LPTSTR
**arg
, LPCTSTR entry
);
299 LPTSTR
*split (LPTSTR
, LPINT
, BOOL
);
300 VOID
freep (LPTSTR
*);
301 LPTSTR
_stpcpy (LPTSTR
, LPCTSTR
);
302 BOOL
IsValidPathName (LPCTSTR
);
303 BOOL
IsExistingFile (LPCTSTR
);
304 BOOL
IsExistingDirectory (LPCTSTR
);
305 BOOL
FileGetString (HANDLE
, LPTSTR
, INT
);
306 VOID
GetPathCase(TCHAR
*, TCHAR
*);
311 #define PROMPT_BREAK 3
313 INT
PagePrompt (VOID
);
314 INT
FilePromptYN (LPTSTR
, ...);
315 INT
FilePromptYNA (LPTSTR
, ...);
318 /* Prototypes for MOVE.C */
319 INT
cmd_move (LPTSTR
, LPTSTR
);
322 /* Prototypes for MSGBOX.C */
323 INT
CommandMsgbox (LPTSTR
, LPTSTR
);
326 /* Prototypes from PATH.C */
327 INT
cmd_path (LPTSTR
, LPTSTR
);
330 /* Prototypes from PROMPT.C */
331 VOID
PrintPrompt (VOID
);
332 INT
cmd_prompt (LPTSTR
, LPTSTR
);
335 /* Prototypes for REDIR.C */
336 #define INPUT_REDIRECTION 1
337 #define OUTPUT_REDIRECTION 2
338 #define OUTPUT_APPEND 4
339 #define ERROR_REDIRECTION 8
340 #define ERROR_APPEND 16
341 INT
GetRedirection (LPTSTR
, LPTSTR
, LPTSTR
, LPTSTR
, LPINT
);
344 /* Prototypes for REN.C */
345 INT
cmd_rename (LPTSTR
, LPTSTR
);
347 /* Prototypes for REN.C */
348 INT
cmd_replace (LPTSTR
, LPTSTR
);
350 /* Prototypes for SCREEN.C */
351 INT
CommandScreen (LPTSTR
, LPTSTR
);
354 /* Prototypes for SET.C */
355 INT
cmd_set (LPTSTR
, LPTSTR
);
357 /* Prototypes for SETLOCAL.C */
358 INT
cmd_setlocal (LPTSTR
, LPTSTR
);
359 INT
cmd_endlocal (LPTSTR
, LPTSTR
);
361 /* Prototypes for START.C */
362 INT
cmd_start (LPTSTR
, LPTSTR
);
365 /* Prototypes for STRTOCLR.C */
366 BOOL
StringToColor (LPWORD
, LPTSTR
*);
369 /* Prototypes for TIME.C */
370 INT
cmd_time (LPTSTR
, LPTSTR
);
373 /* Prototypes for TIMER.C */
374 INT
CommandTimer (LPTSTR cmd
, LPTSTR param
);
377 /* Prototypes for TITLE.C */
378 INT
cmd_title (LPTSTR
, LPTSTR
);
381 /* Prototypes for TYPE.C */
382 INT
cmd_type (LPTSTR
, LPTSTR
);
385 /* Prototypes for VER.C */
386 VOID
ShortVersion (VOID
);
387 INT
cmd_ver (LPTSTR
, LPTSTR
);
390 /* Prototypes for VERIFY.C */
391 INT
cmd_verify (LPTSTR
, LPTSTR
);
394 /* Prototypes for VOL.C */
395 INT
cmd_vol (LPTSTR
, LPTSTR
);
398 /* Prototypes for WHERE.C */
399 BOOL
SearchForExecutable (LPCTSTR
, LPTSTR
);
401 /* Prototypes for WINDOW.C */
402 INT
CommandActivate (LPTSTR
, LPTSTR
);
403 INT
CommandWindow (LPTSTR
, LPTSTR
);
406 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
407 int cmd_if(TCHAR
*, TCHAR
*);
408 int cmd_pause(TCHAR
*, TCHAR
*);
409 int cmd_shift(TCHAR
*, TCHAR
*);
411 #endif /* _CMD_H_INCLUDED_ */