muimaster.library: Area class will not eat wheel movement messages
[AROS.git] / external / openurl / library / init.c
blob24f11f74b614c828f1be6106f39773acfc774883
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/
17 $Id$
19 ***************************************************************************/
21 #include "lib.h"
23 #include "debug.h"
25 #define __NOLIBBASE__
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;
42 #endif
44 #else
45 struct DosLibrary *DOSBase = NULL;
46 #if defined(__AROS__)
47 struct UtilityBase *UtilityBase = NULL;
48 #else
49 struct Library *UtilityBase = NULL;
50 struct Library *__UtilityBase = NULL; // required by clib2 & libnix
51 #endif
52 #if defined(__MORPHOS__)
53 struct Library *RexxSysBase = NULL;
54 #else
55 struct RxsLib *RexxSysBase = NULL;
56 #endif
57 struct Library *IFFParseBase = NULL;
58 #endif
60 /***********************************************************************/
62 ULONG
63 freeBase(struct LibraryHeader *lib)
65 ENTER();
67 D(DBF_STARTUP, "freeing all resources of openurl.library");
69 if(lib->prefs != NULL)
71 CALL_LFUNC(URL_FreePrefsA, lib->prefs, NULL);
72 lib->prefs = NULL;
75 if(RexxSysBase)
77 DROPINTERFACE(IRexxSys);
78 CloseLibrary((struct Library *)RexxSysBase);
79 RexxSysBase = NULL;
82 if(IFFParseBase)
84 DROPINTERFACE(IIFFParse);
85 CloseLibrary(IFFParseBase);
86 IFFParseBase = NULL;
89 // delete our private memory pool
90 if(lib->pool != NULL)
92 #if defined(__amigaos4__)
93 FreeSysObject(ASOT_MEMPOOL, lib->pool);
94 #else
95 DeletePool(lib->pool);
96 #endif
97 lib->pool = NULL;
100 if(UtilityBase)
102 DROPINTERFACE(IUtility);
103 CloseLibrary((struct Library *)UtilityBase);
104 UtilityBase = NULL;
107 if(DOSBase)
109 DROPINTERFACE(IDOS);
110 CloseLibrary((struct Library *)DOSBase);
111 DOSBase = NULL;
114 CLEAR_FLAG(lib->flags, BASEFLG_Init);
116 RETURN(TRUE);
117 return TRUE;
120 /***********************************************************************/
122 ULONG
123 initBase(struct LibraryHeader *lib)
125 ENTER();
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;
139 #endif
140 #endif
142 // setup the debugging stuff
143 #if defined(DEBUG)
144 SetupDebug();
145 #endif
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,
158 TAG_DONE);
159 #else
160 lib->pool = CreatePool(MEMF_CLEAR, 4096, 512);
161 #endif
162 if(lib->pool != NULL)
164 lib->prefs = loadPrefsNotFail();
166 if(lib->prefs != NULL)
168 SET_FLAG(lib->flags, BASEFLG_Init);
170 RETURN(TRUE);
171 return TRUE;
178 freeBase(lib);
180 RETURN(FALSE);
181 return FALSE;
184 /***********************************************************************/