*BSD News Article 7620


Return to BSD News archive

Path: sserve!manuel.anu.edu.au!munnari.oz.au!goanna!escargot!minyos.xx.rmit.oz.au!s902113
From: s902113@minyos.xx.rmit.oz.au (Luke Mewburn)
Newsgroups: comp.unix.bsd
Subject: Re: ->386bsd! man-pages.Z ?
Message-ID: <1dr6fkINN95s@escargot.xx.rmit.OZ.AU>
Date: 11 Nov 92 14:48:20 GMT
References: <1992Nov11.053352.29060@utkux1.utk.edu>
Organization: RMIT Computer Centre
Lines: 237
NNTP-Posting-Host: minyos.xx.rmit.oz.au

frank@martha.utcc.utk.edu (frank segner (phrank)) writes:

>hi folks !

>recently i made a du (-k) /usr/share/man...   (just about 4 Mb ascii... ;-( )
>that reminded me of the time i ran isc, there it was !better! (manpage.0.Z)
>my 'zcat whatever.Z |less' would be fast enough...
>does someone have an idea where to find a decent replacement for the 
>original man?
>if so -> let me know ; flames -> /dev/null ;-]
>so long

As an experiment, I hacked the man sources to do this. Unfortunately,
my hack is not the best, and can die when you do man -a intro (or
something with lots of manuals - I since found out that the normal
man command does the same thing - there is a patch available for this
latter bug but my hack doesn't include it.) I can post my diffs to the
net.
(Note, I admit my way is a kludge, but it works, albiet a little
slowly - you have to wait whilst it temporarily uncompresses _all_
manuals you ask for, cause I didn't hack the way it built up the list
of files to display)

PS: I just noticed - the diffs add some printfs I had as a leftover
from debugging... They can be easily found after you apply the patch -
just look for a printf() in col 0:)

-- diffs --
*** orig.man.c	Tue Aug 18 01:40:10 1992
--- man.c	Tue Aug 18 01:57:58 1992
***************
*** 48,53 ****
--- 48,54 ----
  #include <ctype.h>
  #include <string.h>
  #include <stdlib.h>
+ #include <unistd.h>
  #include "pathnames.h"
  
  extern int errno;
***************
*** 56,61 ****
--- 57,69 ----
  char *command, *machine, *p_augment, *p_path, *pager, *progname;
  extern char **arorder, *pathbuf;
  
+ #ifdef COMPRESSED
+ #define ZAKERREXIT	 { perror("man"); exit(1); }
+ 
+ char **tmpfilelist, tmpfilename[MAXPATHLEN + 1];
+ int tmpfilecnt,tmpindexpos;
+ #endif /* COMPRESSED */
+ 
  main(argc, argv)
  	int argc;
  	register char **argv;
***************
*** 64,71 ****
--- 72,90 ----
  	extern int optind;
  	int ch, res;
  	char *section[2], *check_pager(), *getpath(), **getorder(), *tmp;
+ #ifdef COMPRESSED
+ 	void cleanup();
+ 
+ 	tmpfilecnt=0;
+ 	if (( tmpfilelist=calloc(argc,sizeof(char *))) == NULL)
+ 		ZAKERREXIT
+ 	atexit(cleanup);
+ 	(void) tmpnam(tmpfilename);
+ 	tmpindexpos=strlen(tmpfilename);
+ #endif /* COMPRESSED */
  
  	progname = "man";
+ 
  	while ((ch = getopt(argc, argv, "-acfhkM:m:P:w")) != EOF)
  		switch((char)ch) {
  		case 'a':
***************
*** 146,151 ****
--- 165,171 ----
  	}
  
  	for (; *argv; ++argv) {
+ printf("argv is :%s:\n",*argv);
  		if (p_augment)
  			res = manual(p_augment, *argv);
  		res = manual(p_path, *argv);
***************
*** 156,161 ****
--- 176,190 ----
  		exit(1);
  	}
  
+ #ifdef COMPRESSED
+ printf("command is :%s:\n",command);
+ 	/* wait for uncompressing children */
+ 	while ((res = wait(NULL)) != -1)
+ printf("child %d finished.\n",res);
+ 	if (errno != ECHILD)
+ 		ZAKERREXIT
+ #endif
+ 
  	/* use system(3) in case someone's pager is "pager arg1 arg2" */
  	if (command)
  		(void)system(command);
***************
*** 175,180 ****
--- 204,214 ----
  	register char *end;
  	char fname[MAXPATHLEN + 1];
  
+ #ifdef COMPRESSED
+ 	register int is_compressed,pid;
+ 	char zcatpath[MAXPATHLEN + 1];
+ #endif /* COMPRESSED */
+ 
  	for (res = 0;; path = end + 1) {
  		if (!*path)				/* foo: */
  			break;
***************
*** 183,203 ****
  				continue;
  			*end = '\0';
  		}
  		(void)sprintf(fname, "%s/%s.0", path, name);
  		if (access(fname, R_OK)) {
  			(void)sprintf(fname, "%s/%s/%s.0", path, machine, name);
  			if (access(fname, R_OK))
  				continue;
  		}
  
  		if (f_where)
  			(void)printf("man: found in %s.\n", fname);
! 		else if (f_cat)
  			cat(fname);
  		else if (f_how)
  			how(fname);
  		else
  			add(fname);
  		if (!f_all)
  			return(1);
  		res = 1;
--- 217,276 ----
  				continue;
  			*end = '\0';
  		}
+ #ifdef COMPRESSED
+ 		is_compressed=0;
+ #endif /* COMPRESSED */
  		(void)sprintf(fname, "%s/%s.0", path, name);
  		if (access(fname, R_OK)) {
  			(void)sprintf(fname, "%s/%s/%s.0", path, machine, name);
  			if (access(fname, R_OK))
+ #ifdef COMPRESSED
+ 			{
+ 				(void)sprintf(fname, "%s/%s.0.Z", path, name);
+ 				if (access(fname, R_OK)) {
+ 					(void)sprintf(fname, "%s/%s/%s.0.Z", path, machine, name);
+ 					if (access(fname, R_OK))
+ 						continue;
+ 				}
+ 			}
+ 			is_compressed++;
+ #else
  				continue;
+ #endif /* COMPRESSED */
  		}
  
  		if (f_where)
  			(void)printf("man: found in %s.\n", fname);
! 		else
! #ifdef COMPRESSED
! 		{
! 			if (is_compressed)
! 			{
! 				sprintf(tmpfilename+tmpindexpos,"%.2d",tmpfilecnt);
! 				(void)fprintf(stderr,"Uncompressing %s to %s.\n",fname,tmpfilename);
! 				sprintf(zcatpath,"%s %s > %s",_PATH_ZCAT,fname,tmpfilename);
! 				if ((pid=fork()) == -1)
! 					ZAKERREXIT
! 				if (pid == 0)
! 				{
! printf("child is %d.\n",getpid());
! 					if (system(zcatpath))
! 						ZAKERREXIT
! 					_exit(0);
! 				}
! 				tmpfilelist[tmpfilecnt++] = strdup(tmpfilename);
! 				strcpy(fname, tmpfilename);
! 			}
! #endif /* COMPRESSED */
! 		     if (f_cat)
  			cat(fname);
  		else if (f_how)
  			how(fname);
  		else
  			add(fname);
+ #ifdef COMPRESSED
+ 		}	/* end the brace from elseif (f_cat). */
+ #endif /* COMPRESSED */
  		if (!f_all)
  			return(1);
  		res = 1;
***************
*** 370,372 ****
--- 443,462 ----
  	    "usage: man [-ac] [-M path] [-m path] [section] title ...\n");
  	exit(1);
  }
+ 
+ #ifdef COMPRESSED
+ void cleanup()
+ {
+ 	int lp;
+ 	for (lp=0;lp<tmpfilecnt;lp++)
+ 	{
+ 		if (tmpfilelist[lp] != NULL)
+ 		{
+ 			unlink(tmpfilelist[lp]);
+ 			if ((errno) && (errno != ENOENT))
+ 				perror("man");
+ 		}
+ 	}
+ 	_exit(0);	/* for when used in sig handlers... */
+ }
+ #endif /* COMPRESSED */

>         frank
>--
>frank@martha.utk.edu                  please don't spit on the floor ?!

--
                         Luke Mewburn [Zak]
           s902113@minyos.xx.rmit.oz.au   zak@rmit.edu.au
   "Nobody dies on the Discworld, they just become dimensionally
    disadvantaged."         Terry Pratchett in alt.fan.pratchett