Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / commodities / copybrokerlist.c
blob6179f86a9196d1cd7a9077894b91b879659fc444
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME */
13 #define AROS_ALMOST_COMPATIBLE
15 #include "cxintern.h"
16 #include <exec/memory.h>
17 #include <libraries/commodities.h>
18 #include <proto/exec.h>
19 #include <proto/commodities.h>
21 AROS_LH1(LONG, CopyBrokerList,
23 /* SYNOPSIS */
25 AROS_LHA(struct List *, CopyofList, A0),
27 /* LOCATION */
29 struct Library *, CxBase, 31, Commodities)
31 /* FUNCTION
33 Get a copy of the internal list of brokers.
35 INPUTS
37 CopyofList -- pointer to a list
39 RESULT
41 The number of brokers in the list. The elements of the input list will
42 be deallocated.
44 NOTES
46 This function is present in AmigaOS too but undocumented.
48 EXAMPLE
50 BUGS
52 SEE ALSO
54 INTERNALS
56 HISTORY
58 ******************************************************************************/
61 AROS_LIBFUNC_INIT
63 LONG count = 0;
64 struct BrokerCopy *brokerCopy;
65 CxObj *broker;
67 FreeBrokerList(CopyofList);
69 ObtainSemaphore(&GPB(CxBase)->cx_SignalSemaphore);
71 ForeachNode(&GPB(CxBase)->cx_BrokerList, broker)
73 if (CxObjType(broker) == CX_ZERO)
75 break;
78 brokerCopy = AllocVec(sizeof(struct BrokerCopy), MEMF_PUBLIC | MEMF_CLEAR);
80 if (brokerCopy == NULL)
82 break;
85 /* Copy the broker name */
86 CopyMem(broker->co_Ext.co_BExt, brokerCopy->bc_Name, sizeof(*broker->co_Ext.co_BExt));
87 brokerCopy->bc_Flags = broker->co_Flags;
88 /* Point the node name to the broker name */
89 brokerCopy->bc_Node.ln_Name = brokerCopy->bc_Name;
92 AddTail(CopyofList, &brokerCopy->bc_Node);
93 count++;
96 ReleaseSemaphore(&GPB(CxBase)->cx_SignalSemaphore);
98 return count;
100 AROS_LIBFUNC_EXIT
101 } /* CopyBrokerList */