[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference hydra::amiga_v1

Title:AMIGA NOTES
Notice:Join us in the *NEW* conference - HYDRA::AMIGA_V2
Moderator:HYDRA::MOORE
Created:Sat Apr 26 1986
Last Modified:Wed Feb 05 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:5378
Total number of notes:38326

724.0. "COMPRESS program" by COOKIE::WECKER (A wholly owned subsidiary of DEC) Sat Sep 19 1987 12:20

I got tired of several things:

    1)	Waiting all the time for ARC to do its bit (I run off of KICKBENCH
	with a fully compressed C: directory) when uploading to VD0:

    2)	Having to keep a program as LARGE as ARC around.

    3)	Creating giant ARC files that were too big to manipulate (along with
	ARCs of ARCs).

So I've made available COMPRESS. This is a stripped down version of the PD
COMPRESS used on U**X systems. It will run on VMS/U**X/AMIGA. It is small
(about 10k on the Amiga). It is fast (about 4 times faster than ARC). It uses
full LZW compression so it is equivalent in packing density to ARC. It will
only do single files (this is NOT meant as a replacement for ARC, it is just a
convienient packing program for when you don't want to use ARC.

I've also gotton rid of most of the switches. The program is in:

    COOKIE""::DISK$GZ_2:[WECKER.AMIGA]COMPRESS.ARC  - source and executeable
				      COMPRESS.C    - source

If you want to try it on VMS do:

    $ CC COMPRESS
    $ LINK COMPRESS,SYS$LIBRARY:VAXCRTL/LIB
    $ COMPRESS :== $SYS$DISK:[]COMPRESS

One file option:

    $ compress compress.c			! compresses the source
    $ compress compress.c_z			! decompress the source

Two file option:

    $ compress compress.c foo.comp		! compresses into foo.comp
    $ compress -d foo.comp compress.c		! decompress from foo.com


It will also compress/decompress from/to stdin/stdout so you can do things
like:

    $ arc x foo foo.c | compress >foo.c.z

provided of course you have things like pipes and redirection. Here are
the comments from the source file:

/***************************************************************************
 * compress.c - File compression ala IEEE Computer, June 1984.
 *
 * Algorithm from "A Technique for High Performance Data Compression",
 * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19.
 *
 * Usage: compress [-d] [ifile] [ofile]
 * Switches:
 *	-d:	    If given, decompression is done instead.
 * Files:
 *	none	    if -d switch then decompress stdin to stdout
 *		    else              compresses stdin to stdout
 *	1	    if -d switch then     decompress   to stdout
 *		    else if ending  in .Z decompresses to file without .Z
 *		    else if not end in .Z compresses   to file with    .Z
 *      2           compresses or decompresses files according to -d switch
 * Notes:
 *	The actual extension can be either .Z for .z (case is folded)
 *	On VMS the extension searched/created is _Z instead of .Z
 *
 * Algorithm:
 * 	Modified Lempel-Ziv method (LZW).  Basically finds common
 * substrings and replaces them with a variable size code.  This is
 * deterministic, and can be done on the fly.  Thus, the decompression
 * procedure needs no input table, but tracks the way the table was built.
 *
 * Authors:	Spencer W. Thomas	(decvax!harpo!utah-cs!utah-gr!thomas)
 *		Jim McKie		(decvax!mcvax!jim)
 *		Steve Davies		(decvax!vax135!petsd!peora!srd)
 *		Ken Turkowski		(decvax!decwrl!turtlevax!ken)
 *		James A. Woods		(decvax!ihnp4!ames!jaw)
 *		Joe Orost		(decvax!vax135!petsd!joe)
 *              Dave Wecker             (decvax!decwrl!cookie.dec.com!wecker)
 *
 ***************************************************************************/

Enjoy!
dave

T.RTitleUserPersonal
Name
DateLines
724.1patches already?COOKIE::WECKERA wholly owned subsidiary of DECSat Sep 19 1987 15:0923
re:	.0

I know.. I little quick for patches but:

	1)	I've increased the code size from 12 to 13 bits. This
		gives about a 5% decrease in storage size.

	2)	If you only use one argument, the input file will be
		deleted after compress/decompress (just like the U**X
		version). For example if you want to decompress an
		entire directory (using Steve's Shell) you could say:

		$ foreach f ( *.Z ) compress $f

	3)	It now prints out better messages.

dave

P.S.	Theoretically the number of bits/code can go as high as 16 but
	the hash table size grows exponentially and when I go over 13
	I start crashing with address errors.. so for now this is it
	(still better than ARC).

724.2Does it work with existing tool?NAC::PLOUFFLANsman WesWed Sep 23 1987 17:402
    Is this program compatible with the programs LZCOMP and LZDCMP
    available from the VMS toolshed?
724.3LZ... should workMAY20::MINOWJe suis Marxist, tendance GrouchoThu Sep 24 1987 19:4213
LZCOMP and LZDCMP are reimplementations of Unix compress.  They have
a Unix compatibility mode that can read and write a format generally
acceptable to Unix compress.  There is one incompatibility: LZCOMP
writes an end-of-file marker on the file that *may* result in an extra
<NUL> byte being added to the file when Unix compress decompresses it.
(This is needed when you run LZCOMP on RSTS/E or RT11 where files fill
the last block.)

Assuming the author of .0 hasn't changed the header, files should
be interchangable.  Also, you should be able to bring up LZCOMP
and LZDCMP on an Amiga.  Sources are in the Toolshed.

Martin.
724.4COOKIE::WECKERA wholly owned subsidiary of DECThu Sep 24 1987 20:236
re:	.3

I have NOT changed the headers...

dave

724.5COOKIE::WECKERA wholly owned subsidiary of DECSat Sep 26 1987 13:1714
re:	.0-.3

I have put a new version in: COOKIE::DISK$GZ_2:[WECKER.AMIGA]COMPRESS.*

What I did was add a new switch (just like U**X compress):

	-b maxbits	- number of bits to build hash with.

The defaults on the VAX are still 16 bits and 13 bits on the Amiga. However,
now if you compress something on the VAX at 13 bits (-b 13) it will decompress
fine on the Amiga (fast downloads of single files).

Note: you never have to use the -b switch on decompresses since the header
tells compress how the file was crunched.
724.6AUTHOR::MACDONALDWA1OMM Listening 224.28Thu Oct 15 1987 11:467
    Won't accept wildcards?
    
    COMPRESS *
    
    Gives the error message "Two many files."
    
    Surely you meant "Too many ..."
724.7It does what it's supposed to doCOOKIE::WECKERA wholly owned subsidiary of DECThu Oct 15 1987 15:2318
re:	.-1

no... the message is correct. Since the program figures out what you want
by how many filenames are given to it (1 = work in place, 2 = create new) then
anything more than 2 filename will cause it to say `sorry charlie'

COMPRESS is designed to work on 1 file at a time. If you want to do multiples
do what I do, create a shell aliases for:

	cmpdir	- compress directory (any file NOT ending in .Z gets compressed)
	uncdir	- uncompress dir (any file ending in .Z is uncompressed)
	cmplst	- compress list of files (your compress *)
	unclst	- adds .Z to names it is given and then uncompresses these files

``The actual aliases are left as an exercise to the reader''

dave

724.8MPGS::BAEDERThu Oct 15 1987 20:237
    i don't know...exercises...reminds me of when I taught school...the
    students never liked that type of "exercise"  ;-)
    
    thanks for a great laugh at the end of a hard day.
    
    scott.
    
724.9the answer is in the back of the bookCOOKIE::WECKERA wholly owned subsidiary of DECFri Oct 16 1987 13:258
re:	.8

That WAS a joke (for those who didn't realize it.... :-) when I upload my
.login script this weekend it has all of thoses aliases in it..

what me worry?
dave