home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 539a.lha / EdPlayer_v1.0 / cteled.c next >
Encoding:
C/C++ Source or Header  |  1991-08-09  |  3.2 KB  |  93 lines

  1. /* C version of TellEd, 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.   char myname[80];
  26.  
  27.   typedef struct EdMessage {     /* This is the EdMessage struct!!!! */
  28.     struct Message MainMess;
  29.     double pad1;
  30.     long   pad2;    /* Pads are so some fields coincide with ARexx, but */
  31.     long   result;  /* don't use this with anything except EdPlayer!    */
  32.     long   result2;
  33.     char   *EdCommand;
  34.   };
  35.  
  36.   struct MsgPort *myport, *mynewport;
  37.   struct Message *mymsg;
  38.   struct EdMessage sndmsg;
  39.   struct EdMessage *doofmsg;
  40.  
  41.   retval = 21;    /* Error if something goes wrong */
  42.  
  43.   if (argc != 2) {
  44.     printf("Usage: %s \"<Edplayer command>\"\n",argv[0]);
  45.   } else {
  46.     sndmsg.result = 0l;  /* Always init results to 0 */
  47.     sndmsg.result2 = 0l;
  48.  
  49.     (char *)sndmsg.EdCommand = (char *)argv[1];  /* load up command */
  50.     printf("Telling EdPlayer to %s.\n",argv[1]);
  51.  
  52.     myport = FindPort((char *)"EDPLAYER");
  53.          /* I should probably be using Forbid() right about now... */
  54.  
  55.     if (myport == NULL) {
  56.       printf("Could not find EdPlayer in system.  Please run it.\n");
  57.     } else {
  58.       mypri = 0;
  59.       mynewport = CreatePort(NULL,mypri);  /* Make a replyport */
  60.       sndmsg.MainMess.mn_Length = 44;
  61.       sndmsg.MainMess.mn_ReplyPort = (struct MsgPort *)mynewport;
  62.  
  63.       PutMsg(myport,(struct Message *)&sndmsg);  /* SEND THE MSG! */
  64.  
  65.       mymsg = WaitPort(mynewport);   /* Wait for it..... */
  66.       mymsg = GetMsg(mynewport);    /* Get the returned message */
  67.  
  68.       doofmsg = (struct EdMessage *)mymsg;
  69.       retval = doofmsg->result;
  70.       printf("Returned %d: ",retval);   /* Tell user the number */
  71.  
  72.       switch (retval) {       /* Tell user what the # means... */
  73.         case  0 : printf("All OK.\n"); break;
  74.         case  6 : printf("No program.\n"); break;
  75.         case  7 : printf("Illegal JUMP.\n"); break;
  76.         case  8 : printf("Music STOPped, can't continue.\n"); break;
  77.         case  9 : printf("Nothing to PLAY!\n"); break;
  78.         case 10 : printf("Syntax error.\n"); break;
  79.         case 11 : printf("Can't allocate serial port for MIDI.\n"); break;
  80.         case 12 : printf("File not found.\n"); break;
  81.         case 14 : printf("Disk error.\n"); break;
  82.         case 15 : printf("Out of CHIP memory.\n"); break;
  83.         case 16 : printf("Unknown module type, or corrupted module!\n"); break;
  84.         case 21 : printf("EdPlayer is exiting, command ignored.\n"); break;
  85.         default : printf("Unknown error!\n");
  86.       };
  87.  
  88.       DeletePort(mynewport);   /* Kill the replyport */
  89.     }
  90.   }
  91.   exit(retval);  /* Tell AmigaDOS all about it, too */
  92. }
  93.