#ifndef DEFUTIL_H #define DEFUTIL_H #include <linux/zutil.h> #define Assert(err, str) … #define Trace(dummy) … #define Tracev(dummy) … #define Tracecv(err, dummy) … #define Tracevv(dummy) … #define LENGTH_CODES … /* number of length codes, not counting the special END_BLOCK code */ #define LITERALS … /* number of literal bytes 0..255 */ #define L_CODES … /* number of Literal or Length codes, including the END_BLOCK code */ #define D_CODES … /* number of distance codes */ #define BL_CODES … /* number of codes used to transfer the bit lengths */ #define HEAP_SIZE … /* maximum heap size */ #define MAX_BITS … /* All codes must not exceed MAX_BITS bits */ #define INIT_STATE … #define BUSY_STATE … #define FINISH_STATE … /* Stream status */ /* Data structure describing a single value and its code string. */ ct_data; #define Freq … #define Code … #define Dad … #define Len … static_tree_desc; tree_desc; Pos; IPos; /* A Pos is an index in the character window. We use short instead of int to * save space in the various tables. IPos is used only for parameter passing. */ deflate_state; #ifdef CONFIG_ZLIB_DFLTCC #define zlib_deflate_window_memsize … #else #define zlib_deflate_window_memsize(windowBits) … #endif #define zlib_deflate_prev_memsize(windowBits) … #define zlib_deflate_head_memsize(memLevel) … #define zlib_deflate_overlay_memsize(memLevel) … /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ #define put_byte(s, c) … #define MIN_LOOKAHEAD … /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ #define MAX_DIST(s) … /* In order to simplify the code, particularly on 16 bit machines, match * distances are limited to MAX_DIST instead of WSIZE. */ /* in trees.c */ void zlib_tr_init (deflate_state *s); int zlib_tr_tally (deflate_state *s, unsigned dist, unsigned lc); ulg zlib_tr_flush_block (deflate_state *s, char *buf, ulg stored_len, int eof); void zlib_tr_align (deflate_state *s); void zlib_tr_stored_block (deflate_state *s, char *buf, ulg stored_len, int eof); void zlib_tr_stored_type_only (deflate_state *); /* =========================================================================== * Output a short LSB first on the stream. * IN assertion: there is enough room in pendingBuf. */ #define put_short(s, w) … /* =========================================================================== * Reverse the first len bits of a code, using straightforward code (a faster * method would use a table) * IN assertion: 1 <= len <= 15 */ static inline unsigned bi_reverse( unsigned code, /* the value to invert */ int len /* its bit length */ ) { … } /* =========================================================================== * Flush the bit buffer, keeping at most 7 bits in it. */ static inline void bi_flush(deflate_state *s) { … } /* =========================================================================== * Flush the bit buffer and align the output on a byte boundary */ static inline void bi_windup(deflate_state *s) { … } block_state; #define Buf_size … /* Number of bits used within bi_buf. (bi_buf might be implemented on * more than 16 bits on some systems.) */ /* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef DEBUG_ZLIB static void send_bits (deflate_state *s, int value, int length); static void send_bits( deflate_state *s, int value, /* value to send */ int length /* number of bits */ ) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid)) * unused bits in value. */ if (s->bi_valid > (int)Buf_size - length) { s->bi_buf |= (value << s->bi_valid); put_short(s, s->bi_buf); s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); s->bi_valid += length - Buf_size; } else { s->bi_buf |= value << s->bi_valid; s->bi_valid += length; } } #else /* !DEBUG_ZLIB */ #define send_bits(s, value, length) … #endif /* DEBUG_ZLIB */ static inline void zlib_tr_send_bits( deflate_state *s, int value, int length ) { … } /* ========================================================================= * Flush as much pending output as possible. All deflate() output goes * through this function so some applications may wish to modify it * to avoid allocating a large strm->next_out buffer and copying into it. * (See also read_buf()). */ static inline void flush_pending( z_streamp strm ) { … } #endif /* DEFUTIL_H */