home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 569a.lha / EdPlayer_v1.1 / cteled.c < prev    next >
C/C++ Source or Header  |  1991-10-26  |  3KB  |  98 lines

  1. /* C version of TellEd, version 1.1, by Ed Mackey */
  2.  
  3. /* This is a program demonstrating how to call EdPlayer withOUT the
  4.    use of ARexx.  Do NOT use this method on ANY other program besides
  5.    EdPlayer.  For information on creating true AREXX messages, please
  6.    see your ARexx manual.                                              */
  7.  
  8. /* This is for the Aztec Manx C compiler */
  9. /* and is dedicated to all those MegaBall fans
  10.    who gave me the money to buy it...    */
  11.  
  12. /* I'm sorry if my C is a bit messy, but I'm new at this. */
  13.  
  14. #include <functions.h>
  15. #include <exec/types.h>
  16. #include <exec/ports.h>
  17.  
  18. main(argc,argv)
  19. int argc;      
  20. UBYTE *argv[];
  21. {
  22.   long mypri,lp,retval;    /* Init some variables */
  23.   char *daa;
  24.   char *dbb;
  25.  
  26.   typedef struct EdMessage {     /* This is the EdMessage struct!!!! */
  27.     struct Message MainMess;
  28.     double pad1;
  29.     long   pad2;    /* Pads are so some fields coincide with ARexx, but */
  30.     long   result;  /* don't use this with anything except EdPlayer!    */
  31.     long   result2;
  32.     char   *EdCommand;
  33.   };
  34.  
  35.   struct MsgPort *myport, *mynewport;
  36.   struct Message *mymsg;
  37.   struct EdMessage sndmsg, *EdPmsg;
  38.  
  39.   retval = 21;    /* Error if something goes wrong */
  40.  
  41.   if (argc != 2) {
  42.     printf("Usage: %s \"<Edplayer command>\"\n",argv[0]);
  43.   } else {
  44.     sndmsg.result = 0l;  /* Always init results to 0 */
  45.     sndmsg.result2 = 0l;
  46.  
  47.     (char *)sndmsg.EdCommand = (char *)argv[1];  /* load up command */
  48.     printf("Telling EdPlayer to %s.\n",argv[1]);
  49.  
  50.     mypri = 0;
  51.     mynewport = CreatePort(NULL,mypri);  /* Make a replyport */
  52.     sndmsg.MainMess.mn_Length = 44;
  53.     sndmsg.MainMess.mn_ReplyPort = (struct MsgPort *)mynewport;
  54.  
  55.     Forbid();  /* MULTITASKING = OFF, so EdP doesn't trick us */
  56.     myport = FindPort((char *)"EDPLAYER");
  57.  
  58.     if (myport == NULL) {
  59.  
  60.       Permit(); /* MULTITASKING = ON */
  61.       printf("Could not find EdPlayer in system.  Please run it.\n");
  62.  
  63.     } else {
  64.  
  65.       PutMsg(myport,(struct Message *)&sndmsg);  /* SEND THE MSG! */
  66.       Permit(); /* MULTITASKING = ON */
  67.  
  68.       mymsg = WaitPort(mynewport);   /* Wait for it..... */
  69.       mymsg = GetMsg(mynewport);    /* Get the returned message */
  70.  
  71.       EdPmsg = (struct EdMessage *)mymsg;
  72.       retval = EdPmsg->result;
  73.       printf("Returned %d: ",retval);   /* Tell user the number */
  74.  
  75.       switch (retval) {       /* Tell user what the # means... */
  76.         case  0 : printf("All OK.\n"); break;
  77.         case  5 : printf("Incorrect password for PP-encrypted file.\n"); break;
  78.         case  6 : printf("No program.\n"); break;
  79.         case  7 : printf("Illegal JUMP.\n"); break;
  80.         case  8 : printf("Music STOPped, can't continue.\n"); break;
  81.         case  9 : printf("Nothing to PLAY!\n"); break;
  82.         case 10 : printf("Syntax error.\n"); break;
  83.         case 11 : printf("Can't allocate serial port for MIDI.\n"); break;
  84.         case 12 : printf("File not found.\n"); break;
  85.         case 13 : printf("Can't find LIBS:powerpacker.library.\n"); break;
  86.         case 14 : printf("Disk error.\n"); break;
  87.         case 15 : printf("Out of CHIP memory.\n"); break;
  88.         case 16 : printf("Unknown module type, or corrupted module!\n"); break;
  89.         case 21 : printf("EdPlayer is exiting, command ignored.\n"); break;
  90.         default : printf("Unknown error!\n");
  91.       };
  92.  
  93.       DeletePort(mynewport);   /* Kill the replyport */
  94.     }
  95.   }
  96.   exit(retval);  /* Tell AmigaDOS all about it, too */
  97. }
  98.