ReactOS  0.4.15-dev-1187-g119f102
batch.h
Go to the documentation of this file.
1 /*
2  * BATCH.H - A structure to preserve the context of a batch file
3  */
4 
5 #pragma once
6 
7 /*
8  * This batch type enumeration allows us to adjust the behaviour of some commands
9  * depending on whether they are run from within a .BAT or a .CMD file.
10  * The behaviour is selected when the top-level batch file is loaded,
11  * and it remains the same for any child batch file that may be loaded later.
12  *
13  * See https://ss64.com/nt/errorlevel.html for more details.
14  */
15 typedef enum _BATCH_TYPE
16 {
18  BAT_TYPE, /* Old-style DOS batch file */
19  CMD_TYPE /* New-style NT OS/2 batch file */
20 } BATCH_TYPE;
21 
22 
23 /* Enable this define for Windows' CMD batch-echo behaviour compatibility */
24 #define MSCMD_BATCH_ECHO
25 
26 typedef struct _BATCH_CONTEXT
27 {
29  char *mem; /* batchfile content in memory */
30  DWORD memsize; /* size of batchfile */
31  DWORD mempos; /* current position to read from */
32  BOOL memfree; /* true if it need to be freed when exitbatch is called */
35  LPTSTR raw_params; /* Holds the raw params given by the input */
37 #ifndef MSCMD_BATCH_ECHO
38  BOOL bEcho; /* Preserve echo flag across batch calls */
39 #endif
44 
45 typedef struct _FOR_CONTEXT
46 {
47  struct _FOR_CONTEXT *prev;
52 
53 
54 /*
55  * The stack of current batch contexts.
56  * NULL when no batch is active.
57  */
58 extern BATCH_TYPE BatType;
59 extern PBATCH_CONTEXT bc;
60 extern PFOR_CONTEXT fc;
61 
62 #ifdef MSCMD_BATCH_ECHO
63 extern BOOL bBcEcho;
64 #endif
65 
66 extern BOOL bEcho; /* The echo flag */
67 
68 #define BATCH_BUFFSIZE 8192
69 
70 extern TCHAR textline[BATCH_BUFFSIZE]; /* Buffer for reading Batch file lines */
71 
72 
73 BOOL
74 FindArg(
75  IN TCHAR Char,
76  OUT PCTSTR* ArgPtr,
77  OUT BOOL* IsParam0);
78 
VOID AddBatchRedirection(REDIRECTION **)
Definition: batch.c:506
#define IN
Definition: typedefs.h:39
INT Batch(LPTSTR, LPTSTR, LPTSTR, PARSED_COMMAND *)
Definition: batch.c:300
TCHAR BatchFilePath[MAX_PATH]
Definition: batch.h:33
DWORD mempos
Definition: batch.h:31
LPCSTR PCTSTR
Definition: ntbasedef.h:489
Definition: batch.h:18
LPTSTR ReadBatchLine(VOID)
Definition: batch.c:579
int32_t INT
Definition: typedefs.h:58
struct _FOR_CONTEXT * PFOR_CONTEXT
CHAR * LPTSTR
Definition: xmlstorage.h:192
LPTSTR params
Definition: batch.h:34
TCHAR textline[BATCH_BUFFSIZE]
Definition: batch.c:76
BOOL bEcho
Definition: batch.c:73
INT shiftlevel[10]
Definition: batch.h:36
unsigned int BOOL
Definition: ntddk_ex.h:94
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
struct _SETLOCAL * setlocal
Definition: batch.h:42
BOOL FindArg(IN TCHAR Char, OUT PCTSTR *ArgPtr, OUT BOOL *IsParam0)
Definition: batch.c:85
#define BATCH_BUFFSIZE
Definition: batch.h:68
LPTSTR * values
Definition: batch.h:50
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3034
PBATCH_CONTEXT bc
Definition: batch.c:67
enum _BATCH_TYPE BATCH_TYPE
Definition: batch.h:19
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _BATCH_CONTEXT * prev
Definition: batch.h:28
BOOL memfree
Definition: batch.h:32
TCHAR firstvar
Definition: batch.h:48
PFOR_CONTEXT fc
Definition: for.c:57
struct _FOR_CONTEXT * prev
Definition: batch.h:47
UINT varcount
Definition: batch.h:49
VOID ExitBatch(VOID)
Definition: batch.c:223
char * mem
Definition: batch.h:29
LPTSTR raw_params
Definition: batch.h:35
BATCH_TYPE BatType
Definition: batch.c:66
Definition: batch.h:17
struct _BATCH_CONTEXT * PBATCH_CONTEXT
struct _BATCH_CONTEXT BATCH_CONTEXT
PARSED_COMMAND * current
Definition: batch.h:41
unsigned int UINT
Definition: ndis.h:50
#define OUT
Definition: typedefs.h:40
struct _FOR_CONTEXT FOR_CONTEXT
BOOL BatchGetString(LPTSTR lpBuffer, INT nBufferLength)
Definition: batch.c:526
_BATCH_TYPE
Definition: batch.h:15
REDIRECTION * RedirList
Definition: batch.h:40
BOOL bBcEcho
Definition: batch.c:70
DWORD memsize
Definition: batch.h:30
VOID ExitAllBatches(VOID)
Definition: batch.c:262