source: trunk/poppler/freetype-2.1.10/src/lzw/zopen.h @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 3.8 KB
Line 
1/*      $NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $    */
2
3/*-
4 * Copyright (c) 1985, 1986, 1992, 1993
5 *      The Regents of the University of California.  All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Diomidis Spinellis and James A. Woods, derived from original
9 * work by Spencer Thomas and Joseph Orost.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 *    notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 *    notice, this list of conditions and the following disclaimer in the
18 *    documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the University nor the names of its contributors
20 *    may be used to endorse or promote products derived from this software
21 *    without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 */
35
36/*-
37 *
38 * Copyright (c) 2004
39 *      Albert Chin-A-Young.
40 *
41 * Modified to work with FreeType's PCF driver.
42 *
43 */
44
45#if defined(LIBC_SCCS) && !defined(lint)
46#if 0
47static char sccsid[] = "@(#)zopen.c     8.1 (Berkeley) 6/27/93";
48#else
49static char rcsid[] = "$NetBSD: zopen.c,v 1.8 2003/08/07 11:13:29 agc Exp $";
50#endif
51#endif /* LIBC_SCCS and not lint */
52
53#include <stdio.h>
54
55#define BITS            16              /* Default bits. */
56#define HSIZE           69001           /* 95% occupancy */
57
58/* A code_int must be able to hold 2**BITS values of type int, and also -1. */
59typedef long code_int;
60typedef long count_int;
61
62typedef unsigned char char_type;
63
64typedef enum {
65        S_START, S_MIDDLE, S_EOF
66} zs_enum;
67
68typedef struct {
69        unsigned char *next_in;
70        unsigned int avail_in;
71        unsigned long total_in;
72
73        unsigned char *next_out;
74        unsigned int avail_out;
75        unsigned long total_out;
76
77        zs_enum zs_state;               /* State of computation */
78        int zs_n_bits;                  /* Number of bits/code. */
79        int zs_maxbits;                 /* User settable max # bits/code. */
80        code_int zs_maxcode;            /* Maximum code, given n_bits. */
81        code_int zs_maxmaxcode;         /* Should NEVER generate this code. */
82        count_int zs_htab [HSIZE];
83        unsigned short zs_codetab [HSIZE];
84        code_int zs_hsize;              /* For dynamic table sizing. */
85        code_int zs_free_ent;           /* First unused entry. */
86        /*
87         * Block compression parameters -- after all codes are used up,
88         * and compression rate changes, start over.
89         */
90        int zs_block_compress;
91        int zs_clear_flg;
92        int zs_offset;
93        long zs_in_count;               /* Remaining uncompressed bytes. */
94        char_type zs_buf_len;
95        char_type zs_buf[BITS];         /* Temporary buffer if we need
96                                           to read more to accumulate
97                                           n_bits. */
98        union {
99                struct {
100                        char_type *zs_stackp;
101                        int zs_finchar;
102                        code_int zs_code, zs_oldcode, zs_incode;
103                        int zs_roffset, zs_size;
104                        char_type zs_gbuf[BITS];
105                } r;                    /* Read parameters */
106        } u;
107} s_zstate_t;
108
109static code_int getcode(s_zstate_t *);
110#if 0
111static int      zclose(s_zstate_t *);
112#endif
113static void     zinit(s_zstate_t *);
114static int      zread(s_zstate_t *);
Note: See TracBrowser for help on using the repository browser.