Icons for Radium and Shellplayer.
[AROS-Contrib.git] / bgui / bgui_init.c
blobe2f2f996d14feb75b74586cb9d0182f7cb1d11ba
1 /*
2 Copyright © 1997, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CGFX Library
6 Lang: english
7 */
9 #define NO_MEMORY_ALLOCATION_DEBUG_ALIASING
11 #include "include/classdefs.h"
14 * Global data (written to once at initalization time).
16 BPTR SegList = 0;
17 #ifndef ENHANCED
18 makeproto BOOL OS30 = FALSE;
19 #endif
21 struct Library *BGUIBase = NULL;
22 struct DosLibrary *DOSBase = NULL;
23 struct ExecBase *SysBase = NULL;
24 struct IntuitionBase *IntuitionBase = NULL;
25 struct GfxBase *GfxBase = NULL;
26 struct Library *GadToolsBase = NULL; /* Menu stuff. */
27 struct Library *UtilityBase = NULL;
28 struct Library *LayersBase = NULL;
29 struct Library *AslBase = NULL;
30 struct Library *CxBase = NULL;
31 struct Library *KeymapBase = NULL;
32 struct Library *IFFParseBase = NULL;
33 struct Library *DataTypesBase = NULL;
34 struct Library *LocaleBase = NULL;
35 struct Library *WorkbenchBase = NULL;
36 struct Catalog *Catalog = NULL;
38 struct Task *InputDevice = NULL;
39 APTR InputStack = NULL;
41 #ifdef SysBase
42 # undef SysBase
43 #endif
45 /* Customize libheader.c */
46 #define LC_SYSBASE_FIELD(lib) SysBase
47 #define LC_SEGLIST_FIELD(lib) SegList
48 #define LC_LIBBASESIZE sizeof(struct Library)
49 #define LC_LIBHEADERTYPEPTR LIBBASETYPEPTR
50 #define LC_LIB_FIELD(lib) lib
51 #define LC_STATIC_OPENLIB
52 #define LC_STATIC_CLOSELIB
53 #define LC_STATIC_EXPUNGELIB
54 #define LC_STATIC_INITLIB
56 #include <libcore/libheader.c>
58 /********************************************************************************************/
60 SAVEDS STATIC VOID CloseLibs(void)
62 if (LocaleBase) CloseLibrary(LocaleBase);
63 if (KeymapBase) CloseLibrary(KeymapBase);
64 if (CxBase) CloseLibrary(CxBase);
65 if (AslBase) CloseLibrary(AslBase);
66 if (LayersBase) CloseLibrary(LayersBase);
67 if (UtilityBase) CloseLibrary(UtilityBase);
68 if (GadToolsBase) CloseLibrary(GadToolsBase);
69 if (DataTypesBase) CloseLibrary(DataTypesBase);
70 if (IFFParseBase) CloseLibrary(IFFParseBase);
71 if (WorkbenchBase) CloseLibrary(WorkbenchBase);
72 if (GfxBase) CloseLibrary((struct Library *)GfxBase);
73 if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
74 if (DOSBase) CloseLibrary((struct Library *)DOSBase);
77 /********************************************************************************************/
79 static ULONG SAVEDS STDARGS LC_BUILDNAME(L_InitLib) (LIBBASETYPEPTR LIBBASE)
81 struct Library *lib;
84 * Open up system libraries.
86 #ifdef ENHANCED
87 DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 39);
88 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39);
89 GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 39);
90 #else
91 OS30 = (((struct Library *)SysBase)->lib_Version >= 39);
93 DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37);
94 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
95 GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37);
96 #endif
98 GadToolsBase = OpenLibrary("gadtools.library", 37);
99 UtilityBase = OpenLibrary("utility.library", 37);
100 LayersBase = OpenLibrary("layers.library", 37);
101 AslBase = OpenLibrary("asl.library", 37);
102 CxBase = OpenLibrary("commodities.library", 37);
103 KeymapBase = OpenLibrary("keymap.library", 37);
104 IFFParseBase = OpenLibrary("iffparse.library", 37);
105 WorkbenchBase = OpenLibrary("workbench.library", 37);
106 LocaleBase = OpenLibrary("locale.library", 38);
107 DataTypesBase = OpenLibrary("datatypes.library", 39);
109 InitInputStack();
111 #ifdef OUTDATE_BUILD
112 if(DOSBase)
114 static struct DateStamp expiry_date=
116 OUTDATE_BUILD,0,0
118 struct DateStamp today;
120 DateStamp(&today);
121 if(CompareDates(&today,&expiry_date)<0)
123 /* if we return FALSE here, Expunge is called by libheader.c and so
124 the libs are close there */
126 /* CloseLibs(); */
127 return FALSE;
130 #endif
132 * All libraries open?
134 if (DOSBase && IntuitionBase && GfxBase && GadToolsBase && UtilityBase && LayersBase && IFFParseBase && WorkbenchBase
135 && AslBase && CxBase && KeymapBase)
138 * Initialize the task-list.
140 InitTaskList();
142 return TRUE;
146 /* if we return FALSE here, Expunge is called by libheader.c and so
147 the libs are close there */
149 /* CloseLibs(); */
151 return FALSE;
154 /********************************************************************************************/
156 static void SAVEDS STDARGS LC_BUILDNAME(L_ExpungeLib) (LIBBASETYPEPTR LIBBASE)
158 if (Catalog)
159 CloseCatalog(Catalog);
161 FreeInputStack();
164 * Close system libraries.
166 CloseLibs();
168 FreeTaskList();
171 /********************************************************************************************/
173 static ULONG SAVEDS STDARGS LC_BUILDNAME(L_OpenLib) (LC_LIBBASETYPEPTR lh)
175 UWORD tc;
178 * Add this task to the list.
180 if ((tc = AddTaskMember()) != TASK_FAILED)
183 * Increase open counter when necessary.
186 #if 0
187 if (tc == TASK_ADDED)
188 lib->lib_OpenCnt++;*/
189 #else
190 /* libheader.c always incs opencnt, so we must do this a bit different */
191 if (tc != TASK_ADDED) lh->lib_OpenCnt--;
192 #endif
193 return TRUE;
196 return FALSE;
199 /********************************************************************************************/
201 static void SAVEDS STDARGS LC_BUILDNAME(L_CloseLib) (LC_LIBBASETYPEPTR lh)
203 #warning real BGUI CloseLib (in lib.c) checks if it is safe to closelib or not and if it is not it does not close (dec usecount and maybe expunge)
205 * Remove the task from the member list.
207 FreeTaskMember();