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!
31 #define BREAK_BATCHFILE 1
32 #define BREAK_OUTOFBATCH 2
34 #define BREAK_IGNORE 4
36 /* define some error messages */
38 #define D_OFF _T("off")
40 /* command line buffer length */
41 #define CMDLINE_LENGTH 8192
43 /* 16k = max buffer size */
44 #define BUFF_SIZE 16384
46 /* Global variables */
47 extern LPTSTR lpOriginalEnvironment
;
49 extern WORD wDefColor
;
50 extern BOOL bCtrlBreak
;
51 extern BOOL bIgnoreEcho
;
53 extern BOOL bDisableBatchEcho
;
54 extern BOOL bEnableExtensions
;
55 extern BOOL bDelayedExpansion
;
56 extern INT nErrorLevel
;
59 /* Prototypes for ALIAS.C */
60 VOID
ExpandAlias (LPTSTR
, INT
);
61 INT
CommandAlias (LPTSTR
);
63 /* Prototypes for ASSOC.C */
64 INT
CommandAssoc (LPTSTR
);
66 /* Prototypes for ATTRIB.C */
67 INT
CommandAttrib (LPTSTR
);
69 /* Prototypes for BEEP.C */
70 INT
cmd_beep (LPTSTR
);
72 /* Prototypes for CALL.C */
73 INT
cmd_call (LPTSTR
);
75 /* Prototypes for CHOICE.C */
76 INT
CommandChoice (LPTSTR
);
78 /* Prototypes for CLS.C */
81 /* Prototypes for CMD.C */
82 INT
ConvertULargeInteger(ULONGLONG num
, LPTSTR des
, UINT len
, BOOL bPutSeparator
);
83 HANDLE
RunFile(DWORD
, LPTSTR
, LPTSTR
, LPTSTR
, INT
);
84 INT
ParseCommandLine(LPTSTR
);
85 struct _PARSED_COMMAND
;
86 INT
ExecuteCommand(struct _PARSED_COMMAND
*Cmd
);
87 LPCTSTR
GetEnvVarOrSpecial ( LPCTSTR varName
);
88 VOID
AddBreakHandler (VOID
);
89 VOID
RemoveBreakHandler (VOID
);
90 BOOL
SubstituteVars(TCHAR
*Src
, TCHAR
*Dest
, TCHAR Delim
);
91 BOOL
SubstituteForVars(TCHAR
*Src
, TCHAR
*Dest
);
92 LPTSTR
DoDelayedExpansion(LPTSTR Line
);
93 INT
DoCommand(LPTSTR first
, LPTSTR rest
, struct _PARSED_COMMAND
*Cmd
);
94 BOOL
ReadLine(TCHAR
*commandline
, BOOL bMore
);
96 extern HANDLE CMD_ModuleHandle
;
99 /* Prototypes for CMDINPUT.C */
100 BOOL
ReadCommand (LPTSTR
, INT
);
102 extern TCHAR AutoCompletionChar
;
103 extern TCHAR PathCompletionChar
;
105 #define IS_COMPLETION_DISABLED(CompletionCtrl) \
106 ((CompletionCtrl) == 0x00 || (CompletionCtrl) == 0x0D || (CompletionCtrl) >= 0x20)
109 /* Prototypes for CMDTABLE.C */
110 #define CMD_SPECIAL 1
111 #define CMD_BATCHONLY 2
114 typedef struct tagCOMMAND
119 } COMMAND
, *LPCOMMAND
;
121 extern COMMAND cmds
[]; /* The internal command table */
123 VOID
PrintCommandList (VOID
);
125 LPCTSTR
GetParsedEnvVar ( LPCTSTR varName
, UINT
* varNameLen
, BOOL ModeSetA
);
127 /* Prototypes for CTTY.C */
128 #ifdef INCLUDE_CMD_CTTY
129 INT
cmd_ctty(LPTSTR
);
132 /* Prototypes for COLOR.C */
133 INT
CommandColor(LPTSTR
);
135 /* Prototypes for CONSOLE.C */
138 /* Prototypes for COPY.C */
139 INT
cmd_copy (LPTSTR
);
141 /* Prototypes for DATE.C */
142 INT
cmd_date (LPTSTR
);
144 /* Prototypes for DEL.C */
145 INT
CommandDelete (LPTSTR
);
147 /* Prototypes for DELAY.C */
148 INT
CommandDelay (LPTSTR
);
150 /* Prototypes for DIR.C */
151 INT
FormatDate (TCHAR
*, LPSYSTEMTIME
, BOOL
);
152 INT
FormatTime (TCHAR
*, LPSYSTEMTIME
);
153 INT
CommandDir (LPTSTR
);
155 /* Prototypes for DIRSTACK.C */
156 VOID
InitDirectoryStack (VOID
);
157 VOID
DestroyDirectoryStack (VOID
);
158 INT
GetDirectoryStackDepth (VOID
);
159 INT
CommandPushd (LPTSTR
);
160 INT
CommandPopd (LPTSTR
);
161 INT
CommandDirs (LPTSTR
);
163 /* Prototypes for ECHO.C */
164 BOOL
OnOffCommand(LPTSTR param
, LPBOOL flag
, INT message
);
165 INT
CommandEcho (LPTSTR
);
166 INT
CommandEchos (LPTSTR
);
167 INT
CommandEchoerr (LPTSTR
);
168 INT
CommandEchoserr (LPTSTR
);
170 /* Prototypes for ERROR.C */
171 VOID
ErrorMessage (DWORD
, LPTSTR
, ...);
173 VOID
error_no_pipe (VOID
);
174 VOID
error_bad_command (LPTSTR
);
175 VOID
error_invalid_drive (VOID
);
176 VOID
error_req_param_missing (VOID
);
177 VOID
error_sfile_not_found (LPTSTR
);
178 VOID
error_file_not_found (VOID
);
179 VOID
error_path_not_found (VOID
);
180 VOID
error_too_many_parameters (LPTSTR
);
181 VOID
error_parameter_format(TCHAR
);
182 VOID
error_invalid_switch (TCHAR
);
183 VOID
error_invalid_parameter_format (LPTSTR
);
184 VOID
error_out_of_memory (VOID
);
185 VOID
error_syntax (LPTSTR
);
187 VOID
msg_pause (VOID
);
189 /* Prototypes for FILECOMP.C */
190 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
191 VOID
CompleteFilename (LPTSTR
, UINT
);
192 INT
ShowCompletionMatches (LPTSTR
, INT
);
194 #ifdef FEATURE_4NT_FILENAME_COMPLETION
195 VOID
CompleteFilename (LPTSTR
, BOOL
, LPTSTR
, UINT
);
199 /* Prototypes for FOR.C */
200 #define FOR_DIRS 1 /* /D */
201 #define FOR_F 2 /* /F */
202 #define FOR_LOOP 4 /* /L */
203 #define FOR_RECURSIVE 8 /* /R */
204 INT
cmd_for (LPTSTR
);
205 INT
ExecuteFor(struct _PARSED_COMMAND
*Cmd
);
208 /* Prototypes for FREE.C */
209 INT
CommandFree (LPTSTR
);
211 /* Prototypes for GOTO.C */
212 INT
cmd_goto (LPTSTR
);
214 /* Prototypes for HISTORY.C */
215 #ifdef FEATURE_HISTORY
216 LPCTSTR
PeekHistory(INT
);
217 VOID
History(INT
, LPTSTR
);/*add entries browse history*/
218 VOID
History_move_to_bottom(VOID
);/*F3*/
219 VOID
InitHistory(VOID
);
220 VOID
CleanHistory(VOID
);
221 VOID
History_del_current_entry(LPTSTR str
);/*CTRL-D*/
222 INT
CommandHistory(LPTSTR param
);
225 /* Prototypes for IF.C */
226 #define IFFLAG_NEGATE 1 /* NOT */
227 #define IFFLAG_IGNORECASE 2 /* /I */
228 enum { IF_CMDEXTVERSION
, IF_DEFINED
, IF_ERRORLEVEL
, IF_EXIST
,
229 IF_STRINGEQ
, /* == */
230 IF_EQU
, IF_GTR
, IF_GEQ
, IF_LSS
, IF_LEQ
, IF_NEQ
};
231 INT
ExecuteIf(struct _PARSED_COMMAND
*Cmd
);
233 /* Prototypes for INTERNAL.C */
234 VOID
InitLastPath (VOID
);
235 VOID
FreeLastPath (VOID
);
236 INT
cmd_chdir (LPTSTR
);
237 INT
cmd_mkdir (LPTSTR
);
238 INT
cmd_rmdir (LPTSTR
);
239 INT
CommandExit (LPTSTR
);
240 INT
CommandRem (LPTSTR
);
241 INT
CommandShowCommands (LPTSTR
);
243 /* Prototypes for LABEL.C */
244 INT
cmd_label (LPTSTR
);
246 /* Prototypes for LOCALE.C */
247 extern TCHAR cDateSeparator
;
248 extern INT nDateFormat
;
249 extern TCHAR cTimeSeparator
;
250 extern INT nTimeFormat
;
251 extern TCHAR cThousandSeparator
;
252 extern TCHAR cDecimalSeparator
;
253 extern INT nNumberGroups
;
255 VOID
InitLocale (VOID
);
256 LPTSTR
GetDateString (VOID
);
257 LPTSTR
GetTimeString (VOID
);
259 /* Prototypes for MEMORY.C */
260 INT
CommandMemory (LPTSTR
);
262 /* Prototypes for MKLINK.C */
263 INT
cmd_mklink(LPTSTR
);
265 /* Prototypes for MISC.C */
266 INT
GetRootPath(TCHAR
*InPath
,TCHAR
*OutPath
,INT size
);
267 BOOL
SetRootPath(TCHAR
*oldpath
,TCHAR
*InPath
);
268 TCHAR
cgetchar (VOID
);
269 BOOL
CheckCtrlBreak (INT
);
270 BOOL
add_entry (LPINT ac
, LPTSTR
**arg
, LPCTSTR entry
);
271 LPTSTR
*split (LPTSTR
, LPINT
, BOOL
, BOOL
);
272 LPTSTR
*splitspace (LPTSTR
, LPINT
);
273 VOID
freep (LPTSTR
*);
274 LPTSTR
_stpcpy (LPTSTR
, LPCTSTR
);
275 VOID
StripQuotes(LPTSTR
);
276 BOOL
IsValidPathName (LPCTSTR
);
277 BOOL
IsExistingFile (LPCTSTR
);
278 BOOL
IsExistingDirectory (LPCTSTR
);
279 BOOL
FileGetString (HANDLE
, LPTSTR
, INT
);
280 VOID
GetPathCase(TCHAR
*, TCHAR
*);
285 #define PROMPT_BREAK 3
287 BOOL __stdcall
PagePrompt(PCON_PAGER Pager
, DWORD Done
, DWORD Total
);
288 INT
FilePromptYN (UINT
);
289 INT
FilePromptYNA (UINT
);
291 /* Prototypes for MOVE.C */
292 INT
cmd_move (LPTSTR
);
294 /* Prototypes for MSGBOX.C */
295 INT
CommandMsgbox (LPTSTR
);
297 /* Prototypes from PARSER.C */
298 enum { C_COMMAND
, C_QUIET
, C_BLOCK
, C_MULTI
, C_IFFAILURE
, C_IFSUCCESS
, C_PIPE
, C_IF
, C_FOR
};
299 typedef struct _PARSED_COMMAND
301 struct _PARSED_COMMAND
*Subcommands
;
302 struct _PARSED_COMMAND
*Next
;
303 struct _REDIRECTION
*Redirections
;
325 struct tagFORCONTEXT
*Context
;
329 PARSED_COMMAND
*ParseCommand(LPTSTR Line
);
330 VOID
EchoCommand(PARSED_COMMAND
*Cmd
);
331 TCHAR
*Unparse(PARSED_COMMAND
*Cmd
, TCHAR
*Out
, TCHAR
*OutEnd
);
332 VOID
FreeCommand(PARSED_COMMAND
*Cmd
);
334 /* Prototypes from PATH.C */
335 INT
cmd_path (LPTSTR
);
337 /* Prototypes from PROMPT.C */
338 VOID
InitPrompt (VOID
);
339 VOID
PrintPrompt (VOID
);
340 INT
cmd_prompt (LPTSTR
);
342 /* Prototypes for REDIR.C */
343 HANDLE
GetHandle(UINT Number
);
344 VOID
SetHandle(UINT Number
, HANDLE Handle
);
346 typedef enum _REDIR_MODE
352 typedef struct _REDIRECTION
354 struct _REDIRECTION
*Next
;
360 BOOL
PerformRedirection(REDIRECTION
*);
361 VOID
UndoRedirection(REDIRECTION
*, REDIRECTION
*End
);
362 INT
GetRedirection(LPTSTR
, REDIRECTION
**);
363 VOID
FreeRedirection(REDIRECTION
*);
365 /* Prototypes for REN.C */
366 INT
cmd_rename (LPTSTR
);
368 /* Prototypes for REN.C */
369 INT
cmd_replace (LPTSTR
);
371 /* Prototypes for SCREEN.C */
372 INT
CommandScreen (LPTSTR
);
374 /* Prototypes for SET.C */
375 INT
cmd_set (LPTSTR
);
377 /* Prototypes for SETLOCAL.C */
378 LPTSTR
DuplicateEnvironment(VOID
);
379 INT
cmd_setlocal (LPTSTR
);
380 INT
cmd_endlocal (LPTSTR
);
382 /* Prototypes for START.C */
383 INT
cmd_start (LPTSTR
);
385 /* Prototypes for STRTOCLR.C */
386 BOOL
StringToColor (LPWORD
, LPTSTR
*);
388 /* Prototypes for TIME.C */
389 INT
cmd_time (LPTSTR
);
391 /* Prototypes for TIMER.C */
392 INT
CommandTimer (LPTSTR param
);
394 /* Prototypes for TITLE.C */
395 INT
cmd_title (LPTSTR
);
397 /* Prototypes for TYPE.C */
398 INT
cmd_type (LPTSTR
);
400 /* Prototypes for VER.C */
401 VOID
InitOSVersion(VOID
);
402 VOID
PrintOSVersion(VOID
);
403 INT
cmd_ver (LPTSTR
);
405 /* Prototypes for VERIFY.C */
406 INT
cmd_verify (LPTSTR
);
408 /* Prototypes for VOL.C */
409 INT
cmd_vol (LPTSTR
);
411 /* Prototypes for WHERE.C */
412 BOOL
SearchForExecutable (LPCTSTR
, LPTSTR
);
414 /* Prototypes for WINDOW.C */
415 INT
CommandActivate (LPTSTR
);
416 INT
CommandWindow (LPTSTR
);
418 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
420 int cmd_pause(TCHAR
*);
421 int cmd_shift(TCHAR
*);