1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
19 ***************************************************************************/
26 #include <proto/openurl.h>
28 #if defined(__amigaos4__)
29 struct Library
*DOSBase
= NULL
;
30 struct Library
*UtilityBase
= NULL
;
31 struct Library
*RexxSysBase
= NULL
;
32 struct Library
*IFFParseBase
= NULL
;
34 struct DOSIFace
* IDOS
= NULL
;
35 struct UtilityIFace
* IUtility
= NULL
;
36 struct RexxSysIFace
* IRexxSys
= NULL
;
37 struct IFFParseIFace
* IIFFParse
= NULL
;
39 #if !defined(__NEWLIB__)
40 extern struct Library
*__UtilityBase
;
41 extern struct UtilityIFace
* __IUtility
;
45 struct DosLibrary
*DOSBase
= NULL
;
47 struct UtilityBase
*UtilityBase
= NULL
;
49 struct Library
*UtilityBase
= NULL
;
50 struct Library
*__UtilityBase
= NULL
; // required by clib2 & libnix
52 #if defined(__MORPHOS__)
53 struct Library
*RexxSysBase
= NULL
;
55 struct RxsLib
*RexxSysBase
= NULL
;
57 struct Library
*IFFParseBase
= NULL
;
60 /***********************************************************************/
63 freeBase(struct LibraryHeader
*lib
)
67 D(DBF_STARTUP
, "freeing all resources of openurl.library");
69 if(lib
->prefs
!= NULL
)
71 CALL_LFUNC(URL_FreePrefsA
, lib
->prefs
, NULL
);
77 DROPINTERFACE(IRexxSys
);
78 CloseLibrary((struct Library
*)RexxSysBase
);
84 DROPINTERFACE(IIFFParse
);
85 CloseLibrary(IFFParseBase
);
89 // delete our private memory pool
92 #if defined(__amigaos4__)
93 FreeSysObject(ASOT_MEMPOOL
, lib
->pool
);
95 DeletePool(lib
->pool
);
102 DROPINTERFACE(IUtility
);
103 CloseLibrary((struct Library
*)UtilityBase
);
110 CloseLibrary((struct Library
*)DOSBase
);
114 CLEAR_FLAG(lib
->flags
, BASEFLG_Init
);
120 /***********************************************************************/
123 initBase(struct LibraryHeader
*lib
)
127 if((DOSBase
= (APTR
)OpenLibrary("dos.library", 37)) &&
128 GETINTERFACE(IDOS
, DOSBase
))
130 if((UtilityBase
= (APTR
)OpenLibrary("utility.library", 37)) &&
131 GETINTERFACE(IUtility
, UtilityBase
))
133 // we have to please the internal utilitybase
134 // pointers of libnix and clib2
135 #if !defined(__NEWLIB__) && !defined(__AROS__)
136 __UtilityBase
= (APTR
)UtilityBase
;
137 #if defined(__amigaos4__)
138 __IUtility
= IUtility
;
142 // setup the debugging stuff
147 if((IFFParseBase
= OpenLibrary("iffparse.library", 37)) &&
148 GETINTERFACE(IIFFParse
, IFFParseBase
))
149 if((RexxSysBase
= (APTR
)OpenLibrary("rexxsyslib.library", 36)) &&
150 GETINTERFACE(IRexxSys
, RexxSysBase
))
152 #if defined(__amigaos4__)
153 lib
->pool
= AllocSysObjectTags(ASOT_MEMPOOL
, ASOPOOL_MFlags
, MEMF_SHARED
|MEMF_CLEAR
,
154 ASOPOOL_Puddle
, 4096,
155 ASOPOOL_Threshold
, 512,
156 ASOPOOL_Name
, "openurl.library pool",
157 ASOPOOL_LockMem
, FALSE
,
160 lib
->pool
= CreatePool(MEMF_CLEAR
, 4096, 512);
162 if(lib
->pool
!= NULL
)
164 lib
->prefs
= loadPrefsNotFail();
166 if(lib
->prefs
!= NULL
)
168 SET_FLAG(lib
->flags
, BASEFLG_Init
);
184 /***********************************************************************/