Added Eric Kohl's port of freedos command
[reactos.git] / rosapps / cmd / shift.c
1 /*
2 * SHIFT.C - shift internal batch command
3 *
4 *
5 * History:
6 *
7 * 16 Jul 1998 (Hans B Pufal)
8 * started.
9 *
10 * 16 Jul 1998 (John P Price)
11 * Separated commands into individual files.
12 *
13 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
14 * added config.h include
15 *
16 * 07-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
17 * Added help text ("shift /?") and cleaned up.
18 *
19 * 20-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
20 * Unicode and redirection safe!
21 */
22
23 #define WIN32_LEAN_AND_MEAN
24
25 #include "config.h"
26
27 #include <windows.h>
28 #include <tchar.h>
29 #include <string.h>
30
31 #include "cmd.h"
32 #include "batch.h"
33
34
35 /*
36 * Perform the SHIFT command.
37 *
38 * Only valid inside batch files.
39 *
40 * FREEDOS extension : optional parameter DOWN to allow shifting
41 * parameters backwards.
42 */
43
44 INT cmd_shift (LPTSTR cmd, LPTSTR param)
45 {
46 #ifdef _DEBUG
47 DebugPrintf ("cmd_shift: (\'%s\', \'%s\'\n", cmd, param);
48 #endif
49
50 if (!_tcsncmp (param, _T("/?"), 2))
51 {
52 ConOutPuts (_T("Changes the position of replaceable parameters in a batch file.\n\n"
53 "SHIFT [DOWN]"));
54 return 0;
55 }
56
57 if (bc == NULL)
58 {
59 /* not in batch - error!! */
60 return 1;
61 }
62
63 if (!_tcsicmp (param, _T("down")))
64 {
65 if (bc->shiftlevel)
66 bc->shiftlevel--;
67 }
68 else /* shift up */
69 bc->shiftlevel++;
70
71 return 0;
72 }