cmd.exe: Fix FOR so it works as 'well' as before.
[wine.git] / programs / cmd / wcmd.h
blob0781fb6c8f451d7cadba8c551479c86147fb93c5
1 /*
2 * CMD - Wine-compatible command line interface.
4 * Copyright (C) 1999 D A Pickles
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define IDI_ICON1 1
22 #include <windows.h>
23 #ifndef RC_INVOKED
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <ctype.h>
29 #include <wine/unicode.h>
31 /* Data structure to hold commands to be processed */
33 typedef struct _CMD_LIST {
34 WCHAR *command; /* Command string to execute */
35 struct _CMD_LIST *nextcommand; /* Next command string to execute */
36 BOOL isAmphersand;/* Whether follows && */
37 int bracketDepth;/* How deep bracketing have we got to */
38 } CMD_LIST;
40 void WCMD_assoc (WCHAR *, BOOL);
41 void WCMD_batch (WCHAR *, WCHAR *, int, WCHAR *, HANDLE);
42 void WCMD_call (WCHAR *command);
43 void WCMD_change_tty (void);
44 void WCMD_clear_screen (void);
45 void WCMD_color (void);
46 void WCMD_copy (void);
47 void WCMD_create_dir (void);
48 BOOL WCMD_delete (WCHAR *, BOOL);
49 void WCMD_directory (WCHAR *);
50 void WCMD_echo (const WCHAR *);
51 void WCMD_endlocal (void);
52 void WCMD_enter_paged_mode(const WCHAR *);
53 void WCMD_exit (CMD_LIST **cmdList);
54 void WCMD_for (WCHAR *, CMD_LIST **cmdList);
55 void WCMD_give_help (WCHAR *command);
56 void WCMD_goto (CMD_LIST **cmdList);
57 void WCMD_if (WCHAR *, CMD_LIST **cmdList);
58 void WCMD_leave_paged_mode(void);
59 void WCMD_more (WCHAR *);
60 void WCMD_move (void);
61 void WCMD_output (const WCHAR *format, ...);
62 void WCMD_output_asis (const WCHAR *message);
63 void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2);
64 void WCMD_pause (void);
65 void WCMD_pipe (CMD_LIST **command, WCHAR *var, WCHAR *val);
66 void WCMD_popd (void);
67 void WCMD_print_error (void);
68 void WCMD_process_command (WCHAR *command, CMD_LIST **cmdList);
69 void WCMD_pushd (WCHAR *);
70 int WCMD_read_console (WCHAR *string, int str_len);
71 void WCMD_remove_dir (WCHAR *command);
72 void WCMD_rename (void);
73 void WCMD_run_program (WCHAR *command, int called);
74 void WCMD_setlocal (const WCHAR *command);
75 void WCMD_setshow_attrib (void);
76 void WCMD_setshow_date (void);
77 void WCMD_setshow_default (WCHAR *command);
78 void WCMD_setshow_env (WCHAR *command);
79 void WCMD_setshow_path (WCHAR *command);
80 void WCMD_setshow_prompt (void);
81 void WCMD_setshow_time (void);
82 void WCMD_shift (WCHAR *command);
83 void WCMD_show_prompt (void);
84 void WCMD_title (WCHAR *);
85 void WCMD_type (WCHAR *);
86 void WCMD_verify (WCHAR *command);
87 void WCMD_version (void);
88 int WCMD_volume (int mode, WCHAR *command);
90 WCHAR *WCMD_fgets (WCHAR *s, int n, HANDLE stream);
91 WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where);
92 WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string);
93 void WCMD_strtrim_trailing_spaces (WCHAR *string);
94 void WCMD_opt_s_strip_quotes(WCHAR *cmd);
95 void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable);
96 BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll);
98 void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
99 WCHAR *WCMD_LoadMessage(UINT id);
100 WCHAR *WCMD_strdupW(WCHAR *input);
101 BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars,
102 LPDWORD charsRead, const LPOVERLAPPED unused);
104 WCHAR *WCMD_ReadAndParseLine(WCHAR *initialcmd, CMD_LIST **output, HANDLE readFrom);
105 CMD_LIST *WCMD_process_commands(CMD_LIST *thisCmd, BOOL oneBracket, WCHAR *var, WCHAR *val);
106 void WCMD_free_commands(CMD_LIST *cmds);
107 void WCMD_execute (WCHAR *orig_command, WCHAR *parameter, WCHAR *substitution, CMD_LIST **cmdList);
109 /* Data structure to hold context when executing batch files */
111 typedef struct {
112 WCHAR *command; /* The command which invoked the batch file */
113 HANDLE h; /* Handle to the open batch file */
114 int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
115 void *prev_context; /* Pointer to the previous context block */
116 BOOL skip_rest; /* Skip the rest of the batch program and exit */
117 CMD_LIST *toExecute; /* Commands left to be executed */
118 } BATCH_CONTEXT;
120 /* Data structure to save setlocal and pushd information */
122 struct env_stack
124 struct env_stack *next;
125 union {
126 int stackdepth; /* Only used for pushd and popd */
127 WCHAR cwd; /* Only used for set/endlocal */
128 } u;
129 WCHAR *strings;
132 /* Data structure to handle building lists during recursive calls */
134 typedef struct _DIRECTORY_STACK
136 struct _DIRECTORY_STACK *next;
137 WCHAR *dirName;
138 WCHAR *fileName;
139 } DIRECTORY_STACK;
141 #endif /* !RC_INVOKED */
144 * Serial nos of builtin commands. These constants must be in step with
145 * the list of strings defined in WCMD.C, and WCMD_EXIT *must* always be
146 * the last one.
148 * Yes it *would* be nice to use an enumeration here, but the Resource
149 * Compiler won't accept resource IDs from enumerations :-(
152 #define WCMD_ATTRIB 0
153 #define WCMD_CALL 1
154 #define WCMD_CD 2
155 #define WCMD_CHDIR 3
156 #define WCMD_CLS 4
157 #define WCMD_COPY 5
158 #define WCMD_CTTY 6
159 #define WCMD_DATE 7
160 #define WCMD_DEL 8
161 #define WCMD_DIR 9
162 #define WCMD_ECHO 10
163 #define WCMD_ERASE 11
164 #define WCMD_FOR 12
165 #define WCMD_GOTO 13
166 #define WCMD_HELP 14
167 #define WCMD_IF 15
168 #define WCMD_LABEL 16
169 #define WCMD_MD 17
170 #define WCMD_MKDIR 18
171 #define WCMD_MOVE 19
172 #define WCMD_PATH 20
173 #define WCMD_PAUSE 21
174 #define WCMD_PROMPT 22
175 #define WCMD_REM 23
176 #define WCMD_REN 24
177 #define WCMD_RENAME 25
178 #define WCMD_RD 26
179 #define WCMD_RMDIR 27
180 #define WCMD_SET 28
181 #define WCMD_SHIFT 29
182 #define WCMD_TIME 30
183 #define WCMD_TITLE 31
184 #define WCMD_TYPE 32
185 #define WCMD_VERIFY 33
186 #define WCMD_VER 34
187 #define WCMD_VOL 35
189 #define WCMD_ENDLOCAL 36
190 #define WCMD_SETLOCAL 37
191 #define WCMD_PUSHD 38
192 #define WCMD_POPD 39
193 #define WCMD_ASSOC 40
194 #define WCMD_COLOR 41
195 #define WCMD_FTYPE 42
196 #define WCMD_MORE 43
198 /* Must be last in list */
199 #define WCMD_EXIT 44
201 /* Some standard messages */
202 extern const WCHAR newline[];
203 extern WCHAR anykey[];
204 extern WCHAR version_string[];
206 /* Translated messages */
207 #define WCMD_ALLHELP 1000
208 #define WCMD_CONFIRM 1001
209 #define WCMD_YES 1002
210 #define WCMD_NO 1003
211 #define WCMD_NOASSOC 1004
212 #define WCMD_NOFTYPE 1005
213 #define WCMD_OVERWRITE 1006
214 #define WCMD_MORESTR 1007
215 #define WCMD_TRUNCATEDLINE 1008
216 #define WCMD_NYI 1009
217 #define WCMD_NOARG 1010
218 #define WCMD_SYNTAXERR 1011
219 #define WCMD_FILENOTFOUND 1012
220 #define WCMD_NOCMDHELP 1013
221 #define WCMD_NOTARGET 1014
222 #define WCMD_CURRENTDATE 1015
223 #define WCMD_CURRENTTIME 1016
224 #define WCMD_NEWDATE 1017
225 #define WCMD_NEWTIME 1018
226 #define WCMD_MISSINGENV 1019
227 #define WCMD_READFAIL 1020
228 #define WCMD_CALLINSCRIPT 1021
229 #define WCMD_ALL 1022
230 #define WCMD_DELPROMPT 1023
231 #define WCMD_ECHOPROMPT 1024
232 #define WCMD_VERIFYPROMPT 1025
233 #define WCMD_VERIFYERR 1026
234 #define WCMD_ARGERR 1027
235 #define WCMD_VOLUMEDETAIL 1028
236 #define WCMD_VOLUMEPROMPT 1029
237 #define WCMD_NOPATH 1030
238 #define WCMD_ANYKEY 1031
239 #define WCMD_CONSTITLE 1032
240 #define WCMD_VERSION 1033
241 #define WCMD_MOREPROMPT 1034
243 /* msdn specified max for Win XP */
244 #define MAXSTRING 8192