mirror of https://github.com/GnoConsortium/gno.git
- modifications for compilation under GNO v2.0.6 base build. See
the README for details of changes.
This commit is contained in:
parent
aa8b92ae3a
commit
db224b5b07
|
@ -0,0 +1,106 @@
|
|||
#
|
||||
# Devin Reade, 1998
|
||||
#
|
||||
# $Id: Makefile,v 1.1 1998/03/29 07:15:38 gdr-ftp Exp $
|
||||
#
|
||||
|
||||
CUSTOM_RULES = true # provide our own build rules
|
||||
CUSTOM_RELEASE = true # provide our own release and install targets
|
||||
|
||||
#
|
||||
# Define: -DDEBUG to produce more debugging info and checks
|
||||
#
|
||||
# -DSTACK_CHECK to show stack usage. If you use this
|
||||
# one, ensure you add -l/usr/lib/stack to your LDLIBS.
|
||||
#
|
||||
DEFINES +=
|
||||
STACK = 1280
|
||||
LDADD = -lcontrib
|
||||
BINDIR = /usr/bin
|
||||
SBINDIR = /usr/sbin
|
||||
DESC = manpack.desc
|
||||
|
||||
.INCLUDE: /src/gno/prog.mk
|
||||
|
||||
RELSBIN = $(RELEASE_DIR)$(SBINDIR)
|
||||
|
||||
PROGS = $(OBJ_DIR)apropos $(OBJ_DIR)catman $(OBJ_DIR)makewhatis \
|
||||
$(OBJ_DIR)man $(OBJ_DIR)whatis
|
||||
|
||||
APROPOS_OBJ = apropos.o apropos2.o util.o globals.o
|
||||
CATMAN_OBJ = catman.o util.o globals.o common.o
|
||||
MAKEWHATIS_OBJ = makewhatis.o fillbuffer.o process.o
|
||||
MAN_OBJ = man.o man2.o apropos2.o util.o globals.o common.o
|
||||
WHATIS_OBJ = whatis.o apropos2.o util.o globals.o
|
||||
|
||||
MAINCFLAGS = $(CFLAGS:s/ -r / /g)
|
||||
|
||||
build: $(OBJ_DIR) $(LOCAL_SETUP) $(PROGS)
|
||||
|
||||
$(OBJ_DIR)apropos: $(APROPOS_OBJ) apropos.r
|
||||
$(CC) $(LDFLAGS) $(OBJ_DIR){$(APROPOS_OBJ)} $(LDLIBS) -o $@
|
||||
$(CATREZ) -d $@ $*.r
|
||||
|
||||
$(OBJ_DIR)catman: $(CATMAN_OBJ) catman.r
|
||||
$(CC) $(LDFLAGS) $(OBJ_DIR){$(CATMAN_OBJ)} $(LDLIBS) -o $@
|
||||
$(CATREZ) -d $@ $*.r
|
||||
|
||||
$(OBJ_DIR)makewhatis: $(MAKEWHATIS_OBJ) makewhatis.r
|
||||
$(CC) $(LDFLAGS) $(OBJ_DIR){$(MAKEWHATIS_OBJ)} $(LDLIBS) -o $@
|
||||
$(CATREZ) -d $@ $*.r
|
||||
|
||||
$(OBJ_DIR)man: $(MAN_OBJ) man.r
|
||||
$(CC) $(LDFLAGS) $(OBJ_DIR){$(MAN_OBJ)} $(LDLIBS) -o $@
|
||||
$(CATREZ) -d $@ $*.r
|
||||
|
||||
$(OBJ_DIR)whatis: $(WHATIS_OBJ) whatis.r
|
||||
$(CC) $(LDFLAGS) $(OBJ_DIR){$(WHATIS_OBJ)} $(LDLIBS) -o $@
|
||||
$(CATREZ) -d $@ $*.r
|
||||
|
||||
apropos.o: apropos.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c apropos.c
|
||||
catman.o: catman.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c catman.c
|
||||
makewhatis.o: makewhatis.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c makewhatis.c
|
||||
man.o: man.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c man.c
|
||||
whatis.o: whatis.c; $(CC) -o $@ $(MAINCFLAGS) -a0 -c whatis.c
|
||||
|
||||
$(OBJ_DIR):; $(INSTALL) -d $(OBJ_DIR)
|
||||
|
||||
M1 = man.1 whatis.1
|
||||
M8 = catman.8 makewhatis.8
|
||||
DIRS = $(SBINDIR) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8
|
||||
RELDIRS = $(RELSBIN) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8 $(DESC_DIR)
|
||||
|
||||
release: $(PROGS) $(M1) $(M8) $(DESC)
|
||||
$(INSTALL) -d $(RELSBIN) $(RELBIN) $(RELMAN)/man1 $(RELMAN)/man8
|
||||
$(INSTALL) -d $(DESC_DIR)
|
||||
$(INSTALL) apropos man whatis $(RELBIN)
|
||||
$(INSTALL) catman makewhatis $(RELSBIN)
|
||||
$(INSTALL) $(M1) $(RELMAN)/man1
|
||||
$(INSTALL) $(M8) $(RELMAN)/man8
|
||||
$(DESCU) -o $(DESC_SRC) $(DESC_SRC) $(DESC)
|
||||
|
||||
install: $(PROGS) $(M1) $(M8)
|
||||
$(INSTALL) -d $(SBINDIR) $(BINDIR) $(MANDIR)/man1 $(MANDIR)/man8
|
||||
$(INSTALL) apropos man whatis $(BINDIR)
|
||||
$(INSTALL) catman makewhatis $(SBINDIR)
|
||||
$(INSTALL) $(M1) $(MANDIR)/man1
|
||||
$(INSTALL) $(M8) $(MANDIR)/man8
|
||||
|
||||
# additional dependancies
|
||||
apropos.o: man.h
|
||||
apropos2.o: man.h
|
||||
catman.o: man.h
|
||||
common.o: man.h
|
||||
fillbuffer.o: man.h
|
||||
globals.o: man.h
|
||||
makewhatis.o: man.h
|
||||
man.o: man.h
|
||||
man2.o: man.h
|
||||
process.o: man.h
|
||||
util.o: man.h
|
||||
whatis.o: man.h
|
||||
apropos.r: common.rez
|
||||
catman.r: common.rez
|
||||
makewhatis.r: common.rez
|
||||
man.r: common.rez
|
||||
whatis.r: common.rez
|
|
@ -1,7 +1,7 @@
|
|||
--------------------------------------------
|
||||
Name: manpack
|
||||
Version: 3.0
|
||||
Author: Devin Reade <gdr@myrias.com>
|
||||
Version: 3.1
|
||||
Author: Devin Reade <gdr@trenco.gno.org>
|
||||
Computer: Apple IIgs
|
||||
Requires: GNO v2.x
|
||||
--------------------------------------------
|
||||
|
@ -10,13 +10,14 @@ Requires: GNO v2.x
|
|||
Description:
|
||||
===========
|
||||
|
||||
Various programs for working with manual pages. This archive includes:
|
||||
Various programs for working with manual pages. This archive includes
|
||||
the following utilities. All utilities have their versions lockstepped:
|
||||
|
||||
apropos v3.0 locate commands by keyword
|
||||
catman v1.0 format cat pages from man pages
|
||||
makewhatis v1.2 create the whatis database
|
||||
man v3.0 display reference manual pages
|
||||
whatis v3.0 locate commands by name
|
||||
apropos locate commands by keyword
|
||||
catman format cat pages from man pages
|
||||
makewhatis create the whatis database
|
||||
man display reference manual pages
|
||||
whatis locate commands by name
|
||||
|
||||
============
|
||||
Installation:
|
||||
|
@ -26,23 +27,26 @@ Type at the command line `dmake install`. You may wish to first
|
|||
verify the destination directories in "Makefile.mk". By default
|
||||
these are:
|
||||
|
||||
BINDIR = /usr/bin (apropos, catman, man, and whatis)
|
||||
SBINDIR = /usr/sbin (makewhatis)
|
||||
BINDIR = /usr/bin (apropos, man, and whatis)
|
||||
SBINDIR = /usr/sbin (catman, and makewhatis)
|
||||
MANDIR = /usr/man (all manual pages)
|
||||
|
||||
Ensure that all older versions of these programs are deleted.
|
||||
They may or may not be in the above directories.
|
||||
|
||||
If you're building a GNO release in the base builds, then use the
|
||||
command `dmake release`.
|
||||
|
||||
==========
|
||||
Legalities:
|
||||
==========
|
||||
|
||||
These utilities are copyright 1995 by Devin Reade <gdr@myrias.com>.
|
||||
These utilities are copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>.
|
||||
|
||||
They are provided as freeware, and may be distributed by Internet
|
||||
archive sites, online services such as GEnie, or BBSes provided that
|
||||
archive sites, online services such as Delphi, or BBSes provided that
|
||||
the archive remains intact. Permission is granted for distribution
|
||||
with GNO/ME and Orca provided credit for this work is given along
|
||||
with GNO and ORCA provided credit for this work is given along
|
||||
with any other attributions.
|
||||
|
||||
Inclusion of these utilities in collections on disk, CD-ROM, or
|
||||
|
@ -52,20 +56,27 @@ author regarding other commercial distributions.
|
|||
|
||||
Updates to these utilities may be distributed provided that the source
|
||||
and this README file are included. Please follow the coding style
|
||||
already in use and document your changes in this file.
|
||||
already in use and document your changes in this file. Better yet,
|
||||
email me with your suggested changes and I'll consider incorporating
|
||||
them into the base distribution.
|
||||
|
||||
=======
|
||||
CHANGES:
|
||||
=======
|
||||
|
||||
apropos, whatis
|
||||
v3.1 (28 Mar 98)
|
||||
Incorporated all utilities into the GNO base build. All
|
||||
versions are now lockstepped.
|
||||
|
||||
Searches are no longer case sensitive.
|
||||
|
||||
v3.0 (24 Jul 95)
|
||||
Complete rewrite from scratch by Devin Reade.
|
||||
|
||||
This version makes use of MANPATH in the same way
|
||||
as man(1) v3.0. Similarily, it will also search
|
||||
the 17/syscmnd Orca database.
|
||||
the 17/syscmnd ORCA database.
|
||||
|
||||
In the previous version, the behavior of apropos was
|
||||
identical to that of whatis. This version has been
|
||||
|
@ -81,11 +92,21 @@ apropos, whatis
|
|||
because it shipped with man(1) v2.1.
|
||||
|
||||
catman
|
||||
v3.1 (28 Mar 98)
|
||||
Incorporated all utilities into the GNO base build. All
|
||||
versions are now lockstepped.
|
||||
|
||||
v1.0 (24 Jul 95)
|
||||
Initial release. Written from scratch by Devin Reade.
|
||||
|
||||
makewhatis
|
||||
v3.1 (28 Mar 98)
|
||||
Incorporated all utilities into the GNO base build. All
|
||||
versions are now lockstepped.
|
||||
|
||||
Don't use binary mode to read the files; this doesn't
|
||||
give the right results with the GNO v2.0.6 stdio package
|
||||
since we're doing calls to fgets() at times.
|
||||
|
||||
v1.2 (24 Jul 95)
|
||||
Fixed bug where pages in "manl" ending in ".l" (that's
|
||||
|
@ -149,6 +170,12 @@ makewhatis
|
|||
Initial release. Written from scratch by Devin Reade.
|
||||
|
||||
man
|
||||
v3.1 (28 Mar 98)
|
||||
Incorporated all utilities into the GNO base build. All
|
||||
versions are now lockstepped.
|
||||
|
||||
Searches are no longer case sensitive.
|
||||
|
||||
v3.0 (24 Jul 95)
|
||||
Complete rewrite from scratch by Devin Reade.
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
.so man1/whatis.1
|
|
@ -1,41 +1,36 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: apropos.c,v 1.2 1998/03/29 07:15:42 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "apropos___";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc.h>
|
||||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static char *versionstr = "3.0";
|
||||
static char *versionstr = VERSION_STR;
|
||||
static char *nothing = "nothing appropriate";
|
||||
|
||||
extern void begin_stack_check(void);
|
||||
extern int end_stack_check(void);
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
char *path;
|
||||
int i, matches1, matches2, matches3;
|
||||
short V_flag, M_flag, m_flag, n_flag, err_flag;
|
||||
|
||||
/* make sure Gno is running */
|
||||
/* make sure GNO is running */
|
||||
if (needsgno()==0) {
|
||||
fprintf(stderr,"Requires Gno/ME\n");
|
||||
return 1;
|
||||
errx(1, "Requires GNO\n");
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
begin_stack_check();
|
||||
#endif
|
||||
__REPORT_STACK();
|
||||
|
||||
/* initialization */
|
||||
V_flag = M_flag = m_flag = n_flag = err_flag = 0;
|
||||
|
@ -101,10 +96,6 @@ int main (int argc, char **argv) {
|
|||
fprintf(stderr,"%s: %s\n",basename(argv[0]),nothing);
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
|
||||
#endif
|
||||
|
||||
if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* $Id: apropos.rez,v 1.1 1998/03/29 07:15:43 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
|
||||
#define PROG "apropos"
|
||||
#define DESC "Locate commands by keyword"
|
||||
|
||||
#include "common.rez"
|
|
@ -1,10 +1,15 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: apropos2.c,v 1.2 1998/03/29 07:15:45 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "apropos2__";
|
||||
#pragma noroot
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
@ -13,7 +18,7 @@ segment "apropos2__";
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "util.h"
|
||||
#include <err.h>
|
||||
#include "man.h"
|
||||
|
||||
/*
|
||||
|
@ -21,7 +26,8 @@ segment "apropos2__";
|
|||
* length of the command
|
||||
*/
|
||||
|
||||
static char *orcapadding (char *command) {
|
||||
static char *
|
||||
orcapadding (char *command) {
|
||||
int i;
|
||||
static char *two ="\t\t";
|
||||
static char *one ="\t";
|
||||
|
@ -40,9 +46,10 @@ static char *orcapadding (char *command) {
|
|||
* orcacommand() modifies the buffer.
|
||||
*/
|
||||
|
||||
static char *orcacomment (char *buffer) {
|
||||
static char *
|
||||
orcacomment (char *buffer) {
|
||||
char *p;
|
||||
static char *bad_line="malformed SYSCMND line\n";
|
||||
static char *bad_line = "malformed SYSCMND line\n";
|
||||
|
||||
p = buffer;
|
||||
|
||||
|
@ -91,7 +98,8 @@ static char *orcacomment (char *buffer) {
|
|||
* modifies the buffer.
|
||||
*/
|
||||
|
||||
static char *orcacommand(char *buffer) {
|
||||
static char *
|
||||
orcacommand(char *buffer) {
|
||||
char *p;
|
||||
|
||||
p = buffer;
|
||||
|
@ -136,12 +144,14 @@ static char *orcacommand(char *buffer) {
|
|||
* WARNING: Use of the MAN_F_MODE may alter the contents of argv[].
|
||||
*/
|
||||
|
||||
int apropos(int argc, char **argv, int apropos_mode) {
|
||||
int
|
||||
apropos(int argc, char **argv, int apropos_mode) {
|
||||
char **manpath_array;
|
||||
char *current_path, *p, *q, *r, *keyword;
|
||||
FILE *fp;
|
||||
char dirbrk;
|
||||
int i, j, matches;
|
||||
LC_StringArray_t sarray;
|
||||
|
||||
#ifdef DEBUG
|
||||
assert ((apropos_mode == WHATIS_MODE) ||
|
||||
|
@ -193,8 +203,10 @@ int apropos(int argc, char **argv, int apropos_mode) {
|
|||
/* loop over keywords */
|
||||
for(i=0; i<argc; i++) {
|
||||
keyword = argv[i];
|
||||
if ((apropos_mode == ORCA_K_MODE && ncstrstr(linebuf,keyword)) ||
|
||||
(apropos_mode == ORCA_F_MODE && strstr(linebuf,keyword)) ||
|
||||
|
||||
if (((apropos_mode == ORCA_K_MODE ||
|
||||
apropos_mode == ORCA_F_MODE) &&
|
||||
strcasestr(linebuf,keyword)) ||
|
||||
(apropos_mode == ORCA_W_MODE &&
|
||||
!strncmp(linebuf,keyword,strlen(keyword)))) {
|
||||
r = orcacomment(linebuf);
|
||||
|
@ -208,8 +220,9 @@ int apropos(int argc, char **argv, int apropos_mode) {
|
|||
fclose(fp);
|
||||
return matches;
|
||||
}
|
||||
|
||||
if ((manpath_array = makePathArray(manpath)) == NULL) return -1;
|
||||
|
||||
sarray = MakePathArray(manpath); /* can't fail */
|
||||
manpath_array = sarray->lc_vec;
|
||||
|
||||
/*
|
||||
* loop over all the paths in MANPATH
|
||||
|
@ -240,31 +253,24 @@ int apropos(int argc, char **argv, int apropos_mode) {
|
|||
keyword = argv[j];
|
||||
switch (apropos_mode) {
|
||||
case MAN_F_MODE:
|
||||
if (strstr(linebuf,keyword)) {
|
||||
printf("%s",linebuf);
|
||||
matches++;
|
||||
}
|
||||
break;
|
||||
case MAN_K_MODE:
|
||||
if (ncstrstr(linebuf,keyword)) {
|
||||
if (strcasestr(linebuf,keyword)) {
|
||||
printf("%s",linebuf);
|
||||
matches++;
|
||||
}
|
||||
break;
|
||||
case WHATIS_MODE:
|
||||
/* avoid unnecessary strcpy's */
|
||||
if (strstr(linebuf,keyword)==NULL) break;
|
||||
if (strcasestr(linebuf,keyword)==NULL) break;
|
||||
strcpy(linebuf2,linebuf);
|
||||
if ((p = strchr(linebuf2,'(')) != NULL) *p = '\0';
|
||||
if (strstr(linebuf2,keyword)) {
|
||||
if (strcasestr(linebuf2,keyword)) {
|
||||
printf("%s",linebuf);
|
||||
matches++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"internal error line %d of %s\n",
|
||||
__LINE__,__FILE__);
|
||||
exit(1);
|
||||
errx(1, "internal error at %s:%d", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
} else if (ferror(fp)) {
|
||||
|
@ -280,5 +286,6 @@ int apropos(int argc, char **argv, int apropos_mode) {
|
|||
current_path = manpath_array[i];
|
||||
} /* endwhile loop over directories */
|
||||
|
||||
LC_StringArrayDestroy(sarray);
|
||||
return matches;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
.\" Copyright (c) 1995 Devin Reade <gdr@myrias.com>. All rights reserved.
|
||||
.\" Copyright (c) 1995-1997 Devin Reade <gdr@trenco.gno.org>.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.TH CATMAN 8 "System Administration" "24 July 95" "Version 1.0"
|
||||
.\" $Id: catman.8,v 1.2 1998/03/29 07:15:47 gdr-ftp Exp $
|
||||
.\"
|
||||
.TH CATMAN 8 "28 March 1998" GNO "System Administration"
|
||||
.SH NAME
|
||||
catman \- format cat pages from man pages
|
||||
.SH SYNOPSIS
|
||||
|
@ -74,16 +77,6 @@ on to the list of paths for which manual pages will be updated.
|
|||
Display version information and exit.
|
||||
.IP \fB-v\fR
|
||||
Verbose. Show processing information.
|
||||
.SH BUGS
|
||||
Please report any bugs to Devin Reade, <gdr@myrias.ab.ca>.
|
||||
.SH SEE ALSO
|
||||
.BR apropos (1),
|
||||
.BR man (1),
|
||||
.BR whatis (1),
|
||||
.BR gzip (1),
|
||||
.BR compress (1),
|
||||
.BR freeze (1),
|
||||
.BR makewhatis (8).
|
||||
.SH WARNING
|
||||
.BR catman
|
||||
will unlink any out-of-date files in the
|
||||
|
@ -93,3 +86,15 @@ subdirectories. The files that would be unlinked are listed when
|
|||
is invoked with the
|
||||
.BR -p
|
||||
option.
|
||||
.SH VERSION
|
||||
This manual page documents
|
||||
.BR catman
|
||||
version 3.1.
|
||||
.SH SEE ALSO
|
||||
.BR apropos (1),
|
||||
.BR man (1),
|
||||
.BR whatis (1),
|
||||
.BR gzip (1),
|
||||
.BR compress (1),
|
||||
.BR freeze (1),
|
||||
.BR makewhatis (8).
|
||||
|
|
|
@ -1,37 +1,34 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: catman.c,v 1.2 1998/03/29 07:15:48 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "catman____";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <libc.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "util.h"
|
||||
#include <err.h>
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
#define OVERFLOW_ABORT(line,file) { \
|
||||
fprintf(stderr,overflowMsg,line,file); \
|
||||
exit(1); \
|
||||
}
|
||||
#define OVERFLOW_ABORT(line,file) errx(1, overflowMsg, line, file)
|
||||
|
||||
short v_flag, V_flag, M_flag, m_flag, p_flag, err_flag;
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static char *versionstr = "1.0";
|
||||
static const char *versionstr = VERSION_STR;
|
||||
|
||||
/* This is of the form "man<section>" */
|
||||
char mandir[FILENAME_MAX];
|
||||
|
@ -48,9 +45,6 @@ char base[FILENAME_MAX];
|
|||
|
||||
static char *overflowMsg = "internal buffer overflow at line %d of %s\n";
|
||||
|
||||
extern void begin_stack_check(void);
|
||||
extern int end_stack_check(void);
|
||||
|
||||
/*
|
||||
* catman
|
||||
*
|
||||
|
@ -83,9 +77,11 @@ int catman(int argc, char **argv) {
|
|||
fileType *ftype; /* the file type of the man page */
|
||||
struct stat statbuf1, statbuf2;
|
||||
char dirbrk;
|
||||
LC_StringArray_t sarray;
|
||||
|
||||
/* create array of paths to search */
|
||||
if ((manpath_array = makePathArray(manpath)) == NULL) return 1;
|
||||
sarray = MakePathArray(manpath);
|
||||
manpath_array = sarray->lc_vec;
|
||||
|
||||
/* loop over paths in MANPATH */
|
||||
pathIndex=0;
|
||||
|
@ -271,20 +267,16 @@ int catman(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
char *path;
|
||||
int i, result1, result2;
|
||||
|
||||
/* make sure Gno is running */
|
||||
/* make sure GNO is running */
|
||||
if (needsgno()==0) {
|
||||
fprintf(stderr,"Requires Gno/ME\n");
|
||||
return 1;
|
||||
errx(1, "Requires GNO\n");
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
begin_stack_check();
|
||||
#endif
|
||||
__REPORT_STACK();
|
||||
|
||||
/* initialization */
|
||||
v_flag = V_flag = M_flag = m_flag = p_flag = err_flag = 0;
|
||||
|
@ -348,9 +340,5 @@ int main (int argc, char **argv) {
|
|||
result2 = catman(argc-optind, &argv[optind]);
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
|
||||
#endif
|
||||
|
||||
return (result1 || result2);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* $Id: catman.rez,v 1.1 1998/03/29 07:15:50 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
|
||||
#define PROG "catman"
|
||||
#define DESC "Preformat manual pages"
|
||||
|
||||
#include "common.rez"
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* This file is intended to be #included by the other *.rez files.
|
||||
*
|
||||
* $Id: common.rez,v 1.1 1998/03/29 07:15:53 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "/src/gno/build.tools/builddate.rez"
|
||||
|
||||
resource rVersion (0x1, purgeable3, nocrossbank) {
|
||||
|
||||
{ 3, 1, 0, /* version */
|
||||
release, /* development|alpha|beta|final|release */
|
||||
0 /* non-final release number */
|
||||
},
|
||||
verUS,
|
||||
PROG,
|
||||
DESC "\nWritten by Devin Reade for GNO\n"
|
||||
BUILD_DATE
|
||||
};
|
|
@ -1,50 +0,0 @@
|
|||
Name: apropos
|
||||
Version: 3.0 (24 Jul 95)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@myrias.com
|
||||
Where: /usr/bin
|
||||
FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu
|
||||
|
||||
Locate commands by keyword. Bundled with catman, makewhatis,
|
||||
man, and whatis in the manpack30.shk archive.
|
||||
|
||||
Name: catman
|
||||
Version: 1.0 (24 Jul 95)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@myrias.com
|
||||
Where: /usr/sbin
|
||||
FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu
|
||||
|
||||
Preformat manual reference pages. Bundled with apropos, makewhatis,
|
||||
man, and whatis in the manpack30.shk archive.
|
||||
|
||||
Name: makewhatis
|
||||
Version: 1.2 (24 Jul 95)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@myrias.com
|
||||
Where: /usr/sbin
|
||||
FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu
|
||||
|
||||
Create the whatis database used by man(1), apropos(1), and whatis(1).
|
||||
Bundled with apropos, catman, man, and whatis in the manpack30.shk archive.
|
||||
|
||||
Name: man
|
||||
Version: 3.0 (24 Jul 95)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@myrias.com
|
||||
Where: /usr/bin
|
||||
FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu
|
||||
|
||||
Display manual reference pages. Bundled with apropos, catman,
|
||||
makewhatis, and whatis in the manpack30.shk archive.
|
||||
|
||||
Name: whatis
|
||||
Version: 3.0 (24 Jul 95)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@myrias.com
|
||||
Where: /usr/bin
|
||||
FTP: ftp.cco.caltech.edu, grind.isca.uiowa.edu
|
||||
|
||||
Locate commands by name. Bundled with apropos, catman,
|
||||
makewhatis, and man in the manpack30.shk archive.
|
||||
|
|
@ -1,15 +1,21 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: fillbuffer.c,v 1.4 1998/03/29 07:15:55 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "makewhatis";
|
||||
#pragma noroot
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "makewhatis.h"
|
||||
#include <err.h>
|
||||
#include "man.h"
|
||||
|
||||
#define NAME1 "NAME"
|
||||
#define NAME2 "N\bNA\bAM\bME\bE"
|
||||
|
@ -86,7 +92,7 @@ void fillbuffer (char *filename) {
|
|||
* open the file
|
||||
*/
|
||||
|
||||
if ((fp = fopen(filename,"rb")) == NULL) {
|
||||
if ((fp = fopen(filename,"r")) == NULL) {
|
||||
buffer[0] = '\0';
|
||||
if (v_flag) fprintf (error_fp,"Open failed for file \"%s\"\n",filename);
|
||||
return;
|
||||
|
@ -141,7 +147,7 @@ void fillbuffer (char *filename) {
|
|||
|
||||
|
||||
/* we need the previous newline for the next algorithm to work */
|
||||
fseek(fp,-1L,SEEK_CUR);
|
||||
ungetc('\n', fp);
|
||||
|
||||
/*
|
||||
* Make p1 point to spot in buffer2 where there occurs the first
|
||||
|
@ -188,7 +194,7 @@ void fillbuffer (char *filename) {
|
|||
*/
|
||||
|
||||
if (in_comment) {
|
||||
while((p1<p2) && (*p1 != '\r')) p1++;
|
||||
while((p1<p2) && (*p1 != '\n')) p1++;
|
||||
in_comment = 0;
|
||||
}
|
||||
|
||||
|
@ -215,14 +221,14 @@ void fillbuffer (char *filename) {
|
|||
for (; p1<p2; p1++) {
|
||||
|
||||
/* skip .\" comments */
|
||||
if (strncmp(p1,"\r.\\\"",4) == 0) {
|
||||
while ((p1<p2) && (*p1!='\r')) p1++;
|
||||
if (strncmp(p1,"\n.\\\"",4) == 0) {
|
||||
while ((p1<p2) && (*p1!='\n')) p1++;
|
||||
if (p1==p2) in_comment = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* skip .BR-type formatting */
|
||||
if ((p1<p2) && (*p1=='\r') && (*(p1+1)=='.')) {
|
||||
if ((p1<p2) && (*p1=='\n') && (*(p1+1)=='.')) {
|
||||
p1++;
|
||||
while ((p1<p2) && !isspace(*p1)) p1++;
|
||||
if (p1==p2) in_format_BR = 1;
|
||||
|
@ -250,7 +256,7 @@ void fillbuffer (char *filename) {
|
|||
if (isgraph(*p1) && (*p1!=' ')) foo=1;
|
||||
if (!foo) {
|
||||
while ((p1<p2) && !(isgraph(*p1) && (*p1!=' '))) p1++;
|
||||
if ((*p1=='.') && (*(p1-1)=='\r')) p1 -=2;
|
||||
if ((*p1=='.') && (*(p1-1)=='\n')) p1 -=2;
|
||||
else --p1;
|
||||
continue;
|
||||
}
|
||||
|
@ -258,7 +264,7 @@ void fillbuffer (char *filename) {
|
|||
if (isgraph(*p1)) foo=1;
|
||||
if (!foo) {
|
||||
while ((p1<p2) && !isgraph(*p1)) p1++;
|
||||
if ((*p1=='.') && (*(p1-1)=='\r')) p1 -=2;
|
||||
if ((*p1=='.') && (*(p1-1)=='\n')) p1 -=2;
|
||||
else --p1;
|
||||
continue;
|
||||
}
|
||||
|
@ -357,7 +363,7 @@ void fillbuffer (char *filename) {
|
|||
*/
|
||||
|
||||
if (in_comment) {
|
||||
while((p1<p2) && (*p1 != '\r')) p1++;
|
||||
while((p1<p2) && (*p1 != '\n')) p1++;
|
||||
in_comment = 0;
|
||||
}
|
||||
|
||||
|
@ -384,13 +390,13 @@ void fillbuffer (char *filename) {
|
|||
for (; p1<p2; p1++) {
|
||||
|
||||
/* skip .\" comments */
|
||||
if (strncmp(p1,"\r.\\\"",4) == 0) {
|
||||
while ((p1<p2) && (*p1!='\r')) p1++;
|
||||
if (strncmp(p1,"\n.\\\"",4) == 0) {
|
||||
while ((p1<p2) && (*p1!='\n')) p1++;
|
||||
if (p1==p2) in_comment = 1;
|
||||
}
|
||||
|
||||
/* skip .BR-type formatting */
|
||||
if ((p1<p2) && (*p1=='\r') && (*(p1+1)=='.')) {
|
||||
if ((p1<p2) && (*p1=='\n') && (*(p1+1)=='.')) {
|
||||
p1++;
|
||||
while ((p1<p2) && !isspace(*p1)) p1++;
|
||||
if (p1==p2) in_format_BR = 1;
|
||||
|
@ -450,10 +456,18 @@ void fillbuffer (char *filename) {
|
|||
if (count == 0) {
|
||||
/* eof or error; terminate buffer and return */
|
||||
*p3 = '\0';
|
||||
if (v_flag) {
|
||||
#define NO_DESCRIPTION "description not found"
|
||||
if (feof(fp)) {
|
||||
warnx("EOF on %s, %s", filename, NO_DESCRIPTION);
|
||||
} else if (ferror(fp)) {
|
||||
warn("error on %s, %s", filename, NO_DESCRIPTION);
|
||||
} else {
|
||||
errx(1, "fread above line %d returned zero", __LINE__);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
if (v_flag) fprintf (error_fp,
|
||||
"EOF or error on %s, description not found.\n",filename);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
buffer2[count] = '\0';
|
||||
p1 = buffer2;
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: globals.c,v 1.2 1998/03/29 07:15:58 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include <types.h>
|
||||
#include "man.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0x0L
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The compression suffixes and how to uncompress the files.
|
||||
* If you use ".l" (that's "ell") as a suffix, you will break the
|
||||
|
|
|
@ -1,70 +0,0 @@
|
|||
#
|
||||
# Makefile for the man package, for use with dmake(1).
|
||||
#
|
||||
|
||||
# Location for executables. They should normally be /usr/sbin and /usr/bin.
|
||||
|
||||
SBINDIR = /usr/sbin
|
||||
BINDIR = /usr/bin
|
||||
|
||||
# Location for man pages. Usually /usr/man.
|
||||
|
||||
MANDIR = /usr/man
|
||||
|
||||
#
|
||||
# You should not have to change anything below this line
|
||||
#
|
||||
# Define: -DDEBUG to produce more debugging info and checks
|
||||
#
|
||||
# -DSTACK_CHECK to show stack usage. If you use this
|
||||
# one, ensure you add -l/usr/lib/stack to your LDLIBS.
|
||||
#
|
||||
|
||||
STACK = -s1270
|
||||
DEFINES =
|
||||
CFLAGS = $(DEFINES) $(STACK) -w -v -O -I/usr/include
|
||||
LDFLAGS = -v
|
||||
LDLIBS = -l/usr/lib/gnulib -l/usr/lib/stack
|
||||
CP = /bin/cp -f
|
||||
|
||||
build: apropos catman makewhatis man whatis
|
||||
|
||||
apropos: apropos.o apropos2.o util.o utilgs.o globals.o
|
||||
$(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
|
||||
|
||||
catman: catman.o util.o utilgs.o globals.o common.o
|
||||
$(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
|
||||
|
||||
makewhatis: makewhatis.o fillbuffer.o process.o
|
||||
$(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
|
||||
|
||||
man: man.o man2.o apropos2.o util.o utilgs.o globals.o common.o
|
||||
$(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
|
||||
|
||||
whatis: whatis.o apropos2.o util.o utilgs.o globals.o
|
||||
$(CC) $(LDFLAGS) $< $(LDLIBS) -o $@
|
||||
|
||||
clobber:
|
||||
$(RM) *.o *.root
|
||||
|
||||
install:
|
||||
$(CP) apropos man whatis $(BINDIR)
|
||||
$(CP) catman makewhatis $(SBINDIR)
|
||||
$(CP) apropos.1 man.1 whatis.1 $(MANDIR)/man1
|
||||
$(CP) catman.8 makewhatis.8 $(MANDIR)/man8
|
||||
|
||||
# additional dependancies
|
||||
|
||||
apropos.o:: man.h util.h
|
||||
apropos2.o:: man.h util.h
|
||||
catman.o:: man.h util.h
|
||||
common.o:: man.h util.h
|
||||
fillbuffer.o:: makewhatis.h
|
||||
globals.o:: man.h
|
||||
makewhatis.o:: makewhatis.h
|
||||
man.o:: man.h util.h
|
||||
man2.o:: man.h util.h
|
||||
process.o:: makewhatis.h
|
||||
util.o:: util.h
|
||||
utilgs.o:: util.h
|
||||
whatis.o:: man.h util.h
|
|
@ -1,4 +1,4 @@
|
|||
.TH MAKEWHATIS 8 "System Administration" "24 July 1995" "Version 1.2"
|
||||
.TH MAKEWHATIS 8 "28 March 1998" GNO "System Administration"
|
||||
.SH NAME
|
||||
.B makewhatis
|
||||
\- generate the whatis database file
|
||||
|
@ -22,6 +22,10 @@
|
|||
.B -V
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
This manual page documents
|
||||
.B makewhatis
|
||||
version 3.1.
|
||||
.LP
|
||||
.B makewhatis
|
||||
generates the whatis database for
|
||||
.BR apropos (1),
|
||||
|
@ -286,7 +290,7 @@ of the input buffer, you may see formatting infomation such as
|
|||
in the output. This was not fixed due to the overhead of having to
|
||||
check for such a condition.
|
||||
.LP
|
||||
Please report any additional bugs to Devin Reade, <gdr@myrias.com>.
|
||||
Please report any additional bugs to Devin Reade, <gdr@trenco.gno.org>.
|
||||
.SH FILES
|
||||
.nf
|
||||
/usr/[share/]man/whatis -- the whatis database
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: makewhatis.c,v 1.4 1998/03/29 07:16:01 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "makewhatis";
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
@ -13,15 +17,8 @@ segment "makewhatis";
|
|||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include "getopt.h"
|
||||
#include <libc.h>
|
||||
|
||||
#include "makewhatis.h"
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
extern void begin_stack_check(void);
|
||||
extern int end_stack_check(void);
|
||||
#endif
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
/*
|
||||
* Options:
|
||||
|
@ -55,7 +52,7 @@ char *man_subdir[] = {
|
|||
};
|
||||
|
||||
/*
|
||||
* we include cat* since some Gno utility man pages aren't written in
|
||||
* we include cat* since some GNO utility man pages aren't written in
|
||||
* either nroff or aroff source ... go figure.
|
||||
*/
|
||||
|
||||
|
@ -90,14 +87,12 @@ static char progdir[FILENAME_MAX]; /* the directory where makewhatis started */
|
|||
FILE *output_fp;
|
||||
FILE *error_fp;
|
||||
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
|
||||
static char tmp_file[L_tmpnam]; /* a scratch file */
|
||||
char *manpath; /* the location of the man pages */
|
||||
char *path; /* the current path; taken from manpath */
|
||||
char *p=NULL; /* a temporary pointer */
|
||||
struct dirent *file; /* the current file we have open */
|
||||
char tmp_file[L_tmpnam]; /* a scratch file */
|
||||
FILE *tmp_fp; /* pointer to tmp_file */
|
||||
FILE *whatis_fp; /* pointer to the current whatis database */
|
||||
DIR *subdir; /* the current man subdirectory -- eg: /usr/man/man3 */
|
||||
|
@ -107,15 +102,13 @@ int main (int argc, char **argv) {
|
|||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
/* make sure Gno is running */
|
||||
/* make sure GNO is running */
|
||||
if (needsgno()==0) {
|
||||
fprintf(stderr,"Requires Gno/ME\n");
|
||||
fprintf(stderr,"Requires GNO\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
begin_stack_check();
|
||||
#endif
|
||||
__REPORT_STACK();
|
||||
|
||||
/*
|
||||
* set the defaults
|
||||
|
@ -173,7 +166,7 @@ int main (int argc, char **argv) {
|
|||
case 'V':
|
||||
fprintf(stderr,
|
||||
"%s --\n\tCreate the %s database.\n\tVersion %s by Devin Reade\n\n",
|
||||
argv[0],WHATIS,VERSIONSTRING);
|
||||
argv[0],WHATIS,VERSION_STR);
|
||||
errflag++;
|
||||
break;
|
||||
default:
|
||||
|
@ -326,9 +319,5 @@ Aborted.\n",
|
|||
if (output_fp != stdout) fclose(output_fp);
|
||||
if (error_fp != stderr) fclose(error_fp);
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
fprintf(stderr,"Makewhatis stack usage: %d bytes\n",end_stack_check());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*/
|
||||
|
||||
#define VERSIONSTRING "1.2"
|
||||
#define ISGRAPH_FIX 1
|
||||
|
||||
/* The size of the IO buffers */
|
||||
#define BUFFERSIZE 1024
|
||||
|
||||
/* The default name for the whatis database */
|
||||
#define WHATIS "whatis"
|
||||
|
||||
/* The number of characters per tab in the whatis database */
|
||||
#define TABLENGTH 8
|
||||
|
||||
#define DEFAULT_MANPATH "/usr/man"
|
||||
|
||||
extern int chdir (const char *);
|
||||
extern int system (const char *);
|
||||
|
||||
void fillbuffer (char *filename);
|
||||
void process (char *filename, char *tmp_file, FILE *whatis_fp, char *sec);
|
||||
|
||||
extern short v_flag;
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* $Id: makewhatis.rez,v 1.1 1998/03/29 07:16:04 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
|
||||
#define PROG "makewhatis"
|
||||
#define DESC "Create the whatis(1) database."
|
||||
|
||||
#include "common.rez"
|
|
@ -3,10 +3,10 @@
|
|||
.\" specifies the terms and conditions for redistribution.
|
||||
.\"
|
||||
.\" While this manual page is based on one from UCB, the included
|
||||
.\" C source, makefile, and executables are copyright (c) 1995
|
||||
.\" by Devin Reade <gdr@myrias.com>. All rights reserved.
|
||||
.\" C source, makefile, and executables are copyright (c) 1995-1998
|
||||
.\" by Devin Reade <gdr@trenco.gno.org>. All rights reserved.
|
||||
.\"
|
||||
.TH MAN 1 "Commands and Applications" "24 July 95" "Version 3.0"
|
||||
.TH MAN 1 "28 March 1998" GNO "Commands and Applications"
|
||||
.SH NAME
|
||||
man \- display reference manual pages; find reference pages by keyword
|
||||
.SH SYNOPSIS
|
||||
|
@ -33,6 +33,10 @@ man \- display reference manual pages; find reference pages by keyword
|
|||
.I filename
|
||||
\&.\|.\|.
|
||||
.SH DESCRIPTION
|
||||
This manual page documents
|
||||
.BR man
|
||||
version 3.0.
|
||||
.LP
|
||||
.B man
|
||||
displays information from the reference manuals.
|
||||
It can display complete manual pages that you select by
|
||||
|
@ -511,7 +515,7 @@ and
|
|||
preprocessors is not yet implemented. Since these preprocessors do
|
||||
not as yet exist for GNO, this is not too much of a problem.
|
||||
.LP
|
||||
Please report any other bugs to Devin Reade, <gdr@myrias.com>.
|
||||
Please report any other bugs to Devin Reade, <gdr@trenco.gno.org>.
|
||||
.SH HISTORY
|
||||
The GNO version of
|
||||
.BR man
|
||||
|
|
|
@ -1,30 +1,28 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: man.c,v 1.2 1998/03/29 07:16:07 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "man_______";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include <sgtty.h>
|
||||
#include <unistd.h>
|
||||
#include "util.h"
|
||||
#include <err.h>
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void begin_stack_check(void);
|
||||
extern int end_stack_check(void);
|
||||
#endif
|
||||
|
||||
char *macroPackage = "an"; /* default /usr/lib/tmac/tmac.an */
|
||||
char *versionStr = "Version 3.0 by Devin Reade";
|
||||
char *versionStr = VERSION_STR;
|
||||
char *pager;
|
||||
char *troff;
|
||||
char *tcat;
|
||||
|
@ -53,15 +51,12 @@ int main (int argc, char **argv) {
|
|||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
/* make sure Gno is running */
|
||||
/* make sure GNO is running */
|
||||
if (needsgno()==0) {
|
||||
fprintf(stderr,"Requires Gno/ME\n");
|
||||
return 1;
|
||||
err(1, "Requires GNO");
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
begin_stack_check();
|
||||
#endif
|
||||
__REPORT_STACK();
|
||||
|
||||
/*
|
||||
* initialization
|
||||
|
@ -86,7 +81,7 @@ int main (int argc, char **argv) {
|
|||
break;
|
||||
case 'M':
|
||||
M_flag++;
|
||||
manpath = Xstrdup(optarg,__LINE__,__FILE__);
|
||||
manpath = LC_xstrdup(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
n_flag++;
|
||||
|
@ -145,10 +140,5 @@ int main (int argc, char **argv) {
|
|||
}
|
||||
free(manpath);
|
||||
result = ((result == 0) && (i == 0)) ? 0 : 1;
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,27 +1,49 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: man.h,v 1.2 1998/03/29 07:16:09 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifndef _STDIO_H_
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef _GNO_CONTRIB_H_
|
||||
#include <gno/contrib.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Configuration info
|
||||
*/
|
||||
|
||||
#define WHATIS "whatis"
|
||||
#define PAGER "/bin/more"
|
||||
#define SYSCMND "15/syscmnd"
|
||||
#define VERSION_STR "3.1"
|
||||
|
||||
#define AROFF "aroff"
|
||||
#define NROFF "nroff"
|
||||
#define TROFF "troff -t"
|
||||
#define TCAT "lpr -t"
|
||||
#define CAT "cat"
|
||||
#define EQN "eqn"
|
||||
#define REFER "refer"
|
||||
#define TBL "tbl"
|
||||
#define VGRIND "vgrind"
|
||||
/* Defaults */
|
||||
#define WHATIS "whatis" /* basename of the whatis database */
|
||||
#define SYSCMND "15/syscmnd" /* full path of the ORCA syscmnd file */
|
||||
#define DEFAULT_MANPATH "/usr/man" /* default $MANPATH */
|
||||
|
||||
/* The names of various programs */
|
||||
#define PAGER "/bin/more"
|
||||
#define AROFF "aroff"
|
||||
#define NROFF "nroff"
|
||||
#define TROFF "troff -t"
|
||||
#define TCAT "lpr -t"
|
||||
#define CAT "cat"
|
||||
#define EQN "eqn"
|
||||
#define REFER "refer"
|
||||
#define TBL "tbl"
|
||||
#define VGRIND "vgrind"
|
||||
|
||||
/* The number of characters per tab in the whatis database */
|
||||
#define TABLENGTH 8
|
||||
|
||||
/* The size of the IO buffers */
|
||||
#define BUFFERSIZE 2048
|
||||
|
||||
/* File types */
|
||||
#define NON 0x00
|
||||
#define TXT 0x04
|
||||
#define BIN 0x06
|
||||
|
@ -34,18 +56,24 @@
|
|||
#define ORCA_K_MODE 5
|
||||
#define ORCA_W_MODE 6
|
||||
|
||||
#define BUFFERSIZE 2048
|
||||
|
||||
typedef struct Section_tag {
|
||||
char *name; /* section name */
|
||||
char *suffix; /* directory suffix */
|
||||
typedef struct Section {
|
||||
char *name; /* section name */
|
||||
char *suffix; /* directory suffix */
|
||||
} Section;
|
||||
|
||||
typedef struct {
|
||||
char *suffix;
|
||||
char *extractor;
|
||||
typedef struct compressionType {
|
||||
char *suffix;
|
||||
char *extractor;
|
||||
} compressionType;
|
||||
|
||||
typedef struct fileType {
|
||||
unsigned int type;
|
||||
unsigned long int auxtype;
|
||||
} fileType, *fileTypePtr;
|
||||
|
||||
fileType * getFileType (const char *file);
|
||||
|
||||
/*
|
||||
* from globals.c
|
||||
*/
|
||||
|
@ -69,27 +97,19 @@ extern char *macroPackage;
|
|||
extern short hyphen_flag;
|
||||
extern short n_flag;
|
||||
extern short t_flag;
|
||||
extern short v_flag;
|
||||
|
||||
/*
|
||||
* from apropos2.c
|
||||
*/
|
||||
LC_StringArray_t MakePathArray (char *path);
|
||||
int apropos(int argc, char **argv, int whole_line);
|
||||
void fillbuffer (char *filename);
|
||||
char * getManpath (void);
|
||||
int getSuffixIndex(char *name);
|
||||
char getcharraw (void);
|
||||
int man (int argc, char *argv[]);
|
||||
char * newerFile (char *path1, char *path2);
|
||||
void process (char *filename, char *tmp_file, FILE *whatis_fp,
|
||||
char *sec);
|
||||
char * strcasestr (char *str, char *substr);
|
||||
int whatis(int argc, char **argv);
|
||||
|
||||
int apropos(int argc, char **argv, int whole_line);
|
||||
|
||||
/*
|
||||
* from whatis2.c
|
||||
*/
|
||||
|
||||
int whatis(int argc, char **argv);
|
||||
|
||||
/*
|
||||
* from man2.c
|
||||
*/
|
||||
int man (int argc, char *argv[]);
|
||||
|
||||
|
||||
/*
|
||||
* from common.c
|
||||
*/
|
||||
|
||||
int getSuffixIndex(char *name);
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* $Id: man.rez,v 1.1 1998/03/29 07:16:10 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
|
||||
#define PROG "man"
|
||||
#define DESC "Display manual reference pages"
|
||||
|
||||
#include "common.rez"
|
|
@ -1,10 +1,15 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: man2.c,v 1.2 1998/03/29 07:16:12 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "man2______";
|
||||
#pragma noroot
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -17,15 +22,16 @@ segment "man2______";
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sgtty.h>
|
||||
#include "util.h"
|
||||
#include <err.h>
|
||||
#include <gno/contrib.h>
|
||||
#include "man.h"
|
||||
|
||||
#define MAX(a,b) ((a) > (b)) ? (a) : (b)
|
||||
|
||||
static char **buildManList(char *suffix, char *name);
|
||||
static void display(char *list);
|
||||
static char *getBaseName (char *out, char *in);
|
||||
static void cleanManList(char **list);
|
||||
static LC_StringArray_t buildManList(char *suffix, char *name);
|
||||
static LC_StringArray_t makePathArray(const char *manpath);
|
||||
static void display(char *list);
|
||||
static char * getBaseName (char *out, char *in);
|
||||
|
||||
/*
|
||||
* Pre: argc is the number of strings in argv. It should either be 1 or 2.
|
||||
|
@ -49,7 +55,7 @@ static void cleanManList(char **list);
|
|||
*/
|
||||
|
||||
int man(int argc, char *argv[]) {
|
||||
char **manpath_array, **manpagelist;
|
||||
LC_StringArray_t manpath_array, manpagelist;
|
||||
char *sec, *name, *current_path;
|
||||
Section *section;
|
||||
int i, j, k, abort;
|
||||
|
@ -66,10 +72,10 @@ int man(int argc, char *argv[]) {
|
|||
if (t_flag) {
|
||||
if ((tcat = getenv("TCAT")) == NULL) {
|
||||
tcat = TCAT;
|
||||
} else tcat = Xstrdup(tcat,__LINE__,__FILE__);
|
||||
} else tcat = LC_xstrdup(tcat);
|
||||
if ((troff = getenv("TROFF")) == NULL) {
|
||||
troff = TROFF;
|
||||
} else troff = Xstrdup(troff,__LINE__,__FILE__);
|
||||
} else troff = LC_xstrdup(troff);
|
||||
}
|
||||
if (hyphen_flag) {
|
||||
pager = CAT;
|
||||
|
@ -86,13 +92,13 @@ int man(int argc, char *argv[]) {
|
|||
case 2:
|
||||
sec = argv[0];
|
||||
/* special case some section abbreviations */
|
||||
if (!strcmp(sec,"l")) {
|
||||
if (!strcasecmp(sec,"l")) {
|
||||
sec = "local";
|
||||
} else if (!strcmp(sec,"n")) {
|
||||
} else if (!strcasecmp(sec,"n")) {
|
||||
sec = "new";
|
||||
} else if (!strcmp(sec,"o")) {
|
||||
} else if (!strcasecmp(sec,"o")) {
|
||||
sec = "old";
|
||||
} else if (!strcmp(sec,"p")) {
|
||||
} else if (!strcasecmp(sec,"p")) {
|
||||
sec = "public";
|
||||
}
|
||||
name = argv[1];
|
||||
|
@ -104,13 +110,15 @@ int man(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
/* create array of paths to search */
|
||||
if ((manpath_array = makePathArray(manpath)) == NULL) return 1;
|
||||
if ((manpath_array = makePathArray(manpath)) == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* loop over all the paths in MANPATH
|
||||
*/
|
||||
i=0;
|
||||
current_path = manpath_array[i];
|
||||
current_path = (manpath_array->lc_vec)[i];
|
||||
while (!abort && current_path) {
|
||||
|
||||
dirbrk = (strchr(current_path,':')!=NULL) ? ':' : '/';
|
||||
|
@ -118,7 +126,7 @@ int man(int argc, char *argv[]) {
|
|||
/* go to the current path in MANPATH */
|
||||
if (chdir(current_path) == -1) {
|
||||
i++;
|
||||
current_path = manpath_array[i];
|
||||
current_path = (manpath_array->lc_vec)[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -129,9 +137,9 @@ int man(int argc, char *argv[]) {
|
|||
* if section number was specified and this isn't it, do
|
||||
* the next loop
|
||||
*/
|
||||
if (sec && (strcmp(sec,sections[j].name) ||
|
||||
if (sec && (strcasecmp(sec,sections[j].name) ||
|
||||
(!isdigit(*sec) &&
|
||||
strncmp(sec,sections[j].name,strlen(sec))))) continue;
|
||||
strncasecmp(sec,sections[j].name,strlen(sec))))) continue;
|
||||
section_found++;
|
||||
|
||||
/*
|
||||
|
@ -140,11 +148,11 @@ int man(int argc, char *argv[]) {
|
|||
*/
|
||||
|
||||
manpagelist = buildManList(sections[j].suffix,name);
|
||||
if (!manpagelist) continue;
|
||||
if (manpagelist->lc_used == 0) continue;
|
||||
page_found++;
|
||||
|
||||
for (k=0; !abort && manpagelist[k]; k++) {
|
||||
display(manpagelist[k]);
|
||||
for (k=0; !abort && k < manpagelist->lc_used; k++) {
|
||||
display((manpagelist->lc_vec)[k]);
|
||||
if (!hyphen_flag && !t_flag) {
|
||||
fprintf(stderr,
|
||||
"type q to quit, or any other key for next man page: ");
|
||||
|
@ -160,11 +168,11 @@ int man(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
cleanManList(manpagelist);
|
||||
LC_StringArrayDestroy(manpagelist);
|
||||
|
||||
} /* done looping over sections */
|
||||
i++;
|
||||
current_path = manpath_array[i];
|
||||
current_path = (manpath_array->lc_vec)[i];
|
||||
|
||||
} /* done looping over paths */
|
||||
|
||||
|
@ -189,19 +197,20 @@ int man(int argc, char *argv[]) {
|
|||
static const char *manstr="man";
|
||||
static const char *catstr="cat";
|
||||
|
||||
static char **buildManList(char *suffix, char *name) {
|
||||
static LC_StringArray_t
|
||||
buildManList(char *suffix, char *name) {
|
||||
static char buffer1[FILENAME_MAX];
|
||||
static char buffer2[FILENAME_MAX];
|
||||
DIR *directory;
|
||||
struct dirent *entry;
|
||||
char **list1, **list2, **list3;
|
||||
LC_StringArray_t list1, list2;
|
||||
size_t len;
|
||||
int total1, total2, i, j, k;
|
||||
char *p, *fn;
|
||||
int i, j, k;
|
||||
char *p, *fn, *L1, *L2;
|
||||
|
||||
/* initialization */
|
||||
list1 = list2 = list3 = NULL;
|
||||
total1 = total2 = 0;
|
||||
list1 = LC_StringArrayNew();
|
||||
list2 = LC_StringArrayNew();
|
||||
|
||||
#ifdef DEBUG
|
||||
/* sanity check on arguments */
|
||||
|
@ -221,19 +230,19 @@ static char **buildManList(char *suffix, char *name) {
|
|||
|
||||
/* skip if no match */
|
||||
len = strlen(name);
|
||||
if (strncmp(entry->d_name,name,len) ||
|
||||
if (strncasecmp(entry->d_name,name,len) ||
|
||||
(entry->d_name[len] != '.')) continue;
|
||||
|
||||
if (strlen(manstr) + strlen(suffix) + strlen(entry->d_name) +
|
||||
strlen(suffix) + 1 >= FILENAME_MAX) {
|
||||
fprintf(stderr,"internal error: buffer overflow at line %d of %s\n",
|
||||
__LINE__,__FILE__);
|
||||
errx(1, "internal error: buffer overflow at line %s:%d\n",
|
||||
__FILE__, __LINE__);
|
||||
}
|
||||
sprintf(buffer1,"%s%s:%s",manstr,suffix,entry->d_name);
|
||||
|
||||
/* look for "links" to aroff files. (what a kludge) */
|
||||
if ((buffer1[3] != 'l') &&
|
||||
(strcmp(".l",&buffer1[strlen(buffer1)-2])==0)) {
|
||||
(strcasecmp(".l",&buffer1[strlen(buffer1)-2])==0)) {
|
||||
FILE *linkptr;
|
||||
char *tp;
|
||||
|
||||
|
@ -253,14 +262,12 @@ static char **buildManList(char *suffix, char *name) {
|
|||
fclose(linkptr);
|
||||
|
||||
if (access(buffer2,R_OK) == 0) {
|
||||
list1 = addToStringArray(list1, buffer2);
|
||||
total1++;
|
||||
LC_StringArrayAdd(list1, buffer2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* not a .l "link"; a normal file */
|
||||
list1 = addToStringArray(list1, buffer1);
|
||||
total1++;
|
||||
LC_StringArrayAdd(list1, buffer1);
|
||||
}
|
||||
}
|
||||
closedir(directory);
|
||||
|
@ -277,7 +284,7 @@ static char **buildManList(char *suffix, char *name) {
|
|||
|
||||
/* skip if no match */
|
||||
len = strlen(name);
|
||||
if (strncmp(entry->d_name,name,len) ||
|
||||
if (strncasecmp(entry->d_name,name,len) ||
|
||||
(entry->d_name[len] != '.')) continue;
|
||||
|
||||
if (strlen(catstr) + strlen(suffix) + strlen(entry->d_name) +
|
||||
|
@ -286,8 +293,7 @@ static char **buildManList(char *suffix, char *name) {
|
|||
__LINE__,__FILE__);
|
||||
}
|
||||
sprintf(buffer1,"%s%s:%s",catstr,suffix,entry->d_name);
|
||||
list2 = addToStringArray(list2, buffer1);
|
||||
total2++;
|
||||
LC_StringArrayAdd(list2, buffer1);
|
||||
}
|
||||
closedir(directory);
|
||||
}
|
||||
|
@ -297,40 +303,34 @@ static char **buildManList(char *suffix, char *name) {
|
|||
* eliminate files common to both lists
|
||||
*/
|
||||
len = strlen(suffix);
|
||||
for(i=0; i<total1; i++) {
|
||||
if (list1[i] == NULL) continue;
|
||||
for (j=0; j<total2; j++) {
|
||||
if (list2[j] == NULL) continue;
|
||||
for(i=0; i< list1->lc_used; i++) {
|
||||
L1 = (list1->lc_vec)[i];
|
||||
for (j=0; j< list2->lc_used; j++) {
|
||||
L2 = (list2->lc_vec)[j];
|
||||
|
||||
getBaseName(buffer1,list1[i]);
|
||||
getBaseName(buffer2,list2[j]);
|
||||
getBaseName(buffer1, L1);
|
||||
getBaseName(buffer2, L2);
|
||||
|
||||
#ifdef DEBUG
|
||||
if ((strlen(buffer1) < len + 5) ||
|
||||
(strlen(buffer2) < len + 5)) {
|
||||
fprintf(stderr,"internal error at line %d of %s\n",__LINE__,
|
||||
__FILE__);
|
||||
exit(1);
|
||||
err(1, "internal error at line %d of %s\n", __LINE__, __FILE__);
|
||||
}
|
||||
#endif
|
||||
/* match after the respective "manXX/" and "catXX/" */
|
||||
if ( strcmp(&buffer1[len+4],&buffer2[len+4]) == 0 ) {
|
||||
if (strcasecmp(&buffer1[len+4],&buffer2[len+4]) == 0 ) {
|
||||
|
||||
p = newerFile(list1[i],list2[j]);
|
||||
if (p == list1[i]) {
|
||||
free(list2[j]);
|
||||
list2[j] = NULL;
|
||||
} else if (p == list2[j]) {
|
||||
free(list1[i]);
|
||||
list1[i] = NULL;
|
||||
break;
|
||||
p = newerFile(L1,L2);
|
||||
if (p == L1) {
|
||||
LC_StringArrayDelete(list2, L2);
|
||||
--j;
|
||||
} else if (p == (list2->lc_vec)[j]) {
|
||||
LC_StringArrayDelete(list1, L1);
|
||||
--i;
|
||||
break;
|
||||
} else {
|
||||
fprintf(stderr,"internal error at line %d of %s\n\t%s\n\t%s\n",
|
||||
__LINE__,__FILE__,
|
||||
(list1[i]) ? list1[i] : "(NULL)",
|
||||
(list2[j]) ? list2[j] : "(NULL)");
|
||||
perror("newerFile failed");
|
||||
exit(1);
|
||||
err(1, "internal error at %s:%d (newerFile failed)",
|
||||
__FILE__, __LINE__);
|
||||
}
|
||||
} /* endif */
|
||||
} /* endfor */
|
||||
|
@ -339,41 +339,12 @@ static char **buildManList(char *suffix, char *name) {
|
|||
/*
|
||||
* combine the two lists
|
||||
*/
|
||||
for (i=0;i<total1;i++) {
|
||||
if (list1[i] != NULL) {
|
||||
list3 = addToStringArray(list3, list1[i]);
|
||||
free(list1[i]);
|
||||
}
|
||||
j = list2->lc_used;
|
||||
for (i=0; i<j; i++) {
|
||||
LC_StringArrayAdd(list1, (list2->lc_vec)[i]);
|
||||
}
|
||||
for (j=0;j<total2;j++) {
|
||||
if (list2[j] != NULL) {
|
||||
list3 = addToStringArray(list3, list2[j]);
|
||||
free(list2[j]);
|
||||
}
|
||||
}
|
||||
free(list1);
|
||||
free(list2);
|
||||
return list3;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* cleanManList
|
||||
*
|
||||
* Pre: list is a NULL-terminated array of strings, where the array
|
||||
* and each string in the array was allocated by malloc.
|
||||
*
|
||||
* Post: all malloc'd memory in list is free'd.
|
||||
*/
|
||||
|
||||
static void cleanManList(char **list) {
|
||||
int i;
|
||||
|
||||
for (i=0; list[i]; i++) {
|
||||
free(list[i]);
|
||||
}
|
||||
free (list);
|
||||
return;
|
||||
LC_StringArrayDestroy(list2);
|
||||
return list1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -409,7 +380,7 @@ static void display(char *file) {
|
|||
/*
|
||||
* determine which subdirectory this file is in
|
||||
*/
|
||||
if (strncmp(file,"cat",3) == 0) {
|
||||
if (strncasecmp(file,"cat",3) == 0) {
|
||||
isubdir = CATSUBDIR;
|
||||
} else {
|
||||
isubdir = MANSUBDIR;
|
||||
|
@ -587,7 +558,7 @@ static void display(char *file) {
|
|||
* that may be on the base name. The set of compression
|
||||
* suffixes is defined by the NULL-terminated compressArray[].
|
||||
*
|
||||
* It is the user's responsibility to ensure that the
|
||||
* It is the caller's responsibility to ensure that the
|
||||
* buffer *out has been allocated with sufficient space
|
||||
* for the result.
|
||||
*
|
||||
|
@ -601,7 +572,7 @@ static char *getBaseName (char *out, char *in) {
|
|||
strcpy(out,in);
|
||||
if ((p = strrchr(out,'.')) != NULL) {
|
||||
for (i=0; compressArray[i].suffix; i++) {
|
||||
if (strcmp(p,compressArray[i].suffix)==0) {
|
||||
if (strcasecmp(p,compressArray[i].suffix)==0) {
|
||||
*p = '\0';
|
||||
break;
|
||||
}
|
||||
|
@ -609,3 +580,27 @@ static char *getBaseName (char *out, char *in) {
|
|||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/*
|
||||
* makePathArray
|
||||
*
|
||||
* Pre: <manpath> is a list of colon-delimited path names
|
||||
* Post: returns a StringArray pointer where each string is an
|
||||
* element of <manpath>
|
||||
*/
|
||||
|
||||
static LC_StringArray_t
|
||||
makePathArray(const char *manpath) {
|
||||
LC_StringArray_t result;
|
||||
char *pathcopy, *p;
|
||||
|
||||
result = LC_StringArrayNew();
|
||||
pathcopy = LC_xstrdup(manpath);
|
||||
p = strtok(pathcopy, ":");
|
||||
while (p != NULL) {
|
||||
LC_StringArrayAdd(result, p);
|
||||
p = strtok(NULL, ":");
|
||||
}
|
||||
free(pathcopy);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
Name: apropos
|
||||
Version: 3.1 (28 March 1998)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@trenco.gno.org
|
||||
Where: /usr/bin
|
||||
FTP: ftp.gno.org
|
||||
|
||||
Locate commands by keyword.
|
||||
Bundled with catman, makewhatis, man, and whatis in the manpack archive.
|
||||
|
||||
Name: catman
|
||||
Version: 3.1 (28 March 1998)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@trenco.gno.org
|
||||
Where: /usr/sbin
|
||||
FTP: ftp.gno.org
|
||||
|
||||
Preformat manual reference pages.
|
||||
Bundled with apropos, makewhatis, man, and whatis in the manpack archive.
|
||||
|
||||
Name: makewhatis
|
||||
Version: 3.1 (28 March 1998)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@trenco.gno.org
|
||||
Where: /usr/sbin
|
||||
FTP: ftp.gno.org
|
||||
|
||||
Create the whatis database used by man(1), apropos(1), and whatis(1).
|
||||
Bundled with apropos, catman, man, and whatis in the manpack archive.
|
||||
|
||||
Name: man
|
||||
Version: 3.1 (28 March 1998)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@trenco.gno.org
|
||||
Where: /usr/bin
|
||||
FTP: ftp.gno.org
|
||||
|
||||
Display manual reference pages.
|
||||
Bundled with apropos, catman, makewhatis, and whatis in the manpack archive.
|
||||
|
||||
Name: whatis
|
||||
Version: 3.1 (28 March 1998)
|
||||
Author: Devin Reade.
|
||||
Contact: gdr@trenco.gno.org
|
||||
Where: /usr/bin
|
||||
FTP: ftp.gno.org
|
||||
|
||||
Locate commands by name.
|
||||
Bundled with apropos, catman, makewhatis, and man in the manpack archive.
|
|
@ -0,0 +1,8 @@
|
|||
# 0
|
||||
# 1 The first column is the "real" man page; the second is the .so link.
|
||||
# 2 All paths should be relative to the /usr/man directory. This list
|
||||
# 3 should be kept sorted.
|
||||
# 4
|
||||
# 5 $Id: mkso.data,v 1.1 1998/03/29 07:16:16 gdr-ftp Exp $
|
||||
# 6
|
||||
man1/whatis.1 man1/apropos.1
|
|
@ -1,10 +1,15 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: process.c,v 1.4 1998/03/29 07:16:17 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "makewhatis";
|
||||
#pragma noroot
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -13,8 +18,8 @@ segment "makewhatis";
|
|||
#include <stdlib.h>
|
||||
#include <gsos.h>
|
||||
#include <orca.h>
|
||||
|
||||
#include "makewhatis.h"
|
||||
#include <gno/contrib.h>
|
||||
#include "man.h"
|
||||
|
||||
/* These are the compression types */
|
||||
#define NO_COMPRESS 0
|
||||
|
@ -59,7 +64,9 @@ void process (char *filename, char *tmp_file, FILE *whatis_fp, char *sec) {
|
|||
char *name; /* points to the file basename */
|
||||
short compression; /* the compression type (if nec) */
|
||||
|
||||
if (v_flag>=2) fprintf(output_fp,"Working on file %s/%s ...\n",sec,filename);
|
||||
if (v_flag>=2) {
|
||||
fprintf(output_fp,"Working on sec %s file %s ...\n", sec, filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* get the file basename
|
||||
|
|
|
@ -1,22 +1,31 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: util.c,v 1.2 1998/03/29 07:16:19 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "util______";
|
||||
#pragma noroot
|
||||
#endif
|
||||
|
||||
#define __USE_DYNAMIC_GSSTRING__
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <types.h>
|
||||
#include <gsos.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <sgtty.h>
|
||||
#include <fcntl.h>
|
||||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
/*
|
||||
* getManpath -- return a malloc'd copy of the MANPATH. If MANPATH
|
||||
|
@ -33,147 +42,14 @@ char *getManpath(void) {
|
|||
if (manpath == NULL) manpath = getenv("MANDIR");
|
||||
if (manpath == NULL) manpath = DEFAULT_MANPATH;
|
||||
|
||||
return Xstrdup(manpath,__LINE__,__FILE__);
|
||||
}
|
||||
|
||||
/*
|
||||
* Xstrdup - a safe strdup; it will handle error conditions and exit
|
||||
* one occurs
|
||||
*
|
||||
* line and file are arbitrary, but are expected to be the
|
||||
* values of __LINE__ and __FILE__ respectively.
|
||||
*/
|
||||
|
||||
char *Xstrdup(char *oldstr, int line, char *file) {
|
||||
char *newstr;
|
||||
|
||||
if ((newstr = malloc(strlen(oldstr)+1)) == NULL) {
|
||||
fprintf(stderr,"Xstrdup failed at line %d in file %s: %s\n",line,
|
||||
file,strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
strcpy(newstr,oldstr);
|
||||
return newstr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Xmalloc - a safe malloc; it will handle error conditions and exit
|
||||
* if one occurs.
|
||||
*
|
||||
* line and file are arbitrary, but are expected to be the
|
||||
* values of __LINE__ and __FILE__ respectively.
|
||||
*/
|
||||
|
||||
void *Xmalloc(size_t size, int line, char *file) {
|
||||
char *p;
|
||||
|
||||
if ((p = malloc(size)) == NULL) {
|
||||
fprintf(stderr,"Xmalloc failed at line %d in file %s: %s\n",line,
|
||||
file,strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
return ((void *) p);
|
||||
return LC_xstrdup(manpath);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Xrealloc - a safe realloc; it will handle error conditions and exit
|
||||
* if one occurs.
|
||||
*
|
||||
* line and file are arbitrary, but are expected to be the
|
||||
* values of __LINE__ and __FILE__ respectively.
|
||||
*/
|
||||
|
||||
void *Xrealloc(void *oldptr, size_t size, int line, char *file) {
|
||||
char *p;
|
||||
|
||||
if ((p = realloc(oldptr, size)) == NULL) {
|
||||
fprintf(stderr,"Xrealloc failed at line %d in file %s: %s\n",line,
|
||||
file,strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
return ((void *) p);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* addToStringArray -- add a string to a NULL-terminated array of strings.
|
||||
* If oldArray is NULL, then a new array is created,
|
||||
* otherwise oldArray is expanded.
|
||||
*
|
||||
* WARNING: | Because of the allocation scheme used, any oldArray
|
||||
* | passed to this routine _must_ be the return value
|
||||
* | of a previous call to this routine. This does not
|
||||
* | imply that only one array can be expanded by this
|
||||
* | routine (any number may be expanded).
|
||||
*
|
||||
* The value of macro SLOTS_QUANTUM defined below is
|
||||
* the number of array slots allocated at one time. The
|
||||
* size of the string array is always a multiple of this
|
||||
* value.
|
||||
*
|
||||
* Returns a pointer to an array that contains the old
|
||||
* strings with the new one appended. The array is
|
||||
* NULL-terminated.
|
||||
*/
|
||||
|
||||
#define SLOTS_QUANTUM 10
|
||||
|
||||
char **addToStringArray(char **oldArray, char *string) {
|
||||
|
||||
char **result;
|
||||
int slotsAlloced, slotsUsed;
|
||||
|
||||
if (oldArray == NULL) {
|
||||
|
||||
/*
|
||||
* This is a new array; do the brute force approach
|
||||
*/
|
||||
|
||||
result = Xmalloc(SLOTS_QUANTUM * sizeof(char *), __LINE__, __FILE__);
|
||||
result[0] = Xstrdup(string,__LINE__,__FILE__);
|
||||
result[1] = NULL;
|
||||
|
||||
} else {
|
||||
|
||||
/*
|
||||
* adding to and, if necessary, expanding an old array
|
||||
*/
|
||||
|
||||
/* determine slotsUsed and slotsAlloced */
|
||||
for (slotsUsed=0; oldArray[slotsUsed]; slotsUsed++);
|
||||
|
||||
if (slotsUsed % SLOTS_QUANTUM == SLOTS_QUANTUM-1) { /* space for NULL */
|
||||
slotsAlloced = slotsUsed+1;
|
||||
} else {
|
||||
slotsAlloced = ((slotsUsed / SLOTS_QUANTUM) + 1) * SLOTS_QUANTUM;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
assert(slotsUsed < slotsAlloced);
|
||||
#endif
|
||||
|
||||
/* expand number of slots if necessary */
|
||||
if (slotsUsed+1 < slotsAlloced) {
|
||||
/* there are enough slots; add it to this array */
|
||||
result = oldArray;
|
||||
} else {
|
||||
/* we need more slots; expand the array */
|
||||
slotsAlloced += SLOTS_QUANTUM;
|
||||
result = Xrealloc(oldArray, slotsAlloced * sizeof(char *),
|
||||
__LINE__, __FILE__);
|
||||
}
|
||||
|
||||
/* add the string to the array */
|
||||
result[slotsUsed++] = Xstrdup(string, __LINE__, __FILE__);
|
||||
result[slotsUsed] = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* makePathArray -- parse a path list and break it into a NULL-terminated
|
||||
* array of paths. The original path is left unchanged.
|
||||
* MakePathArray -- parse a path list and break it into a StringArray_t.
|
||||
* The original path is left unchanged.
|
||||
*
|
||||
* The delimiter between paths may either be a ' ' or a ':'.
|
||||
* The delimiter is assumed to be a ':' if <path> contains
|
||||
|
@ -181,70 +57,42 @@ char **addToStringArray(char **oldArray, char *string) {
|
|||
* otherwise the delimiter is assumed to be a ' '.
|
||||
*/
|
||||
|
||||
char **makePathArray(char *path) {
|
||||
LC_StringArray_t
|
||||
MakePathArray(char *path) {
|
||||
LC_StringArray_t result;
|
||||
char *delim, *p, *q;
|
||||
|
||||
char *delim, *p, *q, **result;
|
||||
/* set the delimiter */
|
||||
if ((strchr(path,' ')==NULL) &&
|
||||
strchr(path,':') &&
|
||||
strchr(path,'/')) {
|
||||
delim = ":";
|
||||
} else {
|
||||
delim = " ";
|
||||
}
|
||||
|
||||
/* set the delimiter */
|
||||
if ( strchr(path,' ')==NULL &&
|
||||
strchr(path,':') &&
|
||||
strchr(path,'/')) {
|
||||
delim = ":";
|
||||
} else {
|
||||
delim = " ";
|
||||
}
|
||||
/* build the array */
|
||||
#ifndef __ORCAC__
|
||||
/* ORCA/C's strtok implementation doesn't modify the provided buffer */
|
||||
p = LC_xstrdup(path);
|
||||
#else
|
||||
p = path;
|
||||
#endif
|
||||
result = LC_StringArrayNew();
|
||||
q = strtok(p,delim);
|
||||
while (q != NULL) {
|
||||
LC_StringArrayAdd(result, q);
|
||||
q = strtok(NULL,delim);
|
||||
}
|
||||
|
||||
/* build the array */
|
||||
p = Xstrdup(path, __LINE__, __FILE__);
|
||||
q = strtok(p,delim);
|
||||
result = NULL;
|
||||
while (q) {
|
||||
result = addToStringArray(result, q);
|
||||
q = strtok(NULL,delim);
|
||||
}
|
||||
|
||||
free(p);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ncstrcmp -- A case insensitive ("no-case") strcmp
|
||||
*/
|
||||
|
||||
int ncstrcmp(char *a, char *b) {
|
||||
|
||||
while (*a && *b) {
|
||||
if (*a == *b) {
|
||||
a++; b++;
|
||||
continue;
|
||||
}
|
||||
return ((int) *b - *a);
|
||||
}
|
||||
if (!*a && !*b) return 0;
|
||||
return ((int) *b - *a);
|
||||
#ifndef __ORCAC__
|
||||
free(p);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* ncstrncmp -- A case insensitive ("no-case") strncmp
|
||||
*/
|
||||
|
||||
int ncstrncmp (char *a, char *b, unsigned int count) {
|
||||
unsigned int i=0;
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (a[i] == b[i]) {
|
||||
if (!a[i]) break;
|
||||
else continue;
|
||||
}
|
||||
return ((int) b[i]-a[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ncstrstr -- A case insensitive ("no-case") strstr
|
||||
* strcasestr -- A case insensitive ("no-case") strstr
|
||||
*
|
||||
* This is implemented using a convert-copy-to-single-case-
|
||||
* then-strstr hack.
|
||||
|
@ -253,12 +101,13 @@ int ncstrncmp (char *a, char *b, unsigned int count) {
|
|||
* and using a straight-forward search for strlen(substr) <= 5.
|
||||
*/
|
||||
|
||||
char *ncstrstr(char *str, char *substr) {
|
||||
char *
|
||||
strcasestr(char *str, char *substr) {
|
||||
|
||||
char *strCopy, *substrCopy, *p;
|
||||
|
||||
strCopy = Xstrdup(str,__LINE__,__FILE__);
|
||||
substrCopy = Xstrdup(substr,__LINE__,__FILE__);
|
||||
strCopy = LC_xstrdup(str);
|
||||
substrCopy = LC_xstrdup(substr);
|
||||
|
||||
/* convert the strings */
|
||||
p = strCopy;
|
||||
|
@ -288,35 +137,48 @@ char *ncstrstr(char *str, char *substr) {
|
|||
* is an error.
|
||||
*/
|
||||
|
||||
char *newerFile(char *path1, char *path2) {
|
||||
static struct stat record1, record2;
|
||||
int i,j;
|
||||
char *
|
||||
newerFile(char *path1, char *path2) {
|
||||
|
||||
/*
|
||||
* see if both, only one, or neither files exist
|
||||
*/
|
||||
static struct stat sbuf1, sbuf2;
|
||||
int e1, e2;
|
||||
|
||||
i = access(path1, F_OK);
|
||||
j = access(path2, F_OK);
|
||||
if (i==-1 && j==-1) {
|
||||
errno = ENOENT;
|
||||
return NULL;
|
||||
} else if (i==-1) {
|
||||
return path2;
|
||||
} else if (j==-1) {
|
||||
return path1;
|
||||
}
|
||||
/* stat the first file */
|
||||
if (stat(path1, &sbuf1) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
e1 = ENOENT;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
e1 = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* both files exist; stat them
|
||||
*/
|
||||
/* stat the second file */
|
||||
if (stat(path2, &sbuf2) < 0) {
|
||||
if (errno == ENOENT) {
|
||||
e2 = ENOENT;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
e2 = 0;
|
||||
}
|
||||
|
||||
if (stat(path1,&record1) != 0) return NULL;
|
||||
if (stat(path2,&record2) != 0) return NULL;
|
||||
|
||||
return (record1.st_mtime > record2.st_mtime) ? path1 : path2;
|
||||
}
|
||||
/* one or both don't exist? */
|
||||
if (e1 && e2) {
|
||||
return NULL;
|
||||
}
|
||||
if (e1) {
|
||||
return path2;
|
||||
}
|
||||
if (e2) {
|
||||
return path1;
|
||||
}
|
||||
|
||||
/* both exist */
|
||||
return (sbuf1.st_mtime > sbuf2.st_mtime) ? path1 : path2;
|
||||
}
|
||||
|
||||
/*
|
||||
* getcharraw() - return the next character from stdin without waiting
|
||||
|
@ -326,7 +188,8 @@ char *newerFile(char *path1, char *path2) {
|
|||
|
||||
#define FAILED_CHAR '\0';
|
||||
|
||||
char getcharraw(void) {
|
||||
char
|
||||
getcharraw(void) {
|
||||
short oldmode;
|
||||
struct sgttyb s;
|
||||
int count;
|
||||
|
@ -348,39 +211,37 @@ char getcharraw(void) {
|
|||
}
|
||||
|
||||
/*
|
||||
* basename -- return a pointer to the base filename (all leading
|
||||
* pathname components removed) of <path>. <path> _must_
|
||||
* point to a NULL-terminated string.
|
||||
* getFileType -- Get the file type and auxillary file type of a file.
|
||||
* On success it returns a pointer to an internal buffer
|
||||
* containing the file type and aux type. On failure
|
||||
* it returns NULL and sets errno.
|
||||
*/
|
||||
|
||||
char *basename (char *path) {
|
||||
char *p, dirsep;
|
||||
fileType *getFileType (char *file) {
|
||||
|
||||
dirsep = (strchr(path,':')) ? ':' : '/';
|
||||
if ((p = strrchr(path,dirsep)) != NULL) {
|
||||
return p+1;
|
||||
} else {
|
||||
return path;
|
||||
static FileInfoRecGS record;
|
||||
static fileType result;
|
||||
int i;
|
||||
|
||||
/* set the parameters */
|
||||
record.pCount = 4;
|
||||
if ((record.pathname = __C2GSMALLOC(file)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dirname -- return a pointer to a string consisting of the directory
|
||||
* component of <path>. This returns a pointer to an internal
|
||||
* buffer, so the next call to dirname() will overwrite this
|
||||
* buffer. <path> must be a NULL-terminated string.
|
||||
*/
|
||||
|
||||
char *dirname (const char *path) {
|
||||
static char buffer[FILENAME_MAX];
|
||||
char *p, dirsep;
|
||||
|
||||
strcpy(buffer,path);
|
||||
|
||||
dirsep = (strchr(buffer,':')) ? ':' : '/';
|
||||
if ((p = strrchr(buffer,dirsep)) != NULL) {
|
||||
*p = '\0';
|
||||
/* get the info */
|
||||
GetFileInfoGS(&record);
|
||||
i = _toolErr;
|
||||
GIfree(record.pathname);
|
||||
if (i) {
|
||||
errno = _mapErr(i);
|
||||
return NULL;
|
||||
}
|
||||
return buffer;
|
||||
|
||||
/* set the return value */
|
||||
result.type = record.fileType;
|
||||
result.auxtype = record.auxType;
|
||||
|
||||
return &result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*/
|
||||
|
||||
/*
|
||||
* from util.c
|
||||
*/
|
||||
|
||||
#define DEFAULT_MANPATH "/usr/man"
|
||||
|
||||
char *getManpath(void);
|
||||
char *Xstrdup(char *oldstr, int line, char *file);
|
||||
void *Xmalloc(size_t size, int line, char *file);
|
||||
void *Xrealloc(void *oldptr, size_t size, int line, char *file);
|
||||
char **addToStringArray(char **oldArray, char *string);
|
||||
char **makePathArray(char *path);
|
||||
int ncstrcmp(char *a, char *b);
|
||||
int ncstrncmp (char *a, char *b, unsigned int count);
|
||||
char *ncstrstr(char *str, char *substr);
|
||||
char *newerFile(char *path1, char *path2);
|
||||
char getcharraw(void);
|
||||
char *basename (char *path);
|
||||
char *dirname (const char *path);
|
||||
|
||||
|
||||
/*
|
||||
* from utilgs.c
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
unsigned int type;
|
||||
unsigned long int auxtype;
|
||||
} fileType, fileTypePtr;
|
||||
|
||||
fileType *getFileType (char *file);
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*/
|
||||
|
@ -17,8 +17,10 @@ segment "utilgs____";
|
|||
extern GSString255Ptr __C2GSMALLOC(char *);
|
||||
extern int _mapErr(int);
|
||||
|
||||
#if 0 /* we should be able to use the GNO v2.0.6 libraries for this */
|
||||
|
||||
/*
|
||||
* access -- a replacement for the standard Gno one; this one will actually
|
||||
* access -- a replacement for the standard GNO one; this one will actually
|
||||
* return 0 when testing X_OK on a directory.
|
||||
*
|
||||
* This one still has a bug in it: If the file is a shell command or sys
|
||||
|
@ -52,7 +54,7 @@ int access(char *name, int mode) {
|
|||
|
||||
|
||||
/*
|
||||
* chdir -- Replacement for the one normally shipping with Gno.
|
||||
* chdir -- Replacement for the one normally shipping with GNO.
|
||||
* Returns -1 and sets errno on failure, instead of always
|
||||
* returning zero.
|
||||
*/
|
||||
|
@ -92,6 +94,7 @@ int chdir (const char *pathname) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#endif /* 0 */
|
||||
|
||||
/*
|
||||
* getFileType -- Get the file type and auxillary file type of a file.
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
.\" specifies the terms and conditions for redistribution.
|
||||
.\"
|
||||
.\" While this manual page is based on one from UCB, the included
|
||||
.\" C source, makefile, and executables are copyright (c) 1995
|
||||
.\" by Devin Reade <gdr@myrias.com>. All rights reserved.
|
||||
.\" C source, makefile, and executables are copyright (c) 1995-1998
|
||||
.\" by Devin Reade <gdr@trenco.gno.org>. All rights reserved.
|
||||
.\"
|
||||
.TH WHATIS 1 "Commands and Applications" "24 July 95" "Version 3.0"
|
||||
.TH WHATIS 1 "28 March 1998" GNO "Commands and Applications"
|
||||
.SH NAME
|
||||
whatis, apropos \- locate commands by name or keyword lookup
|
||||
.SH SYNOPSIS
|
||||
|
@ -39,8 +39,7 @@ while
|
|||
shows which manual pages contain instances of any of the given
|
||||
.IR keyword (s)
|
||||
in their title line.
|
||||
Each word is considered separately and, for
|
||||
.BR apropos ,
|
||||
Each word is considered separately and, for the GNO implementation,
|
||||
the case of letters is ignored.
|
||||
Words which are part of other words are considered; when looking for
|
||||
.IR compile ,
|
||||
|
@ -55,6 +54,8 @@ If a line output by either of these commands starts with
|
|||
|
||||
.fi
|
||||
you can enter
|
||||
.BI man name
|
||||
or
|
||||
.BI man " section name"
|
||||
to get its documentation.
|
||||
.SH OPTIONS
|
||||
|
@ -167,14 +168,18 @@ flag, in turn, overrides this value.)
|
|||
See the description of the
|
||||
.B \-M
|
||||
flag for syntax details.
|
||||
.SH VERSION
|
||||
This manual page documents
|
||||
.BR apropos
|
||||
and
|
||||
.BR whatis
|
||||
versions 3.1.
|
||||
.SH FILES
|
||||
.\" .IP \fB/usr/\fR[\fBshare/\fR]\fBman/whatis\fR
|
||||
.BR /usr/ [ share/ ] man/whatis " \-"
|
||||
The
|
||||
.BR whatis (1)
|
||||
database.
|
||||
.SH BUGS
|
||||
Please report any bugs to Devin Reade, <gdr@myrias.ab.ca>.
|
||||
.SH SEE ALSO
|
||||
.BR man (1),
|
||||
.BR whereis (1),
|
||||
|
|
|
@ -1,41 +1,39 @@
|
|||
/*
|
||||
* Copyright 1995 by Devin Reade <gdr@myrias.com>. For distribution
|
||||
* Copyright 1995-1998 by Devin Reade <gdr@trenco.gno.org>. For distribution
|
||||
* information see the README file that is part of the manpack archive,
|
||||
* or contact the author, above.
|
||||
*
|
||||
* $Id: whatis.c,v 1.2 1998/03/29 07:16:24 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#ifdef __ORCAC__
|
||||
segment "apropos___";
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <libc.h>
|
||||
#include "util.h"
|
||||
#include <unistd.h>
|
||||
#include <gno/gno.h>
|
||||
#include "man.h"
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
static char *versionstr = "3.0";
|
||||
static char *versionstr = VERSION_STR;
|
||||
static char *nothing = "nothing appropriate";
|
||||
|
||||
extern void begin_stack_check(void);
|
||||
extern int end_stack_check(void);
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
char *path;
|
||||
int i, matches1, matches2, matches3;
|
||||
short V_flag, M_flag, m_flag, n_flag, err_flag;
|
||||
|
||||
/* make sure Gno is running */
|
||||
/* make sure GNO is running */
|
||||
if (needsgno()==0) {
|
||||
fprintf(stderr,"Requires Gno/ME\n");
|
||||
fprintf(stderr,"Requires GNO\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
begin_stack_check();
|
||||
#endif
|
||||
__REPORT_STACK();
|
||||
|
||||
/* initialization */
|
||||
V_flag = M_flag = m_flag = n_flag = err_flag = 0;
|
||||
|
@ -101,10 +99,6 @@ int main (int argc, char **argv) {
|
|||
fprintf(stderr,"%s: %s\n",basename(argv[0]),nothing);
|
||||
}
|
||||
|
||||
#ifdef STACK_CHECK
|
||||
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
|
||||
#endif
|
||||
|
||||
if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*
|
||||
* $Id: whatis.rez,v 1.1 1998/03/29 07:16:25 gdr-ftp Exp $
|
||||
*/
|
||||
|
||||
#include "Types.Rez"
|
||||
|
||||
#define PROG "whatis"
|
||||
#define DESC "Locate commands by name."
|
||||
|
||||
#include "common.rez"
|
Loading…
Reference in New Issue