Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / libs / openurl / library / init.c
blob8f92cb963196fccc51eae701d9d1937e9006a4e3
1 /*
2 ** openurl.library - universal URL display and browser
3 ** launcher library
4 **
5 ** Written by Troels Walsted Hansen <troels@thule.no>
6 ** Placed in the public domain.
7 **
8 ** Developed by:
9 ** - Alfonso Ranieri <alforan@tin.it>
10 ** - Stefan Kost <ensonic@sonicpulse.de>
12 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
16 #include "lib.h"
17 #include <dos/dostags.h>
19 /***********************************************************************/
21 void
22 freeBase(void)
24 if (lib_prefs)
26 URL_FreePrefsA(lib_prefs,NULL);
27 lib_prefs = NULL;
30 #if defined(__amigaos4__)
31 if( IRexxSys )
33 DropInterface( (struct Interface*)IRexxSys );
34 IRexxSys = NULL;
37 if (IIFFParse)
39 DropInterface( (struct Interface*)IIFFParse );
40 IIFFParse = NULL;
43 if( IUtility )
45 DropInterface( (struct Interface*)IUtility );
46 IUtility = NULL;
48 #endif
50 if (RexxSysBase)
52 CloseLibrary((struct Library *)RexxSysBase);
53 RexxSysBase = NULL;
56 if (IFFParseBase)
58 CloseLibrary(IFFParseBase);
59 IFFParseBase = NULL;
62 if (UtilityBase)
64 CloseLibrary((struct Library*)UtilityBase);
65 UtilityBase = NULL;
68 #if defined(__amigaos4__)
69 if( IDOS )
71 DropInterface( (struct Interface*)IDOS );
72 IDOS = NULL;
74 #endif
76 if (DOSBase)
78 CloseLibrary((struct Library *)DOSBase);
79 DOSBase = NULL;
82 if (lib_pool)
84 DeletePool(lib_pool);
85 lib_pool = NULL;
88 lib_flags &= ~BASEFLG_Init;
91 /***********************************************************************/
93 ULONG
94 initBase(void)
96 if ((lib_pool = CreatePool(MEMF_PUBLIC|MEMF_CLEAR,16384,8192)) &&
97 (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",36)) &&
98 (UtilityBase = (struct UtilityBase*)OpenLibrary("utility.library",36)) &&
99 (IFFParseBase = OpenLibrary("iffparse.library",36)) &&
100 (RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library",33)) &&
101 #if defined(__amigaos4__)
102 (IDOS = (struct DOSIFace *) GetInterface( (struct Library*)DOSBase, "main", 1L, NULL )) &&
103 (IUtility = (struct UtilityIFace *) GetInterface( UtilityBase, "main", 1L, NULL)) &&
104 (IIFFParse = (struct IFFParseIFace *) GetInterface( IFFParseBase, "main", 1L, NULL)) &&
105 (IRexxSys = (struct RexxSysIFace *) GetInterface( (struct Library*)RexxSysBase, "main", 1L, NULL)) &&
106 #endif
107 (lib_prefs = loadPrefsNotFail()))
109 lib_flags |= BASEFLG_Init;
111 return TRUE;
114 freeBase();
116 return FALSE;
119 /***********************************************************************/