#ifndef IPC_PORTS_H
#define IPC_PORTS_H

/*** include this BEFORE IPC.H (if required) ***/

/*******************************************************************
 *                                                                 *
 *                           IPCPorts.h                            *
 *                                                                 *
 *           Inter-Process-Communication Port Format               *
 *                                                                 *
 *              Release  1.0 -- 1988 April 30                      *
 *                                                                 *
 *              Copyright 1988 Peter Goodeve                       *
 *                                                                 *
 *  This source is freely distributable, and may be used freely    *
 *  in any program,  but the structures should not be modified     *
 *  without prior consultation with the author.  (This is just to  *
 *  prevent proliferation of incompatible variants.  Don't be      *
 *  inhibited from suggesting enhancements!)                       *
 *                                                                 *
 *******************************************************************/

#ifndef EXEC_TYPES_H
#include "exec/types.h"
#endif

#ifndef EXEC_PORTS_H
#include "exec/ports.h"
#endif

/*******************************************************************
 *                                                                 *
 *  IPC Ports are essentially standard Exec message Ports except   *
 *  for added fields to keep track of their usage.  Also they      *
 *  are kept on their own list.                                    *
 *                                                                 *
 *  Note that the port name has to be kept WITHIN the structure    *
 *  also, as the process that created it may go away.  The size    *
 *  field holds the size of the structure including the name, so   *
 *  it may be deleted safely when no longer needed.                *
 *                                                                 *
 *******************************************************************/

struct IPCPort {
    struct MsgPort  ipp_Port;
    ULONG           ipp_Id;         /* for future use */
    UWORD           ipp_UseCount,   /* number of connections to the port */
                    ipp_Flags,      /* internal information */
                    ipp_Size;       /* size of the WHOLE structure */
    char            ipp_Name[1];    /* where name is actually kept! */
    };


/* ipp_Flags: */

#define IPP_SERVED 0x8000
#define IPP_SHUT 0x4000

#define IPP_SERVER_FLAGS 0x00FF
#define IPP_NOTIFY 0x0001



/*******************************************************************
 *                                                                 *
 *  Only one IPCBasePort structure will exist in the system.       *
 *  It is the only IPC Port on the public Exec port list, and      *
 *  has the standard name "IPC_Base_Port".  (Note that the name    *
 *  string begins in the last location of the IPCPort structure;   *
 *  "moreName" is just to provide the necessary space, so the      *
 *  list header begins at a defined offset.)                       *
 *                                                                 *
 *******************************************************************/

struct IPCBasePort {
    struct IPCPort ipcb_Port;   /* used to place in public Port list */
                                /* also will be public port for a Broker */
    char        moreName[20];   /* enough space for name  */
    struct List ipcb_PortList;  /* List of current IPCPorts */
    };

/*******************************************************************/

#endif
