1 /*
2     File lz_nonslide.h, part of lzxcomp library
3     Copyright (C) 2002 Matthew T. Russotto
4 
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU Lesser General Public License as published by
7     the Free Software Foundation; version 2.1 only
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU Lesser General Public License for more details.
13 
14     You should have received a copy of the GNU Lesser General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19 #if defined(_WIN32) || defined(__APPLE__) || defined(__linux__)
20 typedef unsigned char           u_char;
21 #endif
22 
23 typedef struct lz_info lz_info;
24 typedef int (*get_chars_t)(lz_info *lzi, int n, u_char *buf);
25 typedef int (*output_match_t)(lz_info *lzi, int match_pos, int match_len);
26 typedef void (*output_literal_t)(lz_info *lzi, u_char ch);
27 
28 struct lz_info
29 {
30   int wsize; /* window size in bytes */
31   int max_match; /* size of longest match in bytes */
32   int min_match;
33   u_char *block_buf;
34   u_char *block_bufe;
35   int block_buf_size;
36   int chars_in_buf;
37   int cur_loc;            /* location within stream */
38   int block_loc;
39   int frame_size;
40   int max_dist;
41   u_char **prevtab;
42   int *lentab;
43   short eofcount;
44   short stop;
45   short analysis_valid;
46 
47   get_chars_t get_chars;
48   output_match_t output_match;
49   output_literal_t output_literal;
50   void *user_data;
51 };
52 
53 void lz_init(lz_info *lzi, int wsize, int max_dist,
54 	     int max_match, int min_match,
55 	     int frame_size,
56 	     get_chars_t get_chars,
57 	     output_match_t output_match,
58 	     output_literal_t output_literal, void *user_data);
59 
60 void lz_release(lz_info *lzi);
61 
62 void lz_reset(lz_info *lzi);
63 void lz_stop_compressing(lz_info *lzi);
64 int lz_left_to_process(lz_info *lzi); /* returns # chars read in but unprocessed */
65 int lz_compress(lz_info *lzi, int nchars);
66