closing brace is only needed on smp build.
[AROS.git] / test / rexx / vartest.c
blob820f9898ed7df2203851fbcfa23b1d96295fd807
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/alib.h>
8 #include <proto/rexxsyslib.h>
10 #include <exec/ports.h>
11 #include <rexx/errors.h>
12 #include <rexx/storage.h>
13 #include <stdio.h>
14 #include <string.h>
16 int main(void)
18 struct MsgPort *port;
19 struct RexxMsg *msg;
20 struct Library *RexxSysBase;
21 char *value;
23 RexxSysBase = OpenLibrary("rexxsyslib.library", 0);
24 if (RexxSysBase == NULL)
26 puts("Error opening rexxsyslib.library");
27 return 20;
30 port = CreatePort("VARTEST", 1);
31 if (port == NULL)
33 puts("Error creating port");
34 CloseLibrary(RexxSysBase);
35 return 20;
38 printf("Port created %p, waiting for message\n", port);
39 WaitPort(port);
40 msg = (struct RexxMsg *)GetMsg(port);
41 puts("Got a message");
42 if (!IsRexxMsg(msg))
44 puts("Message is not a rexxmsg");
45 ReplyMsg((struct Message *)msg);
46 DeletePort(port);
47 CloseLibrary(RexxSysBase);
48 return 20;
51 puts("Is a rexx message");
52 if (!CheckRexxMsg(msg))
54 puts("Message is not from rexx interpreter");
55 msg->rm_Result1 = RC_ERROR;
56 ReplyMsg((struct Message *)msg);
57 DeletePort(port);
58 CloseLibrary(RexxSysBase);
59 return 20;
62 puts("Message is from the rexx interpreter");
63 if (GetRexxVar(msg, "A", &value) != RC_OK)
65 puts("Error during retrieval of value!");
67 else
69 printf("Length string: %d\n", (int)strlen(value));
70 printf("Value of A: %s\n", value);
73 SetRexxVar(msg, "A", "2", 1);
74 msg->rm_Result1 = RC_OK;
75 msg->rm_Result2 = 0;
76 ReplyMsg((struct Message *)msg);
77 DeletePort(port);
78 CloseLibrary(RexxSysBase);
80 return 0;