home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume02 / ncmprss / part01 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  53.6 KB

  1. From: Peter Jannesen <peter@ncs.nl>
  2. Subject: v02i025: ncompress - (Ver. 4.2.3) an improved file compressor, Part01/02
  3. Newsgroups: comp.sources.reviewed
  4. Approved: csr@calvin.dgbt.doc.ca
  5.  
  6. Submitted-by: Peter Jannesen <peter@ncs.nl>
  7. Posting-number: Volume 2, Issue 25
  8. Archive-name: ncompress/part01
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 1 (of 2)."
  17. # Contents:  Acknowleds Changes LZW.INFO MANIFEST Makefile.def README
  18. #   build compress.1 patchlevel.h zcmp zcmp.1 zdiff zmore zmore.1
  19. # Wrapped by csr@calvin.dgbt.doc.ca on Wed Aug  5 18:27:11 1992
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'Acknowleds' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'Acknowleds'\"
  23. else
  24. echo shar: Extracting \"'Acknowleds'\" \(685 characters\)
  25. sed "s/^X//" >'Acknowleds' <<'END_OF_FILE'
  26. XAcknowledgments:
  27. X
  28. X(N)compress, Version 4.2
  29. X
  30. XThanks to the previous authors whom I didn't contact, for making
  31. Xthe program available originally.
  32. X   Spencer W. Thomas   (decvax!harpo!utah-cs!utah-gr!thomas)
  33. X   Jim McKie           (decvax!mcvax!jim)
  34. X   Steve Davies        (decvax!vax135!petsd!peora!srd)
  35. X   Ken Turkowski       (decvax!decwrl!turtlevax!ken)
  36. X   James A. Woods      (decvax!ihnp4!ames!jaw)
  37. X   Joe Orost           (decvax!vax135!petsd!joe)
  38. X   Dave Mack           (csu@alembic.acs.com)
  39. X
  40. XAlso thanks to Frans Meulenbroeks, Jan Christiaan van Winkel,
  41. XPeter van Hooft and the testers of comp.sources.reveiwed for testing
  42. Xthis version on different platforms.
  43. X-- 
  44. XPeter Jannesen
  45. END_OF_FILE
  46. if test 685 -ne `wc -c <'Acknowleds'`; then
  47.     echo shar: \"'Acknowleds'\" unpacked with wrong size!
  48. fi
  49. # end of 'Acknowleds'
  50. fi
  51. if test -f 'Changes' -a "${1}" != "-c" ; then 
  52.   echo shar: Will not clobber existing file \"'Changes'\"
  53. else
  54. echo shar: Extracting \"'Changes'\" \(3214 characters\)
  55. sed "s/^X//" >'Changes' <<'END_OF_FILE'
  56. X(N)compress cersion 4.2.2
  57. X    Minor changes after the reviewes from comp.sources.reviewed
  58. X    o Change the name to ncompress because of version problems.
  59. X    o Start all scripts with ':'
  60. X    o Added libary options to buidl script.
  61. X    o Install zmore zcmp zdiff and manuals.
  62. X    o Added patchlevel.h
  63. X    o Updated README file. Created LZW.INFO
  64. X    o a complete grammatical go-round
  65. X    o Use utime.h if availble
  66. X    o Change de default input/output buffer size to BUFSIZ. Because
  67. X      of performance problems with read a head on systems.
  68. X    o Build generates a makefile.
  69. X
  70. Xcompress version 4.2.1 improvements
  71. X    o Change the name to ncompress because of version problems.
  72. X    o Completly rewrite of the compress and decompress functions.
  73. X      compress speedup 25-50% (user cpu time).
  74. X      decompress speedup 20-30% (user cpu time).
  75. X    o Add special fast compress hash algorithm.
  76. X    o Fix some minor things.
  77. X    o use #include <utime.h> if availble.
  78. X    o Cleanup the source code (I think so).
  79. X    o Test if filename is not to long. This is done on runtime no fix length
  80. X      size any more.
  81. X    o Powerfull build script (test almost every thing).
  82. X
  83. XModifications for version 4.1: 
  84. X    o Added -r command line flag to allow recursive compression/
  85. X      decompression of directory trees. As a side-effect, compress
  86. X      no longer tries to compress/decompress anything that isn't
  87. X      a regular file. In particular, it ignores symbolic links.
  88. X    o zcat no longer cares whether a filename ends in .Z or
  89. X      not - it relies on the magic number in the file. If zcat
  90. X      is given a filename that doesn't end with .Z and the file
  91. X      referenced doesn't exist, zcat will append a .Z and try
  92. X      to open that instead.
  93. X    o compress -f will now compress multiply hardlinked files.
  94. X      Uncompress does not recreate the hard link, it creates
  95. X      a new file.
  96. X    o Removed compressdir/uncompressdir - no longer needed.
  97. X    o Removed atob/btoa/tarmail/untarmail - my versions are
  98. X      based on btoa 5.2 which is not compatible with the atob
  99. X      included with compress4.0.
  100. X
  101. XCompress version 4.0 improvements:
  102. X    o compress() speedup (10-50%) by changing division hash to xor
  103. X    o decompress() speedup (5-10%)
  104. X    o Memory requirements reduced (3-30%)
  105. X    o Stack requirements reduced to less than 4kb
  106. X    o Removed 'Big+Fast' compress code (FBITS) because of compress speedup
  107. X    o Portability mods for Z8000 and PC/XT (but not zeus 3.2)
  108. X    o Default to 'quiet' mode
  109. X    o Unification of 'force' flags
  110. X    o Manual page overhaul
  111. X    o Portability enhancement for M_XENIX
  112. X    o Removed text on #else and #endif
  113. X    o Added "-V" switch to print version and options
  114. X    o Added #defines for SIGNED_COMPARE_SLOW
  115. X    o Added Makefile and "usermem" program
  116. X    o Removed all floating point computations
  117. X    o New programs:
  118. X        compressdir - compress all files on a directory
  119. X        uncompressdir - uncompress all files on a directory
  120. X        zcmp - cmp compressed files
  121. X        zdiff - diff compressed files
  122. X      The following are with thanks to philabs!per:
  123. X        btoa - convert binary to ascii for mailing
  124. X        atob - convert ascii to binary with checksum
  125. X        tarmail - tar, compress, btoa, and mail files
  126. X        untarmail - restore "tarmail" files
  127. X
  128. X        WARNING: These last few programs are not compatible 
  129. X        with the original ones from the net.  The encoding
  130. X        has changed.  See btoa.c for more info.
  131. X
  132. END_OF_FILE
  133. if test 3214 -ne `wc -c <'Changes'`; then
  134.     echo shar: \"'Changes'\" unpacked with wrong size!
  135. fi
  136. # end of 'Changes'
  137. fi
  138. if test -f 'LZW.INFO' -a "${1}" != "-c" ; then 
  139.   echo shar: Will not clobber existing file \"'LZW.INFO'\"
  140. else
  141. echo shar: Extracting \"'LZW.INFO'\" \(4347 characters\)
  142. sed "s/^X//" >'LZW.INFO' <<'END_OF_FILE'
  143. XThe following article from James A. Woods, one of the earlier
  144. Xauthors of compress, explains its relationship to the Unisys
  145. Xpatent on the LZW compression method:
  146. X
  147. XFrom uunet!zephyr.ens.tek.com!uw-beaver!mit-eddie!wuarchive!usc!ucsd!ucbvax!agate!riacs!jaw Wed Aug  1 15:06:59 EDT 1990
  148. XArticle: 1282 of gnu.misc.discuss
  149. XPath: alembic!uunet!zephyr.ens.tek.com!uw-beaver!mit-eddie!wuarchive!usc!ucsd!ucbvax!agate!riacs!jaw
  150. XFrom: jaw@riacs.edu (James A. Woods)
  151. XNewsgroups: gnu.misc.discuss
  152. XSubject: Sperry patent #4,558,302 does *not* affect 'compress'
  153. XKeywords: data compression, algorithm, patent
  154. XMessage-ID: <1990Jul31.220935.1424@riacs.edu>
  155. XDate: 31 Jul 90 22:09:35 GMT
  156. XOrganization: RIACS, NASA Ames Research Center
  157. XLines: 69
  158. X
  159. X#  "The chief defect of Henry King
  160. X    Was chewing little bits of string."
  161. X
  162. X        -- Hilaire Belloc, Cautionary Tales [1907]
  163. X
  164. X     As a co-author of 'compress' who has had contact with an attorney for
  165. XUnisys (nee Sperry), I would like to relay a very basic admission from Unisys
  166. Xthat noncommercial use of 'compress' is perfectly legal.  'Compress' is also
  167. Xcommercially distributed by AT&T as part of Unix System 5 release 4,
  168. Xwith no further restrictions placed upon the use of the binary, as far
  169. Xas I am aware.
  170. X
  171. X     From conversations with Professor Abraham Lempel and others, it 
  172. Xappears that neither AT&T, Sun Microsystems, Hewlett Packard, nor IBM
  173. Xare paying any sort of license fees to Unisys in conjunction with patent
  174. X#4,558,302.  It may be true that some organizations are paying fees for
  175. Xdata compression technology licensed from one or more of the many holders
  176. Xof compression patents, but this is all independent from 'compress'.
  177. X
  178. X     In particular, I received a letter at NASA dated October 1, 1987 from
  179. XJohn B. Sowell of the Unisys law department, informing me for the first
  180. Xtime that some form of LZW was patented.  I naturally expressed
  181. Xskepticism that an algorithm could be patented (a murky legal area
  182. Xwhich remains so), stated that 'compress' is not identical to LZW,
  183. Xand in fact was designed, developed, and distributed before the ink
  184. Xon the patent was dry.  Several telephone conversations later, Mr. Sowell
  185. Xintimated that they would *not* seek any fees from users of 'compress'
  186. Xbut instead were signing licensees for hardware implementations of LZW.
  187. X
  188. X     So, regardless of what you believe about a shady legal area, if anyone
  189. Xfrom Unisys contacts you to extract tribute for the use of 'compress', please
  190. Xtell them that, first, it is not theirs to begin with, and, second, there is
  191. Xsomeone who will testify in court about the conversation above.
  192. XIt is not even clear if anyone can "own" 'compress', since original developer
  193. XSpencer Thomas, myself, and others placed the code in the public domain
  194. Xlong before the adoption of the Berne copyright convention.
  195. X
  196. X     In light of the events above, it seems that the Free Software
  197. XFoundation is being unduly paranoid about the use of 'compress'.
  198. XNow I can well believe that FSF is more likely to be a legal target
  199. Xthan a behemoth like AT&T, but if they are simply redistributing
  200. Xuntouched free software developed years ago in the public sector,
  201. XI see no problem.
  202. X
  203. X     Aside:  I am investigating, possibly for a case history to be
  204. Xrecycled to USENET, the particulars of data compression patents.
  205. XI am aware of the following patents: IBM's Miller-Wegman LZ variant,
  206. Xthose of Telcor and ACT [losing candidates for the British Telecom modem
  207. Xstandard], James A. Storer's work on limited lookahead as explicated in his
  208. Xtext "Data Compression (methods and theory)", Computer Science Press, 1988,
  209. Xand the various patents pending associated with the Fiala and Greene
  210. XCACM article of April, 1989 on textual substitution methods.
  211. XIf you have any lore, send it this way.
  212. X
  213. X
  214. X
  215. X                    Sincerely,
  216. X
  217. X                    James A. Woods
  218. X                    NASA Ames Research Center (RIACS)
  219. X                    jaw@riacs.edu (or ames!jaw)
  220. X
  221. X
  222. XP.S.  The algorithm patent issue certainly is a "topic A" at the moment.
  223. XOne useful reference is the review article by Anthony and Colwell --
  224. X"Litigating the Validity and Infringement of Software Patents" in
  225. XWashington and Lee Law Review, volume 41, fall 1984.  I know Robert Colwell
  226. Xpersonally.  As a practicing patent attorney, he tells me that, at a minimum,
  227. Xuse of an invention "for research purposes" is legitimate.
  228. END_OF_FILE
  229. if test 4347 -ne `wc -c <'LZW.INFO'`; then
  230.     echo shar: \"'LZW.INFO'\" unpacked with wrong size!
  231. fi
  232. # end of 'LZW.INFO'
  233. fi
  234. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  235.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  236. else
  237. echo shar: Extracting \"'MANIFEST'\" \(542 characters\)
  238. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  239. X   File Name        Archive #    Description
  240. X-----------------------------------------------------------
  241. X Acknowleds                 1    
  242. X Changes                    1    
  243. X Makefile.def                1
  244. X MANIFEST                   1    This shipping list
  245. X LZW.INFO                    1
  246. X README                     1    
  247. X build                      1    
  248. X compress.1                 1    
  249. X compress42.c               1/2    
  250. X patchlevel.h                2
  251. X zcmp                       1    
  252. X zcmp.1                     1    
  253. X zdiff                      1    
  254. X zmore                      1    
  255. X zmore.1                    1    
  256. END_OF_FILE
  257. if test 542 -ne `wc -c <'MANIFEST'`; then
  258.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  259. fi
  260. # end of 'MANIFEST'
  261. fi
  262. if test -f 'Makefile.def' -a "${1}" != "-c" ; then 
  263.   echo shar: Will not clobber existing file \"'Makefile.def'\"
  264. else
  265. echo shar: Extracting \"'Makefile.def'\" \(1830 characters\)
  266. sed "s/^X//" >'Makefile.def' <<'END_OF_FILE'
  267. X# Makefile
  268. X
  269. X# C complier
  270. XCC=cc
  271. X
  272. X# Install directory for binarys
  273. XBINDIR=/usr/local/bin
  274. X
  275. X# Install directory for manual
  276. XMANDIR=/usr/local/man/man1
  277. X
  278. X# compiler options:
  279. X# options is a collection of:
  280. X#
  281. X#    -DDIRENT=1                    Use dirent.h
  282. X#    -DSYSDIR=1                    Use sys/dir.h
  283. X#    -DLSTAT=1                    Use lstat for finding symlinks.
  284. X#    -DUTIME_H=1                    Use utime.h
  285. X#    -DUSERMEM=<size>            Availble memory for compress (default 800k).
  286. X#    -DREGISTERS=<nbr>            Number of registers (default 2).
  287. X#    -DIBUFSIZ=<size>            Input buffer size (default BUFSIZ).
  288. X#    -DOBUFSIZ=<size>            Output buffer size (default BUFSIZ)
  289. X#    -DBYTEORDER=<order>            Byte order (default: unknown).
  290. X#    -DNOALLIGN=1                Data word allignment (default: yes).
  291. X#    -DDEF_ERRNO=1                Define error (not defined in errno.h).
  292. X#    -DMAXSEG_64K=1 -BITS=16        Support segment processsor like 80286.
  293. X#
  294. Xoptions= -DIRENT=1 -DUSERMEM=800000 -DREGISTERS=3  
  295. X
  296. X# libary options
  297. XLBOPT=
  298. X
  299. Xcompress:    Makefile compress42.c patchlevel.h
  300. X    $(CC) -o compress $(options) "-DCOMPILE_DATE=\"`date`\"" compress42.c $(LBOPT)
  301. X
  302. Xinstall:    compress
  303. X        [ -f /usr/local/bin/compress ] &&             { rm -f /usr/local/bin/compress.old ;               mv /usr/local/bin/compress /usr/local/bin/compress.old ; }
  304. X        rm -f /usr/local/bin/uncompress /usr/local/bin/zcat
  305. X        cp compress /usr/local/bin/compress
  306. X        strip /usr/local/bin/compress
  307. X        rm -f /usr/local/bin/uncompress
  308. X        ln /usr/local/bin/compress /usr/local/bin/uncompress
  309. X        rm -f  /usr/local/bin/zcat
  310. X        ln -f /usr/local/bin/compress /usr/local/bin/zcat
  311. X        cp zcmp zdiff zmore /usr/local/bin/.
  312. X        chmod 0755 /usr/local/bin/compress /usr/local/bin/zcmp /usr/local/bin/zdiff                    /usr/local/bin/zmore
  313. X        cp compress.1 zcmp.1 zmore.1 /usr/local/man/man1/.
  314. X        chmod 0644 /usr/local/man/man1/compress.1 /usr/local/man/man1/zcmp.1                    /usr/local/man/man1/zmore.1
  315. X
  316. Xcleanup:
  317. X        rm -f compress compress.def comp.log
  318. END_OF_FILE
  319. if test 1830 -ne `wc -c <'Makefile.def'`; then
  320.     echo shar: \"'Makefile.def'\" unpacked with wrong size!
  321. fi
  322. # end of 'Makefile.def'
  323. fi
  324. if test -f 'README' -a "${1}" != "-c" ; then 
  325.   echo shar: Will not clobber existing file \"'README'\"
  326. else
  327. echo shar: Extracting \"'README'\" \(3709 characters\)
  328. sed "s/^X//" >'README' <<'END_OF_FILE'
  329. XThis is version 4.2 of (N)compress (an improved version of compress 4.1).
  330. X
  331. XCompress is a fast, simple LZW file compressor.  Compress does not have
  332. Xthe highest compression rate, but it is one of the fastest programs to
  333. Xcompress data.  Compress is the defacto standard in the UNIX community
  334. Xfor compressing files.
  335. X
  336. X'build' is a menu driven shell script for compiling, testing and
  337. Xinstalling (N)compress. So to build and install (N)compress all you have to
  338. Xdo is run build.  Build will first test your system for default
  339. Xsettings. The current compile settings are stored in a special file
  340. Xcalled compress.def.
  341. X
  342. XFor user with problems with build there is a default makefile included
  343. Xcalled 'Makefile.def'. Also build is capable te generate a Makefile with
  344. Xall options (option genmake).
  345. X
  346. X(N)compress 4.2 has a special, fast compression hash algorithm.  This
  347. Xalgorithm uses more memory than the old hash table. If you don't want
  348. Xthe faster hash table algorithm set 'Memory free for compress' below
  349. X800000.
  350. X
  351. Xzcmp, zdiff, zmore were copied from version 4.1 without any changes.
  352. X
  353. XThe output of (N)compress 4.2 is fully compatible with that of compress 3.0.
  354. XIn other words, the output of (N)compress 4.2 may be fed into uncompress 3.0 or
  355. Xthe output of compress 3.0 may be fed into uncompress 4.2.
  356. X
  357. XThe output of (N)compress 4.2 is not compatible with that of
  358. Xcompress 2.0.  However, compress 4.2 still accepts the output of
  359. Xcompress 2.0.  To generate output that is compatible with compress
  360. X2.0, use the undocumented "-C" flag.
  361. X
  362. XSend comments, complaints and especially patches relating to
  363. X    peter@ncs.nl
  364. X
  365. X
  366. XREMARKS
  367. X
  368. X- Build is a bourne shell script. On some system it is nessesary to type
  369. X  'sh build'.
  370. X
  371. X- The build script usages tput for nice screen handling of the script.
  372. X  If your system has no tput no problems.
  373. X
  374. X- For configuration testing build uses a lot of small C programs. During
  375. X  those test stderr is redirected to /dev/null.
  376. X  During the compilation of compress output is NOT redirected.
  377. X
  378. X- The /bin/sh under Ultrix can't handle ${var:-str} so use ksh for the
  379. X  build script.
  380. X
  381. X- If there are any problems with the libary functions definitions in
  382. X  compress42.c define NOFUNCDEF (-DNOFUNCDEF=1) to disable the definitions.
  383. X  IBM AIX (RS/6000) uses a different definitions of open(), define -D_IBMRT=1
  384. X  to disable the open() definition.
  385. X
  386. X- The output if (N)compress 4.2 is not exactly the same as compress 4.0
  387. X  because of differente table reset point. The output of (N)compress 4.2
  388. X  is 100% compatible with compress 4.0
  389. X
  390. X- Some systems has performance problems with reads bigger than BUFSIZ
  391. X  (The read a head function is not working as expected). For those
  392. X  system use the default BSIZE input buffer size.
  393. X
  394. X- (N)compress can by slower on small files (<10Kb) because of a greate 
  395. X  table reset overhead. Use cpio or tar to make 1 bigger file if
  396. X  posible, it is faster and also gives a beter compression ratio most
  397. X  of the time.
  398. X
  399. X- (N)compress is slower in vax systems because of removing some
  400. X  undocumented inline asembler.
  401. X
  402. X- files compressed on a large machine with more bits than allowed by 
  403. X  a version of compress on a smaller machine cannot be decompressed!  Use the
  404. X  "-b12" flag to generate a file on a large machine that can be uncompressed 
  405. X  on a 16-bit machine.
  406. X
  407. X- compatibility with compress 3.0 has not been tested in the 4.2 release of
  408. X  (N)compress.
  409. X
  410. X===============================================================================
  411. XPeter Jannesen
  412. XNetwork Communication Systems (N.C.S), The Netherlands
  413. XPhone:  +31104130093                             Fax:    +31104146452
  414. XAddress: Westbaak 96a                            Email:  peter@ncs.nl
  415. X         3012 KM Rotterdam, The Netherlands
  416. END_OF_FILE
  417. if test 3709 -ne `wc -c <'README'`; then
  418.     echo shar: \"'README'\" unpacked with wrong size!
  419. fi
  420. # end of 'README'
  421. fi
  422. if test -f 'build' -a "${1}" != "-c" ; then 
  423.   echo shar: Will not clobber existing file \"'build'\"
  424. else
  425. echo shar: Extracting \"'build'\" \(19727 characters\)
  426. sed "s/^X//" >'build' <<'END_OF_FILE'
  427. X:
  428. X#!/bin/sh
  429. X#
  430. Xversion="4.2.3"
  431. X
  432. Xecho "Build (N)compress ${version}"
  433. XCLS=`sh -c 'tput clear' 2>/dev/null`
  434. X
  435. Xif expr `echo "foo\c"` : '.*c' >/dev/null
  436. Xthen
  437. X    n='-n'
  438. X    c=''
  439. Xelse
  440. X    n=''
  441. X    c='\c'
  442. Xfi
  443. X
  444. Xtrap 'rm -f /tmp/sh$$.tm* /tmp/sh$$.f* /tmp/sh$$.log /tmp/sh*.c' 0
  445. Xtrap 'set +x ; exit 1' 1 2 15
  446. X
  447. X[ -f compress.def ] && . ./compress.def
  448. X
  449. Xwhile true
  450. Xdo
  451. X    if [ "${DEFINED}" = yes ]
  452. X    then
  453. X        echo "${CLS}    Build (N)compress ${version}
  454. X
  455. X 1.  Directory to install compress in: ${BINDIR}
  456. X                          manual in  : ${MANDIR}
  457. X 2.  Memory free for compress        : ${USERMEM}
  458. X 3.  Input/Output buffer size        : ${IBUFSIZ} ${OBUFSIZ}
  459. X 4.  C Compiler                      : ${CC}
  460. X 5.  Compiler options                : ${CCOPT:---none--}
  461. X 6.  Libary options                  : ${LBOPT:---none--}
  462. X 7.  Special options for your system : ${EXTRA:---none--}
  463. X 8.  Number of register variable     : ${REGISTERS}
  464. X 9.  Symbolic links                  : ${LSTAT}
  465. X10.  Use include <utime.h>           : ${UTIME_H}"
  466. X
  467. X        if [ ".${DIRENT}" = .yes ] 
  468. X        then
  469. X            echo "11.  Your system support dirent.h"
  470. X        else
  471. X            if [ ".${SYSDIR}" = .yes -a ".${DIRENT}" != .yes ]
  472. X            then
  473. X                echo "11.  Your system support sys/dir.h"
  474. X            else
  475. X                echo "11.  No directory support -r disabled."
  476. X            fi
  477. X        fi
  478. X    
  479. X        echo "12.  Word must start at even addres: ${NOALLIGN}, Bytorder on your system: ${BYTEORDER}"
  480. X        echo "
  481. X d. Set default settings                    mkshar.  Create shell archive
  482. X c. Compile compress                        mktar.   Create tar archive
  483. X t. Test compress                           cleanup. Cleanup
  484. X i. Install compress                        genmake. Generate makefile
  485. X q. Stop
  486. X"
  487. X        echo ${n} "   Choice [1..10,d,c,t,i,q,mkshar,mktar,cleanup] : ${c}"
  488. X
  489. X        (
  490. X            echo "# Current parameters."
  491. X            for var in CC CCOPT LBOPT BINDIR MANDIR DIRENT SYSDIR IBUFSIZ \
  492. X                        OBUFSIZ USERMEM REGISTERS LSTAT BYTEORDER NOALLIGN \
  493. X                        EXTRA DEFINED UTIME_H
  494. X            do
  495. X                echo "${var}='`eval echo \$\{${var}\}`'"
  496. X            done
  497. X        ) >compress.def
  498. X
  499. X        read choice var1 var2 var3 var4 varr
  500. X        echo ""
  501. X    else
  502. X        choice=D
  503. X    fi
  504. X
  505. X    case "${choice}" in
  506. X    1)
  507. X        if [ ".${var1}" = . ]
  508. X        then
  509. X            echo ${n} "Directory to install compress in (default:${BINDIR}) ? ${c}"
  510. X            read var1 dummy
  511. X        fi
  512. X
  513. X        BINDIR="${var1:-${BINDIR}}"
  514. X
  515. X        if [ ".${var2}" = . ]
  516. X        then
  517. X            echo ${n} "Directory to install manuals in (default:${MANDIR}) ? ${c}"
  518. X            read var2 dummy
  519. X        fi
  520. X
  521. X        MANDIR="${var2:-${MANDIR}}"
  522. X        ;;
  523. X
  524. X    2)
  525. X        if [ ".${var1}" = . ]
  526. X        then
  527. X            echo "Compress use a lot of memory, the more memory it can just the faster"
  528. X            echo "the programm is and the better compression is."
  529. X            echo ${n} "Memory free for compress (default:${USERMEM}) ? ${c}"
  530. X            read var1 dummy 
  531. X        fi
  532. X
  533. X        USERMEM="${var1:-${USERMEM}}"
  534. X        ;;
  535. X
  536. X    3)    
  537. X        if [ ".${var1}" = . ]
  538. X        then
  539. X            echo "For input and output compress use buffers. A bigger buffer reduce"
  540. X            echo "system (kernel) overhead. If your system is a 16 bits system don't"
  541. X            echo "make the buffers bigger than 2048 bytes. The default 2048 is in"
  542. X            echo "most cases a good answer."
  543. X            echo ${n} "Best input buffer size (default:${IBUFSIZ}) ? ${c}"
  544. X            read var1 var2 dummy
  545. X
  546. X            if [ ".${var2}" = . ] 
  547. X            then
  548. X                echo ${n} "Best output buffer size (default:${OBUFSIZ}) ? ${c}"
  549. X                read D dummy 
  550. X            fi
  551. X        fi
  552. X
  553. X        var2="${var2:-${var1}}"
  554. X         IBUFSIZ="${var1:-${IBUFSIZ}}"
  555. X         OBUFSIZ="${var2:-${OBUFSIZ}}"
  556. X        ;;
  557. X
  558. X    4)
  559. X        if [ ".${var1}" = . ]
  560. X        then    
  561. X            echo "C compiler to use for compilation (must by cc compatible)".
  562. X            echo ${n} "C Compiler (default:${CC}) ? ${c}"
  563. X            read var1 dummy
  564. X        fi
  565. X
  566. X        CC="${var1:-${CC}}"
  567. X        ;;
  568. X
  569. X    5)
  570. X        if [ ".${var1}" = . ]
  571. X        then
  572. X            echo ${n} "Compiler options (default:${CCOPT:-none}) ? ${c}"
  573. X            read var1
  574. X        fi
  575. X
  576. X        [ ".${var1}" != . ] && CCOPT="${var1} ${var2} ${var3} ${var4} ${varr}"
  577. X        ;;    
  578. X
  579. X    6)
  580. X        if [ ".${var1}" = . ]
  581. X        then
  582. X            echo ${n} "Libary options (default:${LBOPT:-none}) ? ${c}"
  583. X            read var1
  584. X        fi
  585. X
  586. X        [ ".${var1}" != . ] && LBOPT="${var1} ${var2} ${var3} ${var4} ${varr}"
  587. X        ;;    
  588. X
  589. X    7)
  590. X        if [ ".${var1}" = . ]
  591. X        then
  592. X            echo "Some system needs extra defines see README"
  593. X            echo ${n} "Special for your system (default:${EXTRA:-none}) ? ${c}"
  594. X            read var1
  595. X        fi
  596. X
  597. X        [ ".${var1}" != . ] && EXTRA="${var1} ${var2} ${var3} ${var4} ${varr}"
  598. X        ;;    
  599. X
  600. X    8)
  601. X        if [ ".${var1}" = . ]
  602. X        then
  603. X            echo ${n} "Number of register variable (default:${REGISTERS}) ? ${c}"
  604. X            read var1 dummy
  605. X        fi
  606. X
  607. X        REGISTERS="${var1:-${REGISTERS}}"
  608. X        ;;
  609. X
  610. X    9)
  611. X        if [ ".${var1}" = . ]
  612. X        then
  613. X            echo ${n} "Symbolic links (default:${LSTAT}) ? ${c}"
  614. X            read var1 dummy
  615. X        fi
  616. X
  617. X        case "${var1:-${DIRENT}}" in
  618. X        y|Y|yes|YES) LSTAT=yes; ;;
  619. X        *)             LSTAT=no; ;;
  620. X        esac
  621. X        ;;
  622. X
  623. X    10)
  624. X        if [ ".${var1}" = . ]
  625. X        then
  626. X            echo ${n} "Do your system support utime.h (default:${UTIME_H}) ? ${c}"
  627. X            read var1 dummy
  628. X        fi
  629. X
  630. X        case "${var1:-${DIRENT}}" in
  631. X        y|Y|yes|YES) UTIME_H=yes; ;;
  632. X        *)             UTIME_H=no; ;;
  633. X        esac
  634. X        ;;
  635. X
  636. X    11)
  637. X        case "${var1}" in
  638. X        dirent)
  639. X            DIRENT=yes; SYSDIR=no;
  640. X            ;;
  641. X        sys/dir) 
  642. X            DIRENT=no; SYSDIR=yes;
  643. X            ;;
  644. X        *)
  645. X            echo ${n} "Do your system support dirent.h (default:${DIRENT}) ? ${c}"
  646. X            read var1 dummy
  647. X            case "${var1:-${DIRENT}}" in
  648. X            y|Y|yes|YES) DIRENT=yes; SYSDIR=no; ;;
  649. X            *)             DIRENT=no; SYSDIR=no; ;;
  650. X            esac
  651. X
  652. X            if [ ${DIRENT} = no ]
  653. X            then
  654. X                echo ${n} "Do your system support sys/dir.h (default:${SYSDIR}) ? ${c}"
  655. X                read var1 dummy
  656. X                case "${var1:-${SYSDIR}}" in
  657. X                y|Y|yes|YES) DIRENT=no; SYSDIR=yes; ;;
  658. X                *)             DIRENT=no; SYSDIR=no; ;;
  659. X                esac
  660. X            fi
  661. X            ;;
  662. X        esac
  663. X        ;;
  664. X
  665. X    12)
  666. X        if [ ".${var1}" = . ]
  667. X        then
  668. X            echo "If your system don't need word allignment for words (like 80386)"
  669. X            echo "compress can use this fact to by faster. If your are not sure type y"
  670. X            echo ${n} "Must words start at a even address (default:${NOALLIGN}) ? ${c}"
  671. X            read var1 var2 varr
  672. X        fi
  673. X
  674. X        if [ ".${var2}" = . ]
  675. X        then
  676. X            echo ${n} "Byteorder on your system (default:${BYTEORDER}) ? ${c}"
  677. X            read var2 varr 
  678. X        fi
  679. X
  680. X        case "${var1}" in
  681. X        n|no|N|NO)    var1=no; ;;
  682. X        *)            var1=yes; ;;
  683. X        esac
  684. X
  685. X         NOALLIGN="${var1:-${NOALLIGN}}"
  686. X         BYTEORDER="${var2:-${BYTEORDER}}"
  687. X        ;;
  688. X
  689. X    d|D)
  690. X        echo "Testing the system to find out what kind of system we have."
  691. X        BINDIR=/usr/bin
  692. X        MANDIR=/usr/man/man1
  693. X        DIRENT=no
  694. X        SYSDIR=no
  695. X        UTIME_H=no
  696. X        IBUFSIZ=2048
  697. X        OBUFSIZ=2048
  698. X        USERMEM=0
  699. X        REGISTERS=2
  700. X        LSTAT=no
  701. X        CCOPT='-O'
  702. X        LBOPT=
  703. X        EXTRA=
  704. X        [ -f /usr/include/sys/dir.h ] && { SYSDIR=yes; }
  705. X        [ -f /usr/include/dirent.h ] && { DIRENT=yes; }
  706. X        [ -f /usr/include/utime.h ] && { UTIME_H=yes; }
  707. X        [ -d /usr/local/bin ] && { BINDIR=/usr/local/bin; }
  708. X        [ -d /usr/local/man ] && { BINDIR=/usr/local/man/man1; }
  709. X        [ -f /usr/bin/compress ] && { BINDIR=/usr/bin; }
  710. X    
  711. X        if [ ".${CC}" = . ]
  712. X        then
  713. X            echo ${n} "Find compiler. Compiler is: ${c}"
  714. X            echo 'main() {return 0;}' >/tmp/sh$$.c
  715. X
  716. X            for cc in cc gcc
  717. X            do
  718. X                if ${cc} -c /tmp/sh$$.c >/dev/null 2>&1
  719. X                then
  720. X                    rm -f sh$$.o
  721. X                    CC=${cc}
  722. X                    echo ${CC}
  723. X                    break
  724. X                fi
  725. X            done
  726. X
  727. X            if [ ".${CC}" = . ]
  728. X            then
  729. X                echo "Can't file one of the standaard compilers. Give C Compiler name"
  730. X                echo ${n} "C Compiler : ${c}"
  731. X                read CC dummy
  732. X            fi
  733. X        fi
  734. X
  735. X        echo ${n} "Test best buffer size: ${c}"
  736. X        cat >/tmp/sh$$.c <<!
  737. X#include <stdio.h>
  738. X        main()
  739. X            {
  740. X                int        size;
  741. X    
  742. X                size = 1024;
  743. X#ifdef BUFSIZ
  744. X                if (size < BUFSIZ)    size = BUFSIZ;
  745. X#endif
  746. X                if (sizeof(int)<4)    size = 2048;
  747. X                printf("%d\n", size);
  748. X                return 0;
  749. X            }
  750. X!
  751. X        ${CC} /tmp/sh$$.c && IBUFSIZ=`./a.out`
  752. X        rm -f /tmp/sh$$.c a.out
  753. X        OBUFSIZ=${IBUFSIZ}
  754. X        echo "${IBUFSIZ}"
  755. X
  756. X        echo ${n} "Test byte order of system: ${c}"
  757. X        cat >/tmp/sh$$.c <<!
  758. X        main()
  759. X            {
  760. X                long    test;
  761. X        extern    int        write();
  762. X        
  763. X                test = 0x31323334L;
  764. X                write(1, (char *)&test, 4);
  765. X                return 0;
  766. X            }
  767. X!
  768. X        ${CC} /tmp/sh$$.c && BYTEORDER=`./a.out`
  769. X        BYTEORDER="${BYTEORDER:-0000}"
  770. X        echo ${BYTEORDER}
  771. X        rm -f /tmp/sh$$.c a.out
  772. X
  773. X
  774. X        echo ${n} "Test word allignment. Must words be allign: ${c}"
  775. X        cat >/tmp/sh$$.c <<!
  776. X        sig() {exit(1);}
  777. X        main()
  778. X            {
  779. X                int        i;
  780. X                char    bfr1[6];
  781. X                char    bfr2[6];
  782. X                long    test;
  783. X        extern    int        write();
  784. X
  785. X                for (i = 1 ; i <= 15 ; ++i)
  786. X                    signal(i, sig);
  787. X    
  788. X                bfr1[0]=' ';bfr1[1]='1';bfr1[2]='2';
  789. X                bfr1[3]='3';bfr1[4]='4';bfr1[5]=' ';
  790. X                bfr2[0]='X';bfr2[1]='X';bfr2[2]='X';
  791. X                bfr2[3]='X';bfr2[4]='X';bfr2[5]='X';
  792. X
  793. X                test = *(long *)(bfr1+1);
  794. X                *(long *)(bfr2+0) = test;
  795. X    
  796. X                if (bfr2[0] == '1' && bfr2[1] == '2' && bfr2[2] == '3' &&
  797. X                    bfr2[3] == '4' && bfr2[4] == 'X')
  798. X                    write(1, "no", 2);
  799. X
  800. X                return 0;
  801. X            }
  802. X!
  803. X        ${CC} /tmp/sh$$.c && NOALLIGN=`( ./a.out ) 2>/dev/null`
  804. X        NOALLIGN="${NOALLIGN:-yes}"
  805. X        echo ${NOALLIGN}
  806. X        rm -f /tmp/sh$$.c a.out core
  807. X
  808. X        echo ${n} "Test number of register vars. Registers var: ${c}"
  809. X        cat >/tmp/sh$$.c <<!
  810. X        main()
  811. X            {
  812. X                long            l11;
  813. X                long            l12;
  814. X                long            l13;
  815. X                long            l1;
  816. X                register long    rl01; register long    rl02;
  817. X                register long    rl03; register long    rl04;
  818. X                register long    rl05; register long    rl06;
  819. X                register long    rl07; register long    rl08;
  820. X                register long    rl09; register long    rl10;
  821. X                register long    rl11; register long    rl12;
  822. X                register long    rl13; register long    rl14;
  823. X                register long    rl15; register long    rl16;
  824. X                register long    rl17; register long    rl18;
  825. X                register long    rl19; register long    rl20;
  826. X                long            l2;
  827. X                long            l22;
  828. X                long            l23;
  829. X                long            l24;
  830. X
  831. X                l1 = (char *)&l1-(char *)&l2;
  832. X                if (l1 < 0)    l1 = -l1;
  833. X                l1 = 21-(l1/sizeof(long));
  834. X                if (l1 > 0 && l1 < 21)
  835. X                    printf("%ld", l1);
  836. X                exit(0);
  837. X            }
  838. X!
  839. X        cc /tmp/sh$$.c && REGISTERS=`./a.out`
  840. X        REGISTERS=${REGISTERS:-2};
  841. X        echo ${REGISTERS}
  842. X        rm -f a.out /tmp/sh$$.c
  843. X
  844. X        echo ${n} "Test if errno is declared in errno.h: ${c}"
  845. X        cat >/tmp/sh$$.c <<!
  846. X#include    <stdio.h>
  847. X#include    <errno.h>
  848. X        main()
  849. X            {
  850. X                return    errno;
  851. X            }
  852. X!
  853. X        if cc /tmp/sh$$.c
  854. X        then
  855. X            echo "Yes"
  856. X        else
  857. X            echo "No"
  858. X            EXTRA="${EXTRA} -DDEF_ERRNO=1"
  859. X        fi
  860. X
  861. X        rm -f a.out /tmp/sh$$.c
  862. X
  863. X
  864. X        echo ${n} "Test if system support symbolic links? ${c}"
  865. X        cat >/tmp/sh$$.c <<!
  866. X        main()
  867. X            {
  868. X                lstat(0, 0);
  869. X            }
  870. X!
  871. X        LSTAT=no
  872. X        ${CC} /tmp/sh$$.c >/dev/null 2>&1 && LSTAT=yes
  873. X        echo "${LSTAT}"
  874. X        rm -f a.out /tmp/sh$$.c
  875. X
  876. X        echo ${n} "Test availble memory${c}"
  877. X        for size in 75000 130000 230000 440000 800000
  878. X        do
  879. X            cat >/tmp/sh$$.c <<!
  880. X            char    test[${size}+128000];
  881. X    
  882. X            extern    int                alarm();
  883. X            extern    int                exit();
  884. X            extern    int                signal();
  885. X    
  886. X            sig() {exit(1);}
  887. X
  888. X            main()
  889. X                {
  890. X                    register int    i;
  891. X                    register long    j;
  892. X    
  893. X                    for (i = 1 ; i <= 15 ; ++i)
  894. X                        signal(i, sig);        
  895. X
  896. X                    alarm(2);
  897. X    
  898. X                    for (i = 0 ; i < 10 ; ++i)
  899. X                        for (j = 0 ; j < sizeof(test) ; j+= 1024)
  900. X                            test[j] = i;
  901. X
  902. X                    alarm(0);
  903. X                    return 0;
  904. X                }
  905. X!
  906. X            ${CC} /tmp/sh$$.c >/dev/null 2>&1 || break
  907. X            ./a.out || break
  908. X            rm a.out /tmp/sh$$.c
  909. X            USERMEM=${size}
  910. X            echo ${n} " ${size}${c}"
  911. X        done
  912. X
  913. X        rm a.out /tmp/sh$$.c
  914. X
  915. X        echo ""
  916. X
  917. X        if [ ${USERMEM} = 0 ]
  918. X        then
  919. X            echo ${n} "Memory size is 0, segmented processor: ${c}"
  920. X            cat >/tmp/sh$$.c <<!
  921. X            long htab0[8192];
  922. X            long htab1[8192];
  923. X            long htab2[8192];
  924. X            long htab3[8192];
  925. X            long htab4[8192];
  926. X            long htab5[8192];
  927. X            long htab6[8192];
  928. X            long htab7[8192];
  929. X            long htab8[8192];
  930. X            short code0tab[16384];
  931. X            short code1tab[16384];
  932. X            short code2tab[16384];
  933. X            short code3tab[16384];
  934. X            short code4tab[16384];
  935. X            main() {return 0;}
  936. X!
  937. X            rm -f ./a.out
  938. X            if ${CC} /tmp/sh$$.c >/dev/null 2>&1 
  939. X            then
  940. X                :
  941. X            else
  942. X                opt="-Ml"
  943. X
  944. X                while [ ".${opt}" != . ]
  945. X                do
  946. X                    if ${CC} ${opt} /tmp/sh$$.c >/dev/null 2>&1 
  947. X                    then
  948. X                        :
  949. X                    else
  950. X                        CCOPT="${CCOPT} ${opt}"
  951. X                        break
  952. X                    fi
  953. X
  954. X                    echo ${n} "Large model compile option: ${c}"
  955. X                    read opt dummy
  956. X                done
  957. X            fi
  958. X
  959. X            if [ -f ./a.out ]
  960. X            then
  961. X                if ./a.out
  962. X                then
  963. X                    echo "Yes"
  964. X                    MEMSIZE=0
  965. X                    EXTRA="${EXTRA} -DMAXSEG_64K=1 -DBITS=16"
  966. X                else
  967. X                    echo "No"
  968. X                fi
  969. X            fi
  970. X
  971. X            rm ./a.out /tmp/sh$$.c
  972. X        fi
  973. X
  974. X        DEFINED=yes
  975. X        echo ""
  976. X        echo "I have now create the default options for compiling compress ${version}"
  977. X    ;;
  978. X
  979. X    c|C)
  980. X        options="${CCOPT} -o compress"
  981. X        [ "${DIRENT}" = yes ] && options="${options} -DDIRENT=1"
  982. X        [ "${SYSDIR}" = yes ] && options="${options} -DSYSDIR=1"
  983. X        [ "${LSTAT}" != no  ] && options="${options} -DLSTAT=1"
  984. X        [ "${UTIME_H}" != no  ] && options="${options} -DUTIME_H=1"
  985. X        options="${options} -DUSERMEM=${USERMEM}"
  986. X        options="${options} -DREGISTERS=${REGISTERS}"
  987. X        options="${options} -DIBUFSIZ=${IBUFSIZ} -DOBUFSIZ=${OBUFSIZ}"
  988. X        options="${options} -DBYTEORDER=${BYTEORDER}"
  989. X        [ "${NOALLIGN}" = no ] && options="${options} -DNOALLIGN=1"
  990. X        options="${options} ${EXTRA}"
  991. X
  992. X        echo ""
  993. X        echo "Compiling compress ${version}"
  994. X
  995. X        echo ${CC} ${options} "-DCOMPILE_DATE=\"`date`\"" compress42.c ${LBOPT}
  996. X
  997. X        if ${CC} ${options} "-DCOMPILE_DATE=\"`date`\"" compress42.c ${LBOPT}
  998. X        then
  999. X            echo ""
  1000. X            ./compress -V
  1001. X            echo ""
  1002. X            echo "Compress compiled, use 'i' to install compress in ${BINDIR}"
  1003. X        else
  1004. X            echo ""
  1005. X            echo "Error(s) in compilation"
  1006. X        fi
  1007. X        echo ""
  1008. X        echo ${n} "Press return to continue${c}"
  1009. X        read dummy
  1010. X        ;;
  1011. X
  1012. X    s|S)
  1013. X        options="-O -S"
  1014. X        [ "${DIRENT}" = yes ] && options="${options} -DDIRENT=1"
  1015. X        [ "${SYSDIR}" = yes ] && options="${options} -DSYSDIR=1"
  1016. X        [ "${LSTAT}" != no  ] && options="${options} -DLSTAT=1"
  1017. X        [ "${UTIME_H}" != no  ] && options="${options} -DUTIME_H=1"
  1018. X        options="${options} -DUSERMEM=${USERMEM}"
  1019. X        options="${options} -DREGISTERS=${REGISTERS}"
  1020. X        options="${options} -DIBUFSIZ=${IBUFSIZ} -DOBUFSIZ=${OBUFSIZ}"
  1021. X        options="${options} -DBYTEORDER=${BYTEORDER}"
  1022. X        [ "${NOALLIGN}" = no ] && options="${options} -DNOALLIGN=1"
  1023. X        options="${options} ${EXTRA}"
  1024. X
  1025. X        echo ""
  1026. X        echo "Compiling compress ${version}"
  1027. X
  1028. X        echo ${CC} ${options} "-DCOMPILE_DATE=\"`date`\"" compress42.c 
  1029. X
  1030. X        ${CC} ${options} "-DCOMPILE_DATE=\"`date`\"" compress42.c 
  1031. X        echo ""
  1032. X        echo ${n} "Press return to continue${c}"
  1033. X        read dummy
  1034. X        ;;
  1035. X
  1036. X    t|T)
  1037. X        if [ ! -x ./compress ]
  1038. X        then
  1039. X            echo "Compile compress first before testing!"
  1040. X        else
  1041. X            if [ ".${var1}" = . ]
  1042. X            then
  1043. X                echo "To test compress you need a test set. For a test set alle filein one"
  1044. X                echo "directory are combined to one file with cpio and compress/decompressed"
  1045. X                echo ${n} "Test directory [default:current]: ${c}"
  1046. X                read var1 varr
  1047. X            fi
  1048. X
  1049. X            if [ ! -d ${var1:-.} ]
  1050. X            then
  1051. X                echo "$var1: no directory"
  1052. X            else
  1053. X                var1=`cd ${var1:-.};pwd`
  1054. X                find ${var1} -type f -print |
  1055. X                    ( while read fn ; do [ -r ${fn} ] && echo ${fn} ; done ) |
  1056. X                    sort >/tmp/sh$$.fi
  1057. X
  1058. X                (
  1059. X                    echo "==============================================================================="
  1060. X                    echo "Directory: ${var1:-/}"
  1061. X                    echo "./compress -V"
  1062. X                    ./compress -V
  1063. X
  1064. X                    if [ -x ${BINDIR}/compress ]
  1065. X                    then
  1066. X                        old=${var2:-${BINDIR}/compress}
  1067. X                        set -- ./compress ${old} \
  1068. X                                ${old} ./compress \
  1069. X                                ./compress ./compress \
  1070. X                                ${old} ${old}
  1071. X
  1072. X                        echo "${old} -V"
  1073. X                        ${old} -V </dev/null dummy-file
  1074. X                    else
  1075. X                        set -- ./compress ./compress
  1076. X                    fi
  1077. X
  1078. X                    while [ $# != 0 ]
  1079. X                    do
  1080. X                        echo "---------------- $1 -> $2 ----------------"
  1081. X                        if [ -x /sbin/sync ] ;    then /sbin/sync
  1082. X                                                else sync ; fi
  1083. X
  1084. X                        sleep 1
  1085. X
  1086. X                        cpio -o </tmp/sh$$.fi |
  1087. X                            ( time $1 -v 2>/tmp/sh$$.tm1 ) |
  1088. X                            ( time $2 -d 2>/tmp/sh$$.tm2 ) |
  1089. X                            ( cpio -ivt >/tmp/sh$$.fo )
  1090. X        
  1091. X                        awk </tmp/sh$$.fo '{print $8}'  >/tmp/sh$$.foo
  1092. X    
  1093. X                        if cmp /tmp/sh$$.fi /tmp/sh$$.foo
  1094. X                        then
  1095. X                            :
  1096. X                        else
  1097. X                            echo ------ ERROR
  1098. X                            diff /tmp/sh$$.fi /tmp/sh$$.foo
  1099. X                        fi
  1100. X
  1101. X                        echo "---------------"
  1102. X                        echo "compress   $1("`cat /tmp/sh$$.tm1`")"
  1103. X                        echo "decompress $2("`cat /tmp/sh$$.tm2`")"
  1104. X                        shift 2
  1105. X                    done
  1106. X                ) 2>&1 | tee /tmp/sh$$.log
  1107. X
  1108. X                cat /tmp/sh$$.log >>comp.log && rm /tmp/sh$$.log
  1109. X            fi
  1110. X
  1111. X            echo ""
  1112. X        fi
  1113. X
  1114. X        echo ${n} "Press return to continue${c}"
  1115. X        read dummy
  1116. X        ;;
  1117. X    i|I)
  1118. X        if [ ".${var1}" = . ]
  1119. X        then
  1120. X            echo ${n} "Install compress with user ? (default current user) ? ${c}"
  1121. X            read var1 dummy
  1122. X        fi
  1123. X
  1124. X        pwd=`pwd`
  1125. X
  1126. X        ( cat - <<!
  1127. X            set -x
  1128. X
  1129. X            cd ${pwd}
  1130. X
  1131. X            [ -f ${BINDIR}/compress ] &&
  1132. X                { rm -f ${BINDIR}/compress.old ;
  1133. X                  mv ${BINDIR}/compress ${BINDIR}/compress.old || exit 1; }
  1134. X
  1135. X            rm -f ${BINDIR}/uncompress ${BINDIR}/zcat || exit 1
  1136. X
  1137. X            cp compress ${BINDIR}/compress || exit 1
  1138. X            strip ${BINDIR}/compress
  1139. X            rm -f ${BINDIR}/uncompress || exit 1
  1140. X            ln ${BINDIR}/compress ${BINDIR}/uncompress || exit 1
  1141. X            rm -f  ${BINDIR}/zcat || exit 1
  1142. X            ln -f ${BINDIR}/compress ${BINDIR}/zcat || exit 1
  1143. X            cp zcmp zdiff zmore ${BINDIR}/. || exit 1
  1144. X            chmod 0755 ${BINDIR}/compress ${BINDIR}/zcmp ${BINDIR}/zdiff \
  1145. X                       ${BINDIR}/zmore || exit 1
  1146. X            cp compress.1 zcmp.1 zmore.1 ${MANDIR}/. || exit 1
  1147. X            chmod 0644 ${MANDIR}/compress.1 ${MANDIR}/zcmp.1 \
  1148. X                       ${MANDIR}/zmore.1 || exit 1
  1149. X
  1150. X            if [ ".${var1}" != . ]
  1151. X            then
  1152. X                chown ${var1} ${BINDIR}/compress ${BINDIR}/zcmp \
  1153. X                              ${BINDIR}/zdiff ${BINDIR}/zmore \
  1154. X                              ${MANDIR}/compress.1 ${MANDIR}/zcmp.1 \
  1155. X                                 ${MANDIR}/zmore.1 
  1156. X            fi
  1157. X!
  1158. X        ) | (
  1159. X            if [ ".${var1}" = . ] ;    then sh 
  1160. X                                    else su - ${var1} -c sh ; fi
  1161. X        )
  1162. X
  1163. X        echo ""
  1164. X        echo ${n} "Press return to continue${c}"
  1165. X        read dummy
  1166. X        ;;
  1167. X
  1168. X    genmake)
  1169. X        options=
  1170. X        [ "${DIRENT}" = yes ] && options="${options} -DDIRENT=1"
  1171. X        [ "${SYSDIR}" = yes ] && options="${options} -DSYSDIR=1"
  1172. X        [ "${LSTAT}" != no  ] && options="${options} -DLSTAT=1"
  1173. X        [ "${UTIME_H}" != no  ] && options="${options} -DUTIME_H=1"
  1174. X        options="${options} -DUSERMEM=${USERMEM}"
  1175. X        options="${options} -DREGISTERS=${REGISTERS}"
  1176. X        options="${options} -DIBUFSIZ=${IBUFSIZ} -DOBUFSIZ=${OBUFSIZ}"
  1177. X        options="${options} -DBYTEORDER=${BYTEORDER}"
  1178. X        [ "${NOALLIGN}" = no ] && options="${options} -DNOALLIGN=1"
  1179. X        options="${options} ${EXTRA}"
  1180. X
  1181. X        cat - <<! >Makefile
  1182. X# Makefile generated by build.
  1183. X
  1184. X# C complier
  1185. XCC=${CC}
  1186. X
  1187. X# Install directory for binarys
  1188. XBINDIR=${BINDIR}
  1189. X
  1190. X# Install directory for manual
  1191. XMANDIR=${MANDIR}
  1192. X
  1193. X# compiler options:
  1194. X# options is a collection of:
  1195. X#
  1196. X#    -DDIRENT=1                    Use dirent.h
  1197. X#    -DSYSDIR=1                    Use sys/dir.h
  1198. X#    -DLSTAT=1                    Use lstat for finding symlinks.
  1199. X#    -DUTIME_H=1                    Use utime.h
  1200. X#    -DUSERMEM=<size>            Availble memory for compress (default 800k).
  1201. X#    -DREGISTERS=<nbr>            Number of registers (default 2).
  1202. X#    -DIBUFSIZ=<size>            Input buffer size (default BUFSIZ).
  1203. X#    -DOBUFSIZ=<size>            Output buffer size (default BUFSIZ)
  1204. X#    -DBYTEORDER=<order>            Byte order (default: unknown).
  1205. X#    -DNOALLIGN=1                Data word allignment (default: yes).
  1206. X#    -DDEF_ERRNO=1                Define error (not defined in errno.h).
  1207. X#    -DMAXSEG_64K=1 -BITS=16        Support segment processsor like 80286.
  1208. X#
  1209. Xoptions=${options}
  1210. X
  1211. X# libary options
  1212. XLBOPT=${LBOPT}
  1213. X
  1214. X
  1215. Xcompress:    Makefile compress42.c patchlevel.h
  1216. X    $(CC) -o compress $(options) "-DCOMPILE_DATE=\"\`date\`\"" compress42.c $(LBOPT)
  1217. X
  1218. Xinstall:    compress
  1219. X        [ -f ${BINDIR}/compress ] && \
  1220. X            { rm -f ${BINDIR}/compress.old ; \
  1221. X              mv ${BINDIR}/compress ${BINDIR}/compress.old ; }
  1222. X        rm -f ${BINDIR}/uncompress ${BINDIR}/zcat
  1223. X        cp compress ${BINDIR}/compress
  1224. X        strip ${BINDIR}/compress
  1225. X        rm -f ${BINDIR}/uncompress
  1226. X        ln ${BINDIR}/compress ${BINDIR}/uncompress
  1227. X        rm -f  ${BINDIR}/zcat
  1228. X        ln -f ${BINDIR}/compress ${BINDIR}/zcat
  1229. X        cp zcmp zdiff zmore ${BINDIR}/.
  1230. X        chmod 0755 ${BINDIR}/compress ${BINDIR}/zcmp ${BINDIR}/zdiff \
  1231. X                   ${BINDIR}/zmore
  1232. X        cp compress.1 zcmp.1 zmore.1 ${MANDIR}/.
  1233. X        chmod 0644 ${MANDIR}/compress.1 ${MANDIR}/zcmp.1 \
  1234. X                   ${MANDIR}/zmore.1
  1235. X
  1236. Xcleanup:
  1237. X        rm -f compress compress.def comp.log
  1238. X!
  1239. X        ;;
  1240. X
  1241. X    mkshar)
  1242. X        xshar -sc -opart -l64 MANIFEST Acknowleds zmore Changes compress.1 \
  1243. X            zcmp zmore.1 README LZW.INFO zcmp.1 zdiff build Makefile.def \
  1244. X            compress42.c patchlevel.h
  1245. X        ;;
  1246. X
  1247. X    mktar)
  1248. X        rm -f comp.tar
  1249. X        tar cvf comp.tar MANIFEST Acknowleds zmore Changes compress.1 \
  1250. X            zcmp zmore.1 README LZW.INFO zcmp.1 zdiff build Makefile.def \
  1251. X            compress42.c patchlevel.h
  1252. X        ;;
  1253. X
  1254. X    cleanup)
  1255. X        rm -f compress compress.def comp.log
  1256. X        exit 0
  1257. X        ;;
  1258. X
  1259. X    q|Q)
  1260. X        exit 0
  1261. X        ;;
  1262. X    *)
  1263. X        echo "                                      Unknown choice ${choice}"
  1264. X        sleep 2
  1265. X        ;;
  1266. X    esac
  1267. Xdone
  1268. END_OF_FILE
  1269. if test 19727 -ne `wc -c <'build'`; then
  1270.     echo shar: \"'build'\" unpacked with wrong size!
  1271. fi
  1272. chmod +x 'build'
  1273. # end of 'build'
  1274. fi
  1275. if test -f 'compress.1' -a "${1}" != "-c" ; then 
  1276.   echo shar: Will not clobber existing file \"'compress.1'\"
  1277. else
  1278. echo shar: Extracting \"'compress.1'\" \(6484 characters\)
  1279. sed "s/^X//" >'compress.1' <<'END_OF_FILE'
  1280. X.PU
  1281. X.TH COMPRESS 1 local
  1282. X.SH NAME
  1283. Xcompress, uncompress, zcat \- compress and expand data (version 4.1)
  1284. X.SH SYNOPSIS
  1285. X.ll +8
  1286. X.B compress
  1287. X[
  1288. X.B \-f
  1289. X] [
  1290. X.B \-v
  1291. X] [
  1292. X.B \-c
  1293. X] [
  1294. X.B \-V
  1295. X] [
  1296. X.B \-r
  1297. X] [
  1298. X.B \-b
  1299. X.I bits
  1300. X] [
  1301. X.I "name \&..."
  1302. X]
  1303. X.ll -8
  1304. X.br
  1305. X.B uncompress
  1306. X[
  1307. X.B \-f
  1308. X] [
  1309. X.B \-v
  1310. X] [
  1311. X.B \-c
  1312. X] [
  1313. X.B \-V
  1314. X] [
  1315. X.I "name \&..."
  1316. X]
  1317. X.br
  1318. X.B zcat
  1319. X[
  1320. X.B \-V
  1321. X] [
  1322. X.I "name \&..."
  1323. X]
  1324. X.SH DESCRIPTION
  1325. X.I Compress
  1326. Xreduces the size of the named files using adaptive Lempel-Ziv coding.
  1327. XWhenever possible,
  1328. Xeach file is replaced by one with the extension
  1329. X.B "\&.Z,"
  1330. Xwhile keeping the same ownership modes, access and modification times.
  1331. XIf no files are specified, the standard input is compressed to the
  1332. Xstandard output.
  1333. X.I Compress
  1334. Xwill only attempt to compress regular files.
  1335. XIn particular, it will ignore symbolic links. If a file has multiple
  1336. Xhard links,
  1337. X.I compress
  1338. Xwill refuse to compress it unless the
  1339. X.B \-f
  1340. Xflag is given.
  1341. X.PP
  1342. XIf
  1343. X.B \-f
  1344. Xis not given and
  1345. X.I compress
  1346. Xis run in the foreground,
  1347. Xthe user is prompted as to whether an existing file should be overwritten.
  1348. X.PP
  1349. XCompressed files can be restored to their original form using
  1350. X.I uncompress
  1351. Xor
  1352. X.I zcat.
  1353. X.PP
  1354. X.I uncompress
  1355. Xtakes a list of files on its command line and replaces each
  1356. Xfile whose name ends with
  1357. X.B "\&.Z"
  1358. Xand which begins with the correct magic number with an uncompressed
  1359. Xfile without the 
  1360. X.B "\&.Z."
  1361. XThe uncompressed file will have the mode, ownership and
  1362. Xtimestamps of the compressed file.
  1363. X.PP
  1364. XThe
  1365. X.B \-c
  1366. Xoption makes
  1367. X.I compress/uncompress
  1368. Xwrite to the standard output; no files are changed.
  1369. X.PP
  1370. X.I zcat
  1371. Xis identical to
  1372. X.I uncompress
  1373. X.B \-c.
  1374. X.I zcat
  1375. Xuncompresses either a list of files on the command line or its
  1376. Xstandard input and writes the uncompressed data on standard output.
  1377. X.I zcat
  1378. Xwill uncompress files that have the correct magic number whether
  1379. Xthey have a
  1380. X.B "\&.Z"
  1381. Xsuffix or not.
  1382. X.PP
  1383. XIf the
  1384. X.B \-r
  1385. Xflag is specified, 
  1386. X.I compress
  1387. Xwill operate recursively. If any of the file names specified on the command
  1388. Xline are directories, 
  1389. X.I compress
  1390. Xwill descend into the directory and compress all the files it finds there.
  1391. X.PP
  1392. XThe
  1393. X.B \-V
  1394. Xflag tells each of these programs to print its version and patchlevel,
  1395. Xalong with any preprocessor flags specified during compilation, on
  1396. Xstderr before doing any compression or uncompression.
  1397. X.PP
  1398. X.I Compress
  1399. Xuses the modified Lempel-Ziv algorithm popularized in
  1400. X"A Technique for High Performance Data Compression",
  1401. XTerry A. Welch,
  1402. X.I "IEEE Computer,"
  1403. Xvol. 17, no. 6 (June 1984), pp. 8-19.
  1404. XCommon substrings in the file are first replaced by 9-bit codes 257 and up.
  1405. XWhen code 512 is reached, the algorithm switches to 10-bit codes and
  1406. Xcontinues to use more bits until the
  1407. Xlimit specified by the
  1408. X.B \-b
  1409. Xflag is reached (default 16).
  1410. X.I Bits
  1411. Xmust be between 9 and 16.  The default can be changed in the source to allow
  1412. X.I compress
  1413. Xto be run on a smaller machine.
  1414. X.PP
  1415. XAfter the
  1416. X.I bits
  1417. Xlimit is attained,
  1418. X.I compress
  1419. Xperiodically checks the compression ratio.  If it is increasing,
  1420. X.I compress
  1421. Xcontinues to use the existing code dictionary.  However,
  1422. Xif the compression ratio decreases,
  1423. X.I compress
  1424. Xdiscards the table of substrings and rebuilds it from scratch.  This allows
  1425. Xthe algorithm to adapt to the next "block" of the file.
  1426. X.PP
  1427. XNote that the
  1428. X.B \-b
  1429. Xflag is omitted for
  1430. X.I uncompress,
  1431. Xsince the 
  1432. X.I bits
  1433. Xparameter specified during compression
  1434. Xis encoded within the output, along with
  1435. Xa magic number to ensure that neither decompression of random data nor
  1436. Xrecompression of compressed data is attempted. 
  1437. X.PP
  1438. X.ne 8
  1439. XThe amount of compression obtained depends on the size of the
  1440. Xinput, the number of
  1441. X.I bits
  1442. Xper code, and the distribution of common substrings.
  1443. XTypically, text such as source code or English
  1444. Xis reduced by 50\-60%.
  1445. XCompression is generally much better than that achieved by
  1446. XHuffman coding (as used in
  1447. X.IR pack ),
  1448. Xor adaptive Huffman coding
  1449. X.RI ( compact ),
  1450. Xand takes less time to compute.
  1451. X.PP
  1452. XUnder the
  1453. X.B \-v
  1454. Xoption,
  1455. Xa message is printed yielding the percentage of
  1456. Xreduction for each file compressed.
  1457. X.PP
  1458. XExit status is normally 0;
  1459. Xif the last file is larger after (attempted) compression, the status is 2;
  1460. Xif an error occurs, exit status is 1.
  1461. X.SH "SEE ALSO"
  1462. Xpack(1), compact(1)
  1463. X.SH "DIAGNOSTICS"
  1464. XUsage: compress [\-dfvcVr] [\-b maxbits] [file ...]
  1465. X.in +8
  1466. XInvalid options were specified on the command line.
  1467. X.in -8
  1468. XMissing maxbits
  1469. X.in +8
  1470. XMaxbits must follow
  1471. X.BR \-b \.
  1472. X.in -8
  1473. X.IR file :
  1474. Xnot in compressed format
  1475. X.in +8
  1476. XThe file specified to
  1477. X.I uncompress
  1478. Xhas not been compressed.
  1479. X.in -8
  1480. X.IR file :
  1481. Xcompressed with 
  1482. X.I xx
  1483. Xbits, can only handle 
  1484. X.I yy
  1485. Xbits
  1486. X.in +8
  1487. X.I File
  1488. Xwas compressed by a program that could deal with
  1489. Xmore 
  1490. X.I bits
  1491. Xthan the compress code on this machine.
  1492. XRecompress the file with smaller
  1493. X.IR bits \.
  1494. X.in -8
  1495. X.IR file :
  1496. Xalready has .Z suffix -- no change
  1497. X.in +8
  1498. XThe file is assumed to be already compressed.
  1499. XRename the file and try again.
  1500. X.in -8
  1501. X.IR file :
  1502. Xfilename too long to tack on .Z
  1503. X.in +8
  1504. XThe file cannot be compressed because its name is longer than
  1505. X12 characters.
  1506. XRename and try again.
  1507. XThis message does not occur on BSD systems.
  1508. X.in -8
  1509. X.I file
  1510. Xalready exists; do you wish to overwrite (y or n)?
  1511. X.in +8
  1512. XRespond "y" if you want the output file to be replaced; "n" if not.
  1513. X.in -8
  1514. Xuncompress: corrupt input
  1515. X.in +8
  1516. XA SIGSEGV violation was detected which usually means that the input file has
  1517. Xbeen corrupted.
  1518. X.in -8
  1519. XCompression: 
  1520. X.I "xx.xx%"
  1521. X.in +8
  1522. XPercentage of the input saved by compression.
  1523. X(Relevant only for
  1524. X.BR \-v \.)
  1525. X.in -8
  1526. X-- not a regular file or directory: ignored
  1527. X.in +8
  1528. XWhen the input file is not a regular file or directory,
  1529. X(e.g. a symbolic link, socket, FIFO, device file), it is
  1530. Xleft unaltered.
  1531. X.in -8
  1532. X-- has 
  1533. X.I xx 
  1534. Xother links: unchanged
  1535. X.in +8
  1536. XThe input file has links; it is left unchanged.  See
  1537. X.IR ln "(1)"
  1538. Xfor more information. Use the
  1539. X.B \-f
  1540. Xflag to force compression of multiply-linked files.
  1541. X.in -8
  1542. X-- file unchanged
  1543. X.in +8
  1544. XNo savings is achieved by
  1545. Xcompression.  The input remains virgin.
  1546. X.in -8
  1547. X.SH "BUGS"
  1548. XAlthough compressed files are compatible between machines with large memory,
  1549. X.BR \-b \12
  1550. Xshould be used for file transfer to architectures with 
  1551. Xa small process data space (64KB or less, as exhibited by the DEC PDP
  1552. Xseries, the Intel 80286, etc.)
  1553. X.PP
  1554. XInvoking compress with a \-r
  1555. Xflag will occasionally cause it to produce spurious error warnings of the form
  1556. X.PP
  1557. X.in 8
  1558. X"<filename>.Z already has .Z suffix - ignored"
  1559. X.in -8
  1560. X.PP
  1561. XThese warnings can be ignored. See the comments in compress.c:compdir()
  1562. Xfor an explanation.
  1563. X
  1564. END_OF_FILE
  1565. if test 6484 -ne `wc -c <'compress.1'`; then
  1566.     echo shar: \"'compress.1'\" unpacked with wrong size!
  1567. fi
  1568. # end of 'compress.1'
  1569. fi
  1570. if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  1571.   echo shar: Will not clobber existing file \"'patchlevel.h'\"
  1572. else
  1573. echo shar: Extracting \"'patchlevel.h'\" \(76 characters\)
  1574. sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
  1575. Xstatic char    ident[] = "@(#)(N)compress 4.2.3";
  1576. X#define    version_id (ident+4)
  1577. END_OF_FILE
  1578. if test 76 -ne `wc -c <'patchlevel.h'`; then
  1579.     echo shar: \"'patchlevel.h'\" unpacked with wrong size!
  1580. fi
  1581. # end of 'patchlevel.h'
  1582. fi
  1583. if test -f 'zcmp' -a "${1}" != "-c" ; then 
  1584.   echo shar: Will not clobber existing file \"'zcmp'\"
  1585. else
  1586. echo shar: Extracting \"'zcmp'\" \(772 characters\)
  1587. sed "s/^X//" >'zcmp' <<'END_OF_FILE'
  1588. X:
  1589. X#!/bin/sh
  1590. X
  1591. XOPTIONS=
  1592. XFILES=
  1593. Xfor ARG
  1594. Xdo
  1595. X    case "$ARG" in
  1596. X    -*)    OPTIONS="$OPTIONS $ARG";;
  1597. X    *)    FILES="$FILES $ARG";;
  1598. X    esac
  1599. Xdone
  1600. Xif test -z "$FILES"; then
  1601. X    echo "Usage: zcmp [cmp_options] file [file]"
  1602. X    exit 1
  1603. Xfi
  1604. Xset $FILES
  1605. Xif test $# -eq 1; then
  1606. X    FILE=`expr $1 : '\(.*\)\.Z' '|' $1`
  1607. X    zcat $FILE | cmp $OPTIONS - $FILE
  1608. X    STAT="$?"
  1609. Xelif test $# -eq 2; then
  1610. X    case "$1" in
  1611. X    *.Z)    case "$2" in
  1612. X        *.Z)    F=`basename $2 .Z`
  1613. X            zcat $2 > /tmp/$F.$$
  1614. X            zcat $1 | cmp $OPTIONS - /tmp/$F.$$
  1615. X            STAT="$?";;
  1616. X        *)    zcat $1 | cmp $OPTIONS - $2;;
  1617. X        esac;;
  1618. X    *)    case "$2" in
  1619. X        *.Z)    F=`basename $2 .Z`
  1620. X            zcat $2 > /tmp/$F.$$
  1621. X            cmp $OPTIONS $1 /tmp/$F.$$
  1622. X            STAT="$?";;
  1623. X        *)    cmp $OPTIONS $1 $2
  1624. X            STAT="$?";;
  1625. X        esac;;
  1626. X    esac
  1627. X    exit "$STAT"
  1628. Xelse
  1629. X    echo "Usage: zcmp [cmp_options] file [file]"
  1630. X    exit 1
  1631. Xfi
  1632. END_OF_FILE
  1633. if test 772 -ne `wc -c <'zcmp'`; then
  1634.     echo shar: \"'zcmp'\" unpacked with wrong size!
  1635. fi
  1636. chmod +x 'zcmp'
  1637. # end of 'zcmp'
  1638. fi
  1639. if test -f 'zcmp.1' -a "${1}" != "-c" ; then 
  1640.   echo shar: Will not clobber existing file \"'zcmp.1'\"
  1641. else
  1642. echo shar: Extracting \"'zcmp.1'\" \(797 characters\)
  1643. sed "s/^X//" >'zcmp.1' <<'END_OF_FILE'
  1644. X.TH ZCMP 1
  1645. X.SH NAME
  1646. Xzcmp, zdiff \- compare compressed files
  1647. X.SH SYNOPSIS
  1648. X.B zcmp
  1649. X[ cmp_options ] file1
  1650. X[ file2 ]
  1651. X.br
  1652. X.B zdiff
  1653. X[ diff_options ] file1
  1654. X[ file2 ]
  1655. X.SH DESCRIPTION
  1656. X.I  Zcmp
  1657. Xand 
  1658. X.I zdiff
  1659. Xare used to invoke the
  1660. X.I cmp
  1661. Xor the
  1662. X.I diff
  1663. Xprogram on compressed files.  All options specified are passed directly to
  1664. X.I cmp
  1665. Xor
  1666. X.IR diff "."
  1667. XIf only 1 file is specified, then the files compared are
  1668. X.I file1
  1669. Xand an uncompressed
  1670. X.IR file1 ".Z."
  1671. XIf two files are specified, then they are uncompressed (if ending with ".Z")
  1672. Xand fed to
  1673. X.I cmp
  1674. Xor
  1675. X.IR diff "."
  1676. XThe exit status from 
  1677. X.I cmp
  1678. Xor
  1679. X.I diff
  1680. Xis preserved.
  1681. X.SH "SEE ALSO"
  1682. Xcmp(1), diff(1), zmore(1), zcat(1), compress(1), uncompress(1)
  1683. X.SH BUGS
  1684. XMessages from the
  1685. X.I cmp
  1686. Xor
  1687. X.I diff
  1688. Xprograms refer to temporary filenames instead of those specified.
  1689. END_OF_FILE
  1690. if test 797 -ne `wc -c <'zcmp.1'`; then
  1691.     echo shar: \"'zcmp.1'\" unpacked with wrong size!
  1692. fi
  1693. # end of 'zcmp.1'
  1694. fi
  1695. if test -f 'zdiff' -a "${1}" != "-c" ; then 
  1696.   echo shar: Will not clobber existing file \"'zdiff'\"
  1697. else
  1698. echo shar: Extracting \"'zdiff'\" \(736 characters\)
  1699. sed "s/^X//" >'zdiff' <<'END_OF_FILE'
  1700. X:
  1701. X#!/bin/sh
  1702. X
  1703. XOPTIONS=
  1704. XFILES=
  1705. Xfor ARG
  1706. Xdo
  1707. X    case "$ARG" in
  1708. X    -*)    OPTIONS="$OPTIONS $ARG";;
  1709. X    *)    FILES="$FILES $ARG";;
  1710. X    esac
  1711. Xdone
  1712. Xif test -z "$FILES"; then
  1713. X    echo "Usage: zdiff [diff_options] file [file]"
  1714. X    exit 1
  1715. Xfi
  1716. Xset $FILES
  1717. Xif test $# -eq 1; then
  1718. X    FILE=`expr $1 : '\(.*\)\.Z' '|' $1`
  1719. X    zcat $FILE | diff $OPTIONS - $FILE
  1720. X    STAT="$?"
  1721. Xelif test $# -eq 2; then
  1722. X    case "$1" in
  1723. X    *.Z)    case "$2" in
  1724. X        *.Z)    F=`basename $2 .Z`
  1725. X            zcat $2 > /tmp/$F.$$
  1726. X            zcat $1 | diff $OPTIONS - /tmp/$F.$$
  1727. X            STAT="$?";;
  1728. X        *)    zcat $1 | diff $OPTIONS - $2;;
  1729. X        esac;;
  1730. X    *)    case "$2" in
  1731. X        *.Z)    zcat $2 | diff $OPTIONS $1 -
  1732. X            STAT="$?";;
  1733. X        *)    diff $OPTIONS $1 $2
  1734. X            STAT="$?";;
  1735. X        esac;;
  1736. X    esac
  1737. X    exit "$STAT"
  1738. Xelse
  1739. X    echo "Usage: zdiff [diff_options] file [file]"
  1740. X    exit 1
  1741. Xfi
  1742. END_OF_FILE
  1743. if test 736 -ne `wc -c <'zdiff'`; then
  1744.     echo shar: \"'zdiff'\" unpacked with wrong size!
  1745. fi
  1746. chmod +x 'zdiff'
  1747. # end of 'zdiff'
  1748. fi
  1749. if test -f 'zmore' -a "${1}" != "-c" ; then 
  1750.   echo shar: Will not clobber existing file \"'zmore'\"
  1751. else
  1752. echo shar: Extracting \"'zmore'\" \(319 characters\)
  1753. sed "s/^X//" >'zmore' <<'END_OF_FILE'
  1754. X:
  1755. X#!/bin/sh
  1756. X
  1757. XFIRST=1
  1758. Xfor FILE
  1759. Xdo
  1760. X    if test $FIRST -eq 0; then
  1761. X        echo "--More--(Next file: $FILE)\c"
  1762. X        stty cbreak -echo
  1763. X        ANS=`dd bs=1 count=1 2>/dev/null` 
  1764. X        stty -cbreak echo
  1765. X        echo " "
  1766. X        if test "$ANS" = 'e'; then
  1767. X            exit
  1768. X        fi
  1769. X    fi
  1770. X    echo "------> $FILE <------"
  1771. X    zcat $FILE | more
  1772. X    if test -t; then
  1773. X        FIRST=0
  1774. X    fi
  1775. Xdone
  1776. END_OF_FILE
  1777. if test 319 -ne `wc -c <'zmore'`; then
  1778.     echo shar: \"'zmore'\" unpacked with wrong size!
  1779. fi
  1780. chmod +x 'zmore'
  1781. # end of 'zmore'
  1782. fi
  1783. if test -f 'zmore.1' -a "${1}" != "-c" ; then 
  1784.   echo shar: Will not clobber existing file \"'zmore.1'\"
  1785. else
  1786. echo shar: Extracting \"'zmore.1'\" \(3702 characters\)
  1787. sed "s/^X//" >'zmore.1' <<'END_OF_FILE'
  1788. X.TH ZMORE 1
  1789. X.SH NAME
  1790. Xzmore \- file perusal filter for crt viewing of compressed text
  1791. X.SH SYNOPSIS
  1792. X.B zmore
  1793. X[ name ...  ]
  1794. X.SH DESCRIPTION
  1795. X.I  Zmore
  1796. Xis a filter which allows examination of compressed text files
  1797. Xone screenful at a time on a soft-copy terminal.
  1798. XIt normally pauses after each screenful, printing --More--
  1799. Xat the bottom of the screen.
  1800. XIf the user then types a carriage return, one more line is displayed.
  1801. XIf the user hits a space,
  1802. Xanother screenful is displayed.  Other possibilites are enumerated later.
  1803. X.PP
  1804. X.I Zmore
  1805. Xlooks in the file
  1806. X.I /etc/termcap
  1807. Xto determine terminal characteristics,
  1808. Xand to determine the default window size.
  1809. XOn a terminal capable of displaying 24 lines,
  1810. Xthe default window size is 22 lines.
  1811. X.PP
  1812. XOther sequences which may be typed when
  1813. X.I zmore
  1814. Xpauses, and their effects, are as follows (\fIi\fP is an optional integer
  1815. Xargument, defaulting to 1) :
  1816. X.PP
  1817. X.IP \fIi\|\fP<space>
  1818. Xdisplay
  1819. X.I i
  1820. Xmore lines, (or another screenful if no argument is given)
  1821. X.PP
  1822. X.IP ^D
  1823. Xdisplay 11 more lines (a ``scroll'').
  1824. XIf
  1825. X.I i
  1826. Xis given, then the scroll size is set to \fIi\|\fP.
  1827. X.PP
  1828. X.IP d
  1829. Xsame as ^D (control-D)
  1830. X.PP
  1831. X.IP \fIi\|\fPz
  1832. Xsame as typing a space except that \fIi\|\fP, if present, becomes the new
  1833. Xwindow size.  Note that the window size reverts back to the default at the
  1834. Xend of the current file.
  1835. X.PP
  1836. X.IP \fIi\|\fPs
  1837. Xskip \fIi\|\fP lines and print a screenful of lines
  1838. X.PP
  1839. X.IP \fIi\|\fPf
  1840. Xskip \fIi\fP screenfuls and print a screenful of lines
  1841. X.PP
  1842. X.IP "q or Q"
  1843. Xquit reading the current file; go on to the next (if any)
  1844. X.PP
  1845. X.IP e
  1846. XWhen the prompt --More--(Next file: 
  1847. X.IR file )
  1848. Xis printed, this command causes zmore to exit.
  1849. X.PP 
  1850. X.IP =
  1851. XDisplay the current line number.
  1852. X.PP
  1853. X.IP \fIi\|\fP/expr
  1854. Xsearch for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP
  1855. XIf the pattern is not found,
  1856. X.I zmore
  1857. Xgoes on to the next file (if any).
  1858. XOtherwise, a screenful is displayed, starting two lines before the place
  1859. Xwhere the expression was found.
  1860. XThe user's erase and kill characters may be used to edit the regular
  1861. Xexpression.
  1862. XErasing back past the first column cancels the search command.
  1863. X.PP
  1864. X.IP \fIi\|\fPn
  1865. Xsearch for the \fIi\|\fP-th occurrence of the last regular expression entered.
  1866. X.PP
  1867. X.IP !command
  1868. Xinvoke a shell with \fIcommand\|\fP. 
  1869. XThe character `!' in "command" are replaced with the
  1870. Xthe previous shell command.  The sequence "\\!" is replaced by "!".
  1871. X.PP
  1872. X.IP ":q or :Q"
  1873. Xquit reading the current file; go on to the next (if any)
  1874. X(same as q or Q).
  1875. X.PP
  1876. X.IP .
  1877. X(dot) repeat the previous command.
  1878. X.PP
  1879. XThe commands take effect immediately, i.e., it is not necessary to
  1880. Xtype a carriage return.
  1881. XUp to the time when the command character itself is given,
  1882. Xthe user may hit the line kill character to cancel the numerical
  1883. Xargument being formed.
  1884. XIn addition, the user may hit the erase character to redisplay the
  1885. X--More-- message.
  1886. X.PP
  1887. XAt any time when output is being sent to the terminal, the user can
  1888. Xhit the quit key (normally control\-\\).
  1889. X.I Zmore
  1890. Xwill stop sending output, and will display the usual --More--
  1891. Xprompt.
  1892. XThe user may then enter one of the above commands in the normal manner.
  1893. XUnfortunately, some output is lost when this is done, due to the
  1894. Xfact that any characters waiting in the terminal's output queue
  1895. Xare flushed when the quit signal occurs.
  1896. X.PP
  1897. XThe terminal is set to
  1898. X.I noecho
  1899. Xmode by this program so that the output can be continuous.
  1900. XWhat you type will thus not show on your terminal, except for the / and !
  1901. Xcommands.
  1902. X.PP
  1903. XIf the standard output is not a teletype, then
  1904. X.I zmore
  1905. Xacts just like
  1906. X.I zcat,
  1907. Xexcept that a header is printed before each file.
  1908. X.SH FILES
  1909. X.DT
  1910. X/etc/termcap        Terminal data base
  1911. X.SH "SEE ALSO"
  1912. Xmore(1), zcat(1), compress(1), uncompress(1)
  1913. END_OF_FILE
  1914. if test 3702 -ne `wc -c <'zmore.1'`; then
  1915.     echo shar: \"'zmore.1'\" unpacked with wrong size!
  1916. fi
  1917. # end of 'zmore.1'
  1918. fi
  1919. echo shar: End of archive 1 \(of 2\).
  1920. cp /dev/null ark1isdone
  1921. MISSING=""
  1922. for I in 1 2 ; do
  1923.     if test ! -f ark${I}isdone ; then
  1924.     MISSING="${MISSING} ${I}"
  1925.     fi
  1926. done
  1927. if test "${MISSING}" = "" ; then
  1928.     echo You have unpacked both archives.
  1929.     rm -f ark[1-9]isdone
  1930. else
  1931.     echo You still need to unpack the following archives:
  1932.     echo "        " ${MISSING}
  1933. fi
  1934. ##  End of shell archive.
  1935. exit 0
  1936. exit 0 # Just in case...
  1937.