int inflateSync() {
		int n; // number of bytes to look at
		int p; // pointer to bytes
		int m; // number of marker bytes found in a row
		long r, w; // temporaries to save total_in and total_out

		// set up
		if (z == null)
			return Z_STREAM_ERROR;
		if (this.mode != BAD) {
			this.mode = BAD;
			this.marker = 0;
		}
		if ((n = z.avail_in) == 0)
			return Z_BUF_ERROR;

		p = z.next_in_index;
		m = this.marker;
		// search
		while (n != 0 && m < 4) {
			if (z.next_in[p] == mark[m]) {
				m++;
			} else if (z.next_in[p] != 0) {
				m = 0;
			} else {
				m = 4 - m;
			}
			p++;
			n--;
		}

		// restore
		z.total_in += p - z.next_in_index;
		z.next_in_index = p;
		z.avail_in = n;
		this.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.total_in = r;
		z.total_out = w;
		this.mode = BLOCKS;

		return Z_OK;
	}