
/*
 *  DListen.c
 */

#include "lib.h"

PORT *
DListen(portnum)
uword portnum;
{
    PORT *port = NULL;
    char *ptr;

    ptr = AllocMem(NAMELEN, MEMF_PUBLIC);   /*  memory the the name     */
    if(ptr == NULL) return (PORT *)NULL;
    sprintf(ptr, NAMEPAT, portnum);
    Forbid();                               /*  task-atomic operation   */
    if (FindPort(ptr) || !(port = CreatePort(ptr,0)))
	FreeMem(ptr, NAMELEN);
    Permit();
    return(port);
}

