1 /* $Id: lzh.c,v 1.15 91/07/06 19:18:51 dhesi Exp $ */
2 /*
3 lzh compression and uncompression interface module
4 */
5 
6 #include "options.h"
7 #include "zoo.h"
8 #include "ar.h"
9 #include "errors.i"
10 
11 FILE *arcfile;
12 
13 extern void prterror();
14 
15 extern char *out_buf_adr;			/* address of buffer */
16 
lzh_encode(infile,outfile)17 int lzh_encode(infile, outfile)
18 FILE *infile;
19 FILE *outfile;
20 {
21 	extern void encode();
22 	encode(infile, outfile);
23 	return 0;
24 }
25 
26 /*
27 lzh_decode decodes its input and sends it to output.
28 Should return error status or byte count, but currently
29 returns 0.
30 */
31 
32 #undef COUNT_BYTES		/* define for debugging */
33 
lzh_decode(infile,outfile)34 int lzh_decode(infile, outfile)
35 FILE *infile;
36 FILE *outfile;
37 {
38 	int n;
39 	extern int decoded;
40 #ifdef COUNT_BYTES
41 	int bytes_decoded = 0;		/*debug*/ /* count bytes after decoding */
42 #endif
43 
44 	arcfile = infile;					/* stream to be decoded */
45 
46 	decode_start();
47 	while (!decoded) {
48 		n = decode((uint) DICSIZ, (uchar *)out_buf_adr); /* n = count of chars decoded */
49 #ifdef COUNT_BYTES
50 		bytes_decoded += n;	/*debug*/
51 #endif
52 #ifdef CHECK_BREAK
53 		check_break();
54 #endif
55 		fwrite_crc((uchar *)out_buf_adr, n, outfile);
56 #ifdef SHOW_DOTS
57 		(void) putc('.', stderr);
58 		(void) fflush(stderr);
59 #endif
60 	}
61 #ifdef COUNT_BYTES
62 	(void) fprintf(stderr, "bytes decoded = %d\n", bytes_decoded);
63 #endif
64 	return 0;
65 }
66