home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma28.dms / ma28.adf / AmiCDROM / cdromemu / main.c < prev    next >
C/C++ Source or Header  |  1994-09-08  |  873b  |  45 lines

  1. /* main.c: */
  2.  
  3. #include <proto/utility.h>
  4. #include <proto/exec.h>
  5.  
  6. #include <exec/ports.h>
  7.  
  8. #include <stdlib.h>
  9. #include <stdio.h>
  10.  
  11. #include "cdromemu.h"
  12.  
  13. static char* version = "$VER: " VERSION "\n";
  14.  
  15. void main (int argc, char *argv[])
  16. {
  17.   int remove = 0;
  18.   int insert = 0;
  19.   struct MsgPort *port;
  20.   struct IORequest ior;
  21.  
  22.   if (argc != 2 ||
  23.       (!(remove = !Stricmp ("remove", argv[1])) &&
  24.        !(insert = !Stricmp ("insert", argv[1])))) {
  25.     fprintf (stderr, "usage: cdromemu (insert|remove)\n");
  26.     exit (1);
  27.   }
  28.  
  29.   ior.io_Command = insert ? CMD_XXX_INSERT : CMD_XXX_REMOVE;
  30.   ior.io_Message.mn_Length = sizeof (ior);
  31.  
  32.   Forbid ();
  33.   port = FindPort ((STRPTR) "CDROMEMU");
  34.   if (!port) {
  35.     Permit ();
  36.     fprintf (stderr, "cdromemu.device is not running\n");
  37.     exit (1);
  38.   } else {
  39.     PutMsg (port, (struct Message*) &ior);
  40.     Permit ();
  41.   }
  42.  
  43.   exit (0);
  44. }
  45.