Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / commodities / removecxobj.c
blobfb4f9b566a15aaf534eaa4b4c88f2c017393a55b
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME */
13 #include "cxintern.h"
14 #include <devices/input.h>
15 #include <proto/exec.h>
16 #include <proto/commodities.h>
17 #include <aros/debug.h>
19 VOID RemoveHandler(struct CommoditiesBase *CxBase);
21 AROS_LH1(VOID, RemoveCxObj,
23 /* SYNOPSIS */
25 AROS_LHA(CxObj *, co, A0),
27 /* LOCATION */
29 struct Library *, CxBase, 17, Commodities)
31 /* FUNCTION
33 Removes 'co' from the lists it's in. The function handles smoothly the
34 cases when 'co' is NULL or haven't been inserted in a list.
36 INPUTS
38 co -- the commodity object to remove (may be NULL)
40 RESULT
42 NOTES
44 EXAMPLE
46 BUGS
48 SEE ALSO
50 AttachCxObj(), EnqueueCxObj(), InsertCxObj()
52 INTERNALS
54 HISTORY
56 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 if (co == NULL)
63 return;
66 if ((co->co_Flags & COF_VALID) == 0)
68 return;
71 ObtainSemaphore(&GPB(CxBase)->cx_SignalSemaphore);
73 Remove(&co->co_Node);
74 co->co_Flags &= ~COF_VALID;
76 if ((CXOBJType(co) == CX_BROKER) || (CXOBJType(co) == CX_ZERO))
78 if (IsListEmpty(&GPB(CxBase)->cx_BrokerList))
80 RemoveHandler(GPB(CxBase));
82 else
84 /* Tell Exchange what happened */
85 BrokerCommand(NULL, CXCMD_LIST_CHG);
89 ReleaseSemaphore(&GPB(CxBase)->cx_SignalSemaphore);
91 AROS_LIBFUNC_EXIT
92 } /* RemoveCxObj */
95 VOID RemoveHandler(struct CommoditiesBase *CxBase)
97 if (CxBase->cx_IORequest.io_Device == NULL)
99 return;
102 CxBase->cx_InputMP.mp_SigTask = FindTask(NULL);
103 CxBase->cx_IORequest.io_Command = IND_REMHANDLER;
104 DoIO((struct IORequest *)&CxBase->cx_IORequest);
105 CloseDevice((struct IORequest *)&CxBase->cx_IORequest);
106 CxBase->cx_IORequest.io_Device = NULL;
107 CxBase->cx_Running = FALSE;