home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog_c / handler.lzh / HANDLER / MISC.C < prev    next >
C/C++ Source or Header  |  1991-11-01  |  2KB  |  72 lines

  1. /* misc.c  - support routines - Phillip Lindsay (C) Commodore 1986  
  2.  *  You may freely distribute this source and use it for Amiga Development -
  3.  *  as long as the Copyright notice is left intact.
  4.  *
  5.  * 30-SEP-86
  6.  */
  7.  
  8. #include <exec/types.h>
  9. #include <exec/nodes.h>
  10. #include <exec/lists.h>
  11. #include <exec/ports.h>
  12. #include <libraries/dos.h>
  13. #include <libraries/dosextens.h>
  14.  
  15. #ifdef MANX
  16. #include <functions.h>
  17. #endif
  18.  
  19. /* returnpkt() - packet support routine 
  20.  * here is the guy who sends the packet back to the sender...
  21.  * 
  22.  * (I modeled this just like the BCPL routine [so its a little redundant] )
  23.  */
  24.  
  25. void returnpkt(packet,res1,res2)
  26.  
  27. struct DosPacket *packet;
  28. ULONG  res1,res2;
  29.  
  30. {
  31.  struct Message *mess;
  32.  struct MsgPort *replyport;
  33.  struct Process *myproc;
  34.  
  35.  packet->dp_Res1          = res1;
  36.  packet->dp_Res2          = res2; 
  37.  replyport                = packet->dp_Port;
  38.  mess                     = packet->dp_Link;
  39.  myproc                   = (struct Process *) FindTask(0L);
  40.  packet->dp_Port          = &myproc->pr_MsgPort;
  41.  mess->mn_Node.ln_Name    = (char *) packet;
  42.  mess->mn_Node.ln_Succ    = NULL;
  43.  mess->mn_Node.ln_Pred    = NULL;
  44.  
  45.  PutMsg(replyport,mess); 
  46.  
  47. }
  48.  
  49.  
  50. /*
  51.  * taskwait() ... Waits for a message to arrive at your port and 
  52.  *   extracts the packet address which is returned to you.
  53.  */
  54.  
  55. struct DosPacket *taskwait()
  56. {
  57.  struct Process *myproc;
  58.  struct MsgPort *myport;
  59.  struct Message *mymess;
  60.  
  61.  myproc = (struct Process *) FindTask(0L);
  62.  myport = &myproc->pr_MsgPort;
  63.  
  64.  WaitPort(myport); /* wait for packet */
  65.  mymess = (struct Message *) GetMsg(myport);
  66.  
  67. /* give them the pointer to the packet */
  68. return((struct DosPacket *) mymess->mn_Node.ln_Name);
  69.  
  70. /* end of misc.c */
  71.