Merge 14551:14980 from trunk
[reactos.git] / reactos / subsys / system / 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 * 30-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>)
23 * Remove all hardcode string to En.rc
24 */
25
26 #include "precomp.h"
27 #include "resource.h"
28
29
30 /*
31 * Perform the SHIFT command.
32 *
33 * Only valid inside batch files.
34 *
35 * FREEDOS extension : optional parameter DOWN to allow shifting
36 * parameters backwards.
37 *
38 */
39
40 INT cmd_shift (LPTSTR cmd, LPTSTR param)
41 {
42 TCHAR szMsg[RC_STRING_MAX_SIZE];
43
44 #ifdef _DEBUG
45 DebugPrintf (_T("cmd_shift: (\'%s\', \'%s\')\n"), cmd, param);
46 #endif
47
48 if (!_tcsncmp (param, _T("/?"), 2))
49 {
50 LoadString(GetModuleHandle(NULL), STRING_SHIFT_HELP, szMsg, RC_STRING_MAX_SIZE);
51 ConOutPuts(szMsg);
52 return 0;
53 }
54
55 if (bc == NULL)
56 {
57 /* not in batch - error!! */
58 return 1;
59 }
60
61 if (!_tcsicmp (param, _T("down")))
62 {
63 if (bc->shiftlevel)
64 bc->shiftlevel--;
65 }
66 else /* shift up */
67 bc->shiftlevel++;
68
69 return 0;
70 }
71
72 /* EOF */