From uunet!zaphod.mps.ohio-state.edu!rpi!clarkson!grape.ecs.clarkson.edu!nelson Sat Nov 17 08:36:29 EST 1990
Article 2369 of alt.sources:
Path: cos!uunet!zaphod.mps.ohio-state.edu!rpi!clarkson!grape.ecs.clarkson.edu!nelson
>From: nelson@sun.soe.clarkson.edu (Russ Nelson)
Newsgroups: alt.sources
Subject: code for reading from .?Q? files
Message-ID: <NELSON.90Nov15100004@image.clarkson.edu>
Date: 15 Nov 90 15:00:04 GMT
References: <1422@tharr.UUCP>
Sender: @grape.ecs.clarkson.edu
Reply-To: nelson@clutx.clarkson.edu (aka NELSON@CLUTX.BITNET)
Distribution: alt
Organization: Clarkson University, Potsdam NY
Lines: 561
In-Reply-To: gtoal@tharr.UUCP's message of 15 Nov 90 00:59:40 GMT
Status: OR

In article <1422@tharr.UUCP> gtoal@tharr.UUCP (Graham Toal) writes:

   This posting consists of a set of routines which roughly simulate
   fopen, fgetc, fgets, and fclose.  The difference between these and
   the originals is that these will read data from a .Z compressed
   file, decompressing it on the fly.  It does *not* uses pipes,
   processes, or intermediate files.  This makes it useful to add to
   any programs which read large text files sequentially.

I had a very similar need, except that I needed to SEEK also.  With
compress, this is a problem.  But with Huffman encoding, seeking isn't
a problem, so long as you seek to a bit boundary rather than a byte
boundary.

Since other people may need to seek into squeezed files, here's my
version.  It reads files produced in the format of the "SQ" standard
first seen on CP/M.  It's derived from
simtel20.army.mil:pd1:<unix-c.cpm>xsq.tar-z, and is kind of useless
without it, because you need to modify xsq.c or xusq.c to convince it to tell
you the code offsets.  I've enclosed my xusqi.c program, which looks
through a specially formatted-file (seven-line records), and maps a byte
offset into the original file into a bit offset into the squeezed file.

This code has been written for MSDOS, but should be portable to Unix.

