Small cleanup of extensions code
[AROS.git] / compiler / libinit / libinit.c
blob6143b299a61713e8e5b84484c5f4d043863cded5
1 /*
2 Copyright © 1995-2006, 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 *set[],
28 int order,
29 int test_fail,
30 APTR libbase
33 int pos, (*func)(APTR);
35 ForeachElementInSet(set, order, pos, func)
37 if (test_fail)
39 if (!(*func)(libbase))
40 return FALSE;
42 else
44 (void)(*func)(libbase);
48 return TRUE;
51 int set_call_devfuncs
53 const void *set[],
54 int order,
55 int test_fail,
56 void *libbase,
57 void *ioreq,
58 ULONG unitnum,
59 ULONG flags
62 int pos;
64 if (order>=0)
66 int (*func)(APTR, APTR, ULONG, ULONG);
68 ForeachElementInSet(set, order, pos, func)
70 if (test_fail)
72 if (!(*func)(libbase, ioreq, unitnum, flags))
73 return FALSE;
75 else
77 (void)(*func)(libbase, ioreq, unitnum, flags);
81 else
83 int (*func)(APTR, APTR);
85 ForeachElementInSet(set, order, pos, func)
87 if (test_fail)
89 if (!(*func)(libbase, ioreq))
90 return FALSE;
92 else
94 (void)(*func)(libbase, ioreq);
99 return TRUE;