revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / AHI / Examples / Low-level / lib / AHI_lib.c
blob43b620d419a42d371f63ef9e7dbc24755195d1b2
1 /*
2 These SAS/C autoopen/autoclose functions was supplied by Mattias
3 Karlsson. Thanks!
4 */
6 #define USE_AHI_VERSION 4
8 #include <devices/ahi.h>
9 #include <proto/ahi.h>
10 #include <proto/exec.h>
11 #include <dos.h>
13 extern void __regargs __autoopenfail(char *);
15 extern long __oslibversion;
17 struct Library *AHIBase;
18 struct MsgPort *AHImp=NULL;
19 struct AHIRequest *AHIio=NULL;
20 BYTE AHIDevice=-1;
22 // Autoopen rutin för ahi.
23 int __stdargs _STI_openahi(void)
26 if(AHImp=CreateMsgPort())
28 if(AHIio=(struct AHIRequest *)CreateIORequest(AHImp,sizeof(struct AHIRequest)))
30 AHIio->ahir_Version=USE_AHI_VERSION;
32 if(!(AHIDevice=OpenDevice(AHINAME,AHI_NO_UNIT,(struct IORequest *)AHIio,NULL)))
34 AHIBase=(struct Library *)AHIio->ahir_Std.io_Device;
35 return 0;
40 // Så vi får rätt version angivelse
41 __oslibversion=USE_AHI_VERSION;
42 __autoopenfail("ahi.device");
43 return 1;
46 // autoclose rutin finns det oxo :)
47 void __stdargs _STD_closeahi(void)
50 if(AHIDevice==0)
52 CloseDevice((struct IORequest *)AHIio);
55 if(AHIio)
57 DeleteIORequest((struct IORequest *)AHIio);
58 AHIio=NULL;
61 if(AHImp)
63 DeleteMsgPort(AHImp);
64 AHImp=NULL;