6 #define LIBNAME "wave.datatype"
8 #include "wave.datatype_rev.h"
9 #include "wave_class.h"
17 ULONG
libObtain (struct LibraryManagerInterface
*Self
);
18 ULONG
libRelease (struct LibraryManagerInterface
*Self
);
19 struct ClassBase
*libOpen (struct LibraryManagerInterface
*Self
, ULONG version
);
20 BPTR
libClose (struct LibraryManagerInterface
*Self
);
21 BPTR
libExpunge (struct LibraryManagerInterface
*Self
);
23 static CONST_APTR lib_manager_vectors
[] = {
35 static const struct TagItem lib_managerTags
[] = {
36 { MIT_Name
, (ULONG
)"__library" },
37 { MIT_VectorTable
, (ULONG
)lib_manager_vectors
},
42 ULONG
dtObtain (struct DTClassIFace
*Self
);
43 ULONG
dtRelease (struct DTClassIFace
*Self
);
44 Class
* dtObtainEngine (struct DTClassIFace
*Self
);
46 static CONST_APTR lib_main_vectors
[] = {
55 static const struct TagItem lib_mainTags
[] = {
56 { MIT_Name
, (ULONG
)"main" },
57 { MIT_VectorTable
, (ULONG
)lib_main_vectors
},
62 static CONST_APTR libInterfaces
[] = {
68 struct ClassBase
* libInit (struct ClassBase
*libBase
, BPTR seglist
, struct ExecIFace
*ISys
);
70 static const struct TagItem libCreateTags
[] = {
71 { CLT_DataSize
, (ULONG
)sizeof(struct ClassBase
) },
72 { CLT_InitFunc
, (ULONG
)libInit
},
73 { CLT_Interfaces
, (ULONG
)libInterfaces
},
77 const struct Resident lib_res
84 (struct Resident
*)&lib_res
,
86 RTF_NATIVE
|RTF_AUTOINIT
, /* Add RTF_COLDSTART if you want to be resident */
88 NT_LIBRARY
, /* Make this NT_DEVICE if needed */
89 0, /* PRI, usually not needed unless you're resident */
98 static int openDTLibs (struct ClassBase
*libBase
);
99 static void closeDTLibs (struct ClassBase
*libBase
);
101 struct ClassBase
*libInit (struct ClassBase
*libBase
, BPTR seglist
, struct ExecIFace
*ISys
) {
103 libBase
->libNode
.lib_Node
.ln_Type
= NT_LIBRARY
;
104 libBase
->libNode
.lib_Node
.ln_Pri
= 0;
105 libBase
->libNode
.lib_Node
.ln_Name
= LIBNAME
;
106 libBase
->libNode
.lib_Flags
= LIBF_SUMUSED
|LIBF_CHANGED
;
107 libBase
->libNode
.lib_Version
= VERSION
;
108 libBase
->libNode
.lib_Revision
= REVISION
;
109 libBase
->libNode
.lib_IdString
= VSTRING
;
112 libBase
->SegList
= seglist
;
113 if (openDTLibs(libBase
)) {
114 if (libBase
->DTClass
= initDTClass(libBase
)) {
118 closeDTLibs(libBase
);
123 ULONG
libObtain (struct LibraryManagerInterface
*Self
) {
124 return Self
->Data
.RefCount
++;
127 ULONG
libRelease (struct LibraryManagerInterface
*Self
) {
128 return Self
->Data
.RefCount
--;
131 struct ClassBase
*libOpen (struct LibraryManagerInterface
*Self
, ULONG version
) {
132 struct ClassBase
*libBase
;
134 libBase
= (struct ClassBase
*)Self
->Data
.LibBase
;
136 libBase
->libNode
.lib_OpenCnt
++;
137 libBase
->libNode
.lib_Flags
&= ~LIBF_DELEXP
;
142 BPTR
libClose (struct LibraryManagerInterface
*Self
) {
143 struct ClassBase
*libBase
;
145 libBase
= (struct ClassBase
*)Self
->Data
.LibBase
;
147 libBase
->libNode
.lib_OpenCnt
--;
149 if (libBase
->libNode
.lib_OpenCnt
) {
153 if (libBase
->libNode
.lib_Flags
& LIBF_DELEXP
) {
154 return (BPTR
)Self
->LibExpunge();
160 BPTR
libExpunge (struct LibraryManagerInterface
*Self
) {
161 struct ClassBase
*libBase
;
164 libBase
= (struct ClassBase
*)Self
->Data
.LibBase
;
166 if (libBase
->libNode
.lib_OpenCnt
== 0) {
167 Remove(&libBase
->libNode
.lib_Node
);
169 result
= libBase
->SegList
;
171 freeDTClass(libBase
, libBase
->DTClass
);
172 libBase
->DTClass
= NULL
;
174 closeDTLibs(libBase
);
176 Remove(&libBase
->libNode
.lib_Node
);
177 DeleteLibrary(&libBase
->libNode
);
179 libBase
->libNode
.lib_Flags
|= LIBF_DELEXP
;
185 ULONG
dtObtain (struct DTClassIFace
*Self
) {
186 return(Self
->Data
.RefCount
++);
189 ULONG
dtRelease (struct DTClassIFace
*Self
) {
190 return(Self
->Data
.RefCount
--);
193 Class
* dtObtainEngine (struct DTClassIFace
*Self
) {
194 struct ClassBase
*libBase
;
195 libBase
= (struct ClassBase
*)Self
->Data
.LibBase
;
196 return libBase
->DTClass
;
200 static int openDTLibs (struct ClassBase
*libBase
) {
201 DOSBase
= OpenLibrary("dos.library", 50);
202 if (!DOSBase
) return FALSE
;
204 IntuitionBase
= OpenLibrary("intuition.library", 50);
205 if (!IntuitionBase
) return FALSE
;
207 UtilityBase
= OpenLibrary("utility.library", 50);
208 if (!UtilityBase
) return FALSE
;
210 DataTypesBase
= OpenLibrary("datatypes.library", 50);
211 if (!DataTypesBase
) return FALSE
;
216 static void closeDTLibs (struct ClassBase
*libBase
) {
217 if (DataTypesBase
) CloseLibrary(DataTypesBase
);
219 if (UtilityBase
) CloseLibrary(UtilityBase
);
221 if (IntuitionBase
) CloseLibrary(IntuitionBase
);
223 if (DOSBase
) CloseLibrary(DOSBase
);