/*
 *  MBPORT.H - 6/21/87 - Definitions for MailBox ports.
 */

/*
 *  Device connected to the port. (port->dev)
 */

#define p_serial    1	  /* Device is "raw" serial, another computer */
#define p_memory    2	  /* Device is the in memory "pipe"           */
#define p_tnc	    3	  /* Device is a tnc with TAPR commands       */
#define p_hayes     4	  /* Device is a Hayes compatible modem       */
#define p_console   5	  /* Device is the local machine console      */

/*
 *  Permissions associated with the port. (port->priv)
 */

#define p_bbs	  0x0001  /* Only BBS may connect to this port	      */
#define p_ilcal   0x0002  /* Illegal call kicked off		      */
#define p_ildig   0x0004  /* Illegal digi call no no   (not imp)      */
#define p_mon	  0x0008  /* Monitoring ok			      */
#define p_gate	  0x0010  /* Gateway out from this port ok	      */
#define p_sysop   0x0020  /* Remote sysop allowed (IF user can)       */
#define p_upload  0x0040  /* Upload allowed from this port	      */
#define p_dnload  0x0080  /* Download allowed from this port	      */

/*
** Permission associated with the port. (port->priv) AY-881127
*/

#define p_mailfor 0x0100  /* Annouce allowed from this port Mail for  */
#define p_mbready 0x0200  /* Annouce allowed form this port Ready to Use */

/*
 *  Port Mode values. (port->mode)
 */

#define sysop	0x0001	 /* User is sysop			      */
#define local	0x0002	 /* User is local machine console	      */
#define remote	0x0004	 /* User is not sysop			      */
#define idle	0x0010	 /* The port is idle			      */
#define discon	0x0020	 /* User has disconnected, but not logged out */
#define timeout 0x0040	 /* User timed out, but not yet logged out    */
#define exclude 0x0080	 /* User excluded, but not yet logged out     */
#define logout	0x0100	 /* User did "B", but not yet logged out      */
#define forced	0x0200	 /* User forced off, but not yet logged out   */

#define all  (local | remote | sysop)
#define ops  (local | sysop)
#define gone (discon | timeout | forced)

/*
 *  Port flags. (port->flags)
 */

#define p_fwdok  0x0001  /* "ok to forward" flag                   */
#define p_dofwd  0x0002  /* "forward for this port now"            */
#define p_clrsys 0x0004  /* Must clear sysop mode on exit if discon*/
#define p_req	 0x0008  /* Had a connect request		   */
#define p_give	 0x0010  /* Ok to give time to DD on I/O	   */
#define p_echo	 0x0020  /* Need to echo input to user		   */
#define p_lf	 0x0040  /* This port needs LF after CR 	   */
#define p_opreq  0x0080  /* Local console wants to int user	   */
#define p_dotmr  0x0100  /* Set the input timeout in getdat	   */

typedef struct ports_s
{
  struct ports_s *next;  /* Next port				   */
  struct ports_s *lport; /* Port this one linked to or NULL	   */
  char	id;		 /* Identifies port to user		   */
  int	idn;		 /* Identifies port to op sys		   */
  byte	dev;		 /* Device connected to the port	   */
  word	flags;		 /* Flags				   */
  word	priv;		 /* What can you do from this port	   */
  word	mode;		 /* Present state of the port		   */
  byte	ndigi;		 /* # digi allowed on connect		   */
  short ctime;		 /* "Waiting for input" timeout            */
  short dtime;		 /* "Waiting for disconnect" timeout       */
  byte	errmax; 	 /* Allowed command errors before kick off */
  byte	errors; 	 /* Number of errors user has made	   */
  char	*name;		 /* Name of the port			   */
  short mtime;		 /* Allowed monitor time		   */
  word	mcount; 	 /* Lines allowed in monitor		   */
  byte	maxhrd; 	 /* Max on heard list			   */
  byte	nhrd;		 /* # presently on heard list		   */
  char	*heard; 	 /* Pointer to calls heard list 	   */
  byte	fwdmin; 	 /* Minute of the hour to forward	   */
  char	rcall[ln_call];
/* Task stuff. Doesn't really belong here, but saves an indirect. */
  long	itime;		 /* Time when wait for input times out	   */
  long	expire; 	 /* Time at which we time this out	   */
  byte	flds;		 /* # fields in current command 	   */
  char	*fld[maxflds];	 /* Pointers to the start of fields in cmd */
  char	*cmd;		 /* The command field text		   */
  char	*line;		 /* Text line last collected		   */
  char	opt1;		 /* Major command id			   */
  char	opt2;		 /* Minor command id			   */
  word	cmdcnt; 	 /* # commands done since login 	   */
  FILE	*fl;		 /* For any file required		   */
  char	*msg;		 /* Error msg before prompt, or NULL	   */
  struct user_s *user;	 /* Pointer to user record		   */
  struct msg_hdr_s *mmhs;/* Pointer to message header record	   */
  char *mready;   /* Buffer for BBS Ready to Use...         */
} PORTS;

/*
 *  porthd is list header.
 *  port   is the currently active port.
 *  cport  is the machine console.
 */

extern PORTS *porthd, *port, *cport;
extern PORTS *findport();

