Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / muimaster / muimaster_init.c
blobe26b898b28f0562f3a98a0786f360143cac120a4
1 /*
2 Copyright © 2002, The AROS Development Team.
3 All rights reserved.
5 $Id$
6 */
8 #include <exec/types.h>
9 #include <exec/libraries.h>
11 #include <proto/exec.h>
12 #include <clib/alib_protos.h>
14 #include "muimaster_intern.h"
15 #include "mui.h"
17 /****************************************************************************************/
19 /* #define MYDEBUG 1 */
20 #include "debug.h"
22 /* Global libbase vars */
23 #undef IntuitionBase
25 /* Undef the following bases because the casts struct Libaray * -> struct <Lib>Base * casts
26 * would use them */
27 #undef UtilityBase
28 #undef DOSBase
29 #undef GfxBase
31 struct Library *MUIMasterBase;
32 struct IntuitionBase *IntuitionBase;
33 struct Library *DataTypesBase;
35 struct Library **MUIMasterBasePtr = &MUIMasterBase;
37 /****************************************************************************************/
39 ULONG SAVEDS STDARGS LC_BUILDNAME(L_InitLib) (LC_LIBHEADERTYPEPTR MUIMasterBase)
41 D(bug("Inside Init func of muimaster.library\n"));
43 *MUIMasterBasePtr = MUIMasterBase;
45 if (!MUIMB(MUIMasterBase)->dosbase)
47 if (!(MUIMB(MUIMasterBase)->dosbase = (struct DosLibrary*)OpenLibrary("dos.library", 37)))
48 return FALSE;
51 if (!MUIMB(MUIMasterBase)->utilitybase)
53 if (!(MUIMB(MUIMasterBase)->utilitybase = (struct UtilityBase*)OpenLibrary("utility.library", 37)))
54 return FALSE;
57 if (!MUIMB(MUIMasterBase)->gfxbase)
59 if (!(MUIMB(MUIMasterBase)->gfxbase = (struct GfxBase*)OpenLibrary("graphics.library", 39)))
60 return FALSE;
63 if (!AslBase)
64 AslBase = OpenLibrary("asl.library", 37);
65 if (!AslBase)
66 return FALSE;
68 if (!LayersBase)
69 LayersBase = OpenLibrary("layers.library", 37);
70 if (!LayersBase)
71 return FALSE;
73 if (!IntuitionBase)
74 IntuitionBase = (struct IntuitionBase*)OpenLibrary("intuition.library", 39);
75 if (!IntuitionBase)
76 return FALSE;
78 if (!CxBase)
79 CxBase = OpenLibrary("commodities.library", 37);
80 if (!CxBase)
81 return FALSE;
83 if (!GadToolsBase)
84 GadToolsBase = OpenLibrary("gadtools.library", 37);
85 if (!GadToolsBase)
86 return FALSE;
88 if (!KeymapBase)
89 KeymapBase = OpenLibrary("keymap.library", 37);
90 if (!KeymapBase)
91 return FALSE;
93 if (!DataTypesBase)
94 DataTypesBase = OpenLibrary("datatypes.library", 37);
95 if (!DataTypesBase)
96 return FALSE;
98 if (!IFFParseBase)
99 IFFParseBase = OpenLibrary("iffparse.library", 37);
100 if (!IFFParseBase)
101 return FALSE;
103 if (!DiskfontBase)
104 DiskfontBase = OpenLibrary("diskfont.library", 37);
105 if (!DiskfontBase)
106 return FALSE;
108 if (!IconBase)
109 IconBase = OpenLibrary("icon.library", 37); /* V44 really */
110 if (!IconBase)
111 return FALSE;
113 if (!CyberGfxBase)
114 CyberGfxBase = OpenLibrary("cybergraphics.library", 0);
115 /* continue even if cybergraphics.library is not available */
117 #ifdef HAVE_COOLIMAGES
118 if (!CoolImagesBase)
119 CoolImagesBase = OpenLibrary("coolimages.library", 0);
120 #endif
122 MUIMB(MUIMasterBase)->intuibase = IntuitionBase;
124 InitSemaphore(&MUIMB(MUIMasterBase)->ZuneSemaphore);
126 NewList((struct List *)&MUIMB(MUIMasterBase)->BuiltinClasses);
127 NewList((struct List *)&MUIMB(MUIMasterBase)->Applications);
128 return TRUE;
131 /****************************************************************************************/
133 ULONG SAVEDS STDARGS LC_BUILDNAME(L_OpenLib) (LC_LIBHEADERTYPEPTR MUIMasterBase)
135 D(bug("Inside Open func of muimaster.library\n"));
137 return TRUE;
140 /****************************************************************************************/
142 void SAVEDS STDARGS LC_BUILDNAME(L_CloseLib) (LC_LIBHEADERTYPEPTR MUIMasterBase)
144 D(bug("Inside Close func of muimaster.library\n"));
147 /****************************************************************************************/
149 void SAVEDS STDARGS LC_BUILDNAME(L_ExpungeLib) (LC_LIBHEADERTYPEPTR MUIMasterBase)
151 D(bug("Inside Expunge func of muimaster.library\n"));
153 /* CloseLibrary() checks for NULL-pointers */
155 CloseLibrary((struct Library *)MUIMB(MUIMasterBase)->gfxbase);
156 MUIMB(MUIMasterBase)->gfxbase = NULL;
158 CloseLibrary((struct Library *)MUIMB(MUIMasterBase)->utilitybase);
159 MUIMB(MUIMasterBase)->utilitybase = NULL;
161 CloseLibrary(AslBase);
162 CloseLibrary((struct Library *)MUIMB(MUIMasterBase)->dosbase);
163 MUIMB(MUIMasterBase)->dosbase = NULL;
165 AslBase = NULL;
167 CloseLibrary(LayersBase);
168 LayersBase = NULL;
170 CloseLibrary((struct Library *)MUIMB(MUIMasterBase)->intuibase);
171 MUIMB(MUIMasterBase)->intuibase = IntuitionBase = NULL;
173 CloseLibrary(CxBase);
174 CxBase = NULL;
176 CloseLibrary(GadToolsBase);
177 GadToolsBase = NULL;
179 CloseLibrary(KeymapBase);
180 KeymapBase = NULL;
182 CloseLibrary(DataTypesBase);
183 DataTypesBase = NULL;
185 CloseLibrary(IFFParseBase);
186 IFFParseBase = NULL;
188 CloseLibrary(DiskfontBase);
189 DiskfontBase = NULL;
191 CloseLibrary(IconBase);
192 IconBase = NULL;
194 CloseLibrary(CyberGfxBase);
195 CyberGfxBase = NULL;
197 #ifdef HAVE_COOLIMAGES
198 CloseLibrary(CoolImagesBase);
199 CoolImagesBase = NULL;
200 #endif
203 /****************************************************************************************/