Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / AHI / Drivers / Filesave / filesave-init.c
blob4bc923b2b6c6802e6202aa4d3fa6d7a5cc304b36
2 #include <config.h>
4 #include <dos/dos.h>
5 #include <graphics/gfxbase.h>
6 #include <libraries/asl.h>
7 #include <proto/exec.h>
8 #include <proto/datatypes.h>
10 #include "library.h"
12 #include "DriverData.h"
14 #ifdef __AROS__
15 #include <proto/stdc.h>
17 struct StdCBase *StdCBase = NULL;
18 #endif
21 /******************************************************************************
22 ** Custom driver init *********************************************************
23 ******************************************************************************/
25 BOOL
26 DriverInit( struct DriverBase* AHIsubBase )
28 struct FilesaveBase* FilesaveBase = (struct FilesaveBase*) AHIsubBase;
30 FilesaveBase->dosbase = (struct DosLibrary *)OpenLibrary( DOSNAME, 37 );
31 FilesaveBase->gfxbase = (APTR)OpenLibrary( GRAPHICSNAME, 37 );
32 FilesaveBase->aslbase = OpenLibrary( AslName, 37);
33 FilesaveBase->dtsbase = OpenLibrary( "datatypes.library" ,39 );
35 if( DOSBase == NULL )
37 Req( "Unable to open '" DOSNAME "' version 37.\n" );
38 return FALSE;
41 if( GfxBase == NULL )
43 Req( "Unable to open '" GRAPHICSNAME "' version 37.\n" );
44 return FALSE;
47 // Don't fail if these ones don't open!
49 if( AslBase == NULL )
51 Req( "Unable to open '" AslName "' version 37.\n" );
54 #if 0
55 if( DataTypesBase == NULL )
57 Req( "Unable to open 'datatypes.library' version 39.\n" );
59 #endif
61 #ifdef __AMIGAOS4__
62 if ((IDOS = (struct DOSIFace *) GetInterface((struct Library *) DOSBase, "main", 1, NULL)) == NULL)
64 Req("Couldn't open IDOS interface!\n");
65 return FALSE;
68 if (AslBase != NULL) {
69 if ((IAsl = (struct AslIFace *) GetInterface((struct Library *) AslBase, "main", 1, NULL)) == NULL)
71 Req("Couldn't open IAsl interface!\n");
72 return FALSE;
76 if (DataTypesBase != NULL) {
77 if ((IDataTypes = (struct DataTypesIFace *) GetInterface((struct Library *) DataTypesBase, "main", 1, NULL)) == NULL)
79 Req("Couldn't open IDataTypes interface!\n");
80 return FALSE;
83 #endif
85 #ifdef __AROS__
86 StdCBase = (struct StdCBase *) OpenLibrary( "stdc.library", 0 );
88 if( StdCBase == NULL )
90 Req( "Unable to open 'stdc.library'.\n" );
91 return FALSE;
93 #endif
95 return TRUE;
99 /******************************************************************************
100 ** Custom driver clean-up *****************************************************
101 ******************************************************************************/
103 VOID
104 DriverCleanup( struct DriverBase* AHIsubBase )
106 struct FilesaveBase* FilesaveBase = (struct FilesaveBase*) AHIsubBase;
108 #ifdef __AROS__
109 CloseLibrary( (struct Library*) StdCBase );
110 #endif
112 #ifdef __AMIGAOS4__
113 DropInterface( (struct Interface *) IDOS);
114 DropInterface( (struct Interface *) IAsl);
115 DropInterface( (struct Interface *) IDataTypes);
116 #endif
118 CloseLibrary( (APTR)FilesaveBase->dosbase );
119 CloseLibrary( (APTR)FilesaveBase->gfxbase );
120 CloseLibrary( (APTR)FilesaveBase->aslbase );
121 CloseLibrary( (APTR)FilesaveBase->dtsbase );