3 // ©1996-2000 Henrik Isaksson
5 // Library init & cleanup
17 struct Library
*UtilityBase
=NULL
;
18 struct IntuitionBase
*IntuitionBase
=NULL
;
19 struct GfxBase
*GfxBase
=NULL
;
20 struct DosLibrary
*DOSBase
=NULL
;
21 struct Library
*CxBase
=NULL
;
22 struct Library
*LayersBase
=NULL
;
23 struct Library
*CyberGfxBase
=NULL
;
25 extern struct ExecBase
*SysBase
;
34 if(MemPool
) DeletePool(MemPool
);
35 if(UtilityBase
) CloseLibrary((struct Library
*)UtilityBase
);
36 if(GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
37 if(IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
38 if(DOSBase
) CloseLibrary((struct Library
*)DOSBase
);
39 if(CxBase
) CloseLibrary((struct Library
*)CxBase
);
40 if(LayersBase
) CloseLibrary((struct Library
*)LayersBase
);
41 if(CyberGfxBase
) CloseLibrary((struct Library
*)CyberGfxBase
);
53 BOOL __asm __saveds
OpenLibs(register __a6
struct PopupMenuBase
*l
)
55 if(UtilityBase
) return TRUE
;
57 l
->pmb_UtilityBase
=OpenLibrary("utility.library",37L);
58 if(l
->pmb_UtilityBase
) {
59 UtilityBase
=l
->pmb_UtilityBase
;
60 l
->pmb_GfxBase
=OpenLibrary("graphics.library",40L);
61 if(!l
->pmb_GfxBase
) l
->pmb_GfxBase
=OpenLibrary("graphics.library",37L);
64 GfxBase
=(struct GfxBase
*)l
->pmb_GfxBase
;
65 l
->pmb_IntuitionBase
=OpenLibrary("intuition.library",37L);
66 if(l
->pmb_IntuitionBase
) {
67 IntuitionBase
=(struct IntuitionBase
*)l
->pmb_IntuitionBase
;
68 l
->pmb_DOSBase
=OpenLibrary("dos.library",0L);
70 DOSBase
=(struct DosLibrary
*)l
->pmb_DOSBase
;
71 l
->pmb_ExecBase
= (struct Library
*)SysBase
;
72 l
->pmb_CxBase
=OpenLibrary("commodities.library",37L);
75 LayersBase
=OpenLibrary("layers.library",0);
76 l
->pmb_LayersBase
=LayersBase
;
78 CyberGfxBase
=OpenLibrary("cybergraphics.library",39L);
81 l
->pmb_CyberGfxBase
=CyberGfxBase
;
82 #if defined(__AROS__) || defined(__MORPHOS)
83 if((MemPool
= CreatePool(MEMF_ANY
| MEMF_CLEAR
| MEMF_SEM_PROTECTED
, 10240L, 10240L))) {
85 if((MemPool
= CreatePool(MEMF_ANY
, 10240L, 10240L))) {
88 PM_Prefs_Load(PMP_PATH
);
103 // Library initializtion
106 int __asm __saveds
__UserLibInit(register __a6
struct PopupMenuBase
*l
)
108 //kprintf("UserLibInit, pmbase = %08lx\n", l);
111 SysBase
= (struct ExecBase
*)l
->pmb_ExecBase
;
113 SysBase
=*((struct ExecBase
**)4);
115 if(!OpenLibs(l
)) return -1;
117 //kprintf("UserLibInit failed\n");
122 void __asm __saveds
__UserLibCleanup(register __a6
struct PopupMenuBase
*l
)
125 //kprintf("UserLibCleanUp, pmbase = %08lx\n", l);
127 //PM_FreeAllImages();
133 if(MemPool
) DeletePool(MemPool
);
134 if(UtilityBase
) CloseLibrary((struct Library
*)UtilityBase
);
135 if(GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
136 if(IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
137 if(DOSBase
) CloseLibrary((struct Library
*)DOSBase
);
138 if(CxBase
) CloseLibrary((struct Library
*)CxBase
);
139 if(LayersBase
) CloseLibrary((struct Library
*)LayersBase
);
140 if(CyberGfxBase
) CloseLibrary((struct Library
*)CyberGfxBase
);
142 //kprintf("UserLibCleanUp done.\n");
146 #include <aros/symbolsets.h>
147 #include <aros/debug.h>
149 static int AROS__UserLibInit(struct PopupMenuBase
*PopupMenuBase
)
151 return (__UserLibInit(PopupMenuBase
) == 0) ? TRUE
: FALSE
;
154 static int AROS__UserLibCleanup(struct PopupMenuBase
*PopupMenuBase
)
156 __UserLibCleanup(PopupMenuBase
);
161 ADD2INITLIB(AROS__UserLibInit
, 0);
162 ADD2EXPUNGELIB(AROS__UserLibCleanup
, 0);