File: lzh.c

package info (click to toggle)
zoo 2.10-21
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 852 kB
  • ctags: 1,258
  • sloc: ansic: 8,944; asm: 793; makefile: 179
file content (65 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* $Id: lzh.c,v 1.15 91/07/06 19:18:51 dhesi Exp $ */
/*
lzh compression and uncompression interface module
*/

#include "options.h"
#include "zoo.h"
#include "ar.h"
#include "errors.i"

FILE *arcfile;

extern void prterror();

extern char *out_buf_adr;			/* address of buffer */

int lzh_encode(infile, outfile)
FILE *infile;
FILE *outfile;
{
	extern void encode();
	encode(infile, outfile);
	return 0;
}

/*
lzh_decode decodes its input and sends it to output.
Should return error status or byte count, but currently
returns 0.
*/

#undef COUNT_BYTES		/* define for debugging */

int lzh_decode(infile, outfile)
FILE *infile;
FILE *outfile;
{
	int n;
	extern int decoded;
#ifdef COUNT_BYTES
	int bytes_decoded = 0;		/*debug*/ /* count bytes after decoding */
#endif

	arcfile = infile;					/* stream to be decoded */

	decode_start();
	while (!decoded) {
		n = decode((uint) DICSIZ, out_buf_adr); /* n = count of chars decoded */
#ifdef COUNT_BYTES
		bytes_decoded += n;	/*debug*/
#endif
#ifdef CHECK_BREAK
		check_break();
#endif
		fwrite_crc(out_buf_adr, n, outfile);
#ifdef SHOW_DOTS
		(void) putc('.', stderr);
		(void) fflush(stderr);
#endif
	}
#ifdef COUNT_BYTES
	(void) fprintf(stderr, "bytes decoded = %d\n", bytes_decoded);
#endif
	return 0;
}