home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 367.lha / netkeys_v2.0 / nkutil.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-02  |  2.5 KB  |  84 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* |_o_o|\\ Copyright (c) 1990 The Software Distillery.  All Rights Reserved.*/
  3. /* |. o.| || This program may not be distributed without the permission of   */
  4. /* | .  | || the authors.                                                    */
  5. /* | o  | ||                                                                 */
  6. /* |  . |// Written by Doug Walker                                           */
  7. /* ======          BBS:(919)-471-6436      VOICE:(919)-467-4764              */ 
  8. /*                 BIX: djwalker           USENET: ...!mcnc!rti!sas!walker   */
  9. /*                 405 B3 Gooseneck Dr, Cary, NC 27513, USA                  */
  10. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  11. #include <exec/types.h>
  12. #include <exec/nodes.h>
  13. #include <exec/lists.h>
  14. #include <exec/memory.h>
  15. #include <exec/ports.h>
  16. #include <exec/io.h>
  17. #include <proto/exec.h>
  18.  
  19. struct IOStdReq * CreateIOReq(struct MsgPort *, int);
  20. void DeleteIOReq(struct IOStdReq *);
  21.  
  22. struct MsgPort * CreatePort(name, pri)
  23. char *name;
  24. int pri;
  25. {
  26.    UBYTE sigbit;
  27.    register struct MsgPort *port;
  28.  
  29.    if ((sigbit = AllocSignal(-1)) == -1)
  30.       return((struct MsgPort *)0);
  31.  
  32.    if ((port = (struct MsgPort *)AllocMem(sizeof(struct MsgPort),
  33.                         MEMF_CLEAR|MEMF_PUBLIC)) == 0)
  34.       {
  35.       FreeSignal(sigbit);
  36.       return((struct MsgPort *) (0));
  37.       }
  38.    port->mp_Node.ln_Name = name;
  39.    port->mp_Node.ln_Pri = pri;
  40.    port->mp_Node.ln_Type = NT_MSGPORT;
  41.    port->mp_Flags = PA_SIGNAL;
  42.    port->mp_SigBit = sigbit;
  43.    port->mp_SigTask = (struct Task *)FindTask(0);
  44.    AddPort(port);
  45.    return(port);
  46. }
  47.  
  48. void DeletePort(port)
  49. struct MsgPort *port;
  50. {
  51. RemPort(port);
  52. FreeSignal(port->mp_SigBit);
  53. FreeMem((char *)port,sizeof(struct MsgPort));
  54. }
  55.  
  56. struct IOStdReq *
  57. CreateIOReq(port, size)
  58. struct MsgPort *port;
  59. int size;
  60. {
  61.    struct IOStdReq *ioReq;
  62.  
  63.    if ((ioReq = (struct IOStdReq *)
  64.                 AllocMem(size, MEMF_CLEAR | MEMF_PUBLIC)) != NULL)
  65.       {
  66.       ioReq->io_Message.mn_Node.ln_Type = NT_MESSAGE;
  67.       ioReq->io_Message.mn_Node.ln_Pri  = 0;
  68.       ioReq->io_Message.mn_Length       = size;
  69.       ioReq->io_Message.mn_ReplyPort    = port;
  70.       }
  71.    return(ioReq);
  72. }
  73.  
  74. void DeleteIOReq(ioReq)
  75. struct IOStdReq *ioReq;
  76. {
  77. ioReq->io_Message.mn_Node.ln_Type = 0xff;
  78. ioReq->io_Device = (struct Device *) -1;
  79. ioReq->io_Unit = (struct Unit *) -1;
  80.  
  81. FreeMem( (char *)ioReq, ioReq->io_Message.mn_Length);
  82. }
  83.  
  84.