ReactOS
0.4.16-dev-340-g0540c21
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
{
17
NONE
,
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
{
28
struct
_BATCH_CONTEXT
*
prev
;
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 */
33
TCHAR
BatchFilePath
[
MAX_PATH
];
34
LPTSTR
params
;
35
LPTSTR
raw_params
;
/* Holds the raw params given by the input */
36
INT
shiftlevel
[10];
37
#ifndef MSCMD_BATCH_ECHO
38
BOOL
bEcho
;
/* Preserve echo flag across batch calls */
39
#endif
40
REDIRECTION
*
RedirList
;
41
PARSED_COMMAND
*
current
;
42
struct
_SETLOCAL
*
setlocal
;
43
}
BATCH_CONTEXT
, *
PBATCH_CONTEXT
;
44
45
typedef
struct
_FOR_CONTEXT
46
{
47
struct
_FOR_CONTEXT
*
prev
;
48
TCHAR
firstvar
;
49
UINT
varcount
;
50
LPTSTR
*
values
;
51
}
FOR_CONTEXT
, *
PFOR_CONTEXT
;
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
79
VOID
ExitBatch
(
VOID
);
80
VOID
ExitAllBatches
(
VOID
);
81
INT
Batch
(
LPTSTR
,
LPTSTR
,
LPTSTR
,
PARSED_COMMAND
*);
82
BOOL
BatchGetString
(
LPTSTR
lpBuffer
,
INT
nBufferLength
);
83
LPTSTR
ReadBatchLine
(
VOID
);
84
VOID
AddBatchRedirection
(
REDIRECTION
**);
BATCH_BUFFSIZE
#define BATCH_BUFFSIZE
Definition:
batch.h:68
bBcEcho
BOOL bBcEcho
Definition:
batch.c:70
FOR_CONTEXT
struct _FOR_CONTEXT FOR_CONTEXT
bc
PBATCH_CONTEXT bc
Definition:
batch.c:67
PFOR_CONTEXT
struct _FOR_CONTEXT * PFOR_CONTEXT
textline
TCHAR textline[BATCH_BUFFSIZE]
Definition:
batch.c:76
BatType
BATCH_TYPE BatType
Definition:
batch.c:66
ExitBatch
VOID ExitBatch(VOID)
Definition:
batch.c:222
BATCH_CONTEXT
struct _BATCH_CONTEXT BATCH_CONTEXT
FindArg
BOOL FindArg(IN TCHAR Char, OUT PCTSTR *ArgPtr, OUT BOOL *IsParam0)
Definition:
batch.c:84
bEcho
BOOL bEcho
Definition:
batch.c:73
AddBatchRedirection
VOID AddBatchRedirection(REDIRECTION **)
Definition:
batch.c:501
BatchGetString
BOOL BatchGetString(LPTSTR lpBuffer, INT nBufferLength)
Definition:
batch.c:521
ExitAllBatches
VOID ExitAllBatches(VOID)
Definition:
batch.c:261
_BATCH_TYPE
_BATCH_TYPE
Definition:
batch.h:16
BAT_TYPE
@ BAT_TYPE
Definition:
batch.h:18
CMD_TYPE
@ CMD_TYPE
Definition:
batch.h:19
NONE
@ NONE
Definition:
batch.h:17
ReadBatchLine
LPTSTR ReadBatchLine(VOID)
Definition:
batch.c:558
PBATCH_CONTEXT
struct _BATCH_CONTEXT * PBATCH_CONTEXT
fc
PFOR_CONTEXT fc
Definition:
for.c:57
BATCH_TYPE
enum _BATCH_TYPE BATCH_TYPE
lpBuffer
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition:
db.cpp:175
MAX_PATH
#define MAX_PATH
Definition:
compat.h:34
BOOL
unsigned int BOOL
Definition:
ntddk_ex.h:94
DWORD
unsigned long DWORD
Definition:
ntddk_ex.h:95
void
Definition:
nsiface.idl:2307
UINT
unsigned int UINT
Definition:
ndis.h:50
PCTSTR
LPCSTR PCTSTR
Definition:
ntbasedef.h:496
Batch
@ Batch
Definition:
ntsecapi.h:291
_BATCH_CONTEXT
Definition:
batch.h:27
_BATCH_CONTEXT::memsize
DWORD memsize
Definition:
batch.h:30
_BATCH_CONTEXT::mem
char * mem
Definition:
batch.h:29
_BATCH_CONTEXT::prev
struct _BATCH_CONTEXT * prev
Definition:
batch.h:28
_BATCH_CONTEXT::memfree
BOOL memfree
Definition:
batch.h:32
_BATCH_CONTEXT::setlocal
struct _SETLOCAL * setlocal
Definition:
batch.h:42
_BATCH_CONTEXT::params
LPTSTR params
Definition:
batch.h:34
_BATCH_CONTEXT::BatchFilePath
TCHAR BatchFilePath[MAX_PATH]
Definition:
batch.h:33
_BATCH_CONTEXT::raw_params
LPTSTR raw_params
Definition:
batch.h:35
_BATCH_CONTEXT::RedirList
REDIRECTION * RedirList
Definition:
batch.h:40
_BATCH_CONTEXT::shiftlevel
INT shiftlevel[10]
Definition:
batch.h:36
_BATCH_CONTEXT::current
PARSED_COMMAND * current
Definition:
batch.h:41
_BATCH_CONTEXT::mempos
DWORD mempos
Definition:
batch.h:31
_FOR_CONTEXT
Definition:
batch.h:46
_FOR_CONTEXT::values
LPTSTR * values
Definition:
batch.h:50
_FOR_CONTEXT::varcount
UINT varcount
Definition:
batch.h:49
_FOR_CONTEXT::firstvar
TCHAR firstvar
Definition:
batch.h:48
_FOR_CONTEXT::prev
struct _FOR_CONTEXT * prev
Definition:
batch.h:47
_PARSED_COMMAND
Definition:
cmd.h:365
_REDIRECTION
Definition:
cmd.h:450
_SETLOCAL
Definition:
setlocal.c:15
INT
int32_t INT
Definition:
typedefs.h:58
IN
#define IN
Definition:
typedefs.h:39
OUT
#define OUT
Definition:
typedefs.h:40
nBufferLength
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition:
winbase.h:3098
TCHAR
char TCHAR
Definition:
xmlstorage.h:189
LPTSTR
CHAR * LPTSTR
Definition:
xmlstorage.h:192
base
shell
cmd
batch.h
Generated on Thu Dec 12 2024 06:02:26 for ReactOS by
1.9.6