home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / cdrom / atapi_pnp300 / developer_kit / opendoor.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  2KB  |  58 lines

  1. /****************************************************************************
  2. *
  3. *
  4. *   $VER: OpenDoor.c  1.0 (22 Jan 1996) by M_Campinoti CD++
  5. *
  6. *   $HISTORY:
  7. *
  8. *   22 Jan 1996 : 001.000 : First and Last release of an example that show
  9. *                           how to open the drive door by means of CD_EJECT command.
  10. *                           Didactical use, so CLI & WB      :)
  11. *
  12. ****************************************************************************/
  13. #include <proto/exec.h>
  14. #include <exec/devices.h>
  15. #include <exec/io.h>
  16. #include <stdio.h>
  17.  
  18. #include "atapi_cd.h"
  19.  
  20. #define OPEN_DOOR  1
  21. #define CLOSE_DOOR 0
  22.  
  23. main (void)
  24. {
  25.     struct IOStdReq      *ioreq = NULL ;
  26.     struct MsgPort       *reply = NULL ;
  27.     
  28.     if( reply = CreateMsgPort() )
  29.     {
  30.       if( ioreq = (struct IOStdReq *)
  31.              CreateIORequest(reply ,sizeof(struct  IOStdReq)) )
  32.       {
  33.         if(!OpenDevice("cd.device",0,(struct IORequest*)ioreq,NULL) )
  34.         {
  35.  
  36.           ioreq->io_Command = CD_EJECT ;
  37.           ioreq->io_Length  = OPEN_DOOR ;  /*  <-- change here to close the drive door */
  38.           ioreq->io_Offset  = 0 ;
  39.  
  40.           DoIO((struct IORequest*)ioreq);
  41.           
  42.           if (!ioreq->io_Error)              /* Command succeeded        */
  43.           {
  44.  
  45.           }
  46.           else printf("I/O error !\n");      /* analyze ioreq->io_Error to know what kind ... */
  47.                                              /* ... see atapi_cd.h for #defines of it !       */
  48.           
  49.           CloseDevice((struct IORequest *)ioreq) ;
  50.         }
  51.         
  52.         DeleteIORequest(ioreq) ;
  53.       }
  54.  
  55.       DeleteMsgPort(reply);
  56.     }
  57. }
  58.