2 Copyright © 1997, The AROS Development Team. All rights reserved.
9 #define NO_MEMORY_ALLOCATION_DEBUG_ALIASING
11 #include "include/classdefs.h"
14 * Global data (written to once at initalization time).
18 makeproto BOOL OS30
= FALSE
;
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
;
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
)
84 * Open up system libraries.
87 DOSBase
= (struct DosLibrary
*) OpenLibrary("dos.library", 39);
88 IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library", 39);
89 GfxBase
= (struct GfxBase
*) OpenLibrary("graphics.library", 39);
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);
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);
114 static struct DateStamp expiry_date
=
118 struct 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 */
132 * All libraries open?
134 if (DOSBase
&& IntuitionBase
&& GfxBase
&& GadToolsBase
&& UtilityBase
&& LayersBase
&& IFFParseBase
&& WorkbenchBase
135 && AslBase
&& CxBase
&& KeymapBase
)
138 * Initialize the task-list.
146 /* if we return FALSE here, Expunge is called by libheader.c and so
147 the libs are close there */
154 /********************************************************************************************/
156 static void SAVEDS STDARGS
LC_BUILDNAME(L_ExpungeLib
) (LIBBASETYPEPTR LIBBASE
)
159 CloseCatalog(Catalog
);
164 * Close system libraries.
171 /********************************************************************************************/
173 static ULONG SAVEDS STDARGS
LC_BUILDNAME(L_OpenLib
) (LC_LIBBASETYPEPTR lh
)
178 * Add this task to the list.
180 if ((tc
= AddTaskMember()) != TASK_FAILED
)
183 * Increase open counter when necessary.
187 if (tc
== TASK_ADDED
)
188 lib
->lib_OpenCnt
++;*/
190 /* libheader.c always incs opencnt, so we must do this a bit different */
191 if (tc
!= TASK_ADDED
) lh
->lib_OpenCnt
--;
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.