Replacement for man(1) (part 1 of 2)

John W. Eaton jwe at che.utexas.edu
Mon Jan 7 08:24:12 AEST 1991


This distribution includes man(1), apropos(1), whatis(1), and
manpath(1).  I wrote these mostly because Ultrix man(1) doesn't
understand multiple man page directory trees, and because I wanted to
be able to choose whatever pager program I wanted.  If you use these
programs, I hope you find them useful.  If you encounter bugs, please
forward reports directly to me.  I can't guarantee that I'll be able
to fix them, but I'll give it a shot :-).

This man(1) has all kinds of neat features that other versions of
man don't, including support for multiple man page directory trees,
preformatted man pages, and troff.  It is distributed under the terms
of the GNU copyleft.

If you compile with support for preformatted man pages, man(1) will
try to update the preformatted page if the man page source is newer.

If you compile with support for troff, you can say things like
`man -t foo | psdit > foo.ps' and have fabulous printed documentation
as well.

These files are also available via anonymous ftp from che.utexas.edu
(128.83.162.5).  Please limit your use of this service to off hours.

Cheers,

John W. Eaton
jwe at che.utexas.edu
Department of Chemical Engineering
The University of Texas at Austin

-------------------------------cut here-------------------------------
#! /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 1 (of 2)."
# Contents:  man-1.0 man-1.0/COPYING man-1.0/Makefile man-1.0/README
#   man-1.0/TODO man-1.0/apropos.man man-1.0/apropos.sh
#   man-1.0/config.h man-1.0/gripes.c man-1.0/gripes.h
#   man-1.0/makewhatis.sh man-1.0/man.man man-1.0/manpath.c
#   man-1.0/manpath.config man-1.0/manpath.h man-1.0/manpath.man
#   man-1.0/ndir.h man-1.0/strdup.c man-1.0/util.c man-1.0/version.h
#   man-1.0/whatis.man man-1.0/whatis.sh
# Wrapped by jwe at andy.che.utexas.edu on Sun Jan  6 15:10:28 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d 'man-1.0' ; then
    echo shar: Creating directory \"'man-1.0'\"
    mkdir 'man-1.0'
fi
if test -f 'man-1.0/COPYING' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/COPYING'\"
else
echo shar: Extracting \"'man-1.0/COPYING'\" \(7742 characters\)
sed "s/^X//" >'man-1.0/COPYING' <<'END_OF_FILE'
X		 GNU EMACS GENERAL PUBLIC LICENSE
X		    (Clarified 11 Feb 1988)
X
X Copyright (C) 1985, 1987, 1988 Richard M. Stallman
X Everyone is permitted to copy and distribute verbatim copies
X of this license, but changing it is not allowed.  You can also
X use this wording to make the terms for other programs.
X
X  The license agreements of most software companies keep you at the
Xmercy of those companies.  By contrast, our general public license is
Xintended to give everyone the right to share GNU Emacs.  To make
Xsure that you get the rights we want you to have, we need to make
Xrestrictions that forbid anyone to deny you these rights or to ask you
Xto surrender the rights.  Hence this license agreement.
X
X  Specifically, we want to make sure that you have the right to give
Xaway copies of Emacs, that you receive source code or else can get it
Xif you want it, that you can change Emacs or use pieces of it in new
Xfree programs, and that you know you can do these things.
X
X  To make sure that everyone has such rights, we have to forbid you to
Xdeprive anyone else of these rights.  For example, if you distribute
Xcopies of Emacs, you must give the recipients all the rights that you
Xhave.  You must make sure that they, too, receive or can get the
Xsource code.  And you must tell them their rights.
X
X  Also, for our own protection, we must make certain that everyone
Xfinds out that there is no warranty for GNU Emacs.  If Emacs is
Xmodified by someone else and passed on, we want its recipients to know
Xthat what they have is not what we distributed, so that any problems
Xintroduced by others will not reflect on our reputation.
X
X  Therefore we (Richard Stallman and the Free Software Fundation,
XInc.) make the following terms which say what you must do to be
Xallowed to distribute or change GNU Emacs.
X
X			COPYING POLICIES
X
X  1. You may copy and distribute verbatim copies of GNU Emacs source code
Xas you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy a valid copyright notice "Copyright
X(C) 1988 Free Software Foundation, Inc." (or with whatever year is
Xappropriate); keep intact the notices on all files that refer to this
XLicense Agreement and to the absence of any warranty; and give any
Xother recipients of the GNU Emacs program a copy of this License
XAgreement along with the program.  You may charge a distribution fee
Xfor the physical act of transferring a copy.
X
X  2. You may modify your copy or copies of GNU Emacs source code or
Xany portion of it, and copy and distribute such modifications under
Xthe terms of Paragraph 1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating
X    that you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish,
X    that in whole or in part contains or is a derivative of GNU Emacs
X    or any part thereof, to be licensed at no charge to all third
X    parties on terms identical to those contained in this License
X    Agreement (except that you may choose to grant more extensive
X    warranty protection to some or all third parties, at your option).
X
X    c) if the modified program serves as a text editor, cause it when
X    started running in the simplest and usual way, to print an
X    announcement including a valid copyright notice "Copyright (C)
X    1988 Free Software Foundation, Inc." (or with the year that is
X    appropriate), saying that there is no warranty (or else, saying
X    that you provide a warranty) and that users may redistribute the
X    program under these conditions, and telling the user how to view a
X    copy of this License Agreement.
X
X    d) You may charge a distribution fee for the physical act of
X    transferring a copy, and you may at your option offer warranty
X    protection in exchange for a fee.
X
XMere aggregation of another unrelated program with this program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other program under the scope of these terms.
X
X  3. You may copy and distribute GNU Emacs (or a portion or derivative of it,
Xunder Paragraph 2) in object code or executable form under the terms of
XParagraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal
X    shipping charge) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XFor an executable file, complete source code means all the source code for
Xall modules it contains; but, as a special exception, it need not include
Xsource code for modules which are standard libraries that accompany the
Xoperating system on which the executable file runs.
X
X  4. You may not copy, sublicense, distribute or transfer GNU Emacs
Xexcept as expressly provided under this License Agreement.  Any attempt
Xotherwise to copy, sublicense, distribute or transfer GNU Emacs is void and
Xyour rights to use GNU Emacs under this License agreement shall be
Xautomatically terminated.  However, parties who have received computer
Xsoftware programs from you with this License Agreement will not have
Xtheir licenses terminated so long as such parties remain in full compliance.
X
X  5. If you wish to incorporate parts of GNU Emacs into other free programs
Xwhose distribution conditions are different, write to the Free Software
XFoundation.  We have not yet worked out a simple rule that can be stated
Xhere, but we will often permit this.  We will be guided by the two goals of
Xpreserving the free status of all derivatives of our free software and of
Xpromoting the sharing and reuse of software.
X
XYour comments and suggestions about our licensing policies and our
Xsoftware are welcome!  Please contact the Free Software Foundation, Inc.,
X675 Mass Ave, Cambridge, MA 02139, or call (617) 876-3296.
X
X			   NO WARRANTY
X
X  BECAUSE GNU EMACS IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
XNO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
XWHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
XRICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE GNU EMACS "AS IS"
XWITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
XBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
XAND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE GNU EMACS
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
XSERVICING, REPAIR OR CORRECTION.
X
X IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL FREE SOFTWARE
XFOUNDATION, INC., RICHARD M. STALLMAN, AND/OR ANY OTHER PARTY WHO MAY
XMODIFY AND REDISTRIBUTE GNU EMACS AS PERMITTED ABOVE, BE LIABLE TO YOU
XFOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR OTHER
XSPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
XINABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
XBEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR A
XFAILURE OF THE PROGRAM TO OPERATE WITH PROGRAMS NOT DISTRIBUTED BY
XFREE SOFTWARE FOUNDATION, INC.) THE PROGRAM, EVEN IF YOU HAVE BEEN
XADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY
XOTHER PARTY.
END_OF_FILE
if test 7742 -ne `wc -c <'man-1.0/COPYING'`; then
    echo shar: \"'man-1.0/COPYING'\" unpacked with wrong size!
fi
# end of 'man-1.0/COPYING'
fi
if test -f 'man-1.0/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/Makefile'\"
else
echo shar: Extracting \"'man-1.0/Makefile'\" \(4084 characters\)
sed "s/^X//" >'man-1.0/Makefile' <<'END_OF_FILE'
X# Makefile for man and manpath
X#
X# Copyright (c) 1991, John W. Eaton.
X#
X# You may distribute under the terms of the GNU General Public
X# License as specified in the README file that comes with the man 1.0
X# distribution.  
X#
X# John W. Eaton
X# jwe at che.utexas.edu
X# Department of Chemical Engineering
X# The University of Texas at Austin
X# Austin, Texas  78712
X
XDISTDIR = man-1.0
X
XTOP = /usr/local
X
XBINDIR = $(TOP)/bin
XLIBDIR = $(TOP)/lib/man
XMANDIR = $(TOP)/man
XMANEXT = 1
X
XMANBINNAME = man
X
X# The file that defines the mapping of bin directories to man
X# directories.  This should match the definition of config_file[] in
X# config.h.
X
XMANPATH_CONFIG_FILE=$(LIBDIR)/manpath.config
X
X# Add these to DEFS if...
X#
X# -DHAS_TROFF		if you have troff installed
X# -DSUPPORT_CAT_DIRS	if you have directories of preformatted man pages
X# -DCHARSPRINTF		if your sprintf returns char *
X# -DSTD_HEADERS		if you have standard headers installed
X# -DALT_SYSTEMS		if you have system specific subdirectories in
X#			your manpath (i.e. /usr/man/sunos/...)
X# -DSTRDUP_MISSING	if your system lacks strdup()
X#
X# Edit and add any of the defs below if you want to override the
X# defaults in config.h.
X#
X# -DMAXPATHLEN=512	maximum number of characters in an absolute filename
X# -DBUFSIZ=1024		input buffers and some other things have this length
X# -DMAXDIRS=64		something more than the maximum number of
X#			directories in the config file 
X
XDEFS = -DSUPPORT_CAT_DIRS -DCHARSPRINTF -DHAS_TROFF -DSTRDUP_MISSING
X
XCC = gcc
XCFLAGS = -Wall -O $(DEFS)
X
Xall: man manpath apropos whatis makewhatis manpages
X
Xmanpath: manpath.c config.h manpath.h gripes.o util.o strdup.o
X	$(CC) $(CFLAGS) -DMAIN -o manpath manpath.c gripes.o util.o strdup.o
X
Xman: man.c config.h gripes.h manpath.c manpath.h gripes.o glob.o \
X	util.o strdup.o
X	$(CC) $(CFLAGS) -o man man.c manpath.c gripes.o glob.o util.o strdup.o
X
Xgripes.o: gripes.h
Xutil.o: gripes.h
X
Xapropos: apropos.sh
X	sed -e 's,LIBDIR,$(LIBDIR),' -e 's,BINDIR,$(BINDIR),' \
X		apropos.sh > apropos
X
Xwhatis: whatis.sh
X	sed -e 's,LIBDIR,$(LIBDIR),' -e 's,BINDIR,$(BINDIR),' \
X		whatis.sh > whatis
X
Xmakewhatis: makewhatis.sh
X	cp makewhatis.sh makewhatis
X
Xinstall: all install.man apropos whatis makewhatis
X	install -c -m 755 man $(BINDIR)/$(MANBINNAME)
X	install -c -m 755 manpath $(BINDIR)/manpath
X	install -c -m 755 apropos $(BINDIR)/apropos
X	install -c -m 755 whatis $(BINDIR)/whatis
X	install -c -m 754 makewhatis $(LIBDIR)/makewhatis
X	install -c -m 644 manpath.config $(LIBDIR)/manpath.config
X
Xmanpages: man.$(MANEXT) manpath.$(MANEXT) apropos.$(MANEXT) whatis.$(MANEXT) 
X
Xman.$(MANEXT): man.man
X	sed -e 's,MANPATH_CONFIG_FILE,$(MANPATH_CONFIG_FILE),' \
X	man.man > man.$(MANEXT)
X
Xmanpath.$(MANEXT): manpath.man
X	sed -e 's,MANPATH_CONFIG_FILE,$(MANPATH_CONFIG_FILE),' \
X	manpath.man > manpath.$(MANEXT)
X
Xapropos.$(MANEXT): apropos.man
X	sed -e 's,MANPATH_CONFIG_FILE,$(MANPATH_CONFIG_FILE),' \
X	apropos.man > apropos.$(MANEXT)
X
Xwhatis.$(MANEXT): whatis.man
X	sed -e 's,MANPATH_CONFIG_FILE,$(MANPATH_CONFIG_FILE),' \
X	whatis.man > whatis.$(MANEXT)
X
Xinstall.man:
X	install -c -m 644 man.$(MANEXT) \
X		$(MANDIR)/man$(MANEXT)/man.$(MANEXT)
X	install -c -m 644 manpath.$(MANEXT) \
X		$(MANDIR)/man$(MANEXT)/manpath.$(MANEXT)
X	install -c -m 644 apropos.$(MANEXT) \
X		$(MANDIR)/man$(MANEXT)/apropos.$(MANEXT)
X	install -c -m 644 whatis.$(MANEXT) \
X		$(MANDIR)/man$(MANEXT)/whatis.$(MANEXT)
X	
Xclean:
X	rm -f *.o *~ core
X
Xspotless: clean
X	rm -f manpath man apropos whatis makewhatis
X	rm -f man.$(MANEXT) manpath.$(MANEXT)
X	rm -f apropos.$(MANEXT) whatis.$(MANEXT) 
X
Xdist:
X	[ -d $(DISTDIR) ] || mkdir $(DISTDIR)
X	cp glob.c gripes.c manpath.c strdup.c util.c $(DISTDIR)
X	cp gripes.h manpath.h ndir.h version.h $(DISTDIR)
X	cp apropos.man man.man manpath.man whatis.man $(DISTDIR)
X	cp apropos.sh whatis.sh makewhatis.sh $(DISTDIR)
X	cp README COPYING TODO $(DISTDIR)
X	cp config.h.dist $(DISTDIR)/config.h
X	cp manpath.config.dist $(DISTDIR)/manpath.config
X	cp Makefile.dist $(DISTDIR)/Makefile
X	(cd $(DISTDIR) ; gawk -f ../fixdist.awk ../man.c > man.c)
X
Xtar.dist: dist
X	tar czvf $(DISTDIR).tar.Z $(DISTDIR)
END_OF_FILE
if test 4084 -ne `wc -c <'man-1.0/Makefile'`; then
    echo shar: \"'man-1.0/Makefile'\" unpacked with wrong size!
fi
# end of 'man-1.0/Makefile'
fi
if test -f 'man-1.0/README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/README'\"
else
echo shar: Extracting \"'man-1.0/README'\" \(2077 characters\)
sed "s/^X//" >'man-1.0/README' <<'END_OF_FILE'
XREADME file for man(1).
X
XThis is a replacement for Un*x man(1), apropos(1), whatis(1), and
Xmanpath(1).  It has all kinds of neat features that other versions of
Xman don't, including support for multiple man page directory trees,
Xpreformatted man pages, and troff.  It is provided without any
Xwarranty whatever.  I hope you find it useful.  It is distributed
Xunder the terms of the GNU copyleft which is described in the file
XCOPYING.
X
XThere is a solution written in perl which is probably superior in
Xevery way, but, like me, you may prefer this one anyway.
X:-)
X
XIf you compile with support for preformatted man pages, man(1) will
Xtry to update the preformatted page if the man page source is newer.
X
XIf you compile with support for troff, you can say things like
X`man -t foo | psdit > foo.ps' and have fabulous printed documentation
Xas well.
X
XThe file ndir.h is included because you might need it to compile glob.c.
X
XThese programs have been tested on a VaxStation 3200 running Ultrix 3.1, 
Xand an Encore Multimax running Umax 4.3, a DEC 5810 running Ultrix 4.0, 
Xand a Convex C-220 running Convex Unix.
X
XINSTALLATION
X
X1. Edit the file config.h to match your site.
X
X2. Edit the manpath.config file.  This determines the system-wide
X   mappings for bin directories and man page directories.
X
X3. Edit the Makefile.  Make sure that all the directories you specify
X   exist -- no checks are made on this.
X
X4. Do a `make all', try it out, and then if you're happy with that, do
X   a `make install'.  You don't need to be root to use this set of
X   programs.
X
X5. Install the whatis database(s) by running makewhatis.  If you want
X   to keep things absolutely current, you'll need to run this whenever
X   you add new man pages.  You might want to add an entry in your
X   crontab. 
X
X
XBUGS
X
XIf you find one of these, please tell me about it.  If you have a fix,
Xthat's even better.  If not, I can't guarantee that I'll fix it, but I
Xwould like to know about them.
X
XJohn Eaton
Xjwe at che.utexas.edu
XDepartment of Chemical Engineering
XThe University of Texas at Austin
XAustin, Texas  78712
END_OF_FILE
if test 2077 -ne `wc -c <'man-1.0/README'`; then
    echo shar: \"'man-1.0/README'\" unpacked with wrong size!
fi
# end of 'man-1.0/README'
fi
if test -f 'man-1.0/TODO' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/TODO'\"
else
echo shar: Extracting \"'man-1.0/TODO'\" \(823 characters\)
sed "s/^X//" >'man-1.0/TODO' <<'END_OF_FILE'
XThings that would be nice but aren't really necessary:
X
X0.  Update the documentation.
X
X1.  Properly handle commands like `man 3f intro' when the name of the
X    file we want is something like .../man3/intro.3f.  The way this is
X    done right now seems sort of kludgey but it mostly works.  See
X    man.c for details.
X
X2.  Malloc everything instead of having fixed limits... Or at least
X    check the limits everywhere.  If you're paranoid about this, make
X    the limits big (famous last words: really, there aren't that many
X    things that could go wrong :-).
X
X3.  Try to do a little better job of memory management.  There are a
X    lot of little temporary strings that are malloc'd and never freed.
X    This is probably ok for a standalone program but not so good if
X    you wanted to call man() from another program.
END_OF_FILE
if test 823 -ne `wc -c <'man-1.0/TODO'`; then
    echo shar: \"'man-1.0/TODO'\" unpacked with wrong size!
fi
# end of 'man-1.0/TODO'
fi
if test -f 'man-1.0/apropos.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/apropos.man'\"
else
echo shar: Extracting \"'man-1.0/apropos.man'\" \(712 characters\)
sed "s/^X//" >'man-1.0/apropos.man' <<'END_OF_FILE'
X.\" Man page for apropos
X.\"
X.\" Copyright (c) 1991, John W. Eaton.
X.\"
X.\" You may distribute under the terms of the GNU General Public
X.\" License as specified in the README file that comes with the man 1.0
X.\" distribution.  
X.\"
X.\" John W. Eaton
X.\" jwe at che.utexas.edu
X.\" Department of Chemical Engineering
X.\" The University of Texas at Austin
X.\" Austin, Texas  78712
X.\"
X.TH apropos 1 "Jan 15, 1991"
X.LO 1
X.SH NAME
Xapropos \- search the whatis database for strings
X.SH SYNOPSIS
X.BI apropos
Xkeyword ...
X.SH DESCRIPTION
Xapropos searches a set of database files containing short descriptions
Xof system commands for keywords and displays the result on the
Xstandard output.
X.SH "SEE ALSO"
Xwhatis(1), man(1).
END_OF_FILE
if test 712 -ne `wc -c <'man-1.0/apropos.man'`; then
    echo shar: \"'man-1.0/apropos.man'\" unpacked with wrong size!
fi
# end of 'man-1.0/apropos.man'
fi
if test -f 'man-1.0/apropos.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/apropos.sh'\"
else
echo shar: Extracting \"'man-1.0/apropos.sh'\" \(1103 characters\)
sed "s/^X//" >'man-1.0/apropos.sh' <<'END_OF_FILE'
X#!/bin/sh
X#
X# apropos -- search the whatis database for keywords.
X#
X# Copyright (c) 1991, John W. Eaton.
X#
X# You may distribute under the terms of the GNU General Public
X# License as specified in the README file that comes with the man 1.0
X# distribution.  
X#
X# John W. Eaton
X# jwe at che.utexas.edu
X# Department of Chemical Engineering
X# The University of Texas at Austin
X# Austin, Texas  78712
X
XPATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
X
Xlibdir=LIBDIR
X
Xif [ $# = 0 ]
Xthen
X    echo "usage: `basename $0` keyword ..."
X    exit 1
Xfi
X
Xmanpath=`BINDIR/manpath -q | tr : '\040'`
X
Xif [ "$manpath" = "" ]
Xthen
X    echo "whatis: manpath is null"
X    exit 1
Xfi
X
Xwhile [ $1 ]
Xdo
X        found=0
X        for d in $manpath /usr/lib
X        do
X            if [ -f $d/whatis ]
X            then
X                grep -i "$1" $d/whatis
X                status=$?
X                if [ "$status" = "0" ]
X                then
X                    found=1
X                fi
X            fi
X        done
X
X        if [ "$found" = "0" ]
X        then
X            echo "$1: nothing appropriate"
X        fi
X
X        shift
Xdone
X
Xexit
END_OF_FILE
if test 1103 -ne `wc -c <'man-1.0/apropos.sh'`; then
    echo shar: \"'man-1.0/apropos.sh'\" unpacked with wrong size!
fi
# end of 'man-1.0/apropos.sh'
fi
if test -f 'man-1.0/config.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/config.h'\"
else
echo shar: Extracting \"'man-1.0/config.h'\" \(2981 characters\)
sed "s/^X//" >'man-1.0/config.h' <<'END_OF_FILE'
X/*
X * config.h
X *
X * Edit this file to match your site.
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
X#ifndef BUFSIZ
X#define BUFSIZ 1024
X#endif
X
X#ifndef MAXPATHLEN
X#define MAXPATHLEN 512
X#endif
X
X#ifndef MAXDIRS
X#define MAXDIRS 64
X#endif
X
X/*
X * These are the programs man(1) execs with the -k and -f options.
X */
X
X#define APROPOS "/usr/local/bin/apropos"
X#define WHATIS  "/usr/local/bin/whatis"
X
X/*
X * This might also be "/usr/ucb/more -s", though I prefer less(1)
X * because it allows one to backup even when reading from pipes.
X */
X
X#define PAGER   "/usr/local/bin/less -sC"
X
Xstatic char config_file[] = "/usr/local/lib/man/manpath.config";
X
X/*
X * These might also be something like
X *
X *  nroff_command[] = "/usr/local/bin/groff -Tascii -man"
X *  troff_command[] = "/usr/local/bin/groff -Tps -man"
X */
X
Xstatic char nroff_command[] = "/usr/bin/nroff -man";
X
X#ifdef HAS_TROFF
Xstatic char troff_command[] = "/usr/bin/troff -man";
X#endif
X
X/*
X * Define the valid manual sections.  For example, if your man
X * directory tree has subdirectories man1, man2, man3, mann,
X * and man3foo, valid_sections[] would have "1", "2", "3", "n", and
X * "3foo".  Directories are searched in the order they appear.  Having
X * extras isn't fatal, it just slows things down a bit.
X *
X * Note that this is just for directories to search.  If you have
X * files like .../man3/foobar.3Xtc, you don't need to have "3Xtc" in
X * the list below -- this is handled separately, so that `man 3Xtc foobar',
X * `man 3 foobar', and `man foobar' should find the file .../man3/foo.3Xtc,
X * (assuming, of course, that there isn't a .../man1/foo.1 or somesuch
X * that we would find first).
X *
X * Note that this list should be in the order that you want the
X * directories to be searched.  Is there a standard for this?  What is
X * the normal order?  If anyone knows, please tell me!
X */
X
Xstatic char *valid_sections[] = 
X{
X  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  NULL
X};
X
X/*
X * Not all systems define these in stat.h.
X */
X
X#ifndef S_IRUSR
X#define	S_IRUSR	00400		/*  read permission: owner */
X#endif
X#ifndef S_IWUSR
X#define	S_IWUSR	00200		/*  write permission: owner */
X#endif
X#ifndef S_IRGRP
X#define	S_IRGRP	00040		/*  read permission: group */
X#endif
X#ifndef S_IWGRP
X#define	S_IWGRP	00020		/*  write permission: group */
X#endif
X#ifndef S_IROTH
X#define	S_IROTH	00004		/*  read permission: other */
X#endif
X#ifndef S_IWOTH
X#define	S_IWOTH	00002		/*  write permission: other */
X#endif
X
X/*
X * This is the mode used for formatted pages that we create.
X */
X
X#ifndef CATMODE
X#define CATMODE S_IRUSR | S_IRGRP | S_IROTH
X#endif
X
X#ifdef SUPPORT_CAT_DIRS
Xstatic int cat_support = 1;
X#else
Xstatic int cat_support = 0;
X#endif
END_OF_FILE
if test 2981 -ne `wc -c <'man-1.0/config.h'`; then
    echo shar: \"'man-1.0/config.h'\" unpacked with wrong size!
fi
# end of 'man-1.0/config.h'
fi
if test -f 'man-1.0/gripes.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/gripes.c'\"
else
echo shar: Extracting \"'man-1.0/gripes.c'\" \(2590 characters\)
sed "s/^X//" >'man-1.0/gripes.c' <<'END_OF_FILE'
X/*
X * gripes.c
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
X#include <stdio.h>
X#include "gripes.h"
X
X#ifndef __STDH__
Xextern int fprintf ();
Xextern int fflush ();
Xextern int exit ();
X#endif
X
Xextern char *prognam;
X
Xvoid
Xgripe_no_name (section)
X     char *section;
X{
X  if (section)
X    fprintf (stderr, "What manual page do you want from section %s?\n",
X	     section);
X  else
X    fprintf (stderr, "What manual page do you want?\n");
X
X  fflush (stderr);
X}
X
Xvoid
Xgripe_reading_man_file (name)
X     char *name;
X{
X  fprintf (stderr, "Read access denied for file %s\n", name);
X
X  fflush (stderr);
X}
X
Xvoid
Xgripe_converting_name (name, to_cat)
X     char *name;
X     int to_cat;
X{
X  if (to_cat)
X    fprintf (stderr, "Error converting %s to cat name\n", name);
X  else
X    fprintf (stderr, "Error converting %s to man name\n", name);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_system_command (status)
X     int status;
X{
X  fprintf (stderr, "Error executing formatting or display command.\n");
X  fprintf (stderr, "system command exited with status %d\n", status);
X
X  fflush (stderr);
X}
X
Xvoid
Xgripe_not_found (name, section)
X     char *name, *section;
X{
X  if (section)
X    fprintf (stderr, "No entry for %s in section %s of the manual\n",
X	     name, section);
X  else
X    fprintf (stderr, "No manual entry for %s\n", name);
X
X  fflush (stderr);
X}
X
Xvoid
Xgripe_incompatible (s)
X     char *s;
X{
X  fprintf (stderr, "%s: incompatible options %s\n", prognam, s);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_getting_mp_config (file)
X     char *file;
X{
X  fprintf (stderr, "%s: unable to find the file %s\n", prognam, file);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_reading_mp_config (file)
X     char *file;
X{
X  fprintf (stderr, "%s: unable to make sense of the file %s\n", prognam, file);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_invalid_section (section)
X     char *section;
X{
X  fprintf (stderr, "%s: invalid section (%s) selected\n", prognam, section);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_manpath ()
X{
X  fprintf (stderr, "%s: manpath is null\n", prognam);
X
X  fflush (stderr);
X
X  exit (1);
X}
X
Xvoid
Xgripe_alloc (bytes, object)
X     int bytes;
X     char *object;
X{
X  fprintf (stderr, "%s: can't malloc %d bytes for %s\n",
X	   prognam, bytes, object);
X
X  fflush (stderr);
X
X  exit (1);
X}
END_OF_FILE
if test 2590 -ne `wc -c <'man-1.0/gripes.c'`; then
    echo shar: \"'man-1.0/gripes.c'\" unpacked with wrong size!
fi
# end of 'man-1.0/gripes.c'
fi
if test -f 'man-1.0/gripes.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/gripes.h'\"
else
echo shar: Extracting \"'man-1.0/gripes.h'\" \(746 characters\)
sed "s/^X//" >'man-1.0/gripes.h' <<'END_OF_FILE'
X/*
X * gripes.h
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
Xextern void gripe_no_name ();
Xextern void gripe_converting_name ();
Xextern void gripe_system_command ();
Xextern void gripe_reading_man_file ();
Xextern void gripe_not_found ();
Xextern void gripe_invalid_section ();
Xextern void gripe_manpath ();
Xextern void gripe_alloc ();
Xextern void gripe_incompatible ();
Xextern void gripe_getting_mp_config ();
Xextern void gripe_reading_mp_config ();
END_OF_FILE
if test 746 -ne `wc -c <'man-1.0/gripes.h'`; then
    echo shar: \"'man-1.0/gripes.h'\" unpacked with wrong size!
fi
# end of 'man-1.0/gripes.h'
fi
if test -f 'man-1.0/makewhatis.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/makewhatis.sh'\"
else
echo shar: Extracting \"'man-1.0/makewhatis.sh'\" \(2412 characters\)
sed "s/^X//" >'man-1.0/makewhatis.sh' <<'END_OF_FILE'
X#!/bin/sh
X#
X# makewhatis -- update the whatis database in the man directories.
X#
X# Copyright (c) 1991, John W. Eaton.
X#
X# You may distribute under the terms of the GNU General Public
X# License as specified in the README file that comes with the man 1.0
X# distribution.  
X#
X# John W. Eaton
X# jwe at che.utexas.edu
X# Department of Chemical Engineering
X# The University of Texas at Austin
X# Austin, Texas  78712
X
XPATH=/bin:/usr/local/bin:/usr/ucb:/usr/bin
X
Xif [ $# = 0 ]
Xthen
X    echo "usage: makewhatis directory [...]"
X    exit 1
Xfi
X
Xfor dir in $*
Xdo
X    cd $dir
X    for subdir in man*
X    do
X        if [ -d $subdir ]
X        then
X            for f in `find . -name '*' -print`
X            do
X                sed -n '/^\.TH.*$/p
X                        /^\.SH[         ]*NAME/,/^\.SH/p' $f |\
X                sed -e 's/\\[   ]*\-/-/
X                        s/^.PP.*$//
X                        s/\\(em//
X                        s/\\fI//
X                        s/\\fR//' |\
X                awk 'BEGIN {insh = 0} {
X                     if ($1 == ".TH")
X                       sect = $3
X                     else if ($1 == ".SH" && insh == 1) {
X                       if (i > 0 && name != NULL) {
X                         namesect = sprintf("%s (%s)", name, sect)
X                         printf("%-20.20s", namesect)
X                         printf(" - ")
X                         for (j = 0; j < i-1; j++)
X                           printf("%s ", desc[j])
X                         printf("%s\n", desc[i-1])
X                       }
X                     } else if ($1 == ".SH" && insh == 0) {
X                       insh = 1
X                       count = 0
X                       i = 0
X                     } else if (insh == 1) {
X                       count++
X                       if (count == 1 && NF > 2) {
X                         start = 2
X                         if ($2 == "-") start = 3
X                         if (NF > start + 1)
X                           for (j = start; j <= NF; j++)
X                             desc[i++] = $j
X                           name = $1
X                       } else {
X                         for (j = 1; j <= NF; j++)
X                           desc[i++] = $j
X                       }
X                     }
X                }'
X            done
X            cd ..
X        fi
X    done | sort | colrm 80 > $dir/whatis.db.tmp
X    mv $dir/whatis.db.tmp $dir/whatis
Xdone
X
Xexit
END_OF_FILE
if test 2412 -ne `wc -c <'man-1.0/makewhatis.sh'`; then
    echo shar: \"'man-1.0/makewhatis.sh'\" unpacked with wrong size!
fi
# end of 'man-1.0/makewhatis.sh'
fi
if test -f 'man-1.0/man.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/man.man'\"
else
echo shar: Extracting \"'man-1.0/man.man'\" \(2323 characters\)
sed "s/^X//" >'man-1.0/man.man' <<'END_OF_FILE'
X.\" Man page for man
X.\"
X.\" Copyright (c) 1991, John W. Eaton.
X.\"
X.\" You may distribute under the terms of the GNU General Public
X.\" License as specified in the README file that comes with the man 1.0
X.\" distribution.  
X.\"
X.\" John W. Eaton
X.\" jwe at che.utexas.edu
X.\" Department of Chemical Engineering
X.\" The University of Texas at Austin
X.\" Austin, Texas  78712
X.\"
X.TH man 1 "Jan 5, 1991"
X.LO 1
X.SH NAME
Xman \- format and display the on-line manual pages
X.SH SYNOPSIS
Xman [\-afhkt] [\-M path] [\-P pager] [\-S system] [section] name ...
X.SH DESCRIPTION
Xman formats and displays the on-line manual pages.  This version knows
Xabout the MANPATH and PAGER environment variables, so you can have
Xyour own set(s) of personal man pages and choose whatever program you
Xlike to display the formatted pages.  If section is specified, man
Xonly looks in that section of the manual.
X.SH OPTIONS
X.TP
X.B \-\^P " pager"
XSpecify which pager to use.  By default,
X.B man
Xuses
X.B less,
Xwhich has the ability to backup on files and pipes, so you can go
Xbackwards while reading the manual.  This option overrides the
X.B PAGER
Xenvironment variable.
X.TP
X.B \-\^M " path"
XSpecify an alternate manpath.  By default, man uses
X.B manpath
Xto determine the path to search.  This option overrides the
X.B MANPATH
Xenvironment variable.
X.TP
X.B \-\^a
XBy default,
X.B man
Xwill exit after displaying the first manual page it finds.  Using this
Xoption forces
X.B man
Xto display all the manual pages that match
X.B name, 
Xnot just the first.  
X.TP
X.B \-\^f
XEquivalent to
X.B whatis.
X.TP
X.B \-\^h
XPrint a one line help message and exit.
X.TP
X.B \-\^k
XEquivalent to
X.B apropos.
X.TP
X.B \-\^t
XUse
X.B troff
Xto format the manual page, passing the output to 
X.B stdout.
XNormally the output from
X.B troff
Xwill need to be passed through some filter or another before being
Xprinted.
X.SH ENVIRONMENT
X.TP \w'MANPATH\ \ 'u
X.B MANPATH
XIf
X.B MANPATH
Xis set,
X.B man
Xuses its value as the path to search for manual pages.
X.TP
X.B PAGER
XIf
X.B PAGER
Xis set,
X.B man
Xuses its value as the name of the program to use to display the man
Xpage.  By default,
X.B less
Xis used.
X.SH "SEE ALSO"
Xapropos(1), whatis(1), manpath(1), less(1), nroff(1), troff(1), psdit(1).
X.SH BUGS
XThe
X.B \-t
Xoption only works if
X.B troff
Xis installed.
X.PP
X.B less
Xis sometimes confused by underlined text.
END_OF_FILE
if test 2323 -ne `wc -c <'man-1.0/man.man'`; then
    echo shar: \"'man-1.0/man.man'\" unpacked with wrong size!
fi
# end of 'man-1.0/man.man'
fi
if test -f 'man-1.0/manpath.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/manpath.c'\"
else
echo shar: Extracting \"'man-1.0/manpath.c'\" \(9441 characters\)
sed "s/^X//" >'man-1.0/manpath.c' <<'END_OF_FILE'
X/*
X * manpath.c
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
X#include <stdio.h>
X#include <string.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include "config.h"
X#include "manpath.h"
X#include "gripes.h"
X
X#ifdef STD_HEADERS
X#include <stdlib.h>
X#else
Xextern int fprintf ();
Xextern int strcmp ();
Xextern int strncmp ();
Xextern char *getenv();
Xextern char *malloc();
Xextern void free ();
Xextern int exit ();
X#endif
X
Xextern char *strdup ();
X
X#ifndef MAIN
Xextern int debug;
X#endif
X
X#ifdef MAIN
X
X#ifndef __ANSI__
Xextern char *strcpy ();
Xextern int fflush ();
X#endif
X
Xchar *prognam;
Xint debug;
X
X/*
X * Examine user's PATH and print a reasonable MANPATH.
X */
Xint
Xmain(argc, argv)
X     int argc;
X     char **argv;
X{
X  int c;
X  int quiet;
X  char *mp;
X  extern int getopt ();
X  extern char *mkprogname ();
X  void usage ();
X  char *manpath ();
X
X  quiet = 1;
X
X  prognam = mkprogname (argv[0]);
X
X  while ((c = getopt (argc, argv, "dhq?")) != EOF)
X    {
X      switch (c)
X	{
X	case 'd':
X	  debug++;
X	  break;
X	case 'q':
X	  quiet = 0;
X	  break;
X	case '?':
X	case 'h':
X	default:
X	  usage();
X          break;
X	}
X    }
X
X  mp = manpath (quiet);
X
X  fprintf (stdout, "%s\n", mp);
X  fflush (stdout);
X
X  return 0;
X}
X
Xvoid
Xusage ()
X{
X  fprintf (stderr, "usage: %s [-q]\n", prognam);
X  exit (1);
X}
X#endif /* MAIN */
X
X/*
X * If the environment variable MANPATH is set, return it.
X * If the environment variable PATH is set and has a nonzero length,
X * try to determine the corresponding manpath, otherwise, return the
X * default manpath.
X *
X * The manpath.config file is used to map system wide /bin directories
X * to top level man page directories.
X *
X * For directories which are in the user's path but not in the
X * manpath.config file, see if there is a subdirectory `man' or `MAN'.
X * If so, add that directory to the path.  Example:  user has
X * $HOME/bin in his path and the directory $HOME/bin/man exists -- the
X * directory $HOME/bin/man will be added to the manpath.
X */
Xchar *
Xmanpath (perrs)
X     register int perrs;
X{
X  register int len;
X  register char *manpathlist;
X  register char *path;
X  int  get_dirlist ();
X  char *def_path ();
X  char *get_manpath ();
X
X  if (get_dirlist ())
X      gripe_reading_mp_config ();
X
X  if ((manpathlist = getenv ("MANPATH")) != NULL)
X    /*
X     * This must be it.
X     */
X    {
X      if (perrs)
X	fprintf (stderr, "(Warning: MANPATH environment variable set)\n");
X      return manpathlist;
X    }
X  else if ((path = getenv ("PATH")) == NULL)
X    /*
X     * Things aren't going to work well, but hey...
X     */
X    {
X      if (perrs)
X	fprintf (stderr, "Warning: path not set\n");
X      return def_path (perrs);
X    }
X  else
X    {
X      if ((len = strlen (path)) == 0)
X	/*
X	 * Things aren't going to work well here either...
X	 */
X	{
X	  if (perrs)
X	    fprintf (stderr, "Warning: path set but has zero length\n");
X	  return def_path (perrs);
X	}
X      return get_manpath (perrs, path);
X    }
X}
X
X/*
X * Get the list of bin directories and the corresponding man
X * directories from the manpath.config file.
X *
X * This is ugly.
X */
Xint
Xget_dirlist ()
X{
X  int i;
X  char *bp;
X  char *p;
X  char buf[BUFSIZ];
X  DIRLIST *dlp = list;
X  FILE *config;
X
X  if ((config = fopen (config_file, "r")) == NULL)
X    gripe_getting_mp_config (config_file);
X
X  while ((bp = fgets (buf, BUFSIZ, config)) != NULL)
X    {
X      while (*bp && (*bp == ' ' || *bp == '\t'))
X	bp++;
X
X      if (*bp == '#' || *bp == '\n')
X	continue;
X
X      if (!strncmp ("MANBIN", bp, 6))
X	continue;
X
X      if (!strncmp ("MANDATORY_MANPATH", bp, 17))
X	{
X	  if ((p = strchr (bp, ' ')) == NULL)
X	    if ((p = strchr (bp, '\t')) == NULL)
X	      return -1;
X
X	  bp = p;
X
X	  dlp->mandatory = 1;
X
X	  while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
X	    bp++;
X
X	  i = 0;
X	  while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
X	    dlp->mandir[i++] = *bp++;
X	  dlp->mandir[i] = '\0';
X
X	  if (debug)
X	    fprintf (stderr, "found mandatory man directory %s\n",
X		     dlp->mandir);
X	}
X      else if (!strncmp ("MANPATH_MAP", bp, 11))
X	{
X	  if ((p = strchr (bp, ' ')) == NULL)
X	    if ((p = strchr (bp, '\t')) == NULL)
X	      return -1;
X
X	  bp = p;
X
X	  dlp->mandatory = 0;
X
X	  while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
X	    bp++;
X
X	  i = 0;
X	  while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
X	    dlp->bin[i++] = *bp++;
X	  dlp->bin[i] = '\0';
X
X	  while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
X	    bp++;
X
X	  i = 0;
X	  while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
X	    dlp->mandir[i++] = *bp++;
X	  dlp->mandir[i] = '\0';
X
X	  if (debug)
X	    fprintf (stderr, "found manpath map %s --> %s\n",
X		     dlp->bin, dlp->mandir);
X	}
X      else
X	{
X	  gripe_reading_mp_config ();
X	}
X      dlp++;
X    }
X
X  dlp->bin[0] = NULL;
X  dlp->mandir[0] = NULL;
X  dlp->mandatory = 0;
X
X  return 0;
X}
X
X/*
X * Construct the default manpath.  This picks up mandatory manpaths
X * only.
X */
Xchar *
Xdef_path (perrs)
X     int perrs;
X{
X  register int len;
X  register char *manpathlist;
X  register DIRLIST *dlp;
X
X  len = 0;
X  dlp = list;
X  while (dlp->mandatory != 0)
X    {
X      len += strlen (dlp->mandir) + 1;
X      dlp++;
X    }
X
X  if ((manpathlist = malloc (len)) == NULL)
X    {
X      fprintf (stderr, "Fatal: can't malloc %d bytes for manpathlist\n", len);
X      exit (1);
X    }
X  *manpathlist = '\0';
X
X  dlp = list;
X  while (dlp->mandatory != 0)
X    {
X      strcat (manpathlist, dlp->mandir);
X      strcat (manpathlist, ":");
X      dlp++;
X    }
X
X  manpathlist[len-1] = '\0';
X
X  return manpathlist;
X}
X
X/*
X * For each directory in the user's path, see if it is one of the
X * directories listed in the manpath.config file.  If so, and it is
X * not already in the manpath, add it.  If the directory is not listed
X * in the manpath.config file, see if there is a subdirectory `man' or
X * `MAN'.  If so, and it is not already in the manpath, add it.
X * Example:  user has $HOME/bin in his path and the directory
X * $HOME/bin/man exists -- the directory $HOME/bin/man will be added
X * to the manpath.
X */
Xchar *
Xget_manpath (perrs, path)
X     register int perrs;
X     register char *path;
X{
X  register int len;
X  register char *tmppath;
X  register char *t;
X  register char *p;
X  register char **lp;
X  register char *end;
X  register char *manpathlist;
X  register DIRLIST *dlp;
X  void add_dir_to_list ();
X  char *has_subdirs ();
X
X  tmppath = strdup (path);
X
X  for (p = tmppath; ; p = end+1)
X    {
X      if (end = strchr(p, ':'))
X	*end = '\0';
X
X      if (debug)
X	fprintf (stderr, "\npath directory %s ", p);
X
X      for (dlp = list; dlp->mandir[0] != NULL; dlp++)
X	if (dlp->bin[0] != NULL && !strcmp (p, dlp->bin))
X	  {
X	    /*
X	     * The directory we're working on is in the config file.
X	     * If we haven't added it to the list yet, do.
X	     */
X	    if (debug)
X	      fprintf (stderr, "is in the config file\n");
X
X	    add_dir_to_list (tmplist, dlp->mandir);
X	    goto found;
X	  }
X      /*
X       * The directory we're working on isn't in the config file.  See
X       * if it has man or MAN subdirectories.  If so, and it hasn't
X       * been added to the list, do.
X       */
X      if (debug)
X	fprintf (stderr, "is not in the config file\n");
X
X      t = has_subdirs (p);
X      if (t != NULL)
X	{
X	  if (debug)
X	    fprintf (stderr, "but it does have a man or MAN subdirectory\n");
X
X	  add_dir_to_list (tmplist, t);
X	  free (t);
X	}
X      else
X	{
X	  if (debug)
X	    fprintf (stderr, "and doesn't have man or MAN subdirectories\n");
X	}
X
X    found:
X
X      if (!end)
X	break;
X    }
X
X  if (debug)
X    fprintf (stderr, "\nadding mandatory man directories\n\n");
X
X  dlp = list;
X  while (dlp->mandatory != 0)
X    {
X      add_dir_to_list (tmplist, dlp->mandir);
X      dlp++;
X    }
X
X  len = 0;
X  lp = tmplist;
X  while (*lp != NULL)
X    {
X      len += strlen (*lp) + 1;
X      lp++;
X    }
X
X  if ((manpathlist = malloc (len)) == NULL)
X    {
X      fprintf (stderr, "Fatal: can't malloc %d bytes for manpathlist\n", len);
X      exit (1);
X    }
X  *manpathlist = '\0';
X
X  lp = tmplist;
X  while (*lp != NULL)
X    {
X      strcat (manpathlist, *lp);
X      strcat (manpathlist, ":");
X      lp++;
X    }
X
X  manpathlist[len-1] = '\0';
X
X  return manpathlist;
X}
X
X/*
X * Add a directory to the manpath list if it isn't already there.
X */
Xvoid
Xadd_dir_to_list (lp, dir)
X     char **lp;
X     char *dir;
X{
X  extern char *strdup ();
X
X  while (*lp != NULL)
X    {
X      if (!strcmp (*lp, dir))
X	{
X	  if (debug)
X	    fprintf (stderr, "%s is already in the manpath\n", dir);
X	  return;
X	}
X      lp++;
X    }
X  /*
X   * Not found -- add it.
X   */
X  if (debug)
X    fprintf (stderr, "adding %s to manpath\n", dir);
X
X  *lp = strdup (dir);
X}
X
X/*
X * Check to see if the current directory has man or MAN
X * subdirectories. 
X */
Xchar *
Xhas_subdirs (p)
X     register char *p;
X{
X  int len;
X  register char *t;
X  register struct stat sb;
X  extern int stat ();
X
X  len = strlen (p);
X
X  t = malloc ((unsigned) len + 5);
X
X  if (t == 0)
X    gripe_alloc (len, "p\n");
X
X  strcpy (t, p);
X  strcat (t, "/man");
X
X  if (stat (t, &sb) == 0 && (sb.st_mode & S_IFDIR) == S_IFDIR)
X    return t;
X
X  strcpy (t, p);
X  strcat (t, "/MAN");
X  
X  if (stat (t, &sb) == 0 && (sb.st_mode & S_IFDIR) == S_IFDIR)
X    return t;
X
X  return NULL;
X}
END_OF_FILE
if test 9441 -ne `wc -c <'man-1.0/manpath.c'`; then
    echo shar: \"'man-1.0/manpath.c'\" unpacked with wrong size!
fi
# end of 'man-1.0/manpath.c'
fi
if test -f 'man-1.0/manpath.config' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/manpath.config'\"
else
echo shar: Extracting \"'man-1.0/manpath.config'\" \(1159 characters\)
sed "s/^X//" >'man-1.0/manpath.config' <<'END_OF_FILE'
X# manpath.config
X#
X# Edit this file to match your site.
X#
X# Copyright (c) 1991, John W. Eaton.
X#
X# You may distribute under the terms of the GNU General Public
X# License as specified in the README file that comes with the man 1.0
X# distribution.  
X#
X# John W. Eaton
X# jwe at che.utexas.edu
X# Department of Chemical Engineering
X# The University of Texas at Austin
X# Austin, Texas  78712
X#
X# This file is read by manpath to configure the mandatory manpath, to
X# map each path element to a manpath element and to determine where the
X# "man" binary lives.  The format is:
X#
X# MANBIN				pathname
X# MANDATORY_MANPATH			manpath_element
X# MANPATH_MAP		path_element	manpath_element
X#
X# MANBIN is optional.
X#
X#MANBIN		/usr/local/lib/man
X#
X# every automatically generated MANPATH includes these fields
X#
XMANDATORY_MANPATH	/usr/man
XMANDATORY_MANPATH	/usr/local/man
XMANDATORY_MANPATH	/usr/local/X11/man
X#
X# set up PATH to MANPATH mapping
X#
XMANPATH_MAP	/bin			/usr/man
XMANPATH_MAP	/usr/bin		/usr/man
XMANPATH_MAP	/usr/ucb		/usr/man
XMANPATH_MAP	/usr/local/bin		/usr/local/man
XMANPATH_MAP	/usr/local/bin/X11	/usr/local/X11/man
XMANPATH_MAP	/usr/local/bin/X11R4	/usr/local/X11/man
END_OF_FILE
if test 1159 -ne `wc -c <'man-1.0/manpath.config'`; then
    echo shar: \"'man-1.0/manpath.config'\" unpacked with wrong size!
fi
# end of 'man-1.0/manpath.config'
fi
if test -f 'man-1.0/manpath.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/manpath.h'\"
else
echo shar: Extracting \"'man-1.0/manpath.h'\" \(505 characters\)
sed "s/^X//" >'man-1.0/manpath.h' <<'END_OF_FILE'
X/*
X * manpath.h
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
Xtypedef struct
X{
X  char mandir[MAXPATHLEN];
X  char bin[MAXPATHLEN];
X  int mandatory;
X} DIRLIST;
X
XDIRLIST list[MAXDIRS];
X
Xchar *tmplist[MAXDIRS];
END_OF_FILE
if test 505 -ne `wc -c <'man-1.0/manpath.h'`; then
    echo shar: \"'man-1.0/manpath.h'\" unpacked with wrong size!
fi
# end of 'man-1.0/manpath.h'
fi
if test -f 'man-1.0/manpath.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/manpath.man'\"
else
echo shar: Extracting \"'man-1.0/manpath.man'\" \(1436 characters\)
sed "s/^X//" >'man-1.0/manpath.man' <<'END_OF_FILE'
X.\" Man page for manpath
X.\"
X.\" Copyright (c) 1991, John W. Eaton.
X.\"
X.\" You may distribute under the terms of the GNU General Public
X.\" License as specified in the README file that comes with the man 1.0
X.\" distribution.  
X.\"
X.\" John W. Eaton
X.\" jwe at che.utexas.edu
X.\" Department of Chemical Engineering
X.\" The University of Texas at Austin
X.\" Austin, Texas  78712
X.\"
X.TH manpath 1 "Jan 5, 1991"
X.LO 1
X.SH NAME
Xmanpath \- determine user's search path for man pages
X.SH SYNOPSIS
Xmanpath [\-q]
X.SH DESCRIPTION
Xmanpath tries to determine the user's manpath from a set of system
Xdefaults and the user's
X.B PATH ,
Xechoing the result to the standard output.  Warnings and errors are
Xwritten to the standard error.
XIf a directory in the user's path is not listed in the manpath.config
Xfile, manpath looks for the subdirectories man or MAN.  If they exist,
Xthey are added to the search path.
X.PP
Xmanpath is used by
X.B man
Xto determine the search path, so user's normally don't need to set the
X.B MANPATH
Xenvironment variable directly.
X.SH OPTIONS
X.TP
X.B \-\^q
XOperate quietly.  Only echo the final manpath.
X.SH ENVIRONMENT
X.TP \w'MANPATH\ \ 'u
X.B MANPATH
XIf
X.B MANPATH
Xis set,
X.B manpath
Xechoes its value on the standard output and issues a warning on the
Xstandard error.
X.SH FILES
X.TP \w'MANPATH_CONFIG_FILE'u+2n
X.BI MANPATH_CONFIG_FILE
XSystem configuration file.
X.SH "SEE ALSO"
Xapropos(1), whatis(1), man(1).
X.SH BUGS
XNone known.
END_OF_FILE
if test 1436 -ne `wc -c <'man-1.0/manpath.man'`; then
    echo shar: \"'man-1.0/manpath.man'\" unpacked with wrong size!
fi
# end of 'man-1.0/manpath.man'
fi
if test -f 'man-1.0/ndir.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/ndir.h'\"
else
echo shar: Extracting \"'man-1.0/ndir.h'\" \(1262 characters\)
sed "s/^X//" >'man-1.0/ndir.h' <<'END_OF_FILE'
X/*
X	<dir.h> -- definitions for 4.2BSD-compatible directory access
X
X	last edit:	09-Jul-1983	D A Gwyn
X*/
X
X#ifdef VMS
X#ifndef FAB$C_BID
X#include <fab.h>
X#endif
X#ifndef NAM$C_BID
X#include <nam.h>
X#endif
X#ifndef RMS$_SUC
X#include <rmsdef.h>
X#endif
X#include "dir.h"
X#endif /* VMS */
X
X#define DIRBLKSIZ	512		/* size of directory block */
X#ifdef VMS
X#define MAXNAMLEN	(DIR$S_NAME + 7) /* 80 plus room for version #.  */
X#define MAXFULLSPEC	NAM$C_MAXRSS /* Maximum full spec */
X#else
X#define MAXNAMLEN	15		/* maximum filename length */
X#endif /* VMS */
X	/* NOTE:  MAXNAMLEN must be one less than a multiple of 4 */
X
Xstruct direct				/* data from readdir() */
X	{
X	long		d_ino;		/* inode number of entry */
X	unsigned short	d_reclen;	/* length of this record */
X	unsigned short	d_namlen;	/* length of string in d_name */
X	char		d_name[MAXNAMLEN+1];	/* name of file */
X	};
X
Xtypedef struct
X	{
X	int	dd_fd;			/* file descriptor */
X	int	dd_loc;			/* offset in block */
X	int	dd_size;		/* amount of valid data */
X	char	dd_buf[DIRBLKSIZ];	/* directory block */
X	}	DIR;			/* stream data from opendir() */
X
Xextern DIR		*opendir();
Xextern struct direct	*readdir();
Xextern long		telldir();
Xextern void		seekdir();
Xextern void		closedir();
X
X#define rewinddir( dirp )	seekdir( dirp, 0L )
END_OF_FILE
if test 1262 -ne `wc -c <'man-1.0/ndir.h'`; then
    echo shar: \"'man-1.0/ndir.h'\" unpacked with wrong size!
fi
# end of 'man-1.0/ndir.h'
fi
if test -f 'man-1.0/strdup.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/strdup.c'\"
else
echo shar: Extracting \"'man-1.0/strdup.c'\" \(1141 characters\)
sed "s/^X//" >'man-1.0/strdup.c' <<'END_OF_FILE'
X/* strdup.c -- return a newly allocated copy of a string
X   Copyright (C) 1989, 1990 Free Software Foundation, Inc.
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   This program is distributed in the hope that it will be useful,
X   but WITHOUT ANY WARRANTY; without even the implied warranty of
X   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X   GNU General Public License for more details.
X
X   You should have received a copy of the GNU General Public License
X   along with this program; if not, write to the Free Software
X   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
X
X#ifdef STRDUP_MISSING
X/* If you have the STDC headers, you surely have strdup, too. */
Xchar *malloc ();
Xchar *strcpy ();
X
X/* Return a newly allocated copy of string S;
X   return 0 if out of memory. */
X
Xchar *
Xstrdup (s)
X     char *s;
X{
X  char *p;
X
X  p = malloc ((unsigned) (strlen (s) + 1));
X  if (p)
X    strcpy (p, s);
X  return p;
X}
X#endif
END_OF_FILE
if test 1141 -ne `wc -c <'man-1.0/strdup.c'`; then
    echo shar: \"'man-1.0/strdup.c'\" unpacked with wrong size!
fi
# end of 'man-1.0/strdup.c'
fi
if test -f 'man-1.0/util.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/util.c'\"
else
echo shar: Extracting \"'man-1.0/util.c'\" \(723 characters\)
sed "s/^X//" >'man-1.0/util.c' <<'END_OF_FILE'
X/*
X * util.c
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
X#ifdef STD_HEADERS
X#include <stdio.h>
X#include <string.h>
X#include <stdlib.h>
X#else
X#include <stdio.h>
X#include <string.h>
Xextern char *strdup ();
X#endif
X
X/*
X * Extract last element of a name like /foo/bar/baz.
X */
Xchar *
Xmkprogname (s)
X     register char *s;
X{
X  char *t;
X
X  t = strrchr (s, '/');
X  if (t == NULL)
X    t = s;
X  else
X    t++;
X
X  return strdup (t);
X}
END_OF_FILE
if test 723 -ne `wc -c <'man-1.0/util.c'`; then
    echo shar: \"'man-1.0/util.c'\" unpacked with wrong size!
fi
# end of 'man-1.0/util.c'
fi
if test -f 'man-1.0/version.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/version.h'\"
else
echo shar: Extracting \"'man-1.0/version.h'\" \(391 characters\)
sed "s/^X//" >'man-1.0/version.h' <<'END_OF_FILE'
X/*
X * version.h
X *
X * Copyright (c) 1991, John W. Eaton.
X *
X * You may distribute under the terms of the GNU General Public
X * License as specified in the README file that comes with the man 1.0
X * distribution.  
X *
X * John W. Eaton
X * jwe at che.utexas.edu
X * Department of Chemical Engineering
X * The University of Texas at Austin
X * Austin, Texas  78712
X */
X
Xstatic char version[] = "1.0";
END_OF_FILE
if test 391 -ne `wc -c <'man-1.0/version.h'`; then
    echo shar: \"'man-1.0/version.h'\" unpacked with wrong size!
fi
# end of 'man-1.0/version.h'
fi
if test -f 'man-1.0/whatis.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/whatis.man'\"
else
echo shar: Extracting \"'man-1.0/whatis.man'\" \(758 characters\)
sed "s/^X//" >'man-1.0/whatis.man' <<'END_OF_FILE'
X.\" Man page for whatis
X.\"
X.\" Copyright (c) 1991, John W. Eaton.
X.\"
X.\" You may distribute under the terms of the GNU General Public
X.\" License as specified in the README file that comes with the man 1.0
X.\" distribution.  
X.\"
X.\" John W. Eaton
X.\" jwe at che.utexas.edu
X.\" Department of Chemical Engineering
X.\" The University of Texas at Austin
X.\" Austin, Texas  78712
X.\"
X.TH whatis 1 "Jan 5, 1991"
X.LO 1
X.SH NAME
Xwhatis \- search the whatis database for complete words.
X.SH SYNOPSIS
X.BI whatis
Xkeyword ...
X.SH DESCRIPTION
Xwhatis searches a set of database files containing short descriptions
Xof system commands for keywords and displays the result on the
Xstandard output.  Only complete word matches are displayed.
X.SH "SEE ALSO"
Xapropos(1), man(1).
END_OF_FILE
if test 758 -ne `wc -c <'man-1.0/whatis.man'`; then
    echo shar: \"'man-1.0/whatis.man'\" unpacked with wrong size!
fi
# end of 'man-1.0/whatis.man'
fi
if test -f 'man-1.0/whatis.sh' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'man-1.0/whatis.sh'\"
else
echo shar: Extracting \"'man-1.0/whatis.sh'\" \(1190 characters\)
sed "s/^X//" >'man-1.0/whatis.sh' <<'END_OF_FILE'
X#!/bin/sh
X#
X# whatis -- search the whatis database for keywords.  Like apropos,
X#           but match only commands (as whole words).
X#
X# Copyright (c) 1991, John W. Eaton.
X#
X# You may distribute under the terms of the GNU General Public
X# License as specified in the README file that comes with the man 1.0
X# distribution.  
X#
X# John W. Eaton
X# jwe at che.utexas.edu
X# Department of Chemical Engineering
X# The University of Texas at Austin
X# Austin, Texas  78712
X
XPATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
X
Xlibdir=LIBDIR
X
Xif [ $# = 0 ]
Xthen
X    echo "usage: `basename $0` name ..."
X    exit 1
Xfi
X
Xmanpath=`BINDIR/manpath -q | tr : '\040'`
X
Xif [ "$manpath" = "" ]
Xthen
X    echo "whatis: manpath is null"
X    exit 1
Xfi
X
Xwhile [ $1 ]
Xdo
X        found=0
X        for d in $manpath /usr/lib
X        do
X            if [ -f $d/whatis ]
X            then
X                grep -iw "^$1" $d/whatis
X                status=$?
X                if [ "$status" = "0" ]
X                then
X                    found=1
X		    export found;
X                fi
X            fi
X        done
X
X        if [ "$found" = "0" ]
X        then
X            echo "$1: nothing appropriate"
X        fi
X
X        shift
Xdone
X
Xexit
END_OF_FILE
if test 1190 -ne `wc -c <'man-1.0/whatis.sh'`; then
    echo shar: \"'man-1.0/whatis.sh'\" unpacked with wrong size!
fi
# end of 'man-1.0/whatis.sh'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both 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



More information about the Alt.sources mailing list