Small cleanup of extensions code
[AROS.git] / compiler / autoinit / libraries.c
blob737d4fa0ee0c65751bb1c098f09e3e4f62093cdf
1 /*
2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: autoinit library - automatic library opening/closing handling
6 Lang: english
7 */
9 #include <proto/exec.h>
10 #include <dos/dos.h>
11 #include <aros/symbolsets.h>
12 #include <aros/autoinit.h>
13 #include <intuition/intuition.h>
14 #include <dos/dosextens.h>
15 #include <proto/intuition.h>
16 #include <proto/dos.h>
17 #include <stdlib.h>
19 DECLARESET(LIBS);
21 AROS_MAKE_ASM_SYM(int, dummy, __includelibrarieshandling, 0);
22 AROS_EXPORT_ASM_SYM(__includelibrarieshandling);
24 int set_open_libraries_list(const void *list[])
26 int pos;
27 struct libraryset *set;
29 ForeachElementInSet(list, 1, pos, set)
31 LONG version = *set->versionptr;
32 BOOL do_not_fail = 0;
34 if (version < 0)
36 version = -(version + 1);
37 do_not_fail = 1;
40 *set->baseptr = OpenLibrary(set->name, version);
42 if (!do_not_fail && *set->baseptr == NULL)
44 __showerror
46 "Could not open version %ld or higher of library \"%s\".",
47 (const IPTR []){version, set->name}
50 return 0;
54 return 1;
57 void set_close_libraries_list(const void *list[])
59 int pos;
60 struct libraryset *set;
62 ForeachElementInSet(SETNAME(LIBS), 1, pos, set)
64 if (*set->baseptr)
65 CloseLibrary(*set->baseptr);