ReactOS  0.4.14-dev-317-g96040ec
cmd.h
Go to the documentation of this file.
1 /*
2  * CMD.H - header file for the modules in CMD.EXE
3  *
4  *
5  * History:
6  *
7  * 7-15-95 Tim Norman
8  * started
9  *
10  * 06/29/98 (Rob Lake)
11  * Moved error messages in here
12  *
13  * 07/12/98 (Rob Lake)
14  * Moved more error messages here.
15  *
16  * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
17  * Added compile date to version.
18  *
19  * 26-Feb-1999 (Eric Kohl)
20  * Introduced a new version string.
21  * Thanks to Emanuele Aliberti!
22  */
23 
24 #pragma once
25 
26 #include <config.h>
27 
28 #include "cmdver.h"
29 #include "cmddbg.h"
30 
31 #define BREAK_BATCHFILE 1
32 #define BREAK_OUTOFBATCH 2
33 #define BREAK_INPUT 3
34 #define BREAK_IGNORE 4
35 
36 /* define some error messages */
37 #define D_ON _T("on")
38 #define D_OFF _T("off")
39 
40 /* command line buffer length */
41 #define CMDLINE_LENGTH 8192
42 
43 /* 16k = max buffer size */
44 #define BUFF_SIZE 16384
45 
46 /* Global variables */
48 extern WORD wColor;
49 extern WORD wDefColor;
50 extern BOOL bCtrlBreak;
51 extern BOOL bIgnoreEcho;
52 extern BOOL bExit;
53 extern BOOL bDisableBatchEcho;
54 extern BOOL bEnableExtensions;
55 extern BOOL bDelayedExpansion;
56 extern INT nErrorLevel;
57 
58 
59 /* Prototypes for ALIAS.C */
62 
63 /* Prototypes for ASSOC.C */
65 
66 /* Prototypes for BEEP.C */
68 
69 /* Prototypes for CALL.C */
71 
72 /* Prototypes for CHOICE.C */
74 
75 /* Prototypes for CLS.C */
77 
78 /* Prototypes for CMD.C */
82 struct _PARSED_COMMAND;
87 BOOL SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim);
88 BOOL SubstituteForVars(TCHAR *Src, TCHAR *Dest);
91 BOOL ReadLine(TCHAR *commandline, BOOL bMore);
92 
94 
95 
96 /* Prototypes for CMDINPUT.C */
98 
101 
102 #define IS_COMPLETION_DISABLED(CompletionCtrl) \
103  ((CompletionCtrl) == 0x00 || (CompletionCtrl) == 0x0D || (CompletionCtrl) >= 0x20)
104 
105 
106 /* Prototypes for CMDTABLE.C */
107 #define CMD_SPECIAL 1
108 #define CMD_BATCHONLY 2
109 #define CMD_HIDE 4
110 
111 typedef struct tagCOMMAND
112 {
114  INT flags;
115  INT (*func)(LPTSTR);
116 } COMMAND, *LPCOMMAND;
117 
118 extern COMMAND cmds[]; /* The internal command table */
119 
121 
122 LPCTSTR GetParsedEnvVar ( LPCTSTR varName, UINT* varNameLen, BOOL ModeSetA );
123 
124 /* Prototypes for CTTY.C */
125 #ifdef INCLUDE_CMD_CTTY
127 #endif
128 
129 /* Prototypes for COLOR.C */
131 
132 /* Prototypes for CONSOLE.C */
133 #include "console.h"
134 
135 /* Prototypes for COPY.C */
137 
138 /* Prototypes for DATE.C */
140 
141 /* Prototypes for DEL.C */
143 
144 /* Prototypes for DELAY.C */
146 
147 /* Prototypes for DIR.C */
151 
152 /* Prototypes for DIRSTACK.C */
159 
160 /* Prototypes for ECHO.C */
166 
167 /* Prototypes for ERROR.C */
168 VOID ErrorMessage (DWORD, LPTSTR, ...);
169 
183 
185 
186 /* Prototypes for FILECOMP.C */
187 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
189 INT ShowCompletionMatches (LPTSTR, INT);
190 #endif
191 #ifdef FEATURE_4NT_FILENAME_COMPLETION
193 #endif
194 
195 
196 /* Prototypes for FOR.C */
197 #define FOR_DIRS 1 /* /D */
198 #define FOR_F 2 /* /F */
199 #define FOR_LOOP 4 /* /L */
200 #define FOR_RECURSIVE 8 /* /R */
201 INT cmd_for (LPTSTR);
203 
204 
205 /* Prototypes for FREE.C */
207 
208 /* Prototypes for GOTO.C */
210 
211 /* Prototypes for HISTORY.C */
212 #ifdef FEATURE_HISTORY
214 VOID History(INT, LPTSTR);/*add entries browse history*/
220 #endif
221 
222 /* Prototypes for IF.C */
223 #define IFFLAG_NEGATE 1 /* NOT */
224 #define IFFLAG_IGNORECASE 2 /* /I */
226  IF_STRINGEQ, /* == */
229 
230 /* Prototypes for INTERNAL.C */
239 
240 /* Prototypes for LOCALE.C */
241 extern TCHAR cDateSeparator;
242 extern INT nDateFormat;
243 extern TCHAR cTimeSeparator;
244 extern INT nTimeFormat;
246 extern TCHAR cDecimalSeparator;
247 extern INT nNumberGroups;
248 
252 
253 /* Prototypes for MEMORY.C */
255 
256 /* Prototypes for MKLINK.C */
258 
259 /* Prototypes for MISC.C */
260 INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size);
261 BOOL SetRootPath(TCHAR *oldpath,TCHAR *InPath);
267 VOID freep (LPTSTR *);
275 
276 #define PROMPT_NO 0
277 #define PROMPT_YES 1
278 #define PROMPT_ALL 2
279 #define PROMPT_BREAK 3
280 
281 BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total);
284 
285 /* Prototypes for MOVE.C */
287 
288 /* Prototypes for MSGBOX.C */
290 
291 /* Prototypes from PARSER.C */
293 typedef struct _PARSED_COMMAND
294 {
299  union
300  {
301  struct
302  {
305  } Command;
306  struct
307  {
312  } If;
313  struct
314  {
320  } For;
321  };
327 
328 /* Prototypes from PATH.C */
330 
331 /* Prototypes from PROMPT.C */
335 
336 /* Prototypes for REDIR.C */
339 
340 typedef enum _REDIR_MODE
341 {
345 } REDIR_MODE;
346 typedef struct _REDIRECTION
347 {
353 } REDIRECTION;
358 
359 /* Prototypes for REN.C */
361 
362 /* Prototypes for REN.C */
364 
365 /* Prototypes for SCREEN.C */
367 
368 /* Prototypes for SET.C */
369 INT cmd_set (LPTSTR);
370 
371 /* Prototypes for SETLOCAL.C */
375 
376 /* Prototypes for START.C */
378 
379 /* Prototypes for STRTOCLR.C */
381 
382 /* Prototypes for TIME.C */
384 
385 /* Prototypes for TIMER.C */
387 
388 /* Prototypes for TITLE.C */
390 
391 /* Prototypes for TYPE.C */
393 
394 /* Prototypes for VER.C */
397 INT cmd_ver (LPTSTR);
398 
399 /* Prototypes for VERIFY.C */
401 
402 /* Prototypes for VOL.C */
403 INT cmd_vol (LPTSTR);
404 
405 /* Prototypes for WHERE.C */
407 
408 /* Prototypes for WINDOW.C */
411 
412 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
413 int cmd_if(TCHAR *);
414 int cmd_pause(TCHAR *);
415 int cmd_shift(TCHAR *);
VOID InitLocale(VOID)
Definition: locale.c:25
VOID InitLastPath(VOID)
INT GetRedirection(LPTSTR, REDIRECTION **)
INT DoCommand(LPTSTR first, LPTSTR rest, struct _PARSED_COMMAND *Cmd)
Definition: cmd.c:552
INT cmd_mklink(LPTSTR)
Definition: mklink.c:124
int cmd_shift(TCHAR *)
GLenum func
Definition: glext.h:6028
VOID PrintCommandList(VOID)
Definition: cmdtable.c:234
INT FormatTime(TCHAR *, LPSYSTEMTIME)
Definition: dir.c:703
INT CommandTimer(LPTSTR param)
Definition: timer.c:59
BOOL add_entry(LPINT ac, LPTSTR **arg, LPCTSTR entry)
Definition: misc.c:185
Definition: cmd.h:292
BOOL bCtrlBreak
Definition: cmd.c:154
BOOL CheckCtrlBreak(INT)
Definition: misc.c:132
Definition: tftpd.h:59
Definition: cmd.h:292
INT nErrorLevel
Definition: cmd.c:157
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
INT CommandHistory(LPTSTR param)
Definition: history.c:71
VOID InitHistory(VOID)
Definition: history.c:132
BOOL IsValidPathName(LPCTSTR)
Definition: misc.c:483
LPCTSTR GetParsedEnvVar(LPCTSTR varName, UINT *varNameLen, BOOL ModeSetA)
BOOL SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim)
Definition: cmd.c:1206
struct _PARSED_COMMAND * Subcommands
Definition: cmd.h:295
VOID CleanHistory(VOID)
Definition: history.c:163
INT cmd_rmdir(LPTSTR)
Definition: internal.c:406
Definition: cmd.h:292
LPTSTR List
Definition: cmd.h:318
VOID error_invalid_drive(VOID)
Definition: error.c:115
enum _REDIR_MODE REDIR_MODE
INT cmd_start(LPTSTR)
Definition: start.c:37
LPTSTR Params
Definition: cmd.h:317
BOOL FileGetString(HANDLE, LPTSTR, INT)
Definition: misc.c:514
VOID ErrorMessage(DWORD, LPTSTR,...)
Definition: error.c:26
BYTE Type
Definition: cmd.h:298
LPCTSTR GetEnvVarOrSpecial(LPCTSTR varName)
Definition: cmd.c:852
INT cmd_goto(LPTSTR)
Definition: goto.c:39
INT CommandActivate(LPTSTR)
const GLint * first
Definition: glext.h:5794
VOID error_parameter_format(TCHAR)
Definition: error.c:63
VOID History_move_to_bottom(VOID)
Definition: history.c:280
INT cmd_date(LPTSTR)
Definition: date.c:176
TCHAR * LeftArg
Definition: cmd.h:310
#define INT
Definition: polytest.cpp:20
VOID DestroyDirectoryStack(VOID)
Definition: dirstack.c:91
INT CommandDirs(LPTSTR)
Definition: dirstack.c:154
LPTSTR * splitspace(LPTSTR, LPINT)
Definition: misc.c:382
INT cmd_copy(LPTSTR)
Definition: copy.c:331
BOOL bEnableExtensions
Definition: cmd.c:160
INT cmd_endlocal(LPTSTR)
Definition: setlocal.c:95
INT CommandFree(LPTSTR)
Definition: free.c:86
INT FormatDate(TCHAR *, LPSYSTEMTIME, BOOL)
Definition: dir.c:674
Definition: cmd.h:292
Definition: cmd.h:225
VOID InitPrompt(VOID)
Definition: prompt.c:57
INT cmd_type(LPTSTR)
Definition: type.c:34
struct _REDIRECTION REDIRECTION
VOID StripQuotes(LPTSTR)
INT cmd_path(LPTSTR)
Definition: path.c:36
INT nTimeFormat
Definition: locale.c:21
INT CommandRem(LPTSTR)
Definition: internal.c:557
struct tagCOMMAND * LPCOMMAND
INT flags
Definition: cmdcons.c:28
int32_t INT
Definition: typedefs.h:56
struct _PARSED_COMMAND * Next
Definition: cmd.h:296
INT CommandMsgbox(LPTSTR)
CHAR * LPTSTR
Definition: xmlstorage.h:192
BYTE Operator
Definition: cmd.h:309
LPTSTR name
Definition: cmd.h:113
REDIR_MODE Mode
Definition: cmd.h:351
BYTE Switches
Definition: cmd.h:315
HANDLE OldHandle
Definition: cmd.h:349
INT cmd_cls(LPTSTR)
Definition: cls.c:33
INT CommandEchoerr(LPTSTR)
Definition: echo.c:106
VOID SetHandle(UINT Number, HANDLE Handle)
Definition: redir.c:50
INT CommandAssoc(LPTSTR)
Definition: assoc.c:190
LPTSTR GetTimeString(VOID)
Definition: locale.c:73
VOID freep(LPTSTR *)
Definition: misc.c:447
INT cmd_mkdir(LPTSTR)
Definition: internal.c:322
LPTSTR _stpcpy(LPTSTR, LPCTSTR)
Definition: misc.c:461
Definition: cmd.h:227
struct _PARSED_COMMAND::@54::@58 For
unsigned int BOOL
Definition: ntddk_ex.h:94
INT nNumberGroups
Definition: locale.c:22
VOID error_req_param_missing(VOID)
Definition: error.c:108
INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeparator)
Definition: cmd.c:188
INT cmd_move(LPTSTR)
Definition: move.c:87
INT CommandMemory(LPTSTR)
Definition: memory.c:18
INT cmd_replace(LPTSTR)
Definition: replace.c:392
INT cmd_call(LPTSTR)
Definition: call.c:37
HANDLE RunFile(DWORD, LPTSTR, LPTSTR, LPTSTR, INT)
Definition: cmd.c:265
const WCHAR * str
INT GetDirectoryStackDepth(VOID)
Definition: dirstack.c:98
TCHAR First[]
Definition: cmd.h:304
INT FilePromptYN(UINT)
Definition: misc.c:601
INT ParseCommandLine(LPTSTR)
Definition: cmd.c:631
INT cmd_setlocal(LPTSTR)
Definition: setlocal.c:39
VOID error_out_of_memory(VOID)
Definition: error.c:136
BOOL SearchForExecutable(LPCTSTR, LPTSTR)
Definition: where.c:142
INT cmd_chdir(LPTSTR)
Definition: internal.c:217
VOID error_invalid_parameter_format(LPTSTR)
Definition: error.c:143
TCHAR cTimeSeparator
Definition: locale.c:17
VOID CompleteFilename(LPTSTR, BOOL, LPTSTR, UINT)
Definition: filecomp.c:545
INT cmd_time(LPTSTR)
Definition: time.c:132
TCHAR cThousandSeparator
Definition: locale.c:18
TCHAR cDecimalSeparator
Definition: locale.c:19
LPTSTR DuplicateEnvironment(VOID)
Definition: setlocal.c:22
VOID error_path_not_found(VOID)
Definition: error.c:84
INT FilePromptYNA(UINT)
Definition: misc.c:665
INT cmd_for(LPTSTR)
Definition: for.c:37
BYTE Number
Definition: cmd.h:350
char TCHAR
Definition: xmlstorage.h:189
_In_ HANDLE Handle
Definition: extypes.h:390
BOOL __stdcall PagePrompt(PCON_PAGER Pager, DWORD Done, DWORD Total)
Definition: misc.c:554
BOOL bIgnoreEcho
Definition: cmd.c:155
BOOL IsExistingDirectory(LPCTSTR)
Definition: misc.c:507
GLsizeiptr size
Definition: glext.h:5919
COMMAND cmds[]
Definition: main.c:21
VOID InitDirectoryStack(VOID)
Definition: dirstack.c:80
INT CommandPushd(LPTSTR)
Definition: dirstack.c:107
Definition: cmd.h:292
uint64_t ULONGLONG
Definition: typedefs.h:65
TCHAR * RightArg
Definition: cmd.h:311
BOOL ReadCommand(LPTSTR, INT)
Definition: cmdinput.c:138
GLfloat param
Definition: glext.h:5796
VOID GetPathCase(TCHAR *, TCHAR *)
Definition: misc.c:86
TCHAR Filename[]
Definition: cmd.h:352
INT cmd_title(LPTSTR)
Definition: title.c:18
unsigned short WORD
Definition: ntddk_ex.h:93
TCHAR PathCompletionChar
Definition: cmdinput.c:112
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint num
Definition: glext.h:9618
BOOL SubstituteForVars(TCHAR *Src, TCHAR *Dest)
Definition: cmd.c:1372
#define __stdcall
Definition: typedefs.h:25
INT CommandShowCommands(LPTSTR)
Definition: internal.c:569
VOID error_invalid_switch(TCHAR)
Definition: error.c:70
INT CommandScreen(LPTSTR)
Definition: screen.c:18
VOID error_file_not_found(VOID)
Definition: error.c:91
VOID PrintOSVersion(VOID)
Definition: ver.c:114
Definition: cmd.h:227
LPTSTR lpOriginalEnvironment
Definition: cmd.c:163
struct tagCOMMAND COMMAND
TCHAR * Rest
Definition: cmd.h:303
Definition: ncftp.h:79
BOOL OnOffCommand(LPTSTR param, LPBOOL flag, INT message)
Definition: echo.c:32
WORD wColor
LPTSTR GetDateString(VOID)
Definition: locale.c:58
INT cmd_set(LPTSTR)
Definition: set.c:73
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 flag
Definition: glfuncs.h:52
Definition: sacdrv.h:277
TCHAR cDateSeparator
Definition: locale.c:16
VOID error_sfile_not_found(LPTSTR)
Definition: error.c:98
INT CommandWindow(LPTSTR)
INT CommandPopd(LPTSTR)
Definition: dirstack.c:132
VOID History_del_current_entry(LPTSTR str)
Definition: history.c:175
BOOL StringToColor(LPWORD, LPTSTR *)
Definition: strtoclr.c:255
uint32_t entry
Definition: isohybrid.c:63
int cmd_if(TCHAR *)
INT ExecuteCommand(struct _PARSED_COMMAND *Cmd)
Definition: cmd.c:772
int cmd_pause(TCHAR *)
GLenum GLsizei len
Definition: glext.h:6722
INT cmd_verify(LPTSTR)
Definition: verify.c:30
unsigned char BYTE
Definition: mem.h:68
INT cmd_ver(LPTSTR)
Definition: ver.c:126
VOID UndoRedirection(REDIRECTION *, REDIRECTION *End)
Definition: redir.c:142
INT CommandDelete(LPTSTR)
Definition: del.c:358
VOID FreeCommand(PARSED_COMMAND *Cmd)
Definition: parser.c:1015
struct _PARSED_COMMAND::@54::@57 If
VOID EchoCommand(PARSED_COMMAND *Cmd)
Definition: parser.c:811
BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
Definition: internal.c:182
LPTSTR * split(LPTSTR, LPINT, BOOL, BOOL)
Definition: misc.c:283
_In_opt_ PENTER_STATE_SYSTEM_HANDLER _In_opt_ PVOID _In_ LONG _In_opt_ LONG volatile * Number
Definition: ntpoapi.h:204
INT CommandAlias(LPTSTR)
Definition: alias.c:174
TCHAR Variable
Definition: cmd.h:316
TCHAR AutoCompletionChar
Definition: cmdinput.c:111
Definition: cmd.h:292
INT CommandEchoserr(LPTSTR)
Definition: echo.c:121
BOOL bDisableBatchEcho
Definition: cmd.c:159
struct _REDIRECTION * Redirections
Definition: cmd.h:297
VOID error_too_many_parameters(LPTSTR)
Definition: error.c:77
Definition: cmd.h:227
VOID msg_pause(VOID)
Definition: error.c:165
TCHAR * Unparse(PARSED_COMMAND *Cmd, TCHAR *Out, TCHAR *OutEnd)
Definition: parser.c:905
uint16_t * LPWORD
Definition: typedefs.h:54
INT GetRootPath(TCHAR *InPath, TCHAR *OutPath, INT size)
Definition: internal.c:152
_REDIR_MODE
Definition: cmd.h:340
VOID error_syntax(LPTSTR)
Definition: error.c:150
INT CommandDir(LPTSTR)
Definition: dir.c:1828
INT CommandChoice(LPTSTR)
Definition: choice.c:102
LPCTSTR PeekHistory(INT)
Definition: history.c:287
INT cmd_beep(LPTSTR)
Definition: beep.c:31
BOOL * LPBOOL
Definition: windef.h:162
Definition: cmd.h:227
BOOL ReadLine(TCHAR *commandline, BOOL bMore)
Definition: cmd.c:1435
static const WCHAR des[]
Definition: oid.c:1212
INT cmd_rename(LPTSTR)
Definition: ren.c:53
VOID error_bad_command(LPTSTR)
Definition: error.c:122
VOID RemoveBreakHandler(VOID)
Definition: cmd.c:1559
BOOL bExit
Definition: cmd.c:152
unsigned int UINT
Definition: ndis.h:50
VOID ExpandAlias(LPTSTR, INT)
Definition: alias.c:89
VOID FreeRedirection(REDIRECTION *)
Definition: redir.c:153
BOOL PerformRedirection(REDIRECTION *)
Definition: redir.c:63
VOID AddBreakHandler(VOID)
Definition: cmd.c:1553
INT cmd_ctty(LPTSTR)
Definition: ctty.c:102
PARSED_COMMAND * ParseCommand(LPTSTR Line)
Definition: parser.c:766
struct _PARSED_COMMAND PARSED_COMMAND
struct _REDIRECTION * Next
Definition: cmd.h:348
INT cmd_prompt(LPTSTR)
Definition: prompt.c:231
Definition: cmd.h:292
INT CommandEcho(LPTSTR)
Definition: echo.c:65
INT nDateFormat
Definition: locale.c:20
HANDLE CMD_ModuleHandle
Definition: cmd.c:164
VOID error_no_pipe(VOID)
Definition: error.c:129
INT ExecuteIf(struct _PARSED_COMMAND *Cmd)
Definition: if.c:66
TCHAR cgetchar(VOID)
Definition: misc.c:41
struct tagFORCONTEXT * Context
Definition: cmd.h:319
INT ExecuteFor(struct _PARSED_COMMAND *Cmd)
Definition: for.c:463
VOID History(INT, LPTSTR)
Definition: history.c:326
HANDLE GetHandle(UINT Number)
Definition: redir.c:39
Definition: cmd.h:227
INT CommandDelay(LPTSTR)
Definition: delay.c:17
INT CommandEchos(LPTSTR)
Definition: echo.c:91
VOID FreeLastPath(VOID)
Definition: cmd.h:227
BOOL bDelayedExpansion
Definition: cmd.c:161
Definition: main.c:14
INT CommandExit(LPTSTR)
Definition: internal.c:512
BOOL IsExistingFile(LPCTSTR)
Definition: misc.c:500
BYTE Flags
Definition: cmd.h:308
INT cmd_vol(LPTSTR)
Definition: vol.c:64
VOID InitOSVersion(VOID)
Definition: ver.c:32
VOID PrintPrompt(VOID)
Definition: prompt.c:109
LPTSTR DoDelayedExpansion(LPTSTR Line)
Definition: cmd.c:1408
INT CommandColor(LPTSTR)
Definition: color.c:32
int * LPINT
Definition: windef.h:178
struct _PARSED_COMMAND::@54::@56 Command
WORD wDefColor
Definition: cmd.c:179