* timer.h
 *
 *	DRH	920801	Changed to external format.
 *


define OPENRTCLOCK		0x0031

	* CTOS Timer Request Block structure *
typedef struct timerrequestblocktype{
	unsigned int		counter;
	unsigned int		counterreload;
	unsigned int		cevents;
	unsigned int		exchresp;
	unsigned int		ercret;
	unsigned int		rqcode;
} TRB;

	* With one CTOS timer we can simulate any number of pseudo timers.  This 
	 * structure defines the fields needed to implement software timers. 
	 * Whenever the timer is running, it is on a doublylinked list pointed to 
	 * by timers so that the (hardware) timer interrupt process can  run 
	 * through the list and change counts and states.  Stopping a timer or 
	 * letting it expire causes it to be removed from the list; starting a 
	 * timer puts it on the list.
	 *

typedef struct timertype {
	struct timertype		* next;		* Doublylinkedlist pointers *
	struct timertype		* prev;
	unsigned int			start;		* Period of counter (load value) *
	unsigned int			count;		* Ticks to go until expiration *
	void					(*func)();	* Function to call at expiration *
	char					* arg;		* Arg to pass function *
	char					state;		* Timer state *
define	TIMER_STOP			0
define	TIMER_RUN			1
define	TIMER_EXPIRE		2
define TIMER_START			3
} TIMER;

define	NULLTIMER			( TIMER *)0
define	MAX_TIME			(unsigned int) 65535l	* Max short integer *
define	MSPTICK				100						* Milliseconds per tick *

* Macros that hide the timer structure internals *
define	set_timer( t, x)	( ( ( t)>start) = ( x)  MSPTICK)
define	dur_timer( t)		( ( t)>start)
define	read_timer( t)		( ( t)>count)
define	run_timer( t)		( ( ( t)>state == TIMER_RUN) || \
							  ( ( t)>state == TIMER_START))
_TO_HOSTNAME;
endif

if( SET_RQ_OPEN_TCP_CONNECTION || SET_RQ_OPEN_TCP_CONNECTION_NO_WAIT)
typedef struct {
		REQUEST					rq;
		unsigned int			index;
		unsigned int			localport;		* 0 means use the first	*
												* free port >= 1024		*

		unsigned int			remoteport;		* not needed if not Active	*
												