Remove GNU man implemenation now that the BSD version has cooked for a while.

This commit is contained in:
Gordon Tetlow 2011-04-21 07:14:10 +00:00
parent 84d8c09a40
commit 16e07d175a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=220910
24 changed files with 0 additions and 5170 deletions

View File

@ -1,339 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -1,12 +0,0 @@
# Master Makefile for man, manpath, apropos, and whatis
#
# You may distribute under the terms of the GNU General Public
# License as specified in the README file that comes with the man 1.0
# distribution.
#
# $FreeBSD$
#
SUBDIR = lib man manpath apropos
.include <bsd.subdir.mk>

View File

@ -1,31 +0,0 @@
# $FreeBSD$
#
# Set a bunch of things to hardcoded paths so that we don't accidently
# pick up a user's own version of some utility and hose ourselves.
#
libdir= /etc
bindir= ${BINDIR}
pager= more -s
manpath_config_file= /etc/manpath.config
troff= /usr/bin/groff -S -man
# -Tascii or localized encoding added automatically
nroff= /usr/bin/groff -S -Wall -mtty-char -man
apropos= /usr/bin/apropos
whatis= /usr/bin/whatis
eqn= /usr/bin/eqn
# -Tascii or localized encoding added automatically
neqn= /usr/bin/eqn
tbl= /usr/bin/tbl
col= /usr/bin/col
vgrind= /usr/bin/vgrind
refer= /usr/bin/refer
grap= # no grap
pic= /usr/bin/pic
zcat= /usr/bin/zcat
compress= /usr/bin/gzip -c
compext= .gz
LIBDESTDIR= ${.OBJDIR}/../lib
LIBMAN= ${LIBDESTDIR}/libman.a
.include "../Makefile.inc"

View File

@ -1,134 +0,0 @@
README file for man(1).
This is a replacement for Un*x man(1), apropos(1), whatis(1), and
manpath(1). It 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 provided without any
warranty whatever. I hope you find it useful.
This program is not a GNU product but it is distributed under the
terms of the GNU copyleft which is described in the file COPYING.
There is a solution written in perl which is probably superior in
every way, but, like me, you may prefer this one anyway.
:-)
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.
I have resisted the temptation to handle all the bizarre ways various
vendors have of organizing man pages. This version of man assumes
that directory trees have the structure:
.../man
/manSect
/foo.Sect*
...
/catSect
/foo.Sect*
...
where Sect is some number or string and should be listed in the set of
sections to be searched. It is not necessary to have both the cat*
and man* subdirectories, but you must have at least one. :-)
INSTALLATION
1. Run configure. This will grope around your system a bit and then
ask you a number of questions. It will create a Makefile from the
file Makefile.in, and a config.h file from config.h.in. You may
have to do some fine tuning to get things to work exactly right on
your system. If you do, I'd like to know what changes you had to
make to get things working.
2. Edit the manpath.config file. This determines the system-wide
mappings for bin directories and man page directories.
3. Do a `make all', try it out, and then if you're happy with that, do
a `make install'. You don't need to be root to use this set of
programs.
4. Install the whatis database(s) by running makewhatis. If you want
to keep things absolutely current, you'll need to run this whenever
you add new man pages. You might want to add an entry in your
crontab.
BUGS
If you find one of these, please tell me about it. If you have a fix,
that's even better. If not, I can't guarantee that I'll fix it, but I
would like to know about them.
John Eaton
jwe@che.utexas.edu
Department of Chemical Engineering
The University of Texas at Austin
Austin, Texas 78712
CHANGES
Partial list of changes since version 1.0:
Installation made easier (this was the intent anyway) with the
introduction of a configure script.
Commands like `man 3f intro' handled properly when the name of the
file we want is something like .../man3/intro.3f.
Man can now run set uid to a special user so formatted man pages don't
have to be world writable.
Man now works with compressed (.Z) frozen (.F) and yabba (.Y) cat
files. Frozen files are compressed files using freeze/melt, some
combination of LZW and tree coding. Sources for it came out on
comp.sources.misc or alt.sources or ... a few months ago. Yabba files
are compressed using yabba/unyabba, a data compression scheme posted
to alt.sources by Dan Bernstein.
Man now uses a more reasonable default for the search order:
1, n, l, 6, 8, 2, 3, 4, 5, 7, p, o
Man now allows for user-definable section search order via -S or
MANSECT.
Glob.c can work even if you don't have alloca, and works properly on
Suns with the Sun C compiler.
There is now a way to automatically to run preprocessors like the Sun
man program. The first line of the man page indicates which
preprocessors should be run:
If the first line is a string of the form:
'\" X
where X is separated from the the `"' by a single SPACE and
consists of any combination of characters in the following
list, man pipes its input to troff(1) or nroff(1) through
the corresponding preprocessors.
e eqn(1), or neqn for nroff
g grap(1)
p pic(1)
r refer(1)
t tbl(1), and col(1V) for nroff
v vgrind(1)
Preprocessors may also be set on the command line with -p or from the
environment with MANROFFSEQ.
The tbl preprocessor is run by default.
Manpath now stat()'s the directories in MANPATH to avoid including
directories that don't exist.
The output of apropos and whatis are now piped through PAGER.
There is a new option to show where you would find a man page
(-w option) and in what order (-w with -a).

View File

@ -1,125 +0,0 @@
$FreeBSD$
Things that would be nice but aren't really necessary:
0. Update the documentation.
XX Come up with an easier way to install this thing. There are now
lots of options and dependent flags to set. Should I worry too
much about this?
XX Properly handle commands like `man 3f intro' when the name of the
file we want is something like .../man3/intro.3f. The way this is
done right now seems sort of kludgey but it mostly works. See
man.c for details.
2. Malloc everything instead of having fixed limits... Or at least
check the limits everywhere. If you're paranoid about this, make
the limits big (famous last words: really, there aren't that many
things that could go wrong :-).
3. Try to do a little better job of memory management. There are a
lot of little temporary strings that are malloc'd and never freed.
This is probably ok for a standalone program but not so good if
you wanted to call man() from another program.
XX Come up with a clear view of the cat directory file permissions
problem. What's a good solution, other than having man run setuid
to some special user? (Make directories writable by all, cat
files 666.)
XX Allow a compile time option that makes man run setuid to some
other user that owns all the cat pages, so that they don't have to
be world writable.
XX Allow man to deal with compressed (.Z) frozen (.F) and yabba (.Y)
cat files. Frozen files are compressed files using freeze/melt,
some combination of LZW and tree coding. Sources for it came out
on comp.sources.misc or alt.sources or ... a few months ago.
Yabba files are compressed using yabba/unyabba, a data compression
scheme posted to alt.sources by Dan Bernstein.
XX Choose a more reasonable default for the search order. Perhaps
this: 1, n, l, 6, 8, 2, 3, 4, 5, 7, p, o
XX Fix glob.c so it doesn't need alloca, and/or fix it so that it can
work on a Sun:
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* !__GNUC__ */
#ifdef sparc
#include <alloca.h>
#endif /* sparc */
#endif /* __GNUC__ */
XX Add some way to automatically to run preprocessors. The Sun man
program has a convention that the first line of the man page can
indicate which preprocessors should be run. Here's an excerpt from
its man page:
Preprocessing Manual Pages
If the first line is a string of the form:
'\" X
where X is separated from the the `"' by a single SPACE and
consists of any combination of characters in the following
list, man pipes its input to troff(1) or nroff(1) through
the corresponding preprocessors.
e eqn(1), or neqn for nroff
r refer(1)
t tbl(1), and col(1V) for nroff
v vgrind(1)
If eqn or neqn is invoked, it will automatically read the
file /usr/pub/eqnchar (see eqnchar(7)).
XX Have manpath stat() the directories in MANPATH to avoid including
directories that don't exist. Some versions of man and whatis
complain when the directories (like /usr/new/man) don't exist.
XX Pipe the output of apropos and whatis through a pager.
XX I've been using your man(1) package for a while now and I ran into
a problem with the X man pages that use tbl commands. Is it
possible to configure your man(1) package to use a general command
string. For example, a user could set an environment variable:
setenv ROFFLINE 'pic $* | tbl | nroff -man'
13. Fix makewhatis so that it can handle stuff like this (from the
Motif 1.1 man pages):
.TH XmRowColumn 3X "" "" "" ""
.SH NAME
.mc |
\fBXmRowColumn \(em the RowColumn widget class.\fP
.mc
.iX "XmRowColumn"
.iX "widget class" "RowColumn"
.sp 1
.SH SYNOPSIS
14. Consider changing the format of the awk command's printf to use
"%s" instead of the standard 20.20s to accomodate the extra long
file names used by Motif. Maybe there's a better way to handle
this?
XX Add ability to run man on a local file
16. Handle per-tree tmac macros
XX Allow user-definable section search order via -S or $MANSECT.
Thus programmers can get stty(3) before stty(1).
XX Show all the places you would find a man page (-w option) and in
what order.
19. Support for multi-char sections like man1m/*.1m or manavs/*.avs
(can I have a section that doesn't start with a numeral?)
20. Implement man -K for regexp apropos
21. An option to grep through all the man pages in $MANPATH

View File

@ -1,21 +0,0 @@
# $FreeBSD$
SCRIPTS=apropos
MAN= apropos.1
CLEANFILES+= ${SCRIPTS} ${MAN}
LINKS= ${BINDIR}/apropos ${BINDIR}/whatis
MLINKS= apropos.1 whatis.1
.sh:
sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
-e 's,%pager%,${pager},' \
${.ALLSRC} > ${.TARGET}
apropos.1: apropos.man
sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
-e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
-e 's,%manpath_config_file%,${manpath_config_file},' \
${.ALLSRC} > ${.TARGET}
.include <bsd.prog.mk>

View File

@ -1,65 +0,0 @@
.\" Man page for apropos an whatis
.\"
.\" Copyright (c) 1990, 1991, John W. Eaton.
.\"
.\" You may distribute under the terms of the GNU General Public
.\" License as specified in the README file that comes with the man 1.0
.\" distribution.
.\"
.\" John W. Eaton
.\" jwe@che.utexas.edu
.\" Department of Chemical Engineering
.\" The University of Texas at Austin
.\" Austin, Texas 78712
.\"
.\" $FreeBSD$
.Dd January 15, 1991
.Dt APROPOS 1
.Os
.Sh NAME
.Nm apropos ,
.Nm whatis
.Nd search the whatis database
.Sh SYNOPSIS
.Nm apropos
.Ar keyword ...
.Nm whatis
.Ar keyword ...
.Sh DESCRIPTION
The
.Nm
utility
searches a set of database files containing short descriptions
of system commands for keywords and displays the result on the
standard output.
The
.Nm whatis
utility
displays only complete word matches.
.Pp
The
.Ar keyword
really is an extended regular expression, please read
.Xr grep 1
manual page for more information about its format.
.Sh ENVIRONMENT
.Bl -tag -width ".Ev PAGER"
.It Ev PATH , MANPATH , MANLOCALES
Used in finding the
.Nm whatis
database files.
See
.Xr manpath 1 .
.It Ev PAGER
Command used to page the output.
The default is
.Nm more Fl s .
.El
.Sh EXIT STATUS
The
.Nm
utility exits 0 on success, and 1 if no keyword matched.
.Sh SEE ALSO
.Xr grep 1 ,
.Xr makewhatis 1 ,
.Xr man 1

View File

@ -1,110 +0,0 @@
#!/bin/sh
#
# apropos -- search the whatis database for keywords.
#
# Copyright (c) February 1996 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
# Copyright (c) 1990, 1991, John W. Eaton.
#
# You may distribute under the terms of the GNU General Public
# License as specified in the README file that comes with the man
# distribution.
#
# John W. Eaton
# jwe@che.utexas.edu
# Department of Chemical Engineering
# The University of Texas at Austin
# Austin, Texas 78712
#
# $FreeBSD$
db=whatis # name of whatis data base
grepopt=''
# man -k complains if exit_nomatch=1 and no keyword matched
: ${exit_nomatch=0}
exit_error=2
# argument test
case $# in 0)
echo "usage: `basename $0` keyword ..." >&2
exit $exit_error
;;
esac
case "$0" in
*whatis) grepopt='-w';; # run as whatis(1)
*) grepopt='';; # otherwise run as apropos(1)
esac
# test manpath
manpath=`%bindir%/manpath -q | tr : '\040'`
case X"$manpath" in X)
echo "`basename $0`: manpath is null, using \"/usr/share/man\"" >&2
manpath=/usr/share/man
;;
esac
# reset $PAGER if $PAGER is empty
case X"$PAGER" in X)
PAGER="%pager%"
;;
esac
man_locales=`%bindir%/manpath -qL`
# search for existing */whatis databases
mandir=''
for d in $manpath
do
if [ -f "$d/$db" -a -r "$d/$db" ]
then
mandir="$mandir $d/$db"
fi
# Check for localized manpage subdirectories
if [ X"$man_locales" != X ]; then
for l in $man_locales
do
if [ -f "$d/$l/$db" -a -r "$d/$l/$db" ];
then
mandir="$mandir $d/$l/$db"
fi
done
fi
done
case X"$mandir" in X)
echo "`basename $0`: no whatis databases in $manpath" >&2
exit $exit_error
esac
for manpage
do
if grep -Ehi $grepopt -- "$manpage" $mandir; then :
else
echo "$manpage: nothing appropriate"
fi
done |
( # start $PAGER only if we find a manual page
while read line
do
case $line in
# collect error(s)
*": nothing appropriate") line2="$line2$line\n";;
# matched line or EOF
*) break;;
esac
done
# nothing found, exit
if [ -z "$line" -a ! -z "$line2" ]; then
printf -- "$line2"
exit $exit_nomatch
else
( printf -- "$line2"; echo "$line"; cat ) | $PAGER
fi
)

View File

@ -1,27 +0,0 @@
# $FreeBSD$
LIB= man
INTERNALLIB=
CFLAGS+= -DSTDC_HEADERS
CLEANFILES+= config.h
SRCS= gripes.c util.c
# Kludge to create config.h for other modules. The library itself doesn't
# depend on config.h.
SRCS+= config.h
config.h: ${.CURDIR}/config.h_dist ${.CURDIR}/../Makefile.inc
sed -e 's,%apropos%,${apropos},' -e 's,%whatis%,${whatis},' \
-e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
-e 's,%nroff%,${nroff},' -e 's,%tbl%,${tbl},' \
-e 's,%col%,${col},' -e 's,%pic%,${pic},' \
-e 's,%eqn%,${eqn},' -e 's,%neqn%,${neqn},' \
-e 's,%vgrind%,${vgrind},' -e 's,%refer%,${refer},' \
-e 's,%grap%,${grap},' -e 's,%zcat%,${zcat},' \
-e 's,%manpath_config_file%,${manpath_config_file},' \
-e 's,%compress%,${compress},' \
-e 's,%compext%,${compext},' \
${.CURDIR}/config.h_dist > ${.TARGET}
.include <bsd.lib.mk>

View File

@ -1,210 +0,0 @@
/*
* config.h
*
* If you haven't read the README file, now might be a good time.
*
* This file is edited by configure, so you shouldn't have to.
* If that doesn't work, edit this file to match your site.
*
* Sorry it's so long, but there are lots of things you might want to
* customize for your site.
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
/*
* This is the size of a number of internal buffers. It should
* probably not be less than 512.
*/
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif
/*
* This should be at least the size of the longest path.
*/
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
/*
* This is the maximum number of directories expected in the manpath.
*/
#ifndef MAXDIRS
#define MAXDIRS 64
#endif
/*
* This is the name of the group that owns the preformatted man pages.
* If you are running man as a setgid program, you should make sure
* that all of the preformatted man pages and the directories that
* they live in are readable and writeable and owned by this group.
*/
#ifdef SECURE_MAN_UID
#define MAN_USER ""
#endif
/*
* It's probably best to define absolute paths to all of these. If
* you don't, you'll be depending on the user's path to be correct
* when system () is called. This can result in weird behavior that's
* hard to track down, especially after you forget how this program
* works... If you don't have some of these programs, simply define
* them to be empty strings (i.e. ""). As a minimum, you must have
* nroff installed.
*/
#ifndef APROPOS
#define APROPOS "%apropos%"
#endif
#ifndef WHATIS
#define WHATIS "%whatis%"
#endif
#ifndef PAGER
#define PAGER "%pager%"
#endif
#ifdef HAS_TROFF
#ifndef TROFF
#define TROFF "%troff%"
#endif
#endif
#ifndef NROFF
#define NROFF "%nroff%"
#endif
#ifndef EQN
#define EQN "%eqn%"
#endif
#ifndef NEQN
#define NEQN "%neqn%"
#endif
#ifndef TBL
#define TBL "%tbl%"
#endif
#ifndef COL
#define COL "%col%"
#endif
#ifndef VGRIND
#define VGRIND "%vgrind%"
#endif
#ifndef REFER
#define REFER "%refer%"
#endif
#ifndef GRAP
#define GRAP "%grap%"
#endif
#ifndef PIC
#define PIC "%pic%"
#endif
/*
* Define the absolute path to the configuration file.
*/
#ifndef MAN_MAIN
static char config_file[] = "%manpath_config_file%" ;
#endif
/*
* Define the uncompression program(s) to use for those preformatted
* pages that end in the given character. If you add extras here, you
* may need to change man.c. [I have no idea what FCAT and YCAT files
* are! - I will leave them in for now.. -jkh]
*/
/* .F files */
#define FCAT ""
/* .Y files */
#define YCAT ""
/* .Z files */
#define ZCAT "%zcat%"
/*
* This is the standard program to use on this system for compressing
* pages once they have been formatted, and the character to tack on
* to the end of those files. The program listed is expected to read
* from the standard input and write compressed output to the standard
* output. These won't actually be used unless compression is enabled.
*/
#ifdef DO_COMPRESS
#define COMPRESSOR "%compress%"
#define COMPRESS_EXT "%compext%"
#endif
/*
* Define the standard manual sections. For example, if your man
* directory tree has subdirectories man1, man2, man3, mann,
* and man3foo, std_sections[] would have "1", "2", "3", "n", and
* "3foo". Directories are searched in the order they appear. Having
* extras isn't fatal, it just slows things down a bit.
*
* Note that this is just for directories to search. If you have
* files like .../man3/foobar.3Xtc, you don't need to have "3Xtc" in
* the list below -- this is handled separately, so that `man 3Xtc foobar',
* `man 3 foobar', and `man foobar' should find the file .../man3/foo.3Xtc,
* (assuming, of course, that there isn't a .../man1/foo.1 or somesuch
* that we would find first).
*
* Note that this list should be in the order that you want the
* directories to be searched. Is there a standard for this? What is
* the normal order? If anyone knows, please tell me!
*/
#ifndef MANPATH_MAIN
static char *std_sections[] =
{
"1", "1aout", "8", "2", "3", "n", "4", "5", "6", "7", "9", "l", NULL
};
#endif
/*
* Not all systems define these in stat.h.
*/
#ifndef S_IRUSR
#define S_IRUSR 00400 /* read permission: owner */
#endif
#ifndef S_IWUSR
#define S_IWUSR 00200 /* write permission: owner */
#endif
#ifndef S_IRGRP
#define S_IRGRP 00040 /* read permission: group */
#endif
#ifndef S_IWGRP
#define S_IWGRP 00020 /* write permission: group */
#endif
#ifndef S_IROTH
#define S_IROTH 00004 /* read permission: other */
#endif
#ifndef S_IWOTH
#define S_IWOTH 00002 /* write permission: other */
#endif
/*
* This is the mode used for formatted pages that we create. If you
* are using the setgid option, you should use 664. If you are not,
* you should use 666 and make the cat* directories mode 777.
*/
#ifndef CATMODE
#ifdef SECURE_MAN_UID
#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH
#else
#define CATMODE S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
#endif
#endif

View File

@ -1,180 +0,0 @@
/*
* gripes.c
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
#include <stdio.h>
#include "gripes.h"
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
extern int fprintf ();
extern int fflush ();
extern int exit ();
#endif
extern char *prognam;
void
gripe_no_name (section)
char *section;
{
if (section)
fprintf (stderr, "What manual page do you want from section %s?\n",
section);
else
fprintf (stderr, "What manual page do you want?\n");
fflush (stderr);
}
void
gripe_reading_man_file (name)
char *name;
{
fprintf (stderr, "Read access denied for file %s\n", name);
fflush (stderr);
}
void
gripe_converting_name (name, to_cat)
char *name;
int to_cat;
{
if (to_cat)
fprintf (stderr, "Error converting %s to cat name\n", name);
else
fprintf (stderr, "Error converting %s to man name\n", name);
fflush (stderr);
exit (1);
}
void
gripe_system_command (status)
int status;
{
fprintf (stderr, "Error executing formatting or display command.\n");
fprintf (stderr, "system command exited with status %d\n", status);
fflush (stderr);
}
void
gripe_not_found (name, section)
char *name, *section;
{
if (section)
fprintf (stderr, "No entry for %s in section %s of the manual\n",
name, section);
else
fprintf (stderr, "No manual entry for %s\n", name);
fflush (stderr);
}
void
gripe_incompatible (s)
char *s;
{
fprintf (stderr, "%s: incompatible options %s\n", prognam, s);
fflush (stderr);
exit (1);
}
void
gripe_getting_mp_config (file)
char *file;
{
fprintf (stderr, "%s: unable to find the file %s\n", prognam, file);
fflush (stderr);
exit (1);
}
void
gripe_reading_mp_config (file)
char *file;
{
fprintf (stderr, "%s: unable to make sense of the file %s\n", prognam, file);
fflush (stderr);
exit (1);
}
void
gripe_invalid_section (section)
char *section;
{
fprintf (stderr, "%s: invalid section (%s) selected\n", prognam, section);
fflush (stderr);
exit (1);
}
void
gripe_manpath ()
{
fprintf (stderr, "%s: manpath is null\n", prognam);
fflush (stderr);
exit (1);
}
void
gripe_alloc (bytes, object)
int bytes;
char *object;
{
fprintf (stderr, "%s: can't malloc %d bytes for %s\n",
prognam, bytes, object);
fflush (stderr);
exit (1);
}
void
gripe_roff_command_from_file (file)
char *file;
{
fprintf (stderr, "Error parsing *roff command from file %s\n", file);
fflush (stderr);
}
void
gripe_roff_command_from_env ()
{
fprintf (stderr, "Error parsing MANROFFSEQ. Using system defaults.\n");
fflush (stderr);
}
void
gripe_roff_command_from_command_line ()
{
fprintf (stderr, "Error parsing *roff command from command line.\n");
fflush (stderr);
}

View File

@ -1,30 +0,0 @@
/*
* gripes.h
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
extern void gripe_no_name ();
extern void gripe_converting_name ();
extern void gripe_system_command ();
extern void gripe_reading_man_file ();
extern void gripe_not_found ();
extern void gripe_invalid_section ();
extern void gripe_manpath ();
extern void gripe_alloc ();
extern void gripe_incompatible ();
extern void gripe_getting_mp_config ();
extern void gripe_reading_mp_config ();
extern void gripe_roff_command_from_file ();
extern void gripe_roff_command_from_env ();
extern void gripe_roff_command_from_command_line ();

View File

@ -1,180 +0,0 @@
/*
* util.c
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
/* $FreeBSD$ */
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
extern int fprintf ();
extern int tolower ();
#endif
extern char *strdup ();
extern int system ();
#include "gripes.h"
/*
* Extract last element of a name like /foo/bar/baz.
*/
char *
mkprogname (s)
register char *s;
{
char *t;
t = strrchr (s, '/');
if (t == (char *)NULL)
t = s;
else
t++;
return strdup (t);
}
void
downcase (s)
unsigned char *s;
{
register unsigned char c;
while ((c = *s) != '\0')
{
if (isalpha (c))
*s = tolower (c);
s++;
}
}
/*
* Is file a newer than file b?
*
* case:
*
* a newer than b returns 1
* a older than b returns 0
* stat on a fails returns -1
* stat on b fails returns -2
* stat on a and b fails returns -3
*/
int
is_newer (fa, fb)
register char *fa;
register char *fb;
{
struct stat fa_sb;
struct stat fb_sb;
register int fa_stat;
register int fb_stat;
register int status = 0;
fa_stat = stat (fa, &fa_sb);
if (fa_stat != 0)
status = 1;
fb_stat = stat (fb, &fb_sb);
if (fb_stat != 0)
status |= 2;
if (status != 0)
return -status;
return (fa_sb.st_mtime > fb_sb.st_mtime);
}
/*
* Is path a directory?
*/
int
is_directory (path)
char *path;
{
struct stat sb;
register int status;
status = stat (path, &sb);
if (status != 0)
return -1;
return ((sb.st_mode & S_IFDIR) == S_IFDIR);
}
/*
* Is path a regular file?
*/
int
is_file (path)
char *path;
{
struct stat sb;
register int status;
status = stat (path, &sb);
if (status != 0)
return -1;
return ((sb.st_mode & S_IFREG) == S_IFREG);
}
/*
* Attempt a system () call. Return 1 for success and 0 for failure
* (handy for counting successes :-).
*/
int
do_system_command (command)
char *command;
{
int status = 0;
extern int debug;
/*
* If we're debugging, don't really execute the command -- you never
* know what might be in that mangled string :-O.
*/
if (debug)
fprintf (stderr, "\ntrying command: %s\n", command);
else
status = system (command);
/* check return value from system() function first */
if (status == -1) {
fprintf(stderr,
"wait() for exit status of shell failed in function system()\n");
return 0;
} else if (status == 127 || status == (127 << 8)) {
fprintf(stderr, "execution of the shell failed in function system()\n");
return 0;
}
if (WIFSIGNALED(status))
return -1;
else if (WEXITSTATUS(status)) {
gripe_system_command (status);
return 0;
}
else
return 1;
}

View File

@ -1,33 +0,0 @@
# $FreeBSD$
#
MAN_LIBZ=YES
PROG= man
SRCS= man.c manpath.c glob.c
CFLAGS+= -I${LIBDESTDIR}
DPADD= ${LIBMAN}
LDADD= ${LIBMAN}
.if defined(MAN_LIBZ) && !empty(MAN_LIBZ)
DPADD+= ${LIBZ}
LDADD+= -lz
CFLAGS+=-DHAVE_LIBZ=1
.endif
CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF
CFLAGS+= -DDO_COMPRESS -DCATMODE=0644
CLEANFILES+= man.1
.PATH: ${.CURDIR}/../manpath
man.1: ${.CURDIR}/man.man
@${ECHO} echo Making ${.TARGET:T} from ${.ALLSRC:T}; \
sed -e 's,%libdir%,${libdir},' -e 's,%bindir%,${bindir},' \
-e 's,%pager%,${pager},' -e 's,%troff%,${troff},' \
-e 's,%manpath_config_file%,${manpath_config_file},' \
-e 's,%compress%,${compress},' \
${.ALLSRC} > ${.TARGET}
.include <bsd.prog.mk>

View File

@ -1,709 +0,0 @@
/* File-name wildcard pattern matching for GNU.
Copyright (C) 1985, 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* $FreeBSD$ */
/* To whomever it may concern: I have never seen the code which most
Unix programs use to perform this function. I wrote this from scratch
based on specifications for the pattern matching. --RMS. */
#ifdef SHELL
#include "config.h"
#endif /* SHELL */
#include <sys/types.h>
#if defined (USGr3) && !defined (DIRENT)
#define DIRENT
#endif /* USGr3 */
#if defined (Xenix) && !defined (SYSNDIR)
#define SYSNDIR
#endif /* Xenix */
#if defined (POSIX) || defined (DIRENT) || defined (__GNU_LIBRARY__)
#include <dirent.h>
#define direct dirent
#define D_NAMLEN(d) strlen((d)->d_name)
#else /* not POSIX or DIRENT or __GNU_LIBRARY__ */
#define D_NAMLEN(d) ((d)->d_namlen)
#ifdef USG
#if defined (SYSNDIR)
#include <sys/ndir.h>
#else /* SYSNDIR */
#include "ndir.h"
#endif /* not SYSNDIR */
#else /* not USG */
#include <sys/dir.h>
#endif /* USG */
#endif /* POSIX or DIRENT or __GNU_LIBRARY__ */
#if defined (_POSIX_SOURCE)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
#define REAL_DIR_ENTRY(dp) 1
#else
#define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* _POSIX_SOURCE */
#if defined (STDC_HEADERS) || defined (__GNU_LIBRARY__)
#include <stdlib.h>
#include <string.h>
#define STDC_STRINGS
#else /* STDC_HEADERS or __GNU_LIBRARY__ */
#if defined (USG)
#include <string.h>
#ifndef POSIX
#include <memory.h>
#endif /* POSIX */
#define STDC_STRINGS
#else /* not USG */
#ifdef NeXT
#include <string.h>
#else /* NeXT */
#include <strings.h>
#endif /* NeXT */
/* Declaring bcopy causes errors on systems whose declarations are different.
If the declaration is omitted, everything works fine. */
#endif /* not USG */
extern char *malloc ();
extern char *realloc ();
extern void free ();
#ifndef NULL
#define NULL 0
#endif
#endif /* Not STDC_HEADERS or __GNU_LIBRARY__. */
#ifdef STDC_STRINGS
#define bcopy(s, d, n) memcpy ((d), (s), (n))
#define index strchr
#define rindex strrchr
#endif /* STDC_STRINGS */
#ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* Not GCC. */
#ifdef sparc
#include <alloca.h>
#else /* Not sparc. */
extern char *alloca ();
#endif /* sparc. */
#endif /* GCC. */
#endif
/* Nonzero if '*' and '?' do not match an initial '.' for glob_filename. */
int noglob_dot_filenames = 1;
static int glob_match_after_star ();
#ifdef __FreeBSD__
static int collate_range_cmp(a, b)
int a, b;
{
static char s[2][2];
s[0][0] = a;
s[1][0] = b;
return (strcoll(s[0], s[1]));
}
#endif
/* Return nonzero if PATTERN has any special globbing chars in it. */
int
glob_pattern_p (pattern)
char *pattern;
{
register char *p = pattern;
register char c;
int open = 0;
while ((c = *p++) != '\0')
switch (c)
{
case '?':
case '*':
return 1;
case '[': /* Only accept an open brace if there is a close */
open++; /* brace to match it. Bracket expressions must be */
continue; /* complete, according to Posix.2 */
case ']':
if (open)
return 1;
continue;
case '\\':
if (*p++ == '\0')
return 0;
}
return 0;
}
/* Match the pattern PATTERN against the string TEXT;
return 1 if it matches, 0 otherwise.
A match means the entire string TEXT is used up in matching.
In the pattern string, `*' matches any sequence of characters,
`?' matches any character, [SET] matches any character in the specified set,
[!SET] matches any character not in the specified set.
A set is composed of characters or ranges; a range looks like
character hyphen character (as in 0-9 or A-Z).
[0-9a-zA-Z_] is the set of characters allowed in C identifiers.
Any other character in the pattern must be matched exactly.
To suppress the special syntactic significance of any of `[]*?!-\',
and match the character exactly, precede it with a `\'.
If DOT_SPECIAL is nonzero,
`*' and `?' do not match `.' at the beginning of TEXT. */
int
glob_match (pattern, text, dot_special)
char *pattern, *text;
int dot_special;
{
register char *p = pattern, *t = text;
register char c;
while ((c = *p++) != '\0')
switch (c)
{
case '?':
if (*t == '\0' || (dot_special && t == text && *t == '.'))
return 0;
else
++t;
break;
case '\\':
if (*p++ != *t++)
return 0;
break;
case '*':
if (dot_special && t == text && *t == '.')
return 0;
return glob_match_after_star (p, t);
case '[':
{
register char c1 = *t++;
int invert;
char *cp1 = p;
if (c1 == '\0')
return 0;
invert = (*p == '!');
if (invert)
p++;
c = *p++;
while (1)
{
register char cstart = c, cend = c;
if (c == '\\')
{
cstart = *p++;
cend = cstart;
}
if (cstart == '\0')
{
/* Missing ']'. */
if (c1 != '[')
return 0;
/* matched a single bracket */
p = cp1;
goto breakbracket;
}
c = *p++;
if (c == '-')
{
cend = *p++;
if (cend == '\\')
cend = *p++;
if (cend == '\0')
return 0;
c = *p++;
}
#ifdef __FreeBSD__
if ( collate_range_cmp (c1, cstart) >= 0
&& collate_range_cmp (c1, cend) <= 0
)
#else
if (c1 >= cstart && c1 <= cend)
#endif
goto match;
if (c == ']')
break;
}
if (!invert)
return 0;
break;
match:
/* Skip the rest of the [...] construct that already matched. */
while (c != ']')
{
if (c == '\0')
return 0;
c = *p++;
if (c == '\0')
return 0;
if (c == '\\')
p++;
}
if (invert)
return 0;
breakbracket:
break;
}
default:
if (c != *t++)
return 0;
}
return *t == '\0';
}
/* Like glob_match, but match PATTERN against any final segment of TEXT. */
static int
glob_match_after_star (pattern, text)
char *pattern, *text;
{
register char *p = pattern, *t = text;
register char c, c1;
while ((c = *p++) == '?' || c == '*')
if (c == '?' && *t++ == '\0')
return 0;
if (c == '\0')
return 1;
if (c == '\\')
c1 = *p;
else
c1 = c;
--p;
while (1)
{
if ((c == '[' || *t == c1) && glob_match (p, t, 0))
return 1;
if (*t++ == '\0')
return 0;
}
}
/* Return a vector of names of files in directory DIR
whose names match glob pattern PAT.
The names are not in any particular order.
Wildcards at the beginning of PAT do not match an initial period
if noglob_dot_filenames is nonzero.
The vector is terminated by an element that is a null pointer.
To free the space allocated, first free the vector's elements,
then free the vector.
Return NULL if cannot get enough memory to hold the pointer
and the names.
Return -1 if cannot access directory DIR.
Look in errno for more information. */
char **
glob_vector (pat, dir)
char *pat;
char *dir;
{
struct globval
{
struct globval *next;
char *name;
};
DIR *d;
register struct direct *dp;
struct globval *lastlink;
register struct globval *nextlink;
register char *nextname;
unsigned int count;
int lose;
register char **name_vector;
register unsigned int i;
#ifdef ALLOCA_MISSING
struct globval *templink;
#endif
d = opendir (dir);
if (d == NULL)
return (char **) -1;
lastlink = NULL;
count = 0;
lose = 0;
/* Scan the directory, finding all names that match.
For each name that matches, allocate a struct globval
on the stack and store the name in it.
Chain those structs together; lastlink is the front of the chain. */
while (1)
{
#if defined (SHELL)
/* Make globbing interruptible in the bash shell. */
extern int interrupt_state;
if (interrupt_state)
{
closedir (d);
lose = 1;
goto lost;
}
#endif /* SHELL */
dp = readdir (d);
if (dp == NULL)
break;
if (REAL_DIR_ENTRY (dp)
&& glob_match (pat, dp->d_name, noglob_dot_filenames))
{
#ifdef ALLOCA_MISSING
nextlink = (struct globval *) malloc (sizeof (struct globval));
#else
nextlink = (struct globval *) alloca (sizeof (struct globval));
#endif
nextlink->next = lastlink;
i = D_NAMLEN (dp) + 1;
nextname = (char *) malloc (i);
if (nextname == NULL)
{
lose = 1;
break;
}
lastlink = nextlink;
nextlink->name = nextname;
bcopy (dp->d_name, nextname, i);
count++;
}
}
closedir (d);
if (!lose)
{
name_vector = (char **) malloc ((count + 1) * sizeof (char *));
lose |= name_vector == NULL;
}
/* Have we run out of memory? */
#ifdef SHELL
lost:
#endif
if (lose)
{
/* Here free the strings we have got. */
while (lastlink)
{
free (lastlink->name);
#ifdef ALLOCA_MISSING
templink = lastlink->next;
free ((char *) lastlink);
lastlink = templink;
#else
lastlink = lastlink->next;
#endif
}
return NULL;
}
/* Copy the name pointers from the linked list into the vector. */
for (i = 0; i < count; ++i)
{
name_vector[i] = lastlink->name;
#ifdef ALLOCA_MISSING
templink = lastlink->next;
free ((char *) lastlink);
lastlink = templink;
#else
lastlink = lastlink->next;
#endif
}
name_vector[count] = NULL;
return name_vector;
}
/* Return a new array, replacing ARRAY, which is the concatenation
of each string in ARRAY to DIR.
Return NULL if out of memory. */
static char **
glob_dir_to_array (dir, array)
char *dir, **array;
{
register unsigned int i, l;
int add_slash = 0;
char **result;
l = strlen (dir);
if (l == 0)
return array;
if (dir[l - 1] != '/')
add_slash++;
for (i = 0; array[i] != NULL; i++)
;
result = (char **) malloc ((i + 1) * sizeof (char *));
if (result == NULL)
return NULL;
for (i = 0; array[i] != NULL; i++)
{
result[i] = (char *) malloc (1 + l + add_slash + strlen (array[i]));
if (result[i] == NULL)
return NULL;
strcpy (result[i], dir);
if (add_slash)
result[i][l] = '/';
strcpy (result[i] + l + add_slash, array[i]);
}
result[i] = NULL;
/* Free the input array. */
for (i = 0; array[i] != NULL; i++)
free (array[i]);
free ((char *) array);
return result;
}
/* Do globbing on PATHNAME. Return an array of pathnames that match,
marking the end of the array with a null-pointer as an element.
If no pathnames match, then the array is empty (first element is null).
If there isn't enough memory, then return NULL.
If a file system error occurs, return -1; `errno' has the error code.
Wildcards at the beginning of PAT, or following a slash,
do not match an initial period if noglob_dot_filenames is nonzero. */
char **
glob_filename (pathname)
char *pathname;
{
char **result;
unsigned int result_size;
char *directory_name, *filename;
unsigned int directory_len;
result = (char **) malloc (sizeof (char *));
result_size = 1;
if (result == NULL)
return NULL;
result[0] = NULL;
/* Find the filename. */
filename = rindex (pathname, '/');
if (filename == NULL)
{
filename = pathname;
directory_name = "";
directory_len = 0;
}
else
{
directory_len = (filename - pathname) + 1;
#ifdef ALLOCA_MISSING
directory_name = (char *) malloc (directory_len + 1);
#else
directory_name = (char *) alloca (directory_len + 1);
#endif
bcopy (pathname, directory_name, directory_len);
directory_name[directory_len] = '\0';
++filename;
}
/* If directory_name contains globbing characters, then we
have to expand the previous levels. Just recurse. */
if (glob_pattern_p (directory_name))
{
char **directories;
register unsigned int i;
if (directory_name[directory_len - 1] == '/')
directory_name[directory_len - 1] = '\0';
directories = glob_filename (directory_name);
#ifdef ALLOCA_MISSING
free ((char *) directory_name);
#endif
if (directories == NULL)
goto memory_error;
else if (directories == (char **) -1)
return (char **) -1;
else if (*directories == NULL)
{
free ((char *) directories);
return (char **) -1;
}
/* We have successfully globbed the preceding directory name.
For each name in DIRECTORIES, call glob_vector on it and
FILENAME. Concatenate the results together. */
for (i = 0; directories[i] != NULL; i++)
{
char **temp_results = glob_vector (filename, directories[i]);
if (temp_results == NULL)
goto memory_error;
else if (temp_results == (char **) -1)
/* This filename is probably not a directory. Ignore it. */
;
else
{
char **array = glob_dir_to_array (directories[i], temp_results);
register unsigned int l;
l = 0;
while (array[l] != NULL)
++l;
result = (char **) realloc (result,
(result_size + l) * sizeof (char *));
if (result == NULL)
goto memory_error;
for (l = 0; array[l] != NULL; ++l)
result[result_size++ - 1] = array[l];
result[result_size - 1] = NULL;
free ((char *) array);
}
}
/* Free the directories. */
for (i = 0; directories[i] != NULL; i++)
free (directories[i]);
free ((char *) directories);
return result;
}
/* If there is only a directory name, return it. */
if (*filename == '\0')
{
result = (char **) realloc ((char *) result, 2 * sizeof (char *));
if (result != NULL)
{
result[0] = (char *) malloc (directory_len + 1);
if (result[0] == NULL)
{
#ifdef ALLOCA_MISSING
free ((char *) directory_name);
#endif
goto memory_error;
}
bcopy (directory_name, result[0], directory_len + 1);
result[1] = NULL;
}
#ifdef ALLOCA_MISSING
free ((char *) directory_name);
#endif
return result;
}
else
{
/* Otherwise, just return what glob_vector
returns appended to the directory name. */
char **temp_results = glob_vector (filename,
(directory_len == 0
? "." : directory_name));
if (temp_results == NULL || temp_results == (char **) -1)
{
#ifdef NO_ALLOCA
free ((char *) directory_name);
#endif
return temp_results;
}
temp_results = glob_dir_to_array (directory_name, temp_results);
#ifdef NO_ALLOCA
free ((char *) directory_name);
#endif
return temp_results;
}
/* We get to memory error if the program has run out of memory, or
if this is the shell, and we have been interrupted. */
memory_error:
if (result != NULL)
{
register unsigned int i;
for (i = 0; result[i] != NULL; ++i)
free (result[i]);
free ((char *) result);
}
#if defined (SHELL)
{
extern int interrupt_state;
if (interrupt_state)
throw_to_top_level ();
}
#endif /* SHELL */
return NULL;
}
#ifdef TEST
main (argc, argv)
int argc;
char **argv;
{
char **value;
int i, optind;
for (optind = 1; optind < argc; optind++)
{
value = glob_filename (argv[optind]);
if (value == NULL)
puts ("virtual memory exhausted");
else if (value == (char **) -1)
perror (argv[optind]);
else
for (i = 0; value[i] != NULL; i++)
puts (value[i]);
}
exit (0);
}
#endif /* TEST */

File diff suppressed because it is too large Load Diff

View File

@ -1,310 +0,0 @@
.\" Man page for man
.\"
.\" Copyright (c) 1990, 1991, John W. Eaton.
.\"
.\" You may distribute under the terms of the GNU General Public
.\" License as specified in the README file that comes with the man 1.0
.\" distribution.
.\"
.\" John W. Eaton
.\" jwe@che.utexas.edu
.\" Department of Chemical Engineering
.\" The University of Texas at Austin
.\" Austin, Texas 78712
.\"
.\" $FreeBSD$
.\"
.Dd December 3, 2005
.Dt MAN 1
.Os
.Sh NAME
.Nm man
.Nd format and display the on-line manual pages
.Sh SYNOPSIS
.Nm
.Op Fl adfhkotw
.Op Fl m Ar arch Ns Op : Ns Ar machine
.Op Fl p Ar string
.Op Fl M Ar path
.Op Fl P Ar pager
.Op Fl S Ar list
.Op Ar section
.Ar name ...
.Sh DESCRIPTION
The
.Nm
utility
formats and displays the on-line manual pages.
This version knows
about the
.Ev MANPATH
and
.Ev PAGER
environment variables, so you can have
your own set(s) of personal man pages and choose whatever program you
like to display the formatted pages.
If
.Ar section
is specified,
.Nm
only looks in that section of the manual.
You may also specify the
order to search the sections for entries and which preprocessors to
run on the source files via command line options or environment
variables.
If enabled by the system administrator, formatted man
pages will also be compressed with the
.Dq Li "%compress%"
command to save space.
.Pp
The options are as follows:
.Bl -tag -width ".Fl P Ar pager"
.It Fl M Ar path
Specify an alternate manpath.
By default,
.Nm
uses
.Xr manpath 1
(which is built into the
.Nm
binary)
to determine the path to search.
This option overrides the
.Ev MANPATH
environment variable.
.It Fl P Ar pager
Specify which pager to use.
By default,
.Nm
uses
.Dq Li "%pager%" .
This option overrides the
.Ev PAGER
environment variable.
.It Fl S Ar list
List is a colon separated list of manual sections to search.
This option overrides the
.Ev MANSECT
environment variable.
.It Fl a
By default,
.Nm
will exit after displaying the first manual page it
finds.
Using this option forces
.Nm
to display all the manual pages
that match
.Ar name ,
not just the first.
.It Fl d
Do not actually display the man pages, but do print gobs of debugging
information.
.It Fl f
Equivalent to
.Nm whatis .
.It Fl h
Print a help message and exit.
.It Fl k
Equivalent to
.Nm apropos .
.It Fl m Ar arch Ns Op : Ns Ar machine
As some manual pages are intended only for specific
architectures and machine types,
.Nm
searches any subdirectories,
with the same name as the current machine type and architecture,
in every directory which it searches.
Machine specific areas are checked before architecture specific areas,
and architecture specific areas are checked before general areas.
For example, for
.Dq Li i386:pc98 ,
the following subdirectories will be searched for section 8
manpages, in order:
.Pa man8/pc98, man8/i386 ,
and
.Pa man8 .
.Pp
The current machine type may be overridden using this option
or by setting the environment variable
.Ev MACHINE
to the name of a specific machine.
The current architecture may be overridden using this option
or by setting the environment variable
.Ev MACHINE_ARCH
to the name of a specific architecture.
This option overrides the
.Ev MACHINE
and
.Ev MACHINE_ARCH
environment variables.
A
.Ar machine
component, if omitted, defaults to
.Ar arch .
.It Fl o
Look for original, non-localized manpages only.
.Pp
By default,
.Nm
searches for a localized manpage
in a set of locale subdirectories of each
.Xr manpath 1
component.
.Pp
Locale name is taken from the first of three environment variables
with a nonempty value:
.Ev LC_ALL , LC_CTYPE ,
or
.Ev LANG ,
in the specified order.
.Pp
If the value could not be determined, or is not a valid locale name,
then only non-localized manpage will be looked up.
.Pp
Otherwise,
.Nm
will search in the following subdirectories, in the order of precedence:
.Pp
.Bl -item -offset indent -compact
.Sm off
.It
.Pa <lang> _ <country> . <charset>
.It
.Pa <lang> . <charset>
.It
.Pa en . <charset>
.Sm on
.El
.Pp
For example, for the
.Dq Li de_DE.ISO8859-1
locale,
.Nm
will search in the following subdirectories of the
.Pa /usr/share/man
manpath component:
.Pp
.Bl -item -offset indent -compact
.It
.Pa /usr/share/man/de_DE.ISO8859-1
.It
.Pa /usr/share/man/de.ISO8859-1
.It
.Pa /usr/share/man/en.ISO8859-1
.El
.Pp
Finally,
if the search of localized manpage fails,
it will be looked up in the default
.Pa /usr/share/man
directory.
.It Fl p Ar string
Specify the sequence of preprocessors to run before
.Xr nroff 1
or
.Xr troff 1 .
Not all installations will have a full set of preprocessors.
Some of the preprocessors and the letters used to designate them are:
.Nm eqn Pq e ,
.Nm grap Pq g ,
.Nm pic Pq p ,
.Nm tbl Pq t ,
.Nm vgrind Pq v ,
.Nm refer Pq r .
This option overrides the
.Ev MANROFFSEQ
environment variable.
.It Fl t
Use
.Dq Li "%troff%"
to format the manual page, passing the output to stdout.
The default output format of
.Xr groff 1
is Postscript, but see the manual page of
.Xr groff 1
for ways to pick an alternate format.
.Pp
Depending on the selected format and the availability of printing
devices, the output
may need to be passed through some filter or another before being
printed.
.It Fl w
Do not actually display the man pages, but do print the location(s) of
the files that would be formatted or displayed.
.El
.Sh ENVIRONMENT
.Bl -tag -width ".Ev MACHINE_ARCH"
.It Ev LC_ALL , LC_CTYPE , LANG
These variables specify the preferred language for manual pages.
(See the
.Fl o
option above.)
.It Ev MACHINE
If
.Ev MACHINE
is set, its value is used to override the current machine type
when searching machine specific subdirectories.
.It Ev MACHINE_ARCH
If
.Ev MACHINE_ARCH
is set, its value is used to override the current architecture
when searching architecture specific subdirectories.
.It Ev MANPATH
If
.Ev MANPATH
is set, its value is used as the path to search for manual pages.
.It Ev MANROFFSEQ
If
.Ev MANROFFSEQ
is set, its value is used to determine the set of preprocessors run
before running
.Xr nroff 1
or
.Xr troff 1 .
By default, pages are passed through
the table preprocessor
.Pq Xr tbl 1
before
.Xr nroff 1 .
.It Ev MANSECT
If
.Ev MANSECT
is set, its value is used to determine which manual sections to search.
.It Ev PAGER
If
.Ev PAGER
is set, its value is used as the name of the program to use to display
the man page.
By default,
.Dq Li "%pager%"
is used.
.El
.Sh EXAMPLES
.Pp
Normally, to look at the relevant manpage information for
.Dq Li getopt ,
one would use:
.Pp
.Dl "man getopt"
.Pp
However, when referring to a specific section of the manual,
such as
.Xr getopt 3 ,
one would use:
.Pp
.Dl "man 3 getopt"
.Sh SEE ALSO
.Xr apropos 1 ,
.Xr groff 1 ,
.Xr manpath 1 ,
.Xr more 1 ,
.Xr whatis 1 ,
.Xr man 7 ,
.Xr mdoc 7
.Sh BUGS
The
.Fl t
option only works if the
.Xr troff 1 Ns -like
program is installed.

View File

@ -1,51 +0,0 @@
/*
<dir.h> -- definitions for 4.2BSD-compatible directory access
last edit: 09-Jul-1983 D A Gwyn
*/
#ifdef VMS
#ifndef FAB$C_BID
#include <fab.h>
#endif
#ifndef NAM$C_BID
#include <nam.h>
#endif
#ifndef RMS$_SUC
#include <rmsdef.h>
#endif
#include "dir.h"
#endif /* VMS */
#define DIRBLKSIZ 512 /* size of directory block */
#ifdef VMS
#define MAXNAMLEN (DIR$S_NAME + 7) /* 80 plus room for version #. */
#define MAXFULLSPEC NAM$C_MAXRSS /* Maximum full spec */
#else
#define MAXNAMLEN 15 /* maximum filename length */
#endif /* VMS */
/* NOTE: MAXNAMLEN must be one less than a multiple of 4 */
struct direct /* data from readdir() */
{
long d_ino; /* inode number of entry */
unsigned short d_reclen; /* length of this record */
unsigned short d_namlen; /* length of string in d_name */
char d_name[MAXNAMLEN+1]; /* name of file */
};
typedef struct
{
int dd_fd; /* file descriptor */
int dd_loc; /* offset in block */
int dd_size; /* amount of valid data */
char dd_buf[DIRBLKSIZ]; /* directory block */
} DIR; /* stream data from opendir() */
extern DIR *opendir();
extern struct direct *readdir();
extern long telldir();
extern void seekdir();
extern void closedir();
#define rewinddir( dirp ) seekdir( dirp, 0L )

View File

@ -1,17 +0,0 @@
/*
* version.h
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
static char version[] = "1.1";

View File

@ -1,17 +0,0 @@
# $FreeBSD$
PROG= manpath
DPADD= ${LIBMAN}
LDADD= ${LIBMAN}
CFLAGS+= -DMAIN -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS
CFLAGS+= -I${.CURDIR}/../lib -I${.OBJDIR}/../lib
CLEANFILES+= manpath.1
manpath.1: ${.CURDIR}/manpath.man
@${ECHO} Making ${.TARGET:T} from ${.ALLSRC:T}; \
sed -e 's,%manpath_config_file%,/etc/manpath.config,' \
${.ALLSRC} > ${.TARGET}
.include <bsd.prog.mk>

View File

@ -1,602 +0,0 @@
/*
* manpath.c
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*
* $FreeBSD$
*/
#define MANPATH_MAIN
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "config.h"
#include "manpath.h"
#include "gripes.h"
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
extern int fprintf ();
extern int strcmp ();
extern int strncmp ();
extern char *memcpy ();
extern char *getenv();
extern char *malloc();
extern void free ();
extern int exit ();
#endif
extern char *strdup ();
extern int is_directory ();
#ifndef MAIN
extern int debug;
#endif
#ifdef MAIN
#ifndef STDC_HEADERS
extern char *strcpy ();
extern int fflush ();
#endif
char *prognam;
int debug;
int locale;
char *man_locales;
/*
* Examine user's PATH and print a reasonable MANPATH.
*/
int
main(argc, argv)
int argc;
char **argv;
{
int c;
int quiet;
char *mp;
extern int getopt ();
extern char *mkprogname ();
void usage ();
char *manpath ();
quiet = 1;
prognam = mkprogname (argv[0]);
while ((c = getopt (argc, argv, "dhLq?")) != -1)
{
switch (c)
{
case 'd':
debug++;
break;
case 'L':
locale++;
break;
case 'q':
quiet = 0;
break;
case '?':
case 'h':
default:
usage();
break;
}
}
mp = manpath (quiet);
fprintf (stdout, "%s\n", mp);
fflush (stdout);
return 0;
}
void
usage ()
{
fprintf (stderr, "usage: %s [-dLq]\n", prognam);
exit (1);
}
#endif /* MAIN */
/*
* If the environment variable MANPATH is set, return it.
* If the environment variable PATH is set and has a nonzero length,
* try to determine the corresponding manpath, otherwise, return the
* default manpath.
*
* The manpath.config file is used to map system wide /bin directories
* to top level man page directories.
*
* For directories which are in the user's path but not in the
* manpath.config file, see if there is a subdirectory `man' or `MAN'.
* If so, add that directory to the path. Example: user has
* $HOME/bin in his path and the directory $HOME/bin/man exists -- the
* directory $HOME/bin/man will be added to the manpath.
*
* Also search for a `man' directory next to the directory on the path.
* Example: $HOME/bin will look for $HOME/man
*/
char *
manpath (perrs)
register int perrs;
{
register int len;
register char *manpathlist;
register char *path;
int get_dirlist ();
char *def_path ();
char *get_manpath ();
if (get_dirlist ())
gripe_reading_mp_config (config_file);
#ifdef MAIN
if (locale)
{
if ((manpathlist = getenv ("MANLOCALES")) != NULL)
/*
* This must be it.
*/
{
if (perrs)
fprintf (stderr, "(Warning: MANLOCALES environment variable set)\n");
return strdup (manpathlist);
}
return (man_locales ? man_locales : "");
}
#endif /* MAIN */
if ((manpathlist = getenv ("MANPATH")) != NULL)
/*
* This must be it.
*/
{
if (perrs)
fprintf (stderr, "(Warning: MANPATH environment variable set)\n");
return strdup (manpathlist);
}
else if ((path = getenv ("PATH")) == NULL)
/*
* Things aren't going to work well, but hey...
*/
{
if (perrs)
fprintf (stderr, "Warning: path not set\n");
return def_path (perrs);
}
else
{
if ((len = strlen (path)) == 0)
/*
* Things aren't going to work well here either...
*/
{
if (perrs)
fprintf (stderr, "Warning: path set but has zero length\n");
return def_path (perrs);
}
return get_manpath (perrs, path);
}
}
/*
* Get the list of bin directories and the corresponding man
* directories from the manpath.config file.
*
* This is ugly.
*/
int
get_dirlist ()
{
int i;
char *bp;
char *p;
char buf[BUFSIZ];
DIRLIST *dlp = list;
FILE *config;
if ((config = fopen (config_file, "r")) == NULL)
gripe_getting_mp_config (config_file);
while ((bp = fgets (buf, BUFSIZ, config)) != NULL)
{
while (*bp && (*bp == ' ' || *bp == '\t'))
bp++;
if (*bp == '#' || *bp == '\n')
continue;
if (!strncmp ("MANDATORY_MANPATH", bp, 17) ||
!strncmp ("OPTIONAL_MANPATH", bp, 16))
{
if ((p = strchr (bp, ' ')) == NULL &&
(p = strchr (bp, '\t')) == NULL) {
fclose(config);
return -1;
}
dlp->type = *bp == 'M'? MANPATH_MANDATORY: MANPATH_OPTIONAL;
bp = p;
while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
bp++;
i = 0;
while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
dlp->mandir[i++] = *bp++;
dlp->mandir[i] = '\0';
if (debug)
fprintf (stderr, "found %s man directory %s\n",
dlp->type == MANPATH_MANDATORY? "mandatory": "optional",
dlp->mandir);
}
else if (!strncmp ("MANPATH_MAP", bp, 11))
{
if ((p = strchr (bp, ' ')) == NULL &&
(p = strchr (bp, '\t')) == NULL) {
fclose(config);
return -1;
}
bp = p;
dlp->type = MANPATH_MAP;
while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
bp++;
i = 0;
while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
dlp->bin[i++] = *bp++;
dlp->bin[i] = '\0';
while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
bp++;
i = 0;
while (*bp && *bp != '\n' && *bp != ' ' && *bp != '\t')
dlp->mandir[i++] = *bp++;
dlp->mandir[i] = '\0';
if (debug)
fprintf (stderr, "found manpath map %s --> %s\n",
dlp->bin, dlp->mandir);
}
else if (!strncmp ("MANLOCALES", bp, 10))
{
if ((p = strchr (bp, ' ')) == NULL &&
(p = strchr (bp, '\t')) == NULL) {
fclose(config);
return -1;
}
bp = p;
while (*bp && *bp != '\n' && (*bp == ' ' || *bp == '\t'))
bp++;
for (p = bp; *p && *p != '\n'; p++)
;
do {
*p-- = '\0';
} while (p >= bp && (*p == ' ' || *p == '\t'));
#ifdef MAIN
if (man_locales != NULL)
free (man_locales);
if ((man_locales = strdup (bp)) == NULL) {
fclose(config);
return -1;
}
#endif /* MAIN */
if (debug)
fprintf (stderr, "found man locales: %s\n", bp);
}
else
{
gripe_reading_mp_config (config_file);
}
dlp++;
}
fclose(config);
dlp->bin[0] = '\0';
dlp->mandir[0] = '\0';
dlp->type = MANPATH_NONE;
return 0;
}
/*
* Construct the default manpath. This picks up mandatory
* and optional (if they exist) manpaths only.
*/
char *
def_path (perrs)
int perrs;
{
register int len;
register char *manpathlist, *p;
register DIRLIST *dlp;
len = 0;
dlp = list;
while (dlp->type != MANPATH_NONE) {
if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL)
len += strlen (dlp->mandir) + 1;
dlp++;
}
manpathlist = (char *) malloc (len);
if (manpathlist == NULL)
gripe_alloc (len, "manpathlist");
*manpathlist = '\0';
dlp = list;
p = manpathlist;
while (dlp->type != MANPATH_NONE) {
if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL) {
int status;
char *path = dlp->mandir;
status = is_directory(path);
if (status < 0 && perrs && dlp->type == MANPATH_MANDATORY)
{
fprintf (stderr, "Warning: couldn't stat file %s!\n", path);
}
else if (status == 0 && perrs)
{
fprintf (stderr, "Warning: %s isn't a directory!\n", path);
}
else if (status == 1)
{
len = strlen (path);
memcpy (p, path, len);
p += len;
*p++ = ':';
}
}
dlp++;
}
p[-1] = '\0';
return manpathlist;
}
/*
* For each directory in the user's path, see if it is one of the
* directories listed in the manpath.config file. If so, and it is
* not already in the manpath, add it. If the directory is not listed
* in the manpath.config file, see if there is a subdirectory `man' or
* `MAN'. If so, and it is not already in the manpath, add it.
* Example: user has $HOME/bin in his path and the directory
* $HOME/bin/man exists -- the directory $HOME/bin/man will be added
* to the manpath.
*/
char *
get_manpath (perrs, path)
register int perrs;
register char *path;
{
register int len;
register char *tmppath;
register char *t;
register char *p;
register char **lp;
register char *end;
register char *manpathlist;
register DIRLIST *dlp;
void add_dir_to_list ();
char *has_subdirs ();
tmppath = strdup (path);
for (p = tmppath; ; p = end+1)
{
if ((end = strchr(p, ':')) != NULL)
*end = '\0';
if (debug)
fprintf (stderr, "\npath directory %s ", p);
if (*p != '/')
{
if (debug)
fprintf (stderr, "is not an absolute pathname\n");
goto found; /* skip. */
}
/*
* The directory we're working on is in the config file.
* If we haven't added it to the list yet, do.
*/
for (dlp = list; dlp->mandir[0] != '\0'; dlp++)
if (dlp->bin[0] != '\0' && !strcmp (p, dlp->bin))
{
if (debug)
fprintf (stderr, "is in the config file\n");
add_dir_to_list (tmplist, dlp->mandir, perrs);
goto found;
}
/*
* The directory we're working on isn't in the config file. See
* if it has man or MAN subdirectories. If so, and it hasn't
* been added to the list, do.
*/
if (debug)
fprintf (stderr, "is not in the config file\n");
t = has_subdirs (p);
if (t != NULL)
{
if (debug)
fprintf (stderr, "but it does have a man or MAN subdirectory\n");
add_dir_to_list (tmplist, t, perrs);
free (t);
}
else
{
if (debug)
fprintf (stderr, "and doesn't have man or MAN subdirectories\n");
}
found:
if (!end)
break;
}
if (debug)
fprintf (stderr, "\nadding mandatory man directories\n\n");
dlp = list;
while (dlp->type != MANPATH_NONE) {
if (dlp->type == MANPATH_MANDATORY || dlp->type == MANPATH_OPTIONAL)
add_dir_to_list (tmplist, dlp->mandir,
dlp->type == MANPATH_MANDATORY? perrs: 0);
dlp++;
}
len = 0;
lp = tmplist;
while (*lp != NULL)
{
len += strlen (*lp) + 1;
lp++;
}
if (!len)
return strdup("");
manpathlist = (char *) malloc (len);
if (manpathlist == NULL)
gripe_alloc (len, "manpathlist");
*manpathlist = '\0';
lp = tmplist;
p = manpathlist;
while (*lp != NULL)
{
len = strlen (*lp);
memcpy (p, *lp, len);
p += len;
*p++ = ':';
lp++;
}
p[-1] = '\0';
return manpathlist;
}
/*
* Add a directory to the manpath list if it isn't already there.
*/
void
add_dir_to_list (lp, dir, perrs)
char **lp;
char *dir;
int perrs;
{
extern char *strdup ();
int status;
while (*lp != NULL)
{
if (!strcmp (*lp, dir))
{
if (debug)
fprintf (stderr, "%s is already in the manpath\n", dir);
return;
}
lp++;
}
/*
* Not found -- add it.
*/
status = is_directory(dir);
if (status < 0 && perrs)
{
fprintf (stderr, "Warning: couldn't stat file %s!\n", dir);
}
else if (status == 0 && perrs)
{
fprintf (stderr, "Warning: %s isn't a directory!\n", dir);
}
else if (status == 1)
{
if (debug)
fprintf (stderr, "adding %s to manpath\n", dir);
*lp = strdup (dir);
}
}
/*
* Check to see if the current directory has man or MAN
* subdirectories.
*/
char *
has_subdirs (p)
register char *p;
{
int len;
register char *t;
len = strlen (p);
t = (char *) malloc ((unsigned) len + 5);
if (t == NULL)
gripe_alloc (len+5, "p\n");
memcpy (t, p, len);
strcpy (t + len, "/man");
if (is_directory (t) == 1)
return t;
strcpy (t + len, "/MAN");
if (is_directory (t) == 1)
return t;
/* If the path ends in `bin' then replace with `man' and see if that works. */
if (len > 3 && strncmp(t+len-4, "/bin", 4) == 0) {
strcpy(t+len-4, "/man");
if (is_directory(t) == 1)
return t;
}
return NULL;
}

View File

@ -1,29 +0,0 @@
# $FreeBSD$
#
# This file is read by manpath(1) to configure the mandatory manpath,
# optional manpath and to map each path element to a manpath element.
# The format is:
#
# MANDATORY_MANPATH manpath_element
# OPTIONAL_MANPATH manpath_element
# MANPATH_MAP path_element manpath_element
# MANLOCALES locale1 locale2 ...
#
# every automatically generated MANPATH includes these fields
#
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/share/openssl/man
#
# check if the directory exists and if it does, add it to MANPATH
#
OPTIONAL_MANPATH /usr/local/man
#
# set up PATH to MANPATH mapping
#
MANPATH_MAP /bin /usr/share/man
MANPATH_MAP /usr/bin /usr/share/man
MANPATH_MAP /usr/local/bin /usr/local/man
#
# set man locales, if needed
#
#MANLOCALES ru_RU.KOI8-R

View File

@ -1,32 +0,0 @@
/*
* manpath.h
*
* Copyright (c) 1990, 1991, John W. Eaton.
*
* You may distribute under the terms of the GNU General Public
* License as specified in the file COPYING that comes with the man
* distribution.
*
* John W. Eaton
* jwe@che.utexas.edu
* Department of Chemical Engineering
* The University of Texas at Austin
* Austin, Texas 78712
*/
typedef struct
{
char mandir[MAXPATHLEN];
char bin[MAXPATHLEN];
int type;
} DIRLIST;
/* manpath types */
#define MANPATH_NONE 0
#define MANPATH_MANDATORY 1 /* manpath is mandatory */
#define MANPATH_OPTIONAL 2 /* manpath is optional */
#define MANPATH_MAP 3 /* maps path to manpath */
DIRLIST list[MAXDIRS];
char *tmplist[MAXDIRS];

View File

@ -1,98 +0,0 @@
.\" Man page for manpath
.\"
.\" Copyright (c) 1990, 1991, John W. Eaton.
.\"
.\" You may distribute under the terms of the GNU General Public
.\" License as specified in the README file that comes with the man 1.0
.\" distribution.
.\"
.\" John W. Eaton
.\" jwe@che.utexas.edu
.\" Department of Chemical Engineering
.\" The University of Texas at Austin
.\" Austin, Texas 78712
.\"
.\" $FreeBSD$
.Dd August 16, 1999
.Dt MANPATH 1
.Os
.Sh NAME
.Nm manpath
.Nd determine user's search path for man pages
.Sh SYNOPSIS
.Nm
.Op Fl dLq
.Sh DESCRIPTION
The
.Nm
utility
tries to determine the user's manpath from a set of system
defaults and the user's
.Ev PATH ,
echoing the result to the standard output.
Warnings and errors are written to the standard error.
If a directory in the user's path is not listed in the
.Pa %manpath_config_file%
file,
.Nm
looks for the subdirectories
.Pa man
or
.Pa MAN .
If they exist, they are added to the search path.
If they do not exist, but the directory ends in
.Pa /bin ,
.Nm
replaces
.Pa /bin
with
.Pa /man
and checks if that directory exists.
If it exists, it is added to the search path.
.Pp
The
.Nm
utility is used by
.Xr man 1
to determine the search path, so users normally do not need to set the
.Ev MANPATH
environment variable directly.
.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl d
Output additional debug information.
.It Fl L
Output man locales list (if it exists).
.It Fl q
Operate quietly.
Only echo the final result.
.El
.Sh ENVIRONMENT
.Bl -tag -width ".Ev MANLOCALES" -compact
.It Ev MANPATH
If
.Ev MANPATH
is set,
.Nm
echoes its value on the standard output and issues a warning on the
standard error.
.It Ev MANLOCALES
If
.Ev MANLOCALES
is set and
.Fl L
option is set,
.Nm
echoes its value on the standard output and issues a warning on the
standard error.
.El
.Sh FILES
.Bl -tag -width ".Pa %manpath_config_file%" -compact
.It Pa %manpath_config_file%
System configuration file.
.El
.Sh SEE ALSO
.Xr apropos 1 ,
.Xr man 1 ,
.Xr whatis 1