ReactOS  0.4.14-dev-376-gaedba84
goto.c File Reference
#include "precomp.h"
Include dependency graph for goto.c:

Go to the source code of this file.

Functions

INT cmd_goto (LPTSTR param)
 

Function Documentation

◆ cmd_goto()

INT cmd_goto ( LPTSTR  param)

Definition at line 39 of file goto.c.

40 {
41  LPTSTR tmp, tmp2;
42 
43  TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param));
44 
45  if (!_tcsncmp (param, _T("/?"), 2))
46  {
48  return 0;
49  }
50 
51  /* if not in batch -- error!! */
52  if (bc == NULL)
53  {
54  return 1;
55  }
56 
57  if (*param == _T('\0'))
58  {
60  ExitBatch();
61  return 1;
62  }
63 
64  /* terminate label at first space char */
65  tmp = param+1;
66  while (!_istcntrl (*tmp) && !_istspace (*tmp) && (*tmp != _T(':')))
67  tmp++;
68  *(tmp) = _T('\0');
69 
70  /* jump to end of the file */
71  if ( _tcsicmp( param, _T(":eof"))==0)
72  {
73  bc->mempos=bc->memsize; /* position at the end of the batchfile */
74  return 0;
75  }
76 
77  /* jump to begin of the file */
78  bc->mempos=0;
79 
80  while (BatchGetString (textline, sizeof(textline) / sizeof(textline[0])))
81  {
82  int pos;
83  INT_PTR size;
84 
85  /* Strip out any trailing spaces or control chars */
86  tmp = textline + _tcslen (textline) - 1;
87 
88  while (tmp > textline && (_istcntrl (*tmp) || _istspace (*tmp) || (*tmp == _T(':'))))
89  tmp--;
90  *(tmp + 1) = _T('\0');
91 
92  /* Then leading spaces... */
93  tmp = textline;
94  while (_istspace (*tmp))
95  tmp++;
96 
97  /* All space after leading space terminate the string */
98  size = _tcslen(tmp) -1;
99  pos=0;
100  while (tmp+pos < tmp+size)
101  {
102  if (_istspace(tmp[pos]))
103  tmp[pos]=_T('\0');
104  pos++;
105  }
106 
107  tmp2 = param;
108  /* use whole label name */
109  if ((*tmp == _T(':')) && ((_tcsicmp (++tmp, param) == 0) || (_tcsicmp (tmp, ++tmp2) == 0)))
110  return 0;
111 
112  }
113 
115  ExitBatch();
116  return 1;
117 }
#define TRUE
Definition: types.h:120
DWORD mempos
Definition: batch.h:12
#define _tcsicmp
Definition: xmlstorage.h:205
LPBATCH_CONTEXT bc
Definition: batch.c:66
#define debugstr_aw
Definition: precomp.h:43
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
int32_t INT_PTR
Definition: typedefs.h:62
BOOL BatchGetString(LPTSTR lpBuffer, INT nBufferLength)
Definition: batch.c:400
CHAR * LPTSTR
Definition: xmlstorage.h:192
#define STRING_GOTO_HELP1
Definition: resource.h:135
#define ConErrResPrintf(uID,...)
Definition: console.h:51
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
VOID ExitBatch(VOID)
Definition: batch.c:186
#define STRING_GOTO_ERROR2
Definition: resource.h:52
TCHAR textline[BATCH_BUFFSIZE]
Definition: batch.c:73
#define _T(x)
Definition: vfdio.h:22
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
GLfloat param
Definition: glext.h:5796
#define _istcntrl
Definition: tchar.h:739
#define STRING_GOTO_ERROR1
Definition: resource.h:51
DWORD memsize
Definition: batch.h:11
#define _istspace
Definition: tchar.h:1504
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9

Referenced by Batch().