xref: /csrg-svn/usr.bin/finger/finger.h (revision 37664)
137660Sbostic /*
237660Sbostic  * Copyright (c) 1989 The Regents of the University of California.
337660Sbostic  * All rights reserved.
437660Sbostic  *
537660Sbostic  * This code is derived from software contributed to Berkeley by
637660Sbostic  * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
737660Sbostic  *
837660Sbostic  * Redistribution and use in source and binary forms are permitted
937660Sbostic  * provided that the above copyright notice and this paragraph are
1037660Sbostic  * duplicated in all such forms and that any documentation,
1137660Sbostic  * advertising materials, and other materials related to such
1237660Sbostic  * distribution and use acknowledge that the software was developed
1337660Sbostic  * by the University of California, Berkeley.  The name of the
1437660Sbostic  * University may not be used to endorse or promote products derived
1537660Sbostic  * from this software without specific prior written permission.
1637660Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1737660Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1837660Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1937660Sbostic  *
20*37664Sedward  *	@(#)finger.h	5.2 (Berkeley) 05/07/89
2137660Sbostic  */
2237660Sbostic 
2337660Sbostic #include <pwd.h>
2437660Sbostic #include <utmp.h>
2537660Sbostic 
26*37664Sedward /*
27*37664Sedward  * All unique persons are linked in a list headed by "head" and linkd
28*37664Sedward  * by the "next" field, as well as kept in a hash table.
29*37664Sedward  */
30*37664Sedward 
3137660Sbostic typedef struct person {
3237660Sbostic 	struct person *next;		/* link to next person */
33*37664Sedward 	struct person *hlink;		/* link to next person in hash bucket */
3437660Sbostic 	uid_t uid;			/* user id */
3537660Sbostic 	char *dir;			/* user's home directory */
3637660Sbostic 	char *homephone;		/* pointer to home phone no. */
3737660Sbostic 	char *name;			/* login name */
3837660Sbostic 	char *office;			/* pointer to office name */
3937660Sbostic 	char *officephone;		/* pointer to office phone no. */
4037660Sbostic 	char *realname;			/* pointer to full name */
4137660Sbostic 	char *shell;			/* user's shell */
42*37664Sedward 	struct where *whead, *wtail;	/* list of where he is or has been */
43*37664Sedward } PERSON;
44*37664Sedward 
45*37664Sedward enum status { LASTLOG, LOGGEDIN };
46*37664Sedward 
47*37664Sedward typedef struct where {
48*37664Sedward 	struct where *next;		/* next place he is or has been */
49*37664Sedward 	enum status info;		/* type/status of request */
50*37664Sedward 	short writable;			/* tty is writable */
51*37664Sedward 	time_t loginat;			/* time of (last) login */
52*37664Sedward 	time_t idletime;		/* how long idle (if logged in) */
5337660Sbostic 	char tty[UT_LINESIZE+1];	/* null terminated tty line */
5437660Sbostic 	char host[UT_HOSTSIZE+1];	/* null terminated remote host name */
55*37664Sedward } WHERE;
5637660Sbostic 
57*37664Sedward #define	HBITS	8			/* number of bits in hash code */
58*37664Sedward #define	HSIZE	(1 << 8)		/* hash table size */
59*37664Sedward #define	HMASK	(HSIZE - 1)		/* hash code mask */
60*37664Sedward 
61*37664Sedward PERSON *htab[HSIZE];			/* the buckets */
62*37664Sedward PERSON *phead, *ptail;			/* the linked list of all people */
63*37664Sedward 
64*37664Sedward int entries;				/* number of people */
65*37664Sedward 
66*37664Sedward PERSON *enter_person(), *find_person(), *palloc();
67*37664Sedward WHERE *walloc();
68*37664Sedward 
6937660Sbostic extern char tbuf[1024];			/* temp buffer for anybody */
70