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
SubstituteVars(TCHAR
*Src
, TCHAR
*Dest
, TCHAR Delim
);
106 BOOL
SubstituteForVars(TCHAR
*Src
, TCHAR
*Dest
);
107 LPTSTR
DoDelayedExpansion(LPTSTR Line
);
108 BOOL
DoCommand (LPTSTR line
, struct _PARSED_COMMAND
*Cmd
);
109 BOOL
ReadLine(TCHAR
*commandline
, BOOL bMore
);
110 int cmd_main (int argc
, const TCHAR
*argv
[]);
112 extern HANDLE CMD_ModuleHandle
;
115 /* Prototypes for CMDINPUT.C */
116 VOID
ReadCommand (LPTSTR
, INT
);
119 /* Prototypes for CMDTABLE.C */
120 #define CMD_SPECIAL 1
121 #define CMD_BATCHONLY 2
124 typedef struct tagCOMMAND
129 } COMMAND
, *LPCOMMAND
;
131 extern COMMAND cmds
[]; /* The internal command table */
133 VOID
PrintCommandList (VOID
);
134 VOID
PrintCommandListDetail (VOID
);
137 LPCTSTR
GetParsedEnvVar ( LPCTSTR varName
, UINT
* varNameLen
, BOOL ModeSetA
);
139 /* Prototypes for COLOR.C */
140 VOID
SetScreenColor(WORD wArgColor
, BOOL bFill
);
141 INT
CommandColor (LPTSTR
);
143 VOID
ConInDummy (VOID
);
144 VOID
ConInDisable (VOID
);
145 VOID
ConInEnable (VOID
);
146 VOID
ConInFlush (VOID
);
147 VOID
ConInKey (PINPUT_RECORD
);
148 VOID
ConInString (LPTSTR
, DWORD
);
150 VOID
ConOutChar (TCHAR
);
151 VOID
ConOutPuts (LPTSTR
);
152 VOID
ConOutPrintf (LPTSTR
, ...);
153 INT
ConOutPrintfPaging (BOOL NewPage
, LPTSTR
, ...);
154 VOID
ConErrChar (TCHAR
);
155 VOID
ConErrPuts (LPTSTR
);
156 VOID
ConErrPrintf (LPTSTR
, ...);
157 VOID
ConOutFormatMessage (DWORD MessageId
, ...);
158 VOID
ConErrFormatMessage (DWORD MessageId
, ...);
160 SHORT
GetCursorX (VOID
);
161 SHORT
GetCursorY (VOID
);
162 VOID
GetCursorXY (PSHORT
, PSHORT
);
163 VOID
SetCursorXY (SHORT
, SHORT
);
165 VOID
GetScreenSize (PSHORT
, PSHORT
);
166 VOID
SetCursorType (BOOL
, BOOL
);
168 VOID
ConOutResPuts (UINT resID
);
169 VOID
ConErrResPuts (UINT resID
);
170 VOID
ConOutResPrintf (UINT resID
, ...);
171 VOID
ConErrResPrintf (UINT resID
, ...);
172 VOID
ConOutResPaging(BOOL NewPage
, UINT resID
);
174 /* Prototypes for COPY.C */
175 INT
cmd_copy (LPTSTR
);
178 /* Prototypes for DATE.C */
179 INT
cmd_date (LPTSTR
);
182 /* Prototypes for DEL.C */
183 INT
CommandDelete (LPTSTR
);
186 /* Prototypes for DELAY.C */
187 INT
CommandDelay (LPTSTR
);
190 /* Prototypes for DIR.C */
191 INT
CommandDir (LPTSTR
);
194 /* Prototypes for DIRSTACK.C */
195 VOID
InitDirectoryStack (VOID
);
196 VOID
DestroyDirectoryStack (VOID
);
197 INT
GetDirectoryStackDepth (VOID
);
198 INT
CommandPushd (LPTSTR
);
199 INT
CommandPopd (LPTSTR
);
200 INT
CommandDirs (LPTSTR
);
203 /* Prototypes for ECHO.C */
204 INT
CommandEcho (LPTSTR
);
205 INT
CommandEchos (LPTSTR
);
206 INT
CommandEchoerr (LPTSTR
);
207 INT
CommandEchoserr (LPTSTR
);
210 /* Prototypes for ERROR.C */
211 VOID
ErrorMessage (DWORD
, LPTSTR
, ...);
213 VOID
error_no_pipe (VOID
);
214 VOID
error_bad_command (VOID
);
215 VOID
error_invalid_drive (VOID
);
216 VOID
error_req_param_missing (VOID
);
217 VOID
error_sfile_not_found (LPTSTR
);
218 VOID
error_file_not_found (VOID
);
219 VOID
error_path_not_found (VOID
);
220 VOID
error_too_many_parameters (LPTSTR
);
221 VOID
error_parameter_format(TCHAR
);
222 VOID
error_invalid_switch (TCHAR
);
223 VOID
error_invalid_parameter_format (LPTSTR
);
224 VOID
error_out_of_memory (VOID
);
225 VOID
error_syntax (LPTSTR
);
227 VOID
msg_pause (VOID
);
230 /* Prototypes for FILECOMP.C */
231 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
232 VOID
CompleteFilename (LPTSTR
, UINT
);
233 INT
ShowCompletionMatches (LPTSTR
, INT
);
235 #ifdef FEATURE_4NT_FILENAME_COMPLETION
236 VOID
CompleteFilename (LPTSTR
, BOOL
, LPTSTR
, UINT
);
240 /* Prototypes for FOR.C */
241 #define FOR_DIRS 1 /* /D */
242 #define FOR_F 2 /* /F */
243 #define FOR_LOOP 4 /* /L */
244 #define FOR_RECURSIVE 8 /* /R */
245 INT
cmd_for (LPTSTR
);
246 BOOL
ExecuteFor(struct _PARSED_COMMAND
*Cmd
);
249 /* Prototypes for FREE.C */
250 INT
CommandFree (LPTSTR
);
253 /* Prototypes for GOTO.C */
254 INT
cmd_goto (LPTSTR
);
257 /* Prototypes for HISTORY.C */
258 #ifdef FEATURE_HISTORY
259 LPCTSTR
PeekHistory(INT
);
260 VOID
History (INT
, LPTSTR
);/*add entries browse history*/
261 VOID
History_move_to_bottom(VOID
);/*F3*/
262 VOID
InitHistory(VOID
);
263 VOID
CleanHistory(VOID
);
264 VOID
History_del_current_entry(LPTSTR str
);/*CTRL-D*/
265 INT
CommandHistory (LPTSTR param
);
269 /* Prototypes for IF.C */
270 #define IFFLAG_NEGATE 1 /* NOT */
271 #define IFFLAG_IGNORECASE 2 /* /I */
272 enum { IF_CMDEXTVERSION
, IF_DEFINED
, IF_ERRORLEVEL
, IF_EXIST
,
273 IF_STRINGEQ
, /* == */
274 IF_EQU
, IF_GTR
, IF_GEQ
, IF_LSS
, IF_LEQ
, IF_NEQ
};
275 BOOL
ExecuteIf(struct _PARSED_COMMAND
*Cmd
);
278 /* Prototypes for INTERNAL.C */
279 VOID
InitLastPath (VOID
);
280 VOID
FreeLastPath (VOID
);
281 INT
cmd_chdir (LPTSTR
);
282 INT
cmd_mkdir (LPTSTR
);
283 INT
cmd_rmdir (LPTSTR
);
284 INT
CommandExit (LPTSTR
);
285 INT
CommandRem (LPTSTR
);
286 INT
CommandShowCommands (LPTSTR
);
287 INT
CommandShowCommandsDetail (LPTSTR
);
289 /* Prototypes for LABEL.C */
290 INT
cmd_label (LPTSTR
);
293 /* Prototypes for LOCALE.C */
294 extern TCHAR cDateSeparator
;
295 extern INT nDateFormat
;
296 extern TCHAR cTimeSeparator
;
297 extern INT nTimeFormat
;
298 extern TCHAR cThousandSeparator
;
299 extern TCHAR cDecimalSeparator
;
300 extern INT nNumberGroups
;
303 VOID
InitLocale (VOID
);
304 VOID
PrintDate (VOID
);
305 VOID
PrintTime (VOID
);
308 extern UINT InputCodePage
;
309 extern UINT OutputCodePage
;
311 /* Prototypes for MEMORY.C */
312 INT
CommandMemory (LPTSTR
);
315 /* Prototypes for MISC.C */
316 INT
GetRootPath(TCHAR
*InPath
,TCHAR
*OutPath
,INT size
);
317 BOOL
SetRootPath(TCHAR
*InPath
);
318 TCHAR
cgetchar (VOID
);
319 BOOL
CheckCtrlBreak (INT
);
320 BOOL
add_entry (LPINT ac
, LPTSTR
**arg
, LPCTSTR entry
);
321 LPTSTR
*split (LPTSTR
, LPINT
, BOOL
);
322 LPTSTR
*splitspace (LPTSTR
, LPINT
);
323 VOID
freep (LPTSTR
*);
324 LPTSTR
_stpcpy (LPTSTR
, LPCTSTR
);
325 VOID
StripQuotes(LPTSTR
);
326 BOOL
IsValidPathName (LPCTSTR
);
327 BOOL
IsExistingFile (LPCTSTR
);
328 BOOL
IsExistingDirectory (LPCTSTR
);
329 BOOL
FileGetString (HANDLE
, LPTSTR
, INT
);
330 VOID
GetPathCase(TCHAR
*, TCHAR
*);
335 #define PROMPT_BREAK 3
337 INT
PagePrompt (VOID
);
338 INT
FilePromptYN (UINT
);
339 INT
FilePromptYNA (UINT
);
342 /* Prototypes for MOVE.C */
343 INT
cmd_move (LPTSTR
);
346 /* Prototypes for MSGBOX.C */
347 INT
CommandMsgbox (LPTSTR
);
350 /* Prototypes from PARSER.C */
351 enum { C_COMMAND
, C_QUIET
, C_BLOCK
, C_MULTI
, C_IFFAILURE
, C_IFSUCCESS
, C_PIPE
, C_IF
, C_FOR
};
352 typedef struct _PARSED_COMMAND
354 struct _PARSED_COMMAND
*Subcommands
;
355 struct _PARSED_COMMAND
*Next
;
356 struct _REDIRECTION
*Redirections
;
378 struct tagFORCONTEXT
*Context
;
382 PARSED_COMMAND
*ParseCommand(LPTSTR Line
);
383 VOID
EchoCommand(PARSED_COMMAND
*Cmd
);
384 VOID
FreeCommand(PARSED_COMMAND
*Cmd
);
387 /* Prototypes from PATH.C */
388 INT
cmd_path (LPTSTR
);
391 /* Prototypes from PROMPT.C */
392 VOID
PrintPrompt (VOID
);
393 INT
cmd_prompt (LPTSTR
);
396 /* Prototypes for REDIR.C */
397 enum { REDIR_READ
, REDIR_WRITE
, REDIR_APPEND
};
398 typedef struct _REDIRECTION
400 struct _REDIRECTION
*Next
;
406 BOOL
PerformRedirection(REDIRECTION
*);
407 VOID
UndoRedirection(REDIRECTION
*, REDIRECTION
*End
);
408 INT
GetRedirection(LPTSTR
, REDIRECTION
**);
409 VOID
FreeRedirection(REDIRECTION
*);
412 /* Prototypes for REN.C */
413 INT
cmd_rename (LPTSTR
);
415 /* Prototypes for REN.C */
416 INT
cmd_replace (LPTSTR
);
418 /* Prototypes for SCREEN.C */
419 INT
CommandScreen (LPTSTR
);
422 /* Prototypes for SET.C */
423 INT
cmd_set (LPTSTR
);
425 /* Prototypes for SETLOCAL.C */
426 INT
cmd_setlocal (LPTSTR
);
427 INT
cmd_endlocal (LPTSTR
);
429 /* Prototypes for START.C */
430 INT
cmd_start (LPTSTR
);
433 /* Prototypes for STRTOCLR.C */
434 BOOL
StringToColor (LPWORD
, LPTSTR
*);
437 /* Prototypes for TIME.C */
438 INT
cmd_time (LPTSTR
);
441 /* Prototypes for TIMER.C */
442 INT
CommandTimer (LPTSTR param
);
445 /* Prototypes for TITLE.C */
446 INT
cmd_title (LPTSTR
);
449 /* Prototypes for TYPE.C */
450 INT
cmd_type (LPTSTR
);
453 /* Prototypes for VER.C */
454 VOID
ShortVersion (VOID
);
455 INT
cmd_ver (LPTSTR
);
458 /* Prototypes for VERIFY.C */
459 INT
cmd_verify (LPTSTR
);
462 /* Prototypes for VOL.C */
463 INT
cmd_vol (LPTSTR
);
466 /* Prototypes for WHERE.C */
467 BOOL
SearchForExecutable (LPCTSTR
, LPTSTR
);
469 /* Prototypes for WINDOW.C */
470 INT
CommandActivate (LPTSTR
);
471 INT
CommandWindow (LPTSTR
);
474 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
476 int cmd_pause(TCHAR
*);
477 int cmd_shift(TCHAR
*);
479 #endif /* _CMD_H_INCLUDED_ */