ReactOS 0.4.15-dev-8093-g3285f69
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 */
15typedef enum _BATCH_TYPE
16{
18 BAT_TYPE, /* Old-style DOS batch file */
19 CMD_TYPE /* New-style NT OS/2 batch file */
21
22
23/* Enable this define for Windows' CMD batch-echo behaviour compatibility */
24#define MSCMD_BATCH_ECHO
25
26typedef 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
45typedef struct _FOR_CONTEXT
46{
52
53
54/*
55 * The stack of current batch contexts.
56 * NULL when no batch is active.
57 */
58extern BATCH_TYPE BatType;
59extern PBATCH_CONTEXT bc;
60extern PFOR_CONTEXT fc;
61
62#ifdef MSCMD_BATCH_ECHO
63extern BOOL bBcEcho;
64#endif
65
66extern BOOL bEcho; /* The echo flag */
67
68#define BATCH_BUFFSIZE 8192
69
70extern TCHAR textline[BATCH_BUFFSIZE]; /* Buffer for reading Batch file lines */
71
72
73BOOL
75 IN TCHAR Char,
76 OUT PCTSTR* ArgPtr,
77 OUT BOOL* IsParam0);
78
#define BATCH_BUFFSIZE
Definition: batch.h:68
BOOL bBcEcho
Definition: batch.c:70
struct _FOR_CONTEXT FOR_CONTEXT
PBATCH_CONTEXT bc
Definition: batch.c:67
struct _FOR_CONTEXT * PFOR_CONTEXT
TCHAR textline[BATCH_BUFFSIZE]
Definition: batch.c:76
BATCH_TYPE BatType
Definition: batch.c:66
VOID ExitBatch(VOID)
Definition: batch.c:222
struct _BATCH_CONTEXT BATCH_CONTEXT
BOOL FindArg(IN TCHAR Char, OUT PCTSTR *ArgPtr, OUT BOOL *IsParam0)
Definition: batch.c:84
BOOL bEcho
Definition: batch.c:73
VOID AddBatchRedirection(REDIRECTION **)
Definition: batch.c:507
BOOL BatchGetString(LPTSTR lpBuffer, INT nBufferLength)
Definition: batch.c:527
VOID ExitAllBatches(VOID)
Definition: batch.c:261
_BATCH_TYPE
Definition: batch.h:16
@ BAT_TYPE
Definition: batch.h:18
@ CMD_TYPE
Definition: batch.h:19
@ NONE
Definition: batch.h:17
LPTSTR ReadBatchLine(VOID)
Definition: batch.c:564
struct _BATCH_CONTEXT * PBATCH_CONTEXT
PFOR_CONTEXT fc
Definition: for.c:57
enum _BATCH_TYPE BATCH_TYPE
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned int UINT
Definition: ndis.h:50
LPCSTR PCTSTR
Definition: ntbasedef.h:488
@ Batch
Definition: ntsecapi.h:291
DWORD memsize
Definition: batch.h:30
char * mem
Definition: batch.h:29
struct _BATCH_CONTEXT * prev
Definition: batch.h:28
BOOL memfree
Definition: batch.h:32
struct _SETLOCAL * setlocal
Definition: batch.h:42
LPTSTR params
Definition: batch.h:34
TCHAR BatchFilePath[MAX_PATH]
Definition: batch.h:33
LPTSTR raw_params
Definition: batch.h:35
REDIRECTION * RedirList
Definition: batch.h:40
INT shiftlevel[10]
Definition: batch.h:36
PARSED_COMMAND * current
Definition: batch.h:41
DWORD mempos
Definition: batch.h:31
LPTSTR * values
Definition: batch.h:50
UINT varcount
Definition: batch.h:49
TCHAR firstvar
Definition: batch.h:48
struct _FOR_CONTEXT * prev
Definition: batch.h:47
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3073
char TCHAR
Definition: xmlstorage.h:189
CHAR * LPTSTR
Definition: xmlstorage.h:192