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) 17 * Added help text ("shift /?") and cleaned up. 18 * 19 * 20-Jan-1999 (Eric Kohl) 20 * Unicode and redirection safe! 21 * 22 * 30-Apr-2005 (Magnus Olsen <magnus@greatlord.com>) 23 * Remove all hardcoded strings in En.rc 24 */ 25 26 #include "precomp.h" 27 28 /* 29 * Perform the SHIFT command. 30 * 31 * Only valid inside batch files. 32 * 33 * FREEDOS extension : optional parameter DOWN to allow shifting 34 * parameters backwards. 35 * 36 */ 37 38 INT cmd_shift (LPTSTR param) 39 { 40 INT i = 0; 41 TRACE ("cmd_shift: (\'%s\')\n", debugstr_aw(param)); 42 43 if (!_tcsncmp (param, _T("/?"), 2)) 44 { 45 ConOutResPaging(TRUE,STRING_SHIFT_HELP); 46 return 0; 47 } 48 49 nErrorLevel = 0; 50 51 if (bc == NULL) 52 { 53 /* not in batch - error!! */ 54 nErrorLevel = 1; 55 return 1; 56 } 57 58 if (!_tcsicmp (param, _T("down"))) 59 { 60 if (bc->shiftlevel[0]) 61 for (; i <= 9; i++) 62 bc->shiftlevel[i]--; 63 } 64 else /* shift up */ 65 { 66 if (*param == _T('/')) 67 { 68 if (!_istdigit(param[1])) 69 { 70 error_invalid_switch(param[1]); 71 return 1; 72 } 73 i = param[1] - '0'; 74 } 75 76 for (; i < 9; i++) 77 bc->shiftlevel[i] = bc->shiftlevel[i + 1]; 78 bc->shiftlevel[i]++; 79 } 80 81 return 0; 82 } 83 84 /* EOF */ 85