cmd.exe: Support for DEL filename /s.
[wine] / programs / cmd / wcmd.h
1 /*
2  * CMD - Wine-compatible command line interface.
3  *
4  * Copyright (C) 1999 D A Pickles
5  *
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.
10  *
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.
15  *
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
19  */
20
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
30 void WCMD_assoc (char *, BOOL);
31 void WCMD_batch (char *, char *, int, char *, HANDLE);
32 void WCMD_call (char *command);
33 void WCMD_change_tty (void);
34 void WCMD_clear_screen (void);
35 void WCMD_color (void);
36 void WCMD_copy (void);
37 void WCMD_create_dir (void);
38 BOOL WCMD_delete (char *, BOOL);
39 void WCMD_directory (char *);
40 void WCMD_echo (const char *);
41 void WCMD_endlocal (void);
42 void WCMD_enter_paged_mode(const char *);
43 void WCMD_exit (void);
44 void WCMD_for (char *);
45 void WCMD_give_help (char *command);
46 void WCMD_goto (void);
47 void WCMD_if (char *);
48 void WCMD_leave_paged_mode(void);
49 void WCMD_more (char *);
50 void WCMD_move (void);
51 void WCMD_output (const char *format, ...);
52 void WCMD_output_asis (const char *message);
53 void WCMD_parse (char *s, char *q, char *p1, char *p2);
54 void WCMD_pause (void);
55 void WCMD_pipe (char *command);
56 void WCMD_popd (void);
57 void WCMD_print_error (void);
58 void WCMD_process_command (char *command);
59 void WCMD_pushd (char *);
60 int  WCMD_read_console (char *string, int str_len);
61 void WCMD_remove_dir (char *command);
62 void WCMD_rename (void);
63 void WCMD_run_program (char *command, int called);
64 void WCMD_setlocal (const char *command);
65 void WCMD_setshow_attrib (void);
66 void WCMD_setshow_date (void);
67 void WCMD_setshow_default (char *command);
68 void WCMD_setshow_env (char *command);
69 void WCMD_setshow_path (char *command);
70 void WCMD_setshow_prompt (void);
71 void WCMD_setshow_time (void);
72 void WCMD_shift (char *command);
73 void WCMD_show_prompt (void);
74 void WCMD_title (char *);
75 void WCMD_type (char *);
76 void WCMD_verify (char *command);
77 void WCMD_version (void);
78 int  WCMD_volume (int mode, char *command);
79
80 char *WCMD_fgets (char *s, int n, HANDLE stream);
81 char *WCMD_parameter (char *s, int n, char **where);
82 char *WCMD_strtrim_leading_spaces (char *string);
83 void WCMD_strtrim_trailing_spaces (char *string);
84 void WCMD_opt_s_strip_quotes(char *cmd);
85 void WCMD_HandleTildaModifiers(char **start, char *forVariable);
86 BOOL WCMD_ask_confirm (char *message, BOOL showSureText);
87
88 void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);
89
90 /*      Data structure to hold context when executing batch files */
91
92 typedef struct {
93   char *command;        /* The command which invoked the batch file */
94   HANDLE h;             /* Handle to the open batch file */
95   int shift_count[10];  /* Offset in terms of shifts for %0 - %9 */
96   void *prev_context;   /* Pointer to the previous context block */
97   BOOL  skip_rest;      /* Skip the rest of the batch program and exit */
98 } BATCH_CONTEXT;
99
100 /* Data structure to save setlocal and pushd information */
101
102 struct env_stack
103 {
104   struct env_stack *next;
105   union {
106     int    stackdepth;       /* Only used for pushd and popd */
107     char   cwd;              /* Only used for set/endlocal   */
108   } u;
109   WCHAR *strings;
110 };
111
112 /* Data structure to handle building lists during recursive calls */
113
114 typedef struct _DIRECTORY_STACK
115 {
116   struct _DIRECTORY_STACK *next;
117   char  *dirName;
118   char  *fileName;
119 } DIRECTORY_STACK;
120
121 #endif /* !RC_INVOKED */
122
123 /*
124  *      Serial nos of builtin commands. These constants must be in step with
125  *      the list of strings defined in WCMD.C, and WCMD_EXIT *must* always be
126  *      the last one.
127  *
128  *      Yes it *would* be nice to use an enumeration here, but the Resource
129  *      Compiler won't accept resource IDs from enumerations :-(
130  */
131
132 #define WCMD_ATTRIB  0
133 #define WCMD_CALL    1
134 #define WCMD_CD      2
135 #define WCMD_CHDIR   3
136 #define WCMD_CLS     4
137 #define WCMD_COPY    5
138 #define WCMD_CTTY    6
139 #define WCMD_DATE    7
140 #define WCMD_DEL     8
141 #define WCMD_DIR     9
142 #define WCMD_ECHO   10
143 #define WCMD_ERASE  11
144 #define WCMD_FOR    12
145 #define WCMD_GOTO   13
146 #define WCMD_HELP   14
147 #define WCMD_IF     15
148 #define WCMD_LABEL  16
149 #define WCMD_MD     17
150 #define WCMD_MKDIR  18
151 #define WCMD_MOVE   19
152 #define WCMD_PATH   20
153 #define WCMD_PAUSE  21
154 #define WCMD_PROMPT 22
155 #define WCMD_REM    23
156 #define WCMD_REN    24
157 #define WCMD_RENAME 25
158 #define WCMD_RD     26
159 #define WCMD_RMDIR  27
160 #define WCMD_SET    28
161 #define WCMD_SHIFT  29
162 #define WCMD_TIME   30
163 #define WCMD_TITLE  31
164 #define WCMD_TYPE   32
165 #define WCMD_VERIFY 33
166 #define WCMD_VER    34
167 #define WCMD_VOL    35
168
169 #define WCMD_ENDLOCAL 36
170 #define WCMD_SETLOCAL 37
171 #define WCMD_PUSHD  38
172 #define WCMD_POPD   39
173 #define WCMD_ASSOC  40
174 #define WCMD_COLOR  41
175 #define WCMD_FTYPE  42
176 #define WCMD_MORE   43
177
178 /* Must be last in list */
179 #define WCMD_EXIT   44
180
181 /* Some standard messages */
182 extern const char nyi[];
183 extern const char newline[];
184 extern const char version_string[];
185 extern const char anykey[];
186
187 /* Translated messages */
188 #define WCMD_CONFIRM  1001
189 #define WCMD_YES      1002
190 #define WCMD_NO       1003
191 #define WCMD_NOASSOC  1004
192 #define WCMD_NOFTYPE  1005
193 #define WCMD_OVERWRITE 1006
194 #define WCMD_MORESTR  1007
195
196 /* msdn specified max for Win XP */
197 #define MAXSTRING 8192