home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / CLISP / CLISPSRC.TAR / clisp-1995-01-01 / amiga / jchlib / misc / CreatePort.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-30  |  1.2 KB  |  55 lines

  1. /* GCC Library
  2.  * J÷rg H÷hle, 30-Nov-92
  3.  */
  4.  
  5. #include <exec/types.h>
  6. #include <exec/ports.h>
  7. #include <exec/memory.h>
  8. #ifdef __GNUC__
  9.   #include <inline/exec.h>
  10. #else
  11.   #include <clib/exec.h>
  12. #endif
  13.  
  14. void DeletePort(struct MsgPort * port);
  15. void DeletePort(port)
  16. struct MsgPort* port;
  17. {
  18.   if (port != NULL)
  19.     {
  20.       if (port->mp_Node.ln_Name)
  21.     { RemPort(port); }
  22.       if (port->mp_Flags == PA_SIGNAL)
  23.         { FreeSignal(port->mp_SigBit); }
  24.       FreeMem(port,sizeof(struct MsgPort));
  25.     }
  26. }
  27.  
  28. struct MsgPort * CreatePort(UBYTE * name, long priority);
  29. struct MsgPort * CreatePort(name, pri)
  30. UBYTE* name;
  31. long pri;
  32. {
  33.   register struct MsgPort* port;
  34.   if ((port = (struct MsgPort *)AllocMem(sizeof(struct MsgPort),MEMF_PUBLIC | MEMF_CLEAR)) != NULL)
  35.     {
  36.       if ((BYTE)(port->mp_SigBit = AllocSignal(-1L)) >= 0)
  37.         {
  38.           port->mp_Node.ln_Name = name;
  39.           port->mp_Node.ln_Type = NT_MSGPORT;
  40.           port->mp_Node.ln_Pri = pri;
  41.           port->mp_SigTask = FindTask(NULL);
  42.           port->mp_Flags = PA_SIGNAL;
  43.           NewList(&port->mp_MsgList);
  44.           if (name != NULL)
  45.         { AddPort(port); }
  46.         }
  47.       else
  48.         {
  49.           FreeMem(port,sizeof(struct MsgPort));
  50.           port = NULL;
  51.         }
  52.     }
  53.   return port;
  54. }
  55.