📄 compress.h
字号:
#define TITLE "$@(#) compress.h,v 4.3d 90/01/18 03:00:00 don Release ^"
#ifndef FALSE /* let's get some sense to this */
#define FALSE 0
#define TRUE !FALSE
#endif
#define SIGNAL_ERROR -1 /* signal function error */
#define NOMEM -2 /* Ran out of memory */
#define TOKTOOBIG -3 /* Token longer than MAXTOKLEN chars */
#define READERR -4 /* I/O error on input */
#define WRITEERR -5 /* I/O error on output */
#define INFILEBAD -6 /* Infile not in compressed format */
#define CODEBAD -7 /* Infile contained a bad token code */
#define TABLEBAD -8 /* The tables got corrupted (!) */
#define NOSAVING -9 /* no saving in file size */
#define NOTOPENED -10 /* output file couldn't be opened */
#define YES 1
#define NO 0
#define OK 0
#ifndef DEBUG /* some convoluted defines to make the source */
#ifndef NDEBUG /* on command line use -DNDEBUG to make a */
#define DEBUG /* program without the debugging routines */
#endif
#endif
#ifdef TOLZ
#define FILTER FALSE
#define KEEPFLAG TRUE
#endif
#ifdef UNIX
#define NPROTO
#define COMP40 /* take this out for a little more speed */
#ifdef ALLOC
char *alloc();
#define ALLOCATE(x,y) alloc((unsigned int)x*y)
#else
char *malloc();
#define ALLOCATE(x,y) malloc((unsigned int)x*y)
#endif
#define FREEIT(ptr) free(ptr)
#define setbinary(fp)
#define NO_SETVBUF /* most don't support setvbuf() function */
#endif
#ifdef ISC386 /* my unix version compiler and system DjG */
#define NPROTO /* the unix release 3.2 dose not support prototypes */
/* #define COMP40 */ /* took this out for a little more speed */
#include <malloc.h> /* compiler has it, so put it in for future */
#define ALLOCATE(x,y) malloc((unsigned int)x*y)
#define FREEIT(ptr) free(ptr)
#define setbinary(fp)
#include <limits.h>
#define _MAX_PATH PATH_MAX
#define _MAX_NAME NAME_MAX
#define _MAX_DIR (PATH_MAX + NAME_MAX)
#define UNIX /* the rest of the unix stuff is still good */
#define COMPVER "386/ix"
#endif
/* Microsoft C compiler v 4.0-5.1 */
/* MSC is defined in makefile.msc */
#ifdef MSC
#define COMPVER "Msdos"
//#define FAR
//#define MAXSEG_64K
#define NO_REVSEARCH
#define CONST const
#define ALLOCTYPE void
#ifdef M_I86SM
#define SMALLMODEL /* compiled in small model */
#endif
#define setbinary(fp) setmode(fileno((fp)), O_BINARY)
#endif
/* MINIX adaptions
NOTE: This program will not work on the IBM/PC version of MINIX due to
the small memory model restrictions. There is no such thing as a FAR
pointer in MINIX-PC
*/
#ifdef MINIX /* Unix V7 clone for Atari ST */
#define COMPVER "minix"
#define strchr index
#define strrchr rindex
#define DFLTBITS 13 /* compatible with original MINIX compress, max=16 */
#ifndef KEEPFLAG
#define KEEPFLAG 1 /* compatible with original MINIX compress */
#endif /* may be redefined from the Makefile if desired */
#ifndef VERBOSE
#define VERBOSE TRUE /* compatible with original MINIX compress */
#endif /* may be redefined from the Makefile if desired */
#define NPROTO
#define SIGTYPE int /* MINIX defines this as pointer to int */
/* for the return from a signal */
#endif /* end of MINIX changes */
/* Mark Williams C for ATARI ST (V3.0.5) MWC is defined in makefile.mwc */
#ifdef MWC
#define COMPVER "TOS(mwc)"
#define MSDOS
#define NOSIGNAL
#define DFLTBITS 14
#define NPROTO
/* #define MAXSEG_64K */ /* use this if your compiler has a problem with */
/* indexing arrays larger than 64k */
#define NO_SETVBUF
#define NO_REVSEARCH
#define ALLOCATE(x,y) lcalloc((unsigned long)(x),((unsigned long)(unsigned)(y)))
#define FREEIT(ptr) free(ptr)
#define setbinary(fp) ((fp)->_ff &= ~_FASCII)
#endif
/*
Sozobon or Alcyon (4.14) C for Atari ST used with the dLibs standard library
*/
#ifdef ALCYON
#define SOZOBON 1
#endif
#ifdef SOZOBON
#define COMPVER "TOS(sozobon)"
#define MSDOS
#define NOSIGNAL
#define DFLTBITS 14
#define NPROTO
/* #define MAXSEG_64K */ /* use this if your compiler has a problem with */
/* indexing arrays larger than 64k */
#define ALLOCATE(x,y) lalloc((unsigned long)(x) * ((unsigned long)(y)))
#define FREEIT(ptr) free(ptr)
#define setbinary(fp) ((fp)->_flag |= _IOBIN)
#define FILTER FALSE
#endif
#ifdef __ZTC__ /* Zortech compiler */
#define setbinary(fp) ((fp)->_flag&=~_IOTRAN)
#define NO_REVSEARCH
#define CONST const
#define MAXSEG_64K
#endif
#ifdef XENIX
#define setbinary(fp)
#define FAR far
#define CONST
#define SIGTYPE int /* xenix defines this as pointer to int */
/* for the return from a signal */
#ifdef M_I286
#define MAXSEG_64K
#endif
#define NO_SETVBUF /* evidently xenix chokes on the large buff*/
#endif /* really needs to be fine tuned */
#ifdef MCH_AMIGA
#define COMPVER "Amiga"
#define CONST
#define MAXSEG_64K /* Manx C compiler limitation */
#define NO_SETVBUF
#endif
#ifdef vms
#define NO_SETVBUF
#endif
#ifdef __TURBOC__
#define MSDOS
#define MAXSEG_64K
#define NO_REVSEARCH
#ifdef __SMALL__
#define SMALLMODEL
#endif
#define CONST const
#define FAR far
#define setbinary(fp) setmode(fileno((fp)), O_BINARY)
#endif
/* FILTER if you want the program to operate as a unix type filter */
/* if not defined TRUE, then issuing command without parameters will */
/* print a usage and help information */
/* Use -DFILTER=0 to deactivate filter operation */
#ifndef FILTER
#define FILTER TRUE
#endif
/* KEEPFLAG determines the default action on successful completion */
/* Unix convention is FALSE (erase input file) */
/* Use -DKEEPFLAG=1 to keep files as default or change here */
/* if you don't set it before here and you are compiling the debug */
/* version, then files will be kept. */
#ifndef KEEPFLAG
#ifdef DEBUG
#define KEEPFLAG TRUE
#else
#define KEEPFLAG FALSE
#endif
#endif
/* Does your compiler support extended prototyping? */
/* Uncomment the following if your compiler does not.*/
/* support full prototyping, such as: */
/* char *emalloc(unsigned,int); */
/* if defined it will use the following: */
/* char *emalloc(); */
/* #define NPROTO */
/* putting the include files in one location */
#include <ctype.h>
#ifdef MINIX
#define assert(x)
extern char *index(), *rindex(), *strcat(), *strcpy(), *strncat(), *strncpy();
#else
#include <assert.h>
#include <string.h>
#endif
#ifndef NOSIGNAL
#include <signal.h>
#endif
#ifdef MWC
#include <stdlib.h>
#include <types.h>
#include <stat.h>
#else
#ifdef SOZOBON
#include <stdio.h>
#include <stat.h>
#include <limits.h>
#include <malloc.h>
#include <errno.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#endif
#endif
#ifdef M_XENIX
#include <fcntl.h>
#endif
#ifdef MSC
#include <stdlib.h>
#include <io.h>
#include <sys/utime.h>
#include <fcntl.h>
#include <limits.h>
#endif
#ifdef __TURBOC__
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <limits.h>
#endif
#ifndef NOSIGNAL
#ifndef SIGTYPE
#define SIGTYPE void
#endif
#ifndef SIG_ERR
#define SIG_ERR (SIGTYPE(*)())-1
#endif
#endif
/* This is for Microsoft C v5.1 to compile and be bound */
/* for use with os/2. Also if compiled just for os/2 */
/* The signal function is different between protected */
/* and real mode. */
/* #define BIND */
#ifdef INCL_DOSPROCESS
#define ISOS2 TRUE
#endif
#ifdef BIND
#define ISOS2 TRUE
#endif
/* The following is defined in MSC 5.1 stdlib.h
Replace with appropriate values for your system.
These values are used for MSDos system.
*/
#ifndef _MAX_PATH
#define _MAX_PATH 144 /* max. length of full pathname */
#define _MAX_DRIVE 3 /* max. length of drive component */
#define _MAX_DIR 130 /* max. length of path component */
#define _MAX_FNAME 9 /* max. length of file name component */
#define _MAX_EXT 5 /* max. length of extension component */
#endif
/* the following tells the system that the maximum segment is 64k */
/* if your compiler is not one of these and has this limitation */
/* Because of this, this code should compile with minimum porting */
/* in the COMPUSI.UNI module to most unix systems. */
/* This is also used to keep array indexing to 16 bit integer */
/* if not predefined in compiler implementation, you must define */
/* it separately if applicable to your compiler/system */
/* #define MAXSEG_64K */
/* put this in if you are compiling in small code */
/* model and your compiler does not predefine it */
/* this is for CPU' with 64k segment limitation. */
/* Use this define for small code, it is used by */
/* the header to decide on value for NEARHEAP */
/* #define SMALLMODEL */
/* does your system use far pointers ? if you want it enabled keep this */
/* if you have segment limit and compile in larger than 13 bits */
/* then you will have to use compact or large model if your compiler */
/* does not support far pointer keyword. */
#ifndef FAR
#define FAR
#endif
/* What type does the alloc() function return, char or void? */
#ifndef ALLOCTYPE
#define ALLOCTYPE char
#endif
/* If you use compusi.dos and your computer supports the unix */
/* file links and the link code is set properly in the stat() */
/* then define the following: */
/* #define USE_LINKS */
/* Does your run time library support the ANSI functions for:*/
/* reverse string set search? strrpbrk() if so: */
/*#define NO_REVSEARCH*//* dos module uses this function. */
/* Does your library include strrchr()? If not define this: */
/*#define NO_STRRCHR*//* unix/xenix module uses this function*/
/* Does your library include strchr()? If not define this: */
/*#define NO_STRCHR*//* dos module uses this function. */
/* definition for const key word if supported */
#ifndef CONST
#define CONST
#endif
/* And now for some typedefs */
typedef unsigned short CODE;
typedef unsigned char UCHAR;
typedef unsigned int INTCODE;
typedef unsigned int HASH;
typedef int FLAG;
/*
* You can define the value of MAXBITS to be anything betweeen MINBITS
* and MAXMAXBITS. This is will determine the maximum memory you will
* use and how the tables will be handled. I recommend you just leave
* it at MAXMAXBITS, because you can define DFLTBITS in compiling the
* module COMPRESS.C to set the default, and you can vary the number
* of bits at runtime by using the -b switch.
*/
/*
* The only reason to change MAXBITS is if you absolutely must have
* faster performance. If you specify 14 bits, the tables will not
* be split; at 13 bits, you can fit in the MSDOS small memory model
* and allocate tables in near heap.
* This value is available to other modules through the variable maxbits.
*/
#define INITBITS 9
#define MINBITS 12
#define MAXMAXBITS 16
#ifndef MAXBITS
#define MAXBITS MAXMAXBITS
#endif
#if (MAXBITS > MAXMAXBITS)
#undef MAXBITS
#define MAXBITS MAXMAXBITS
#endif
#if (MAXBITS < MINBITS)
#undef MAXBITS
#define MAXBITS MINBITS
#endif
/* You should define DFLTBITS to be the default compression code
* bit length you desire on your system.
* (I define mine in the compiler command line in my Makefile.LvR)
* (I leave mine alone and keep to the maximum. DjG)
*/
#ifndef DFLTBITS
#define DFLTBITS MAXBITS
#endif
#if (DFLTBITS < MINBITS)
#undef DFLTBITS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -