Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / rexxsupport / closeport.c
blob49dd35b40410a04b70c3a07ff3ab1ce3c1ba361d
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Rexx function to close a MsgPort
6 Lang: English
7 */
9 #include <proto/exec.h>
10 #include <proto/rexxsyslib.h>
11 #include <proto/alib.h>
13 #include <exec/types.h>
14 #include <exec/memory.h>
15 #include <rexx/storage.h>
16 #include <rexx/errors.h>
18 #include <string.h>
20 #include "rexxsupport_intern.h"
21 #include "portnode.h"
23 LONG rxsupp_closeport(struct Library *RexxSupportBase, struct RexxMsg *msg, UBYTE **argstring)
25 struct PortNodeData *data;
27 data = (struct PortNodeData *)FindName(&RSBI(RexxSupportBase)->openports, ARG1(msg));
28 if (data != NULL)
30 struct MsgPort *replyport, *rexxport;
31 struct RexxMsg *msg2, *msg3;
33 rexxport = FindPort("REXX");
34 replyport = CreateMsgPort();
35 msg2 = CreateRexxMsg(replyport, NULL, NULL);
36 if (rexxport == NULL || replyport == NULL || msg2 == NULL)
38 *argstring = NULL;
39 return rexxport == NULL ? ERR10_013 : ERR10_003;
41 replyport->mp_Node.ln_Name = NULL;
42 msg2->rm_Private1 = msg->rm_Private1;
43 msg2->rm_Private2 = msg->rm_Private2;
44 msg2->rm_Action = RXREMRSRC;
45 msg2->rm_Args[0] = (IPTR)data->self;
46 PutMsg(rexxport, (struct Message *)msg2);
47 do {
48 WaitPort(replyport);
49 msg3 = (struct RexxMsg *)GetMsg(replyport);
50 } while (msg3 != msg2);
51 if (msg2->rm_Result1 != RC_OK)
52 kprintf("ClosePort REMRSRC Result1 != RC_OK\n");
53 DeleteMsgPort(replyport);
54 DeleteRexxMsg(msg2);
56 portcleanup(RexxSupportBase, (struct PortNode *)data->self);
58 *argstring = CreateArgstring("1", 1);
60 else
62 *argstring = CreateArgstring("0", 1);
64 return RC_OK;