add another arch specific function for IRQ handling.
[AROS.git] / compiler / alib / setrexxvar.c
blob1b4e6d412b44eb8ca86bf82bee5ede45a7d7e61e
1 /*
2 Copyright © 1995-2016, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <proto/alib.h>
10 #include <proto/exec.h>
11 #include <proto/rexxsyslib.h>
12 #include <rexx/storage.h>
13 #include <rexx/errors.h>
15 #include "alib_intern.h"
17 /*****************************************************************************
19 NAME */
20 LONG SetRexxVar(
22 /* SYNOPSIS */
23 struct RexxMsg *msg,
24 CONST_STRPTR varname,
25 char *value,
26 ULONG length)
28 /* FUNCTION
29 Set the value of the named Rexx variable.
31 INPUTS
32 msg - A Rexx message generated from a running Rexx script
33 varname - The name of the variable to set the value
34 value - a pointer to the beginning of the value to set
35 length - the length of the value argument
37 RESULT
38 0 when success, otherwise a Rexx error value is returned.
40 NOTES
42 EXAMPLE
44 BUGS
46 SEE ALSO
47 CheckRexxMsg(), GetRexxVar()
49 INTERNALS
50 This function creates a Rexx message that is sent to the AREXX
51 port with a RXSETVAR command.
54 *****************************************************************************/
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;
64 if (!IsRexxMsg(msg))
66 retval = ERR10_010;
67 goto cleanup;
70 rexxport = FindPort("REXX");
71 if (rexxport==NULL)
73 retval = ERR10_013;
74 goto cleanup;
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]==0 || msg2->rm_Args[1]==0) goto cleanup;
88 PutMsg(rexxport, (struct Message *)msg2);
89 msg3 = NULL;
90 while (msg3!=msg2)
92 WaitPort(port);
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;
100 cleanup:
101 if (msg2!=NULL)
103 if (msg2->rm_Args[0]!=0) DeleteArgstring((UBYTE *)msg2->rm_Args[0]);
104 if (msg2->rm_Args[1]!=0) DeleteArgstring((UBYTE *)msg2->rm_Args[1]);
105 DeleteRexxMsg(msg2);
107 if (port!=NULL) DeletePort(port);
108 if (RexxSysBase!=NULL) CloseLibrary(RexxSysBase);
110 return retval;
111 } /* SetRexxVar */