ReactOS  0.4.15-dev-1039-gb9754fa
batch.c File Reference
#include "precomp.h"
Include dependency graph for batch.c:

Go to the source code of this file.

Functions

BOOL FindArg (IN TCHAR Char, OUT PCTSTR *ArgPtr, OUT BOOL *IsParam0)
 
static LPTSTR BatchParams (LPTSTR s1, LPTSTR s2)
 
static VOID ClearBatch (VOID)
 
VOID ExitBatch (VOID)
 
VOID ExitAllBatches (VOID)
 
static void BatchFile2Mem (HANDLE hBatchFile)
 
INT Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
 
VOID AddBatchRedirection (REDIRECTION **RedirList)
 
BOOL BatchGetString (LPTSTR lpBuffer, INT nBufferLength)
 
LPTSTR ReadBatchLine (VOID)
 

Variables

BATCH_TYPE BatType = NONE
 
PBATCH_CONTEXT bc = NULL
 
BOOL bBcEcho = TRUE
 
BOOL bEcho = TRUE
 
TCHAR textline [BATCH_BUFFSIZE]
 

Function Documentation

◆ AddBatchRedirection()

VOID AddBatchRedirection ( REDIRECTION **  RedirList)

Definition at line 457 of file batch.c.

458 {
460 
461  /* Prepend the list to the batch context's list */
462  ListEnd = RedirList;
463  while (*ListEnd)
464  ListEnd = &(*ListEnd)->Next;
465  *ListEnd = bc->RedirList;
466  bc->RedirList = *RedirList;
467 
468  /* Null out the pointer so that the list will not be cleared prematurely.
469  * These redirections should persist until the batch file exits. */
470  *RedirList = NULL;
471 }
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY ListEnd
Definition: exfuncs.h:1223
smooth NULL
Definition: ftsmooth.c:416
PBATCH_CONTEXT bc
Definition: batch.c:67
REDIRECTION * RedirList
Definition: batch.h:40

Referenced by Batch().

◆ Batch()

INT Batch ( LPTSTR  fullname,
LPTSTR  firstword,
LPTSTR  param,
PARSED_COMMAND Cmd 
)

Definition at line 270 of file batch.c.

271 {
272  INT ret = 0;
273  INT i;
274  HANDLE hFile = NULL;
275  BOOLEAN bSameFn = FALSE;
276  BOOLEAN bTopLevel;
277  BATCH_CONTEXT new;
278  PFOR_CONTEXT saved_fc;
279 
280  SetLastError(0);
281  if (bc && bc->mem)
282  {
283  TCHAR fpname[MAX_PATH];
284  GetFullPathName(fullname, ARRAYSIZE(fpname), fpname, NULL);
285  if (_tcsicmp(bc->BatchFilePath, fpname) == 0)
286  bSameFn = TRUE;
287  }
288  TRACE("Batch(\'%s\', \'%s\', \'%s\') bSameFn = %d\n",
289  debugstr_aw(fullname), debugstr_aw(firstword), debugstr_aw(param), bSameFn);
290 
291  if (!bSameFn)
292  {
296 
298  {
300  return 1;
301  }
302  }
303 
304  /*
305  * Remember whether this is a top-level batch context, i.e. if there is
306  * no batch context existing prior (bc == NULL originally), and we are
307  * going to create one below.
308  */
309  bTopLevel = !bc;
310 
311  if (bc != NULL && Cmd == bc->current)
312  {
313  /* Then we are transferring to another batch */
314  ClearBatch();
315  AddBatchRedirection(&Cmd->Redirections);
316  }
317  else
318  {
319  struct _SETLOCAL *setlocal = NULL;
320 
321  if (Cmd == NULL)
322  {
323  /* This is a CALL. CALL will set errorlevel to our return value, so
324  * in order to keep the value of errorlevel unchanged in the case
325  * of calling an empty batch file, we must return that same value. */
326  ret = nErrorLevel;
327  }
328  else if (bc)
329  {
330  /* If a batch file runs another batch file as part of a compound command
331  * (e.g. "x.bat & somethingelse") then the first file gets terminated. */
332 
333  /* Get its SETLOCAL stack so it can be migrated to the new context */
334  setlocal = bc->setlocal;
335  bc->setlocal = NULL;
336  ExitBatch();
337  }
338 
339  /* Create a new context. This function will not
340  * return until this context has been exited */
341  new.prev = bc;
342  /* copy some fields in the new structure if it is the same file */
343  if (bSameFn)
344  {
345  new.mem = bc->mem;
346  new.memsize = bc->memsize;
347  new.mempos = 0;
348  new.memfree = FALSE; /* don't free this, being used before this */
349  }
350  bc = &new;
351  bc->RedirList = NULL;
352  bc->setlocal = setlocal;
353  }
354 
356 
357  /* If a new batch file, load it into memory and close the file */
358  if (!bSameFn)
359  {
362  }
363 
364  bc->mempos = 0; /* Go to the beginning of the batch file */
365 #ifndef MSCMD_BATCH_ECHO
366  bc->bEcho = bEcho; /* Preserve echo across batch calls */
367 #endif
368  for (i = 0; i < 10; i++)
369  bc->shiftlevel[i] = i;
370 
371  /* Parse the parameters and make a raw copy of them without modifications */
372  bc->params = BatchParams(firstword, param);
374  if (bc->raw_params == NULL)
375  {
377  return 1;
378  }
379 
380  /* If we are calling from inside a FOR, hide the FOR variables */
381  saved_fc = fc;
382  fc = NULL;
383 
384  /* Perform top-level batch initialization */
385  if (bTopLevel)
386  {
387  /* Default the top-level batch context type to .BAT */
388  BatType = BAT_TYPE;
389 
390  /* If this is a .CMD file, adjust the type */
391  TCHAR *dot = _tcsrchr(bc->BatchFilePath, _T('.'));
392  if (dot && (!_tcsicmp(dot, _T(".cmd"))))
393  {
394  BatType = CMD_TYPE;
395  }
396 
397 #ifdef MSCMD_BATCH_ECHO
398  bBcEcho = bEcho;
399 #endif
400  }
401 
402  /* Check if this is a "CALL :label" */
403  if (*firstword == _T(':'))
404  ret = cmd_goto(firstword);
405 
406  /* If we have created a new context, don't return
407  * until this batch file has completed. */
408  while (bc == &new && !bExit)
409  {
410  Cmd = ParseCommand(NULL);
411  if (!Cmd)
412  {
413  if (!bParseError)
414  continue;
415 
416  /* Echo the pre-parsed batch file line on error */
417  if (bEcho && !bDisableBatchEcho)
418  {
419  if (!bIgnoreEcho)
420  ConOutChar(_T('\n'));
421  PrintPrompt();
423  ConOutChar(_T('\n'));
424  }
425  /* Stop all execution */
426  ExitAllBatches();
427  ret = 1;
428  break;
429  }
430 
431  /* JPP 19980807 */
432  /* Echo the command and execute it */
433  bc->current = Cmd;
435  FreeCommand(Cmd);
436  }
437 
438  /* Perform top-level batch cleanup */
439  if (!bc || bTopLevel)
440  {
441  /* Reset the top-level batch context type */
442  BatType = NONE;
443 
444 #ifdef MSCMD_BATCH_ECHO
445  bEcho = bBcEcho;
446 #endif
447  }
448 
449  /* Restore the FOR variables */
450  fc = saved_fc;
451 
452  /* Always return the last command's return code */
453  TRACE("Batch: returns %d\n", ret);
454  return ret;
455 }
INT nErrorLevel
Definition: cmd.c:158
#define NONE
Definition: ntddpar.h:94
#define CloseHandle
Definition: compat.h:487
TCHAR BatchFilePath[MAX_PATH]
Definition: batch.h:33
DWORD mempos
Definition: batch.h:31
BOOL bIgnoreEcho
Definition: cmd.c:155
#define _tcsicmp
Definition: xmlstorage.h:205
Definition: batch.h:18
#define TRUE
Definition: types.h:120
VOID ConOutChar(TCHAR c)
Definition: console.c:123
INT cmd_goto(LPTSTR)
Definition: goto.c:36
INT ExecuteCommandWithEcho(IN PARSED_COMMAND *Cmd)
Definition: cmd.c:861
#define ConErrResPuts(uID)
Definition: console.h:39
VOID AddBatchRedirection(REDIRECTION **RedirList)
Definition: batch.c:457
#define debugstr_aw
Definition: precomp.h:43
BOOL bEcho
Definition: batch.c:73
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT
Definition: typedefs.h:58
#define FILE_SHARE_READ
Definition: compat.h:136
LPTSTR params
Definition: batch.h:34
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FALSE
Definition: types.h:117
INT shiftlevel[10]
Definition: batch.h:36
VOID ExitAllBatches(VOID)
Definition: batch.c:232
struct _SETLOCAL * setlocal
Definition: batch.h:42
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID ExitBatch(VOID)
Definition: batch.c:193
VOID error_out_of_memory(VOID)
Definition: error.c:138
#define OPEN_EXISTING
Definition: compat.h:523
Definition: batch.h:19
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
BATCH_TYPE BatType
Definition: batch.c:66
#define TRACE(s)
Definition: solgame.cpp:4
static VOID ClearBatch(VOID)
Definition: batch.c:169
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
BOOL bDisableBatchEcho
Definition: cmd.c:160
#define SetLastError(x)
Definition: compat.h:500
PFOR_CONTEXT fc
Definition: for.c:57
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
const char * fullname
Definition: shader.c:1766
Definition: sacdrv.h:277
#define GetFullPathName
Definition: winbase.h:3661
#define GENERIC_READ
Definition: compat.h:135
VOID FreeCommand(PARSED_COMMAND *Cmd)
Definition: parser.c:1420
_In_ HANDLE hFile
Definition: mswsock.h:90
BOOL bBcEcho
Definition: batch.c:70
char * mem
Definition: batch.h:29
LPTSTR raw_params
Definition: batch.h:35
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:913
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
#define cmd_dup(str)
Definition: cmddbg.h:32
PARSED_COMMAND * current
Definition: batch.h:41
static LPTSTR BatchParams(LPTSTR s1, LPTSTR s2)
Definition: batch.c:120
BOOL bExit
Definition: cmd.c:152
PARSED_COMMAND * ParseCommand(LPTSTR Line)
Definition: parser.c:805
_TCHAR * _tcsrchr(const _TCHAR *s, _XINT c)
Definition: tcsrchr.h:4
PBATCH_CONTEXT bc
Definition: batch.c:67
static void BatchFile2Mem(HANDLE hBatchFile)
Definition: batch.c:241
REDIRECTION * RedirList
Definition: batch.h:40
VOID PrintPrompt(VOID)
Definition: prompt.c:109
DWORD memsize
Definition: batch.h:30
BOOL bParseError
Definition: parser.c:67
VOID ConOutPuts(LPTSTR szText)
Definition: tee.c:27
#define STRING_BATCH_ERROR
Definition: resource.h:23
TCHAR ParseLine[CMDLINE_LENGTH]
Definition: parser.c:69

◆ BatchFile2Mem()

static void BatchFile2Mem ( HANDLE  hBatchFile)
static

Definition at line 241 of file batch.c.

242 {
243  TRACE("BatchFile2Mem()\n");
244 
245  bc->memsize = GetFileSize(hBatchFile, NULL);
246  bc->mem = (char *)cmd_alloc(bc->memsize+1); /* 1 extra for '\0' */
247 
248  /* if memory is available, read it in and close the file */
249  if (bc->mem != NULL)
250  {
251  TRACE ("BatchFile2Mem memory %08x - %08x\n",bc->mem,bc->memsize);
252  SetFilePointer (hBatchFile, 0, NULL, FILE_BEGIN);
253  ReadFile(hBatchFile, (LPVOID)bc->mem, bc->memsize, &bc->memsize, NULL);
254  bc->mem[bc->memsize]='\0'; /* end this, so you can dump it as a string */
255  bc->memfree=TRUE; /* this one needs to be freed */
256  }
257  else
258  {
259  bc->memsize=0; /* this will prevent mem being accessed */
260  bc->memfree=FALSE;
261  }
262  bc->mempos = 0; /* set position to the start */
263 }
DWORD mempos
Definition: batch.h:31
#define TRUE
Definition: types.h:120
#define FILE_BEGIN
Definition: compat.h:509
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
BOOL memfree
Definition: batch.h:32
char * mem
Definition: batch.h:29
#define cmd_alloc(size)
Definition: cmddbg.h:29
#define ReadFile(a, b, c, d, e)
Definition: compat.h:490
PBATCH_CONTEXT bc
Definition: batch.c:67
#define SetFilePointer
Definition: compat.h:491
DWORD memsize
Definition: batch.h:30

Referenced by Batch().

◆ BatchGetString()

BOOL BatchGetString ( LPTSTR  lpBuffer,
INT  nBufferLength 
)

Definition at line 477 of file batch.c.

478 {
479  LPSTR lpString;
480  INT len = 0;
481 #ifdef _UNICODE
482  lpString = cmd_alloc(nBufferLength);
483  if (!lpString)
484  {
485  WARN("Cannot allocate memory for lpString\n");
487  return FALSE;
488  }
489 #else
490  lpString = lpBuffer;
491 #endif
492  /* read all chars from memory until a '\n' is encountered */
493  if (bc->mem)
494  {
495  for (; (bc->mempos < bc->memsize && len < (nBufferLength-1)); len++)
496  {
497  lpString[len] = bc->mem[bc->mempos++];
498  if (lpString[len] == '\n' )
499  {
500  len++;
501  break;
502  }
503  }
504  }
505 
506  if (!len)
507  {
508 #ifdef _UNICODE
509  cmd_free(lpString);
510 #endif
511  return FALSE;
512  }
513 
514  lpString[len++] = '\0';
515 #ifdef _UNICODE
516  MultiByteToWideChar(OutputCodePage, 0, lpString, -1, lpBuffer, len);
517  cmd_free(lpString);
518 #endif
519  return TRUE;
520 }
DWORD mempos
Definition: batch.h:31
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:112
char * LPSTR
Definition: xmlstorage.h:182
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
VOID error_out_of_memory(VOID)
Definition: error.c:138
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3034
UINT OutputCodePage
Definition: console.c:26
GLenum GLsizei len
Definition: glext.h:6722
char * mem
Definition: batch.h:29
#define cmd_alloc(size)
Definition: cmddbg.h:29
#define cmd_free(ptr)
Definition: cmddbg.h:31
#define MultiByteToWideChar
Definition: compat.h:110
PBATCH_CONTEXT bc
Definition: batch.c:67
DWORD memsize
Definition: batch.h:30

Referenced by cmd_goto(), and ReadBatchLine().

◆ BatchParams()

static LPTSTR BatchParams ( LPTSTR  s1,
LPTSTR  s2 
)
static

Definition at line 120 of file batch.c.

121 {
122  LPTSTR dp = (LPTSTR)cmd_alloc((_tcslen(s1) + _tcslen(s2) + 3) * sizeof (TCHAR));
123 
124  /* JPP 20-Jul-1998 added error checking */
125  if (dp == NULL)
126  {
127  WARN("Cannot allocate memory for dp!\n");
129  return NULL;
130  }
131 
132  if (s1 && *s1)
133  {
134  s1 = _stpcpy (dp, s1);
135  *s1++ = _T('\0');
136  }
137  else
138  s1 = dp;
139 
140  while (*s2)
141  {
142  BOOL inquotes = FALSE;
143 
144  /* Find next parameter */
145  while (_istspace(*s2) || (*s2 && _tcschr(STANDARD_SEPS, *s2)))
146  s2++;
147  if (!*s2)
148  break;
149 
150  /* Copy it */
151  do
152  {
153  if (!inquotes && (_istspace(*s2) || _tcschr(STANDARD_SEPS, *s2)))
154  break;
155  inquotes ^= (*s2 == _T('"'));
156  *s1++ = *s2++;
157  } while (*s2);
158  *s1++ = _T('\0');
159  }
160 
161  *s1 = _T('\0');
162 
163  return dp;
164 }
struct S2 s2
#define WARN(fmt,...)
Definition: debug.h:112
CHAR * LPTSTR
Definition: xmlstorage.h:192
LPTSTR _stpcpy(LPTSTR, LPCTSTR)
Definition: misc.c:460
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
VOID error_out_of_memory(VOID)
Definition: error.c:138
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
struct S1 s1
#define STANDARD_SEPS
Definition: cmd.h:346
#define cmd_alloc(size)
Definition: cmddbg.h:29
#define _istspace
Definition: tchar.h:1504

Referenced by Batch().

◆ ClearBatch()

static VOID ClearBatch ( VOID  )
static

Definition at line 169 of file batch.c.

170 {
171  TRACE("ClearBatch mem = %08x ; free = %d\n", bc->mem, bc->memfree);
172 
173  if (bc->mem && bc->memfree)
174  cmd_free(bc->mem);
175 
176  if (bc->raw_params)
178 
179  if (bc->params)
180  cmd_free(bc->params);
181 }
LPTSTR params
Definition: batch.h:34
#define TRACE(s)
Definition: solgame.cpp:4
BOOL memfree
Definition: batch.h:32
char * mem
Definition: batch.h:29
LPTSTR raw_params
Definition: batch.h:35
#define cmd_free(ptr)
Definition: cmddbg.h:31
PBATCH_CONTEXT bc
Definition: batch.c:67

Referenced by Batch(), and ExitBatch().

◆ ExitAllBatches()

VOID ExitAllBatches ( VOID  )

Definition at line 232 of file batch.c.

233 {
234  while (bc)
235  ExitBatch();
236 }
VOID ExitBatch(VOID)
Definition: batch.c:193
PBATCH_CONTEXT bc
Definition: batch.c:67

Referenced by Batch(), and ReadBatchLine().

◆ ExitBatch()

VOID ExitBatch ( VOID  )

Definition at line 193 of file batch.c.

194 {
195  ClearBatch();
196 
197  TRACE("ExitBatch\n");
198 
201 
202 #ifndef MSCMD_BATCH_ECHO
203  /* Preserve echo state across batch calls */
204  bEcho = bc->bEcho;
205 #endif
206 
207  while (bc->setlocal)
208  cmd_endlocal(_T(""));
209 
210  bc = bc->prev;
211 
212 #if 0
213  /* Do not process any more parts of a compound command */
214  bc->current = NULL;
215 #endif
216 
217  /* If there is no more batch contexts, notify the signal handler */
218  if (!bc)
219  {
221  BatType = NONE;
222 
223 #ifdef MSCMD_BATCH_ECHO
224  bEcho = bBcEcho;
225 #endif
226  }
227 }
BOOL CheckCtrlBreak(INT)
Definition: misc.c:132
#define NONE
Definition: ntddpar.h:94
BOOL bEcho
Definition: batch.c:73
INT cmd_endlocal(LPTSTR)
Definition: setlocal.c:110
struct _SETLOCAL * setlocal
Definition: batch.h:42
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
BATCH_TYPE BatType
Definition: batch.c:66
#define TRACE(s)
Definition: solgame.cpp:4
static VOID ClearBatch(VOID)
Definition: batch.c:169
struct _BATCH_CONTEXT * prev
Definition: batch.h:28
VOID UndoRedirection(REDIRECTION *, REDIRECTION *End)
Definition: redir.c:142
BOOL bBcEcho
Definition: batch.c:70
PARSED_COMMAND * current
Definition: batch.h:41
#define BREAK_OUTOFBATCH
Definition: cmd.h:35
VOID FreeRedirection(REDIRECTION *)
Definition: redir.c:153
PBATCH_CONTEXT bc
Definition: batch.c:67
REDIRECTION * RedirList
Definition: batch.h:40

Referenced by Batch(), cmd_goto(), ExitAllBatches(), and ReadBatchLine().

◆ FindArg()

BOOL FindArg ( IN TCHAR  Char,
OUT PCTSTR ArgPtr,
OUT BOOL IsParam0 
)

Definition at line 85 of file batch.c.

89 {
90  PCTSTR pp;
91  INT n = Char - _T('0');
92 
93  TRACE("FindArg: (%d)\n", n);
94 
95  *ArgPtr = NULL;
96 
97  if (n < 0 || n > 9)
98  return FALSE;
99 
100  n = bc->shiftlevel[n];
101  *IsParam0 = (n == 0);
102  pp = bc->params;
103 
104  /* Step up the strings till we reach
105  * the end or the one we want. */
106  while (*pp && n--)
107  pp += _tcslen(pp) + 1;
108 
109  *ArgPtr = pp;
110  return TRUE;
111 }
LPCSTR PCTSTR
Definition: ntbasedef.h:489
#define TRUE
Definition: types.h:120
GLdouble n
Definition: glext.h:7729
int32_t INT
Definition: typedefs.h:58
LPTSTR params
Definition: batch.h:34
#define FALSE
Definition: types.h:117
INT shiftlevel[10]
Definition: batch.h:36
#define pp
Definition: hlsl.yy.c:1208
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
#define _T(x)
Definition: vfdio.h:22
#define TRACE(s)
Definition: solgame.cpp:4
PBATCH_CONTEXT bc
Definition: batch.c:67

Referenced by GetBatchVar().

◆ ReadBatchLine()

LPTSTR ReadBatchLine ( VOID  )

Definition at line 530 of file batch.c.

531 {
532  TRACE("ReadBatchLine()\n");
533 
534  /* User halt */
536  {
537  ExitAllBatches();
538  return NULL;
539  }
540 
542  {
543  TRACE("ReadBatchLine(): Reached EOF!\n");
544  /* End of file */
545  ExitBatch();
546  return NULL;
547  }
548 
549  TRACE("ReadBatchLine(): textline: \'%s\'\n", debugstr_aw(textline));
550 
551  if (textline[_tcslen(textline) - 1] != _T('\n'))
552  _tcscat(textline, _T("\n"));
553 
554  return textline;
555 }
BOOL CheckCtrlBreak(INT)
Definition: misc.c:132
#define BREAK_BATCHFILE
Definition: cmd.h:34
#define debugstr_aw
Definition: precomp.h:43
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
BOOL BatchGetString(LPTSTR lpBuffer, INT nBufferLength)
Definition: batch.c:477
VOID ExitAllBatches(VOID)
Definition: batch.c:232
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
VOID ExitBatch(VOID)
Definition: batch.c:193
TCHAR textline[BATCH_BUFFSIZE]
Definition: batch.c:76
#define _T(x)
Definition: vfdio.h:22
#define TRACE(s)
Definition: solgame.cpp:4
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8

Referenced by ReadLine().

Variable Documentation

◆ BatType

BATCH_TYPE BatType = NONE

Definition at line 66 of file batch.c.

Referenced by Batch(), cmd_path(), cmd_prompt(), cmd_set(), CommandAssoc(), and ExitBatch().

◆ bBcEcho

BOOL bBcEcho = TRUE

Definition at line 70 of file batch.c.

Referenced by Batch(), and ExitBatch().

◆ bc

◆ bEcho

BOOL bEcho = TRUE

Definition at line 73 of file batch.c.

Referenced by Batch(), CommandEcho(), ExecuteCommandWithEcho(), ExitBatch(), ReadFromConsole(), and ReadLine().

◆ textline

TCHAR textline[BATCH_BUFFSIZE]

Definition at line 76 of file batch.c.

Referenced by cmd_goto(), and ReadBatchLine().