*** compress.c --- ocompres.c ************** *** 1,26 - /* NOTES: - 1. For the full capability (16 bit compression option) - compile using MSC 4.0/5, with the command: - cl -Mc -DBIG -D__MSDOS__ doscompr.c - TurboC will not support a sufficient number of global variables - to compile the full version. Note that function prototyping - is revised downward from the full TurboC/MSC 5 prototypes to - MSC 4.0 compatibility; note also that the 'main' routine - will be too long for the normal post-optimizer and that the - c3l.exe file must be used. To reduce the 468+K file to a - workable size, this should be linked with the 'pack' option, - or exepack should be used. Finally, it should be noted that - this program requires 530K of free memory to work. - 2. For the limited capability (12 bit compress option) - this can be compiled using MSC 4.0/5 or TurboC. For MSC, the - compilation command is: - cl -Ms -D__MSDOS__ -o comprs12 doscompr.c - and for TurboC, the compilation command is: - tcc -ms -D__MSDOS__ -D__TURBOC__ -r -Z -ocomprs12 doscompr.c - The original TurboC version can be recreated by applying the - included patch to doscompr.c. - */ - /* * Compress - data compression program */ --- 1,3 ----- /* * Compress - data compression program */ ************** *** 363,387 #endif #ifdef __MSDOS__ /* Prototypes for Turbo C */ ! void Usage(); ! void version(); ! void compress(); ! void output(); ! code_int getcode(); ! char *rindex(); ! void printcodes(); ! void dump_tab(); ! int in_stack(); ! void writeerr(); ! void copystat(); ! int c_break(); ! void cl_block (); ! void cl_hash(); ! void prratio(); ! void version(); ! char *PathTail(); ! char *strrpbrk(); ! void decompress(); #endif #define ARGVAL() (*++(*argv) || (--argc && *++argv)) --- 340,364 ----- #endif #ifdef __MSDOS__ /* Prototypes for Turbo C */ ! void Usage(void); ! void version(void); ! void compress(char OldChar); ! void output(code_int code); ! code_int getcode(void); ! char *rindex(char *s,char c); ! void printcodes(void); ! void dump_tab(void); ! int in_stack(register c, register stack_top); ! void writeerr(void); ! void copystat(char *ifname,char *ofname); ! int c_break(void); ! void cl_block (void); ! void cl_hash(register count_int hsize); ! void prratio(FILE *stream,long num,long den); ! void version(void); ! char *PathTail(char *Path); ! char *strrpbrk(char *S,char *Chars); ! void decompress(void); #endif #define ARGVAL() (*++(*argv) || (--argc && *++argv)) ************** *** 399,414 #ifdef XENIX_16 # ifdef MSDOS ! count_int htab0[8192]; ! count_int htab1[8192]; ! count_int htab2[8192]; ! count_int htab3[8192]; ! count_int htab4[8192]; ! count_int htab5[8192]; ! count_int htab6[8192]; ! count_int htab7[8192]; ! count_int htab8[HSIZE-65536]; ! count_int * htab[9] = { htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; unsigned short code0tab[16384]; --- 376,391 ----- #ifdef XENIX_16 # ifdef MSDOS ! count_int far htab0[8192]; ! count_int far htab1[8192]; ! count_int far htab2[8192]; ! count_int far htab3[8192]; ! count_int far htab4[8192]; ! count_int far htab5[8192]; ! count_int far htab6[8192]; ! count_int far htab7[8192]; ! count_int far htab8[HSIZE-65536]; ! count_int far * htab[9] = { htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; unsigned short far code0tab[16384]; ************** *** 411,422 count_int * htab[9] = { htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; ! unsigned short code0tab[16384]; ! unsigned short code1tab[16384]; ! unsigned short code2tab[16384]; ! unsigned short code3tab[16384]; ! unsigned short code4tab[16384]; ! unsigned short * codetab[5] = { code0tab, code1tab, code2tab, code3tab, code4tab }; # else --- 388,399 ----- count_int far * htab[9] = { htab0, htab1, htab2, htab3, htab4, htab5, htab6, htab7, htab8 }; ! unsigned short far code0tab[16384]; ! unsigned short far code1tab[16384]; ! unsigned short far code2tab[16384]; ! unsigned short far code3tab[16384]; ! unsigned short far code4tab[16384]; ! unsigned short far * codetab[5] = { code0tab, code1tab, code2tab, code3tab, code4tab }; # else ************** *** 489,495 #ifdef DEBUG # ifdef MSDOS ! fprintf(stderr,"Usage: compress [-cdaDfvV] [-b maxbits] [file ...]\n"); fprintf(stderr,"-c: Write output on stdout, don't remove original.\n"); fprintf(stderr,"-d: If given, decompression is done instead.\n"); fprintf(stderr,"-f: Forces output file to be generated, even if one already exists,\n"); --- 466,472 ----- #ifdef DEBUG # ifdef MSDOS ! fprintf(stderr,"Usage: compress [-cdDfivV] [-b maxbits] [file ...]\n"); fprintf(stderr,"-c: Write output on stdout, don't remove original.\n"); fprintf(stderr,"-d: If given, decompression is done instead.\n"); fprintf(stderr,"-f: Forces output file to be generated, even if one already exists,\n"); ************** *** 496,502 fprintf(stderr," and even if no space is saved by compressing. If -f is not used,\n"); fprintf(stderr," the user will be prompted if stdin is a tty, otherwise, the\n"); fprintf(stderr," output file will not be overwritten.\n"); ! fprintf(stderr,"-a: Conversion mode (defined only under MS-DOS). Allows conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); fprintf(stderr," termination) in uncompressed form. Useful with text files.\n"); --- 473,479 ----- fprintf(stderr," and even if no space is saved by compressing. If -f is not used,\n"); fprintf(stderr," the user will be prompted if stdin is a tty, otherwise, the\n"); fprintf(stderr," output file will not be overwritten.\n"); ! fprintf(stderr,"-i: Image mode (defined only under MS-DOS). Prevents conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); fprintf(stderr," termination) in uncompressed form. Useful with non-text files.\n"); ************** *** 499,505 fprintf(stderr,"-a: Conversion mode (defined only under MS-DOS). Allows conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); ! fprintf(stderr," termination) in uncompressed form. Useful with text files.\n"); fprintf(stderr,"-v: Write compression statistics\n"); fprintf(stderr,"-V: Write version and compilation options.\n"); fprintf(stderr,"-b: Parameter limits the max number of bits/code.\n"); --- 476,482 ----- fprintf(stderr,"-i: Image mode (defined only under MS-DOS). Prevents conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); ! fprintf(stderr," termination) in uncompressed form. Useful with non-text files.\n"); fprintf(stderr,"-v: Write compression statistics\n"); fprintf(stderr,"-V: Write version and compilation options.\n"); fprintf(stderr,"-b: Parameter limits the max number of bits/code.\n"); ************** *** 518,524 #else # ifdef MSDOS ! fprintf(stderr,"Usage: compress [-cdafvV] [-b maxbits] [file ...]\n"); fprintf(stderr,"-c: Write output on stdout, don't remove original.\n"); fprintf(stderr,"-d: If given, decompression is done instead.\n"); fprintf(stderr,"-f: Forces output file to be generated, even if one already exists,\n"); --- 495,501 ----- #else # ifdef MSDOS ! fprintf(stderr,"Usage: compress [-cdfivV] [-b maxbits] [file ...]\n"); fprintf(stderr,"-c: Write output on stdout, don't remove original.\n"); fprintf(stderr,"-d: If given, decompression is done instead.\n"); fprintf(stderr,"-f: Forces output file to be generated, even if one already exists,\n"); ************** *** 525,531 fprintf(stderr," and even if no space is saved by compressing. If -f is not used,\n"); fprintf(stderr," the user will be prompted if stdin is a tty, otherwise, the\n"); fprintf(stderr," output file will not be overwritten.\n"); ! fprintf(stderr,"-a: Conversion mode (defined only under MS-DOS). Allows conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); fprintf(stderr," termination) in uncompressed form. Useful with text files.\n"); --- 502,508 ----- fprintf(stderr," and even if no space is saved by compressing. If -f is not used,\n"); fprintf(stderr," the user will be prompted if stdin is a tty, otherwise, the\n"); fprintf(stderr," output file will not be overwritten.\n"); ! fprintf(stderr,"-i: Image mode (defined only under MS-DOS). Prevents conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); fprintf(stderr," termination) in uncompressed form. Useful with non-text files.\n"); ************** *** 528,534 fprintf(stderr,"-a: Conversion mode (defined only under MS-DOS). Allows conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); ! fprintf(stderr," termination) in uncompressed form. Useful with text files.\n"); fprintf(stderr,"-v: Write compression statistics\n"); fprintf(stderr,"-V: Write version and compilation options.\n"); fprintf(stderr,"-b: Parameter limits the max number of bits/code.\n"); --- 505,511 ----- fprintf(stderr,"-i: Image mode (defined only under MS-DOS). Prevents conversion\n"); fprintf(stderr," between UNIX text representation (LF line termination) in\n"); fprintf(stderr," compressed form and MS-DOS text representation (CR-LF line\n"); ! fprintf(stderr," termination) in uncompressed form. Useful with non-text files.\n"); fprintf(stderr,"-v: Write compression statistics\n"); fprintf(stderr,"-V: Write version and compilation options.\n"); fprintf(stderr,"-b: Parameter limits the max number of bits/code.\n"); ************** *** 568,574 char ofname [100]; #ifdef MSDOS ! int image = 1; /* 1 <=> image (binary) mode; 2 <=> text mode */ int nocharsave = 0; /* set to 1 if -N flag (no char save) is given */ #endif --- 545,551 ----- char ofname [100]; #ifdef MSDOS ! int image = 2; /* 1 <=> image (binary) mode; 2 <=> text mode */ int nocharsave = 0; /* set to 1 if -N flag (no char save) is given */ #endif ************** *** 597,603 * If -f is not used, the user will be prompted if stdin is * a tty, otherwise, the output file will not be overwritten. * ! * -a: Conversion mode (defined only under MS-DOS). Implements * conversion between UNIX text representation (LF line * termination) in compressed form and MS-DOS text * representation (CR-LF line termination) in uncompressed --- 574,580 ----- * If -f is not used, the user will be prompted if stdin is * a tty, otherwise, the output file will not be overwritten. * ! * -i: Image mode (defined only under MS-DOS). Prevents * conversion between UNIX text representation (LF line * termination) in compressed form and MS-DOS text * representation (CR-LF line termination) in uncompressed ************** *** 640,646 int FourthByte; /* Whether header has a fourth byte */ char OldChar = '\0'; /* Char in DOS filename overwritten by Z */ #ifndef __TURBOC__ ! extern void onintr(); #endif #ifdef MSDOS --- 617,623 ----- int FourthByte; /* Whether header has a fourth byte */ char OldChar = '\0'; /* Char in DOS filename overwritten by Z */ #ifndef __TURBOC__ ! extern onintr(); #endif #ifdef MSDOS ************** *** 707,713 * -c => cat all output to stdout * -C => generate output compatible with compress 2.0. * -N => (MSDOS): do not save replaced extension char in header ! * -a => (MSDOS): compress/uncompress with LF - CR/LF conversion * if a string is left, must be an input filename. */ for (argc--, argv++; argc > 0; argc--, argv++) { --- 684,690 ----- * -c => cat all output to stdout * -C => generate output compatible with compress 2.0. * -N => (MSDOS): do not save replaced extension char in header ! * -i => (MSDOS): compress/uncompress as binary * if a string is left, must be an input filename. */ for (argc--, argv++; argc > 0; argc--, argv++) { ************** *** 729,736 #endif /* DEBUG */ #ifdef MSDOS ! case 'a': ! image = 2; break; case 'N': nocharsave = 1; --- 706,713 ----- #endif /* DEBUG */ #ifdef MSDOS ! case 'i': ! image = 1; break; case 'N': nocharsave = 1; ************** *** 1907,1914 #define PATHSEP "/" #endif ! char *PathTail(Path) ! char *Path; /* Given a path, returns a pointer to the last component (tail) */ { char *Temp,*strrpbrk(); --- 1884,1890 ----- #define PATHSEP "/" #endif ! char *PathTail(char *Path) /* Given a path, returns a pointer to the last component (tail) */ { char *Temp,*strrpbrk();