Copy w32api from trunk
[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 #ifdef _MSC_VER
35 #define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
36 #else
37 #ifdef __LCC__
38 #define SHELLVER "Version " CMD_VER " [" __DATE__ ", lcc-win32]"
39 #else
40 #define SHELLVER "Version " CMD_VER " [" __DATE__ "]"
41 #endif
42 #endif
43
44
45 #define BREAK_BATCHFILE 1
46 #define BREAK_OUTOFBATCH 2
47 #define BREAK_INPUT 3
48 #define BREAK_IGNORE 4
49
50 /* define some error messages */
51 #define NOENVERR _T("ERROR: no environment")
52 #define INVALIDDRIVE _T("ERROR: invalid drive")
53 #define INVALIDFUNCTION _T("ERROR: invalid function")
54 #define ACCESSDENIED _T("ERROR: access denied")
55 #define BADENVIROMENT _T("ERROR: bad enviroment")
56 #define BADFORMAT _T("ERROR: bad format")
57 #define ERROR_E2BIG _T("ERROR: Argument list too long")
58 #define ERROR_EINVAL _T("ERROR: Invalid argument")
59
60 #define SHELLINFO "ReactOS Command Line Interpreter"
61
62
63 #define D_ON _T("on")
64 #define D_OFF _T("off")
65
66
67 /* command line buffer length */
68 #ifdef __REACTOS__
69 #define CMDLINE_LENGTH 512
70 #else
71 #define CMDLINE_LENGTH 8192
72 //#define CMDLINE_LENGTH 1024
73 #endif
74
75 /* global variables */
76 extern HANDLE hOut;
77 extern HANDLE hIn;
78 extern HANDLE hConsole;
79 extern WORD wColor;
80 extern WORD wDefColor;
81 extern BOOL bCtrlBreak;
82 extern BOOL bIgnoreEcho;
83 extern BOOL bExit;
84 extern INT nErrorLevel;
85 extern SHORT maxx;
86 extern SHORT maxy;
87 extern OSVERSIONINFO osvi;
88
89
90
91 /* Prototypes for ALIAS.C */
92 VOID InitializeAlias (VOID);
93 VOID DestroyAlias (VOID);
94 VOID ExpandAlias (LPTSTR, INT);
95 INT CommandAlias (LPTSTR, LPTSTR);
96
97
98 /* Prototypes for ATTRIB.C */
99 INT CommandAttrib (LPTSTR, LPTSTR);
100
101
102 /* Prototypes for BEEP.C */
103 INT cmd_beep (LPTSTR, LPTSTR);
104
105
106 /* Prototypes for CALL.C */
107 INT cmd_call (LPTSTR, LPTSTR);
108
109
110 /* Prototypes for CHCP.C */
111 INT CommandChcp (LPTSTR, LPTSTR);
112
113
114 /* Prototypes for CHOICE.C */
115 INT CommandChoice (LPTSTR, LPTSTR);
116
117
118 /* Prototypes for CLS.C */
119 INT cmd_cls (LPTSTR, LPTSTR);
120
121
122 /* Prototypes for CMD.C */
123 VOID ParseCommandLine (LPTSTR);
124 VOID AddBreakHandler (VOID);
125 VOID RemoveBreakHandler (VOID);
126
127
128 /* Prototypes for CMDINPUT.C */
129 VOID ReadCommand (LPTSTR, INT);
130
131
132 /* Prototypes for CMDTABLE.C */
133 #define CMD_SPECIAL 1
134 #define CMD_BATCHONLY 2
135 #define CMD_HIDE 4
136
137 typedef struct tagCOMMAND
138 {
139 LPTSTR name;
140 INT flags;
141 INT (*func) (LPTSTR, LPTSTR);
142 } COMMAND, *LPCOMMAND;
143
144 extern COMMAND cmds[]; /* The internal command table */
145
146 VOID PrintCommandList (VOID);
147
148
149 /* Prototypes for COLOR.C */
150 VOID SetScreenColor(WORD wArgColor, BOOL bFill);
151 INT CommandColor (LPTSTR, LPTSTR);
152
153
154 /* Prototypes for CONSOLE.C */
155 #ifdef _DEBUG
156 VOID DebugPrintf (LPTSTR, ...);
157 #endif /* _DEBUG */
158
159 VOID ConInDummy (VOID);
160 VOID ConInDisable (VOID);
161 VOID ConInEnable (VOID);
162 VOID ConInFlush (VOID);
163 VOID ConInKey (PINPUT_RECORD);
164 VOID ConInString (LPTSTR, DWORD);
165
166 VOID ConOutChar (TCHAR);
167 VOID ConOutPuts (LPTSTR);
168 VOID ConOutPrintf (LPTSTR, ...);
169 VOID ConErrChar (TCHAR);
170 VOID ConErrPuts (LPTSTR);
171 VOID ConErrPrintf (LPTSTR, ...);
172 VOID ConOutFormatMessage (DWORD MessageId, ...);
173
174 SHORT GetCursorX (VOID);
175 SHORT GetCursorY (VOID);
176 VOID GetCursorXY (PSHORT, PSHORT);
177 VOID SetCursorXY (SHORT, SHORT);
178
179 VOID GetScreenSize (PSHORT, PSHORT);
180 VOID SetCursorType (BOOL, BOOL);
181
182
183 /* Prototypes for COPY.C */
184 INT cmd_copy (LPTSTR, LPTSTR);
185
186
187 /* Prototypes for DATE.C */
188 INT cmd_date (LPTSTR, LPTSTR);
189
190
191 /* Prototypes for DEL.C */
192 INT CommandDelete (LPTSTR, LPTSTR);
193
194
195 /* Prototypes for DELAY.C */
196 INT CommandDelay (LPTSTR, LPTSTR);
197
198
199 /* Prototypes for DIR.C */
200 INT CommandDir (LPTSTR, LPTSTR);
201
202
203 /* Prototypes for DIRSTACK.C */
204 VOID InitDirectoryStack (VOID);
205 VOID DestroyDirectoryStack (VOID);
206 INT GetDirectoryStackDepth (VOID);
207 INT CommandPushd (LPTSTR, LPTSTR);
208 INT CommandPopd (LPTSTR, LPTSTR);
209 INT CommandDirs (LPTSTR, LPTSTR);
210
211
212 /* Prototypes for ECHO.C */
213 INT CommandEcho (LPTSTR, LPTSTR);
214 INT CommandEchos (LPTSTR, LPTSTR);
215 INT CommandEchoerr (LPTSTR, LPTSTR);
216 INT CommandEchoserr (LPTSTR, LPTSTR);
217
218
219 /* Prototypes for ERROR.C */
220 VOID ErrorMessage (DWORD, LPTSTR, ...);
221
222 VOID error_no_pipe (VOID);
223 VOID error_bad_command (VOID);
224 VOID error_invalid_drive (VOID);
225 VOID error_req_param_missing (VOID);
226 VOID error_sfile_not_found (LPTSTR);
227 VOID error_file_not_found (VOID);
228 VOID error_path_not_found (VOID);
229 VOID error_too_many_parameters (LPTSTR);
230 VOID error_parameter_format(TCHAR);
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 cThousandSeparator;
292 extern TCHAR cDecimalSeparator;
293 extern INT nNumberGroups;
294
295 VOID InitLocale (VOID);
296 VOID PrintDate (VOID);
297 VOID PrintTime (VOID);
298
299
300 /* Prototypes for MEMORY.C */
301 INT CommandMemory (LPTSTR, LPTSTR);
302
303
304 /* Prototypes for MISC.C */
305 TCHAR cgetchar (VOID);
306 BOOL CheckCtrlBreak (INT);
307 LPTSTR *split (LPTSTR, LPINT, BOOL);
308 VOID freep (LPTSTR *);
309 LPTSTR _stpcpy (LPTSTR, LPTSTR);
310 BOOL IsValidPathName (LPCTSTR);
311 BOOL IsExistingFile (LPCTSTR);
312 BOOL IsExistingDirectory (LPCTSTR);
313 BOOL FileGetString (HANDLE, LPTSTR, INT);
314 #ifndef __REACTOS__
315 HWND GetConsoleWindow(VOID);
316 #endif
317
318 #define PROMPT_NO 0
319 #define PROMPT_YES 1
320 #define PROMPT_ALL 2
321 #define PROMPT_BREAK 3
322
323 INT PagePrompt (VOID);
324 INT FilePromptYN (LPTSTR, ...);
325 INT FilePromptYNA (LPTSTR, ...);
326
327
328 /* Prototypes for MOVE.C */
329 INT cmd_move (LPTSTR, LPTSTR);
330
331
332 /* Prototypes for MSGBOX.C */
333 INT CommandMsgbox (LPTSTR, LPTSTR);
334
335
336 /* Prototypes from PATH.C */
337 INT cmd_path (LPTSTR, LPTSTR);
338
339
340 /* Prototypes from PROMPT.C */
341 VOID PrintPrompt (VOID);
342 INT cmd_prompt (LPTSTR, LPTSTR);
343
344
345 /* Prototypes for REDIR.C */
346 #define INPUT_REDIRECTION 1
347 #define OUTPUT_REDIRECTION 2
348 #define OUTPUT_APPEND 4
349 #define ERROR_REDIRECTION 8
350 #define ERROR_APPEND 16
351 INT GetRedirection (LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPINT);
352
353
354 /* Prototypes for REN.C */
355 INT cmd_rename (LPTSTR, LPTSTR);
356
357
358 /* Prototypes for SCREEN.C */
359 INT CommandScreen (LPTSTR, LPTSTR);
360
361
362 /* Prototypes for SET.C */
363 INT cmd_set (LPTSTR, LPTSTR);
364
365
366 /* Prototypes for START.C */
367 INT cmd_start (LPTSTR, LPTSTR);
368
369
370 /* Prototypes for STRTOCLR.C */
371 BOOL StringToColor (LPWORD, LPTSTR *);
372
373
374 /* Prototypes for TIME.C */
375 INT cmd_time (LPTSTR, LPTSTR);
376
377
378 /* Prototypes for TIMER.C */
379 INT CommandTimer (LPTSTR cmd, LPTSTR param);
380
381
382 /* Prototypes for TITLE.C */
383 INT cmd_title (LPTSTR, LPTSTR);
384
385
386 /* Prototypes for TYPE.C */
387 INT cmd_type (LPTSTR, LPTSTR);
388
389
390 /* Prototypes for VER.C */
391 VOID ShortVersion (VOID);
392 INT cmd_ver (LPTSTR, LPTSTR);
393
394
395 /* Prototypes for VERIFY.C */
396 INT cmd_verify (LPTSTR, LPTSTR);
397
398
399 /* Prototypes for VOL.C */
400 INT cmd_vol (LPTSTR, LPTSTR);
401
402
403 /* Prototypes for WHERE.C */
404 BOOL SearchForExecutable (LPCTSTR, LPTSTR);
405
406 /* Prototypes for WINDOW.C */
407 INT CommandActivate (LPTSTR, LPTSTR);
408 INT CommandWindow (LPTSTR, LPTSTR);
409
410
411 /* The MSDOS Batch Commands [MS-DOS 5.0 User's Guide and Reference p359] */
412 int cmd_if(TCHAR *, TCHAR *);
413 int cmd_pause(TCHAR *, TCHAR *);
414 int cmd_shift(TCHAR *, TCHAR *);
415
416 #endif /* _CMD_H_INCLUDED_ */