Fixed 'echo.' and 'echoerr.'
[reactos.git] / rosapps / cmd / cmd.h
1 /* $Id: cmd.h,v 1.20 2000/07/19 06:58:13 ekohl Exp $
2 *
3 * CMD.H - header file for the modules in CMD.EXE
4 *
5 *
6 * History:
7 *
8 * 7-15-95 Tim Norman
9 * started
10 *
11 * 06/29/98 (Rob Lake)
12 * Moved error messages in here
13 *
14 * 07/12/98 (Rob Lake)
15 * Moved more error messages here.
16 *
17 * 30-Jul-1998 (John P Price <linux-guru@gcfl.net>)
18 * Added compile date to version.
19 *
20 * 26-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
21 * Introduced a new version string.
22 * Thanks to Emanuele Aliberti!
23 */
24
25 #ifndef _CMD_H_INCLUDED_
26 #define _CMD_H_INCLUDED_
27
28 #include "config.h"
29
30 #include <windows.h>
31 #include <tchar.h>
32
33 #include "cmdver.h"
34
35 #ifdef _MSC_VER
36 #define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
37 #else
38 #ifdef __LCC__
39 #define SHELLVER "Version " CMD_VER " [" __DATE__ ", lcc-win32]"
40 #else
41 #define SHELLVER "Version " CMD_VER " [" __DATE__ "]"
42 #endif
43 #endif
44
45
46 #define BREAK_BATCHFILE 1
47 #define BREAK_OUTOFBATCH 2
48 #define BREAK_INPUT 3
49 #define BREAK_IGNORE 4
50
51 /* define some error messages */
52 #define NOENVERR "ERROR: no environment"
53 #define INVALIDDRIVE "ERROR: invalid drive"
54 #define INVALIDFUNCTION "ERROR: invalid function"
55 #define ACCESSDENIED "ERROR: access denied"
56 #define BADENVIROMENT "ERROR: bad enviroment"
57 #define BADFORMAT "ERROR: bad format"
58 #define ERROR_E2BIG "ERROR: Argument list too long"
59 #define ERROR_EINVAL "ERROR: Invalid argument"
60
61 #define SHELLINFO "ReactOS Command Line Interpreter"
62
63
64 #define D_ON "on"
65 #define D_OFF "off"
66
67
68
69 /* global variables */
70 extern HANDLE hOut;
71 extern HANDLE hIn;
72 extern WORD wColor;
73 extern WORD wDefColor;
74 extern BOOL bCtrlBreak;
75 extern BOOL bIgnoreEcho;
76 extern BOOL bExit;
77 extern INT nErrorLevel;
78 extern SHORT maxx;
79 extern SHORT maxy;
80 extern OSVERSIONINFO osvi;
81
82
83
84 /* Prototypes for ALIAS.C */
85 VOID InitializeAlias (VOID);
86 VOID DestroyAlias (VOID);
87 VOID ExpandAlias (LPTSTR, INT);
88 INT CommandAlias (LPTSTR, LPTSTR);
89
90
91 /* Prototypes for ATTRIB.C */
92 INT CommandAttrib (LPTSTR, LPTSTR);
93
94
95 /* Prototypes for BEEP.C */
96 INT cmd_beep (LPTSTR, LPTSTR);
97
98
99 /* Prototypes for CALL.C */
100 INT cmd_call (LPTSTR, LPTSTR);
101
102
103 /* Prototypes for CHCP.C */
104 INT CommandChcp (LPTSTR, LPTSTR);
105
106
107 /* Prototypes for CHOICE.C */
108 INT CommandChoice (LPTSTR, LPTSTR);
109
110
111 /* Prototypes for CLS.C */
112 INT cmd_cls (LPTSTR, LPTSTR);
113
114
115 /* Prototypes for CMD.C */
116 VOID ParseCommandLine (LPTSTR);
117 VOID AddBreakHandler (VOID);
118 VOID RemoveBreakHandler (VOID);
119
120
121 /* Prototypes for CMDINPUT.C */
122 VOID ReadCommand (LPTSTR, INT);
123
124
125 /* Prototypes for CMDTABLE.C */
126 #define CMD_SPECIAL 1
127 #define CMD_BATCHONLY 2
128 #define CMD_HIDE 4
129
130 typedef struct tagCOMMAND
131 {
132 LPTSTR name;
133 INT flags;
134 INT (*func) (LPTSTR, LPTSTR);
135 } COMMAND, *LPCOMMAND;
136
137 extern COMMAND cmds[]; /* The internal command table */
138
139 VOID PrintCommandList (VOID);
140
141
142 /* Prototypes for COLOR.C */
143 VOID SetScreenColor(WORD wArgColor, BOOL bFill);
144 INT CommandColor (LPTSTR, LPTSTR);
145
146
147 /* Prototypes for CONSOLE.C */
148 #ifdef _DEBUG
149 VOID DebugPrintf (LPTSTR, ...);
150 #endif /* _DEBUG */
151
152 VOID ConInDummy (VOID);
153 VOID ConInDisable (VOID);
154 VOID ConInEnable (VOID);
155 VOID ConInFlush (VOID);
156 VOID ConInKey (PINPUT_RECORD);
157 VOID ConInString (LPTSTR, DWORD);
158
159 VOID ConOutChar (TCHAR);
160 VOID ConOutPuts (LPTSTR);
161 VOID ConOutPrintf (LPTSTR, ...);
162 VOID ConErrChar (TCHAR);
163 VOID ConErrPuts (LPTSTR);
164 VOID ConErrPrintf (LPTSTR, ...);
165
166 SHORT GetCursorX (VOID);
167 SHORT GetCursorY (VOID);
168 VOID GetCursorXY (PSHORT, PSHORT);
169 VOID SetCursorXY (SHORT, SHORT);
170
171 VOID GetScreenSize (PSHORT, PSHORT);
172 VOID SetCursorType (BOOL, BOOL);
173
174
175 /* Prototypes for COPY.C */
176 INT cmd_copy (LPTSTR, LPTSTR);
177
178
179 /* Prototypes for DATE.C */
180 INT cmd_date (LPTSTR, LPTSTR);
181
182
183 /* Prototypes for DEL.C */
184 INT CommandDelete (LPTSTR, LPTSTR);
185
186
187 /* Prototypes for DELAY.C */
188 INT CommandDelay (LPTSTR, LPTSTR);
189
190
191 /* Prototypes for DIR.C */
192 INT CommandDir (LPTSTR, LPTSTR);
193
194
195 /* Prototypes for DIRSTACK.C */
196 VOID InitDirectoryStack (VOID);
197 VOID DestroyDirectoryStack (VOID);
198 INT GetDirectoryStackDepth (VOID);
199 INT CommandPushd (LPTSTR, LPTSTR);
200 INT CommandPopd (LPTSTR, LPTSTR);
201 INT CommandDirs (LPTSTR, LPTSTR);
202
203
204 /* Prototypes for ECHO.C */
205 INT CommandEcho (LPTSTR, LPTSTR);
206 INT CommandEchos (LPTSTR, LPTSTR);
207 INT CommandEchoerr (LPTSTR, LPTSTR);
208 INT CommandEchoserr (LPTSTR, LPTSTR);
209
210
211 /* Prototypes for ERROR.C */
212 VOID ErrorMessage (DWORD, LPTSTR, ...);
213
214 VOID error_no_pipe (VOID);
215 VOID error_bad_command (VOID);
216 VOID error_invalid_drive (VOID);
217 VOID error_req_param_missing (VOID);
218 VOID error_sfile_not_found (LPTSTR);
219 VOID error_file_not_found (VOID);
220 VOID error_path_not_found (VOID);
221 VOID error_too_many_parameters (LPTSTR);
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);
226
227 VOID msg_pause (VOID);
228
229
230 /* Prototypes for FILECOMP.C */
231 #ifdef FEATURE_UNIX_FILENAME_COMPLETION
232 VOID CompleteFilename (LPTSTR, INT);
233 INT ShowCompletionMatches (LPTSTR, INT);
234 #endif
235 #ifdef FEATURE_4NT_FILENAME_COMPLETION
236 #endif
237
238
239 /* Prototypes for FOR.C */
240 INT cmd_for (LPTSTR, LPTSTR);
241
242
243 /* Prototypes for FREE.C */
244 INT CommandFree (LPTSTR, LPTSTR);
245
246
247 /* Prototypes for GOTO.C */
248 INT cmd_goto (LPTSTR, LPTSTR);
249
250
251 /* Prototypes for HISTORY.C */
252 #ifdef FEATURE_HISTORY
253 VOID History (INT, LPTSTR);/*add entries browse history*/
254 VOID History_move_to_bottom(VOID);/*F3*/
255 VOID InitHistory(VOID);
256 VOID CleanHistory(VOID);
257 VOID History_del_current_entry(LPTSTR str);/*CTRL-D*/
258 INT CommandHistory (LPTSTR cmd, LPTSTR param);
259 #endif
260
261
262 /* Prototypes for INTERNAL.C */
263 VOID InitLastPath (VOID);
264 VOID FreeLastPath (VOID);
265 INT cmd_chdir (LPTSTR, LPTSTR);
266 INT cmd_mkdir (LPTSTR, LPTSTR);
267 INT cmd_rmdir (LPTSTR, LPTSTR);
268 INT CommandExit (LPTSTR, LPTSTR);
269 INT CommandRem (LPTSTR, LPTSTR);
270 INT CommandShowCommands (LPTSTR, LPTSTR);
271
272
273 /* Prototypes for LABEL.C */
274 INT cmd_label (LPTSTR, LPTSTR);
275
276
277 /* Prototypes for LOCALE.C */
278 extern TCHAR cDateSeparator;
279 extern INT nDateFormat;
280 extern TCHAR cTimeSeparator;
281 extern INT nTimeFormat;
282 extern TCHAR aszDayNames[7][8];
283 extern TCHAR cThousandSeparator;
284 extern TCHAR cDecimalSeparator;
285 extern INT nNumberGroups;
286
287 VOID InitLocale (VOID);
288 VOID PrintDate (VOID);
289 VOID PrintTime (VOID);
290
291
292 /* Prototypes for MEMORY.C */
293 INT CommandMemory (LPTSTR, LPTSTR);
294
295
296 /* Prototypes for MISC.C */
297 TCHAR cgetchar (VOID);
298 BOOL CheckCtrlBreak (INT);
299 LPTSTR *split (LPTSTR, LPINT);
300 VOID freep (LPTSTR *);
301 LPTSTR stpcpy (LPTSTR, LPTSTR);
302 BOOL IsValidPathName (LPCTSTR);
303 BOOL IsValidFileName (LPCTSTR);
304 BOOL IsValidDirectory (LPCTSTR);
305 BOOL FileGetString (HANDLE, LPTSTR, INT);
306 #ifndef __REACTOS__
307 HWND GetConsoleWindow(VOID);
308 #endif
309
310 #define PROMPT_NO 0
311 #define PROMPT_YES 1
312 #define PROMPT_ALL 2
313 #define PROMPT_BREAK 3
314
315 INT PagePrompt (VOID);
316 INT FilePromptYN (LPTSTR, ...);
317 INT FilePromptYNA (LPTSTR, ...);
318
319
320 /* Prototypes for MOVE.C */
321 INT cmd_move (LPTSTR, LPTSTR);
322
323
324 /* Prototypes for MSGBOX.C */
325 INT CommandMsgbox (LPTSTR, LPTSTR);
326
327
328 /* Prototypes from PATH.C */
329 INT cmd_path (LPTSTR, LPTSTR);
330
331
332 /* Prototypes from PROMPT.C */
333 VOID PrintPrompt (VOID);
334 INT cmd_prompt (LPTSTR, LPTSTR);
335
336
337 /* Prototypes for REDIR.C */
338 #define INPUT_REDIRECTION 1
339 #define OUTPUT_REDIRECTION 2
340 #define OUTPUT_APPEND 4
341 #define ERROR_REDIRECTION 8
342 #define ERROR_APPEND 16
343 INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
344
345
346 /* Prototypes for REN.C */
347 INT cmd_rename (LPTSTR, LPTSTR);
348
349
350 /* Prototypes for SCREEN.C */
351 INT CommandScreen (LPTSTR, LPTSTR);
352
353
354 /* Prototypes for SET.C */
355 INT cmd_set (LPTSTR, LPTSTR);
356
357
358 /* Prototypes for START.C */
359 INT cmd_start (LPTSTR, LPTSTR);
360
361
362 /* Prototypes for STRTOCLR.C */
363 BOOL StringToColor (LPWORD, LPTSTR *);
364
365
366 /* Prototypes for TIME.C */
367 INT cmd_time (LPTSTR, LPTSTR);
368
369
370 /* Prototypes for TIMER.C */
371 INT CommandTimer (LPTSTR cmd, LPTSTR param);
372
373
374 /* Prototypes for TITLE.C */
375 INT cmd_title (LPTSTR, LPTSTR);
376
377
378 /* Prototypes for TYPE.C */
379 INT cmd_type (LPTSTR, LPTSTR);
380
381
382 /* Prototypes for VER.C */
383 VOID ShortVersion (VOID);
384 INT cmd_ver (LPTSTR, LPTSTR);
385
386
387 /* Prototypes for VERIFY.C */
388 INT cmd_verify (LPTSTR, LPTSTR);
389
390
391 /* Prototypes for VOL.C */
392 INT cmd_vol (LPTSTR, LPTSTR);
393
394
395 /* Prototypes for WHERE.C */
396 BOOL SearchForExecutable (LPCTSTR, LPTSTR);
397
398 /* Prototypes for WINDOW.C */
399 INT CommandActivate (LPTSTR, LPTSTR);
400 INT CommandWindow (LPTSTR, LPTSTR);
401
402
403 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
404 int cmd_if(char *, char *);
405 int cmd_pause(char *, char *);
406 int cmd_shift(char *, char *);
407
408 #endif /* _CMD_H_INCLUDED_ */