home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Workbench / Misc / NULLHNDL.LHA / Null / src / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-04  |  2.1 KB  |  88 lines

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