xref: /original-bsd/usr.bin/finger/finger.h (revision 4ec22e22)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
7  *
8  * %sccs.include.redist.c%
9  *
10  *	@(#)finger.h	5.5 (Berkeley) 06/01/90
11  */
12 
13 #include <pwd.h>
14 #include <utmp.h>
15 
16 /*
17  * All unique persons are linked in a list headed by "head" and linkd
18  * by the "next" field, as well as kept in a hash table.
19  */
20 
21 typedef struct person {
22 	struct person *next;		/* link to next person */
23 	struct person *hlink;		/* link to next person in hash bucket */
24 	uid_t uid;			/* user id */
25 	char *dir;			/* user's home directory */
26 	char *homephone;		/* pointer to home phone no. */
27 	char *name;			/* login name */
28 	char *office;			/* pointer to office name */
29 	char *officephone;		/* pointer to office phone no. */
30 	char *realname;			/* pointer to full name */
31 	char *shell;			/* user's shell */
32 	struct where *whead, *wtail;	/* list of where he is or has been */
33 } PERSON;
34 
35 enum status { LASTLOG, LOGGEDIN };
36 
37 typedef struct where {
38 	struct where *next;		/* next place he is or has been */
39 	enum status info;		/* type/status of request */
40 	short writable;			/* tty is writable */
41 	time_t loginat;			/* time of (last) login */
42 	time_t idletime;		/* how long idle (if logged in) */
43 	char tty[UT_LINESIZE+1];	/* null terminated tty line */
44 	char host[UT_HOSTSIZE+1];	/* null terminated remote host name */
45 } WHERE;
46 
47 #define	HBITS	8			/* number of bits in hash code */
48 #define	HSIZE	(1 << 8)		/* hash table size */
49 #define	HMASK	(HSIZE - 1)		/* hash code mask */
50 
51 PERSON *htab[HSIZE];			/* the buckets */
52 PERSON *phead, *ptail;			/* the linked list of all people */
53 
54 int entries;				/* number of people */
55 
56 PERSON *enter_person(), *find_person(), *palloc();
57 WHERE *walloc();
58 
59 extern char tbuf[1024];			/* temp buffer for anybody */
60