src/share/native/java/util/zip/zlib-1.2.5/inflate.c

Print this page




1353 
1354     got = *have;
1355     next = 0;
1356     while (next < len && got < 4) {
1357         if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
1358             got++;
1359         else if (buf[next])
1360             got = 0;
1361         else
1362             got = 4 - got;
1363         next++;
1364     }
1365     *have = got;
1366     return next;
1367 }
1368 
1369 int ZEXPORT inflateSync(strm)
1370 z_streamp strm;
1371 {
1372     unsigned len;               /* number of bytes to look at or looked at */
1373     long long in, out;      /* temporary to save total_in and total_out */
1374     unsigned char buf[4];       /* to restore bit buffer to byte string */
1375     struct inflate_state FAR *state;
1376 
1377     /* check parameters */
1378     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1379     state = (struct inflate_state FAR *)strm->state;
1380     if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1381 
1382     /* if first time, start search in bit buffer */
1383     if (state->mode != SYNC) {
1384         state->mode = SYNC;
1385         state->hold <<= state->bits & 7;
1386         state->bits -= state->bits & 7;
1387         len = 0;
1388         while (state->bits >= 8) {
1389             buf[len++] = (unsigned char)(state->hold);
1390             state->hold >>= 8;
1391             state->bits -= 8;
1392         }
1393         state->have = 0;




1353 
1354     got = *have;
1355     next = 0;
1356     while (next < len && got < 4) {
1357         if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
1358             got++;
1359         else if (buf[next])
1360             got = 0;
1361         else
1362             got = 4 - got;
1363         next++;
1364     }
1365     *have = got;
1366     return next;
1367 }
1368 
1369 int ZEXPORT inflateSync(strm)
1370 z_streamp strm;
1371 {
1372     unsigned len;               /* number of bytes to look at or looked at */
1373     unsigned long in, out;      /* temporary to save total_in and total_out */
1374     unsigned char buf[4];       /* to restore bit buffer to byte string */
1375     struct inflate_state FAR *state;
1376 
1377     /* check parameters */
1378     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
1379     state = (struct inflate_state FAR *)strm->state;
1380     if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
1381 
1382     /* if first time, start search in bit buffer */
1383     if (state->mode != SYNC) {
1384         state->mode = SYNC;
1385         state->hold <<= state->bits & 7;
1386         state->bits -= state->bits & 7;
1387         len = 0;
1388         while (state->bits >= 8) {
1389             buf[len++] = (unsigned char)(state->hold);
1390             state->hold >>= 8;
1391             state->bits -= 8;
1392         }
1393         state->have = 0;