📄 compress.h
字号:
#define DFLTBITS MINBITS
#endif
#if (DFLTBITS > MAXBITS)
#undef DFLTBITS
#define DFLTBITS MAXBITS
#endif
/* THIS IS TO COMPILE A 13 BIT MODEL IN SMALL MEMORY AND NEAR HEAP */
/* AS SET UP IT WILL WORK WITH MICROSOFT C COMPILER */
#if (MAXBITS < 14)
#ifdef SMALLMODEL
#define NEARHEAP TRUE
#undef FAR
#define FAR
#endif
#endif
/* correcting for different types of pointer arithmatic */
/* probably won't have to change it */
#define NULLPTR(type) ((type FAR *) NULL)
/* in making this program portable the following allocation and */
/* free functions are called, with the following parameters: */
/* ALLOCTYPE FAR *emalloc(unsigned int x, int y) */
/* void efree(ALLOCTYPE FAR *ptr) */
/* you must define the allocation function and the free function */
/* keep in mind that the casts must be correct for your compiler */
/* NOTE these are the two functions to change for allocating pointers to */
/* far data space if you are not using Microsoft C v.5.1 */
/* Consult your compiler manual and find the low level function that */
/* returns a far pointer when compiled in the small model. */
/* if your compiler does not support that, you will have to compile with */
/* a model that defaults to far pointers to data (compact or large model)*/
/* HERE ARE SOME SAMPLE PREDEFINED ONES */
#ifdef MSC
#include <malloc.h>
#ifdef NEARHEAP
#define ALLOCATE(x,y) malloc((size_t)((x)*(y)))
#define FREEIT(ptr) free((ptr))
#else
#define ALLOCATE(x,y) malloc((size_t)((x)*(y)))
#define FREEIT(ptr) free((ptr))
#endif
#endif
#ifdef HUGE
#include <malloc.h>
#define ALLOCATE(x,y) halloc((long)(x),(size_t)(y))
#define FREEIT(ptr) hfree(ptr)
#endif
#ifdef __TURBOC__
#include <alloc.h>
#ifdef NEARHEAP
#define ALLOCATE(x,y) malloc((unsigned int)((x)*(y)))
#define FREEIT(x) free(x)
#else
#define ALLOCATE(x,y) farmalloc((unsigned long)((x)*(y)))
#define FREEIT(x) farfree(x)
#endif
#endif
/* default allocation function, in segmented addressing, must return */
/* a far pointer or compile with far pointer data as default */
#ifndef ALLOCATE
#include <malloc.h>
#define ALLOCATE(x,y) malloc((unsigned int)x*y)
#define FREEIT(ptr) free((ptr))
#endif
# ifdef MAXSEG_64K
# if MAXBITS > 14
# define SPLIT_HT TRUE
# else
# define SPLIT_HT 0
# endif
# else
# define SPLIT_HT 0
# endif
# ifdef MAXSEG_64K
# if MAXBITS > 15
# define SPLIT_PFX TRUE
# else
# define SPLIT_PFX 0
# endif
# else
# define SPLIT_PFX 0
# endif
#ifndef BUFSIZ
#define BUFSIZ 512
#endif
#ifdef NO_SETBUF
#define NO_SETVBUF
#endif
#ifdef NO_SETVBUF
# ifndef NO_SETBUF
# define setvbuf(fp,buf,mode,size) setbuf((fp),(buf))
# define ZBUFSIZE BUFSIZ
# define XBUFSIZE BUFSIZ
# else
# define setvbuf(fp,buf,mode,size)
# define ZBUFSIZE (1)
# define XBUFSIZE (1)
# endif
#else
# ifdef NEARHEAP
# define XBUFSIZE (0xC00)
# define ZBUFSIZE (0x1800)
# else
# define XBUFSIZE (0x3000) /* 12k bytes */
# define ZBUFSIZE (0x6000) /* 24k bytes */
# endif
#endif
#define UNUSED ((CODE)0) /* Indicates hash table value unused */
#define CLEAR ((CODE)256) /* Code requesting table to be cleared */
#define FIRSTFREE ((CODE)257) /* First free code for token encoding */
#define MAXTOKLEN 512 /* Max chars in token; size of buffer */
#ifdef vms
#define ERROR 0x10000004 /* General unspecified error */
#define NORMAL 1 /* No error */
#define unlink(x) remove(x)
#else
# define NORMAL 0
# ifdef ERROR
# if (ERROR == NORMAL)
//lgd # define ERROR 1 /* force redefine if (ERROR == NORMAL) */
# endif
# else
# define ERROR 1
# endif
#endif
//#include "compress.fns"
/* defines opening mode for files */
/* and suffixes for compressed file */
#ifdef MSDOS
#define WRITE_FILE_TYPE "wb"
#define READ_FILE_TYPE "rb"
#define SUFFIX "Z"
#else
#ifdef vms
#define SUFFIX "_Z"
#define WRITE_FILE_TYPE "wb"
#define READ_FILE_TYPE "rb"
#else
#define WRITE_FILE_TYPE "w"
#define READ_FILE_TYPE "r"
#define SUFFIX ".Z"
#endif
#endif
/* The VERBOSE flag defines the default value of the verbose variable */
/* If it's not already defined, we set it to FALSE here since most */
/* systems set the default that way. -Dal */
#ifndef VERBOSE
#define VERBOSE FALSE
#endif
/* Defines for third byte of header */
#define BIT_MASK 0x1f
#define BLOCK_MASK 0x80
/* Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
a fourth header byte (for expansion).
*/
#define CHECK_GAP 10000L /* ratio check interval */
#ifdef MAIN
UCHAR magic_header[] = { 0x1F,0x9D }; /* 1F 9D */
char rcs_ident[] = TITLE;
#ifdef MWC
long _stksize = 20000L; /* set MWC's stack to 20,000 */
#ifdef MWC_NAME /* if defined in makefile set _cmdname for */
char _cmdname[]=MWC_NAME; /* compress,zcat,uncomp check for desktop and */
#endif /* dumb shells */
#endif
#ifdef SOZOBON
long _STKSIZ = 20000L; /* set runtime stack to 20,000 bytes */
#ifndef CMDNAME
#define CMDNAME "compress"
#endif
#endif
int overwrite = 0; /* Do not overwrite unless given -f flag */
//int maxbits = DFLTBITS; /* user settable max # bits/code */
int exit_stat = 0;
int keep = KEEPFLAG; /* True = don't kill file */
int keep_error = FALSE; /* True = keep output file even if error exist */
char *prog_name;
char ifname[_MAX_DIR];
char inpath[_MAX_DIR];
char ofname [_MAX_DIR];
char outpath[_MAX_DIR];
int is_list = FALSE; /* flag for file parameters */
char endchar[1];
//char xbuf[XBUFSIZE];
//char zbuf[ZBUFSIZE];
#ifdef MSDOS
char separator[] = "\\";
#else
char separator[] = "/";
#endif
//int nomagic = FALSE; /* Use a 3-byte magic number header, unless old file */
int zcat_flg = FALSE; /* Write output on stdout, suppress messages */
int quiet = !VERBOSE; /* don't tell me about compression */
/*
* block compression parameters -- after all codes are used up,
* and compression rate changes, start over.
*/
//
#ifdef COMP40
//long int ratio = 0L;
long checkpoint = CHECK_GAP;
#endif
/* force the overwrite */
int force = 0;
#ifdef DEBUG
int verbose = VERBOSE;
int debug = FALSE;
#endif /* DEBUG */
#ifndef NOSIGNAL
SIGTYPE (*bgnd_flag)();
#endif
int do_decomp = FALSE;
#else /* not defining instance */
extern UCHAR magic_header[];
extern char rcs_ident[];
#ifdef MWC
extern long _stksize;
#endif
extern int overwrite;
//extern int maxbits;
extern int exit_stat;
extern int keep;
extern int keep_error;
//extern char *prog_name;
//extern char inpath[];
extern char outpath[];
extern int is_list;
extern char endchar[];
//extern char xbuf[];
//extern char zbuf[];
extern char ifname[];
extern char ofname[];
extern char separator[];
extern int nomagic;
extern int zcat_flg;
extern int quiet;
//extern int block_compress;
#ifdef COMP40
//extern long int ratio;
extern long checkpoint;
#endif
extern int force;
#ifdef DEBUG
extern int verbose;
extern int debug;
#endif /* DEBUG */
#ifndef NOSIGNAL
extern SIGTYPE (*bgnd_flag)();
#endif
extern int do_decomp;
#endif
typedef struct
{
FILE *fp_src, *fp_zip;
int nomagic;
int maxbits;
int block_compress;
int offset;
INTCODE prefxcode, nextfree;
long int in_count; /* length of input */
long int bytes_out; /* length of compressed output */
INTCODE highcode;
INTCODE maxcode;
HASH hashsize;
int bits;
int oldbits, prevbits;
int ratio;
int size;
INTCODE oldmaxcode;
HASH oldhashsize;
UCHAR inbuf[MAXBITS];
UCHAR outbuf[MAXBITS];
char xbuf[XBUFSIZE];
char zbuf[ZBUFSIZE];
}COMP_PARAMS;
#ifdef NPROTO
extern void Usage();
extern char get_one();
extern int check_error();
extern char *name_index();
extern char *get_program_name();
#ifdef NO_STRCHR
extern char *strchr();
#endif
#ifdef NO_STRRCHR
extern char *strrchr();
#endif
#ifdef NO_REVSEARCH
extern char *strrpbrk();
#endif
extern int is_z_name();
extern int cl_block();
extern int make_z_name();
extern int test_file();
extern void unmake_z_name();
extern int compress(COMP_PARAMS *);
extern int uncompress(COMP_PARAMS *);
extern CODE getcode();
extern void writeerr();
extern void copystat();
#ifndef NOSIGNAL
extern int foreground();
extern SIGTYPE onintr();
extern SIGTYPE oops();
#endif
extern void prratio();
extern void version();
#ifdef NEARHEAP
extern ALLOCTYPE *emalloc();
extern void efree();
#else
extern ALLOCTYPE FAR *emalloc();
extern void efree();
#endif
//extern int alloc_tables();
extern void init_tables();
#else
extern void Usage(int);
extern char get_one(void);
extern int check_error(void);
extern char *name_index(char *);
extern int cl_block(void);
extern char *get_program_name(char *);
extern int is_z_name(char *);
extern int test_file(char *);
extern int make_z_name(char *);
extern void unmake_z_name(char *);
#ifdef NO_STRCHR
extern char *strchr(char *,int);
#endif
#ifdef NO_STRRCHR
extern char *strrchr(char *,int);
#endif
#ifdef NO_REVSEARCH
extern char *strrpbrk(char *,char *);
#endif
extern int compress(COMP_PARAMS *);
extern void putcode(INTCODE,int,COMP_PARAMS *);
extern int uncompress(COMP_PARAMS *);
extern CODE getcode(void);
extern void writeerr(void);
extern void copystat(char *,char *);
#ifndef NOSIGNAL
extern int foreground(void);
extern SIGTYPE onintr(void);
extern SIGTYPE oops(void);
#endif
extern void prratio(FILE *,long,long);
extern void version(void);
#ifdef NEARHEAP
extern ALLOCTYPE *emalloc(unsigned int,int);
extern void efree(ALLOCTYPE *);
#else
extern ALLOCTYPE FAR *emalloc(unsigned int,int);
extern void efree(ALLOCTYPE FAR *);
#endif
extern int alloc_tables(INTCODE,HASH,COMP_PARAMS *);
extern void init_tables(void );
extern int nextcode(INTCODE *,COMP_PARAMS *);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -