home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / bsd / 8743 < prev    next >
Encoding:
Text File  |  1992-11-11  |  6.3 KB  |  249 lines

  1. Path: sparky!uunet!munnari.oz.au!goanna!escargot!minyos.xx.rmit.oz.au!s902113
  2. From: s902113@minyos.xx.rmit.oz.au (Luke Mewburn)
  3. Newsgroups: comp.unix.bsd
  4. Subject: Re: ->386bsd! man-pages.Z ?
  5. Message-ID: <1dr6fkINN95s@escargot.xx.rmit.OZ.AU>
  6. Date: 11 Nov 92 14:48:20 GMT
  7. References: <1992Nov11.053352.29060@utkux1.utk.edu>
  8. Organization: RMIT Computer Centre
  9. Lines: 237
  10. NNTP-Posting-Host: minyos.xx.rmit.oz.au
  11.  
  12. frank@martha.utcc.utk.edu (frank segner (phrank)) writes:
  13.  
  14. >hi folks !
  15.  
  16. >recently i made a du (-k) /usr/share/man...   (just about 4 Mb ascii... ;-( )
  17. >that reminded me of the time i ran isc, there it was !better! (manpage.0.Z)
  18. >my 'zcat whatever.Z |less' would be fast enough...
  19. >does someone have an idea where to find a decent replacement for the 
  20. >original man?
  21. >if so -> let me know ; flames -> /dev/null ;-]
  22. >so long
  23.  
  24. As an experiment, I hacked the man sources to do this. Unfortunately,
  25. my hack is not the best, and can die when you do man -a intro (or
  26. something with lots of manuals - I since found out that the normal
  27. man command does the same thing - there is a patch available for this
  28. latter bug but my hack doesn't include it.) I can post my diffs to the
  29. net.
  30. (Note, I admit my way is a kludge, but it works, albiet a little
  31. slowly - you have to wait whilst it temporarily uncompresses _all_
  32. manuals you ask for, cause I didn't hack the way it built up the list
  33. of files to display)
  34.  
  35. PS: I just noticed - the diffs add some printfs I had as a leftover
  36. from debugging... They can be easily found after you apply the patch -
  37. just look for a printf() in col 0:)
  38.  
  39. -- diffs --
  40. *** orig.man.c    Tue Aug 18 01:40:10 1992
  41. --- man.c    Tue Aug 18 01:57:58 1992
  42. ***************
  43. *** 48,53 ****
  44. --- 48,54 ----
  45.   #include <ctype.h>
  46.   #include <string.h>
  47.   #include <stdlib.h>
  48. + #include <unistd.h>
  49.   #include "pathnames.h"
  50.   
  51.   extern int errno;
  52. ***************
  53. *** 56,61 ****
  54. --- 57,69 ----
  55.   char *command, *machine, *p_augment, *p_path, *pager, *progname;
  56.   extern char **arorder, *pathbuf;
  57.   
  58. + #ifdef COMPRESSED
  59. + #define ZAKERREXIT     { perror("man"); exit(1); }
  60. + char **tmpfilelist, tmpfilename[MAXPATHLEN + 1];
  61. + int tmpfilecnt,tmpindexpos;
  62. + #endif /* COMPRESSED */
  63.   main(argc, argv)
  64.       int argc;
  65.       register char **argv;
  66. ***************
  67. *** 64,71 ****
  68. --- 72,90 ----
  69.       extern int optind;
  70.       int ch, res;
  71.       char *section[2], *check_pager(), *getpath(), **getorder(), *tmp;
  72. + #ifdef COMPRESSED
  73. +     void cleanup();
  74. +     tmpfilecnt=0;
  75. +     if (( tmpfilelist=calloc(argc,sizeof(char *))) == NULL)
  76. +         ZAKERREXIT
  77. +     atexit(cleanup);
  78. +     (void) tmpnam(tmpfilename);
  79. +     tmpindexpos=strlen(tmpfilename);
  80. + #endif /* COMPRESSED */
  81.   
  82.       progname = "man";
  83.       while ((ch = getopt(argc, argv, "-acfhkM:m:P:w")) != EOF)
  84.           switch((char)ch) {
  85.           case 'a':
  86. ***************
  87. *** 146,151 ****
  88. --- 165,171 ----
  89.       }
  90.   
  91.       for (; *argv; ++argv) {
  92. + printf("argv is :%s:\n",*argv);
  93.           if (p_augment)
  94.               res = manual(p_augment, *argv);
  95.           res = manual(p_path, *argv);
  96. ***************
  97. *** 156,161 ****
  98. --- 176,190 ----
  99.           exit(1);
  100.       }
  101.   
  102. + #ifdef COMPRESSED
  103. + printf("command is :%s:\n",command);
  104. +     /* wait for uncompressing children */
  105. +     while ((res = wait(NULL)) != -1)
  106. + printf("child %d finished.\n",res);
  107. +     if (errno != ECHILD)
  108. +         ZAKERREXIT
  109. + #endif
  110.       /* use system(3) in case someone's pager is "pager arg1 arg2" */
  111.       if (command)
  112.           (void)system(command);
  113. ***************
  114. *** 175,180 ****
  115. --- 204,214 ----
  116.       register char *end;
  117.       char fname[MAXPATHLEN + 1];
  118.   
  119. + #ifdef COMPRESSED
  120. +     register int is_compressed,pid;
  121. +     char zcatpath[MAXPATHLEN + 1];
  122. + #endif /* COMPRESSED */
  123.       for (res = 0;; path = end + 1) {
  124.           if (!*path)                /* foo: */
  125.               break;
  126. ***************
  127. *** 183,203 ****
  128.                   continue;
  129.               *end = '\0';
  130.           }
  131.           (void)sprintf(fname, "%s/%s.0", path, name);
  132.           if (access(fname, R_OK)) {
  133.               (void)sprintf(fname, "%s/%s/%s.0", path, machine, name);
  134.               if (access(fname, R_OK))
  135.                   continue;
  136.           }
  137.   
  138.           if (f_where)
  139.               (void)printf("man: found in %s.\n", fname);
  140. !         else if (f_cat)
  141.               cat(fname);
  142.           else if (f_how)
  143.               how(fname);
  144.           else
  145.               add(fname);
  146.           if (!f_all)
  147.               return(1);
  148.           res = 1;
  149. --- 217,276 ----
  150.                   continue;
  151.               *end = '\0';
  152.           }
  153. + #ifdef COMPRESSED
  154. +         is_compressed=0;
  155. + #endif /* COMPRESSED */
  156.           (void)sprintf(fname, "%s/%s.0", path, name);
  157.           if (access(fname, R_OK)) {
  158.               (void)sprintf(fname, "%s/%s/%s.0", path, machine, name);
  159.               if (access(fname, R_OK))
  160. + #ifdef COMPRESSED
  161. +             {
  162. +                 (void)sprintf(fname, "%s/%s.0.Z", path, name);
  163. +                 if (access(fname, R_OK)) {
  164. +                     (void)sprintf(fname, "%s/%s/%s.0.Z", path, machine, name);
  165. +                     if (access(fname, R_OK))
  166. +                         continue;
  167. +                 }
  168. +             }
  169. +             is_compressed++;
  170. + #else
  171.                   continue;
  172. + #endif /* COMPRESSED */
  173.           }
  174.   
  175.           if (f_where)
  176.               (void)printf("man: found in %s.\n", fname);
  177. !         else
  178. ! #ifdef COMPRESSED
  179. !         {
  180. !             if (is_compressed)
  181. !             {
  182. !                 sprintf(tmpfilename+tmpindexpos,"%.2d",tmpfilecnt);
  183. !                 (void)fprintf(stderr,"Uncompressing %s to %s.\n",fname,tmpfilename);
  184. !                 sprintf(zcatpath,"%s %s > %s",_PATH_ZCAT,fname,tmpfilename);
  185. !                 if ((pid=fork()) == -1)
  186. !                     ZAKERREXIT
  187. !                 if (pid == 0)
  188. !                 {
  189. ! printf("child is %d.\n",getpid());
  190. !                     if (system(zcatpath))
  191. !                         ZAKERREXIT
  192. !                     _exit(0);
  193. !                 }
  194. !                 tmpfilelist[tmpfilecnt++] = strdup(tmpfilename);
  195. !                 strcpy(fname, tmpfilename);
  196. !             }
  197. ! #endif /* COMPRESSED */
  198. !              if (f_cat)
  199.               cat(fname);
  200.           else if (f_how)
  201.               how(fname);
  202.           else
  203.               add(fname);
  204. + #ifdef COMPRESSED
  205. +         }    /* end the brace from elseif (f_cat). */
  206. + #endif /* COMPRESSED */
  207.           if (!f_all)
  208.               return(1);
  209.           res = 1;
  210. ***************
  211. *** 370,372 ****
  212. --- 443,462 ----
  213.           "usage: man [-ac] [-M path] [-m path] [section] title ...\n");
  214.       exit(1);
  215.   }
  216. + #ifdef COMPRESSED
  217. + void cleanup()
  218. + {
  219. +     int lp;
  220. +     for (lp=0;lp<tmpfilecnt;lp++)
  221. +     {
  222. +         if (tmpfilelist[lp] != NULL)
  223. +         {
  224. +             unlink(tmpfilelist[lp]);
  225. +             if ((errno) && (errno != ENOENT))
  226. +                 perror("man");
  227. +         }
  228. +     }
  229. +     _exit(0);    /* for when used in sig handlers... */
  230. + }
  231. + #endif /* COMPRESSED */
  232.  
  233. >         frank
  234. >--
  235. >frank@martha.utk.edu                  please don't spit on the floor ?!
  236.  
  237. --
  238.                          Luke Mewburn [Zak]
  239.            s902113@minyos.xx.rmit.oz.au   zak@rmit.edu.au
  240.    "Nobody dies on the Discworld, they just become dimensionally
  241.     disadvantaged."         Terry Pratchett in alt.fan.pratchett
  242.