home *** CD-ROM | disk | FTP | other *** search
- UCOMPBTM 4dos compressed .BTM decompressor
- Copyright (C) 1933 Christopher Hall
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program, as the file COPYING.DOC; if not, write to the
- Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- I may be contacted by e-mail as cah17@phx.cam.ac.uk, or by paper mail at
- Christ's College, Cambridge, CB2 3BU, England
-
-
- What is UCOMPBTM?
- ~~~~~~~~~~~~~~~~~
- UCOMPBTM is a program to decompress compressed .BTM batch files made by 4dos
- version 5.0 and above. 4dos is a commercial replacement for COMMAND.COM made
- by JP Software Inc. As of version 5, it has had an option to compress its
- batch files, using the BATCOMP external program supplied with 4dos. However,
- no way of decompressing these files is provided, which would normally mean
- wasting any disk space you would otherwise have saved, on storing the original
- file. This program solves that problem.
-
- Usage
- ~~~~~
- UCOMPBTM has a very similar syntax to BATCOMP, and is designed to work in as
- similar a way as possible, while still providing full functionality. The full
- syntax is
-
- UCOMPBTM [[/O] input-file [output-file]]
-
- where the square brackets denote optional items.
-
- If no parameters are specified, then UCOMPBTM will decompress standard input,
- and write the result to standard output. Copyright and status messages are
- printed to the error output, so that they won't interfere with the output file.
- If you're running UCOMPBTM under 4dos, then you can use >&>NUL to dispose of
- this output. This option is provided so that you can view a compressed file
- without having to make a permanent decompressed copy. For example, use the
- command
-
- UCOMPBTM < comprssd.btm | more
-
- to view the uncompressed source for comprssd.btm.
-
- The other way of using UCOMPBTM is the same as the way BATCOMP is used. Here,
- the input file is compressed, and written to the output file. If no output
- file is specified, then the input filename will be used, but with its extension
- changed to .BAT. The /O switch allows overwriting of an existing file. Note
- that, as with BATCOMP, wildcards are not allowed. For this, you should
- probably use the FOR command.
-
- Compressed file format
- ~~~~~~~~~~~~~~~~~~~~~~
- The format of compressed files is quite simple.
-
- To start with, there's a 2 byte header, which should consist of the bytes EB
- and BE (in hex). This is the signal to 4dos that it's dealing with a
- compressed file.
-
- Then comes the number of characters in the original file, where line breaks are
- treated as just one character.
-
- Next, come the 30 most used characters in the original batch file, where line
- breaks are treated as just an 0D. Number these from 02 to 1F. (This numbering
- will make sense later). If there aren't this many distinct characters in
- the file, anything can go in the remaining slots.
-
- Now comes the compressed data itself. This consists of a series of nibbles (4
- bits, or one hex digit), with the high nibble in each byte being dealt with
- first. This is interpreted as follows:
- - A nibble of 0 means that the next 2 nibbles are the low and high nibbles
- (respectively) of the next uncompressed byte. This is used if the character
- isn't one of the most common 30. Again, 0D stands for 0D,0A as a line break.
- - A nibble of 1 means that the next nibble will be added to 10 (hex) to create
- the number of a common character from 10 to 1F
- - A nibble of 2 to F is one of the 14 most common characters, numbers 2 to F in
- the table.
-
- This repeats until the end of the file, with a 0 being used to pad at the end
- if an odd number of nibbles is needed. The length word is another way of
- detecting this situation.
-