static int init_match ( struct ucl_compress *c, struct ucl_swd *s, const uint8_t *dict, unsigned int dict_len, uint32_t flags ) { int r; assert(!c->init); c->init = 1; s->c = c; c->last_m_len = c->last_m_off = 0; c->textsize = c->codesize = c->printcount = 0; c->lit_bytes = c->match_bytes = c->rep_bytes = 0; c->lazy = 0; r = swd_init(s,dict,dict_len); if (r != UCL_E_OK) { swd_exit(s); return r; } s->use_best_off = (flags & 1) ? 1 : 0; return UCL_E_OK; }
static void find_match(UCL_COMPRESS_DATA *c, ucl_swd_t *s, DWORD this_len, DWORD skip) { if(skip > 0) { swd_accept(s, this_len - skip); c->textsize += this_len - skip + 1; } else c->textsize += this_len - skip; s->m_len = 1; swd_findbest(s); c->m_len = s->m_len; c->m_off = s->m_off; swd_getbyte(s); if(s->b_char < 0) { c->look = 0; c->m_len = 0; swd_exit(s); } else c->look = s->look + 1; c->bp = c->ip - c->look; if(c->pCallback && c->textsize > c->printcount) { (*c->pCallback->callback)(c->textsize, c->codesize, 3, c->pCallback->pData); c->printcount += 1024; } }
static int init_match(UCL_COMPRESS_T * c, ucl_swd_t * s, const ucl_byte * dict, ucl_uint dict_len, ucl_uint32 flags) { int r; assert(!c->init); c->init = 1; s->c = c; c->last_m_len = c->last_m_off = 0; c->textsize = c->codesize = c->printcount = 0; c->lit_bytes = c->match_bytes = c->rep_bytes = 0; c->lazy = 0; r = swd_init(s, dict, dict_len); if (r != UCL_E_OK) { swd_exit(s); return r; } s->use_best_off = (flags & 1) ? 1 : 0; return UCL_E_OK; }
static __inline int init_match(UCL_COMPRESS_DATA *c, ucl_swd_t *s, LPBYTE dict, DWORD dict_len, BYTE flags) { s->c = c; c->last_m_off = 0; c->textsize = c->codesize = c->printcount = 0; int r = swd_init(s, dict, dict_len); if(r != UCL::E_SUCCESSED) { swd_exit(s); return r; } return UCL::E_SUCCESSED; }
tINT init_match (tUCL_COMPRESS_CTX* c, tUCL_SWD* s, tBYTE* dict, tUINT dict_len, tUINT flags ) { int r; c->init = 1; s->c = c; c->last_m_len = c->last_m_off = 0; c->textsize = c->codesize = c->printcount = 0; c->lit_bytes = c->match_bytes = c->rep_bytes = 0; c->lazy = 0; r = swd_init(s,dict,dict_len); if (r != UCL_E_OK) { swd_exit(s); return r; } s->use_best_off = (flags & 1) ? 1 : 0; return UCL_E_OK; }
static int find_match ( struct ucl_compress *c, struct ucl_swd *s, unsigned int this_len, unsigned int skip ) { assert(c->init); if (skip > 0) { assert(this_len >= skip); swd_accept(s, this_len - skip); c->textsize += this_len - skip + 1; } else { assert(this_len <= 1); c->textsize += this_len - skip; } s->m_len = THRESHOLD; #ifdef SWD_BEST_OFF if (s->use_best_off) memset(s->best_pos,0,sizeof(s->best_pos)); #endif swd_findbest(s); c->m_len = s->m_len; c->m_off = s->m_off; swd_getbyte(s); if (s->b_char < 0) { c->look = 0; c->m_len = 0; swd_exit(s); } else { c->look = s->look + 1; } c->bp = c->ip - c->look; #if 0 /* brute force match search */ if (c->m_len > THRESHOLD && c->m_len + 1 <= c->look) { const uint8_t *ip = c->bp; const uint8_t *m = c->bp - c->m_off; const uint8_t *in = c->in; if (ip - in > N) in = ip - N; for (;;) { while (*in != *ip) in++; if (in == ip) break; if (in != m) if (memcmp(in,ip,c->m_len+1) == 0) printf("%p %p %p %5d\n",in,ip,m,c->m_len); in++; } } #endif return UCL_E_OK; }
static int find_match(UCL_COMPRESS_T * c, ucl_swd_t * s, ucl_uint this_len, ucl_uint skip) { assert(c->init); if (skip > 0) { assert(this_len >= skip); swd_accept(s, this_len - skip); c->textsize += this_len - skip + 1; } else { assert(this_len <= 1); c->textsize += this_len - skip; } s->m_len = THRESHOLD; #ifdef SWD_BEST_OFF if (s->use_best_off) memset(s->best_pos, 0, sizeof(s->best_pos)); #endif swd_findbest(s); c->m_len = s->m_len; #if defined(__UCL_CHECKER) /* s->m_off may be uninitialized if we didn't find a match, * but then its value will never be used. */ c->m_off = (s->m_len == THRESHOLD) ? 0 : s->m_off; #else c->m_off = s->m_off; #endif swd_getbyte(s); if (s->b_char < 0) { c->look = 0; c->m_len = 0; swd_exit(s); } else { c->look = s->look + 1; } c->bp = c->ip - c->look; #if 0 /* brute force match search */ if (c->m_len > THRESHOLD && c->m_len + 1 <= c->look) { const ucl_byte *ip = c->bp; const ucl_byte *m = c->bp - c->m_off; const ucl_byte *in = c->in; if (ip - in > N) in = ip - N; for (;;) { while (*in != *ip) in++; if (in == ip) break; if (in != m) if (memcmp(in, ip, c->m_len + 1) == 0) printf("%p %p %p %5d\n", in, ip, m, c->m_len); in++; } } #endif if (c->cb && c->textsize > c->printcount) { (*c->cb->callback) (c->textsize, c->codesize, 3, c->cb->user); c->printcount += 1024; } return UCL_E_OK; }