head 1.1; branch 1.1.1; access; symbols trunk-20040613:1.1.1.2 mach64-last-merge:1.1.1.2 driinterface-0-0-3-20040303-merge:1.1.1.2 driinterface-0-0-3-20040303-premerge:1.1.1.2 driinterface-0-0-3-20040303:1.1.1.2 driinterface-0-0-3-branch:1.1.1.2.0.92 mach64-0-0-7-branch:1.1.1.2.0.90 driinterface-0-0-2-branch:1.1.1.2.0.88 newmesa-0-0-1-20031209-merge:1.1.1.2 trunk-20031209:1.1.1.2 newmesa-0-0-1-20031209:1.1.1.2 newmesa-0-0-1-branch:1.1.1.2.0.86 driinterface-0-0-1-branch:1.1.1.2.0.84 savage-2-0-0-branch:1.1.1.2.0.82 savage-2-0-0-fork:1.1.1.2 config-0-0-1-20031005-freeze:1.1.1.2 savage-1_0_0-20031002-trunk-premerge:1.1.1.2 cle266-0-0-1-branch:1.1.1.2.0.80 i865-agp-0-1-20030929:1.1.1.2 trunk-20030916:1.1.1.2 XFree86-4_3_99_12-merge:1.1.1.2 trunk-20030912:1.1.1.2 i865-agp-0-1-20030905:1.1.1.2 i865-agp-0-1-20030728:1.1.1.2 i865-agp-0-1-20030707:1.1.1.2 savage-1_0_0-branch:1.1.1.2.0.78 newdrm-0-0-1-branch:1.1.1.2.0.76 i865-agp-0-1-branch:1.1.1.2.0.74 config-0-0-1-branch:1.1.1.2.0.72 texmem-0-0-1-20030429-merge:1.1.1.2 texmem-0-0-1-20030429-premerge:1.1.1.2 texmem-0-0-1-20030407:1.1.1.2 trident-0-0-2-branch:1.1.1.2.0.70 mach64-0-0-6-20030330:1.1.1.2 mach64-0-0-6-20030329-freeze:1.1.1.2 texmem-0-0-1-20030328-freeze:1.1.1.2 X_4_3_0-20030324-merge:1.1.1.2 X_4_3_0-20020324-preimport:1.1.1.2 drm-filp-0-1-branch:1.1.1.2.0.68 mesa-4-0-4-20030222:1.1.1.2 bsd-4-0-0-20030221-merge:1.1.1.2 bsd-4-0-0-20030220:1.1.1.2 bsd-4-0-0-20030220-freeze:1.1.1.2 mesa-4-0-4-20030216:1.1.1.2 mach64-0-0-6-branch:1.1.1.2.0.66 mesa-4-0-4-20030208:1.1.1.2 texmem-0-0-1-20030204-trunk-merge:1.1.1.2 texmem-0-0-1-20030204-trunk-premerge:1.1.1.2 mesa-4-0-4-20030203:1.1.1.2 mesa-4-0-4-20030129:1.1.1.2 texmem-0-0-1-20030125-trunk-merge:1.1.1.2 texmem-0-0-1-20030123-trunk-premerge:1.1.1.2 mesa-4-0-4-20030114:1.1.1.2 agpgart_2_0_branch:1.1.1.2.0.64 mesa-4-0-4-20021220:1.1.1.2 mesa-4-0-4-20021216:1.1.1.2 mesa-4-0-4-20021215:1.1.1.2 mesa-4-0-4-20021214:1.1.1.2 mesa-4-0-4-branch:1.1.1.2.0.62 dmx-1-0-20021129-final:1.1.1.2 texmem-0-0-1-20021127-mesa-4-1-merge:1.1.1.2 trunk-20021125:1.1.1.2 dmx-1-0-20021115-beta:1.1.1.2 bsd-4-0-0-branch:1.1.1.2.0.60 nv-0-0-1-branch:1.1.1.2.0.58 savage-0-0-1-branch:1.1.1.2.0.56 stable-1-0-branch:1.1.1.2.0.54 r200-stable-1-0-20021028:1.1.1.2 dmx-1-0-20021025-alpha:1.1.1.2 X_4_2_99_2-20021023-merge:1.1.1.2 X_4_2_99_2:1.1.1.2 trunk-20021022:1.1.1.2 r200-stable-1-0-branch:1.1.1.2.0.52 mesa-4-1-branch:1.1.1.2.0.50 texmem-0-0-1:1.1.1.2.0.48 trunk-20021002:1.1.1.2 dmx-1-0-20020926-final:1.1.1.2 dmx-1-0-20020830-beta:1.1.1.2 r200-0-2-branch:1.1.1.2.0.46 r200-0-1-20020822-merge:1.1.1.2 r200-0-1-20020822:1.1.1.2 r200-0-1-20020826-freeze:1.1.1.2 xv845g-0-1-branch:1.1.1.2.0.44 xv845g-0-1-bp:1.1.1.2 GEODE-BASE-DRIVER:1.1.1.2 geode-0-0-1-branch:1.1.1.2.0.42 tdlabs-0-0-1-branch:1.1.1.2.0.40 reinit-0-0-1-branch:1.1.1.2.0.38 dmx-1-0-20020719-alpha:1.1.1.2 r200-0-1-20020715:1.1.1.2 r200-0-1-20020714-freeze:1.1.1.2 bsd-3-0-0-20020705-merge:1.1.1.2 bsd-3-0-0-freeze:1.1.1.2 trunk-20020705:1.1.1.2 bsd-3-0-0-20020705:1.1.1.2 trunk-20020703:1.1.1.2 mach64-0-0-5-branch:1.1.1.2.0.34 trunk-20020626:1.1.1.2 trunk-20020617:1.1.1.2 tcl-0-0-20020612-merge:1.1.1.2 tcl-0-0-20020612:1.1.1.2 tcl-0-0-20020612-freeze:1.1.1.2 r200-0-1-branch:1.1.1.2.0.36 dmx-1-0-20020604-phase1:1.1.1.2 dmx-1-0-20020603-base:1.1.1.2 dmx-1-0-branch:1.1.1.2.0.32 dmx-0-1-20020531-final:1.1.1.2 mach64-0-0-4-dma-branch:1.1.1.2.0.30 dmx-0-1-20020419-beta:1.1.1.2 mach64-0-0-4-branch:1.1.1.2.0.28 drmcommand-0-0-1-20020409-merge:1.1.1.2 drmcommand-0-0-1-20020409:1.1.1.2 drmcommand-0-0-1-20020409-freeze:1.1.1.2 trunk-20020328:1.1.1.2 s3virge-0-0-1-branch:1.1.1.2.0.26 drmcommand-0-0-1-branch:1.1.1.2.0.24 trident-0-0-1-branch:1.1.1.2.0.22 mach64-0-0-3-dma-branch:1.1.1.2.0.20 bsd-3-0-0-branch:1.1.1.2.0.18 dmx-0-1-20020228-alpha:1.1.1.2 mach64-0-0-3-branch:1.1.1.2.0.16 trunk-20020221:1.1.1.2 tcl-0-0-branch:1.1.1.2.0.14 mesa-4-0-20020214-merge:1.1.1.2 mesa-4-0-20020214:1.1.1.2 mesa-4-0-20020213:1.1.1.2 mesa-4-0-20020211-freeze:1.1.1.2 X_4_2_0-20020128-merge:1.1.1.2 X_4_2_0:1.1.1.2 X_4_2_0-20020127-preimport:1.1.1.2 X_4_2_0-20020123-preimport:1.1.1.2 dmx-0-1-20020112:1.1.1.2 dmx-0-1-20011128-snapshot:1.1.1.2 dmx-0-1-20011115:1.1.1.2 dmx-0-1-branch:1.1.1.2.0.12 mach64-0-0-2-branch:1.1.1.2.0.10 mesa-4-0-branch:1.1.1.2.0.8 X_4_1_99_1-20010822-merge:1.1.1.2 X_4_1_99_1:1.1.1.2 X_4_1_99_1-20010822-preimport:1.1.1.2 multihead-1-0-0-20010730:1.1.1.2 multihead-1-0-0-20010730-merge:1.1.1.2 multihead-1-0-0-20010727-freeze:1.1.1.2 X_4_1_0-20010615-merge:1.1.1.2 mesa-3-5-20010621-freeze:1.1.1.1.86.1 X_4_1_0:1.1.1.2 X_4_1_0-20010614-preimport:1.1.1.2 multihead-1-0-0-branch:1.1.1.2.0.6 X_4_0_99_3-20010502-merge:1.1.1.2 X_4_0_99_3:1.1.1.2 X_4_0_99_3-20010501-preimport:1.1.1.2 bsd-2-0-0-branch:1.1.1.2.0.4 X_4_0_99_2-20010410-merge:1.1.1.2 X_4_0_99_2:1.1.1.2 X_4_0_99_2-20010409-preimport:1.1.1.2 ati-pcigart-1-0-0-20010405-merge:1.1.1.2 ati-pcigart-1-0-0-20010405:1.1.1.2 ati-pcigart-1-0-0-20010405-freeze:1.1.1.2 ati-pcigart-1-0-0-branch:1.1.1.2.0.2 mesa-3-5-20010323-freeze:1.1.1.1 X_4_0_99_1-20010321-merge:1.1.1.2 X_4_0_99_1:1.1.1.2 X_4_0_99_1-20010319-preimport:1.1.1.1 full-1-0-0-20010315-head:1.1.1.1 sarea-1-0-0-20010314-merge:1.1.1.1 sarea-1-0-0-20010314:1.1.1.1 full-1-0-0-branch:1.1.1.1 sarea-1-0-0-20010307:1.1.1.1 sarea-1-0-0-20010307-freeze:1.1.1.1 tdfx-3-1-0-20010306-merge:1.1.1.1 tdfx-3-1-0-20010306-freeze:1.1.1.1 tdfx-3-1-0-20010306:1.1.1.1 tdfx-3-1-0-20010305-merge:1.1.1.1 tdfx-3-1-0-20010305-freeze2:1.1.1.1 tdfx-3-1-0-20010305-freeze:1.1.1.1 tdfx-3-1-0-20010301-freeze:1.1.1.1 ati-pcigart-0-0-1-branch-02282001-freeze:1.1.1.1 ati-5-0-1-20010220-head:1.1.1.1 ati-5-0-1-branch:1.1.1.1.0.94 sarea-1-0-0-branch:1.1.1.1.0.92 mga-1-0-0-20010215-merge:1.1.1.1 mga-1-0-0-20010215-freeze:1.1.1.1 tdfx-3-1-0-branch:1.1.1.1.0.90 tdfx-3-0-1-branch:1.1.1.1 ati-pcigart-0-0-1-branch:1.1.1.1.0.88 mesa-3-5-branch:1.1.1.1.0.86 tdfx-3-0-0-20010109-merge:1.1.1.1 tdfx-3-0-0-20010108:1.1.1.1 ati-5-0-0-20010105-merge:1.1.1.1 ati-5-0-0-20010105:1.1.1.1 ati-5-0-0-20000104-freeze:1.1.1.1 tdfx-3-0-0-20010104-freeze:1.1.1.1 ati-5-0-0-20001223-merge:1.1.1.1 ati-5-0-0-20001223-freeze:1.1.1.1 X_4_0_2-20001221-merge:1.1.1.1 X_4_0_2:1.1.1.1 mga-1-0-0-branch:1.1.1.1.0.84 X_4_0_1h-20001207-merge:1.1.1.1 X_4_0_1h-20001205-merge:1.1.1.1 X_4_0_1h:1.1.1.1 ati-4-1-1-20001202-merge-trunk:1.1.1.1 sse-1-0-1-branch:1.1.1.1.0.82 ati-4-1-1-20001202-merge:1.1.1.1 tdfx-3-0-0-20001201:1.1.1.1 ati-4-1-1-20001201-freeze:1.1.1.1 tdfx-3-0-0-20001201-freeze:1.1.1.1 X_4_0_1g-20001130-merge:1.1.1.1 X_4_0_1g:1.1.1.1 X_4_0_1f-20001130-merge:1.1.1.1 X_4_0_1f:1.1.1.1 ati-4-1-1-20001125-freeze:1.1.1.1 mach64-0-0-1-branch:1.1.1.1.0.80 ati-5-0-0-branch:1.1.1.1.0.78 X_4_0_1e-20001107-merge:1.1.1.1 X_4_0_1e:1.1.1.1 X_4_0_1d-20001107-merge:1.1.1.1 X_4_0_1d:1.1.1.1 ppc-1-0-1-branch:1.1.1.1.0.76 radeon-1-0-0-20001017:1.1.1.1 full-0-0-2-branch:1.1.1.1.0.74 full-0-0-1-branch:1.1.1.1.0.72 ati-4-1-1-20001009-freeze:1.1.1.1 mga-readpix-0-0-1-branch:1.1.1.1.0.70 tdfx-3-0-0-branch:1.1.1.1.0.68 X_4_0_1d-pre:1.1.1.1 ati-4-1-1-20000919-stable:1.1.1.1 radeon-1-0-0-branch:1.1.1.1.0.66 ppc-1-0-0-20000912:1.1.1.1 mga-lock-debug-0-2-0-branch:1.1.1.1.0.64 sse-1-0-0-branch:1.1.1.1.0.62 mga-lock-debug-0-0-1-branch:1.1.1.1.0.60 gamma-2-0-0-branch:1.1.1.1.0.58 tdfx-2-1-20000907-merge:1.1.1.1 tdfx-2-1-20000906:1.1.1.1 tdfx-2-1-20000905-freeze:1.1.1.1 ppc-1-0-0-2000-09-01-freeze:1.1.1.1 m3-0-0-1-branch:1.1.1.1.0.56 mach64-0-0-0-branch:1.1.1.1.0.54 ati-4-1-1-branch:1.1.1.1.0.52 X_4_0_1b-20000816-merge:1.1.1.1 X_4_0_1b:1.1.1.1 ati-4-0-2-branch:1.1.1.1.0.50 ppc-1-0-0-branch:1.1.1.1.0.48 tdfx-2-1-20000711:1.1.1.1 tdfx-2-1-20000711-freeze:1.1.1.1 X_4_0_1:1.1.1.1 tdfx-2-1-branch:1.1.1.1.0.46 pre401-20000613-freeze:1.1.1.1 bsd-1-0-1-20000613-merge:1.1.1.1 bsd-1-0-1-20000613:1.1.1.1 bsd-1-0-1-20000612-freeze:1.1.1.1 tdfx-2-0-20000612-merge:1.1.1.1 ati-4-1-0-20000613-merge:1.1.1.1 ati-4-1-0-20000613:1.1.1.1 tdfx-2-0-20000608-merge:1.1.1.1 tdfx-2-0-20000608-freeze:1.1.1.1 ati-4-1-0-branch:1.1.1.1.0.44 glxmisc-3-0-0-20000608-merge:1.1.1.1 glxmisc-3-0-0-20000607:1.1.1.1 glxmisc-3-0-0-20000606-freeze:1.1.1.1 bsd-1-0-1-branch:1.1.1.1.0.42 bsd-1-0-0-20000531-merge:1.1.1.1 bsd-1-0-0-20000530-merge:1.1.1.1 bsd-1-0-0-20000530-freeze:1.1.1.1 tdfx-2-0-20000222-merge:1.1.1.1 tdfx-2-0-20000222-freeze:1.1.1.1 ati-4-0-1-20000518-merge:1.1.1.1 ati-4-0-1-20000518:1.1.1.1 video-1-0-0-branch:1.1.1.1.0.40 gamma-1-0-0-branch:1.1.1.1.0.38 mgadh-0-0-3-branch:1.1.1.1.0.36 glxmisc-3-0-0-branch:1.1.1.1.0.34 glxmisc-2-0-0-20000503-merge:1.1.1.1 bsd-1-0-0-branch:1.1.1.1.0.32 glxmisc-2-0-0-20000503:1.1.1.1 glxmisc-2-0-0-branch:1.1.1.1.0.30 tdfx-2-0-branch:1.1.1.1.0.28 tdfx-2-0-trunk:1.1.1.1 glxmisc-1-0-0-20000420-merge:1.1.1.1 glxmisc-1-0-0-20000420:1.1.1.1 ati-4-0-1-beta:1.1.1.1 glxmisc-1-0-0-branch:1.1.1.1.0.26 mga-0-0-3-branch:1.1.1.1.0.24 mga-0-0-2-20000404-merge:1.1.1.1 ati-4-0-1-alpha:1.1.1.1 ati-4-0-1-20000319-base:1.1.1.1 ati-4-0-1-branch:1.1.1.1.0.22 ati-4-0-0-20000319:1.1.1.1 X_4_0-20000315-merge:1.1.1.1 X_4_0:1.1.1.1 freeze-20000226:1.1.1.1 dispatch-0-0-3-20000225-merge:1.1.1.1 dispatch-0-0-3-20000225:1.1.1.1 mga-0-0-1-20000225-merge:1.1.1.1 mga-0-0-2-branch:1.1.1.1.0.20 smt-0-0-2-branch:1.1.1.1.0.18 smt-0-0-1-20000222-freeze:1.1.1.1 X_3_9_18-20000222-merge:1.1.1.1 X_3_9_18:1.1.1.1 smt-0-0-1-stage2c:1.1.1.1 smt-0-0-1-stage2b:1.1.1.1.0.16 dispatch-0-0-3-branch:1.1.1.1.0.14 i810-20000214-beta2:1.1.1.1 dispatch-0-0-2-20000212:1.1.1.1 dispatch-0-0-2-branch:1.1.1.1.0.12 i810-20000201-beta1:1.1.1.1 dispatch-0-0-1-20000129-merge:1.1.1.1 dispatch-0-0-1-20000128:1.1.1.1 smt-0-0-1-20000112-base:1.1.1.1 smt-0-0-1-branch:1.1.1.1.0.6 dispatch-0-0-1-branch:1.1.1.1.0.10 tdfx-1-1:1.1.1.1.0.4 X_3_9_17:1.1.1.1 ati-4-0-0-branch:1.1.1.1.0.8 mga-0-0-1-branch:1.1.1.1.0.2 X_3_9_16:1.1.1.1 XFree:1.1.1; locks; strict; comment @ * @; 1.1 date 99.12.05.01.04.13; author daryll; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.12.05.01.04.13; author daryll; state Exp; branches 1.1.1.1.86.1; next 1.1.1.2; 1.1.1.2 date 2001.03.19.17.45.24; author dawes; state Exp; branches; next ; 1.1.1.1.86.1 date 2001.03.27.20.03.20; author gareth; state Exp; branches; next ; desc @@ 1.1 log @Initial revision @ text @/* $TOG: inflate.c /main/4 1998/02/04 14:33:57 kaleb $ */ /* inflate.c -- zlib interface to inflate modules * Copyright (C) 1995-1998 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "infblock.h" struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ typedef enum { METHOD, /* waiting for method byte */ FLAG, /* waiting for flag byte */ DICT4, /* four dictionary check bytes to go */ DICT3, /* three dictionary check bytes to go */ DICT2, /* two dictionary check bytes to go */ DICT1, /* one dictionary check byte to go */ DICT0, /* waiting for inflateSetDictionary */ BLOCKS, /* decompressing blocks */ CHECK4, /* four check bytes to go */ CHECK3, /* three check bytes to go */ CHECK2, /* two check bytes to go */ CHECK1, /* one check byte to go */ DONE, /* finished check, done */ BAD} /* got an error--stay here */ inflate_mode; /* inflate private state */ struct internal_state { /* mode */ inflate_mode mode; /* current inflate mode */ /* mode dependent information */ union { uInt method; /* if FLAGS, method byte */ struct { uLong was; /* computed check value */ uLong need; /* stream check value */ } check; /* if CHECK, check values to compare */ uInt marker; /* if BAD, inflateSync's marker bytes count */ } sub; /* submode */ /* mode independent information */ int nowrap; /* flag for no wrapper */ uInt wbits; /* log2(window size) (8..15, defaults to 15) */ inflate_blocks_statef *blocks; /* current inflate_blocks state */ }; int EXPORT inflateReset(z) z_streamp z; { if (z == Z_NULL || z->state == Z_NULL) return Z_STREAM_ERROR; z->total_in = z->total_out = 0; z->msg = Z_NULL; z->state->mode = z->state->nowrap ? BLOCKS : METHOD; inflate_blocks_reset(z->state->blocks, z, Z_NULL); Tracev((stderr, "inflate: reset\n")); return Z_OK; } int EXPORT inflateEnd(z) z_streamp z; { if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) return Z_STREAM_ERROR; if (z->state->blocks != Z_NULL) inflate_blocks_free(z->state->blocks, z); ZFREE(z, z->state); z->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } int EXPORT inflateInit2_(z, w, version, stream_size) z_streamp z; int w; const char *version; int stream_size; { if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != sizeof(z_stream)) return Z_VERSION_ERROR; /* initialize state */ if (z == Z_NULL) return Z_STREAM_ERROR; z->msg = Z_NULL; if (z->zalloc == Z_NULL) { z->zalloc = zcalloc; z->opaque = (voidpf)0; } if (z->zfree == Z_NULL) z->zfree = zcfree; if ((z->state = (struct internal_state FAR *) ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) return Z_MEM_ERROR; z->state->blocks = Z_NULL; /* handle undocumented nowrap option (no zlib header or check) */ z->state->nowrap = 0; if (w < 0) { w = - w; z->state->nowrap = 1; } /* set window size */ if (w < 8 || w > 15) { inflateEnd(z); return Z_STREAM_ERROR; } z->state->wbits = (uInt)w; /* create inflate_blocks state */ if ((z->state->blocks = inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) == Z_NULL) { inflateEnd(z); return Z_MEM_ERROR; } Tracev((stderr, "inflate: allocated\n")); /* reset state */ inflateReset(z); return Z_OK; } int EXPORT inflateInit_(z, version, stream_size) z_streamp z; const char *version; int stream_size; { return inflateInit2_(z, DEF_WBITS, version, stream_size); } #define NEEDBYTE {if(z->avail_in==0)return r; if (f != Z_FINISH) r = Z_OK;} #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) int EXPORT inflate(z, f) z_streamp z; int f; { int r; uInt b; if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0) return Z_STREAM_ERROR; r = Z_BUF_ERROR; while (1) switch (z->state->mode) { case METHOD: NEEDBYTE if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) { z->state->mode = BAD; z->msg = (char*)"unknown compression method"; z->state->sub.marker = 5; /* can't try inflateSync */ break; } if ((z->state->sub.method >> 4) + 8 > z->state->wbits) { z->state->mode = BAD; z->msg = (char*)"invalid window size"; z->state->sub.marker = 5; /* can't try inflateSync */ break; } z->state->mode = FLAG; case FLAG: NEEDBYTE b = NEXTBYTE; if (((z->state->sub.method << 8) + b) % 31) { z->state->mode = BAD; z->msg = (char*)"incorrect header check"; z->state->sub.marker = 5; /* can't try inflateSync */ break; } Tracev((stderr, "inflate: zlib header ok\n")); if (!(b & PRESET_DICT)) { z->state->mode = BLOCKS; break; } z->state->mode = DICT4; case DICT4: NEEDBYTE z->state->sub.check.need = (uLong)NEXTBYTE << 24; z->state->mode = DICT3; case DICT3: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 16; z->state->mode = DICT2; case DICT2: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 8; z->state->mode = DICT1; case DICT1: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE; z->adler = z->state->sub.check.need; z->state->mode = DICT0; return Z_NEED_DICT; case DICT0: z->state->mode = BAD; z->msg = (char*)"need dictionary"; z->state->sub.marker = 0; /* can try inflateSync */ return Z_STREAM_ERROR; case BLOCKS: r = inflate_blocks(z->state->blocks, z, r); if (r == Z_DATA_ERROR) { z->state->mode = BAD; z->state->sub.marker = 0; /* can try inflateSync */ break; } if (r != Z_STREAM_END) return f == Z_FINISH && r == Z_OK ? Z_BUF_ERROR : r; r = Z_OK; inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); if (z->state->nowrap) { z->state->mode = DONE; break; } z->state->mode = CHECK4; if (f == Z_FINISH) r = Z_BUF_ERROR; case CHECK4: NEEDBYTE z->state->sub.check.need = (uLong)NEXTBYTE << 24; z->state->mode = CHECK3; case CHECK3: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 16; z->state->mode = CHECK2; case CHECK2: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE << 8; z->state->mode = CHECK1; case CHECK1: NEEDBYTE z->state->sub.check.need += (uLong)NEXTBYTE; if (z->state->sub.check.was != z->state->sub.check.need) { z->state->mode = BAD; z->msg = (char*)"incorrect data check"; z->state->sub.marker = 5; /* can't try inflateSync */ break; } Tracev((stderr, "inflate: zlib check ok\n")); z->state->mode = DONE; case DONE: return Z_STREAM_END; case BAD: return Z_DATA_ERROR; default: return Z_STREAM_ERROR; } #ifdef NEED_DUMMY_RETURN return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ #endif } int EXPORT inflateSetDictionary(z, dictionary, dictLength) z_streamp z; const Bytef *dictionary; uInt dictLength; { uInt length = dictLength; if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) return Z_STREAM_ERROR; if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; z->adler = 1L; if (length >= ((uInt)1<state->wbits)) { length = (1<state->wbits)-1; dictionary += dictLength - length; } inflate_set_dictionary(z->state->blocks, dictionary, length); z->state->mode = BLOCKS; return Z_OK; } int EXPORT inflateSync(z) z_streamp z; { uInt n; /* number of bytes to look at */ Bytef *p; /* pointer to bytes */ uInt m; /* number of marker bytes found in a row */ uLong r, w; /* temporaries to save total_in and total_out */ /* set up */ if (z == Z_NULL || z->state == Z_NULL) return Z_STREAM_ERROR; if (z->state->mode != BAD) { z->state->mode = BAD; z->state->sub.marker = 0; } if ((n = z->avail_in) == 0) return Z_BUF_ERROR; p = z->next_in; m = z->state->sub.marker; /* search */ while (n && m < 4) { static const Byte mark[4] = {0, 0, 0xff, 0xff}; if (*p == mark[m]) m++; else if (*p) m = 0; else m = 4 - m; p++, n--; } /* restore */ z->total_in += p - z->next_in; z->next_in = p; z->avail_in = n; z->state->sub.marker = m; /* return no joy or set up to restart on a new block */ if (m != 4) return Z_DATA_ERROR; r = z->total_in; w = z->total_out; inflateReset(z); z->total_in = r; z->total_out = w; z->state->mode = BLOCKS; return Z_OK; } /* Returns true if inflate is currently at the end of a block generated * by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP * implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH * but removes the length bytes of the resulting empty stored block. When * decompressing, PPP checks that at the end of input packet, inflate is * waiting for these length bytes. */ int EXPORT inflateSyncPoint(z) z_streamp z; { if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) return Z_STREAM_ERROR; return inflate_blocks_sync_point(z->state->blocks); } @ 1.1.1.1 log @Import XFree 3.9.16 @ text @@ 1.1.1.1.86.1 log @Initial merge of trunk onto branch. @ text @d1 1 a1 1 /* $Xorg: inflate.c,v 1.3 2000/08/17 19:46:47 cpqbld Exp $ */ @ 1.1.1.2 log @Import of XFree86 4.0.99.1 @ text @d1 1 a1 1 /* $Xorg: inflate.c,v 1.3 2000/08/17 19:46:47 cpqbld Exp $ */ @