SPLAY(1)

NAME
splay, unsplay - compress and uncompress data

SYNOPSIS
splay [ -c ] [ -f ] [ -n ] [ -v ] [ -s states ] [ filename ] [ -k keyfile ] [ -p password ]
unsplay [ -c ] [ -f ] [ -n ] [ filename ] [ -k keyfile ] [ -p password ]

DESCRIPTION
Splay reduces the size of filename using prefix codes derived from a binary splay tree. Whenever possible, the file is replaced by one with the extension .S. If no files are specified, the standard input is compressed to the standard output. Compressed files with names ending in .S can be restored to their original form using unsplay. Splay/unsplay can also be used as a filter.

The -c (``cat'') option makes splay/unsplay write to the standard output; no other files are changed or deleted. If used, -c must be specified before all other arguments except -f, -n, and -v.

The -f option will force the compression or uncompression of the input file, even if it does not actually shrink, or the corresponding output file already exists. If -f is not given the user is prompted as to whether an existing file should be overwritten and the splay command will fail if the compressed file is larger than the original. In case of failure, the output file is deleted and the input file is left unchanged. -f must be specified before filename.

By default, splay/unsplay will delete the input file. The -n option suppresses this.

The -v option causes the printing of the percentage reduction of the input file. It also prints the number of bytes used to create the splay tree(s).

Splay uses the splay prefix algorithm first presented in "Applications of Splay Trees to Data Compression", D.W. Jones, Communication of the ACM, August 1988, pages 996-1007. A balanced splay tree is first constructed by the program. As each character is pulled from the input text, it is assigned a binary prefix code derived by following the path from the root to the proper leaf. At each compression, the tree is semi-splayed in such a way that the distance from the root to the leaf is shortened. In this way, the most frequently used characters acquire the shortest codes.

By default, splay/unsplay uses a Markov compression algorithm which associates a splay tree with each of 32 states (unless encryption is requested, in which case the default is 1). The number of states can be changed by the -s option, followed by the desired number of states (1 - 256). When compressing a character, the state used is determined by the previous character divided by the total number of states. For 64K machines, no more than 20 states are recommended; for text, more than 32 states usually leads to little improvement, but about 100 states is sufficient to compete with the UNIX compress command. Digitized images can frequently be compressed better than compress command with only 1 state.

Splay can be used for data encryption. By using the -p option, the user may specify a password to be used as an encryption key. The -k option may be specified to enable the program to use a file to hold the encryption key. Before compressing or uncompressing the input, the initial tree used for data compression is semi-splayed about each byte of the key, thus making it very difficult to recover the compressed data without knowledge of the key. Any number of -p or -k options may be used; if multiple keys are specified, they will be concatenated in the order specified. The -p and -k options must be specified after the filename, if any is given.

Any time an encryption key is specified, splay prefixes several random bytes to the source file in order to complicate known-text attacks. These bytes are automatically discarded by unsplay. If a key is specified, splay will retain the output even if it is larger than the input.

DIAGNOSTICS
Error: bad -x argument Usage: splay/unsplay [-c] [-f] [-n] [-v] [-s states] [filename] [-k keyfile] [-p password]
Invalid options were specified on the command line. -c must precede all other arguments. Keys must be specified after filename. -s must be specified before keys.
Error: splay/unsplay can't open filename
Unable to open this file. File does not exist, or is inaccessible.
Error: filename is not in splayed format
Unsplay cannot unsplay the file, because it has not been splayed. All splayed files are given the magic number ^S^P.
Error: corrupt input in filename
Either the file has been encrypted and the proper decoding key has not been entered, or the splayed data has been changed or ruined.
Error: cannot splay/unsplay filename:.S suffix expected
Input file is required to have a .S suffix for unsplay to be able to use it.
Error: filename could not be compressed
Splay was unable to produce a smaller file.
Error: too many arguments
More than one filename has been specified or number of states specified is in conflict with a previous setting.
Error: -s x not in bounds of 1 to 256
The number of states is not within the range 1 - 256.

SEE ALSO
crypt(1), compress(1), uncompress(1), zcat(1)

BUGS
As with most encryption algorithms, we cannot ensure the security of the encrypted result. As of this writing (February 20, 1989), we know nothing about deciphering encrypted text produced using splay trees. In the short run, this may provide a small degree of security, but in the long run, it should only reinforce the insecurity of using this method.

For all of the text we have compressed and uncompressed, the output of the unsplay program has been the same as the original input to the splay program, but we cannot warrant that this will be the case for files we have not tried.

Unlike compress and uncompress, this package makes no effort to preserve the ownership modes, access times, and modification times of the files processed. This package will compress or uncompress only one file at a time.

AUTHORS
Douglas W. Jones and Jeffrey E. Chilton