- Updates to entry selection behaviour to accommodate multiselection test
[AROS.git] / compiler / libinit / libinit.c
blob639b3da09464a4bcf36a388dbc15296c6f61bd23
1 /*
2 Copyright © 1995-2010, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: libinit library - functions calling when opening/closing libs
6 */
8 #include <exec/types.h>
9 #include <aros/symbolsets.h>
11 typedef int (*libfunc)(APTR libbase);
12 typedef int (*opendevfunc)
14 void *libbase,
15 void *ioreq,
16 ULONG unitnum,
17 ULONG flags
19 typedef int (*closedevfunc)
21 void *libbase,
22 void *ioreq
25 int set_call_libfuncs
27 const void * const set[],
28 int order,
29 int test_fail,
30 APTR libbase
33 int pos, (*func)(APTR);
35 if (!set)
36 return TRUE;
38 ForeachElementInSet(set, order, pos, func)
40 if (test_fail)
42 if (!(*func)(libbase))
43 return FALSE;
45 else
47 (void)(*func)(libbase);
51 return TRUE;
54 int set_call_devfuncs
56 const void * const set[],
57 int order,
58 int test_fail,
59 void *libbase,
60 void *ioreq,
61 IPTR unitnum,
62 ULONG flags
65 int pos;
67 if (!set)
68 return TRUE;
70 if (order>=0)
72 int (*func)(APTR, APTR, IPTR, ULONG);
74 ForeachElementInSet(set, order, pos, func)
76 if (test_fail)
78 if (!(*func)(libbase, ioreq, unitnum, flags))
79 return FALSE;
81 else
83 (void)(*func)(libbase, ioreq, unitnum, flags);
87 else
89 int (*func)(APTR, APTR);
91 ForeachElementInSet(set, order, pos, func)
93 if (test_fail)
95 if (!(*func)(libbase, ioreq))
96 return FALSE;
98 else
100 (void)(*func)(libbase, ioreq);
105 return TRUE;