xref: /reactos/base/shell/cmd/cmdtable.c (revision 2b91b296)
1 /*
2  *  CMDTABLE.C - table of internal commands.
3  *
4  *
5  *  History:
6  *
7  *    16 Jul 1998 (Hans B Pufal)
8  *        started.
9  *        New file to keep the internal command table. I plan on
10  *        getting rid of the table real soon now and replacing it
11  *        with a dynamic mechanism.
12  *
13  *    27 Jul 1998  John P. Price
14  *        added config.h include
15  *
16  *    21-Jan-1999 (Eric Kohl)
17  *        Unicode ready!
18  */
19 
20 #include "precomp.h"
21 
22 /*
23  * A list of all the internal commands, associating their command names
24  * to the functions to process them.
25  */
26 
27 
28 COMMAND cmds[] =
29 {
30     {_T("?"), 0, CommandShowCommands},
31 
32 
33 #ifdef INCLUDE_CMD_ACTIVATE
34     {_T("activate"), 0, CommandActivate},
35 #endif
36 
37 #ifdef FEATURE_ALIASES
38     {_T("alias"), 0, CommandAlias},
39 #endif
40 
41 #ifdef INCLUDE_CMD_ASSOC
42     {_T("assoc"), 0, CommandAssoc},
43 #endif
44 
45 #ifdef INCLUDE_CMD_ATTRIB
46     {_T("attrib"), 0, CommandAttrib},
47 #endif
48 
49 #ifdef INCLUDE_CMD_BEEP
50     {_T("beep"),     0, cmd_beep},
51 #endif
52 
53     {_T("call"), CMD_BATCHONLY, cmd_call},
54 
55 #ifdef INCLUDE_CMD_CHDIR
56     {_T("cd"), CMD_SPECIAL, cmd_chdir},
57     {_T("chdir"), CMD_SPECIAL, cmd_chdir},
58 #endif
59 
60 #ifdef INCLUDE_CMD_CHOICE
61     {_T("choice"), 0, CommandChoice},
62 #endif
63 
64 #ifdef INCLUDE_CMD_CLS
65     {_T("cls"), 0, cmd_cls},
66 #endif
67 
68 #ifdef INCLUDE_CMD_COLOR
69     {_T("color"), 0, CommandColor},
70 #endif
71 
72 #ifdef INCLUDE_CMD_COPY
73     {_T("copy"),     0, cmd_copy},
74 #endif
75 
76 #ifdef INCLUDE_CMD_CTTY
77     {_T("ctty"),     0, cmd_ctty},
78 #endif
79 
80 #ifdef INCLUDE_CMD_DATE
81     {_T("date"),     0, cmd_date},
82 #endif
83 
84 #ifdef INCLUDE_CMD_DEL
85     {_T("del"), 0, CommandDelete},
86     {_T("delete"), 0, CommandDelete},
87 #endif
88 
89 #ifdef INCLUDE_CMD_DELAY
90     {_T("delay"), 0, CommandDelay},
91 #endif
92 
93 #ifdef INCLUDE_CMD_DIR
94     {_T("dir"), CMD_SPECIAL, CommandDir},
95 #endif
96 
97 #ifdef FEATURE_DIRECTORY_STACK
98     {_T("dirs"), 0, CommandDirs},
99 #endif
100 
101     {_T("echo"), CMD_SPECIAL, CommandEcho},
102     {_T("echos"), 0, CommandEchos},
103     {_T("echoerr"), CMD_SPECIAL, CommandEchoerr},
104     {_T("echoserr"), 0, CommandEchoserr},
105 
106     {_T("endlocal"), 0, cmd_endlocal},
107 
108 #ifdef INCLUDE_CMD_DEL
109     {_T("erase"), 0, CommandDelete},
110 #endif
111 
112     {_T("exit"), 0, CommandExit},
113 
114     {_T("for"), 0, cmd_for},
115 
116 #ifdef INCLUDE_CMD_FREE
117     {_T("free"), 0, CommandFree},
118 #endif
119 
120     {_T("goto"), CMD_BATCHONLY, cmd_goto},
121 
122 #ifdef FEATURE_HISTORY
123     {_T("history"), 0, CommandHistory},
124 #endif
125 
126     {_T("if"), 0, cmd_if},
127 
128 #ifdef INCLUDE_CMD_LABEL
129     {_T("label"), 0, cmd_label},
130 #endif
131 
132 #ifdef INCLUDE_CMD_MEMORY
133     {_T("memory"), 0, CommandMemory},
134 #endif
135 
136 #ifdef INCLUDE_CMD_MKDIR
137     {_T("md"), CMD_SPECIAL, cmd_mkdir},
138     {_T("mkdir"), CMD_SPECIAL, cmd_mkdir},
139 #endif
140 
141 #ifdef INCLUDE_CMD_MKLINK
142     {_T("mklink"), 0, cmd_mklink},
143 #endif
144 
145 #ifdef INCLUDE_CMD_MOVE
146     {_T("move"), 0, cmd_move},
147 #endif
148 
149 #ifdef INCLUDE_CMD_MSGBOX
150     {_T("msgbox"), 0, CommandMsgbox},
151 #endif
152 
153 #ifdef INCLUDE_CMD_PATH
154     {_T("path"), 0, cmd_path},
155 #endif
156 
157 #ifdef INCLUDE_CMD_PAUSE
158     {_T("pause"), 0, cmd_pause},
159 #endif
160 
161 #ifdef FEATURE_DIRECTORY_STACK
162     {_T("popd"), 0, CommandPopd},
163 #endif
164 
165 #ifdef INCLUDE_CMD_PROMPT
166     {_T("prompt"), 0, cmd_prompt},
167 #endif
168 
169 #ifdef FEATURE_DIRECTORY_STACK
170     {_T("pushd"), 0, CommandPushd},
171 #endif
172 
173 #ifdef INCLUDE_CMD_RMDIR
174     {_T("rd"), CMD_SPECIAL, cmd_rmdir},
175     {_T("rmdir"), CMD_SPECIAL, cmd_rmdir},
176 #endif
177 
178 #ifdef INCLUDE_CMD_REM
179     {_T("rem"), 0, CommandRem},
180 #endif
181 
182 #ifdef INCLUDE_CMD_RENAME
183     {_T("ren"), 0, cmd_rename},
184     {_T("rename"), 0, cmd_rename},
185 #endif
186 
187 #ifdef INCLUDE_CMD_REPLACE
188     {_T("replace"), 0, cmd_replace},
189 #endif
190 
191 #ifdef INCLUDE_CMD_SCREEN
192     {_T("screen"), 0, CommandScreen},
193 #endif
194 
195 #ifdef INCLUDE_CMD_SET
196     {_T("set"), 0, cmd_set},
197 #endif
198 
199     {_T("setlocal"), 0, cmd_setlocal},
200 
201     {_T("shift"), CMD_BATCHONLY, cmd_shift},
202 
203 #ifdef INCLUDE_CMD_START
204     {_T("start"), 0, cmd_start},
205 #endif
206 
207 #ifdef INCLUDE_CMD_TIME
208     {_T("time"), 0, cmd_time},
209 #endif
210 
211 #ifdef INCLUDE_CMD_TIMER
212     {_T("timer"), 0, CommandTimer},
213 #endif
214 
215 #ifdef INCLUDE_CMD_TITLE
216     {_T("title"), 0, cmd_title},
217 #endif
218 
219 #ifdef INCLUDE_CMD_TYPE
220     {_T("type"), 0, cmd_type},
221 #endif
222 
223 #ifdef INCLUDE_CMD_VER
224     {_T("ver"), 0, cmd_ver},
225 #endif
226 
227 #ifdef INCLUDE_CMD_VERIFY
228     {_T("verify"), 0, cmd_verify},
229 #endif
230 
231 #ifdef INCLUDE_CMD_VOL
232     {_T("vol"), 0, cmd_vol},
233 #endif
234 
235 #ifdef INCLUDE_CMD_WINDOW
236     {_T("window"), 0, CommandWindow},
237 #endif
238 
239     {NULL, 0, NULL}
240 };
241 
242 VOID PrintCommandList(VOID)
243 {
244     LPCOMMAND cmdptr;
245     INT y;
246 
247     y = 0;
248     cmdptr = cmds;
249     while (cmdptr->name)
250     {
251         if (!(cmdptr->flags & CMD_HIDE))
252         {
253             if (++y == 8)
254             {
255                 ConOutPuts(cmdptr->name);
256                 ConOutChar(_T('\n'));
257                 y = 0;
258             }
259             else
260             {
261                 ConOutPrintf (_T("%-10s"), cmdptr->name);
262             }
263         }
264 
265         cmdptr++;
266     }
267 
268     if (y != 0)
269         ConOutChar(_T('\n'));
270 }
271 
272 /* EOF */
273