home *** CD-ROM | disk | FTP | other *** search
/ The AGA Experience 2 / agavol2.iso / software / utilities / disk_tools / cd32tools / cdmotor.c < prev    next >
C/C++ Source or Header  |  1995-07-12  |  2KB  |  81 lines

  1. /*
  2.     CD Stopper Daemon for the CD³² Multimedia Computer
  3.  
  4.     this sends a MOTOR_OFF command each <number of ticks> time interval
  5.     to the internal cd.device unit 0, the CDROM drive of the cd32.
  6.  
  7.     installation:
  8.     
  9.     run <>NIL: cdmotor 500 ; this is the number of ``ticks'' to wait
  10.  
  11.     disinstallation, abortiation:
  12.     
  13.     break C $processnumber
  14.  
  15.     written by Daniel Balster, dbalster@uni-paderborn.de
  16. */
  17.  
  18. #include <exec/exec.h>
  19. #include <dos/dos.h>
  20. #include <devices/cd.h>
  21. #include <proto/exec.h>
  22. #include <proto/dos.h>
  23.  
  24. #define DEFAULT_DELAY    500    /* ticks */
  25.  
  26. struct {
  27.     ULONG    interval;
  28.     BOOL    quiet;
  29.     ULONG    pads[2];
  30. } args = {0};
  31.  
  32. int main (void)
  33. {
  34.     struct RDArgs *rdargs;
  35.     struct MsgPort *mp;
  36.     struct IOStdReq *ior;
  37.     
  38.     BOOL quit = FALSE;
  39.  
  40.     if (rdargs=ReadArgs("DELAY/N,QUIET/S",(LONG*)&(args),NULL))
  41.     {
  42.     //    if(!args.quiet) PutStr("*** CD Stopper *** for the Amiga CD³²® Computer\nwritten by Daniel Balster\n");
  43.  
  44.         if(mp=CreateMsgPort())
  45.         {
  46.             if(ior=(struct IOStdReq*)CreateIORequest(mp,sizeof(struct IOStdReq)))
  47.             {
  48.                 if(!OpenDevice("cd.device",0,ior,0))
  49.                 {
  50.                     while (!quit)
  51.                     {
  52.                         if(!args.quiet) PutStr("stopping motor!\n");
  53.                         ior->io_Command    = CD_MOTOR;
  54.                         ior->io_Length    = 0;        /* motor off */
  55.                         DoIO(ior);
  56.             
  57.                         Delay (*(ULONG*)args.interval);
  58.             
  59.                         if(SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) quit=TRUE;
  60.                     
  61.                     }
  62.                 //    PutStr("*** BREAK!\n");
  63.                 
  64.                     CloseDevice((struct IORequest*)ior);
  65.                 }
  66.             //    else PutStr("cannot access cd.device?\n");
  67.                 
  68.                 DeleteIORequest((struct IORequest*)ior);
  69.             }
  70.         //    else PutStr("cannot create ioreq?\n");
  71.  
  72.             DeleteMsgPort(mp);
  73.         }
  74.     //    else PutStr("cannot create msgport?\n");
  75.  
  76.         FreeArgs(rdargs);
  77.     }
  78. //    else PrintFault(IoErr(),0);
  79.  
  80.     return RETURN_OK;
  81. }