| 155 | } |
| 156 | |
| 157 | int ZEXPORT inflateReset2(strm, windowBits) |
| 158 | z_streamp strm; |
| 159 | int windowBits; |
| 160 | { |
| 161 | int wrap; |
| 162 | struct inflate_state FAR *state; |
| 163 | |
| 164 | /* get the state */ |
| 165 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 166 | state = (struct inflate_state FAR *)strm->state; |
| 167 | |
| 168 | /* extract wrap request from windowBits parameter */ |
| 169 | if (windowBits < 0) { |
| 170 | wrap = 0; |
| 171 | windowBits = -windowBits; |
| 172 | } |
| 173 | else { |
| 174 | wrap = (windowBits >> 4) + 5; |
| 175 | #ifdef GUNZIP |
| 176 | if (windowBits < 48) |
| 177 | windowBits &= 15; |
| 178 | #endif |
| 179 | } |
| 180 | |
| 181 | /* set number of window bits, free window if different */ |
| 182 | if (windowBits && (windowBits < 8 || windowBits > 15)) |
| 183 | return Z_STREAM_ERROR; |
| 184 | if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { |
| 185 | ZFREE(strm, state->window); |
| 186 | state->window = Z_NULL; |
| 187 | } |
| 188 | |
| 189 | /* update state and reset the rest of it */ |
| 190 | state->wrap = wrap; |
| 191 | state->wbits = (unsigned)windowBits; |
| 192 | return inflateReset(strm); |
| 193 | } |
| 194 | |
| 195 | int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) |
| 196 | z_streamp strm; |