mk-conf.sh, mk-mk.in: use variables for *all* utilities
[s-mailx.git] / lzw.c
blobd5250c63929e4b325f97e3d2855ef82ad011c586
1 /*@ S-nail - a mail user agent derived from Berkeley Mail.
2 *@ LZW file compression.
4 * Copyright (c) 2000-2004 Gunnar Ritter, Freiburg i. Br., Germany.
5 * Copyright (c) 2012 - 2013 Steffen "Daode" Nurpmeso <sdaoden@users.sf.net>.
6 */
7 /*-
8 * Copyright (c) 1985, 1986, 1992, 1993
9 * The Regents of the University of California. All rights reserved.
11 * This code is derived from software contributed to Berkeley by
12 * Diomidis Spinellis and James A. Woods, derived from original
13 * work by Spencer Thomas and Joseph Orost.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
40 /* from zopen.c 8.1 (Berkeley) 6/27/93 */
41 /* from FreeBSD: /repoman/r/ncvs/src/usr.bin/compress/zopen.c,v
42 * 1.5.6.1 2002/07/16 00:52:08 tjr Exp */
43 /* from FreeBSD: git://git.freebsd.org/freebsd,
44 * master:usr.bin/compress/zopen.c,
45 * (Fix handling of corrupt compress(1)ed data. [11:04], 2011-09-28) */
47 /*-
48 * lzw.c - File compression ala IEEE Computer, June 1984.
50 * Compress authors:
51 * Spencer W. Thomas (decvax!utah-cs!thomas)
52 * Jim McKie (decvax!mcvax!jim)
53 * Steve Davies (decvax!vax135!petsd!peora!srd)
54 * Ken Turkowski (decvax!decwrl!turtlevax!ken)
55 * James A. Woods (decvax!ihnp4!ames!jaw)
56 * Joe Orost (decvax!vax135!petsd!joe)
58 * Cleaned up and converted to library returning I/O streams by
59 * Diomidis Spinellis <dds@doc.ic.ac.uk>.
61 * Adopted for Heirloom mailx by Gunnar Ritter.
64 #ifndef HAVE_AMALGAMATION
65 # include "nail.h"
66 #endif
68 EMPTY_FILE(lzw)
69 #ifdef HAVE_IMAP
70 /* Minimize differences to FreeBSDs usr.bin/compress/zopen.c */
71 #undef u_int
72 #define u_int unsigned int
73 #undef u_short
74 #define u_short unsigned short
75 #undef u_char
76 #define u_char unsigned char
77 #define count cnt
79 #define BITS 16 /* Default bits. */
80 #define HSIZE 69001 /* 95% occupancy */
82 /* A code_int must be able to hold 2**BITS values of type int, and also -1. */
83 typedef long code_int;
84 typedef long count_int;
86 typedef u_char char_type;
87 static char_type magic_header[] = {0x1F, 0x9D}; /* \037, \235 */
89 #define BIT_MASK 0x1f /* Defines for third byte of header. */
90 #define BLOCK_MASK 0x80
93 * Masks 0x40 and 0x20 are free. I think 0x20 should mean that there is
94 * a fourth header byte (for expansion).
96 #define INIT_BITS 9 /* Initial number of bits/code. */
98 #define MAXCODE(n_bits) ((1 << (n_bits)) - 1)
100 struct s_zstate {
101 FILE *zs_fp; /* File stream for I/O */
102 char zs_mode; /* r or w */
103 enum {
104 S_START, S_MIDDLE, S_EOF
105 } zs_state; /* State of computation */
106 u_int zs_n_bits; /* Number of bits/code. */
107 u_int zs_maxbits; /* User settable max # bits/code. */
108 code_int zs_maxcode; /* Maximum code, given n_bits. */
109 code_int zs_maxmaxcode; /* Should NEVER generate this code. */
110 count_int zs_htab [HSIZE];
111 u_short zs_codetab [HSIZE];
112 code_int zs_hsize; /* For dynamic table sizing. */
113 code_int zs_free_ent; /* First unused entry. */
115 * Block compression parameters -- after all codes are used up,
116 * and compression rate changes, start over.
118 int zs_block_compress;
119 int zs_clear_flg;
120 long zs_ratio;
121 count_int zs_checkpoint;
122 u_int zs_offset;
123 long zs_in_count; /* Length of input. */
124 long zs_bytes_out; /* Length of compressed output. */
125 long zs_out_count; /* # of codes output (for debugging). */
126 char_type zs_buf[BITS];
127 union {
128 struct {
129 long zs_fcode;
130 code_int zs_ent;
131 code_int zs_hsize_reg;
132 int zs_hshift;
133 } w; /* Write parameters */
134 struct {
135 char_type *zs_stackp;
136 int zs_finchar;
137 code_int zs_code, zs_oldcode, zs_incode;
138 int zs_roffset, zs_size;
139 char_type zs_gbuf[BITS];
140 } r; /* Read parameters */
141 } u;
144 /* Definitions to retain old variable names */
145 #define fp zs->zs_fp
146 #define zmode zs->zs_mode
147 #define state zs->zs_state
148 #define n_bits zs->zs_n_bits
149 #define maxbits zs->zs_maxbits
150 #define maxcode zs->zs_maxcode
151 #define maxmaxcode zs->zs_maxmaxcode
152 #define htab zs->zs_htab
153 #define codetab zs->zs_codetab
154 #define hsize zs->zs_hsize
155 #define free_ent zs->zs_free_ent
156 #define block_compress zs->zs_block_compress
157 #define clear_flg zs->zs_clear_flg
158 #define ratio zs->zs_ratio
159 #define checkpoint zs->zs_checkpoint
160 #define offset zs->zs_offset
161 #define in_count zs->zs_in_count
162 #define bytes_out zs->zs_bytes_out
163 #define out_count zs->zs_out_count
164 #define buf zs->zs_buf
165 #define fcode zs->u.w.zs_fcode
166 #define hsize_reg zs->u.w.zs_hsize_reg
167 #define ent zs->u.w.zs_ent
168 #define hshift zs->u.w.zs_hshift
169 #define stackp zs->u.r.zs_stackp
170 #define finchar zs->u.r.zs_finchar
171 #define code zs->u.r.zs_code
172 #define oldcode zs->u.r.zs_oldcode
173 #define incode zs->u.r.zs_incode
174 #define roffset zs->u.r.zs_roffset
175 #define size zs->u.r.zs_size
176 #define gbuf zs->u.r.zs_gbuf
179 * To save much memory, we overlay the table used by compress() with those
180 * used by decompress(). The tab_prefix table is the same size and type as
181 * the codetab. The tab_suffix table needs 2**BITS characters. We get this
182 * from the beginning of htab. The output stack uses the rest of htab, and
183 * contains characters. There is plenty of room for any possible stack
184 * (stack used to be 8000 characters).
187 #define htabof(i) htab[i]
188 #define codetabof(i) codetab[i]
190 #define tab_prefixof(i) codetabof(i)
191 #define tab_suffixof(i) ((char_type *)(htab))[i]
192 #define de_stack ((char_type *)&tab_suffixof(1 << BITS))
194 #define CHECK_GAP 10000 /* Ratio check interval. */
197 * the next two codes should not be changed lightly, as they must not
198 * lie within the contiguous general code space.
200 #define FIRST 257 /* First free entry. */
201 #define CLEAR 256 /* Table clear output code. */
203 static int cl_block(struct s_zstate *);
204 static void cl_hash(struct s_zstate *, count_int);
205 static code_int getcode(struct s_zstate *);
206 static int output(struct s_zstate *, code_int);
209 * Algorithm from "A Technique for High Performance Data Compression",
210 * Terry A. Welch, IEEE Computer Vol 17, No 6 (June 1984), pp 8-19.
212 * Algorithm:
213 * Modified Lempel-Ziv method (LZW). Basically finds common
214 * substrings and replaces them with a variable size code. This is
215 * deterministic, and can be done on the fly. Thus, the decompression
216 * procedure needs no input table, but tracks the way the table was built.
220 * compress write
222 * Algorithm: use open addressing double hashing (no chaining) on the
223 * prefix code / next character combination. We do a variant of Knuth's
224 * algorithm D (vol. 3, sec. 6.4) along with G. Knott's relatively-prime
225 * secondary probe. Here, the modular division first probe is gives way
226 * to a faster exclusive-or manipulation. Also do block compression with
227 * an adaptive reset, whereby the code table is cleared when the compression
228 * ratio decreases, but after the table fills. The variable-length output
229 * codes are re-sized at this point, and a special CLEAR code is generated
230 * for the decompressor. Late addition: construct the table according to
231 * file size for noticeable speed improvement on small files. Please direct
232 * questions about this implementation to ames!jaw.
234 FL int
235 zwrite(void *cookie, const char *wbp, int num)
237 code_int i;
238 int c, disp;
239 struct s_zstate *zs;
240 const u_char *bp;
241 u_char tmp;
242 int count;
244 if (num == 0)
245 return (0);
247 zs = cookie;
248 zmode = 'w';
249 count = num;
250 bp = (const u_char *)wbp;
251 if (state == S_MIDDLE)
252 goto middle;
253 state = S_MIDDLE;
255 maxmaxcode = 1L << maxbits;
256 if (fwrite(magic_header,
257 sizeof(char), sizeof(magic_header), fp) != sizeof(magic_header))
258 return (-1);
259 tmp = (u_char)((maxbits) | block_compress);
260 if (fwrite(&tmp, sizeof(char), sizeof(tmp), fp) != sizeof(tmp))
261 return (-1);
263 offset = 0;
264 bytes_out = 3; /* Includes 3-byte header mojo. */
265 out_count = 0;
266 clear_flg = 0;
267 ratio = 0;
268 in_count = 1;
269 checkpoint = CHECK_GAP;
270 maxcode = MAXCODE(n_bits = INIT_BITS);
271 free_ent = ((block_compress) ? FIRST : 256);
273 ent = *bp++;
274 --count;
276 hshift = 0;
277 for (fcode = (long)hsize; fcode < 65536L; fcode *= 2L)
278 hshift++;
279 hshift = 8 - hshift; /* Set hash code range bound. */
281 hsize_reg = hsize;
282 cl_hash(zs, (count_int)hsize_reg); /* Clear hash table. */
284 middle: for (i = 0; count--;) {
285 c = *bp++;
286 in_count++;
287 fcode = (long)(((long)c << maxbits) + ent);
288 i = ((c << hshift) ^ ent); /* Xor hashing. */
290 if (htabof(i) == fcode) {
291 ent = codetabof(i);
292 continue;
293 } else if ((long)htabof(i) < 0) /* Empty slot. */
294 goto nomatch;
295 disp = hsize_reg - i; /* Secondary hash (after G. Knott). */
296 if (i == 0)
297 disp = 1;
298 probe: if ((i -= disp) < 0)
299 i += hsize_reg;
301 if (htabof(i) == fcode) {
302 ent = codetabof(i);
303 continue;
305 if ((long)htabof(i) >= 0)
306 goto probe;
307 nomatch: if (output(zs, (code_int) ent) == -1)
308 return (-1);
309 out_count++;
310 ent = c;
311 if (free_ent < maxmaxcode) {
312 codetabof(i) = free_ent++; /* code -> hashtable */
313 htabof(i) = fcode;
314 } else if ((count_int)in_count >=
315 checkpoint && block_compress) {
316 if (cl_block(zs) == -1)
317 return (-1);
320 return (num);
323 FL int
324 zfree(void *cookie)
326 struct s_zstate *zs;
328 zs = cookie;
329 if (zmode == 'w') { /* Put out the final code. */
330 if (output(zs, (code_int) ent) == -1) {
331 free(zs);
332 return (-1);
334 out_count++;
335 if (output(zs, (code_int) - 1) == -1) {
336 free(zs);
337 return (-1);
340 free(zs);
341 return (0);
345 * Output the given code.
346 * Inputs:
347 * code: A n_bits-bit integer. If == -1, then EOF. This assumes
348 * that n_bits =< (long)wordsize - 1.
349 * Outputs:
350 * Outputs code to the file.
351 * Assumptions:
352 * Chars are 8 bits long.
353 * Algorithm:
354 * Maintain a BITS character long buffer (so that 8 codes will
355 * fit in it exactly). Use the VAX insv instruction to insert each
356 * code in turn. When the buffer fills up empty it and start over.
359 static char_type lmask[9] =
360 {0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00};
361 static char_type rmask[9] =
362 {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
364 static int
365 output(struct s_zstate *zs, code_int ocode)
367 int r_off;
368 u_int bits;
369 char_type *bp;
371 r_off = offset;
372 bits = n_bits;
373 bp = buf;
374 if (ocode >= 0) {
375 /* Get to the first byte. */
376 bp += (r_off >> 3);
377 r_off &= 7;
379 * Since ocode is always >= 8 bits, only need to mask the first
380 * hunk on the left.
382 *bp = (*bp & rmask[r_off]) | ((ocode << r_off) & lmask[r_off]);
383 bp++;
384 bits -= (8 - r_off);
385 ocode >>= 8 - r_off;
386 /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
387 if (bits >= 8) {
388 *bp++ = ocode;
389 ocode >>= 8;
390 bits -= 8;
392 /* Last bits. */
393 if (bits)
394 *bp = ocode;
395 offset += n_bits;
396 if (offset == (n_bits << 3)) {
397 bp = buf;
398 bits = n_bits;
399 bytes_out += bits;
400 if (fwrite(bp, sizeof(char), bits, fp) != bits)
401 return (-1);
402 bp += bits;
403 bits = 0;
404 offset = 0;
407 * If the next entry is going to be too big for the ocode size,
408 * then increase it, if possible.
410 if (free_ent > maxcode || (clear_flg > 0)) {
412 * Write the whole buffer, because the input side won't
413 * discover the size increase until after it has read it.
415 if (offset > 0) {
416 if (fwrite(buf, 1, n_bits, fp) != n_bits)
417 return (-1);
418 bytes_out += n_bits;
420 offset = 0;
422 if (clear_flg) {
423 maxcode = MAXCODE(n_bits = INIT_BITS);
424 clear_flg = 0;
425 } else {
426 n_bits++;
427 if (n_bits == maxbits)
428 maxcode = maxmaxcode;
429 else
430 maxcode = MAXCODE(n_bits);
433 } else {
434 /* At EOF, write the rest of the buffer. */
435 if (offset > 0) {
436 offset = (offset + 7) / 8;
437 if (fwrite(buf, 1, offset, fp) != offset)
438 return (-1);
439 bytes_out += offset;
441 offset = 0;
443 return (0);
447 * Decompress read. This routine adapts to the codes in the file building
448 * the "string" table on-the-fly; requiring no table to be stored in the
449 * compressed file. The tables used herein are shared with those of the
450 * compress() routine. See the definitions above.
452 FL int
453 zread(void *cookie, char *rbp, int num)
455 u_int count;
456 struct s_zstate *zs;
457 u_char *bp, header[3];
459 if (num == 0)
460 return (0);
462 zs = cookie;
463 count = num;
464 bp = (u_char *)rbp;
465 switch (state) {
466 case S_START:
467 state = S_MIDDLE;
468 break;
469 case S_MIDDLE:
470 goto middle;
471 case S_EOF:
472 goto eof;
475 /* Check the magic number */
476 if (fread(header,
477 sizeof(char), sizeof(header), fp) != sizeof(header) ||
478 memcmp(header, magic_header, sizeof(magic_header)) != 0) {
479 return (-1);
481 maxbits = header[2]; /* Set -b from file. */
482 block_compress = maxbits & BLOCK_MASK;
483 maxbits &= BIT_MASK;
484 maxmaxcode = 1L << maxbits;
485 if (maxbits > BITS || maxbits < 12) {
486 return (-1);
488 /* As above, initialize the first 256 entries in the table. */
489 maxcode = MAXCODE(n_bits = INIT_BITS);
490 for (code = 255; code >= 0; code--) {
491 tab_prefixof(code) = 0;
492 tab_suffixof(code) = (char_type) code;
494 free_ent = block_compress ? FIRST : 256;
496 finchar = oldcode = getcode(zs);
497 if (oldcode == -1) /* EOF already? */
498 return (0); /* Get out of here */
500 /* First code must be 8 bits = char. */
501 *bp++ = (u_char)finchar;
502 count--;
503 stackp = de_stack;
505 while ((code = getcode(zs)) > -1) {
507 if ((code == CLEAR) && block_compress) {
508 for (code = 255; code >= 0; code--)
509 tab_prefixof(code) = 0;
510 clear_flg = 1;
511 free_ent = FIRST;
512 oldcode = -1;
513 continue;
515 incode = code;
517 /* Special case for kWkWk string. */
518 if (code >= free_ent) {
519 if (code > free_ent || oldcode == -1) {
520 return (-1);
522 *stackp++ = finchar;
523 code = oldcode;
526 * The above condition ensures that code < free_ent.
527 * The construction of tab_prefixof in turn guarantees that
528 * each iteration decreases code and therefore stack usage is
529 * bound by 1 << BITS - 256.
532 /* Generate output characters in reverse order. */
533 while (code >= 256) {
534 *stackp++ = tab_suffixof(code);
535 code = tab_prefixof(code);
537 *stackp++ = finchar = tab_suffixof(code);
539 /* And put them out in forward order. */
540 middle: do {
541 if (count-- == 0)
542 return (num);
543 *bp++ = *--stackp;
544 } while (stackp > de_stack);
546 /* Generate the new entry. */
547 if ((code = free_ent) < maxmaxcode && oldcode != -1) {
548 tab_prefixof(code) = (u_short) oldcode;
549 tab_suffixof(code) = finchar;
550 free_ent = code + 1;
553 /* Remember previous code. */
554 oldcode = incode;
556 state = S_EOF;
557 eof: return (num - count);
561 * Read one code from the standard input. If EOF, return -1.
562 * Inputs:
563 * stdin
564 * Outputs:
565 * code or -1 is returned.
567 static code_int
568 getcode(struct s_zstate *zs)
570 code_int gcode;
571 int r_off, bits;
572 char_type *bp;
574 bp = gbuf;
575 if (clear_flg > 0 || roffset >= size || free_ent > maxcode) {
577 * If the next entry will be too big for the current gcode
578 * size, then we must increase the size. This implies reading
579 * a new buffer full, too.
581 if (free_ent > maxcode) {
582 n_bits++;
583 if (n_bits == maxbits) /* Won't get any bigger now. */
584 maxcode = maxmaxcode;
585 else
586 maxcode = MAXCODE(n_bits);
588 if (clear_flg > 0) {
589 maxcode = MAXCODE(n_bits = INIT_BITS);
590 clear_flg = 0;
592 size = fread(gbuf, 1, n_bits, fp);
593 if (size <= 0) /* End of file. */
594 return (-1);
595 roffset = 0;
596 /* Round size down to integral number of codes. */
597 size = (size << 3) - (n_bits - 1);
599 r_off = roffset;
600 bits = n_bits;
602 /* Get to the first byte. */
603 bp += (r_off >> 3);
604 r_off &= 7;
606 /* Get first part (low order bits). */
607 gcode = (*bp++ >> r_off);
608 bits -= (8 - r_off);
609 r_off = 8 - r_off; /* Now, roffset into gcode word. */
611 /* Get any 8 bit parts in the middle (<=1 for up to 16 bits). */
612 if (bits >= 8) {
613 gcode |= *bp++ << r_off;
614 r_off += 8;
615 bits -= 8;
618 /* High order bits. */
619 gcode |= (*bp & rmask[bits]) << r_off;
620 roffset += n_bits;
622 return (gcode);
625 static int
626 cl_block(struct s_zstate *zs) /* Table clear for block compress. */
628 long rat;
630 checkpoint = in_count + CHECK_GAP;
632 if (in_count > 0x007fffff) { /* Shift will overflow. */
633 rat = bytes_out >> 8;
634 if (rat == 0) /* Don't divide by zero. */
635 rat = 0x7fffffff;
636 else
637 rat = in_count / rat;
638 } else
639 rat = (in_count << 8) / bytes_out; /* 8 fractional bits. */
640 if (rat > ratio)
641 ratio = rat;
642 else {
643 ratio = 0;
644 cl_hash(zs, (count_int) hsize);
645 free_ent = FIRST;
646 clear_flg = 1;
647 if (output(zs, (code_int) CLEAR) == -1)
648 return (-1);
650 return (0);
653 static void
654 cl_hash(struct s_zstate *zs, count_int cl_hsize) /* Reset code table. */
656 count_int *htab_p;
657 long i, m1;
659 m1 = -1;
660 htab_p = htab + cl_hsize;
661 i = cl_hsize - 16;
662 do { /* Might use Sys V memset(3) here. */
663 *(htab_p - 16) = m1;
664 *(htab_p - 15) = m1;
665 *(htab_p - 14) = m1;
666 *(htab_p - 13) = m1;
667 *(htab_p - 12) = m1;
668 *(htab_p - 11) = m1;
669 *(htab_p - 10) = m1;
670 *(htab_p - 9) = m1;
671 *(htab_p - 8) = m1;
672 *(htab_p - 7) = m1;
673 *(htab_p - 6) = m1;
674 *(htab_p - 5) = m1;
675 *(htab_p - 4) = m1;
676 *(htab_p - 3) = m1;
677 *(htab_p - 2) = m1;
678 *(htab_p - 1) = m1;
679 htab_p -= 16;
680 } while ((i -= 16) >= 0);
681 for (i += 16; i > 0; i--)
682 *--htab_p = m1;
685 #undef fp
686 FL void *
687 zalloc(FILE *fp)
689 #define bits BITS
690 struct s_zstate *zs;
692 zs = scalloc(1, sizeof *zs);
693 maxbits = bits ? bits : BITS; /* User settable max # bits/code. */
694 maxmaxcode = 1L << maxbits; /* Should NEVER generate this code. */
695 hsize = HSIZE; /* For dynamic table sizing. */
696 free_ent = 0; /* First unused entry. */
697 block_compress = BLOCK_MASK;
698 clear_flg = 0;
699 ratio = 0;
700 checkpoint = CHECK_GAP;
701 in_count = 1; /* Length of input. */
702 out_count = 0; /* # of codes output (for debugging). */
703 state = S_START;
704 roffset = 0;
705 size = 0;
706 zs->zs_fp = fp;
707 return zs;
710 #undef u_int
711 #undef u_short
712 #undef u_char
713 #undef count
714 #undef BITS
715 #undef HSIZE
716 #undef BIT_MASK
717 #undef BLOCK_MASK
718 #undef INIT_BITS
719 #undef MAXCODE
720 #undef fp
721 #undef zmode
722 #undef state
723 #undef n_bits
724 #undef maxbits
725 #undef maxcode
726 #undef maxmaxcode
727 #undef htab
728 #undef codetab
729 #undef hsize
730 #undef free_ent
731 #undef block_compress
732 #undef clear_flg
733 #undef ratio
734 #undef checkpoint
735 #undef offset
736 #undef in_count
737 #undef bytes_out
738 #undef out_count
739 #undef buf
740 #undef fcode
741 #undef hsize_reg
742 #undef ent
743 #undef hshift
744 #undef stackp
745 #undef finchar
746 #undef code
747 #undef oldcode
748 #undef incode
749 #undef roffset
750 #undef size
751 #undef gbuf
752 #endif /* ndef HAVE_IMAP */