forked from FDOS/freecom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcall.c
93 lines (80 loc) · 1.87 KB
/
call.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* $Id$
* CALL.C - batch file call command.
*
* Comments:
*
* 16 Jul 1998 (Hans B Pufal)
* started.
*
* 16 Jul 1998 (John P Price)
* Seperated commands into individual files.
*
* 27-Jul-1998 (John P Price <[email protected]>)
* - added config.h include
*
* 04-Aug-1998 (Hans B Pufal)
* - added lines to initialize for pointers (HBP004) This fixed the
* lock-up that happened sometimes when calling a batch file from
* another batch file.
*
* 10-Aug-1998 ska
* - changed: initialize bcontext with function
*
*/
#include "../config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../include/batch.h"
#include "../include/cmdline.h"
#include "../include/command.h"
#include "../err_fcts.h"
#include "../include/kswap.h"
static int optS = 0; /* force to swap out FreeCOM during call */
static int optN = 0; /* force to NOT swap (superceeds optS) */
optScanFct(opt_call)
{
(void)arg;
switch(ch) {
case 'S': return optScanBool(optS);
case 'N': return optScanBool(optN);
case 'Y': return optScanBool(tracemode);
}
optErr();
return E_Useage;
}
/*
* Perform CALL command.
*
* Allocate a new batch context and add it to the current chain.
* Call parsecommandline passing in our param string
* If No batch file was opened then remove our newly allocted
* context block.
*/
int cmd_call (char * param) {
struct bcontext *n = newBatchContext();
int ec;
(void)param;
if (n == 0) {
/* Not in a batch file */
return 1;
}
optS = optN = 0;
if((ec = leadOptions(¶m, opt_call, 0)) != E_None)
return ec;
if(swapOnExec != ERROR) {
if(optS)
swapOnExec = TRUE;
if(optN)
swapOnExec = FALSE;
}
parsecommandline(param, FALSE);
if(swapOnExec != ERROR)
swapOnExec = FALSE;
if (bc->bfile == 0
&& bc->bfnam == 0) { /* Wasn't a batch file so remove context */
bc = bc->prev;
free(n);
}
return 0;
}