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