Re-enabled use of AROS.Boot file due to lack of general enthusiasm for
[tangerine.git] / arch / all-mingw32 / hostlib / hostlib.c
blobc42b0bbc125653ad50bb3da64bff46f287f8e2c5
1 #define DEBUG 0
3 #include <aros/debug.h>
4 #include <aros/kernel.h>
5 #include <aros/libcall.h>
6 #include <aros/symbolsets.h>
7 #include <proto/exec.h>
8 #include <proto/kernel.h>
9 #include <proto/utility.h>
11 #include "../kernel/hostinterface.h"
12 #include "hostlib_intern.h"
14 #include LC_LIBDEFS_FILE
16 AROS_LH2(void *, HostLib_Open,
17 AROS_LHA(const char *, filename, A0),
18 AROS_LHA(char **, error, A1),
19 struct HostLibBase *, HostLibBase, 1, HostLib)
21 AROS_LIBFUNC_INIT
23 return HostLibBase->HostIFace->HostLib_Open(filename, error);
25 AROS_LIBFUNC_EXIT
28 AROS_LH2(BOOL, HostLib_Close,
29 AROS_LHA(void *, handle, A0),
30 AROS_LHA(char **, error, A1),
31 struct HostLibBase *, HostLibBase, 2, HostLib)
33 AROS_LIBFUNC_INIT
35 return HostLibBase->HostIFace->HostLib_Close(handle, error);
37 AROS_LIBFUNC_EXIT
40 AROS_LH3(void *, HostLib_GetPointer,
41 AROS_LHA(void *, handle, A0),
42 AROS_LHA(const char *, symbol, A1),
43 AROS_LHA(char **, error, A2),
44 struct HostLibBase *, HostLibBase, 3, HostLib)
46 AROS_LIBFUNC_INIT
48 return HostLibBase->HostIFace->HostLib_GetPointer(handle, symbol, error);
50 AROS_LIBFUNC_EXIT
53 AROS_LH1(void, HostLib_FreeErrorStr,
54 AROS_LHA(char *, error, A0),
55 struct HostLibBase *, HostLibBase, 4, HostLib)
57 AROS_LIBFUNC_INIT
59 HostLibBase->HostIFace->HostLib_FreeErrorStr(error);
61 AROS_LIBFUNC_EXIT
64 AROS_LH3(APTR *, HostLib_GetInterface,
65 AROS_LHA(void *, handle, A0),
66 AROS_LHA(const char **, symtable, A1),
67 AROS_LHA(ULONG *, unresolved, A2),
68 struct HostLibBase *, HostLibBase, 5, HostLib)
70 AROS_LIBFUNC_INIT
72 const char **c;
73 ULONG cnt = 0;
74 APTR *iface = NULL;
76 for (c = symtable; *c; c++)
77 cnt += sizeof(APTR);
78 if (cnt) {
79 iface = AllocVec(cnt, MEMF_CLEAR);
80 if (iface) {
81 cnt = HostLibBase->HostIFace->HostLib_GetInterface(handle, symtable, iface);
82 if (unresolved)
83 *unresolved = cnt;
86 return iface;
88 AROS_LIBFUNC_EXIT
91 AROS_LH1I(void, HostLib_DropInterface,
92 AROS_LHA(APTR *, interface, A0),
93 struct HostLibBase *, HostLibBase, 6, HostLib)
95 AROS_LIBFUNC_INIT
97 FreeVec(interface);
99 AROS_LIBFUNC_EXIT
102 /* auto init */
103 static int HostLib_Init(LIBBASETYPEPTR LIBBASE)
105 struct UtilityBase *UlitityBase;
106 APTR KernelBase;
107 struct TagItem *BootInfo;
109 UtilityBase = (struct UtilityBase *)OpenLibrary("utility.library", 36);
110 D(bug("[hostlib] UtilityBase = 0x%08lX\n", UtilityBase));
111 if (UtilityBase) {
112 KernelBase = OpenResource("kernel.resource");
113 D(bug("[hostlib] KernelBase = 0x%08lX\n", KernelBase));
114 if (KernelBase) {
115 BootInfo = KrnGetBootInfo();
116 HostLibBase->HostIFace = (struct HostInterface *)GetTagData(KRN_HostInterface, 0, BootInfo);
117 D(bug("[hostlib] HostIFace = 0x%08lX\n", HostLibBase->HostIFace));
119 CloseLibrary((struct Library *)UtilityBase);
121 return (int)HostLibBase->HostIFace;
124 ADD2INITLIB(HostLib_Init, 0)