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 /*****************************************************************************
28 Set a the value of the name rexx variable.
31 msg - A rexx message generated from a running rexx script
32 varname - The name of the variable to set the value
33 value - a pointer to the beginning of the value to set
34 length - the length of the value argument
37 0 when succes, otherwise a rexx error value is returned.
46 CheckRexxMsg, GetRexxVar
49 This function creates a rexx message that is sent to the AREXX
50 port with a RXSETVAR command.
53 *****************************************************************************/
56 struct Library
*RexxSysBase
= NULL
;
57 struct RexxMsg
*msg2
= NULL
, *msg3
;
58 struct MsgPort
*port
= NULL
, *rexxport
;
59 LONG retval
= ERR10_003
;
61 RexxSysBase
= OpenLibrary("rexxsyslib.library", 0);
62 if (RexxSysBase
==NULL
) goto cleanup
;
70 rexxport
= FindPort("REXX");
77 port
= CreateMsgPort();
78 if (port
== NULL
) goto cleanup
;
79 msg2
= CreateRexxMsg(port
, NULL
, NULL
);
80 if (msg2
==NULL
) goto cleanup
;
81 msg2
->rm_Private1
= msg
->rm_Private1
;
82 msg2
->rm_Private2
= msg
->rm_Private2
;
83 msg2
->rm_Action
= RXSETVAR
| 2;
84 msg2
->rm_Args
[0] = (IPTR
)CreateArgstring(varname
, strlen(varname
));
85 msg2
->rm_Args
[1] = (IPTR
)CreateArgstring(value
, length
);
86 if (msg2
->rm_Args
[0]==NULL
|| msg2
->rm_Args
[1]==NULL
) goto cleanup
;
88 PutMsg(rexxport
, (struct Message
*)msg2
);
93 msg3
= (struct RexxMsg
*)GetMsg(port
);
94 if (msg3
!=msg2
) ReplyMsg((struct Message
*)msg3
);
97 if (msg3
->rm_Result1
==RC_OK
) retval
= 0;
98 else retval
= (LONG
)msg3
->rm_Result2
;
103 if (msg2
->rm_Args
[0]!=NULL
) DeleteArgstring((UBYTE
*)msg2
->rm_Args
[0]);
104 if (msg2
->rm_Args
[1]!=NULL
) DeleteArgstring((UBYTE
*)msg2
->rm_Args
[1]);
107 if (port
!=NULL
) DeletePort(port
);
108 if (RexxSysBase
!=NULL
) CloseLibrary(RexxSysBase
);