home *** CD-ROM | disk | FTP | other *** search
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/interrupts.h>
- #include <devices/input.h>
-
- #include <proto/exec.h>
-
- extern void checkDisk( void );
- extern void patchDOSlibrary( void );
- extern BOOL resetDOSlibrary( void );
-
- struct Interrupt *diskhandler;
- struct IOStdReq *inputIO;
- struct MsgPort *inputMPort;
- BYTE diskBit;
- ULONG diskSig;
- struct Task *thisTask;
-
- /*
- * This handler signals us the user has inserted or removed a disk,
- * or some file has been deleted or written. This piece of code sets
- * up the handler; the main code for the handler is in handler.s, in
- * which there is also the code for patching OS functions Delete and
- * Close.
- */
-
- BOOL setDiskHandler( void )
- {
- if ( (diskBit = AllocSignal( -1 )) != -1 )
- {
- diskSig = 1L<<diskBit;
- thisTask = FindTask( NULL );
-
- if ( inputMPort = CreateMsgPort() )
- {
- if ( inputIO = CreateIORequest( inputMPort, sizeof(struct IOStdReq) ) )
- {
- if ( !( OpenDevice( "input.device", 0, (struct IORequest *)inputIO, 0 ) ) )
- {
- if ( diskhandler = AllocVec( sizeof(struct Interrupt), MEMF_ANY | MEMF_CLEAR ) )
- {
- diskhandler->is_Code = checkDisk;
- diskhandler->is_Data = NULL;
- diskhandler->is_Node.ln_Pri = 100;
- diskhandler->is_Node.ln_Name = "Split-DiskHandler";
-
- inputIO->io_Data = (APTR)diskhandler;
- inputIO->io_Command = IND_ADDHANDLER;
- DoIO( (struct IORequest *)inputIO );
-
- return TRUE;
- }
- }
- DeleteIORequest( inputIO );
- }
- DeleteMsgPort( inputMPort );
- }
- FreeSignal( diskBit );
- }
- return FALSE;
- }
-
-
- void removeDiskHandler( void )
- {
- inputIO->io_Data = (APTR)diskhandler;
- inputIO->io_Command = IND_REMHANDLER;
- DoIO( (struct IORequest *)inputIO );
- DeleteIORequest( inputIO );
- DeleteMsgPort( inputMPort );
- FreeSignal( diskBit );
- }
-