2 Copyright © 1995-2007, 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 *****************************************************************************/
59 struct Library
*RexxSysBase
= NULL
;
60 struct RexxMsg
*msg2
= NULL
, *msg3
;
61 struct MsgPort
*port
= NULL
, *rexxport
;
62 LONG retval
= ERR10_003
;
64 RexxSysBase
= OpenLibrary("rexxsyslib.library", 0);
65 if (RexxSysBase
==NULL
) goto cleanup
;
73 rexxport
= FindPort("REXX");
80 port
= CreateMsgPort();
81 if (port
== NULL
) goto cleanup
;
82 msg2
= CreateRexxMsg(port
, NULL
, NULL
);
83 if (msg2
==NULL
) goto cleanup
;
84 msg2
->rm_Private1
= msg
->rm_Private1
;
85 msg2
->rm_Private2
= msg
->rm_Private2
;
86 msg2
->rm_Action
= RXGETVAR
| 1;
87 msg2
->rm_Args
[0] = (IPTR
)CreateArgstring(varname
, strlen(varname
));
88 if (msg2
->rm_Args
[0]==0) goto cleanup
;
90 PutMsg(rexxport
, (struct Message
*)msg2
);
95 msg3
= (struct RexxMsg
*)GetMsg(port
);
96 if (msg3
!=msg2
) ReplyMsg((struct Message
*)msg3
);
99 if (msg3
->rm_Result1
==RC_OK
)
101 *value
= (char *)msg3
->rm_Result2
;
104 else retval
= (LONG
)msg3
->rm_Result2
;
109 if (msg2
->rm_Args
[0]!=0) DeleteArgstring((UBYTE
*)msg2
->rm_Args
[0]);
112 if (port
!=NULL
) DeletePort(port
);
113 if (RexxSysBase
!=NULL
) CloseLibrary(RexxSysBase
);