#ident "$Id: xxx.h,v 1.1 1995/03/16 17:19:43 garyp Exp $"
/*****************************************************************************
 * Copyright (c) 1988-95 Digi International Inc., All Rights Reserved
 * 
 * This  software  contains  proprietary  and  confidential   information   of
 * Digi International  Inc.   By  accepting  transfer  of this copy, Recipient
 * agrees to retain this software in  confidence,  to  prevent  disclosure  to
 * others,  and  to make no  use of this software other than that for which it
 * was delivered.  This is an unpublished copyright work  Digi   International
 * Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is
 * strictly prohibited.
 * 
 * Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc.
 * Confidential  when   combined   with   the   aggregated  modules  for  this
 * product) OBJECT CODE ONLY SOURCE MATERIALS
 * 
 * (C) COPYRIGHT Digi International Inc. 1995
 * 
 * All Rights Reserved
 * 
 * US   Government   Users   Restricted   Rights   -   Use,   duplication   or
 * disclosure  restricted by GSA ADP Schedule Contract with Digi International
 * Inc.
 * 
 *****************************************************************************/



/************************************************************************
 * Copyright (c) 1993-1994 Digi International Inc., All Rights Reserved.
 * This software contains proprietary and confidential information of Digi
 * International Inc.  By accepting transfer of this copy, Recipient agrees
 * to retain this software in confidence, to prevent disclosure to others,
 * and to make no use of this software other than that for which it was
 * delivered.  This is an unpublished copyrighted work of Digi International
 * Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 * prohibited.
 */


/******************************************************************
 *
 *  SpiderX25 - Kernel File
 *
 *  Copyright 1991 Spider Systems Limited
 *
 *  XXX.H
 *
 *    This module contains all the definitions for the XXX module
 *
 ******************************************************************/

/*
 *	 /projects/common/PBRAIN/SCCS/pbrainF/dev/sys/xxx/0/s.xxx.h
 *	@(#)xxx.h	1.31
 *
 *	Last delta created	18:15:36 1/6/93
 *	This file extracted	19:55:43 1/24/93
 *
 */

#define MAX_X3_PARAM 23          /* Maximum number of X3 params + 1  */
#define SET_X3_84    22          /* Using 1984 flavour of XXX */
#define SET_X3_80    18          /* Using 1980 flavour of XXX */

#define maxcmd   256
#define maxiline 256

#define	DATATIMER	0
#define	NTIMERS		1
#define	idle_timer	tmtab[DATATIMER]

/* Call Control Block */

typedef struct ccb {		    /* Call control block		    */
    queue_t *q_ptr;		    /* Read queue for the module	    */
    unsigned int  status;	    /* Call status bits			    */
    unsigned char PADmode;	    /* Denotes Terminal or Host PAD	    */
    unsigned char user_mode;	    /* For processing user characters	    */
    unsigned char opmode;	    /* Current mode of operation	    */
    unsigned char submode;	    /* Holds editing mode of operation	    */
    unsigned char echosw;	    /* Switch echo on/off until CR	    */
    unsigned char profile;	    /* Index of profile in Space.c prof_tab */
    unsigned char breakin_char;	    /* Current breakin character	    */
    unsigned char edatout;	    /* Expedited data outstanding	    */
    unsigned int  ccount;	    /* Count of characters output on line   */
    unsigned char lcount;	    /* Count of lines output on page        */
    unsigned char loghost;	    /* Logging of host X29 settings         */
    unsigned char X29type;	    /* Flavour of X29 call - 1980 or 1984   */
    unsigned char pagewait;	    /* Set if pagewait is enabled           */
    struct xaddrf x_called;	    /* Called address			    */
    struct xaddrf x_calling;	    /* Calling address			    */
    struct extraformat facilities;  /* Facilities available		    */
    short xxx_pgrp;		    /* Process group info.		    */
    int argc;			    /* Argument count			    */
    char *argv[MAXARGC];	    /* Up to MAXARGC arguments		    */
    char cmdbuff[maxcmd];	    /* Command buffer			    */
    mblk_t *uin_buff;		    /* User input buffer		    */
    int uin_count;		    /* Number of input characters	    */
    mblk_t *cud_buff;		    /* CUD (if any) for current call        */
    unsigned char buff_to_go;	    /* Mark if buffer to go to network      */
    int tickid;			    /* Disconnect timer ID                  */
    thead_t thead;		    /* Data forwarding timer		    */
    timer_t tmtab[NTIMERS];	    /*   "	"	 "		    */
    unsigned char valid_termio;     /* Denotes validity of termio params.   */
    struct termio real_termio_pars; /* Real termio parameters		    */
    struct termio fake_termio_pars; /* Fake termio parameters		    */
    unsigned char x3params[MAX_X3_PARAM];  /* Current settings of X3 pars   */
} CCB;


struct xxx_cmd {
	char *cmd_name;
	char *cmd_alias;
	int command;
};

struct prof_entry {
	char *prof_name;
	unsigned char x3params[MAX_X3_PARAM];
};


#define UPROF     x3params[0]
#define RECALL    x3params[1] 
#define LECHO     x3params[2] 
#define DFORWARD  x3params[3]
#define FTIMEOUT  x3params[4]
#define AUXF      x3params[5]
#define PADSRV    x3params[6]
#define BRACT     x3params[7]
#define	DISCARD   x3params[8]
#define	CRPAD     x3params[9]
#define WIDTH     x3params[10]
#define TSPEED    x3params[11]
#define FLOW      x3params[12]
#define LFINSERT  x3params[13]
#define	LFPAD     x3params[14]
#define EDIT      x3params[15]
#define CHARDEL   x3params[16]
#define	LINEDEL   x3params[17]
#define LINEDISP  x3params[18]
#define TTYPE     x3params[19]  
#define ECHOMASK  x3params[20]
#define LPARITY   x3params[21]
#define PAGE      x3params[22]


/* Commands allowed  */

#define cmd_call	0  /* call                            */
#define cmd_status	1  /* status                          */
#define cmd_prof	2  /* profile                         */
#define cmd_log		3  /* log host X29 messages           */
#define cmd_brkey	4  /* break key                       */
#define cmd_echo	5  /* echo mask                       */
#define cmd_echom	6  /* terminal echo                   */
#define cmd_flow	7  /* terminal flow control           */
#define cmd_page	8  /* page wait                       */
#define cmd_width	9  /* terminal width                  */
#define cmd_lfin	10 /* Linefeed insertion              */
#define cmd_bract	11 /* Break action                    */
#define cmd_dfor	12 /* Data forwarding value           */
#define cmd_param	13 /* parameters                      */
#define cmd_clear	14 /* clear                           */
#define cmd_hosts	15 /* hosts                           */
#define cmd_break	16 /* break                           */ 
#define cmd_reset	17 /* reset                           */
#define cmd_quit	20 /* quit                            */
#define cmd_help	21 /* help                            */
#define cmd_message	22 /* message mode                    */
#define cmd_native	23 /* native mode                     */
#define cmd_print	24 /* printer hardcopy device         */
#define cmd_trans	25 /* transparent mode                */
#define cmd_vdu		26 /* vdu display device              */
#define	cmd_breakin	27 /* set breakin character	      */
#define cmd_int		28 /* Interrupt			      */
#define cmd_readpar	29 /* Read parameters		      */
#define	cmd_setpar	30 /* Set parameters		      */
#define cmd_setreadpar	31 /* Set and Read parameters	      */
#define	cmd_justcr	32 /* CR - resume		      */

#define PRINTER   1
#define TERMINAL  2

/* call status bits */

#define CS_DD   0             /* connection dead and disconnected   */
#define CS_AL	1             /* ccb allocated			    */
#define CS_LS   2             /* Listen request at X25 level        */
#define CS_CN   4             /* call out on network                */
#define CS_CI   8             /* call in from the network	    */
#define CS_CE   16            /* call established for data transfer */
#define CS_UR   32            /* user initiated reset               */
#define CS_UD   64            /* user initiated disconnect          */
#define CS_ND   128           /* net initiated disconnect           */
#define CS_CD   256           /* close initiated disconnect         */
#define CS_ICR  512           /* invitation to clear received       */
#define CS_ICS  1024          /* invitation to clear sent           */


/* values for PADmode */

#define	TERMINAL_PAD	1	/*  Denotes Terminal PAD operation  */
#define HOST_PAD	2	/*  Denotes Host PAD operation	    */


/* values for user_mode */

#define XXX_IDLE	0	/* idle, waiting to go into command mode  */
#define XXX_COMMAND	1	/* user command processing		  */
#define XXX_DATAXFER	2	/* normal mode				  */
#define XXX_ESCAPED	3	/* break char typed			  */

/* values for submode */
#define XXX_ERASE	1	/* erasing using character delete	  */

/* values for operating mode  */
#define XXX_MESSAGE     0     /* Message mode of operation             */
#define XXX_TRANSPARENT 1     /* Transparent mode of operation         */ 
#define XXX_NATIVE      2     /* Native mode of operation              */

/* X.29 Version */
#define	X29_1980	1
#define	X29_1984	2

/* X.29 CUD Field */
#define X29_CUD		"\1\0\0\0"

/* Values for X29 Messages */
#define X29_PIND     0
#define X29_ICLR     1
#define X29_SET      2
#define X29_IBRK     3
#define X29_READ     4
#define X29_ERROR    5
#define X29_STRD     6

/* Values for X29 Error PAD Messages */ 
#define X29_LESS_8BITS  0
#define X29_UNRECPM     1
#define X29_BADFMT      2
#define X29_NOTINT      3
#define X29_UNSOLPI     4
#define X29_TOOLONG     5

/* Values for X29 Errors in Parameter Value Fields */
#define X29_NOADDINF 0
#define X29_INVPAR   1
#define X29_INVAL    2
#define X29_NOTALT   3
#define X29_RDONLY   4
#define X29_INVSEP   5

/* Flags to denote operation mode	*/

#define	MESSAGE_MODE	1
#define	NATIVE_MODE	2

/* Flags to denote output data type	*/

#define	NET_DATA	1
#define	ECHO_DATA	2

#define d_digit(x)  ( (x >= '0') && (x <= '9') )
#define x_digit(x)  ( (x >= 'A') && (x <= 'F') )
#define w_space(x)  ( (x == ' ') || (x == '\t') || (x == '\n') || (x == '\r') || (x == ',') )
#define in_range(v,l,h) ( (v >= l) && (v <= h) )
#define d_alpha(x)  (((x >= 'a') && (x <= 'z')) || ((x >= 'A') && (x <= 'Z')))

/* Some standard character codes for ASCII */
#define	XXX_CONTROL(c)	(c & 0x1F)
#define	backspace	XXX_CONTROL('H')           
#define	tab		XXX_CONTROL('I')           
#define	oops		XXX_CONTROL('X')
#define	retype		XXX_CONTROL('R')
#define	DLE_BREAKIN	XXX_CONTROL('P')
#define	del		127

#define MASK_7_BITS ~0x80   /* Masks out 8th bit for 7 bit characters */

#ifndef	TRUE
#define TRUE	1
#endif

#ifndef	FALSE
#define FALSE	0
#endif

#define VAL_BRACT	1	/* selects validation of break action	*/
#define MAX_BRACT	21	/* maximum value for breakaction	*/

#define TOUPPER(x)	\
	if ( (x >= 'a') && (x <= 'z') ) \
	{				\
	    x = x - ('a' - 'A');	\
	}


/*  Defines for X.25 Facility Requests	*/

#define MIN_WND		1
#define	MAX_WND		127

#define	MIN_PKT		4
#define MAX_PKT		12

#define BUFP_T bufp_t

