Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengoto.c
Go to the documentation of this file.
00001 /* 00002 * GOTO.C - goto internal batch command. 00003 * 00004 * History: 00005 * 00006 * 16 Jul 1998 (Hans B Pufal) 00007 * started. 00008 * 00009 * 16 Jul 1998 (John P Price) 00010 * Seperated commands into individual files. 00011 * 00012 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>) 00013 * added config.h include 00014 * 00015 * 28 Jul 1998 (Hans B Pufal) [HBP_003] 00016 * Terminate label on first space character, use only first 8 chars of 00017 * label string 00018 * 00019 * 24-Jan-1999 (Eric Kohl) 00020 * Unicode and redirection safe! 00021 * 00022 * 27-Jan-1999 (Eric Kohl) 00023 * Added help text ("/?"). 00024 * 00025 * 28-Apr-2005 (Magnus Olsen) <magnus@greatlord.com>) 00026 * Remove all hardcode string to En.rc 00027 */ 00028 00029 #include <precomp.h> 00030 00031 00032 /* 00033 * Perform GOTO command. 00034 * 00035 * Only valid if batch file current. 00036 * 00037 */ 00038 00039 INT cmd_goto (LPTSTR param) 00040 { 00041 LPTSTR tmp, tmp2; 00042 00043 TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param)); 00044 00045 if (!_tcsncmp (param, _T("/?"), 2)) 00046 { 00047 ConOutResPaging(TRUE,STRING_GOTO_HELP1); 00048 return 0; 00049 } 00050 00051 /* if not in batch -- error!! */ 00052 if (bc == NULL) 00053 { 00054 return 1; 00055 } 00056 00057 if (*param == _T('\0')) 00058 { 00059 ConErrResPrintf(STRING_GOTO_ERROR1); 00060 ExitBatch(); 00061 return 1; 00062 } 00063 00064 /* terminate label at first space char */ 00065 tmp = param+1; 00066 while (!_istcntrl (*tmp) && !_istspace (*tmp) && (*tmp != _T(':'))) 00067 tmp++; 00068 *(tmp) = _T('\0'); 00069 00070 /* jump to end of the file */ 00071 if ( _tcsicmp( param, _T(":eof"))==0) 00072 { 00073 bc->mempos=bc->memsize; /* position at the end of the batchfile */ 00074 return 0; 00075 } 00076 00077 /* jump to begin of the file */ 00078 bc->mempos=0; 00079 00080 while (BatchGetString (textline, sizeof(textline) / sizeof(textline[0]))) 00081 { 00082 int pos; 00083 INT_PTR size; 00084 00085 /* Strip out any trailing spaces or control chars */ 00086 tmp = textline + _tcslen (textline) - 1; 00087 00088 while (_istcntrl (*tmp) || _istspace (*tmp) || (*tmp == _T(':'))) 00089 tmp--; 00090 *(tmp + 1) = _T('\0'); 00091 00092 /* Then leading spaces... */ 00093 tmp = textline; 00094 while (_istspace (*tmp)) 00095 tmp++; 00096 00097 /* All space after leading space terminate the string */ 00098 size = _tcslen(tmp) -1; 00099 pos=0; 00100 while (tmp+pos < tmp+size) 00101 { 00102 if (_istspace(tmp[pos])) 00103 tmp[pos]=_T('\0'); 00104 pos++; 00105 } 00106 00107 tmp2 = param; 00108 /* use whole label name */ 00109 if ((*tmp == _T(':')) && ((_tcsicmp (++tmp, param) == 0) || (_tcsicmp (tmp, ++tmp2) == 0))) 00110 return 0; 00111 00112 } 00113 00114 ConErrResPrintf(STRING_GOTO_ERROR2, param); 00115 ExitBatch(); 00116 return 1; 00117 } 00118 00119 /* EOF */ Generated on Fri May 25 2012 04:16:30 for ReactOS by
1.7.6.1
|