26 #define WIN32_LEAN_AND_MEAN
43 int max_match,
int min_match,
55 if (max_match > wsize)
100typedef struct lz_user_data
109 lz_user_data *lzud = (lz_user_data *)lzi->
user_data;
113int tmp_output_match(
lz_info *lzi,
int match_pos,
int match_len)
115 lz_user_data *lzud = (lz_user_data *)lzi->
user_data;
118 mod_match_loc = match_pos;
120 fprintf(lzud->outfile,
"(%d, %d)(%d)\n", match_pos, match_len, mod_match_loc);
126 lz_user_data *lzud = (lz_user_data *)lzi->
user_data;
127 fprintf(lzud->outfile,
"'%c'", ch);
157 if (toread > maxchars) toread = maxchars;
159 nread = lzi->
get_chars(lzi, toread, readhere);
168 u_char **prevtab, **prevp;
177#ifdef DEBUG_ANALYZE_BLOCK
181 struct rusage innerloop;
182 struct timeval innertime, tmptime;
183 struct rusage outerloop;
185 struct rusage initialloop;
187 struct rusage totalloop;
191#ifdef DEBUG_ANALYZE_BLOCK
194 memset(chartab, 0,
sizeof(chartab));
195 prevtab = prevp = lzi->
prevtab;
196 lentab = lenp = lzi->
lentab;
200 memset(&innertime, 0,
sizeof(innertime));
201 memset(&outertime, 0,
sizeof(outertime));
202 getrusage(RUSAGE_SELF, &initialloop);
203 totalloop = initialloop;
208 if (chartab[ch = *bbp]) {
209 *prevp = chartab[ch];
218 initialtime = initialloop.ru_utime;
219 getrusage(RUSAGE_SELF, &initialloop);
220 timersub(&initialloop.ru_utime, &initialtime, &initialtime);
223 for (maxlen = 1; wasinc && (maxlen < lzi->
max_match); maxlen++) {
225 getrusage(RUSAGE_SELF, &outerloop);
227 bbp = bbe - maxlen - 1;
232 if (*lenp == maxlen) {
234 getrusage(RUSAGE_SELF, &innerloop);
240 if (
cursor[maxlen] == ch) {
246 if (prevlen != maxlen)
break;
250 tmptime = innerloop.ru_utime;
251 getrusage(RUSAGE_SELF, &innerloop);
252 timersub(&innerloop.ru_utime, &tmptime, &tmptime);
253 timeradd(&tmptime, &innertime, &innertime);
261 tmptime = outerloop.ru_utime;
262 getrusage(RUSAGE_SELF, &outerloop);
263 timersub(&outerloop.ru_utime, &tmptime, &tmptime);
264 timeradd(&tmptime, &outertime, &outertime);
269 totaltime = totalloop.ru_utime;
270 getrusage(RUSAGE_SELF, &totalloop);
271 timersub(&totalloop.ru_utime, &totaltime, &totaltime);
278#ifdef DEBUG_ANALYZE_BLOCK
294 u_char **prevtab, **prevp;
306 int bytes_to_move = lzi->
max_dist + residual;
309#ifdef DEBUG_ANALYZE_BLOCK
310 fprintf(
stderr,
"Moving %06x, chars_in_buf %06x, residual = %06x, nchars= %06x block_loc = %06x\n", bytes_to_move, lzi->
chars_in_buf, residual, nchars, lzi->
block_loc);
315 lzi->
block_loc = bytes_to_move - residual;
317#ifdef DEBUG_ANALYZE_BLOCK
321#ifdef DEBUG_ANALYZE_BLOCK
344 while ((bbp < bbe) && (!lzi->
stop)) {
363 if ((bbp < bbe -1) && !trimmed &&
364 ((lenp[1] > (
len + 1)) )) {
379 if (len < lzi->min_match) {
GLenum GLuint GLenum GLsizei const GLchar * buf
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
void lz_reset(lz_info *lzi)
void lz_release(lz_info *lzi)
int lz_compress(lz_info *lzi, int nchars)
static void lz_analyze_block(lz_info *lzi)
static void fill_blockbuf(lz_info *lzi, int maxchars)
int lz_left_to_process(lz_info *lzi)
void lz_stop_compressing(lz_info *lzi)
void lz_init(lz_info *lzi, int wsize, int max_dist, int max_match, int min_match, int frame_size, get_chars_t get_chars, output_match_t output_match, output_literal_t output_literal, void *user_data)
int(* get_chars_t)(lz_info *lzi, int n, u_char *buf)
void(* output_literal_t)(lz_info *lzi, u_char ch)
int(* output_match_t)(lz_info *lzi, int match_pos, int match_len)
#define memmove(s1, s2, n)
#define R1(v, w, x, y, z, i)
#define R2(v, w, x, y, z, i)
#define R0(v, w, x, y, z, i)
output_match_t output_match
output_literal_t output_literal