/*
 * gfinger.h -- include file for gfinger
 * 
 *	$Source: /afs/athena.mit.edu/user/t/tytso/src/gfinger/RCS/gfinger.h,v $
 *	$Author: tytso $
 *	$Header: /afs/athena.mit.edu/user/t/tytso/src/gfinger/RCS/gfinger.h,v 1.3 88/05/24 19:30:01 tytso Exp Locker: tytso $
 */

#define LIBARY_DIR "/mit/tytso/src/gfinger/lib/"
#define LIBARY_SUFFIX ".list"
	
#define max(a,b) (((a)>(b))?(a):(b))
	
#define DATA_BUFF_SZ	4096
#define INPUT_LINE_SZ	1024

char	*strdup(char *s);
extern int	errno;

#define STATE_EOF 	1
#define STATE_CONNECT 	2
#define STATE_READING 	4
#define STATE_TIMED_OUT	8

#define STATE_ACTIVE	(STATE_CONNECT + STATE_READING)
#define	STATE_INACTIVE	(STATE_EOF + STATE_TIMED_OUT)

/*
 * This is a linked list of strings, where the information passed back
 * is stored.
 */
typedef struct long_string {
	char			*str;
	struct long_string	*next;
} LONG_STRING;
	
/*
 * This is the fundamental data structure of the program.  It keeps
 * all the state for each individual host being contacted.
 */
class hf {
protected:
	int		fd;		/* file descriptor for the socket */
	char		*host;		/* host to be queried */
	int		large;		/* 1 = request verbose mode */
	char		*name;		/* username to finger */
	LONG_STRING	*data;		/* to store the returned data */
	LONG_STRING	*last;		/* the last long_string */
	int		state;		/* current state of this hf */
	long		time;		/* time since last activity */
	hf		*next;		/* next entry in linked list */
	hf		*prev;		/* previous entry in linked list */
public:
	hf(char *name, char *host, int port, int large);
	int input();
	void output();
	void shutdown();
	~hf();
	void delete_ll(hf **top);
	void insert_ll(hf **top, hf *prev_hf);
	char *get_string();
};

extern int	finger_port;	/* TCP port for finger  */
extern int	large;		/* 1 = ask for a verbose version */
extern int	debug;		/* 1 = turn on debugging */
extern char	*user_name;	/* username to finger */
extern int	host_time_out;	/* Number of seconds before timing out */
				/* a host */
extern int	connect_time_out;	/* Number of seconds before */
					/* timing out host while */
					/* connecting a host */
extern int	max_hosts;	/* Number of hosts to finger at a time */

extern hf	*timed_out, *top;
