home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d558 / btntape.lha / BTNtape / src / pktstuff.c < prev    next >
C/C++ Source or Header  |  1991-10-28  |  2KB  |  73 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. #include "tape.h"
  15.  
  16. #if defined AZTEC_C
  17.   #include <functions.h>
  18. #elif defined LATTICE
  19.   #include <proto/exec.h>
  20. #endif
  21.  
  22.  
  23. /* returnpkt() - packet support routine
  24.  * here is the guy who sends the packet back to the sender...
  25.  * (I modeled this just like the BCPL routine [so its a little redundant] )
  26.  */
  27.  
  28. void returnpkt(
  29.    struct DosPacket *packet,
  30.    ULONG  res1,
  31.    ULONG  res2)
  32. {
  33.  struct Message *mess;
  34.  struct MsgPort *replyport;
  35.  struct Process *myproc;
  36.  
  37.  packet->dp_Res1          = res1;
  38.  packet->dp_Res2          = res2;
  39.  replyport                = packet->dp_Port;
  40.  mess                     = packet->dp_Link;
  41.  myproc                   = (struct Process *) FindTask(0L);
  42.  packet->dp_Port          = &myproc->pr_MsgPort;
  43.  mess->mn_Node.ln_Name    = (char *) packet;
  44.  mess->mn_Node.ln_Succ    = NULL;
  45.  mess->mn_Node.ln_Pred    = NULL;
  46.  
  47.  PutMsg(replyport,mess);
  48. }
  49.  
  50.  
  51. /*
  52.  * taskwait() ... Waits for a message to arrive at your port and
  53.  *   extracts the packet address which is returned to you.
  54.  */
  55.  
  56. struct DosPacket *taskwait(void)
  57. {
  58.  struct Process *myproc;
  59.  struct MsgPort *myport;
  60.  struct Message *mymess;
  61.  
  62.  myproc = (struct Process *) FindTask(0L);
  63.  myport = &myproc->pr_MsgPort;
  64.  
  65.  WaitPort(myport); /* wait for packet */
  66.  mymess = (struct Message *) GetMsg(myport);
  67.  
  68. /* give them the pointer to the packet */
  69. return((struct DosPacket *) mymess->mn_Node.ln_Name);
  70. }
  71.  
  72. /* end of misc.c */
  73.