ReactOS  0.4.14-dev-815-ge410a12
call.c
Go to the documentation of this file.
1 /*
2  * CALL.C - call 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  * 04-Aug-1998 (Hans B Pufal)
17  * added lines to initialize for pointers (HBP004) This fixed the
18  * lock-up that happened sometimes when calling a batch file from
19  * another batch file.
20  *
21  * 07-Jan-1999 (Eric Kohl)
22  * Added help text ("call /?") and cleaned up.
23  *
24  * 20-Jan-1999 (Eric Kohl)
25  * Unicode and redirection safe!
26  *
27  * 02-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
28  * Remove all hardcoded strings in En.rc
29  */
30 
31 #include "precomp.h"
32 
33 /*
34  * Perform CALL command.
35  */
36 
38 {
40  TCHAR *first;
41  BOOL bInQuote = FALSE;
42 
43  TRACE ("cmd_call: (\'%s\')\n", debugstr_aw(param));
44  if (!_tcsncmp (param, _T("/?"), 2))
45  {
47  return 0;
48  }
49 
50  /* Do a second round of %-variable substitutions */
51  if (!SubstituteVars(param, line, _T('%')))
52  return (nErrorLevel = 1);
53 
54  /* Find start and end of first word */
55  first = line;
56  while (_istspace(*first))
57  first++;
58 
59  for (param = first; *param; param++)
60  {
61  if (!bInQuote && (_istspace(*param) || _tcschr(_T(",;="), *param)))
62  break;
63  bInQuote ^= (*param == _T('"'));
64  }
65 
66  /* Separate first word from rest of line */
67  memmove(param + 1, param, (_tcslen(param) + 1) * sizeof(TCHAR));
68  *param++ = _T('\0');
69 
70  if (*first == _T(':') && bc)
71  {
72  /* CALL :label - call a subroutine of the current batch file */
73  while (*param == _T(' '))
74  param++;
76  return nErrorLevel;
77  }
78 
80  return nErrorLevel;
81 }
82 
83 /* EOF */
INT nErrorLevel
Definition: cmd.c:157
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
LPBATCH_CONTEXT bc
Definition: batch.c:66
const GLint * first
Definition: glext.h:5794
#define debugstr_aw
Definition: precomp.h:43
#define CMDLINE_LENGTH
Definition: help.h:12
BOOL SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim)
Definition: cmd.c:1206
VOID ConOutResPaging(BOOL StartPaging, UINT resID)
Definition: console.c:182
int32_t INT
Definition: typedefs.h:56
CHAR * LPTSTR
Definition: xmlstorage.h:192
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
Definition: parser.c:48
_TCHAR * _tcschr(const _TCHAR *s, _XINT c)
Definition: tcschr.h:4
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
#define TRACE(s)
Definition: solgame.cpp:4
TCHAR BatchFilePath[MAX_PATH]
Definition: batch.h:14
GLfloat param
Definition: glext.h:5796
char line[200]
Definition: main.c:97
INT cmd_call(LPTSTR param)
Definition: call.c:37
static VOID DoCommand(PCONSOLE_STATE State, LPSTR line)
Definition: cmdcons.c:1082
#define STRING_CALL_HELP
Definition: resource.h:71
#define _istspace
Definition: tchar.h:1504
int _tcsncmp(const _TCHAR *s1, const _TCHAR *s2, size_t n)
Definition: tcsncmp.h:9