forked from adtools/clib2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_arexx_functions.c
124 lines (101 loc) · 2.07 KB
/
test_arexx_functions.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Checks the Arexx functions: CheckRexxMsg, GetRexxVar, SetRexxVar
#include <exec/types.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/rexxsyslib.h>
#include <utility/tagitem.h>
#include <clib/alib_protos.h>
#include <stdlib_constructor.h>
extern struct ExecBase *SysBase;
extern struct DosLibrary *DOSBase;
extern void __ctor_rexxvars_init(void);
extern void __dtor_rexxvars_exit(void);
WORD testArexxFunctions(void)
{
struct MsgPort *rexxPort = NULL;
struct RexxMsg *rexxMsg;
ULONG rexxsigflag,sigrcvd;
BOOL loop = TRUE;
struct TagItem stags[1];
BPTR rexxFile;
LONG error;
unsigned char *value;
WORD errCnt = 0;
__ctor_rexxvars_init();
rexxPort = CreatePort("VARTEST",0);
if(rexxPort == NULL)
{
errCnt++;
goto end;
}
stags[0].ti_Tag = TAG_END;
error = SystemTagList("df0:System/rexxmast > NIL:",stags);
if(error != 0L)
{
errCnt++;
goto end;
}
rexxFile = Open("RAM:testrexx",MODE_NEWFILE);
if(rexxFile == NULL)
{
errCnt++;
goto end;
}
VFPrintf(rexxFile,"/* Testing the variable interface */\nA = 1\nADDRESS 'VARTEST' test\nsay A\n",NULL); // no argv
Close(rexxFile);
error = SystemTagList("run > NIL: df0:rexxc/rx RAM:testrexx > NIL:",stags);
if(error != 0L)
{
errCnt++;
goto end;
}
rexxsigflag = 1L << rexxPort->mp_SigBit;
while(loop)
{
sigrcvd = Wait(SIGBREAKF_CTRL_C | rexxsigflag);
while((rexxMsg = (struct RexxMsg *)GetMsg(rexxPort)))
{
if(CheckRexxMsg(rexxMsg))
{
if(SetRexxVar(rexxMsg,"A","2",1))
{
errCnt++;
}
else
{
if(GetRexxVar(rexxMsg,"A",&value))
{
errCnt++;
}
else
{
if(value[0] != '2')
{
errCnt++;
}
}
}
loop = FALSE;
}
else
{
errCnt++;
}
ReplyMsg((struct Message *)rexxMsg);
}
if(sigrcvd & SIGBREAKF_CTRL_C)
{
errCnt++;
loop = FALSE;
}
}
end:
if(rexxPort != NULL)
{
while((rexxMsg = (struct RexxMsg *)GetMsg(rexxPort)))
ReplyMsg((struct Message *)rexxMsg);
DeletePort(rexxPort);
}
__dtor_rexxvars_exit();
return(errCnt);
}