*** comprs16.c Thu Dec 08 11:53:50 1988 --- comprs12.c Thu Dec 08 09:04:42 1988 ************** *** 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 ----- ************** *** 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 ************** *** 486,492 code_int getcode(); void Usage() { - #ifdef DEBUG # ifdef MSDOS /* MSDOS version is too big in debug mode! */ --- 463,468 ----- ************** *** 488,493 --- 464,470 ----- void Usage() { #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"); ************** *** 489,498 #ifdef DEBUG # ifdef MSDOS ! /* MSDOS version is too big in debug mode! */ ! # else ! fprintf(stderr,"Usage: compress [-cdDfvV] [-b maxbits] [file ...]\n"); ! 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"); ************** *** 499,505 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"); ************** *** 502,510 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,"-D: Debug mode.\n"); ! fprintf(stderr,"-n: No header/magic. Use to compress/decompress compatibly with old methods.\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"); ************** *** 514,519 --- 486,493 ----- fprintf(stderr," stdout (if stdin used as input) When filenames are given,\n"); fprintf(stderr," replaces with the compressed version (.Z suffix) only if the\n"); fprintf(stderr," file decreases in size.\n"); + # else + fprintf(stderr,"Usage: compress [-cdDfvV] [-b maxbits] [file ...]\n"); # endif /* MSDOS */ } ************** *** 521,545 #else # ifdef MSDOS ! fprintf(stderr,"Usage: compress [-acCdfnNvV] [-b maxbits] [file ...]\n\n"); ! fprintf(stderr,"-a: (MS-DOS) Conversion mode. Allows conversion between UNIX (LF line\n"); ! fprintf(stderr," termination) and MS-DOS text (CR-LF termination). Useful for text files.\n"); ! fprintf(stderr,"-c: Write output on stdout, don't remove original.\n"); ! fprintf(stderr,"-C: Generate output compatible with compress 2.0.\n"); ! fprintf(stderr,"-d: Decompress. If given, decompression is done instead.\n"); ! fprintf(stderr,"-f: Forces output file to be generated, even if file already exists and will\n"); ! fprintf(stderr," be overwritten, or if no space is saved by compressing.\n"); ! fprintf(stderr,"-n: No header/magic. Use to compress/decompress compatibly with old methods.\n"); ! fprintf(stderr,"-N: (MS-DOS). Do not save replaced extension character in header.\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"); ! fprintf(stderr,"\nfile ...: Files to be compressed. If none specified, stdin is used.\n"); ! fprintf(stderr,"\nOutputs:\n"); ! fprintf(stderr,"file.Z: Compressed form of file with same mode, date, and utimes or\n"); ! fprintf(stderr," stdout (if stdin used as input). When filenames are given,\n"); ! fprintf(stderr," replaces with the compressed version (.Z suffix) only if the\n"); ! fprintf(stderr," file decreases in size.\n"); # else fprintf(stderr,"Usage: compress [-cdfvV] [-b maxbits] [file ...]\n"); # endif /* MSDOS */ --- 495,520 ----- #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"); ! 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"); ! 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"); ! fprintf(stderr,"file ...: Files to be compressed. If none specified, stdin is used.\n"); ! fprintf(stderr,"\nOutputs:\n"); ! fprintf(stderr,"file.Z: Compressed form of file with same mode, owner, and utimes or\n"); ! fprintf(stderr," stdout (if stdin used as input) When filenames are given,\n"); ! fprintf(stderr," replaces with the compressed version (.Z suffix) only if the\n"); ! fprintf(stderr," file decreases in size.\n"); # else fprintf(stderr,"Usage: compress [-cdfvV] [-b maxbits] [file ...]\n"); # endif /* MSDOS */ ************** *** 570,576 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 ************** *** 599,605 * 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 ************** *** 642,648 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 ************** *** 709,715 * -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++) { ************** *** 731,738 #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; ************** *** 734,742 case 'a': image = 2; break; ! case 'N': ! nocharsave = 1; ! break; #endif case 'v': --- 709,717 ----- case 'i': image = 1; break; ! case 'N': ! nocharsave = 1; ! break; #endif case 'v': ************** *** 784,793 } nextarg: continue; } - if ((block_compress == 0) && (nomagic ==1)){ - fprintf(stderr,"Cannot use -n and -C flags together; ignoring -n flag\n"); - nomagic = 0; - } if(maxbits < INIT_BITS) maxbits = INIT_BITS; if (maxbits > BITS) maxbits = BITS; --- 759,764 ----- ************** *** 855,862 /* Generate output filename */ strcpy(ofname, *fileptr); #ifdef MSDOS - if (nomagic == 1) - goto kluge; if (FourthByte) { /* Replace Z with original character */ ofname[strlen(*fileptr) - 1] = getchar(); if (!zcat_flg) --- 826,831 ----- ************** *** 867,873 ofname[strlen(*fileptr) - 1] = '\0'; /* Strip off Z */ else #endif - kluge: ofname[strlen(*fileptr) - 2] = '\0'; /* Strip off .Z */ } else { /* COMPRESSION */ --- 836,841 ----- ************** *** 1916,1923 #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();