Newsgroups: comp.sources.unix
From: phil@Shiva.COM (Phil Budne)
Subject: v25i170: finger - Phil's Finger Program, Part07/07
Sender: unix-sources-moderator@pa.dec.com
Approved: vixie@pa.dec.com

Submitted-By: phil@Shiva.COM (Phil Budne)
Posting-Number: Volume 25, Issue 170
Archive-Name: finger/part07

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 7 (of 7)."
# Contents:  History.h getttyloc.c
# Wrapped by budd@bu-it on Fri Jul  6 13:22:07 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f History.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"History.h\"
else
echo shar: Extracting \"History.h\" \(31479 characters\)
sed "s/^X//" >History.h <<'END_OF_History.h'
X/*-*-text-*-*/
X/*
X * Copyright (C) 1986, 1990  Philip L. Budne
X *
X * This file is part of "Phil's Finger Program".
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X */
X
X# define HISTORY_RCSID "$Id: History.h,v 3.0 90/07/06 13:09:46 budd Rel $"
X
X# ifdef __GNUC__x		/* works in GCC 1.20 and up */
X# define B(x)			/* RMS does not believe in regression tests! */
X# else  /* __GNUC__x not defined */
X# define B(x) : x
X# endif /* __GNUC__x not defined */
X
Xstruct _JBVER {
X    unsigned who   B(3);	/* 0=development group, 1=other digital */
X				/* 2,3,4 customer; 5,6,7 customer's user */
X    unsigned major B(9);
X    unsigned minor B(6);
X# if 1
X    unsigned edit  B(18);
X# else  /* not 1 */
X    unsigned flag  B(1);
X    unsigned edit  B(17);
X# endif /* not 1 */
X};
X
X/*
X * For the uninformed:
X *
X * This is the format TOPS-10 uses to store version numbers.  Word
X * 0137 in low core -- The JOB DATa area (JOBDAT) is called .JBVER
X *
X * TOPS-20 uses it too, with minor perversions: major/minor edits are
X * displayed as major.minor (5.1 rather than 5A) If the high order bit
X * of edit is set (0400000) the low 17 bits are printed in decimal.
X *
X */
X
X/****************************************************************
X
X	Pre-History:
X
X	Nov 85 -- Work began with code that is now maketree and dofinger.
X		  Just printed current users nicely.
X	Dec 85 -- enhanced ttylocs.
X	Jan 86 -- Command line parsing added.
X
X100	Wed May 21, 1986	Phil
X	Start History file.
X	Allow slash switches appended directly to unames.
X	Create routine doswitch().
X	Files:
X		args.c
X
X101	Wed May 28, 1986	Phil
X	Display last login host uppercase.
X	Remove ".arpa" in undomain.
X	Files:
X		lastlog.c	undomain.c
X
X102	Thurs May 28, 1986	Phil
X	Wrote my own getutmp().
X	Flush SYS V utmp.c
X	Files:
X		getut.c
X
X103	Thurs May 28, 1986	Phil
X	Massive cleanup.  Add copyrights,
X	make sure to use finger.h
X	Display [n.n.n.n]
X	Files:
X		doremote.c ....
X
X**** given to sundar@mit-hermes ****
X
X104	July 16, 1986		BZS
X	Add SYSLOG option to fingerd.c
X
X105	August 12, 1986		Phil
X	Add ttyplace, ttyrandom options to ttyask.c
X
X106	August 12, 1986		Phil
X	Add -j option to force whoj output
X	Files:
X		args.c args.h
X
X107	Weds Sept 3, 1986	Phil
X	Merge in stuff for Umax (Encore Multimax 4.2) [under ifdef Umax]
X	Files:
X		luser.h	getttyloc.c output.c
X		getcommand.c readpr.c fingerd.c
X
X108	Sat Sept 27, 1986	Phil
X	Remove "On since" since it only applies to one login.
X	Files:
X		whois.c
X
X109	Thus Oct 2, 1986	Phil
X	Add hackery for "consdev" on sun. Does the right thing when
X	console is really a printer on ttya, but not when workstation
X	with a console window.
X	Files:
X		readpr.c getcommand.c
X
X110	Thus Oct 2, 1986	Phil
X	Add NETLOC and OTTYLOC conditionals.
X	Files:
X		getttyloc.c locname.c
X
X111	Fri Oct 3, 1986		Phil
X	Add (/L) sw_location -- ignore user ttyloc
X	Files:
X		getttyloc.c args.h args.c
X
X112	Mon Oct 6, 1986		Phil
X	Fix undomain
X	File:
X		undomain.c
X
X113	Mon Oct 6, 1986		Phil
X	Merge in working inq_stats code for Umax (encore)
X	Files:
X		undomain.c
X
X114	Weds Oct 22, 1986	Phil
X	Make getcommand() return struct pr.
X	Print flag for suid programs.
X	Make room for inquire group.
X	Split off whoj.c and finger.c from output.c.
X	Add ifdef lint around copyright in finger.h.
X	Create inquire.c hook into inquire/holmes.
X	Add fields in person struct, move p_Rc into p_flags.
X	Files:
X		whoj.c finger.c output.c finger.h inquire.c getperson.c
X
X115	Wednesday October 28, 1986	Phil
X	Create code to use mmap to read process table, and upage
X	pagemaps.  Code to read actual upage(s) does not work.  (MAP
X	UMAP1 UMAP2 in map.h).  Performance win is barely noticeable
X	Create names.c syms.h info.h. Read namelist into info struct
X	and save as /etc/saved-finger-namelist.  BIG win, bigger than
X	any crock in readpr.
X	Files:
X		readpr.c names.c syms.h info.h map.h
X
X116	Thursday October 29, 1986	Phil
X	create ttycycle (ttyask -c[time]).  Cycles thru ttylplaces
X	sleeping for time seconds.
X	Files:
X		ttyask.c
X
X**** second version given to sundar@hermes ****
X
X117	Saturday November 1, 1986	Phil
X	Split readpr.c into kmem.c, readpr.c, ustruct.c
X	Split pr.h into pr.h and kmem.h
X	Files:
X		getcommand.c readpr.c pr.h
X
X118	Sunday November 1, 1986		Phil
X	Add optional ttyrandom cycling (ttyask -r<time>), -b(ackground).
X	Add savewho/checkwho to kill self when parent goes away.
X	File:
X		ttyask.c
X
X119	Monday November 3, 1986		Phil
X	Append suid character to program name.
X	Start playing with new select stuff (+tty .)
X	Files:
X		finger.c select.h select.c args.c
X
X120	Sunday, November 9, 1986	Phil
X	Make ttyloc check tty ownership, remove fchown().
X	Files:
X		ttyloc.c
X
X121	Monday, November 10, 1986	Phil
X	Don't decr todo counter unless hit has no person entry in pwtree.
X	Files:
X		getperson.c
X
X122	Monday, November 10, 1986	Phil
X	Implement blankline(), better defaults for empty fields in finger.
X	Files:
X		getperson.c doremote.c mcheck.c
X		finger.c inquire.c output.c
X
X
X123	Wednesday, November 12, 1986	Phil
X	Do NETLOC for annexes too!  Make undomain() optionally
X	remove prefixes to 100% domain matches. Put it 'make depend'
X	Files:
X		undomain.c prefixes.h getttyloc.c lastlog.c whoj.c
X		Makefile
X
X124	Tuesday, December 2, 1986	Phil
X	zero p_count in makeperson. Warn about unknown switches.
X	Files:
X		getperson.c args.c
X
X125	Friday, January 1, 1987		Phil
X	Clean up NFILE reading, rejection.
X	Have ttyask use optarg(3), add -t time flag (as opposed
X	too -c [time] and -r [time]), use as timeout in ttyask too.
X	Files:
X		names.c ttyask.c
X
X126	Monday, January 12, 1987	Phil
X	Add read_vmunix, used to find _version in /vmunix and
X	fill in info_verstr when reading nlist.
X	Files:
X		names.c read_vmunix.c
X
X127	Monday, January 12, 1987	Phil
X	Add 4.3 stuff under BSD4_3; tty.h wants ioctl.h
X	tty group/mesg stuff.
X	Files:
X		getcommand.c output.c
X
X128	Friday, January 16, 1987	Phil
X	If stdin is not a tty, act as if /berk.
X	Fix doswitch() to accept multi letter switch names.
X	File:
X		args.c
X
X129	Sunday, January 25, 1987	Phil
X	Print /etc/nologin after herald.
X	File:
X		fingerd.c
X
X130	Feb 26, 1987	Phil
X	Do special ttyloc display for xterms.
X	File:
X		getttyloc.c
X
X131	Friday, March 13, 1987	Phil
X	Create netfinger variable, use in outchar to output <CR><LF>
X	and for /berk madness (see [128])
X	Files:
X		args.c output.c
X
X
X132	Sunday, March 15, 1987	Phil
X	Display times more than a day, and less than 10
X	using hours, not fractions of days. Handle weeks ...
X	File:
X		output.c
X
X133	Weds, April 22, 1987	Phil
X	Don't set same is person && u->u_person are both NULL
X	File:
X		finger.c
X
X134	Sat, May 23, 1987	Phil
X	Clean up for namelist read/write. Add AUTONLIST.
X	Add fchown, fchmod in write.  Add ifdef Umax to read_vmunix.
X	Files:
X		names.c read_vmunix.c
X
X135	Mon, May 25, 1987	Phil
X	Add maddr() for mailing address.
X	Display '.' for biff, ',' for hungry, ';' for hungry + biff.
X	Files:
X		person.h finger.c mcheck.c getperson.c whois.c
X
X136	Tues, May 26, 1987	Phil
X	Never display interval with weeks, and zero days.
X	File:
X		output.c
X
X137	Friday May 29 and (cleanup) Monday June 29, 1987  Phil
X	(My father died June 10th) Use inquire for user lookup.  Use
X	getpwbynam in pwtree if GETPWNAM_SLOW is not defined.
X	makeperson and insert_winner take struct info pointer if
X	INQUIRE is defined. Can now display a person with no password
X	entry (but still has inquire entry!!)
X	Files:
X		getperson.c select.c inquire.c finger.c
X
X140	Saturday July 11, 1987		Phil
X	Check if last element in second strncmp in do_ttyplace.
X	File:
X		ttyask.c
X
X141	Saturday July 11, 1987		Phil
X	Change History into History.c. Create make-version, BUILD,
X	and version.c (reset BUILD when History is modified?)
X	Files:
X		make-version History.c version.c Makefile
X
X142	Saturday July 11, 1987		Phil
X	Implement full switch names. Add switch.h
X	Only say one of forwarded and no mailbox.
X	Add UNPREIX_NODOMAINS and unprefix() [helful for Xhost:display]
X	Add /version
X	create ttyloc.1
X	Files:
X		args.c switch.h mcheck.c undomain.c ttyloc.1
X
X143	Sunday July 12, 1987		Phil
X	Implement tty selectors. +name. checks for implied leading "tty"
X	Add tsel.h
X	Files:
X		getent.c finger.c tsel.h
X
X144	Sunday July 12, 1987		Phil
X	Add CONC macro.  Give SYM two arguments, first string, second member.
X	Put longversion[] into saved nlist file.
X	Files:
X		syms.h info.h names.c finger.h
X
X145	Monday July 13, 1987		Phil
X	Add /help, values on switches.
X	Files:
X		switch.h args.h
X
X146	Tuesday July 14, 1987	2am	Phil	-- Bastile Day!!
X	Add /follow, move savestr to string.c.
X	Add malloc and savestr defs to finger.h
X	Add <strings.h> in many places.
X	Files:
X		switch.h args.h select.c mcheck.c finger.h
X		ttyloc.c fingerd.c whois.c getperson.c
X
X147	Tuesday July 14, 1987	4pm	Phil	-- Bastile Day!!
X	Add readnewttyloc() new format ttyloc file (has short, line type)
X	Files:
X		getttyloc.c readttylocfile.c readttylocfile.h
X
X150	Thursday July 16, 1987		Phil
X	Add getttyents() -- read 4.3 /etc/ttys file as last resort
X	for tty locations.
X	Files:
X		getttyloc.c readttylocfile.c
X
X151	Thursday July 16, 1987		Phil
X	Create getttytype for ttyask-ing.  Create skip.c. use in readttylocfile
X	move findttyloc into readttylocfile.c make nttyloc static there.
X	Files:
X		getttytype.c skip.c readttylocfile.c getttyloc.c Makefile
X
X152	Friday July 17, 1987	2am	Phil
X	Add sw_fields, /fields, set_fields (no action yet)
X	Use binary search in findttyloc
X	Files:
X		args.c args.h switch.h readttylocfile.c
X
X153	Friday July 17, 1987	5pm	Phil
X	Create switch.c move doswitch and other switchiness there.
X	Use skipwhite and skipblack all over.
X	Files:
X		args.c switch.c Makefile getperson.c select.c ttyask.c
X
X154	Wednesday July 22, 1987	4am	Phil
X	Clean up readpr, make signal state an enum. Look at it in getcommand.
X	Files:
X		readpr.c pr.h getcommand.c
X
X155	Wednesday July 22, 1987	5am	Phil
X	Add ttystate, TTYSTATE
X	Files:
X		syms.h finger.c
X
X156	Thursday July 23, 1987	Phil
X	Add /debug sw_debug DEBUGSW
X	Files:
X		args.h switch.h switch.c Makefile getcommand.c
X
X157	Thursday July 23, 1987	Phil
X	Check for backgrounded forks which have group membership
X	by being disowned and writing to tty. Add II and IID macros.
X	File:
X		getcommand.c
X
X160	Saturday July 25, 1987	Phil
X	rename /save to /read. Add /nosave.  Force on when 'xf'
X	Files:
X		args.c args.h switch.h names.c
X
X161	Thursday July 30, 1987	Phil
X	Set width to PLUS_INF if netfinger
X	Files:
X		output.c
X
X162	Friday July 31, 1987	Phil
X	Create flags.h args.m4 flags struct.  Save Flags before
X	smashing for /berk.
X	Files:
X		flags.h args.m4 Makefile args.c
X
X163	Saturday August 1, 1987	Phil
X	Create local.h, removed prefixes.h.  sed UMAX to Umax.
X	Move Makefile work to ymakefile
X	Files:
X		local.h Makefile ymakefile
X
X164	Monday August 3, 1987	Phil
X	Remove tiresome fencepost errors.
X	Files:
X		getcommand.c read_vmunix.c names.c
X
X165	Saturday August 8, 1987	Phil
X	syslog argv passed to finger.
X	File:
X		fingerd.c
X
X166	Wednesday Sept 2, 1987	Phil
X	add unswitch -- detect switches on . and +
X	File:
X		args.c
X
X167	Thursday Sept 17, 1987	Phil
X	add else after doswitch in finger().
X	add ttystate_t tiwait towait
X	Files:
X		args.c pr.h getcommand.c readpr.c
X
X170	Thursday October 29, 1987	Phil
X	Flush zombies in getcommand()
X	Files:
X		getcommand.c
X
X171	Tuesday November 10, 1987	Phil
X	Make compile on ULTRIX
X	Split BSD4_3 defines into TTY_GROUP TTYENT TTY_REQUIRES_IOCTL
X	Files:
X		fingerd.c	getttytype.c	getttyloc	readpr.c
X		getcommand.c	output.c	undomain.c	readttylocfile.c
X
X172	Friday November 13, 1987	Phil
X	Move ttystate_t into ttystate.h (for Umax)
X	Update for Umax 3.1.0; no more libu.a, no more statistics typedefs.
X	Files:
X		ttystate.h getcommand.c readpr.c finger.c getttyloc.c
X		kmem.c names.c output.c pr.h read_vmunix.c ustruct.c
X		ymakefile
X
X**** given to dle@csl.sri.com ****
X
X173	Tuesday Junuary 12, 1988	Phil
X	Display 0:xx as 12:xxAM and 12:xx as 12:xxPM in nicetime.
X	File:
X		whois.c
X
X174	Wednesday January 13, 1988	Phil
X	Port to IBM AIS 4.2 on PC/RT (ibm032);
X	- use getdtablsize in fingerd.
X	- Add L1 and N_SEGSIZ in read_vmunix.
X	- Add VDEBUG in readpr.
X	- Do awful things in ustruct.c
X	Files:
X		read_vmunix.c ustruct.c readpr.c fingerd.c
X
X175	Thursday January 14, 1988	Phil
X	Add u_daemon enum in pr struct.  Fill in
X	by tracing parents of current process in getcommand.
X	Move body of getcommand to getcommand2. Display
X	in getttyloc. Clean up readpr().
X	Files:
X		pr.h getcommand.c getttyloc.c readpr.c
X
X176	Saturday, January 23, 1988	Phil
X	Create daemon struct in daemon.h.
X	Create daemon table in daemon.c.
X	Make u_daemon a short -- index into daemons[].
X	Display daemon parantage without host (suntools)
X	Recognize /dev/console as location "Console"
X	Add suntools, vt100tool, othertools, dlogind(?) to known daemons.
X	Files:
X		ymakefile daemon.h daemon.c getttyloc.c readpr.c
X
X177	Wednesday, February 10, 1988	Phil
X	Add ttwait and selwait check in getcommand.
X	Display number of processes found in readpr.
X	Files:
X		getcommand.c readpr.c
X
X**** new version given to dle@csl.sri.com ****
X**** given to winser@gnu.ai.mit.edu ****
X
X200	Wednesday, Feb 17, 1988	Phil
X	Revamp autoconfig. Do DEFBANNER, TTYGROUP, TTYENT seperately
X	Revamp taring in ymakefile. Include stuff dir.
X	Move this to History.h. Create pversion.c
X	File:
X		autoconfig ymakefile History.h pversion.c
X
X201	Thursday, Feb 25, 1988	Phil
X	Add u_daemonp to LUSER, make u_daemon a struct daemon *
X	Files:
X		luser.h daemon.h getcommand.c getttyloc.c
X
X202	Monday, March 7, 1988	Phil
X	Define INIT_PID as 1, use in getcommand.c ttyask.c
X	Use heuristic weighting in getcommand2()
X	Create pr_weight
X	Files:
X		pr.h finger.h getcommand.c
X
X203	Tuesday March 8, 1988	Phil
X	figure out signal states under Umax
X	use valloc for mapping in readpr()
X	rename ttystate etc to waitstate ...
X	penalize gamescontrol (crocked for now)
X	bonus for runnable
X	finger.c no longer includes waitstate
X	Files:
X		ttystate.h -> waitstate.h
X		finger.c getcommand.c readpr.c
X
X204	Thursday March 10, 1988	Phil
X	Create enum and strings via _STATE and _STATES
X	Create PAuse state and WAit state.
X	Zero strings ends in names.c, alloc strings as VERSTRLEN+1
X	Add _u to syms (for pause state)
X	Files:
X		waitstate.h readpr.c info.h names.c syms.h
X
X205	Tuesday, March 22, 1988 Phil
X	Back from St. Lucia, W.I.
X	Add officialhostname and OFFICIALhostname to args.c, use in undomain.c
X	Other cleanup in undomain.c
X	Handle X11 host:[:]display[.[screen]] madness in getttyloc.c
X	Files:
X		args.c undomain.c getttyloc.c
X
X206	Wednesday, March 23, 1988 Phil
X	Add aliases islocalhost() to args.c, use in mcheck.c
X	Add BOOL to finger.h
X	Make strupcpy() and strzcpy() in strings.c return src (like strcpy)
X	Fix LOG_ERROR to be LOG_ERR (for 4.3) in fingerd.c
X	Files:
X		args.c mcheck.c finger.h strings.c fingerd.c
X
X207	Monday, April 4, 1988	Phil
X	Use mtime .ge. atime (was .gt.) in mcheck()
X	File:
X		mcheck.c
X
X210	Monday, April 10, 1988	Phil
X	NETFOLLOW only when there are local users specified.
X	Do remote users even if no local users were specified.
X	(make just /follow work again)
X	File:
X		args.c
X
X211	Wednesday, April 20, 1988 Phil
X	Call openlog with name "fingerd", use LOG_DAEMON if defined.
X	Add HIDDEN_PROGRAMS for things like "gamescontrol"
X	Files:
X		fingerd.c getcommand.c
X
X212	Tuesday, May 3, 1988	Phil
X	Add /state switch.
X	Files:
X		getcommand.c finger.c flags.h switch.c switch.h
X
X213	Saturday, May 6, 1988	Phil
X	Have makeperson take luser as first arg.  This way we can
X	finger personal name via inquire even if the yellow pages are
X	dead!  Flush getperson1. Add REL_SUP.
X	Files:
X		getperson.c select.c finger.c
X
X214	Sunday, May 7, 1988	Phil
X	If redirected console, display in default ttyloc.  Add /ITS
X	(change nicetime, "Jobnam" header).  Display relation even if
X	REL_SUP under /whois.  Add /output-idle -- displays time since
X	last output.  Display groups in whois() -- Can get redundancies!!
X	Files:
X		getttyloc.c whois.c flags.h switch.c
X		switch.h finger.c output.c
X
X215	Friday, May 13, 1988	Phil
X	Port to Celerity (accel 3.4.x).  Make read_vmunix read NMAGIC
X	files.  Capitalize first letter of uname inserted by '&' crock.
X	Check for vaild u_procp in readpr().  Reuse t_short as long string
X	if no ty_comment in readttyents().  Add PICKY.  Correct TTYENT
X	ifdefs. Fix bsd4_3 quote problem in autoconfig.  Add accel to
X	fingerd ARHITECTUREs.  Make Ultrix an ARCHITECTURE.  Add -L to ls
X	/bin/write in autoconfig -- On accel its a symlink!
X	Files:
X		getperson.c getcommand.c getttyloc.c kmem.c read_vmunix.c
X		readpr.c readttylocfile.c syms.h ustruct.c names.c
X		autoconfig fingerd.c
X
X216	Tuesday, May 17, 1988	Phil
X	Check for console redirection in getttyloc(). Add ISCONS macro.
X	Add BIG_CONSOLE, SMALL_CONSOLE to tag lines.
X	Add UID_NOBODY, USER_NOBODY to fingerd.
X	Files:
X		getttyloc.c fingerd.c
X
X217	Friday, May 20, 1988	Phil
X	Add /process (sw_pid). Column not wide enough!!
X	Files:
X		finger.c flags.h switch.h switch.c
X
X220	Thursday, May 26, 1988	Phil (bucsf)
X	Add NINQUIRE, inquire.h to support *NEW INQUIRE*
X	Add P_NOPWENT to explicily flag users without password
X	file entries (yp failure, stale inquire entry)
X	Add s_next field to SELs for quick traversal.
X	make ttyask timeouts be per question
X	Files:
X		person.h finger.c inquire.h ttyask.c getperson.c
X		select.c select.h
X
X221	Monday, June 6, 1988 AM Phil (bucsf)
X	Add MINCYCLE for ttycycle/ttyrandom.
X	Cleanup in getcommand() and getcommand2().
X	Add X10_STR/X11_STR to getttyloc()
X	Add useinquire global.  Not yet checked *TODO*
X	Use acct as supervisor,  Flush [maddr] display in whois.c
X	Files:
X		ttyask.c getcommand.c getttyloc.c args.c whois.c
X
X222	Monday, June 6, 1988 PM Phil (bucsf)
X	Make finguser() table driven!!!
X	File:
X		finger.c
X
X223	Wednesday, June 8, 1988 Phil
X	Rename /process to /pid. Document.  Create PID_COL:
X	display pid in own column (crowds personal name) if defined.
X	File:
X		finger.c switch.h
X
X**************** Begin version 2
X
X300	Wednesday, June 15, 1988 Phil
X	Prepped for Beta.  Updated all Copyrights, man page dates.
X	Move DOC and SITE text into README.
X	Kill locname.h move stuff to local.h, autoconfig.
X	Make Install a sh file, preprocess with cpp (renamed Install.cpp)
X	Fix day 1 bug in outchar (tab accounting (we do this twice!!)
X	Files:
X		COPYRIGHT Copying finger.1 ttyloc.1 nttyloc.5 fingerd.8c
X		Install.cpp ymakefile Makefile
X		autoconfig ttyloc.c locname.c output.c
X
X**** Beta release!!
X
X301	Wednesday, June 15, 1988 Phil
X	Fix tar build to exclude SAMPLE*.h (avoid doubles)
X	Invoke symdate and make-version with ./
X		Allow supression of "same" (NEVER_SAME) (Fuat@columbia)
X	Flush locname once and for all. Check for /usr/var under ultrix
X		(mkhaw@teknowledge-vaxc.arpa)
X	Allow suppression of "What" field (SUPPRESS_WHAT) (henry@garp)
X	Files:
X		Install.cpp ymakefile autoconfig finger.c
X
X302	Sunday, June 26, 1988 Phil
X	Add ALWAYS_PRINT_HEADER, DONT_TAB_PLAN (fuat)
X	Use LOADADDR on VAXen (Stu Grossman@Stanford)
X	Create HZUP macro for hosts only, create PRESERVE_HOST_CASE (Stu)
X	and uppercase[] table.  Use in zup, strupcpy.
X	Print "No one logged in." when needed.
X	Files:
X		finger.c whois.c read_vmunix.c finger.h doremote.c
X		getttyloc.c whois.c undomain.c string.c ymakefile
X	New:
X		upper.h upper.c
X
X303	Tuesday, July 6, 1988 Phil
X	Ran thru comdef to comment all #else and #endifs (Fuat)
X
X304	Friday, July 8, 1988 Phil
X	Monday, July 11
X	Use fprintf for help, feed thru pager.
X	Print copyright and version along with help.
X	File:
X		switch.c
X
X**** Second Beta release!!
X
X305	Monday, July 25, 1988 Phil
X	rename PRESERVE_HOST_CASE to UPCASE_HOSTS and swap sense of test.
X	(host case preservation is now the default)
X	File:
X		finger.h
X
X306	Wednesday, July 27, 1988 Phil
X	Fix sense of ALWAYS_PRINT_HEADER.  Display last modification
X	date of plan.  Add telnet.gw to daemons under ultrix
X	Files:
X		finger.c whois.c daemon.c
X
X307	Friday, July 29, 1988	Phil
X	Sunday, July 31, 1988
X	Port to SunOS 4.0 (sos4_0) on bu-pub a sun4
X	Files:
X		readpr.c ustruct.c getcommand.c syms.h pr.h
X		autoconfig Install.cpp
X
X310	Monday, August 29, 1988	Phil
X	Use kvm library under sos4_0
X	(but not for struct proc, or nlist)
X	Files:
X		getcommand.c kmem.h names.c ustruct.c
X		kmem.c readpr.c ymakefile
X
X311	Monday, September 19, 1988 Phil
X	Various cleanup; add some forwards (thanks to gcc 1.25)
X	Make edit 310 work on non SOS4.0. Use enum in ttyask.
X	Files:
X		ttyask.c ustruct.c ttyloc.c names.c
X		getttyloc.c args.c
X
X312	Monday, October 24, 1988 Phil
X	Check for pty named ttyv0 under Ultrix, remove leading
X	pound sign and spaces from ttyent comments.  Add dtermd (?)
X	to daemons list.
X	Files:
X		getttyloc.c readttylocfile.c daemon.c
X
X313	Wednesday, October 26, 1988 Phil
X	Use switch in finger(). Add \ quoting. Don't stomp on prog.
X	Increment sp after & copy loop in makeperson()
X	Fix some Ultrix typos.
X	Files:
X		args.c getperson.c
X		autoconfig daemon.c readttylocfile.c
X
X314	Saturday, November 12, 1988	Phil
X	Port to Road Runner (sun 386i); Allow for alternate symbol
X	forms under COFF.  Add cmdtool to daemons list (4.0 sunview?).
X	read_vmunix does not yet understand COFF.  Add RR to fingerd.
X	Detect NULL in pstr().  Chuck tp_long if NULL.
X	Files:
X		names.c syms.h info.h fingerd.c autoconfig
X		daemon.c finger.c getttyloc.c
X
X315	Sunday, November 13, 1988	Phil
X	Crock console stuff to work for 4.0.  Output consdev... under
X	DEBUGSW.  Always output dev_t's in hex. Document consdev obs.
X	Files:
X		getcommand.c kmem.c readpr.c
X
X316	Tuesday, November 15, 1988	Phil
X	Add selection_svc to list of hidden[].  Create IN_DOT_SERVER
X	in case somone other than sun uses in.telnetd etc.  Flush
X	sos4_0 in favor of SunOS >= 40.  Define KMEMREAD FTYPE
X	ISBADFILE using kvm_t. Have symdate give real exit values.
X	Files:
X		getcommand.c daemon.c autoconfig daemon.c kmem.h
X		kmem.c readpr.c ustruct.c fingerd.c pr.h syms.h
X		getcommand.c symdate.c
X
Xmonths pass...
X
X317	Thursday, February 2, 1989	Phil
X	Clean up in autoconfig. Use $T $RD etc for testing.
X	Port to Ultrix 3.0; VOIDSIG (was SunOs >= 40), and P_TTYP.
X	Add S_HELD for yux.
X	Files:
X		autoconfig readpr.c pr.h
X
X320	Thursday, February 16, 1989	Phil
X	Clear lastpr in getcommand()
X	File:
X		getcommand.c
X
X321	Tuesday, February 22, 1989	Phil
X	Fix ttyask symlink in Install.cpp
X	File:
X		Install.cpp
X
X322	Friday, March 3, 1989		Phil
X	Port to Sony News. Very clean 4.3!!
X	Punt in pstr before togoal()!
X	Files:
X		finger.c fingerd.c getttyloc.c read_vmunix.c
X
X323	Wednesday, April 26, 1989	Phil
X	Back from the Yucatan, Mex.
X	Update Copyrights again!  This time use GNU General
X	Public Licence Version 1. RCS-ified (1.1)
X	Files:
X		The known world
X
X324	Wednesday, April 26, 1989	Phil
X	Shorten KIT name for S5!
X	File:
X		ymakefile
X
X325	Sunday, May 21, 1989		Phil
X	Port to DEC PMAX. Ran comdef on *.c. Removed UMAP1/2 code
X	Files:
X		ustruct.c read_vmunix.c fingerd.c
X		autoconfig
X
X326	Monday, May 22, 1989		Phil
X	Use h_errno, h_errlist to report errors!
X	File:
X		doremote.c
X
X327	Sunday, June 11, 1989		Phil
X	Fix long standing bug with explicit finger of remotely logged
X	8 character usernames(!)  in ent_select() found by
X	composer@bucsf
X	File:
X		getent.c
X
X330	Monday, June 12, 1989		Phil
X	Port to SGI/Iris.  First USG system with the necessary tools
X	(job control and GNU Emacs)! myecho no longer needed.
X	Files:
X		Makefile acct.c getttyloc.c readpr.c autoconfig
X		getut.c make-version switch.c finger.c info.h myecho.c
X		syms.h fingerd.c kmem.c names.c getcommand.c kmem.h
X		pr.h ustruct.c getent.c lastlog.c read_vmunix.c
X		ymakefile ttyloc.c ttyask.c getent.c daemon.c
X
X	New:
X		mywhoami.c uptime.c COMDEFALL DIFFALL
X
X331	Wednesday, June 14, 1989	Phil
X	Port back from SGI Clean up system include files in
X	readpr/getcommand/ustruct Compiles on SOS3, SOS4, SGI.  Defend
X	against missing h_errno.  Add new daemon names for SGI.  Try
X	to convert dotted octets to hostname or netname (checkhost).
X	Lookup terminal location for last logout terminal.  If stdout
X	not a terminal use unlimited output width.  Create strings.h
X	to ease ports to other USG systems.
X	Files:
X		daemon.c doremote.c finger.c readpr.c undomain.c
X		ustruct.c getcommand.c output.c readttylocfile.h
X
X	New:
X		strings.h CHECKINALL
X
X332	Thursday, June 15, 1989		Phil
X	Killed unused vars found with gcc -W.  What a compiler!
X	Files:
X		ttyask.c fingerd.c switch.c args.c readttylocfile.c
X		readttylocfile.h kmem.c finger.c
X
X333	Tuesday, June 20, 1989		Phil
X	Port to Umax V (Multimax System 5) -- Second USG system
X	Clean up ttyloc.c, fingerd.c, PMAX/ultrix in ustruct.c
X	More gcc induced cleanup (void and int function decls)
X	Files:
X		Makefile acct.c autoconfig doremote.c finger.c
X		fingerd.c getcommand.c getttyloc.c kmem.c mcheck.c
X		names.c output.c pr.h pversion.c readpr.c syms.h
X		ttyloc.c ustruct.c ymakefile
X	Renamed:
X		readttylocfile.[ch] to ttylocfile.[ch]
X
X334	Wednesday, June 21, 1989	Phil
X	Port back to VAX/4.3 and RT/4.3.  Use getpwnam for unmatched
X	SELs under INQUIRE.  Add new switch /noinquire.  Add s_orig to
X	SEL.  Add PUP telser daemon! Weight reduction in readpr and
X	ustruct.  Always use p_addr, flushed MAP, HOG is default.  Use
X	ioctls to get terminal width.  Add U_BADTTY to luser.  Keep
X	last test version/date in README.
X	Files:
X		luser.h daemon.c finger.c output.c readpr.c
X		select.[ch] switch.[ch] symsh.h ustruct.c README
X		
X
X335	Thursday, June 22, 1989		Phil
X	Update finger man page.  Start port to AIX/RT; autoconfig for
X	SHORT_TTYP SYSLOG STREAMS SVR3_STATES PTYPATH PTS_PTY_NAMES.
X	Set SHELL in Makefile! Handle TTY_WID/PER_WID differently.
X	Move STD_{INPUT,OUTPUT} to finger.h. Always read padded
X	ustruct from drum.
X	Files:
X		Makefile finger.h output.c switch.h autoconfig
X		getcommand.c pr.h syms.h finger.1 getttyloc.c readpr.c
X		ttyask.c finger.c names.c switch.c ustruct.c
X
X336	Sunday, June 25, 1989		Phil
X	Use UNDERSCORE_NLIST_NAMES to determine nlist symbol flavor.
X	Move make depend to Makefile, use cc -M; add cc-M from xrn11.
X	Bring back usrpt lossage for ibm032 under NEED_USRPT.  Add
X	NEED_USERMAP for non accel BSD systems.
X	Files:
X		finger.c getcommand.c names.c pr.h syms.h ustruct.c
X		ymakefile Makefile autoconfig kmem.c readpr.c
X
X337	Tuesday, June 27, 1989		Phil
X	Make /follow work locally (at long last!)
X	Fix ttyloc.  Only CHECKINALL locked files!
X	Files:
X		args.c mcheck.c select.c CHECKINALL
X
X340	Sunday, July 9, 1989		Phil
X	Port back to VAX Ultrix 3.0; Fix mail last read time.
X	Files:
X		ymakefile daemon.c finger.c getcommand.c
X		mcheck.c output.c ustruct.c
X
X341	Wednesday, July 12, 1989	Phil
X	Port back to Umax 4.2 (no ttyp).  Use ut_pid under S5 and
X	kill(2) to verify utmp entries!  Works on sgi and Umax V.
X	Files:
X		getcommand.c getut.c
X
X342	Wednesday, July 26, 1989	Phil
X	output \r in fingerd. ansify newmanifest. Add DONT_SAY_HACKING
X	in whois(). make split uuencodes of compressed tar. Make
X	net_name a routine. use h_addr_list, display Trying...  use
X	net_name for remote fingers.
X	Files:
X		ymakefile fingerd.c newmanifest.c
X		whois.c undomain.c doremote.c
X
X
X343	Tuesday, August 1, 1989		Phil
X	Now works on IBM PC-RT/AIX.  If /usr/mail exists use it.
X	Files:
X		ustruct.c autoconfig
X
X344	Saturday, September 9, 1989	Phil
X	Check for NULL in pcount()
X	File:
X		finger.c
X
X345	Wednesday, November 15, 1989	Phil
X	Add /noplan
X	File:
X		finger.c args.c flag.h switch.c switch.h finger.1
X
X346	Friday, December 1, 1989	Phil
X	Update for Umax V 2.2g
X	Files:
X		autoconfig ustruct.c readpr.c
X
X347	??? Phil
X	Start working on per-user flags.
X	Particularly force /match for local names in .forward!!
X	Files:
X		args.c doremote.c
X
X350	Friday, January 12, 1990	Phil
X	Port to Interactive 386/ix SVR3.2; Put all ustruct include in
X	ustruct.h; Check modes in autoconfig with checkmode.c
X	Files:
X		autoconfig Makefile ymakefile
X		ustruct.c getcommand.c readpr.c 
X	New:
X		checkmode.c ustruct.h
X
X351	Friday, January 12, 1990	Phil
X	Reimplement select.c using lists, flush select.h
X	Implement per-user switches (only /match for now)
X	Files:
X		args.c select.c
X	Flushed:
X		select.h
X
X352	Friday, January 12, 1990	Phil
X	Add struct flags to luser struct
X	Do make depend while building xmakefile
X	Files:
X		finger.c getcommand.c getent.c getperson.c getttyloc.c
X		luser.c mcheck.c output.c select.c whois.c whoj.c
X		Makefile ymakefile
X
X353	Tuesday, January 30, 1990	Phil
X	Flush args.m4, etc, rename flags struct, Flags to
X	switches, Sw.  Remove old inquire (and INQUIRE define).
X	Major cleanup in select.c
X	Flushed:
X		args.m4 flags.h
X	New:
X		args.h	
X	Files:
X		ymakefile args.c finger.c getent.c getttyloc.c inquire.h
X		inquire.c luser.h mcheck.c select.c switch.c finger.1
X
X354	Tuesday, April 24, 1990	Phil
X	Only make depend when building programs. Added DEPEND hack.
X	Fix kit/dist. Update Copyrights to 1990, remove some
X	boilerplate, use RCS Id rather than Header. Ran COMDEFALL.
X	Checked in as RCS version 2.0
X	Files:
X		Makefile ymakefile README autoconfig
X
X355	Wednesday, April 25, 1990 3AM	Phil
X	Touchups for UmaxV and AIX
X	Files:
X		Makefile ymakefile autoconfig readpr.c ustruct.h cc-M
X
X356	Wednesday, April 25, 1990 6PM	Phil
X	Touchups for SGI/Irix and Ultrix 3.1 (per jdh)
X	Files:
X		ustruct.c ustruct.h output.c getttyloc.c
X
X357	Wednesday, April 25, 1990 8PM	Phil
X	Moved make depend work back to x/ymakefile
X	Files:
X		Makefile ymakefile
X
X360	Thursday, April 26, 1990 -
X	Wednesday, May 2, 1990		Phil
X	Fixes to Install.cpp from spike@world.std.com;
X	Implement finger.conf file!!
X	Flushed:
X		acct.c
X	New:
X		conf.c finger.conf.5 finger.conf
X	Files:
X		Install.cpp Makefile args.c autoconfig doremote.c
X		finger.c getcommand.c getperson.c output.c undomain.c
X		whois.c ymakefile
X
X361	Tuesday, May 8, 1990		Phil
X	Port to SunOS 4.1, Make SunOS define 3 digits!!
X	Files:
X		autoconfig daemon.c fingerd.c getcommand.c getttyloc.c
X		kmem.c kmem.h luser.h output.c pr.h readpr.c syms.h
X		ustruct.c ustruct.h README
X
X362	Thursday, May 17, 1990		Phil
X	Port to Sequent S3, add ORIG to kit.
X	New:
X		ORIG
X	Files:
X		DIFFALL README autoconfig fingerd.c read_vmunix.c
X		ustruct.c ymakefile
X
X363	Friday, May 18, 1990		Phil
X	Port back to Celerity, cleanup fingerd
X	Files:
X		autoconfig fingerd.c README
X
X364	Sunday, May 20, 1990		Phil
X	Define Umax as 42 or 43 in preparation for release 4.0
X	Use stat of /dev/tty15 in onlat(). Define and use AIX_RT
X	Files:
X		autoconfig fingerd.c getcommand.c getttyloc.c kmem.c
X		names.c read_vmunix.c readpr.c ustruct.c ustruct.h
X
X365	Monday, May 21, 1990 -
X	Monday, June 4, 1990		Phil
X	Port to AIX3 on the IBM RS/6000
X	Files:
X		args.c autoconfig daemon.c finger.c fingerd.c getcommand.c
X		getttyloc.c output.c readpr.c ustruct.c ustruct.h whois.c
X		ymakefile
X
X366	Tuesday, May 29, 1990 -
X	Monday, June 4, 1990		Phil
X	Merge back changes for AIX 1.1 PS/2 port.
X	Have not tested ustruct2() code. Add "make quick"
X	Files:
X		Makefile autoconfig fingerd.c getut.c ustruct.c ustruct.h
X
X367	Thursday, June 14, 1990		Phil
X	Port to Umax 4.3 (rel 4.0).
X	Files:
X		autoconfig getcommand.c output.c
X		read_vmunix.c readpr.c ustruct.c ymakefile
X
X
X370	Friday, June 29, 1990		Phil
X	Fix display of last login host.  Do checkhost() in lltime(),
X	pass back host flag to prevent tty line lookup!!  If local
X	host is a suffix of remote host remove entire thing!!  Change
X	" Account: " display to " Group: ".
X	Files:
X		undomain.c lastlog.c finger.c
X
X**************** Start version 3
X
X400	Friday, July 6, 1990		Phil
X	Ran COMDEF, checked all files in as 3.0
X	Status "Rel", tag "rel1"
X
X**************** released to comp.sources.unix
X
X******** DONT FORGET TO UPDATE VERSION NUMBER BELOW!! (IN OCTAL) ********/
X
Xstruct _JBVER ver = { 0, 03, 0, 0400 };	/* who, major, minor, edit */
END_OF_History.h
if test 31479 -ne `wc -c <History.h`; then
    echo shar: \"History.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f getttyloc.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"getttyloc.c\"
else
echo shar: Extracting \"getttyloc.c\" \(16826 characters\)
sed "s/^X//" >getttyloc.c <<'END_OF_getttyloc.c'
X/*
X * getttyloc.c -- get tty location for finger (December 1985)
X *
X * Copyright (C) 1988, 1990  Philip L. Budne
X *
X * This file is part of "Phil's Finger Program".
X *
X * This program is free software; you can redistribute it and/or modify
X * it under the terms of the GNU General Public License as published by
X * the Free Software Foundation; either version 1, or (at your option)
X * any later version.
X *
X */
X
X# ifndef lint
Xstatic char *rcsid = "$Id: getttyloc.c,v 3.0 90/07/06 13:10:53 budd Rel $";
X# endif /* lint not defined */
X
X/*
X *	This is pretty ad hoc and ugly.  To add a new flavor of
X *	display you need to take care of two cases; With and without
X *	user string (long and short displays)
X *
X *	TODO:
X *
X *	User ttylocs are stored per tty in a spool area.  Having the
X *	user strings stored in a file containing an array of structs,
X *	would save disk space.
X *
X *	Keeping ALL information (default short, long; current short,
X *	long) in a central, binary file would save CPU in addition.
X *	This way random programs (ie; supdup) could get the correct,
X *	full ttyloc.
X *
X *	This could be done without tracking logins by date stamping
X *	the user set and login dependant info (host, network, deamon)
X *	The finger and ttyloc could update entries via set gid access.
X *	(requies file and/or record locking?)
X *
X *	Use sprintf less!!
X *
X *	Could search cdevsw for ltaopen and ptcopen rather than using
X *	LATPATH and PTYPATH
X */
X
X# ifndef X10_STR
X# define X10_STR "X10"			/* if no "screen" number */
X# endif /* X10_STR not defined */
X
X# ifndef X11_STR
X# define X11_STR "X"			/* if have "screen" number */
X# endif /* X11_STR not defined */
X
X# include <sys/types.h>
X# include <sys/stat.h>
X# include <strings.h>
X# include <ctype.h>
X# include <stdio.h>
X# include "finger.h"
X# include "person.h"
X# include "args.h"			/* before luser.h */
X# include "luser.h"
X# include "ttylocfile.h"
X# include "daemon.h"
X# include "pr.h"
X
X# ifdef USG
X# include <sys/sysmacros.h>		/* for major() macro */
X# endif /* USG defined */
X
X# ifdef ultrix
X# ifdef USE_DEVIOCGET
X# include <sys/file.h>
X# include <sys/ioctl.h>
X# include <sys/devio.h>
X# else  /* USE_DEVIOCGET not defined */
XLOCAL int latmajor = -1;
X# define LATPATH "/dev/tty15"
X# endif /* USE_DEVIOCGET not defined */
X# endif /* ultrix defined */
X
X# ifndef DEFAULT_DAEMON
X# define DEFAULT_DAEMON "Virtual Terminal" /* NVT (host but no daemon found) */
X# endif /* DEFAULT_DAEMON not defined */
X
X/* for console window on Suns */
X# ifndef SMALL_CONSOLE
X/* # define SMALL_CONSOLE " [cons]"	/**/
X# define SMALL_CONSOLE " [console]"	/* enuf room for this! */
X# endif /* SMALL_CONSOLE not defined */
X
X# ifndef BIG_CONSOLE
X# define BIG_CONSOLE " [console]"
X# endif /* BIG_CONSOLE not defined */
X
X# ifndef PTYPATH
X# define PTYPATH "/dev/ttyp1"		/* path for known pty-tty */
X# endif /* PTYPATH not defined */
X
X# ifdef Umax
X# include <netdb.h>			/* for struct hostent */
X# include <sys/socket.h>		/* for AF_INET */
X# endif /* Umax defined */
X
X# define USERLEN 32			/* max length of user string */
X# define LOCLEN 48			/* max length of ttyloc string */
X
XLOCAL char location[LOCLEN];		/* return value goes here */
XLOCAL char userstr[USERLEN];		/* user string (if any) here */
XLOCAL int ptymajor = -1;		/* major device number for tty/pty */
XLOCAL int readfile;			/* ture if we have read LOCFILE */
X
XEXTERN char *zup(), *cleanup();		/* from string.c */
XEXTERN char *locname();			/* from locname.c */
XEXTERN char *netlocname();		/* from locname.c */
X
X# ifdef sun
XEXTERN dev_t consdev, rconsdev;		/* current and real console devs */
X# define ISCONS(d) (d == consdev && consdev != rconsdev)
X# else  /* sun not defined */
X# define ISCONS(d) 0			/* smart compilers will remove this */
X# endif /* sun not defined */
X
XLOCAL BOOL onapty( u )
X    LUSER *u;
X{
X    struct stat stb;
X
X    if( ptymajor == -1 ) {		/* first time? */
X	if( stat(PTYPATH, &stb) == 0 )
X	    ptymajor = major( stb.st_rdev );
X	else {
X	    ptymajor = -2;
X	    return( FALSE );
X	}
X    } /* first time? */
X
X    if( ptymajor > 0 && ptymajor == major( u->u_ttydev ) )
X	return( TRUE );
X    return( FALSE );
X} /* onapty */
X
X# ifdef ultrix
XLOCAL BOOL onlat( u )
X    LUSER *u;
X{
X# ifdef USE_DEVIOCGET
X/* This is soooo dumb.
X * - Requires a fd (so only works when have write access to ttys!)
X * - returns *STRINGS*
X * - **FAILS** on pty's (Not a typewriter!)
X *
X * What twinkies.
X *
X * This will only be of any use if finger runs setuid to root.
X * (setgid group tty is pointless, since finger needs group kmem
X * as well).  This is not (known to be) dangerous, just tasteless!
X *
X * Probably better to just put all LAT lines (!) into /etc/(n)ttyloc.
X */
X    int fd, flag;
X    char path[ 32 ];
X    struct devget dg;
X    static int checked = FALSE, notty = FALSE;
X
X    strcpy( path, "/dev/" );
X    strcat( path, u->u_line );
X
X    if( !checked ) {			/* check if we have a tty */
X	if( (f = open( "/dev/tty", 1)) >= 0 )
X	    close( f );			/* yes we do */
X	else
X	    notty = TRUE;		/* we don't */
X	checked = TRUE;
X    }
X
X    if( (fd = open (argv[i], O_RDONLY|O_NDELAY)) < 0 &&
X       (fd = open (argv[i], O_WRONLY|O_NDELAY)) < 0 )
X	return( FALSE );
X
X    flag = ioctl( fd, DEVIOCGET, &dg ) == 0 &&
X	strcmp( dg.interface, DEV_LAT ) == 0;
X
X    (void) close( fd );
X
X    /* flush tty association -- so fingerd doesn't get attached!! */
X    if( notty && (fd = open( "/dev/tty", 1)) >= 0 ) { /* if no tty */
X	ioctl( fd, TIOCNOTTY, 0 );	/* flush assoc with one */
X	close( f );			/* we just opened */
X    }
X
X    return( flag );
X# else  /* USE_DEVIOCGET not defined */
X    if( latmajor == -1 ) {		/* first time? */
X	if( stat(LATPATH, &stb) == 0 )
X	    latmajor = major( stb.st_rdev );
X	else {
X	    latmajor = -2;
X	    return( FALSE );
X	}
X    } /* first time? */
X
X    if( latmajor > 0 && latmajor == major( u->u_ttydev ) )
X	return( TRUE );
X    return( FALSE );
X# endif /* USE_DEVIOCGET not defined */
X} /* onlat */
X# endif /* ultrix defined */
X
XGLOBAL void inittylocs() {
X    if( !readfile ) {
X	readfile = 1;
X	if( readnewttylocfile() < 1 ) {
X	    int i;
X	    i = readttylocfile();
X# ifdef TTYENT
X	    if( i < 1 )
X		i = readttyents();
X# endif /* TTYENT defined */
X	}
X    } /* try reading a ttyloc file */
X} /* inittylocs */
X
XGLOBAL char *getttyloc( u )		/* return ttyloc string */
X    LUSER *u;
X{
X    int f, cc;			/* file */
X    char *fname, *shortstr, *longstr;
X    TTYLOC *tp;
X
X    userstr[0] = EOS;
X    if( !readfile )
X	inittylocs();
X
X    if( !u->u_sw.sw_location ) {
X	fname = locname(u->u_line); /* try to find file in spool area */
X	if( (f = open(fname, 0)) >= 0 ) {
X	    struct stat stb;
X	    if( fstat(f, &stb) == 0 && stb.st_mtime > u->u_time ) {
X# ifdef DEBUG
X		puts(fname);
X# endif /* DEBUG defined */
X		cc = read(f, userstr, USERLEN-1);
X		if( cc > 0 )
X		    userstr[cc] = EOS;
X	    } /* fstat and recent */
X	    close(f);
X	    cleanup(userstr);
X	} /* fname open */
X
X# ifdef OTTYLOC				/* old style per user ttyloc */
X	/* try ~/.ttyloc file -- this could be cached in the luser struct */
X	if( userstr[0] == EOS && u->u_person != NULL) {
X	    strcpy(fname, u->u_person->p_home);
X	    strcat(fname, "/.ttyloc");
X	    if( (f = open(fname, 0)) >= 0 ) {
X		cc = read(f, userstr, USERLEN-1);
X		userstr[cc] = EOS;
X	    }
X	    close(f);
X	    cleanup(userstr);
X	} /* no userstr yet, have person */
X# endif /* OTTYLOC defined */
X    } /* not sw_location */
X
X    shortstr = longstr = NULL;
X
X    if( u->u_host[0] != EOS )
X	checkhost( u->u_host, sizeof( u->u_host ) );
X# ifdef Umax
X     else if( u->u_ttyaddr != 0 ) {
X	struct hostent *hp;
X	if( (hp = gethostbyaddr( &u->u_ttyaddr,
X				sizeof( u->u_ttyaddr ), AF_INET )) != NULL )
X	    strzcpy( u->u_host, hp->h_name, sizeof( u->u_host ) - 1 );
X	else
X	    strzcpy( u->u_host, inet_ntoa( u->u_ttyaddr ) );
X    } /* no host */
X# endif /* Umax defined */
X
X    if( u->u_host[0] != EOS ) {		/* have host? */
X	register char *cp;
X
X# ifndef NO_X_WINDOWS
X	int display_number, decnet_display, screen_number;
X# define NOT_FOUND -1
X	display_number = screen_number = NOT_FOUND;
X
X	/* This botches on XNS addresses net:addr */
X	if( (cp = index(u->u_host, ':')) != NULL ) { /* host:display */
X	    *cp++ = EOS;		/* blast first ':' */
X
X	    if( *cp == ':' ) {		/* second ':' ? (DECnet) */
X		cp++;			/* advance. */
X		decnet_display = TRUE;
X	    } /* second ':' */
X	    else
X		decnet_display = FALSE;
X
X	    if( isdigit( *cp ) ) {	/* digits after ':'? */
X		display_number = 0;
X		do
X		    display_number = display_number * 10 + *cp++ - '0';
X		while( isdigit(*cp) );
X
X		if( *cp == '.' ) {	/* display terminated by DOT? */
X		    screen_number = 0;	/* X11 "screen number" */
X		    cp++;		/* skip dot */
X
X		    while( isdigit(*cp) )
X			screen_number = screen_number * 10 + *cp++ - '0';
X		} /* collect screen */    
X	    } /* digits after ':' */
X	} /* found : */
X# endif /* NO_X_WINDOWS not defined */
X
X	if( userstr[0] != EOS ) {	/* have user str? */
X	    undomain( u->u_host, TRUE ); /* remove domains and prefixes */
X
X	    longstr = userstr;
X	    shortstr = NULL;
X
X# ifndef NO_X_WINDOWS
X	    if( display_number != NOT_FOUND ) {
X		char screen[ 15 ];
X		if( screen_number != NOT_FOUND && screen_number != 0 )
X		    sprintf( screen, ".%d", screen_number );
X		else
X		    screen[0] = EOS;
X
X		sprintf(location, "%s:%s%d%s",
X			u->u_host,
X			(decnet_display ? ":" : ""),
X			display_number,
X			screen );
X		shortstr = location;
X	    } /* display != -1 */
X# endif /* NO_X_WINDOWS not defined */
X# ifdef Umax
X	    else if( u->u_ttyaddr != 0 ) {
X		register int i;
X		char *lt;
X		static char *ltt[] = {
X		    "", "lp",		/* BSD style driver */
X		    "V", "Vlp" };	/* SYSV style */
X
X		i = u->u_ttytype;
X		if( i < 1 || i-1 > ( sizeof( ltt ) / sizeof( char * ) ) )
X		    lt = "??";
X		else
X		    lt = ltt[ i-1 ];
X		sprintf(location, "%s_%s%d", /* A la ANF-10 !*/
X			HZUP( u->u_host ),
X			lt,
X			u->u_ttynum );
X		shortstr = location;
X	    } /* ttyaddr != 0 */
X# endif /* Umax defined */
X# ifdef ultrix
X	    else if( onlat( u ) )
X		shortstr = "LAT";
X# endif /* ultrix defined */
X	    else
X		shortstr = HZUP( u->u_host );
X	} /* host and user str */
X	else {				/* host, no user string */
X	    undomain( u->u_host, FALSE ); /* just remove domains */
X# ifndef NO_X_WINDOWS
X	    if( display_number != NOT_FOUND ) { /* have x display number */
X		char screen[ 15 ], *xv;	/* X11 */
X		screen[0] = EOS;
X		xv = X10_STR;
X		if( screen_number != NOT_FOUND ) {
X		    xv = X11_STR;
X		    if( screen_number != 0 )
X			sprintf( screen, " screen %d",
X				screen_number ); /* woof */
X		}
X# ifdef X_LOCAL
X		if( casecmp( u->u_host, "UNIX" ) )
X		    sprintf( location, "Local %s display %d%s%s",
X			    xv, display_number, screen,
X			    (ISCONS(u->u_ttydev) ? SMALL_CONSOLE : "") );
X		else
X# endif /* X_LOCAL defined */
X		    sprintf(location, "%s (%s%s display %d%s)%s",
X			    u->u_host,	/* zup'ed already */
X			    (decnet_display ? "DECnet " : ""), /* we use TCP */
X			    xv, display_number, screen,
X			    (ISCONS(u->u_ttydev) ? SMALL_CONSOLE : "") );
X		return( location );
X	    } /* have display number */
X	    else
X# endif /* NO_X_WINDOWS not defined */
X# ifdef Umax
X	    if( u->u_ttyaddr != 0 ) {	/* host, no user, is annex device */
X		register int i;
X		char *lt;
X		static char *ltt[] = {
X		    "port", "lp",	/* BSD devices */
X		    "Vport", "SYSV lp"	/* SYS V devices */
X		    };
X
X# ifdef NETLOC
X		int f;
X		char portname[ 50 ];
X
X		sprintf( portname, "%s:port%d", u->u_host, u->u_ttynum );
X		fname = netlocname( portname );
X		if( (f = open(fname, 0)) >= 0 ) {
X		    struct stat stb;
X		    if( fstat(f, &stb) == 0 && stb.st_mtime > u->u_time ) {
X			cc = read(f, userstr, USERLEN-1);
X			userstr[cc] = EOS;
X		    }
X		    close(f);
X		    cleanup(userstr);
X		    if( userstr[0] != EOS )
X			return( userstr );
X		} /* open ok */
X# endif /* NETLOC defined */
X
X		i = u->u_ttytype;
X		if( i < 1 || i-1 > ( sizeof( ltt ) / sizeof( char * ) ) )
X		    lt = "??";
X		else
X		    lt = ltt[ i-1 ];
X
X		sprintf(location, "%s (Annex Call) %s%d",
X			HZUP( u->u_host ),
X			lt,
X			u->u_ttynum );
X		return( location );
X	    } /* host, no user str, is annex */
X	    else
X# endif /* Umax defined */
X# ifdef ultrix
X	    else if( onlat( u ) ) {	/* host, no user str, LAT */
X		sprintf( location, "%s (LAT)", HZUP( u->u_host ) );
X		return( location );
X	    } /* host, no user str, LAT */
X# endif /* ultrix defined */
X	    {				/* host, nothing unusual */
X		char *dp;
X		if( u->u_daemon != NULL )
X		    dp = u->u_daemon->d_long;
X		else if( u->u_daemonp != NULL &&
X			u->u_daemonp->pr_cmd[0] != EOS )
X		    dp = u->u_daemonp->pr_cmd;
X		else
X		    dp = DEFAULT_DAEMON;
X		sprintf( location, "%s (%s)", HZUP( u->u_host ), dp );
X		return( location );
X	    } /* host, nothing unusual */
X	} /* host, no user string */
X    } /* have host */
X    else if( onapty( u ) ) {		/* is pty, no host */
X	if( userstr[0] != EOS ) {	/* pty, no host, user string */
X	    if( u->u_daemon != NULL )
X		shortstr = u->u_daemon->d_short;
X	    else if( u->u_daemonp != NULL &&
X		    u->u_daemonp->pr_cmd[0] != EOS )
X		shortstr = u->u_daemonp->pr_cmd;
X	    else if( ISCONS(u->u_ttydev) )
X		shortstr = "CONS";
X	    else
X		shortstr = "PTY";	/* sigh */
X	    longstr = userstr;
X	} /* pty, nohost, user string */
X	else if( u->u_daemon != NULL ) { /* pty, nohost, nouser, daemon */
X	    char *cons;
X	    if( ISCONS(u->u_ttydev) )	/* pty nohost nouser daemon cons */
X	        cons = SMALL_CONSOLE;
X	    else
X	        cons = "";
X	    sprintf( location, "via %s%s", u->u_daemon->d_long, cons );
X	    return( location );
X	} /* pty, nohost, nouser, daemon entry */
X	else if( u->u_daemonp != NULL && u->u_daemonp->pr_cmd[0] != EOS ) {
X	    /* pty, nohost, nouser, daemon process (not in daemon table) */
X	    char *cons;
X	    if( ISCONS(u->u_ttydev) )
X		cons = BIG_CONSOLE;
X	    else
X		cons = "";
X	    sprintf( location, "child of %s%s", u->u_daemonp->pr_cmd, cons );
X	    return( location );
X	} /* pty, nohost, nouser, daemon process */
X	else if( ISCONS(u->u_ttydev) )	/* pty, nohost, nouser, nodaemon, con*/
X	    return( "Pseudo Console" );
X# ifndef NO_X_WINDOWS
X	else if( strcmp( u->u_line, "ttyv0" ) == 0 )
X	    return( "X login window");
X# endif /* NO_X_WINDOWS not defined */
X	else				/* pty, nohost, nouser, nodae, nocon */
X	    return( "Pseudo Terminal" );
X    } /* is pty */
X# ifdef ultrix
X    else if( onlat( u ) ) {		/* no host, LAT */
X	if( userstr[0] == EOS )		/* LAT, no host, no userstr */
X	    return( "via LAT" );
X	else
X	    shortstr = "LAT";
X    } /* LAT, no host */
X# endif /* ultrix defined */
X    else {				/* normal line (no host, no pty) */
X# ifdef NETLOC
X	if( userstr[0] == EOS ) {	/* normal line, no userstr */
X	    fname = netlocname(u->u_line); /* try to find file in spool area */
X	    f = open( fname, 0 );
X	    if( f >= 0 ) {
X		struct stat stb;
X		if( fstat(f, &stb) == 0 && stb.st_mtime > u->u_time ) {
X		    cc = read(f, userstr, USERLEN-1);
X		    userstr[cc] = EOS;
X		}
X		close(f);
X		cleanup( userstr );
X	    } /* opened file */
X	} /* no userstr */
X# endif /* NETLOC defined */
X
X	if( (tp = findttyloc( u->u_line )) != NULL ) { /* get from file */
X	    if( userstr[0] != EOS ) {	/* found ttyloc, have userstr */
X		shortstr = tp->t_short;
X		longstr = userstr;
X	    } /* found ttyloc, have userstr */
X	    else if( tp->t_locn != NULL )
X		return( tp->t_locn );
X	    /* fall back on t_short??? WISH */
X	} /* found tp entry */
X# ifdef UmaxV
X	else if( u->u_line[0] == 'r' && u->u_line[1] == 't' ) {
X	    /* mls rdp device; rtAAPPSS */
X	    if( userstr[0] == EOS ) {
X		if( strlen( u->u_line ) == 7 ) {
X		    char session[ 10 ];
X		    
X		    if( u->u_line[6] != '0' )
X			sprintf( session, " session %c",
X				u->u_line[6] );
X		    else
X			session[0] = EOS;
X
X		    sprintf( location, "annex %c%c port %c%c%s",
X			    u->u_line[2], u->u_line[3],
X			    u->u_line[4], u->u_line[5],
X			    session );
X		    return( location );
X		}
X		else
X		    return( "annex RDP connection" );
X	    }
X	    else
X		shortstr = "annex";	/* "RDP" */
X
X	}
X	else if( u->u_line[0] == 'R' && u->u_line[1] == 'T' ) {
X	    /* mls rdp device RTxxxxx for unknown annex */
X	    if( userstr[0] == EOS ) {
X		sprintf( location, "foreign annex %s",
X			u->u_line+2 );
X		return( location );
X	    }
X	    else
X		shortstr = "annex";
X	}
X# endif /* UmaxV defined */
X	else if( userstr[0] != EOS )
X	    return( userstr );
X    } /* normal line (no host, no user) */
X
X    if( longstr == NULL ) {
X	if( strcmp( u->u_line, "console" ) == 0
X# ifdef AIX3
X	    || strcmp( u->u_line, "hft/1" ) == 0
X# endif /* AIX3 defined */
X	    )
X	    longstr = "Console Terminal"; /* physical console */
X    }
X
X    if( shortstr != NULL ) {		/* have short string */
X	if( longstr != NULL ) {
X	    /* was once ':' */
X	    sprintf( location, "%s; %s", shortstr, longstr );
X	    return( location );
X	}
X	else
X	    return( shortstr );
X    } /* short str */
X    else if( longstr != NULL )
X	return( longstr );
X    return( "Unknown" );
X} /* getttyloc */
X
X/*
X * Local variables:
X * comment-column: 40
X * End:
X */
END_OF_getttyloc.c
if test 16826 -ne `wc -c <getttyloc.c`; then
    echo shar: \"getttyloc.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 7 \(of 7\).
cp /dev/null ark7isdone
MISSING=""
for I in 1 2 3 4 5 6 7 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 7 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

