home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * UNIX_COMP.C
- *
- * compress a file source to a destination file pointer, used by
- * BATCHNEWS.
- *
- * This differs from COMP.C in that the AmigaUUCP ulog() call is not
- * used.
- */
-
- #define COMPRESS_ONLY
- #define DECOMPRESS_ONLY /* sneaky shit to avoid repeating core code */
-
- #define BITS 16 /* maximum (dynamically allocate) */
- #define XENIX_16
- #define LOGERROR
- #define NO_ULOG
- #include <stdio.h>
-
- #undef stdin
- #undef stdout
- #define stdin Fi
- #define stdout Fo
-
- #include <stdlib.h>
- #include <string.h>
- #include "config.h"
-
- static FILE *Fi;
- static FILE *Fo;
-
- #include "/unix/compress.ch"
-
- Prototype int unix_compress_from_file(char *, FILE *, short);
- Prototype int unix_compress_from_fp(FILE *, FILE *, short);
- Prototype int unix_uncompress_to_file(FILE *, char *, short *);
- Prototype int unix_uncompress_to_fp(FILE *, FILE *, short *);
-
- int
- unix_compress_from_file(inName, fo, bits)
- char *inName;
- FILE *fo;
- short bits;
- {
- FILE *fi;
- int r = -1;
-
- if (bits < 0) /* block compress */
- bits = -bits | BLOCK_MASK;
-
- if (initcomp(NULL, fo, bits) >= 0) {
- if (fi = fopen(inName, "r")) {
- Fi = fi;
- Fo = fo;
- r = compress();
- fclose(fi);
- }
- }
- deletecomp();
- return(r);
- }
-
- int
- unix_compress_from_fp(fi, fo, bits)
- FILE *fi;
- FILE *fo;
- short bits;
- {
- int r = -1;
-
- if (bits < 0) /* block compress */
- bits = -bits | BLOCK_MASK;
-
- if (initcomp(NULL, fo, bits) >= 0) {
- Fi = fi;
- Fo = fo;
- r = compress();
- }
- deletecomp();
- return(r);
- }
-
- int
- unix_uncompress_to_file(fi, outName, pbits)
- FILE *fi;
- char *outName;
- short *pbits;
- {
- FILE *fo;
- int r = -1;
-
- if (initcomp(fi, NULL, 0) >= 0) {
- if (fo = fopen(outName, "w")) {
- Fi = fi;
- Fo = fo;
- r = decompress();
- *pbits = maxbits;
- fclose(fo);
- }
- }
- deletecomp();
- return(r);
- }
-
- int
- unix_uncompress_to_fp(fi, fo, pbits)
- FILE *fi;
- FILE *fo;
- short *pbits;
- {
- int r = -1;
-
- if (initcomp(fi, NULL, 0) >= 0) {
- Fi = fi;
- Fo = fo;
- r = decompress();
- *pbits = maxbits;
- }
- deletecomp();
- return(r);
- }
-
-
-