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