xref: /original-bsd/usr.bin/finger/finger.h (revision ca3b5b26)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)finger.h	5.3 (Berkeley) 05/08/89
18  */
19 
20 #include <pwd.h>
21 #include <utmp.h>
22 
23 /*
24  * All unique persons are linked in a list headed by "head" and linkd
25  * by the "next" field, as well as kept in a hash table.
26  */
27 
28 typedef struct person {
29 	struct person *next;		/* link to next person */
30 	struct person *hlink;		/* link to next person in hash bucket */
31 	uid_t uid;			/* user id */
32 	char *dir;			/* user's home directory */
33 	char *homephone;		/* pointer to home phone no. */
34 	char *name;			/* login name */
35 	char *office;			/* pointer to office name */
36 	char *officephone;		/* pointer to office phone no. */
37 	char *realname;			/* pointer to full name */
38 	char *shell;			/* user's shell */
39 	struct where *whead, *wtail;	/* list of where he is or has been */
40 } PERSON;
41 
42 enum status { LASTLOG, LOGGEDIN };
43 
44 typedef struct where {
45 	struct where *next;		/* next place he is or has been */
46 	enum status info;		/* type/status of request */
47 	short writable;			/* tty is writable */
48 	time_t loginat;			/* time of (last) login */
49 	time_t idletime;		/* how long idle (if logged in) */
50 	char tty[UT_LINESIZE+1];	/* null terminated tty line */
51 	char host[UT_HOSTSIZE+1];	/* null terminated remote host name */
52 } WHERE;
53 
54 #define	HBITS	8			/* number of bits in hash code */
55 #define	HSIZE	(1 << 8)		/* hash table size */
56 #define	HMASK	(HSIZE - 1)		/* hash code mask */
57 
58 PERSON *htab[HSIZE];			/* the buckets */
59 PERSON *phead, *ptail;			/* the linked list of all people */
60 
61 int entries;				/* number of people */
62 
63 PERSON *enter_person(), *find_person(), *palloc();
64 WHERE *walloc();
65 
66 extern char tbuf[1024];			/* temp buffer for anybody */
67