2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /*****************************************************************************
14 #include <libraries/commodities.h>
15 #include <proto/exec.h>
16 #include <proto/commodities.h>
19 #include <aros/debug.h>
21 #define DEBUG_CREATECXOBJ(x) ;
24 VOID
BrokerFunc(CxObj
*, struct NewBroker
*, struct Library
*CxBase
);
27 AROS_LH3(CxObj
*, CreateCxObj
,
31 AROS_LHA(ULONG
, type
, D0
),
32 AROS_LHA(IPTR
, arg1
, A0
),
33 AROS_LHA(IPTR
, arg2
, A1
),
37 struct Library
*, CxBase
, 5, Commodities
)
41 Creates a commodity object of type 'type'. This function should never
42 be called directly; instead, use the macros defined in <libraries/
43 commodties.h>. Brokers, however, should be created with the CxBroker()
48 type - the type of the commodity object to be created. Possible
49 types are defined in <libraries/commodities.h>.
50 arg1 - depends on the value of 'type' above.
51 arg2 - depends on the value of 'type' above.
55 The commodity object or NULL if it couldn't be created. Not so severe
56 problems in the creation process are recorded in an internal field
57 retrievable with CxObjError(). These errors are defined in <libraries/
62 This 'CxObj *' that is returned from this function (and from CxBroker())
63 is the reference to your commodity object. It shall be used whenever
64 dealing with your commodity objects (functions operating on commodity
73 CxObjError(), CxBroker(), cx_lib/CxSender(), cx_lib/CxSignal(),
74 cx_lib/CxFilter(), cx_lib/CxTranslate() cx_lib/CxCustom(),
81 ******************************************************************************/
88 DEBUG_CREATECXOBJ(dprintf("CreateCxObj: type %lu Arg1 0x%lx Arg2 0x%lx\n",
91 if ((co
= (CxObj
*)AllocCxStructure(CX_OBJECT
, type
, CxBase
)) == NULL
)
93 return NULL
; /* No memory for object */
96 D(bug("CreateCxObject: Memory for object allocated.\n"));
98 co
->co_Node
.ln_Type
= type
;
99 co
->co_Flags
= COF_ACTIVE
;
102 NEWLIST(&co
->co_ObjList
);
107 SetFilter(co
, (STRPTR
)arg1
);
111 /* Obsolete and undocumented */
115 co
->co_Ext
.co_SendExt
->sext_MsgPort
= (struct MsgPort
*)arg1
;
116 co
->co_Ext
.co_SendExt
->sext_ID
= (ULONG
)arg2
;
120 co
->co_Ext
.co_SignalExt
->sixt_Task
= (struct Task
*)arg1
;
121 co
->co_Ext
.co_SignalExt
->sixt_SigBit
= (UBYTE
)arg2
;
125 co
->co_Ext
.co_IE
= (struct InputEvent
*)arg1
;
129 BrokerFunc(co
, (struct NewBroker
*)arg1
, CxBase
);
133 co
->co_Ext
.co_DebugID
= arg1
;
137 co
->co_Ext
.co_CustomExt
->cext_Action
= (APTR
)arg1
;
138 co
->co_Ext
.co_CustomExt
->cext_ID
= arg2
;
145 DEBUG_CREATECXOBJ(dprintf("CreateCxObject: Leaving...\n"));
153 VOID
BrokerFunc(CxObj
*co
, struct NewBroker
*nbrok
, struct Library
*CxBase
)
155 strncpy(co
->co_Ext
.co_BExt
->bext_Name
, nbrok
->nb_Name
, CBD_NAMELEN
- 1);
156 strncpy(co
->co_Ext
.co_BExt
->bext_Title
, nbrok
->nb_Title
, CBD_TITLELEN
- 1);
157 strncpy(co
->co_Ext
.co_BExt
->bext_Descr
, nbrok
->nb_Descr
, CBD_DESCRLEN
- 1);
159 co
->co_Ext
.co_BExt
->bext_Task
= FindTask(NULL
);
161 /* Brokers are created inactive */
162 co
->co_Flags
&= ~COF_ACTIVE
;
163 co
->co_Node
.ln_Pri
= nbrok
->nb_Pri
;
165 co
->co_Ext
.co_BExt
->bext_MsgPort
= nbrok
->nb_Port
;
167 co
->co_Flags
|= (UBYTE
)nbrok
->nb_Flags
;