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
);
73 /* Prototypes for ATTRIB.C */
74 INT
CommandAttrib (LPTSTR
);
77 /* Prototypes for BEEP.C */
78 INT
cmd_beep (LPTSTR
);
81 /* Prototypes for CALL.C */
82 INT
cmd_call (LPTSTR
);
85 /* Prototypes for CHCP.C */
86 INT
CommandChcp (LPTSTR
);
89 /* Prototypes for CHOICE.C */
90 INT
CommandChoice (LPTSTR
);
93 /* Prototypes for CLS.C */
97 /* Prototypes for CMD.C */
98 INT
ConvertULargeInteger (ULARGE_INTEGER num
, LPTSTR des
, INT len
, BOOL bPutSeperator
);
99 VOID
ParseCommandLine (LPTSTR
);
100 struct _PARSED_COMMAND
;
101 BOOL
ExecuteCommand(struct _PARSED_COMMAND
*Cmd
);
102 LPCTSTR
GetEnvVarOrSpecial ( LPCTSTR varName
);
103 VOID
AddBreakHandler (VOID
);
104 VOID
RemoveBreakHandler (VOID
);
105 BOOL
SubstituteForVars(TCHAR
*Src
, TCHAR
*Dest
);
106 LPTSTR
DoDelayedExpansion(LPTSTR Line
);
107 BOOL
DoCommand (LPTSTR line
);
108 BOOL
ReadLine(TCHAR
*commandline
, BOOL bMore
);
109 int cmd_main (int argc
, const TCHAR
*argv
[]);
111 extern HANDLE CMD_ModuleHandle
;
114 /* Prototypes for CMDINPUT.C */
115 VOID
ReadCommand (LPTSTR
, INT
);
118 /* Prototypes for CMDTABLE.C */
119 #define CMD_SPECIAL 1
120 #define CMD_BATCHONLY 2
123 typedef struct tagCOMMAND
128 } COMMAND
, *LPCOMMAND
;
130 extern COMMAND cmds
[]; /* The internal command table */
132 VOID
PrintCommandList (VOID
);
133 VOID
PrintCommandListDetail (VOID
);
136 LPCTSTR
GetParsedEnvVar ( LPCTSTR varName
, UINT
* varNameLen
, BOOL ModeSetA
);
138 /* Prototypes for COLOR.C */
139 VOID
SetScreenColor(WORD wArgColor
, BOOL bFill
);
140 INT
CommandColor (LPTSTR
);
142 VOID
ConInDummy (VOID
);
143 VOID
ConInDisable (VOID
);
144 VOID
ConInEnable (VOID
);
145 VOID
ConInFlush (VOID
);
146 VOID
ConInKey (PINPUT_RECORD
);
147 VOID
ConInString (LPTSTR
, DWORD
);
149 VOID
ConOutChar (TCHAR
);
150 VOID
ConOutPuts (LPTSTR
);
151 VOID
ConOutPrintf (LPTSTR
, ...);
152 INT
ConOutPrintfPaging (BOOL NewPage
, LPTSTR
, ...);
153 VOID
ConErrChar (TCHAR
);
154 VOID
ConErrPuts (LPTSTR
);
155 VOID
ConErrPrintf (LPTSTR
, ...);
156 VOID
ConOutFormatMessage (DWORD MessageId
, ...);
157 VOID
ConErrFormatMessage (DWORD MessageId
, ...);
159 SHORT
GetCursorX (VOID
);
160 SHORT
GetCursorY (VOID
);
161 VOID
GetCursorXY (PSHORT
, PSHORT
);
162 VOID
SetCursorXY (SHORT
, SHORT
);
164 VOID
GetScreenSize (PSHORT
, PSHORT
);
165 VOID
SetCursorType (BOOL
, BOOL
);
167 VOID
ConOutResPuts (UINT resID
);
168 VOID
ConErrResPuts (UINT resID
);
169 VOID
ConOutResPrintf (UINT resID
, ...);
170 VOID
ConErrResPrintf (UINT resID
, ...);
171 VOID
ConOutResPaging(BOOL NewPage
, UINT resID
);
173 /* Prototypes for COPY.C */
174 INT
cmd_copy (LPTSTR
);
177 /* Prototypes for DATE.C */
178 INT
cmd_date (LPTSTR
);
181 /* Prototypes for DEL.C */
182 INT
CommandDelete (LPTSTR
);
185 /* Prototypes for DELAY.C */
186 INT
CommandDelay (LPTSTR
);
189 /* Prototypes for DIR.C */
190 INT
CommandDir (LPTSTR
);
193 /* Prototypes for DIRSTACK.C */
194 VOID
InitDirectoryStack (VOID
);
195 VOID
DestroyDirectoryStack (VOID
);
196 INT
GetDirectoryStackDepth (VOID
);
197 INT
CommandPushd (LPTSTR
);
198 INT
CommandPopd (LPTSTR
);
199 INT
CommandDirs (LPTSTR
);
202 /* Prototypes for ECHO.C */
203 INT
CommandEcho (LPTSTR
);
204 INT
CommandEchos (LPTSTR
);
205 INT
CommandEchoerr (LPTSTR
);
206 INT
CommandEchoserr (LPTSTR
);
209 /* Prototypes for ERROR.C */
210 VOID
ErrorMessage (DWORD
, LPTSTR
, ...);
212 VOID
error_no_pipe (VOID
);
213 VOID
error_bad_command (VOID
);
214 VOID
error_invalid_drive (VOID
);
215 VOID
error_req_param_missing (VOID
);
216 VOID
error_sfile_not_found (LPTSTR
);
217 VOID
error_file_not_found (VOID
);
218 VOID
error_path_not_found (VOID
);
219 VOID
error_too_many_parameters (LPTSTR
);
220 VOID
error_parameter_format(TCHAR
);
221 VOID
error_invalid_switch (TCHAR
);
222 VOID
error_invalid_parameter_format (LPTSTR
);
223 VOID
error_out_of_memory (VOID
);
224 VOID
error_syntax (LPTSTR
);
226 VOID
msg_pause (VOID
);
229 /* Prototypes for FILECOMP.C */
230 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
231 VOID
CompleteFilename (LPTSTR
, UINT
);
232 INT
ShowCompletionMatches (LPTSTR
, INT
);
234 #ifdef FEATURE_4NT_FILENAME_COMPLETION
235 VOID
CompleteFilename (LPTSTR
, BOOL
, LPTSTR
, UINT
);
239 /* Prototypes for FOR.C */
240 #define FOR_DIRS 1 /* /D */
241 #define FOR_F 2 /* /F */
242 #define FOR_LOOP 4 /* /L */
243 #define FOR_RECURSIVE 8 /* /R */
244 INT
cmd_for (LPTSTR
);
245 BOOL
ExecuteFor(struct _PARSED_COMMAND
*Cmd
);
248 /* Prototypes for FREE.C */
249 INT
CommandFree (LPTSTR
);
252 /* Prototypes for GOTO.C */
253 INT
cmd_goto (LPTSTR
);
256 /* Prototypes for HISTORY.C */
257 #ifdef FEATURE_HISTORY
258 LPCTSTR
PeekHistory(INT
);
259 VOID
History (INT
, LPTSTR
);/*add entries browse history*/
260 VOID
History_move_to_bottom(VOID
);/*F3*/
261 VOID
InitHistory(VOID
);
262 VOID
CleanHistory(VOID
);
263 VOID
History_del_current_entry(LPTSTR str
);/*CTRL-D*/
264 INT
CommandHistory (LPTSTR param
);
268 /* Prototypes for IF.C */
269 #define IFFLAG_NEGATE 1 /* NOT */
270 #define IFFLAG_IGNORECASE 2 /* /I */
271 enum { IF_CMDEXTVERSION
, IF_DEFINED
, IF_ERRORLEVEL
, IF_EXIST
,
272 IF_STRINGEQ
, /* == */
273 IF_EQU
, IF_GTR
, IF_GEQ
, IF_LSS
, IF_LEQ
, IF_NEQ
};
274 BOOL
ExecuteIf(struct _PARSED_COMMAND
*Cmd
);
277 /* Prototypes for INTERNAL.C */
278 VOID
InitLastPath (VOID
);
279 VOID
FreeLastPath (VOID
);
280 INT
cmd_chdir (LPTSTR
);
281 INT
cmd_mkdir (LPTSTR
);
282 INT
cmd_rmdir (LPTSTR
);
283 INT
CommandExit (LPTSTR
);
284 INT
CommandRem (LPTSTR
);
285 INT
CommandShowCommands (LPTSTR
);
286 INT
CommandShowCommandsDetail (LPTSTR
);
288 /* Prototypes for LABEL.C */
289 INT
cmd_label (LPTSTR
);
292 /* Prototypes for LOCALE.C */
293 extern TCHAR cDateSeparator
;
294 extern INT nDateFormat
;
295 extern TCHAR cTimeSeparator
;
296 extern INT nTimeFormat
;
297 extern TCHAR cThousandSeparator
;
298 extern TCHAR cDecimalSeparator
;
299 extern INT nNumberGroups
;
302 VOID
InitLocale (VOID
);
303 VOID
PrintDate (VOID
);
304 VOID
PrintTime (VOID
);
307 extern UINT InputCodePage
;
308 extern UINT OutputCodePage
;
310 /* Prototypes for MEMORY.C */
311 INT
CommandMemory (LPTSTR
);
314 /* Prototypes for MISC.C */
315 INT
GetRootPath(TCHAR
*InPath
,TCHAR
*OutPath
,INT size
);
316 BOOL
SetRootPath(TCHAR
*InPath
);
317 TCHAR
cgetchar (VOID
);
318 BOOL
CheckCtrlBreak (INT
);
319 BOOL
add_entry (LPINT ac
, LPTSTR
**arg
, LPCTSTR entry
);
320 LPTSTR
*split (LPTSTR
, LPINT
, BOOL
);
321 LPTSTR
*splitspace (LPTSTR
, LPINT
);
322 VOID
freep (LPTSTR
*);
323 LPTSTR
_stpcpy (LPTSTR
, LPCTSTR
);
324 VOID
StripQuotes(LPTSTR
);
325 BOOL
IsValidPathName (LPCTSTR
);
326 BOOL
IsExistingFile (LPCTSTR
);
327 BOOL
IsExistingDirectory (LPCTSTR
);
328 BOOL
FileGetString (HANDLE
, LPTSTR
, INT
);
329 VOID
GetPathCase(TCHAR
*, TCHAR
*);
334 #define PROMPT_BREAK 3
336 INT
PagePrompt (VOID
);
337 INT
FilePromptYN (UINT
);
338 INT
FilePromptYNA (UINT
);
341 /* Prototypes for MOVE.C */
342 INT
cmd_move (LPTSTR
);
345 /* Prototypes for MSGBOX.C */
346 INT
CommandMsgbox (LPTSTR
);
349 /* Prototypes from PARSER.C */
350 enum { C_COMMAND
, C_QUIET
, C_BLOCK
, C_MULTI
, C_IFFAILURE
, C_IFSUCCESS
, C_PIPE
, C_IF
, C_FOR
};
351 typedef struct _PARSED_COMMAND
353 struct _PARSED_COMMAND
*Subcommands
;
354 struct _PARSED_COMMAND
*Next
;
355 struct _REDIRECTION
*Redirections
;
377 struct tagFORCONTEXT
*Context
;
381 PARSED_COMMAND
*ParseCommand(LPTSTR Line
);
382 VOID
EchoCommand(PARSED_COMMAND
*Cmd
);
383 VOID
FreeCommand(PARSED_COMMAND
*Cmd
);
386 /* Prototypes from PATH.C */
387 INT
cmd_path (LPTSTR
);
390 /* Prototypes from PROMPT.C */
391 VOID
PrintPrompt (VOID
);
392 INT
cmd_prompt (LPTSTR
);
395 /* Prototypes for REDIR.C */
396 enum { REDIR_READ
, REDIR_WRITE
, REDIR_APPEND
};
397 typedef struct _REDIRECTION
399 struct _REDIRECTION
*Next
;
405 BOOL
PerformRedirection(REDIRECTION
*);
406 VOID
UndoRedirection(REDIRECTION
*, REDIRECTION
*End
);
407 INT
GetRedirection(LPTSTR
, REDIRECTION
**);
408 VOID
FreeRedirection(REDIRECTION
*);
411 /* Prototypes for REN.C */
412 INT
cmd_rename (LPTSTR
);
414 /* Prototypes for REN.C */
415 INT
cmd_replace (LPTSTR
);
417 /* Prototypes for SCREEN.C */
418 INT
CommandScreen (LPTSTR
);
421 /* Prototypes for SET.C */
422 INT
cmd_set (LPTSTR
);
424 /* Prototypes for SETLOCAL.C */
425 INT
cmd_setlocal (LPTSTR
);
426 INT
cmd_endlocal (LPTSTR
);
428 /* Prototypes for START.C */
429 INT
cmd_start (LPTSTR
);
432 /* Prototypes for STRTOCLR.C */
433 BOOL
StringToColor (LPWORD
, LPTSTR
*);
436 /* Prototypes for TIME.C */
437 INT
cmd_time (LPTSTR
);
440 /* Prototypes for TIMER.C */
441 INT
CommandTimer (LPTSTR param
);
444 /* Prototypes for TITLE.C */
445 INT
cmd_title (LPTSTR
);
448 /* Prototypes for TYPE.C */
449 INT
cmd_type (LPTSTR
);
452 /* Prototypes for VER.C */
453 VOID
ShortVersion (VOID
);
454 INT
cmd_ver (LPTSTR
);
457 /* Prototypes for VERIFY.C */
458 INT
cmd_verify (LPTSTR
);
461 /* Prototypes for VOL.C */
462 INT
cmd_vol (LPTSTR
);
465 /* Prototypes for WHERE.C */
466 BOOL
SearchForExecutable (LPCTSTR
, LPTSTR
);
468 /* Prototypes for WINDOW.C */
469 INT
CommandActivate (LPTSTR
);
470 INT
CommandWindow (LPTSTR
);
473 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
475 int cmd_pause(TCHAR
*);
476 int cmd_shift(TCHAR
*);
478 #endif /* _CMD_H_INCLUDED_ */