SHARE
TWEET

LZSS

MaKiPL May 4th, 2016 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void Decode(void)   /* Just the reverse of Encode(). */
  2. {
  3.     int  i, j, k, r, c;
  4.     unsigned int  flags;
  5.    
  6.     for (i = 0; i < N - F; i++) text_buf[i] = ' ';
  7.     r = N - F;  flags = 0;
  8.     for ( ; ; ) {
  9.         if (((flags >>= 1) & 256) == 0) {
  10.             if ((c = getc(infile)) == EOF) break;
  11.             flags = c | 0xff00;     /* uses higher byte cleverly */
  12.         }                           /* to count eight */
  13.         if (flags & 1) {
  14.             if ((c = getc(infile)) == EOF) break;
  15.             putc(c, outfile);  text_buf[r++] = c;  r &= (N - 1);
  16.         } else {
  17.             if ((i = getc(infile)) == EOF) break;
  18.             if ((j = getc(infile)) == EOF) break;
  19.             i |= ((j & 0xf0) << 4);  j = (j & 0x0f) + THRESHOLD;
  20.             for (k = 0; k <= j; k++) {
  21.                 c = text_buf[(i + k) & (N - 1)];
  22.                 putc(c, outfile);  text_buf[r++] = c;  r &= (N - 1);
  23.             }
  24.         }
  25.     }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top