-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbgui_init.c
More file actions
209 lines (171 loc) · 6.1 KB
/
Copy pathbgui_init.c
File metadata and controls
209 lines (171 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
Copyright © 1997, The AROS Development Team. All rights reserved.
$Id$
Desc: CGFX Library
Lang: english
*/
#define NO_MEMORY_ALLOCATION_DEBUG_ALIASING
#include "include/classdefs.h"
/*
* Global data (written to once at initalization time).
*/
BPTR SegList = 0;
#ifndef ENHANCED
makeproto BOOL OS30 = FALSE;
#endif
struct Library *BGUIBase = NULL;
struct DosLibrary *DOSBase = NULL;
struct ExecBase *SysBase = NULL;
struct IntuitionBase *IntuitionBase = NULL;
struct GfxBase *GfxBase = NULL;
struct Library *GadToolsBase = NULL; /* Menu stuff. */
struct Library *UtilityBase = NULL;
struct Library *LayersBase = NULL;
struct Library *AslBase = NULL;
struct Library *CxBase = NULL;
struct Library *KeymapBase = NULL;
struct Library *IFFParseBase = NULL;
struct Library *DataTypesBase = NULL;
struct Library *LocaleBase = NULL;
struct Library *WorkbenchBase = NULL;
struct Catalog *Catalog = NULL;
struct Task *InputDevice = NULL;
APTR InputStack = NULL;
#ifdef SysBase
# undef SysBase
#endif
/* Customize libheader.c */
#define LC_SYSBASE_FIELD(lib) SysBase
#define LC_SEGLIST_FIELD(lib) SegList
#define LC_LIBBASESIZE sizeof(struct Library)
#define LC_LIBHEADERTYPEPTR LIBBASETYPEPTR
#define LC_LIB_FIELD(lib) lib
#define LC_STATIC_OPENLIB
#define LC_STATIC_CLOSELIB
#define LC_STATIC_EXPUNGELIB
#define LC_STATIC_INITLIB
#include <libcore/libheader.c>
/********************************************************************************************/
SAVEDS STATIC VOID CloseLibs(void)
{
if (LocaleBase) CloseLibrary(LocaleBase);
if (KeymapBase) CloseLibrary(KeymapBase);
if (CxBase) CloseLibrary(CxBase);
if (AslBase) CloseLibrary(AslBase);
if (LayersBase) CloseLibrary(LayersBase);
if (UtilityBase) CloseLibrary(UtilityBase);
if (GadToolsBase) CloseLibrary(GadToolsBase);
if (DataTypesBase) CloseLibrary(DataTypesBase);
if (IFFParseBase) CloseLibrary(IFFParseBase);
if (WorkbenchBase) CloseLibrary(WorkbenchBase);
if (GfxBase) CloseLibrary((struct Library *)GfxBase);
if (IntuitionBase) CloseLibrary((struct Library *)IntuitionBase);
if (DOSBase) CloseLibrary((struct Library *)DOSBase);
}
/********************************************************************************************/
static ULONG SAVEDS STDARGS LC_BUILDNAME(L_InitLib) (LIBBASETYPEPTR LIBBASE)
{
struct Library *lib;
/*
* Open up system libraries.
*/
#ifdef ENHANCED
DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 39);
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39);
GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 39);
#else
OS30 = (((struct Library *)SysBase)->lib_Version >= 39);
DOSBase = (struct DosLibrary *) OpenLibrary("dos.library", 37);
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 37);
GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 37);
#endif
GadToolsBase = OpenLibrary("gadtools.library", 37);
UtilityBase = OpenLibrary("utility.library", 37);
LayersBase = OpenLibrary("layers.library", 37);
AslBase = OpenLibrary("asl.library", 37);
CxBase = OpenLibrary("commodities.library", 37);
KeymapBase = OpenLibrary("keymap.library", 37);
IFFParseBase = OpenLibrary("iffparse.library", 37);
WorkbenchBase = OpenLibrary("workbench.library", 37);
LocaleBase = OpenLibrary("locale.library", 38);
DataTypesBase = OpenLibrary("datatypes.library", 39);
InitInputStack();
#ifdef OUTDATE_BUILD
if(DOSBase)
{
static struct DateStamp expiry_date=
{
OUTDATE_BUILD,0,0
};
struct DateStamp today;
DateStamp(&today);
if(CompareDates(&today,&expiry_date)<0)
{
/* if we return FALSE here, Expunge is called by libheader.c and so
the libs are close there */
/* CloseLibs(); */
return FALSE;
}
}
#endif
/*
* All libraries open?
*/
if (DOSBase && IntuitionBase && GfxBase && GadToolsBase && UtilityBase && LayersBase && IFFParseBase && WorkbenchBase
&& AslBase && CxBase && KeymapBase)
{
/*
* Initialize the task-list.
*/
InitTaskList();
return TRUE;
}
/* if we return FALSE here, Expunge is called by libheader.c and so
the libs are close there */
/* CloseLibs(); */
return FALSE;
}
/********************************************************************************************/
static void SAVEDS STDARGS LC_BUILDNAME(L_ExpungeLib) (LIBBASETYPEPTR LIBBASE)
{
if (Catalog)
CloseCatalog(Catalog);
FreeInputStack();
/*
* Close system libraries.
*/
CloseLibs();
FreeTaskList();
}
/********************************************************************************************/
static ULONG SAVEDS STDARGS LC_BUILDNAME(L_OpenLib) (LC_LIBBASETYPEPTR lh)
{
UWORD tc;
/*
* Add this task to the list.
*/
if ((tc = AddTaskMember()) != TASK_FAILED)
{
/*
* Increase open counter when necessary.
*/
#if 0
if (tc == TASK_ADDED)
lib->lib_OpenCnt++;*/
#else
/* libheader.c always incs opencnt, so we must do this a bit different */
if (tc != TASK_ADDED) lh->lib_OpenCnt--;
#endif
return TRUE;
}
return FALSE;
}
/********************************************************************************************/
static void SAVEDS STDARGS LC_BUILDNAME(L_CloseLib) (LC_LIBBASETYPEPTR lh)
{
#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)
/*
* Remove the task from the member list.
*/
FreeTaskMember();
}