/*********************************************************************** This file is part of HA, a general purpose file archiver. Copyright (C) 1995 Harri Hirvola This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ************************************************************************ HA sliding window dictionary ***********************************************************************/ #include #include #include "ha.h" #include "haio.h" #include "swdict.h" #include "error.h" #define HSIZE 16384 #define HSHIFT 3 #define HASH(p) ((b[p]^((b[p+1]^(b[p+2]<MAXCNT) cnt=MAXCNT; ptr=ll[bbf]=cr[i]; cr[i]=bbf; swd_char=b[bbf]; if ((start_len=swd_mlf)>=bbl) { if (bbl==0) swd_char=-1; best[bbf]=30000; } else { for (ref=b[bbf+swd_mlf-1];cnt--;ptr=ll[ptr]) { if (b[ptr+swd_mlf-1]==ref && b[ptr]==b[bbf] && b[ptr+1]==b[bbf+1]) { { register unsigned char *p1=b+ptr+3,*p2=b+bbf+3; for (i=3;istart_len) { if (swd_bposp) p=bbf-1-p; else p=cblen-1-p+bbf; while (l--) { b[bbf]=b[p]; putbyte(b[p]); if (++bbf==cblen) bbf=0; if (++p==cblen) p=0; } } void swd_dchar(S16B c) { b[bbf]=c; putbyte(c); if (++bbf==cblen) bbf=0; }