xref: /csrg-svn/usr.bin/finger/finger.h (revision 42731)
137660Sbostic /*
237660Sbostic  * Copyright (c) 1989 The Regents of the University of California.
337660Sbostic  * All rights reserved.
437660Sbostic  *
540027Sbostic  * This code is derived from software contributed to Berkeley by
640027Sbostic  * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
740027Sbostic  *
8*42731Sbostic  * %sccs.include.redist.c%
937660Sbostic  *
10*42731Sbostic  *	@(#)finger.h	5.5 (Berkeley) 06/01/90
1137660Sbostic  */
1237660Sbostic 
1337660Sbostic #include <pwd.h>
1437660Sbostic #include <utmp.h>
1537660Sbostic 
1637664Sedward /*
1737664Sedward  * All unique persons are linked in a list headed by "head" and linkd
1837664Sedward  * by the "next" field, as well as kept in a hash table.
1937664Sedward  */
2037664Sedward 
2137660Sbostic typedef struct person {
2237660Sbostic 	struct person *next;		/* link to next person */
2337664Sedward 	struct person *hlink;		/* link to next person in hash bucket */
2437660Sbostic 	uid_t uid;			/* user id */
2537660Sbostic 	char *dir;			/* user's home directory */
2637660Sbostic 	char *homephone;		/* pointer to home phone no. */
2737660Sbostic 	char *name;			/* login name */
2837660Sbostic 	char *office;			/* pointer to office name */
2937660Sbostic 	char *officephone;		/* pointer to office phone no. */
3037660Sbostic 	char *realname;			/* pointer to full name */
3137660Sbostic 	char *shell;			/* user's shell */
3237664Sedward 	struct where *whead, *wtail;	/* list of where he is or has been */
3337664Sedward } PERSON;
3437664Sedward 
3537664Sedward enum status { LASTLOG, LOGGEDIN };
3637664Sedward 
3737664Sedward typedef struct where {
3837664Sedward 	struct where *next;		/* next place he is or has been */
3937664Sedward 	enum status info;		/* type/status of request */
4037664Sedward 	short writable;			/* tty is writable */
4137664Sedward 	time_t loginat;			/* time of (last) login */
4237664Sedward 	time_t idletime;		/* how long idle (if logged in) */
4337660Sbostic 	char tty[UT_LINESIZE+1];	/* null terminated tty line */
4437660Sbostic 	char host[UT_HOSTSIZE+1];	/* null terminated remote host name */
4537664Sedward } WHERE;
4637660Sbostic 
4737664Sedward #define	HBITS	8			/* number of bits in hash code */
4837664Sedward #define	HSIZE	(1 << 8)		/* hash table size */
4937664Sedward #define	HMASK	(HSIZE - 1)		/* hash code mask */
5037664Sedward 
5137664Sedward PERSON *htab[HSIZE];			/* the buckets */
5237664Sedward PERSON *phead, *ptail;			/* the linked list of all people */
5337664Sedward 
5437664Sedward int entries;				/* number of people */
5537664Sedward 
5637664Sedward PERSON *enter_person(), *find_person(), *palloc();
5737664Sedward WHERE *walloc();
5837664Sedward 
5937660Sbostic extern char tbuf[1024];			/* temp buffer for anybody */
60