compress.c File Reference

#include <limits.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <ctype.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include <stdio.h>

Include dependency graph for compress.c:

Go to the source code of this file.

Defines

#define AZTEC86   1
#define min(a, b)   ((a>b) ? b : a)
#define SACREDMEM   0
#define USERMEM   450000
#define REGISTER   register
#define DOTZ   ".Z"
#define DEFAULTBITS   13
#define BITS   16
#define PBITS   16
#define HSIZE   69001
#define BIT_MASK   0x1f
#define BLOCK_MASK   0x80
#define INIT_BITS   9
#define ARGVAL()   (*++(*argv) || (--argc && *++argv))
#define MAXCODE(n_bits)   ((1 << (n_bits)) - 1)
#define HTABSIZE   ((size_t)(HSIZE*sizeof(count_int)))
#define CODETABSIZE   ((size_t)(HSIZE*sizeof(unsigned short)))
#define htabof(i)   htab[i]
#define codetabof(i)   codetab[i]
#define tab_prefixof(i)   codetabof(i)
#define tab_suffixof(i)   ((char_type *)(htab))[i]
#define de_stack   ((char_type *)&tab_suffixof(1<<BITS))
#define CHECK_GAP   10000
#define FIRST   257
#define CLEAR   256

Typedefs

typedef long int code_int
typedef long int count_int
typedef unsigned char char_type

Functions

 _PROTOTYPE (int main,(int argc, char **argv))
 _PROTOTYPE (void Usage,(void))
 _PROTOTYPE (void onintr,(int dummy))
 _PROTOTYPE (void output,(code_int code))
 _PROTOTYPE (int foreground,(void))
 _PROTOTYPE (code_int getcode,(void))
 _PROTOTYPE (void copystat,(char *ifname, char *ofname))
 _PROTOTYPE (void cl_hash,(count_int hsize))
 _PROTOTYPE (void prratio,(FILE *stream, long int num, long int den))
void Usage ()
int main (int argc, char **argv)
void compress ()
void output (code_int code)
void decompress ()
code_int getcode ()
void writeerr ()
void copystat (char *ifname, char *ofname)
int foreground ()
void onintr (int dummy)
void oops (int dummy)
void cl_block ()
void cl_hash (REGISTER count_int hsize)
void prratio (FILE *stream, long int num, long int den)
void version ()

Variables

char_type magic_header [] = "\037\235"
int n_bits
int maxbits = DEFAULTBITS
code_int maxcode
code_int maxmaxcode = 1 << BITS
count_inthtab
unsigned short * codetab
code_int hsize = HSIZE
count_int fsize
code_int free_ent = 0
int exit_stat = 0
int nomagic = 0
int zcat_flg = 0
int quiet = 0
int block_compress = BLOCK_MASK
int clear_flg = 0
long int ratio = 0
count_int checkpoint = CHECK_GAP
int force = 0
char ofname [100]
void(* bgnd_flag )()
int do_decomp = 0
static int offset
long int in_count = 1
long int bytes_out
long int out_count = 0
static char buf [BITS]
char_type lmask [9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00}
char_type rmask [9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}


Define Documentation

 
#define ARGVAL  )     (*++(*argv) || (--argc && *++argv))
 

Definition at line 172 of file compress.c.

Referenced by main().

#define AZTEC86   1
 

Definition at line 52 of file compress.c.

#define BIT_MASK   0x1f
 

Definition at line 154 of file compress.c.

#define BITS   16
 

Definition at line 83 of file compress.c.

#define BLOCK_MASK   0x80
 

Definition at line 155 of file compress.c.

#define CHECK_GAP   10000
 

Definition at line 258 of file compress.c.

Referenced by cl_block(), and compress().

#define CLEAR   256
 

Definition at line 265 of file compress.c.

#define codetabof i   )     codetab[i]
 

Definition at line 195 of file compress.c.

Referenced by compress().

#define CODETABSIZE   ((size_t)(HSIZE*sizeof(unsigned short)))
 

Definition at line 191 of file compress.c.

Referenced by main().

#define de_stack   ((char_type *)&tab_suffixof(1<<BITS))
 

Definition at line 215 of file compress.c.

#define DEFAULTBITS   13
 

Definition at line 79 of file compress.c.

#define DOTZ   ".Z"
 

Definition at line 73 of file compress.c.

#define FIRST   257
 

Definition at line 264 of file compress.c.

Referenced by chkdev(), cl_block(), compress(), getone(), and markzone().

#define HSIZE   69001
 

Definition at line 114 of file compress.c.

#define htabof i   )     htab[i]
 

Definition at line 194 of file compress.c.

Referenced by compress().

#define HTABSIZE   ((size_t)(HSIZE*sizeof(count_int)))
 

Definition at line 190 of file compress.c.

Referenced by main().

#define INIT_BITS   9
 

Definition at line 159 of file compress.c.

Referenced by compress(), decompress(), getcode(), and output().

#define MAXCODE n_bits   )     ((1 << (n_bits)) - 1)
 

Definition at line 181 of file compress.c.

Referenced by compress(), decompress(), getcode(), and output().

#define min a,
b   )     ((a>b) ? b : a)
 

Definition at line 54 of file compress.c.

#define PBITS   16
 

Definition at line 88 of file compress.c.

#define REGISTER   register
 

Definition at line 72 of file compress.c.

Referenced by cl_block(), cl_hash(), compress(), decompress(), getcode(), output(), and prratio().

#define SACREDMEM   0
 

Definition at line 65 of file compress.c.

#define tab_prefixof i   )     codetabof(i)
 

Definition at line 209 of file compress.c.

Referenced by decompress().

#define tab_suffixof i   )     ((char_type *)(htab))[i]
 

Definition at line 214 of file compress.c.

Referenced by decompress().

#define USERMEM   450000
 

Definition at line 69 of file compress.c.


Typedef Documentation

typedef unsigned char char_type
 

Definition at line 149 of file compress.c.

typedef long int code_int
 

Definition at line 134 of file compress.c.

typedef long int count_int
 

Definition at line 143 of file compress.c.


Function Documentation

_PROTOTYPE void  prratio,
(FILE *stream, long int num, long int den) 
 

_PROTOTYPE void  cl_hash,
(count_int hsize
 

_PROTOTYPE void  copystat,
(char *ifname, char *ofname
 

_PROTOTYPE code_int  getcode,
(void) 
 

_PROTOTYPE int  foreground,
(void) 
 

_PROTOTYPE void  output,
(code_int code
 

_PROTOTYPE void  onintr,
(int dummy) 
 

_PROTOTYPE void  Usage,
(void) 
 

_PROTOTYPE int  main,
(int argc, char **argv) 
 

void cl_block  ) 
 

Definition at line 1459 of file compress.c.

References CHECK_GAP, checkpoint, cl_hash(), CLEAR, clear_flg, debug, FIRST, fprintf(), output, prratio(), ratio, REGISTER, and verbose.

Referenced by compress().

void cl_hash REGISTER count_int  hsize  ) 
 

Definition at line 1501 of file compress.c.

References htab, j, k, m1, memset(), and REGISTER.

Referenced by cl_block(), and compress().

void compress  ) 
 

Definition at line 740 of file compress.c.

References block_compress, c, CHECK_GAP, checkpoint, cl_block(), cl_hash(), clear_flg, codetabof, EOF, ferror, FIRST, free_ent, getc, hsize, htabof, i, INIT_BITS, L, long(), magic_header, maxbits, MAXCODE, maxcode, maxmaxcode, n_bits, nomagic, output, putc, ratio, REGISTER, stdin, stdout, and writeerr().

void copystat char *  ifname,
char *  ofname
 

Definition at line 1347 of file compress.c.

References chmod, chown, close, do_decomp, exit_stat, fflush(), fileno(), force, fprintf(), ofname, perror(), quiet, S_IFMT, S_IFREG, stat::st_atime, stat::st_gid, stat::st_mode, stat::st_mtime, stat::st_nlink, stat::st_uid, stat, stdout, time_t, timep, unlink, and utime.

void decompress  ) 
 

Definition at line 1034 of file compress.c.

References INIT_BITS, MAXCODE, maxcode, n_bits, REGISTER, stackp, tab_prefixof, and tab_suffixof.

Referenced by main().

int foreground  ) 
 

Definition at line 1424 of file compress.c.

References bgnd_flag, and isatty.

code_int getcode  ) 
 

Definition at line 1126 of file compress.c.

References bits, BITS, bp, clear_flg, fread(), free_ent, INIT_BITS, maxbits, MAXCODE, maxcode, maxmaxcode, n_bits, REGISTER, size, and stdin.

int main int  argc,
char **  argv
 

Definition at line 289 of file compress.c.

References ARGVAL, atoi, bgnd_flag, codetab, CODETABSIZE, cp, debug, DEBUG, exit(), fprintf(), htab, HTABSIZE, malloc(), maxbits, nextarg(), NULL, overwrite(), SIG_IGN, SIGINT, signal(), SIGSEGV, stderr, stdin, stdout, strcmp, strrchr(), tempname, Usage(), and version.

void onintr int  dummy  ) 
 

Definition at line 1441 of file compress.c.

References exit(), ofname, SIG_IGN, SIGINT, signal(), and unlink.

void oops int  dummy  ) 
 

Definition at line 1449 of file compress.c.

References do_decomp, exit(), fprintf(), ofname, SIG_IGN, signal(), SIGSEGV, and unlink.

void output code_int  code  ) 
 

Definition at line 887 of file compress.c.

References bits, bp, clear_flg, col(), debug, ferror, fflush(), fprintf(), free_ent, fwrite(), INIT_BITS, maxbits, MAXCODE, maxcode, maxmaxcode, n_bits, putc, REGISTER, stderr, stdout, verbose, and writeerr().

void prratio FILE stream,
long int  num,
long int  den
 

Definition at line 1565 of file compress.c.

References fprintf(), int(), L, putc, and REGISTER.

Referenced by cl_block().

void Usage  ) 
 

Definition at line 238 of file compress.c.

References fprintf(), and stderr.

void version  ) 
 

Definition at line 1586 of file compress.c.

References BITS, and fprintf().

void writeerr  ) 
 

Definition at line 1340 of file compress.c.

References exit(), ofname, perror(), and unlink.

Referenced by compress(), and output().


Variable Documentation

void(* bgnd_flag)()
 

Definition at line 280 of file compress.c.

Referenced by foreground(), and main().

int block_compress = BLOCK_MASK
 

Definition at line 255 of file compress.c.

Referenced by compress().

char buf[BITS] [static]
 

Definition at line 881 of file compress.c.

long int bytes_out
 

Definition at line 721 of file compress.c.

count_int checkpoint = CHECK_GAP
 

Definition at line 259 of file compress.c.

Referenced by cl_block(), and compress().

int clear_flg = 0
 

Definition at line 256 of file compress.c.

Referenced by cl_block(), compress(), getcode(), and output().

unsigned short* codetab
 

Definition at line 189 of file compress.c.

Referenced by main().

int do_decomp = 0
 

Definition at line 286 of file compress.c.

Referenced by copystat(), and oops().

int exit_stat = 0
 

Definition at line 219 of file compress.c.

Referenced by copystat().

int force = 0
 

Definition at line 267 of file compress.c.

code_int free_ent = 0
 

Definition at line 218 of file compress.c.

Referenced by compress(), getcode(), and output().

count_int fsize
 

Definition at line 198 of file compress.c.

Referenced by sendfile().

code_int hsize = HSIZE
 

Definition at line 197 of file compress.c.

Referenced by compress().

count_int* htab
 

Definition at line 188 of file compress.c.

Referenced by cl_hash(), and main().

long int in_count = 1
 

Definition at line 720 of file compress.c.

Referenced by diskio().

char_type lmask[9] = {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00}
 

Definition at line 884 of file compress.c.

Referenced by inflate_fast().

char_type magic_header[] = "\037\235"
 

Definition at line 151 of file compress.c.

Referenced by compress().

int maxbits = DEFAULTBITS
 

Definition at line 175 of file compress.c.

Referenced by compress(), getcode(), main(), and output().

code_int maxcode
 

Definition at line 176 of file compress.c.

Referenced by compress(), decompress(), getcode(), and output().

code_int maxmaxcode = 1 << BITS
 

Definition at line 177 of file compress.c.

Referenced by compress(), getcode(), and output().

int n_bits
 

Definition at line 174 of file compress.c.

Referenced by compress(), decompress(), getcode(), and output().

int nomagic = 0
 

Definition at line 247 of file compress.c.

Referenced by compress().

int offset [static]
 

Definition at line 719 of file compress.c.

char ofname[100]
 

Definition at line 268 of file compress.c.

Referenced by copystat(), encode(), main(), makename(), onintr(), oops(), and writeerr().

long int out_count = 0
 

Definition at line 722 of file compress.c.

int quiet = 0
 

Definition at line 249 of file compress.c.

Referenced by copystat().

long int ratio = 0
 

Definition at line 257 of file compress.c.

Referenced by cl_block(), compress(), do_extract_currentfile(), and do_list().

char_type rmask[9] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}
 

Definition at line 885 of file compress.c.

int zcat_flg = 0
 

Definition at line 248 of file compress.c.


Generated on Fri Apr 14 23:00:06 2006 for minix by  doxygen 1.4.6