Lines Matching refs:state

38 static void	z_comp_free(void *state);
39 static void z_decomp_free(void *state);
40 static int z_comp_init(void *state, unsigned char *options,
43 static int z_decomp_init(void *state, unsigned char *options,
46 static int z_compress(void *state, unsigned char *rptr,
49 static void z_incomp(void *state, unsigned char *ibuf, int icnt);
50 static int z_decompress(void *state, unsigned char *ibuf,
52 static void z_comp_reset(void *state);
53 static void z_decomp_reset(void *state);
54 static void z_comp_stats(void *state, struct compstat *stats);
58 * @arg: pointer to the private state for the compressor.
62 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
64 if (state) {
65 zlib_deflateEnd(&state->strm);
66 vfree(state->strm.workspace);
67 kfree(state);
82 * Returns the pointer to the private state for the compressor,
87 struct ppp_deflate_state *state;
100 state = kzalloc(sizeof(*state),
102 if (state == NULL)
105 state->strm.next_in = NULL;
106 state->w_size = w_size;
107 state->strm.workspace = vmalloc(zlib_deflate_workspacesize(-w_size, 8));
108 if (state->strm.workspace == NULL)
111 if (zlib_deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION,
115 return (void *) state;
118 z_comp_free(state);
124 * @arg: pointer to the private state for the compressor
140 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
146 DEFLATE_SIZE(options[2]) != state->w_size ||
150 state->seqno = 0;
151 state->unit = unit;
152 state->debug = debug;
154 zlib_deflateReset(&state->strm);
161 * @arg: pointer to private state for the compressor.
168 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
170 state->seqno = 0;
171 zlib_deflateReset(&state->strm);
176 * @arg: pointer to private state for the compressor
188 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
213 put_unaligned_be16(state->seqno, wptr);
216 state->strm.next_out = wptr;
217 state->strm.avail_out = oavail = osize - olen;
218 ++state->seqno;
222 state->strm.next_in = rptr;
223 state->strm.avail_in = (isize - off);
226 r = zlib_deflate(&state->strm, Z_PACKET_FLUSH);
228 if (state->debug)
233 if (state->strm.avail_out == 0) {
235 state->strm.next_out = NULL;
236 state->strm.avail_out = oavail = 1000000;
241 olen += oavail - state->strm.avail_out;
247 state->stats.comp_bytes += olen;
248 state->stats.comp_packets++;
250 state->stats.inc_bytes += isize;
251 state->stats.inc_packets++;
254 state->stats.unc_bytes += isize;
255 state->stats.unc_packets++;
268 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
270 *stats = state->stats;
279 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
281 if (state) {
282 zlib_inflateEnd(&state->strm);
283 vfree(state->strm.workspace);
284 kfree(state);
299 * Returns the pointer to the private state for the decompressor,
304 struct ppp_deflate_state *state;
317 state = kzalloc(sizeof(*state), GFP_KERNEL);
318 if (state == NULL)
321 state->w_size = w_size;
322 state->strm.next_out = NULL;
323 state->strm.workspace = vmalloc(zlib_inflate_workspacesize());
324 if (state->strm.workspace == NULL)
327 if (zlib_inflateInit2(&state->strm, -w_size) != Z_OK)
329 return (void *) state;
332 z_decomp_free(state);
338 * @arg: pointer to the private state for the decompressor
355 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
361 DEFLATE_SIZE(options[2]) != state->w_size ||
365 state->seqno = 0;
366 state->unit = unit;
367 state->debug = debug;
368 state->mru = mru;
370 zlib_inflateReset(&state->strm);
377 * @arg: pointer to private state for the decompressor.
384 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
386 state->seqno = 0;
387 zlib_inflateReset(&state->strm);
392 * @arg: pointer to private state for the decompressor
414 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
420 if (state->debug)
422 state->unit, isize);
428 if (seq != (state->seqno & 0xffff)) {
429 if (state->debug)
431 state->unit, seq, state->seqno & 0xffff);
434 ++state->seqno;
449 state->strm.next_in = ibuf + PPP_HDRLEN + DEFLATE_OVHD;
450 state->strm.avail_in = isize - (PPP_HDRLEN + DEFLATE_OVHD);
451 state->strm.next_out = obuf + 3;
452 state->strm.avail_out = 1;
460 r = zlib_inflate(&state->strm, Z_PACKET_FLUSH);
462 if (state->debug)
464 state->unit, r, (state->strm.msg? state->strm.msg: ""));
467 if (state->strm.avail_out != 0)
470 state->strm.avail_out = osize - PPP_HDRLEN;
474 --state->strm.next_out;
475 ++state->strm.avail_out;
484 state->strm.next_out = overflow_buf;
485 state->strm.avail_out = 1;
488 if (state->debug)
490 state->unit);
496 if (state->debug)
498 state->unit);
502 olen = osize + overflow - state->strm.avail_out;
503 state->stats.unc_bytes += olen;
504 state->stats.unc_packets++;
505 state->stats.comp_bytes += isize;
506 state->stats.comp_packets++;
513 * @arg: pointer to private state for the decompressor
519 struct ppp_deflate_state *state = (struct ppp_deflate_state *) arg;
529 ++state->seqno;
535 state->strm.next_in = ibuf + 3;
536 state->strm.avail_in = icnt - 3;
538 --state->strm.next_in;
539 ++state->strm.avail_in;
542 r = zlib_inflateIncomp(&state->strm);
545 if (state->debug) {
547 state->unit, r, (state->strm.msg? state->strm.msg: ""));
555 state->stats.inc_bytes += icnt;
556 state->stats.inc_packets++;
557 state->stats.unc_bytes += icnt;
558 state->stats.unc_packets++;