137660Sbostic /* 237660Sbostic * Copyright (c) 1989 The Regents of the University of California. 337660Sbostic * All rights reserved. 437660Sbostic * 5*40027Sbostic * This code is derived from software contributed to Berkeley by 6*40027Sbostic * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7*40027Sbostic * 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*40027Sbostic * @(#)finger.h 5.4 (Berkeley) 02/07/90 2137660Sbostic */ 2237660Sbostic 2337660Sbostic #include <pwd.h> 2437660Sbostic #include <utmp.h> 2537660Sbostic 2637664Sedward /* 2737664Sedward * All unique persons are linked in a list headed by "head" and linkd 2837664Sedward * by the "next" field, as well as kept in a hash table. 2937664Sedward */ 3037664Sedward 3137660Sbostic typedef struct person { 3237660Sbostic struct person *next; /* link to next person */ 3337664Sedward 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 */ 4237664Sedward struct where *whead, *wtail; /* list of where he is or has been */ 4337664Sedward } PERSON; 4437664Sedward 4537664Sedward enum status { LASTLOG, LOGGEDIN }; 4637664Sedward 4737664Sedward typedef struct where { 4837664Sedward struct where *next; /* next place he is or has been */ 4937664Sedward enum status info; /* type/status of request */ 5037664Sedward short writable; /* tty is writable */ 5137664Sedward time_t loginat; /* time of (last) login */ 5237664Sedward 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 */ 5537664Sedward } WHERE; 5637660Sbostic 5737664Sedward #define HBITS 8 /* number of bits in hash code */ 5837664Sedward #define HSIZE (1 << 8) /* hash table size */ 5937664Sedward #define HMASK (HSIZE - 1) /* hash code mask */ 6037664Sedward 6137664Sedward PERSON *htab[HSIZE]; /* the buckets */ 6237664Sedward PERSON *phead, *ptail; /* the linked list of all people */ 6337664Sedward 6437664Sedward int entries; /* number of people */ 6537664Sedward 6637664Sedward PERSON *enter_person(), *find_person(), *palloc(); 6737664Sedward WHERE *walloc(); 6837664Sedward 6937660Sbostic extern char tbuf[1024]; /* temp buffer for anybody */ 70