2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
8 #include <proto/alib.h>
9 #include <proto/exec.h>
10 #include <proto/rexxsyslib.h>
11 #include <rexx/storage.h>
12 #include <rexx/errors.h>
16 /*****************************************************************************
27 Get a the value of the name rexx variable.
30 msg - A rexx message generated from a running rexx script
31 varname - The name of the variable to get the value from
32 value - a pointer to a string pointer that will be filled with
33 a pointer to the value of the variable. This value
34 not be changed. On AROS this pointer will also be an
35 argstring so you can get the length with LengthArgstring.
36 length - the length of the value argument
39 0 when succes, otherwise a rexx error value is returned.
42 On AROS the pointer returned in value is only valid until the next
43 getrexxvar call on the same running script.
50 CheckRexxMsg, GetRexxVar
53 This function creates a rexx message that is sent to the AREXX
54 port with a RXSETVAR command.
57 *****************************************************************************/
60 struct Library
*RexxSysBase
= NULL
;
61 struct RexxMsg
*msg2
= NULL
, *msg3
;
62 struct MsgPort
*port
= NULL
, *rexxport
;
63 LONG retval
= ERR10_003
;
65 RexxSysBase
= OpenLibrary("rexxsyslib.library", 0);
66 if (RexxSysBase
==NULL
) goto cleanup
;
74 rexxport
= FindPort("REXX");
81 port
= CreateMsgPort();
82 if (port
== NULL
) goto cleanup
;
83 msg2
= CreateRexxMsg(port
, NULL
, NULL
);
84 if (msg2
==NULL
) goto cleanup
;
85 msg2
->rm_Private1
= msg
->rm_Private1
;
86 msg2
->rm_Private2
= msg
->rm_Private2
;
87 msg2
->rm_Action
= RXGETVAR
| 1;
88 msg2
->rm_Args
[0] = (IPTR
)CreateArgstring(varname
, strlen(varname
));
89 if (msg2
->rm_Args
[0]==NULL
) goto cleanup
;
91 PutMsg(rexxport
, (struct Message
*)msg2
);
96 msg3
= (struct RexxMsg
*)GetMsg(port
);
97 if (msg3
!=msg2
) ReplyMsg((struct Message
*)msg3
);
100 if (msg3
->rm_Result1
==RC_OK
)
102 *value
= (char *)msg3
->rm_Result2
;
105 else retval
= (LONG
)msg3
->rm_Result2
;
110 if (msg2
->rm_Args
[0]!=NULL
) DeleteArgstring((UBYTE
*)msg2
->rm_Args
[0]);
113 if (port
!=NULL
) DeletePort(port
);
114 if (RexxSysBase
!=NULL
) CloseLibrary(RexxSysBase
);