- modifications for compilation under GNO v2.0.6 base build. See

the README for details of changes.
This commit is contained in:
gdr-ftp 1998-03-29 07:16:25 +00:00
parent aa8b92ae3a
commit db224b5b07
33 changed files with 745 additions and 789 deletions

106
usr.bin/man/Makefile Normal file
View File

@ -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

View File

@ -1,7 +1,7 @@
-------------------------------------------- --------------------------------------------
Name: manpack Name: manpack
Version: 3.0 Version: 3.1
Author: Devin Reade <gdr@myrias.com> Author: Devin Reade <gdr@trenco.gno.org>
Computer: Apple IIgs Computer: Apple IIgs
Requires: GNO v2.x Requires: GNO v2.x
-------------------------------------------- --------------------------------------------
@ -10,13 +10,14 @@ Requires: GNO v2.x
Description: 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 apropos locate commands by keyword
catman v1.0 format cat pages from man pages catman format cat pages from man pages
makewhatis v1.2 create the whatis database makewhatis create the whatis database
man v3.0 display reference manual pages man display reference manual pages
whatis v3.0 locate commands by name whatis locate commands by name
============ ============
Installation: 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 verify the destination directories in "Makefile.mk". By default
these are: these are:
BINDIR = /usr/bin (apropos, catman, man, and whatis) BINDIR = /usr/bin (apropos, man, and whatis)
SBINDIR = /usr/sbin (makewhatis) SBINDIR = /usr/sbin (catman, and makewhatis)
MANDIR = /usr/man (all manual pages) MANDIR = /usr/man (all manual pages)
Ensure that all older versions of these programs are deleted. Ensure that all older versions of these programs are deleted.
They may or may not be in the above directories. 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: 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 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 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. with any other attributions.
Inclusion of these utilities in collections on disk, CD-ROM, or 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 Updates to these utilities may be distributed provided that the source
and this README file are included. Please follow the coding style 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: CHANGES:
======= =======
apropos, whatis 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) v3.0 (24 Jul 95)
Complete rewrite from scratch by Devin Reade. Complete rewrite from scratch by Devin Reade.
This version makes use of MANPATH in the same way This version makes use of MANPATH in the same way
as man(1) v3.0. Similarily, it will also search 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 In the previous version, the behavior of apropos was
identical to that of whatis. This version has been identical to that of whatis. This version has been
@ -81,11 +92,21 @@ apropos, whatis
because it shipped with man(1) v2.1. because it shipped with man(1) v2.1.
catman catman
v3.1 (28 Mar 98)
Incorporated all utilities into the GNO base build. All
versions are now lockstepped.
v1.0 (24 Jul 95) v1.0 (24 Jul 95)
Initial release. Written from scratch by Devin Reade. Initial release. Written from scratch by Devin Reade.
makewhatis 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) v1.2 (24 Jul 95)
Fixed bug where pages in "manl" ending in ".l" (that's Fixed bug where pages in "manl" ending in ".l" (that's
@ -149,6 +170,12 @@ makewhatis
Initial release. Written from scratch by Devin Reade. Initial release. Written from scratch by Devin Reade.
man 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) v3.0 (24 Jul 95)
Complete rewrite from scratch by Devin Reade. Complete rewrite from scratch by Devin Reade.

View File

@ -1 +0,0 @@
.so man1/whatis.1

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: apropos.c,v 1.2 1998/03/29 07:15:42 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "apropos___"; segment "apropos___";
#endif
#include <stdio.h> #include <stdio.h>
#include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
#include <libc.h> #include <unistd.h>
#include "util.h" #include <err.h>
#include <gno/gno.h>
#include "man.h" #include "man.h"
extern int optind; static char *versionstr = VERSION_STR;
extern char *optarg;
static char *versionstr = "3.0";
static char *nothing = "nothing appropriate"; static char *nothing = "nothing appropriate";
extern void begin_stack_check(void);
extern int end_stack_check(void);
int main (int argc, char **argv) { int main (int argc, char **argv) {
char *path; char *path;
int i, matches1, matches2, matches3; int i, matches1, matches2, matches3;
short V_flag, M_flag, m_flag, n_flag, err_flag; short V_flag, M_flag, m_flag, n_flag, err_flag;
/* make sure Gno is running */ /* make sure GNO is running */
if (needsgno()==0) { if (needsgno()==0) {
fprintf(stderr,"Requires Gno/ME\n"); errx(1, "Requires GNO\n");
return 1;
} }
#ifdef STACK_CHECK __REPORT_STACK();
begin_stack_check();
#endif
/* initialization */ /* initialization */
V_flag = M_flag = m_flag = n_flag = err_flag = 0; 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); 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; if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0;
return 1; return 1;
} }

10
usr.bin/man/apropos.rez Normal file
View File

@ -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"

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: apropos2.c,v 1.2 1998/03/29 07:15:45 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "apropos2__"; segment "apropos2__";
#pragma noroot
#endif
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
@ -13,7 +18,7 @@ segment "apropos2__";
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include "util.h" #include <err.h>
#include "man.h" #include "man.h"
/* /*
@ -21,7 +26,8 @@ segment "apropos2__";
* length of the command * length of the command
*/ */
static char *orcapadding (char *command) { static char *
orcapadding (char *command) {
int i; int i;
static char *two ="\t\t"; static char *two ="\t\t";
static char *one ="\t"; static char *one ="\t";
@ -40,9 +46,10 @@ static char *orcapadding (char *command) {
* orcacommand() modifies the buffer. * orcacommand() modifies the buffer.
*/ */
static char *orcacomment (char *buffer) { static char *
orcacomment (char *buffer) {
char *p; char *p;
static char *bad_line="malformed SYSCMND line\n"; static char *bad_line = "malformed SYSCMND line\n";
p = buffer; p = buffer;
@ -91,7 +98,8 @@ static char *orcacomment (char *buffer) {
* modifies the buffer. * modifies the buffer.
*/ */
static char *orcacommand(char *buffer) { static char *
orcacommand(char *buffer) {
char *p; char *p;
p = buffer; p = buffer;
@ -136,12 +144,14 @@ static char *orcacommand(char *buffer) {
* WARNING: Use of the MAN_F_MODE may alter the contents of argv[]. * 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 **manpath_array;
char *current_path, *p, *q, *r, *keyword; char *current_path, *p, *q, *r, *keyword;
FILE *fp; FILE *fp;
char dirbrk; char dirbrk;
int i, j, matches; int i, j, matches;
LC_StringArray_t sarray;
#ifdef DEBUG #ifdef DEBUG
assert ((apropos_mode == WHATIS_MODE) || assert ((apropos_mode == WHATIS_MODE) ||
@ -193,8 +203,10 @@ int apropos(int argc, char **argv, int apropos_mode) {
/* loop over keywords */ /* loop over keywords */
for(i=0; i<argc; i++) { for(i=0; i<argc; i++) {
keyword = argv[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 && (apropos_mode == ORCA_W_MODE &&
!strncmp(linebuf,keyword,strlen(keyword)))) { !strncmp(linebuf,keyword,strlen(keyword)))) {
r = orcacomment(linebuf); r = orcacomment(linebuf);
@ -209,7 +221,8 @@ int apropos(int argc, char **argv, int apropos_mode) {
return matches; 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 * loop over all the paths in MANPATH
@ -240,31 +253,24 @@ int apropos(int argc, char **argv, int apropos_mode) {
keyword = argv[j]; keyword = argv[j];
switch (apropos_mode) { switch (apropos_mode) {
case MAN_F_MODE: case MAN_F_MODE:
if (strstr(linebuf,keyword)) {
printf("%s",linebuf);
matches++;
}
break;
case MAN_K_MODE: case MAN_K_MODE:
if (ncstrstr(linebuf,keyword)) { if (strcasestr(linebuf,keyword)) {
printf("%s",linebuf); printf("%s",linebuf);
matches++; matches++;
} }
break; break;
case WHATIS_MODE: case WHATIS_MODE:
/* avoid unnecessary strcpy's */ /* avoid unnecessary strcpy's */
if (strstr(linebuf,keyword)==NULL) break; if (strcasestr(linebuf,keyword)==NULL) break;
strcpy(linebuf2,linebuf); strcpy(linebuf2,linebuf);
if ((p = strchr(linebuf2,'(')) != NULL) *p = '\0'; if ((p = strchr(linebuf2,'(')) != NULL) *p = '\0';
if (strstr(linebuf2,keyword)) { if (strcasestr(linebuf2,keyword)) {
printf("%s",linebuf); printf("%s",linebuf);
matches++; matches++;
} }
break; break;
default: default:
fprintf(stderr,"internal error line %d of %s\n", errx(1, "internal error at %s:%d", __FILE__, __LINE__);
__LINE__,__FILE__);
exit(1);
} }
} }
} else if (ferror(fp)) { } else if (ferror(fp)) {
@ -280,5 +286,6 @@ int apropos(int argc, char **argv, int apropos_mode) {
current_path = manpath_array[i]; current_path = manpath_array[i];
} /* endwhile loop over directories */ } /* endwhile loop over directories */
LC_StringArrayDestroy(sarray);
return matches; return matches;
} }

View File

@ -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 .SH NAME
catman \- format cat pages from man pages catman \- format cat pages from man pages
.SH SYNOPSIS .SH SYNOPSIS
@ -74,16 +77,6 @@ on to the list of paths for which manual pages will be updated.
Display version information and exit. Display version information and exit.
.IP \fB-v\fR .IP \fB-v\fR
Verbose. Show processing information. 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 .SH WARNING
.BR catman .BR catman
will unlink any out-of-date files in the 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 is invoked with the
.BR -p .BR -p
option. 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).

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: catman.c,v 1.2 1998/03/29 07:15:48 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "catman____"; segment "catman____";
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h> #include <stdio.h>
#include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <libc.h>
#include <dirent.h> #include <dirent.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "util.h" #include <err.h>
#include <gno/gno.h>
#include "man.h" #include "man.h"
#define OVERFLOW_ABORT(line,file) { \ #define OVERFLOW_ABORT(line,file) errx(1, overflowMsg, line, file)
fprintf(stderr,overflowMsg,line,file); \
exit(1); \
}
short v_flag, V_flag, M_flag, m_flag, p_flag, err_flag; short v_flag, V_flag, M_flag, m_flag, p_flag, err_flag;
extern int optind; static const char *versionstr = VERSION_STR;
extern char *optarg;
static char *versionstr = "1.0";
/* This is of the form "man<section>" */ /* This is of the form "man<section>" */
char mandir[FILENAME_MAX]; char mandir[FILENAME_MAX];
@ -48,9 +45,6 @@ char base[FILENAME_MAX];
static char *overflowMsg = "internal buffer overflow at line %d of %s\n"; 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 * catman
* *
@ -83,9 +77,11 @@ int catman(int argc, char **argv) {
fileType *ftype; /* the file type of the man page */ fileType *ftype; /* the file type of the man page */
struct stat statbuf1, statbuf2; struct stat statbuf1, statbuf2;
char dirbrk; char dirbrk;
LC_StringArray_t sarray;
/* create array of paths to search */ /* 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 */ /* loop over paths in MANPATH */
pathIndex=0; pathIndex=0;
@ -271,20 +267,16 @@ int catman(int argc, char **argv) {
} }
} }
int main (int argc, char **argv) { int main (int argc, char **argv) {
char *path; char *path;
int i, result1, result2; int i, result1, result2;
/* make sure Gno is running */ /* make sure GNO is running */
if (needsgno()==0) { if (needsgno()==0) {
fprintf(stderr,"Requires Gno/ME\n"); errx(1, "Requires GNO\n");
return 1;
} }
#ifdef STACK_CHECK __REPORT_STACK();
begin_stack_check();
#endif
/* initialization */ /* initialization */
v_flag = V_flag = M_flag = m_flag = p_flag = err_flag = 0; 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]); result2 = catman(argc-optind, &argv[optind]);
} }
#ifdef STACK_CHECK
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
#endif
return (result1 || result2); return (result1 || result2);
} }

10
usr.bin/man/catman.rez Normal file
View File

@ -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"

View 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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*/ */

19
usr.bin/man/common.rez Normal file
View File

@ -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
};

View File

@ -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.

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: fillbuffer.c,v 1.4 1998/03/29 07:15:55 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "makewhatis"; segment "makewhatis";
#pragma noroot
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "makewhatis.h" #include <err.h>
#include "man.h"
#define NAME1 "NAME" #define NAME1 "NAME"
#define NAME2 "N\bNA\bAM\bME\bE" #define NAME2 "N\bNA\bAM\bME\bE"
@ -86,7 +92,7 @@ void fillbuffer (char *filename) {
* open the file * open the file
*/ */
if ((fp = fopen(filename,"rb")) == NULL) { if ((fp = fopen(filename,"r")) == NULL) {
buffer[0] = '\0'; buffer[0] = '\0';
if (v_flag) fprintf (error_fp,"Open failed for file \"%s\"\n",filename); if (v_flag) fprintf (error_fp,"Open failed for file \"%s\"\n",filename);
return; return;
@ -141,7 +147,7 @@ void fillbuffer (char *filename) {
/* we need the previous newline for the next algorithm to work */ /* 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 * Make p1 point to spot in buffer2 where there occurs the first
@ -188,7 +194,7 @@ void fillbuffer (char *filename) {
*/ */
if (in_comment) { if (in_comment) {
while((p1<p2) && (*p1 != '\r')) p1++; while((p1<p2) && (*p1 != '\n')) p1++;
in_comment = 0; in_comment = 0;
} }
@ -215,14 +221,14 @@ void fillbuffer (char *filename) {
for (; p1<p2; p1++) { for (; p1<p2; p1++) {
/* skip .\" comments */ /* skip .\" comments */
if (strncmp(p1,"\r.\\\"",4) == 0) { if (strncmp(p1,"\n.\\\"",4) == 0) {
while ((p1<p2) && (*p1!='\r')) p1++; while ((p1<p2) && (*p1!='\n')) p1++;
if (p1==p2) in_comment = 1; if (p1==p2) in_comment = 1;
continue; continue;
} }
/* skip .BR-type formatting */ /* skip .BR-type formatting */
if ((p1<p2) && (*p1=='\r') && (*(p1+1)=='.')) { if ((p1<p2) && (*p1=='\n') && (*(p1+1)=='.')) {
p1++; p1++;
while ((p1<p2) && !isspace(*p1)) p1++; while ((p1<p2) && !isspace(*p1)) p1++;
if (p1==p2) in_format_BR = 1; if (p1==p2) in_format_BR = 1;
@ -250,7 +256,7 @@ void fillbuffer (char *filename) {
if (isgraph(*p1) && (*p1!=' ')) foo=1; if (isgraph(*p1) && (*p1!=' ')) foo=1;
if (!foo) { if (!foo) {
while ((p1<p2) && !(isgraph(*p1) && (*p1!=' '))) p1++; while ((p1<p2) && !(isgraph(*p1) && (*p1!=' '))) p1++;
if ((*p1=='.') && (*(p1-1)=='\r')) p1 -=2; if ((*p1=='.') && (*(p1-1)=='\n')) p1 -=2;
else --p1; else --p1;
continue; continue;
} }
@ -258,7 +264,7 @@ void fillbuffer (char *filename) {
if (isgraph(*p1)) foo=1; if (isgraph(*p1)) foo=1;
if (!foo) { if (!foo) {
while ((p1<p2) && !isgraph(*p1)) p1++; while ((p1<p2) && !isgraph(*p1)) p1++;
if ((*p1=='.') && (*(p1-1)=='\r')) p1 -=2; if ((*p1=='.') && (*(p1-1)=='\n')) p1 -=2;
else --p1; else --p1;
continue; continue;
} }
@ -357,7 +363,7 @@ void fillbuffer (char *filename) {
*/ */
if (in_comment) { if (in_comment) {
while((p1<p2) && (*p1 != '\r')) p1++; while((p1<p2) && (*p1 != '\n')) p1++;
in_comment = 0; in_comment = 0;
} }
@ -384,13 +390,13 @@ void fillbuffer (char *filename) {
for (; p1<p2; p1++) { for (; p1<p2; p1++) {
/* skip .\" comments */ /* skip .\" comments */
if (strncmp(p1,"\r.\\\"",4) == 0) { if (strncmp(p1,"\n.\\\"",4) == 0) {
while ((p1<p2) && (*p1!='\r')) p1++; while ((p1<p2) && (*p1!='\n')) p1++;
if (p1==p2) in_comment = 1; if (p1==p2) in_comment = 1;
} }
/* skip .BR-type formatting */ /* skip .BR-type formatting */
if ((p1<p2) && (*p1=='\r') && (*(p1+1)=='.')) { if ((p1<p2) && (*p1=='\n') && (*(p1+1)=='.')) {
p1++; p1++;
while ((p1<p2) && !isspace(*p1)) p1++; while ((p1<p2) && !isspace(*p1)) p1++;
if (p1==p2) in_format_BR = 1; if (p1==p2) in_format_BR = 1;
@ -450,9 +456,17 @@ void fillbuffer (char *filename) {
if (count == 0) { if (count == 0) {
/* eof or error; terminate buffer and return */ /* eof or error; terminate buffer and return */
*p3 = '\0'; *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); fclose(fp);
if (v_flag) fprintf (error_fp,
"EOF or error on %s, description not found.\n",filename);
return; return;
} }
buffer2[count] = '\0'; buffer2[count] = '\0';

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * 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" #include "man.h"
#ifndef NULL
#define NULL 0x0L
#endif
/* /*
* The compression suffixes and how to uncompress the files. * The compression suffixes and how to uncompress the files.
* If you use ".l" (that's "ell") as a suffix, you will break the * If you use ".l" (that's "ell") as a suffix, you will break the

View File

@ -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

View File

@ -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 .SH NAME
.B makewhatis .B makewhatis
\- generate the whatis database file \- generate the whatis database file
@ -22,6 +22,10 @@
.B -V .B -V
] ]
.SH DESCRIPTION .SH DESCRIPTION
This manual page documents
.B makewhatis
version 3.1.
.LP
.B makewhatis .B makewhatis
generates the whatis database for generates the whatis database for
.BR apropos (1), .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 in the output. This was not fixed due to the overhead of having to
check for such a condition. check for such a condition.
.LP .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 .SH FILES
.nf .nf
/usr/[share/]man/whatis -- the whatis database /usr/[share/]man/whatis -- the whatis database

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: makewhatis.c,v 1.4 1998/03/29 07:16:01 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "makewhatis"; segment "makewhatis";
#endif
#include <sys/types.h> #include <sys/types.h>
#include <stdio.h> #include <stdio.h>
@ -13,15 +17,8 @@ segment "makewhatis";
#include <string.h> #include <string.h>
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#include "getopt.h" #include <gno/gno.h>
#include <libc.h> #include "man.h"
#include "makewhatis.h"
#ifdef STACK_CHECK
extern void begin_stack_check(void);
extern int end_stack_check(void);
#endif
/* /*
* Options: * 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. * 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 *output_fp;
FILE *error_fp; FILE *error_fp;
int main (int argc, char **argv) { int main (int argc, char **argv) {
static char tmp_file[L_tmpnam]; /* a scratch file */
char *manpath; /* the location of the man pages */ char *manpath; /* the location of the man pages */
char *path; /* the current path; taken from manpath */ char *path; /* the current path; taken from manpath */
char *p=NULL; /* a temporary pointer */ char *p=NULL; /* a temporary pointer */
struct dirent *file; /* the current file we have open */ 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 *tmp_fp; /* pointer to tmp_file */
FILE *whatis_fp; /* pointer to the current whatis database */ FILE *whatis_fp; /* pointer to the current whatis database */
DIR *subdir; /* the current man subdirectory -- eg: /usr/man/man3 */ DIR *subdir; /* the current man subdirectory -- eg: /usr/man/man3 */
@ -107,15 +102,13 @@ int main (int argc, char **argv) {
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
/* make sure Gno is running */ /* make sure GNO is running */
if (needsgno()==0) { if (needsgno()==0) {
fprintf(stderr,"Requires Gno/ME\n"); fprintf(stderr,"Requires GNO\n");
return 1; return 1;
} }
#ifdef STACK_CHECK __REPORT_STACK();
begin_stack_check();
#endif
/* /*
* set the defaults * set the defaults
@ -173,7 +166,7 @@ int main (int argc, char **argv) {
case 'V': case 'V':
fprintf(stderr, fprintf(stderr,
"%s --\n\tCreate the %s database.\n\tVersion %s by Devin Reade\n\n", "%s --\n\tCreate the %s database.\n\tVersion %s by Devin Reade\n\n",
argv[0],WHATIS,VERSIONSTRING); argv[0],WHATIS,VERSION_STR);
errflag++; errflag++;
break; break;
default: default:
@ -326,9 +319,5 @@ Aborted.\n",
if (output_fp != stdout) fclose(output_fp); if (output_fp != stdout) fclose(output_fp);
if (error_fp != stderr) fclose(error_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; return 0;
} }

View File

@ -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;

View File

@ -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"

View File

@ -3,10 +3,10 @@
.\" specifies the terms and conditions for redistribution. .\" specifies the terms and conditions for redistribution.
.\" .\"
.\" While this manual page is based on one from UCB, the included .\" While this manual page is based on one from UCB, the included
.\" C source, makefile, and executables are copyright (c) 1995 .\" C source, makefile, and executables are copyright (c) 1995-1998
.\" by Devin Reade <gdr@myrias.com>. All rights reserved. .\" 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 .SH NAME
man \- display reference manual pages; find reference pages by keyword man \- display reference manual pages; find reference pages by keyword
.SH SYNOPSIS .SH SYNOPSIS
@ -33,6 +33,10 @@ man \- display reference manual pages; find reference pages by keyword
.I filename .I filename
\&.\|.\|. \&.\|.\|.
.SH DESCRIPTION .SH DESCRIPTION
This manual page documents
.BR man
version 3.0.
.LP
.B man .B man
displays information from the reference manuals. displays information from the reference manuals.
It can display complete manual pages that you select by It can display complete manual pages that you select by
@ -511,7 +515,7 @@ and
preprocessors is not yet implemented. Since these preprocessors do preprocessors is not yet implemented. Since these preprocessors do
not as yet exist for GNO, this is not too much of a problem. not as yet exist for GNO, this is not too much of a problem.
.LP .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 .SH HISTORY
The GNO version of The GNO version of
.BR man .BR man

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: man.c,v 1.2 1998/03/29 07:16:07 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "man_______"; segment "man_______";
#endif
#include <stdio.h> #include <stdio.h>
#include <getopt.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <libc.h>
#include <ctype.h> #include <ctype.h>
#include <assert.h> #include <assert.h>
#include <sgtty.h> #include <sgtty.h>
#include <unistd.h> #include <unistd.h>
#include "util.h" #include <err.h>
#include <gno/gno.h>
#include "man.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 *macroPackage = "an"; /* default /usr/lib/tmac/tmac.an */
char *versionStr = "Version 3.0 by Devin Reade"; char *versionStr = VERSION_STR;
char *pager; char *pager;
char *troff; char *troff;
char *tcat; char *tcat;
@ -53,15 +51,12 @@ int main (int argc, char **argv) {
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
/* make sure Gno is running */ /* make sure GNO is running */
if (needsgno()==0) { if (needsgno()==0) {
fprintf(stderr,"Requires Gno/ME\n"); err(1, "Requires GNO");
return 1;
} }
#ifdef STACK_CHECK __REPORT_STACK();
begin_stack_check();
#endif
/* /*
* initialization * initialization
@ -86,7 +81,7 @@ int main (int argc, char **argv) {
break; break;
case 'M': case 'M':
M_flag++; M_flag++;
manpath = Xstrdup(optarg,__LINE__,__FILE__); manpath = LC_xstrdup(optarg);
break; break;
case 'n': case 'n':
n_flag++; n_flag++;
@ -145,10 +140,5 @@ int main (int argc, char **argv) {
} }
free(manpath); free(manpath);
result = ((result == 0) && (i == 0)) ? 0 : 1; result = ((result == 0) && (i == 0)) ? 0 : 1;
#ifdef STACK_CHECK
fprintf(stderr,"stack usage: %d bytes\n",end_stack_check());
#endif
return result; return result;
} }

View File

@ -1,17 +1,32 @@
/* /*
* 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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * 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 * Configuration info
*/ */
#define WHATIS "whatis" #define VERSION_STR "3.1"
#define PAGER "/bin/more"
#define SYSCMND "15/syscmnd"
/* 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 AROFF "aroff"
#define NROFF "nroff" #define NROFF "nroff"
#define TROFF "troff -t" #define TROFF "troff -t"
@ -22,6 +37,13 @@
#define TBL "tbl" #define TBL "tbl"
#define VGRIND "vgrind" #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 NON 0x00
#define TXT 0x04 #define TXT 0x04
#define BIN 0x06 #define BIN 0x06
@ -34,18 +56,24 @@
#define ORCA_K_MODE 5 #define ORCA_K_MODE 5
#define ORCA_W_MODE 6 #define ORCA_W_MODE 6
#define BUFFERSIZE 2048
typedef struct Section_tag { typedef struct Section {
char *name; /* section name */ char *name; /* section name */
char *suffix; /* directory suffix */ char *suffix; /* directory suffix */
} Section; } Section;
typedef struct { typedef struct compressionType {
char *suffix; char *suffix;
char *extractor; char *extractor;
} compressionType; } compressionType;
typedef struct fileType {
unsigned int type;
unsigned long int auxtype;
} fileType, *fileTypePtr;
fileType * getFileType (const char *file);
/* /*
* from globals.c * from globals.c
*/ */
@ -69,27 +97,19 @@ extern char *macroPackage;
extern short hyphen_flag; extern short hyphen_flag;
extern short n_flag; extern short n_flag;
extern short t_flag; extern short t_flag;
extern short v_flag;
/* LC_StringArray_t MakePathArray (char *path);
* from apropos2.c
*/
int apropos(int argc, char **argv, int whole_line); int apropos(int argc, char **argv, int whole_line);
void fillbuffer (char *filename);
/* char * getManpath (void);
* from whatis2.c 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 whatis(int argc, char **argv);
/*
* from man2.c
*/
int man (int argc, char *argv[]);
/*
* from common.c
*/
int getSuffixIndex(char *name);

10
usr.bin/man/man.rez Normal file
View File

@ -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"

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: man2.c,v 1.2 1998/03/29 07:16:12 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "man2______"; segment "man2______";
#pragma noroot
#endif
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -17,15 +22,16 @@ segment "man2______";
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <sgtty.h> #include <sgtty.h>
#include "util.h" #include <err.h>
#include <gno/contrib.h>
#include "man.h" #include "man.h"
#define MAX(a,b) ((a) > (b)) ? (a) : (b) #define MAX(a,b) ((a) > (b)) ? (a) : (b)
static char **buildManList(char *suffix, char *name); static LC_StringArray_t buildManList(char *suffix, char *name);
static LC_StringArray_t makePathArray(const char *manpath);
static void display(char *list); static void display(char *list);
static char *getBaseName (char *out, char *in); static char * getBaseName (char *out, char *in);
static void cleanManList(char **list);
/* /*
* Pre: argc is the number of strings in argv. It should either be 1 or 2. * 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[]) { int man(int argc, char *argv[]) {
char **manpath_array, **manpagelist; LC_StringArray_t manpath_array, manpagelist;
char *sec, *name, *current_path; char *sec, *name, *current_path;
Section *section; Section *section;
int i, j, k, abort; int i, j, k, abort;
@ -66,10 +72,10 @@ int man(int argc, char *argv[]) {
if (t_flag) { if (t_flag) {
if ((tcat = getenv("TCAT")) == NULL) { if ((tcat = getenv("TCAT")) == NULL) {
tcat = TCAT; tcat = TCAT;
} else tcat = Xstrdup(tcat,__LINE__,__FILE__); } else tcat = LC_xstrdup(tcat);
if ((troff = getenv("TROFF")) == NULL) { if ((troff = getenv("TROFF")) == NULL) {
troff = TROFF; troff = TROFF;
} else troff = Xstrdup(troff,__LINE__,__FILE__); } else troff = LC_xstrdup(troff);
} }
if (hyphen_flag) { if (hyphen_flag) {
pager = CAT; pager = CAT;
@ -86,13 +92,13 @@ int man(int argc, char *argv[]) {
case 2: case 2:
sec = argv[0]; sec = argv[0];
/* special case some section abbreviations */ /* special case some section abbreviations */
if (!strcmp(sec,"l")) { if (!strcasecmp(sec,"l")) {
sec = "local"; sec = "local";
} else if (!strcmp(sec,"n")) { } else if (!strcasecmp(sec,"n")) {
sec = "new"; sec = "new";
} else if (!strcmp(sec,"o")) { } else if (!strcasecmp(sec,"o")) {
sec = "old"; sec = "old";
} else if (!strcmp(sec,"p")) { } else if (!strcasecmp(sec,"p")) {
sec = "public"; sec = "public";
} }
name = argv[1]; name = argv[1];
@ -104,13 +110,15 @@ int man(int argc, char *argv[]) {
} }
/* create array of paths to search */ /* 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 * loop over all the paths in MANPATH
*/ */
i=0; i=0;
current_path = manpath_array[i]; current_path = (manpath_array->lc_vec)[i];
while (!abort && current_path) { while (!abort && current_path) {
dirbrk = (strchr(current_path,':')!=NULL) ? ':' : '/'; dirbrk = (strchr(current_path,':')!=NULL) ? ':' : '/';
@ -118,7 +126,7 @@ int man(int argc, char *argv[]) {
/* go to the current path in MANPATH */ /* go to the current path in MANPATH */
if (chdir(current_path) == -1) { if (chdir(current_path) == -1) {
i++; i++;
current_path = manpath_array[i]; current_path = (manpath_array->lc_vec)[i];
continue; continue;
} }
@ -129,9 +137,9 @@ int man(int argc, char *argv[]) {
* if section number was specified and this isn't it, do * if section number was specified and this isn't it, do
* the next loop * the next loop
*/ */
if (sec && (strcmp(sec,sections[j].name) || if (sec && (strcasecmp(sec,sections[j].name) ||
(!isdigit(*sec) && (!isdigit(*sec) &&
strncmp(sec,sections[j].name,strlen(sec))))) continue; strncasecmp(sec,sections[j].name,strlen(sec))))) continue;
section_found++; section_found++;
/* /*
@ -140,11 +148,11 @@ int man(int argc, char *argv[]) {
*/ */
manpagelist = buildManList(sections[j].suffix,name); manpagelist = buildManList(sections[j].suffix,name);
if (!manpagelist) continue; if (manpagelist->lc_used == 0) continue;
page_found++; page_found++;
for (k=0; !abort && manpagelist[k]; k++) { for (k=0; !abort && k < manpagelist->lc_used; k++) {
display(manpagelist[k]); display((manpagelist->lc_vec)[k]);
if (!hyphen_flag && !t_flag) { if (!hyphen_flag && !t_flag) {
fprintf(stderr, fprintf(stderr,
"type q to quit, or any other key for next man page: "); "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 */ } /* done looping over sections */
i++; i++;
current_path = manpath_array[i]; current_path = (manpath_array->lc_vec)[i];
} /* done looping over paths */ } /* done looping over paths */
@ -189,19 +197,20 @@ int man(int argc, char *argv[]) {
static const char *manstr="man"; static const char *manstr="man";
static const char *catstr="cat"; 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 buffer1[FILENAME_MAX];
static char buffer2[FILENAME_MAX]; static char buffer2[FILENAME_MAX];
DIR *directory; DIR *directory;
struct dirent *entry; struct dirent *entry;
char **list1, **list2, **list3; LC_StringArray_t list1, list2;
size_t len; size_t len;
int total1, total2, i, j, k; int i, j, k;
char *p, *fn; char *p, *fn, *L1, *L2;
/* initialization */ /* initialization */
list1 = list2 = list3 = NULL; list1 = LC_StringArrayNew();
total1 = total2 = 0; list2 = LC_StringArrayNew();
#ifdef DEBUG #ifdef DEBUG
/* sanity check on arguments */ /* sanity check on arguments */
@ -221,19 +230,19 @@ static char **buildManList(char *suffix, char *name) {
/* skip if no match */ /* skip if no match */
len = strlen(name); len = strlen(name);
if (strncmp(entry->d_name,name,len) || if (strncasecmp(entry->d_name,name,len) ||
(entry->d_name[len] != '.')) continue; (entry->d_name[len] != '.')) continue;
if (strlen(manstr) + strlen(suffix) + strlen(entry->d_name) + if (strlen(manstr) + strlen(suffix) + strlen(entry->d_name) +
strlen(suffix) + 1 >= FILENAME_MAX) { strlen(suffix) + 1 >= FILENAME_MAX) {
fprintf(stderr,"internal error: buffer overflow at line %d of %s\n", errx(1, "internal error: buffer overflow at line %s:%d\n",
__LINE__,__FILE__); __FILE__, __LINE__);
} }
sprintf(buffer1,"%s%s:%s",manstr,suffix,entry->d_name); sprintf(buffer1,"%s%s:%s",manstr,suffix,entry->d_name);
/* look for "links" to aroff files. (what a kludge) */ /* look for "links" to aroff files. (what a kludge) */
if ((buffer1[3] != 'l') && if ((buffer1[3] != 'l') &&
(strcmp(".l",&buffer1[strlen(buffer1)-2])==0)) { (strcasecmp(".l",&buffer1[strlen(buffer1)-2])==0)) {
FILE *linkptr; FILE *linkptr;
char *tp; char *tp;
@ -253,14 +262,12 @@ static char **buildManList(char *suffix, char *name) {
fclose(linkptr); fclose(linkptr);
if (access(buffer2,R_OK) == 0) { if (access(buffer2,R_OK) == 0) {
list1 = addToStringArray(list1, buffer2); LC_StringArrayAdd(list1, buffer2);
total1++;
} }
} }
} else { } else {
/* not a .l "link"; a normal file */ /* not a .l "link"; a normal file */
list1 = addToStringArray(list1, buffer1); LC_StringArrayAdd(list1, buffer1);
total1++;
} }
} }
closedir(directory); closedir(directory);
@ -277,7 +284,7 @@ static char **buildManList(char *suffix, char *name) {
/* skip if no match */ /* skip if no match */
len = strlen(name); len = strlen(name);
if (strncmp(entry->d_name,name,len) || if (strncasecmp(entry->d_name,name,len) ||
(entry->d_name[len] != '.')) continue; (entry->d_name[len] != '.')) continue;
if (strlen(catstr) + strlen(suffix) + strlen(entry->d_name) + if (strlen(catstr) + strlen(suffix) + strlen(entry->d_name) +
@ -286,8 +293,7 @@ static char **buildManList(char *suffix, char *name) {
__LINE__,__FILE__); __LINE__,__FILE__);
} }
sprintf(buffer1,"%s%s:%s",catstr,suffix,entry->d_name); sprintf(buffer1,"%s%s:%s",catstr,suffix,entry->d_name);
list2 = addToStringArray(list2, buffer1); LC_StringArrayAdd(list2, buffer1);
total2++;
} }
closedir(directory); closedir(directory);
} }
@ -297,40 +303,34 @@ static char **buildManList(char *suffix, char *name) {
* eliminate files common to both lists * eliminate files common to both lists
*/ */
len = strlen(suffix); len = strlen(suffix);
for(i=0; i<total1; i++) { for(i=0; i< list1->lc_used; i++) {
if (list1[i] == NULL) continue; L1 = (list1->lc_vec)[i];
for (j=0; j<total2; j++) { for (j=0; j< list2->lc_used; j++) {
if (list2[j] == NULL) continue; L2 = (list2->lc_vec)[j];
getBaseName(buffer1,list1[i]); getBaseName(buffer1, L1);
getBaseName(buffer2,list2[j]); getBaseName(buffer2, L2);
#ifdef DEBUG #ifdef DEBUG
if ((strlen(buffer1) < len + 5) || if ((strlen(buffer1) < len + 5) ||
(strlen(buffer2) < len + 5)) { (strlen(buffer2) < len + 5)) {
fprintf(stderr,"internal error at line %d of %s\n",__LINE__, err(1, "internal error at line %d of %s\n", __LINE__, __FILE__);
__FILE__);
exit(1);
} }
#endif #endif
/* match after the respective "manXX/" and "catXX/" */ /* 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]); p = newerFile(L1,L2);
if (p == list1[i]) { if (p == L1) {
free(list2[j]); LC_StringArrayDelete(list2, L2);
list2[j] = NULL; --j;
} else if (p == list2[j]) { } else if (p == (list2->lc_vec)[j]) {
free(list1[i]); LC_StringArrayDelete(list1, L1);
list1[i] = NULL; --i;
break; break;
} else { } else {
fprintf(stderr,"internal error at line %d of %s\n\t%s\n\t%s\n", err(1, "internal error at %s:%d (newerFile failed)",
__LINE__,__FILE__, __FILE__, __LINE__);
(list1[i]) ? list1[i] : "(NULL)",
(list2[j]) ? list2[j] : "(NULL)");
perror("newerFile failed");
exit(1);
} }
} /* endif */ } /* endif */
} /* endfor */ } /* endfor */
@ -339,41 +339,12 @@ static char **buildManList(char *suffix, char *name) {
/* /*
* combine the two lists * combine the two lists
*/ */
for (i=0;i<total1;i++) { j = list2->lc_used;
if (list1[i] != NULL) { for (i=0; i<j; i++) {
list3 = addToStringArray(list3, list1[i]); LC_StringArrayAdd(list1, (list2->lc_vec)[i]);
free(list1[i]);
} }
} LC_StringArrayDestroy(list2);
for (j=0;j<total2;j++) { return list1;
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;
} }
/* /*
@ -409,7 +380,7 @@ static void display(char *file) {
/* /*
* determine which subdirectory this file is in * determine which subdirectory this file is in
*/ */
if (strncmp(file,"cat",3) == 0) { if (strncasecmp(file,"cat",3) == 0) {
isubdir = CATSUBDIR; isubdir = CATSUBDIR;
} else { } else {
isubdir = MANSUBDIR; isubdir = MANSUBDIR;
@ -587,7 +558,7 @@ static void display(char *file) {
* that may be on the base name. The set of compression * that may be on the base name. The set of compression
* suffixes is defined by the NULL-terminated compressArray[]. * 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 * buffer *out has been allocated with sufficient space
* for the result. * for the result.
* *
@ -601,7 +572,7 @@ static char *getBaseName (char *out, char *in) {
strcpy(out,in); strcpy(out,in);
if ((p = strrchr(out,'.')) != NULL) { if ((p = strrchr(out,'.')) != NULL) {
for (i=0; compressArray[i].suffix; i++) { for (i=0; compressArray[i].suffix; i++) {
if (strcmp(p,compressArray[i].suffix)==0) { if (strcasecmp(p,compressArray[i].suffix)==0) {
*p = '\0'; *p = '\0';
break; break;
} }
@ -609,3 +580,27 @@ static char *getBaseName (char *out, char *in) {
} }
return out; 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;
}

49
usr.bin/man/manpack.desc Normal file
View File

@ -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.

8
usr.bin/man/mkso.data Normal file
View File

@ -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

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: process.c,v 1.4 1998/03/29 07:16:17 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "makewhatis"; segment "makewhatis";
#pragma noroot
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -13,8 +18,8 @@ segment "makewhatis";
#include <stdlib.h> #include <stdlib.h>
#include <gsos.h> #include <gsos.h>
#include <orca.h> #include <orca.h>
#include <gno/contrib.h>
#include "makewhatis.h" #include "man.h"
/* These are the compression types */ /* These are the compression types */
#define NO_COMPRESS 0 #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 */ char *name; /* points to the file basename */
short compression; /* the compression type (if nec) */ 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 * get the file basename

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: util.c,v 1.2 1998/03/29 07:16:19 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "util______"; segment "util______";
#pragma noroot
#endif
#define __USE_DYNAMIC_GSSTRING__
#include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> #include <types.h>
#include <string.h> #include <gsos.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <ctype.h> #include <ctype.h>
#include <string.h>
#include <sgtty.h> #include <sgtty.h>
#include <fcntl.h> #include <unistd.h>
#include "util.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 * 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 = getenv("MANDIR");
if (manpath == NULL) manpath = DEFAULT_MANPATH; if (manpath == NULL) manpath = DEFAULT_MANPATH;
return Xstrdup(manpath,__LINE__,__FILE__); return LC_xstrdup(manpath);
}
/*
* 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);
} }
/*
* 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. * MakePathArray -- parse a path list and break it into a StringArray_t.
* If oldArray is NULL, then a new array is created, * The original path is left unchanged.
* 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.
* *
* The delimiter between paths may either be a ' ' or a ':'. * The delimiter between paths may either be a ' ' or a ':'.
* The delimiter is assumed to be a ':' if <path> contains * The delimiter is assumed to be a ':' if <path> contains
@ -181,12 +57,13 @@ char **addToStringArray(char **oldArray, char *string) {
* otherwise the delimiter is assumed to be a ' '. * otherwise the delimiter is assumed to be a ' '.
*/ */
char **makePathArray(char *path) { LC_StringArray_t
MakePathArray(char *path) {
char *delim, *p, *q, **result; LC_StringArray_t result;
char *delim, *p, *q;
/* set the delimiter */ /* set the delimiter */
if ( strchr(path,' ')==NULL && if ((strchr(path,' ')==NULL) &&
strchr(path,':') && strchr(path,':') &&
strchr(path,'/')) { strchr(path,'/')) {
delim = ":"; delim = ":";
@ -195,56 +72,27 @@ char **makePathArray(char *path) {
} }
/* build the array */ /* build the array */
p = Xstrdup(path, __LINE__, __FILE__); #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); q = strtok(p,delim);
result = NULL; while (q != NULL) {
while (q) { LC_StringArrayAdd(result, q);
result = addToStringArray(result, q);
q = strtok(NULL,delim); q = strtok(NULL,delim);
} }
#ifndef __ORCAC__
free(p); free(p);
#endif
return result; return result;
} }
/* /*
* ncstrcmp -- A case insensitive ("no-case") strcmp * strcasestr -- A case insensitive ("no-case") strstr
*/
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);
}
/*
* 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
* *
* This is implemented using a convert-copy-to-single-case- * This is implemented using a convert-copy-to-single-case-
* then-strstr hack. * 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. * 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; char *strCopy, *substrCopy, *p;
strCopy = Xstrdup(str,__LINE__,__FILE__); strCopy = LC_xstrdup(str);
substrCopy = Xstrdup(substr,__LINE__,__FILE__); substrCopy = LC_xstrdup(substr);
/* convert the strings */ /* convert the strings */
p = strCopy; p = strCopy;
@ -288,36 +137,49 @@ char *ncstrstr(char *str, char *substr) {
* is an error. * is an error.
*/ */
char *newerFile(char *path1, char *path2) { char *
static struct stat record1, record2; newerFile(char *path1, char *path2) {
int i,j;
/* static struct stat sbuf1, sbuf2;
* see if both, only one, or neither files exist int e1, e2;
*/
i = access(path1, F_OK); /* stat the first file */
j = access(path2, F_OK); if (stat(path1, &sbuf1) < 0) {
if (i==-1 && j==-1) { if (errno == ENOENT) {
errno = ENOENT; e1 = ENOENT;
} else {
return NULL; return NULL;
} else if (i==-1) { }
} else {
e1 = 0;
}
/* stat the second file */
if (stat(path2, &sbuf2) < 0) {
if (errno == ENOENT) {
e2 = ENOENT;
} else {
return NULL;
}
} else {
e2 = 0;
}
/* one or both don't exist? */
if (e1 && e2) {
return NULL;
}
if (e1) {
return path2; return path2;
} else if (j==-1) { }
if (e2) {
return path1; return path1;
} }
/* /* both exist */
* both files exist; stat them return (sbuf1.st_mtime > sbuf2.st_mtime) ? path1 : path2;
*/
if (stat(path1,&record1) != 0) return NULL;
if (stat(path2,&record2) != 0) return NULL;
return (record1.st_mtime > record2.st_mtime) ? path1 : path2;
} }
/* /*
* getcharraw() - return the next character from stdin without waiting * getcharraw() - return the next character from stdin without waiting
* for a CR to be hit. Returns '\0' and sets errno * for a CR to be hit. Returns '\0' and sets errno
@ -326,7 +188,8 @@ char *newerFile(char *path1, char *path2) {
#define FAILED_CHAR '\0'; #define FAILED_CHAR '\0';
char getcharraw(void) { char
getcharraw(void) {
short oldmode; short oldmode;
struct sgttyb s; struct sgttyb s;
int count; int count;
@ -348,39 +211,37 @@ char getcharraw(void) {
} }
/* /*
* basename -- return a pointer to the base filename (all leading * getFileType -- Get the file type and auxillary file type of a file.
* pathname components removed) of <path>. <path> _must_ * On success it returns a pointer to an internal buffer
* point to a NULL-terminated string. * containing the file type and aux type. On failure
* it returns NULL and sets errno.
*/ */
char *basename (char *path) { fileType *getFileType (char *file) {
char *p, dirsep;
dirsep = (strchr(path,':')) ? ':' : '/'; static FileInfoRecGS record;
if ((p = strrchr(path,dirsep)) != NULL) { static fileType result;
return p+1; int i;
} else {
return path; /* set the parameters */
record.pCount = 4;
if ((record.pathname = __C2GSMALLOC(file)) == NULL) {
return NULL;
} }
}
/* get the info */
/* GetFileInfoGS(&record);
* dirname -- return a pointer to a string consisting of the directory i = _toolErr;
* component of <path>. This returns a pointer to an internal GIfree(record.pathname);
* buffer, so the next call to dirname() will overwrite this if (i) {
* buffer. <path> must be a NULL-terminated string. errno = _mapErr(i);
*/ return NULL;
}
char *dirname (const char *path) {
static char buffer[FILENAME_MAX]; /* set the return value */
char *p, dirsep; result.type = record.fileType;
result.auxtype = record.auxType;
strcpy(buffer,path);
return &result;
dirsep = (strchr(buffer,':')) ? ':' : '/';
if ((p = strrchr(buffer,dirsep)) != NULL) {
*p = '\0';
}
return buffer;
} }

View File

@ -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);

View 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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*/ */
@ -17,8 +17,10 @@ segment "utilgs____";
extern GSString255Ptr __C2GSMALLOC(char *); extern GSString255Ptr __C2GSMALLOC(char *);
extern int _mapErr(int); 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. * 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 * 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 * Returns -1 and sets errno on failure, instead of always
* returning zero. * returning zero.
*/ */
@ -92,6 +94,7 @@ int chdir (const char *pathname) {
return 0; return 0;
} }
#endif /* 0 */
/* /*
* getFileType -- Get the file type and auxillary file type of a file. * getFileType -- Get the file type and auxillary file type of a file.

View File

@ -4,10 +4,10 @@
.\" specifies the terms and conditions for redistribution. .\" specifies the terms and conditions for redistribution.
.\" .\"
.\" While this manual page is based on one from UCB, the included .\" While this manual page is based on one from UCB, the included
.\" C source, makefile, and executables are copyright (c) 1995 .\" C source, makefile, and executables are copyright (c) 1995-1998
.\" by Devin Reade <gdr@myrias.com>. All rights reserved. .\" 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 .SH NAME
whatis, apropos \- locate commands by name or keyword lookup whatis, apropos \- locate commands by name or keyword lookup
.SH SYNOPSIS .SH SYNOPSIS
@ -39,8 +39,7 @@ while
shows which manual pages contain instances of any of the given shows which manual pages contain instances of any of the given
.IR keyword (s) .IR keyword (s)
in their title line. in their title line.
Each word is considered separately and, for Each word is considered separately and, for the GNO implementation,
.BR apropos ,
the case of letters is ignored. the case of letters is ignored.
Words which are part of other words are considered; when looking for Words which are part of other words are considered; when looking for
.IR compile , .IR compile ,
@ -55,6 +54,8 @@ If a line output by either of these commands starts with
.fi .fi
you can enter you can enter
.BI man name
or
.BI man " section name" .BI man " section name"
to get its documentation. to get its documentation.
.SH OPTIONS .SH OPTIONS
@ -167,14 +168,18 @@ flag, in turn, overrides this value.)
See the description of the See the description of the
.B \-M .B \-M
flag for syntax details. flag for syntax details.
.SH VERSION
This manual page documents
.BR apropos
and
.BR whatis
versions 3.1.
.SH FILES .SH FILES
.\" .IP \fB/usr/\fR[\fBshare/\fR]\fBman/whatis\fR .\" .IP \fB/usr/\fR[\fBshare/\fR]\fBman/whatis\fR
.BR /usr/ [ share/ ] man/whatis " \-" .BR /usr/ [ share/ ] man/whatis " \-"
The The
.BR whatis (1) .BR whatis (1)
database. database.
.SH BUGS
Please report any bugs to Devin Reade, <gdr@myrias.ab.ca>.
.SH SEE ALSO .SH SEE ALSO
.BR man (1), .BR man (1),
.BR whereis (1), .BR whereis (1),

View File

@ -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, * information see the README file that is part of the manpack archive,
* or contact the author, above. * or contact the author, above.
*
* $Id: whatis.c,v 1.2 1998/03/29 07:16:24 gdr-ftp Exp $
*/ */
#ifdef __ORCAC__
segment "apropos___"; segment "apropos___";
#endif
#include <stdio.h> #include <stdio.h>
#include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
#include <libc.h> #include <unistd.h>
#include "util.h" #include <gno/gno.h>
#include "man.h" #include "man.h"
extern int optind; extern int optind;
extern char *optarg; extern char *optarg;
static char *versionstr = "3.0"; static char *versionstr = VERSION_STR;
static char *nothing = "nothing appropriate"; static char *nothing = "nothing appropriate";
extern void begin_stack_check(void);
extern int end_stack_check(void);
int main (int argc, char **argv) { int main (int argc, char **argv) {
char *path; char *path;
int i, matches1, matches2, matches3; int i, matches1, matches2, matches3;
short V_flag, M_flag, m_flag, n_flag, err_flag; short V_flag, M_flag, m_flag, n_flag, err_flag;
/* make sure Gno is running */ /* make sure GNO is running */
if (needsgno()==0) { if (needsgno()==0) {
fprintf(stderr,"Requires Gno/ME\n"); fprintf(stderr,"Requires GNO\n");
return 1; return 1;
} }
#ifdef STACK_CHECK __REPORT_STACK();
begin_stack_check();
#endif
/* initialization */ /* initialization */
V_flag = M_flag = m_flag = n_flag = err_flag = 0; 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); 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; if ((matches1>=0) && (matches2>=0) && (matches3>=0) && i>0) return 0;
return 1; return 1;
} }

10
usr.bin/man/whatis.rez Normal file
View File

@ -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"