[comp.unix.microport] v01i001: help.shar - Source for a help command

plocher@uwspan.UUCP (John Plocher) (12/27/87)

[ I split the submitted file up, tested it, RCS'd it, modified it to use the
env vars HELPDIR and HELPFILE if it could, generated a Makefile and man page,
and then shar'd it up again.  -John ]

:
#!/bin/sh
#    This is a shell archive created by yasa (1.72jmp).
#    Run the following text with /bin/sh to extract.
#
#    Archive: /u/microport/src/help/help.shar        
#
#    This archive is a complete distribution by itself.
#
#    Packed under system5 by plocher@uwspan (John Plocher)
#    Packed on Sat Dec 26 23:50:21 1987
#

YASASTART=`pwd`

echo x - README
if [ -s README ]	# exists & size>0
then
    echo "shar: will not overwrite 'README'"
else
    sed "s/^X//" << \!SHAR-EOF! > README
XSubject: 286 Source: A Help Command for systems with limited disk space
XMessage-Id: <8712221357.AA29111@killer.UUCP>
XDate: 22 Dec 87 13:57:22 CST (Tue)
X
XRCSINFO: $Header: README,v 1.0 87/12/18 18:22:29 wnp Posted $
X
XThe enclosed is a "help" command, patterned after the help command
Xdistributed with MKS Toolkit -- in fact, if you have the Toolkit,
Xyou could use their helpfile as a starting point for a UNIX SysV
Xhelpfile.
X
XIf you don't have the Toolkit, you can construct a helpfile by
Xgleaning short command descriptions from your manual, and adding
Xthem to "/usr/lib/helpfile", according the the pattern of the partial
Xhelpfile shown below.
X
XI find this help command more useful than the help system distributed with
XSystem V, especially on machines with limited disk space, where it is not
Xpractical to keep the manuals on-line.
X
XThe program uses an indexfile, /usr/lib/helpindex, to speed up access;
Xif the indexfile does not exist, or is older than /usr/lib/helpfile (indicating
Xthat the helpfile has been updated), the program will build a new indexfile.
X
XCompile normally, (small model on Uport V/286), then invoke as "help". The
Xprogram should be owned by root and suid, so it can write in /usr/lib (to
Xrecreate the index file as needed.).
X
XThe helpfile below consists of those help entries which I have added to
Xthe MKS Toolkit file to use with my UNIX system. I do not feel free to
Xpost the MKS helpfile, since it is no doubt (c) by MKS.
X
XPut the helpfile into /usr/lib/helpfile, or change the references thereto in
Xhelp.c.
X
XSince I do not have a shar program handy (I'm not posting this on my machine)
XI have manually concatenated the helpfile and help.c. Look for lines beinning
Xwith a few dashes to find the end of one and beginning of the other file.
X
XI hope this is helpful. Civil and constructive comments are invited to
Xihnp4!killer!dcs!wnp, flames should be directed to /dev/null.
X
XWolf N. Paul
Xihnp4!killer!dcs!wnp
X
!SHAR-EOF!
if [ "`wc -c README`" != "   1937 README" ]
then
echo '   README may be bad'
fi
fi
echo x - help.man
if [ -s help.man ]	# exists & size>0
then
    echo "shar: will not overwrite 'help.man'"
else
    sed "s/^X//" << \!SHAR-EOF! > help.man
X.TH LA LOCAL "System V"
X.SH NAME
Xhelp \- Provide brief command explanations
X.\" $Header: help.man,v 1.1 87/12/26 23:35:34 plocher Posted $
X.SH SYNOPSIS
X.B help
X[
X.B command
X]
X.SH DESCRIPTION
X.I Help
Xprints out a quick explanation of a command.
X.SH INSTALLATION
XThe
X.B Makefile
Xprovides entries for automatically installing (and un-installing) this
Xpackage. 
XYou need to be root to install 
X.I "help.@@"
X.I Make install
Xwill completely install the needed files in the appropriate directories
Xwith the needed permissions and ownership.
X.I Make uninstall
Xwill remove the effects of 
X.I make install.
X.SH BUGS
X.PP
XIf you have the MKS Toolkit, you could use their helpfile as a starting
Xpoint for a UNIX SysV helpfile.
X.PP
XIf you don't have the Toolkit, you can construct a helpfile by
Xgleaning short command descriptions from your manual, and adding
Xthem to the helpfile, according the the pattern of the partial
Xhelpfile provided.
X.SH FILES
X.nf
X    /usr/lib/helpfile	default datafile containing help info
X
X    $HELPDIR		Environment variable - directory for helpfile
X    $HELPFILE		Environment variable - alternate name for helpfile
X.fi
X.SH AUTHORS
X.nf
X    Original Author:
X	uwmacc!harvard!killer!wnp (Wolf Paul)
X    
X    Environment variable handling by:
X	plocher@uwspan.uucp (John Plocher)
X
!SHAR-EOF!
if [ "`wc -c help.man`" != "   1289 help.man" ]
then
echo '   help.man may be bad'
fi
fi
echo x - Makefile
if [ -s Makefile ]	# exists & size>0
then
    echo "shar: will not overwrite 'Makefile'"
else
    sed "s/^X//" << \!SHAR-EOF! > Makefile
X#
X# Makefile for Help command
X#
X#	By:		$Author: plocher $  (John Plocher)
X#			$Revision: 1.0 $
X#	Last modified:	$Date: 87/12/26 23:34:30 $
X#	Source is in:	$Source: /u/microport/src/help/RCS/Makefile,v $
X#
X#	Release state:	$State: Posted $
X#
X# Modification Log
X# ----------------
X#
X# $Log:	Makefile,v $
X# Revision 1.0  87/12/26  23:34:30  plocher
X# Initial revision
X# 
X#
X#	$Header: Makefile,v 1.0 87/12/26 23:34:30 plocher Posted $
X#
X
XSHELL=/bin/sh
X
X# Where you put your local binaries...
XLOCAL= /usr/local
XHELPDIR= /usr/lib
X
Xall:	help
X
Xhelp:	help.o
X	cc -o help help.o
X
Xinstall: all
X	chown root help
X	chmod 755 help
X	chmod u+s help
X	if [ -f /usr/bin/help ] ; then  mv /usr/bin/help /usr/bin/help.SV ; fi
X	rm -f $(LOCAL)/help
X	cp help $(LOCAL)
X	chown root helpfile
X	chmod 644 helpfile
X	install -c $(HELPDIR) helpfile
X
Xuninstall:
X	rm -f $(LOCAL)/help $(HELPDIR)/helpfile $(HELPDIR)/helpfile.idx
X
Xclean:
X	rm -f help.o help
!SHAR-EOF!
if [ "`wc -c Makefile`" != "    919 Makefile" ]
then
echo '   Makefile may be bad'
fi
fi
echo x - helpfile
if [ -s helpfile ]	# exists & size>0
then
    echo "shar: will not overwrite 'helpfile'"
else
    sed "s/^X//" << \!SHAR-EOF! > helpfile
X# version
X$Header: helpfile,v 1.1 87/12/26 23:35:43 plocher Posted $
X# atob, btoa
Xbtoa, atob -- encode/decode binary to printable ASCII
XUsage:  btoa < infile > outfile
X        cmd | btoa > outfile
X	atob infile
XBtoa is a filter that reads anything from the standard input, and encodes it
Xinto printable ASCII on the standard output.  It also attaches a header and
Xchecksum information used by the reverse filter atob to find the start of the
Xdata and to check integrity.
X
XAtob reads an encoded file, strips off any leading and trailing lines added
Xby mailers, and recreates a copy of the original file on the standard
Xoutput.  Atob gives NO output (and exits with an error message) if its input
Xis garbage or the checksums do not check.
X# chmod
Xchmod -- change file modes
XUsage:	chmod mode file ...
X
XMode can be either SYMBOLIC or OCTAL.
X
XSYMBOLIC MODES:
X	[who] op perm
X
Xwho:	`u' (user), `g' (group), `o' (others); `a' is equivalent to `ugo';
X
Xop:	+ adds permission, - removes permission, = sets absolute permissions
X
Xperm:	`r' read, `w' write, `x' execute (or search for directories);
X	Super-User only:
X	`s' set UID or set GID; `t' save text/sticky bit.
X
XOCTAL MODES:
X
X	These are constructed by ORing the appropriate modes from this list:
X	
X	4000	Set UID (Superuser only)
X	2000	Set GID (Superuser only)
X	1000	Sticky Bit (Superuser only)
X	0400	Read by Owner
X	0200	Write by Owner
X	0100	Execute by Owner
X	0070	Read, Write, Execute by Group
X	0007	Read, Write, Execute by Others
X# chown
Xchown, chgrp -- change owner or group
XUsage:  chown user file(s)
X	chgrp group file(s)
X
XUser and Group can be either a numerical UID or GID, or a login or group
Xname found in the /etc/passwd and /etc/group files.
X
XOnly the owner of a file (or the Superuser) can change the owner or group
Xof that file.
X# col
Xcol -- convert reverse and half line feeds from nroff
XUsage:  col [-f -b -x -p] [file(s)]
X-f      output device can perform forward half line feeds
X-b      output device is cannot backspace
X-x      do not output tabs for multiple spaces
X-p      let unrecognized escape sequences (other than ESC 7, ESC 8, and
X        ESC 9) pass.
XCol is used to print nroff output on devices that cannot perform forward and
Xreverse half line motions or reverse line feeds, as is the case with most
Xsimple printers and CRT terminals. If no files are given, col reads standard
Xinput.
X# cu
Xcu -- call another UNIX system
XUsage:	cu [-s speed] [-l line] [-h] [-t] [-d] [-o|e] [-n] telno
X	cu [-s speed] [-h] [-d] [-o|e] -l line
X	cu [-h] [-d] [-o|e] systemname
X-s	Specify transmission speed (300, 1200, 2400, 4800, 9600);
X-l	Specify a line to be used
X-h	Emulate local echo (half duplex)
X-t	Map newline to CR/LF for ascii terminals
X-d	Print diagnostic traces
X-o	Generate odd parity on outgoing data
X-e	Generate even parity on outgoing data
X-n	Prompt for telephone number
X
XCommands start with `~' in the first column of a line:
X~.	terminate the conversation
X~!	escape to interactive shell on local system
X~!cmd	run cmd locally (via sh -c)
X~$cmd	run cmd locally and send its output to remote system
X~%cd	change directory on local system
X~%take	copy file1 on remote system to file2 on the local system.
X	If file2 is not specified, the file will have the same name on the
X	local system as on the remote system.
X~%put	copy file1from the local system to file2 on the remote system.
X	If file2 is not specified, the file will have the same name on the
X	remote system as on the local system.
X~~line	send the line "~line" to the remote system (to execute a cu command on
X	the remote system)
X~%break	transmit a BREAK to the remote system
X~%debug	toggle debug option on/off
X~t	print the values of the termio structure variables for the user's
X	terminal
X~l	print the values of the termio structure variables for the remote
X	communications line
X~%nostop  toggle between XON/XOFF input control protocol and no input control
X# help
Xhelp -- provide brief command explanations
XUsage:	help [command]
XLooks in $HELPDIR/$HELPFILE (/usr/lib/ and helpfile are the defaults) for
Xexplanations of a command.
X# lp, cancel
Xlp, cancel -- send/cancel requests to an LP device
XUsage:	lp [-c] [-d dest] [-m] [-n num] [-o opt] [-s] [-t title] [-w] [file(s)]
X	cancel [ids] [devices]
X-c	Copy files immediately instead of linking
X-d	Choose dest as the printer or class of printers to do the printing.
X-m	Send mail after files have been printed
X-n	Print num copies
X-o	Specify printer-dependent options
X-s	Suppress messages from lp such as "request id is ..."
X-t	Print title on the banner page of the output
X-w	Write a message on the user's terminal when files have been printed.
XCancel cancels line printer requests that were made with the lp command.
XThe commandline arguments may be either request ids as returned by lp without
Xthe -s option, or printer names (for a complete list do "lpstat").
X# lpstat
Xlpstat -- print LP status information
XUsage:	lpstat [options]
X-a list	Print acceptance status (with respect to lp) of destinations for
X	requests. "List" is a list of intermixed printer and class names.
X-c list	Print class names and their members. "List" is a list of class names.
X-d	Print the default destination for lp.
X-o list	Print the status of output requests. "List" is a list of intermixed
X	printer names, class names, and request ids.
X-p list	Print the status of printers. "List" is a list of printer names.
X-r	Print the status of the LP request scheduler.
X-s	Print a status summary
X-t	Print all status information
X-u list	Print status of output requests for users. "List" is a list of login
X	names.
X-v list	Print the names of printers and the pathnames of devices associated
X	with them. "List" is a list of printer names.
XIf "list" is omitted in the above options, all information relevant to the
Xoption letter will be printed.
X# mail, mailx
Xmail, mailx -- electronic mail programs
XUsage:	mail		# to check for mail
X	mailx
X	mail user	# to send mail to user
X	mailx user
XThe options and commands for these two programs are too numerous
Xto list here. See the manual entries and tutorials if you need more information
Xthan shown above.
X# mesg
Xmesg -- permit or deny messages
XUsage:	mesg [-n] [-y]
X-n	Forbid messages via write(1)
X-y	Allow messages via write(1)
XWithout options, mesg reports the current status.
X# more
Xmore -- file browser
XUsage:	more file(s)
X# newgrp
Xnewgrp -- log in to a new group
XUsage:	newgrp [-] [group]
XInvokes a new shell with the group id set to the specified group.
XWith argument `-', newgrp sets up the environment as if the user had
Xactually logged in again as a member of the specified group.
XWithout arguments, the group id is set back to that specified in /etc/passwd.
X# nice
Xnice -- run a command at a low priority
XUsage:	nice [-increment] command [arguments]
XNice executes command with a lower CPU scheduling priority. If no "increment"
Xargument is given, a default of 10 is used.
XOnly the Superuser may run commands with higher-than-usual priority by using
Xa negative increment (e.g. --10).
X# nohup
Xnohup - run a command immune to hangups and quits
XUsage:	nohup command [arguments]
XIf nohup should apply to several commands, they should be placed in a file
Xand invoked as "nohup sh commandfile".
XIf the output from "command" is not redirected by the user, it will be placed
Xinto a file nohup.out in the current or HOME directory of the user.
X# nroff
Xnroff -- text formatter for line printer devices
XUsage:  nroff [options] [files]
X-olist  print only pages listed; ranges are allowed
X-nN     number first page N
X-sN     stop every N pages to allow paper loading or
X        changing. Resume upon receipt of a newline.
X-raN    set register a (must be one-character name) to N.
X-i      read standard input after files are exhausted
X-q      invoke the simultaneous input-output mode of the .rd request
X-z      print only messages generated by .tm (terminal message) requests
X-mname	prepend to the input files the the non-compacted (ASCII text) macro file
X	located in /usr/lib/tmac/tmac.name
X-cname	prepend to the input files the compacted macro files located in
X	/usr/lib/macros/cmp.[nt].[dt].name and 
X	/usr/lib/macros/ucmp.[nt].name.
X-kname	Compact the macros used in this invocation of nroff, placing the output
X	in files [dt].name in the current directory. 
X-Tname  prepare output for device name. Known names are 37 (Teletype 37,
X        default), ascii (generic ascii printer w/o reverse linefeed),
X        ansi (ansi or vt100 terminal), fx80 (Epson FX-80 printer),
X        8510 (NEC 8510/C.Itoh dot matrix printer), 3550 (NEC Spinwriter),
X        lp (generic ascii printer with reverse linefeed)
X-e      produce equally-spaced words in adjusted lines, using full device
X        resolution
X-h      use output horizontal tabs to speed output and reduce output character
X        count. Does not work with all printers.
X-wn     set the embolding factor for Font 3 to n, or to zero if n is missing.
X# otroff
Xotroff -- text formatter for Wang Laboratories C/A/T photo typesetter
XUsage:  otroff [options] [files]
X-olist  print only pages listed; ranges are allowed
X-nN     number first page N
X-sN     stop every N pages to allow paper loading or
X        changing. Resume when typesetter's start button is pressed.
X-raN    set register a (must be one-character name) to N.
X-i      read standard input after files are exhausted
X-q      invoke the simultaneous input-output mode of the .rd request
X-z      print only messages generated by .tm (terminal message) requests
X-mname	prepend to the input files the the non-compacted (ASCII text) macro file
X	located in /usr/lib/tmac/tmac.name
X-cname	prepend to the input files the compacted macro files located in
X	/usr/lib/macros/cmp.[nt].[dt].name and 
X	/usr/lib/macros/ucmp.[nt].name.
X-kname	Compact the macros used in this invocation of otroff, placing the output
X	in files [dt].name in the current directory. 
X-t	Direct output to the standard output instead of the phototypesetter.
X-f	Refrain from feeding out paper and stopping the phototypesetter at the
X	end of the run.
X-w	Wait until phototypesetter is ready, if it is currently busy.
X-b	Report on busy/ready status of phototypesetter. No text processing
X	is done.
X-a	Send a printable ASCII approximation of the result to the standard
X	output.
X-pN	print all characters in point size N while retaining all prescribed
X	spacings and motions, to reduce phototypesetter elapsed time.
X-Tcat	Use font-width tables for Wang C/A/T phototypesetter. This is both
X	the default and the only choice.
X# ps
Xps -- display process status
XUsage:	ps [options]
X-e	Print information about all processes
X-d	Print information about all processes, except process group leaders
X-a	Print information about all processes, except process group leaders
X	and processes not associated with a terminal
X-f	Generate a full listing
X-l	Generate a long listing
X-cfile	Use the specified core file instead of /dev/mem
X-sdev	Use the specified swap device instead of /dev/swap
X-nfile	Use specified file instead of /unix
X-tlist	Restrict listing to processes associated with terminals given in list.
X-plist	Restrict listing to processes whose PIDs are given in list.
X-ulist	Restrict listing to processes whose UIDs or LOGNAMEs are given in list.
X-glist	Restrict listing to processes whose GIDs or GROUP names are given in
X	list.
X# sleep
Xsleep -- suspend execution for a specified time
XUsage:	sleep seconds
X# strip
Xstrip -- remove symbol table from COFF executable files
XUsage:	strip [-l] [-x] [-r] [-V] file ...
X-l	Strip line number information only; do not strip symbol table
X-x	Do not strip static or external symbol information
X-r	Reset relocation indexes
X-V	Print strip Version information to standard error.
XIf executed on an ar(1) archive, the archive symbol table will be removed.
X# stty
Xstty - set terminal characteristics and options
XUsage:	stty [-a] [-g] [options]
X-a	Report all current settings
X-g	report current settings in a form that can be used as arguments
X	for another stty command.
XCONTROL MODES:
Xparenb (-parenb)	enable (disable) parity generation & detection
Xparodd (-parodd)	select odd (even) parity
Xcs5 cs6 cs7 cs8		select character size (data bits)
X0 110 300 600 1200 1800 2400 4800 9600
X			select baudrate. 0 hangs up phone immediately.
Xhupcl (-hupcl)		hangup (don't hangup) dataphone on last close
Xhup (-hup)		same as hupcl (-hupcl)
Xcstopb (-cstopb)	use two (one) stop bits per character
Xcread (-cread)		enable (disable) the receiver
Xclocal (-clocal)	assume a line without (with) modem control
Xloblk (-loblk)		block (don't block) output from non-current layer
XINPUT MODES:
Xignbrk (-ignbrk)	ignore (don't ignore) break on input
Xbrkint (-brkint)	signal (don't signal) INTR on break
Xignpar (-ignpar)	ignore (don't ignore) parity errors
Xparmrk (-parmrk)	mark (don't mark) parity errors
Xinpck (-inpck)		enable (disable) input parity checking
Xistrip (-istrip)	strip (don't strip) input characters to 7 bits
Xinlcr (-inlcr)		map (don't map) NL to CR on input
Xigncr (-igncr)		ignore (don't ignore) CR on input
Xicrnl (-icrnl)		map (don't map) CR to NL on input
Xiuclc (-iuclc)		map (don't map) upper case to lower case on input
Xixon (-ixon)		enable (disable) XON/XOFF output control
Xixany (-ixany)		allow any character (only XON) to restart output
Xixoff (-ixoff)		request that system send (not send) XON/XOFF
X			characters when input queue is nearly empty/full.
XOUTPUT MODES
Xopost (-opost)		post-process output (do not post-process output; ignore
X			all other output modes)
Xolcuc (-olcuc)		map (don't map) lower case to upper case on output
Xonlcr (-onlcr)		map (don't map) NL to CR-NL on output
Xocrnl (-ocrnl)		map (don't map) CR to NL on output
Xonocr (-onocr)		do not (do) output CR at column 0
Xonlret (-onlret)	on the terminal, NL performs (doesn't perform) the
X			RETURN function
Xofill (-ofill)		use fill characters (use timing) for delays
Xofdel (-ofdel)		fill characters are DELs (NULs)
Xcr0 cr1 cr2 cr3		set style of delay for CRs
Xnl0 nl1			set style of delay for LFs
Xtab0 tab1 tab2 tab3	set style of delay for horizontal tabs
Xbs0 bs1			set style of delay for backspaces
Xff0 ff1			set style of delay for formfeeds
Xvt0 vt1			set style of delay for vertical tabs
X
XLOCAL MODES
Xisig (-isig)		enable (disable) interpretation of special control
X			characters INTR, QUIT, ans  SWTCH.
Xicanon (-icanon)	enable (disable) canonical input (ERASE and KILL
X			processing)
Xxcase (-xcase)		canonical (unprocessed) upper/lower case presentation
Xecho (-echo)		echo back (don't echo back) every character typed
Xechoe (-echoe)		echo (don't echo) ERASE as a backspace-space-backspace
X			string
Xechok (-echok)		echo (don't echo) NL after KILL character
Xlfkc (-lfkc)		same as echok (-echok) -- obsolete.
Xechonl (-echonl)	echo (don't echo) NL
Xnoflsh (-noflsh)	disable (enable) flush after INTR, QUIT, or SWTCH
Xstwrap (-stwrap)	disable (enable) truncation of lines longer than 79
X			characters on a synchronous line
Xstflush (-stflush)	enable (disable) flush on synchronous line after every
X			write(2)
Xstappl (-stappl)	use application mode (use line mode) on a synchronous
X			line
X
XCONTROL ASSIGNMENTS
Xcontrol-char c		set control-char to c, where control-char is one of:
X			erase, kill, intr, quit, swtch, eof, ctab, min, or time
X			If c is preceded by an (escaped from the shell) caret
X			(^), then the value used is the corresponding CTRL 
X			character (e.g. "^d" is CTRL-D); "^?" is DEL.
Xline i			set line discipline to i ( 0 < i < 127 ).
X
XCOMBINATION MODES
Xevenp or parity		parenb cs7
Xoddp			parenb cs8 parodd
X-parity			-parenb cs8
X-evenp			-parenb cs8
X-oddp			-parenb cs8
Xraw (-raw or cooked)	enable (disable) raw input and output (no ERASE, KILL,
X			INTR, QUIT, SWTCH, EOT, or output post processing).
Xnl (-nl)		unset (set) icrnl, onlcr. In addition, -nl unsets
X			inlcr, igncr, ocrnl, and onlret.
Xlcase (-lcase)		set (unset) xcase, iuclc, and olcuc.
XLCASE (-LCASE)		same as lcase (-lcase)
Xtabs (-tabs or tab3)	preserve (expand to spaces) tabs when printing
Xek			set ERASE and KILL characters back to # and @.
Xsane			reset all modes to some reasonable values
Xterm			set all modes suitable for the terminal type term,
X			where term is one of tty33, tty37, vt05, tn300, ti700,
X			or tek.
X
XIF THIS FLASHED BY QUICKER THAN YOU COULD READ IT, TRY IT AGAIN LIKE THIS:
X
X	help stty | more
X
X# su
Xsu -- become super-user or another user
XUsage:	su [-] [name [arg ...]]
X-	If the first argument to su is `-', the environment will be changed
X	to what it would be if the user actually logged in as "name".
Xname	If name is given, become that user. If no name is given, become
X	root (e.g. the super-user).
Xarg	Optional arguments are passed to the shell invoked by su.
X	Thus, "su - bin -c command args" executes "command" with the temporary
X	environment and permissions of user "bin".
X# tput
Xtput - query terminfo database
XUsage:	tput [-Ttype] capname [parms...]
X-Ttype	indicates the type of terminal. Normally unnecessary, since
X	the default is taken from the environment variable TERM.
Xcapname	indicates the attribute (capabilitry) from the terminfo database
Xparms	if the capability needs parameters, the argument parms will be
X	instantiated into the string.
X# troff
Xtroff, ditroff -- text formatter for typesetters and other high-resolution
X		  output devices
XUsage:	troff [options] [files]
X-o list	Print only pages whose numbers appear in "list".
X-nN	Number first page generated N.
X-sN	Generate output to encourage typesetter to stop every N pages
X-mname	Prepend the macro file /usr/lib/tmac/tmac.name to the input files.
X-raN	Set register a (one-character name) to N.
X-i	Read standard input after the input files are exhausted.
X-q	Invoke the simultaneous input-output mode of the .rd request
X-z	Print only messages generated by the .tm request
X-a	Send a printable ASCII approximation of the results to the standard
X	output.
X-Tdest	Prepare output for typesetter dest. 
X# true
Xtrue, : , false -- provide truth values
XUsage:	: [argument ...]
X	true [argument ...]
X	false
XTrue and : do nothing, successfully. False does nothing, unsuccessfully.
X: is also used as a magic number for Bourne or Korn shell scripts in a
XC-Shell environment.
X# tty
Xtty -- get name of terminal
XUsage:	tty [-l] [-s]
X-l	print synchronous line number if the terminal is on an active
X	synchronous line
X-s	prevent printing of tty pathname, return result as a return code.
X	2 - invalid options; 0 - if tty is a terminal; 1 - otherwise
X# umask
Xumask -- set file-creation mode mask
XUsage:	umask [ooo]
XWithout an argument, umask prints the current value of the mask.
XWith argument, umask sets the mask to the value specified by the three-digit
Xoctal number. See help entry for chmod for legal values.
X# write
Xwrite -- write to another user
XUsage:	write user [line]
XIf you want to write to a user who is logged in more than once,  the 
X"line" argument may be used to direct which terminal to write to.
XPermission to write may be denied or granted by the use of mesg(1).
XDuring a write session, a line starting with ! will cause the rest
Xof that line to be passed to the shell as a command.
XTerminate a write session with your INTR or EOF character.
X
!SHAR-EOF!
if [ "`wc -c helpfile`" != "  19018 helpfile" ]
then
echo '   helpfile may be bad'
fi
fi
echo x - help.c
if [ -s help.c ]	# exists & size>0
then
    echo "shar: will not overwrite 'help.c'"
else
    sed "s/^X//" << \!SHAR-EOF! > help.c
X/*
X * Name:    help.c
X * Purpose: display help about commands & system features
X * Syntax:  help [cmd]
X * Comment: Help displays help screens on all user commands
X *          as set up in the file /usr/lib/helpfile.
X *          It is particularly useful on systems with restricted 
X *          diskspace, where it is not practical to keep the manuals
X *          on-line.
X *          The command is patterned after the MKS Toolkit command
X *          of the same name. If no /usr/lib/helpindex file exists, or if
X *          it is older than the helpfile, a new helpindex will be
X *          created to allow faster access to the helpscreens by
X *          means of fseek().
X *          Desirable enhancements would include the possibility to
X *          have help look in an environment variable HELPFILE for
X *          an alternate or additional helpfile,
X *              [ Done by John Plocher - uses HELPDIR to set the directory
X *              where the help file and its index are.  It also uses HELPFILE
X *              to give the name of the data file ($HELPFILE.idx is the index)
X *              defaults are "/usr/lib" and "helpfile" ]
X *          and/or to have help look in $HOME/.helpfile if a command
X *          is not found in the default helpfile.
X *          Another useful feature would be the possibility of using
X *          a pager specified by $PAGER to output the help info, since
X *          a few entries (stty, vi, ...) are longer than one screen.
X *          No doubt the coding could be considerably improved, and
X *          any suggestions would be more than welcome.
X * Author:  Wolf Paul, ihnp4!killer!dcs!wnp
X * Date:    Dec. 18, 1987
X *
X *	Revision Control Information
X *
X *	Last edited by:	$Author: plocher $
X *			$Revision: 1.1 $
X *	Last modified:	$Date: 87/12/26 23:34:50 $
X *	Source is in:	$Source: /u/microport/src/help/RCS/help.c,v $
X *
X *	Release state:	$State: Posted $
X *
X * Modification Log
X * ----------------
X *
X *	$Log:	help.c,v $
X *	Revision 1.1  87/12/26  23:34:50  plocher
X *	Added enviroment variables for HELPDIR and HELPFILE
X *	
X */
X
X#ifndef lint
X    static char rcsid[] =
X     "$Header: help.c,v 1.1 87/12/26 23:34:50 plocher Posted $";
X#endif
X
X#include <stdio.h>
X#include <ctype.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#define MAXLINE 	134
X#define HELPDIR		"/usr/lib"		/* Added by John Plocher */
X#define HELPFILE	"helpfile"		/* .. */
X#define INDEX		".idx"			/* .. */
X
Xchar helpfilename[128];		/* John Plocher */
Xchar helpidxname[128];		/* .. */
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X	struct
X	{
X		char name[15];
X		long offset;
X	} entry;				/* helpindex entries for each command */
X
X	struct stat sbuf1, sbuf2;	/* stat buffers for helpfile & helpindex */
X	char *command, *line, Line[MAXLINE];
X	register char	*cp;		/* John Plocher */
X	extern char	*getenv();		/* .. */
X	int status;
X	FILE *ifp, *hfp;		/* file pointers for helpfile and helpindex */
X	
X	if ( argc == 1 )		/* If no arguments, ... */
X		command = "help";	/* ... default to "help help" */
X	else
X		command = argv[1];	/* else look for command in argv[1] */
X
X
X	/*		Added by John Plocher Sat Dec 26 22:02:09 CST 1987
X	 * Look for:
X	 *	getenv("HELPDIR") + getenv("HELPFILE")
X	 *	getenv("HELPDIR") + "helpfile"
X	 *	"/usr/lib"		  + getenv("HELPFILE")
X	 *	"/usr/lib"		  + "helpfile"
X	 */
X	if ((cp = getenv("HELPDIR")) != NULL)	/* if a dir is given, use it */
X	    strcpy(helpidxname, cp);
X	else
X		strcpy(helpidxname, HELPDIR);
X	strcpy(helpfilename, helpidxname);
X	strcat(helpfilename, "/");
X
X	if ((cp = getenv("HELPFILE")) != NULL)	/* if a filename is given, use it */
X	    strcat(helpfilename, cp);
X	else
X		strcat(helpfilename, HELPFILE);
X
X	strcpy(helpidxname, helpfilename);		/* make a name for the index file */
X	strcat(helpidxname, INDEX);
X
X	stat(helpfilename, &sbuf1);	/* get mtime for helpfile */
X	status=access(helpidxname, 0);
X	if ( status == 0 )	/* if helpindex exists ... */
X	{
X		stat(helpidxname, &sbuf2);	/* get mtime for helpindex */
X	}
X	if ( (status != 0) || 			/* if there is no helpindex ... */
X		((time_t)sbuf1.st_mtime > (time_t)sbuf2.st_mtime) )
X									/* or if it is older than helpfile */
X	{
X		buildindex();		/* build a new helpindex */
X	}
X
X	if ( (ifp=fopen(helpidxname, "r")) == NULL )
X	{
X		fprintf(stderr, "Can't read %s\n", helpidxname);
X		exit(-1);
X	}
X	
X	while ( 1 )		/* look for index entry for "command" */
X	{
X		status=fread(&entry, sizeof(entry), 1, ifp);
X		if ( status==0 ) /* quit at end of index file */
X		{
X			fprintf(stderr, "No help for %s\n", command);
X			fclose(ifp);
X			exit(1);		}
X		if ( strcmp(entry.name, command) == 0 ) /* quit when we find it */
X		{
X			fclose(ifp);
X			break;
X		}
X	}
X
X	if ((hfp=fopen(helpfilename, "r")) == NULL )
X	{
X		fprintf(stderr, "Can't open %s\n", helpfilename);
X		exit(-1);
X	}
X
X	fseek(hfp, entry.offset, 0);	/* go to the help entry */
X
X	while ( 1 )			/* just copy lines to stdout */
X	{
X		line = fgets(Line, MAXLINE, hfp);
X		if ( line == (char *) NULL || line[0] == '#' )
X						/* until another entry starts */
X			break;
X		fputs(line,stdout);
X	}
X
X	fclose(hfp);
X}
X
Xbuildindex()
X{
X	FILE *hfp, *ifp;
X	struct {
X		char name[15];
X		long offset;
X	} entry;
X	char Line[MAXLINE];
X	char *line;
X	int i,j;
X
X
X	unlink(helpidxname); /* remove old index file */
X	if ( (hfp=fopen(helpfilename, "r")) == NULL )
X	{
X		fprintf(stderr,"buildindex: Can't read %s\n", helpfilename);
X		exit(-1);
X	}
X	if ( (ifp=fopen(helpidxname, "w")) == NULL )
X	{
X		fprintf(stderr, "buildindex: Can't write %s\n", helpidxname);
X		exit(-1);
X	}
X
X	while (1)	/* Read thru helpfile ... */
X	{
X		entry.offset=(long) 0;
X		line = fgets(Line, MAXLINE, hfp);
X		if ( line == (char *) NULL ) break;
X		if ( line[0] == '#' )	/* and for each help entry ... */
X		{
X			line++;
X			while ( isspace(line[0]) ) line++;
X			i=j=0;
X			while ( line[i] != '\0' )
X			{
X				if ( line[i] == '\n' ) break;
X				while ( line[i] == ' ' || line[i] == ',' ) i++;
X				while ( !isspace(line[i] ) &&
X						line[i] != ',') /* save its name ... */
X				{
X					entry.name[j] = line[i];
X					i++; j++;
X				}
X				while ( j < 15 )
X					entry.name[j++] = '\0';
X				j = 0;
X				entry.offset=ftell(hfp);	/* and its offset ... */
X				fwrite(&entry, sizeof(entry), 1, ifp);
X										/* and write it to indexfile */
X			}
X		}
X	}
X	fclose(hfp);
X	fclose(ifp);
X}
!SHAR-EOF!
if [ "`wc -c help.c`" != "   6250 help.c" ]
then
echo '   help.c may be bad'
fi
fi
-- 
Email to microport-request@uwspan for info on the newsgroup comp.unix.microport,
otherwise mail to microport@uwspan with a Subject: line  containing one of:
    6300+, 386, 286, Bug, Source, Merge, "Send Buglist", or "Send Version"
(UUCP: ...!uwvax!uwspan!microport & ...!uwvax!uwspan!microport-request)

-- 
Email to microport-request@uwspan for info on the newsgroup comp.unix.microport,
otherwise mail to microport@uwspan with a Subject: line  containing one of:
    6300+, 386, 286, Bug, Source, Merge, "Send Buglist", or "Send Version"
(UUCP: ...!uwvax!uwspan!microport & ...!uwvax!uwspan!microport-request)