Lines Matching refs:state

16     gz_statep state)  in gz_init()  argument
19 z_streamp strm = &(state->strm); in gz_init()
22 state->in = (unsigned char *)malloc(state->want); in gz_init()
23 if (state->in == NULL) { in gz_init()
24 gz_error(state, Z_MEM_ERROR, "out of memory"); in gz_init()
29 if (!state->direct) { in gz_init()
31 state->out = (unsigned char *)malloc(state->want); in gz_init()
32 if (state->out == NULL) { in gz_init()
33 free(state->in); in gz_init()
34 gz_error(state, Z_MEM_ERROR, "out of memory"); in gz_init()
42 ret = deflateInit2(strm, state->level, Z_DEFLATED, in gz_init()
43 MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); in gz_init()
45 free(state->out); in gz_init()
46 free(state->in); in gz_init()
47 gz_error(state, Z_MEM_ERROR, "out of memory"); in gz_init()
53 state->size = state->want; in gz_init()
56 if (!state->direct) { in gz_init()
57 strm->avail_out = state->size; in gz_init()
58 strm->next_out = state->out; in gz_init()
59 state->x.next = strm->next_out; in gz_init()
71 gz_statep state, in gz_comp() argument
76 z_streamp strm = &(state->strm); in gz_comp()
79 if (state->size == 0 && gz_init(state) == -1) in gz_comp()
83 if (state->direct) { in gz_comp()
84 got = write(state->fd, strm->next_in, strm->avail_in); in gz_comp()
86 gz_error(state, Z_ERRNO, zstrerror()); in gz_comp()
100 have = (unsigned)(strm->next_out - state->x.next); in gz_comp()
101 if (have && ((got = write(state->fd, state->x.next, have)) < 0 || in gz_comp()
103 gz_error(state, Z_ERRNO, zstrerror()); in gz_comp()
107 strm->avail_out = state->size; in gz_comp()
108 strm->next_out = state->out; in gz_comp()
110 state->x.next = strm->next_out; in gz_comp()
117 gz_error(state, Z_STREAM_ERROR, in gz_comp()
134 gz_statep state, in gz_zero() argument
139 z_streamp strm = &(state->strm); in gz_zero()
142 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) in gz_zero()
148 n = GT_OFF(state->size) || (z_off64_t)state->size > len ? in gz_zero()
149 (unsigned)len : state->size; in gz_zero()
151 memset(state->in, 0, n); in gz_zero()
155 strm->next_in = state->in; in gz_zero()
156 state->x.pos += n; in gz_zero()
157 if (gz_comp(state, Z_NO_FLUSH) == -1) in gz_zero()
171 gz_statep state; in gzwrite() local
177 state = (gz_statep)file; in gzwrite()
178 strm = &(state->strm); in gzwrite()
181 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzwrite()
187 gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); in gzwrite()
196 if (state->size == 0 && gz_init(state) == -1) in gzwrite()
200 if (state->seek) { in gzwrite()
201 state->seek = 0; in gzwrite()
202 if (gz_zero(state, state->skip) == -1) in gzwrite()
207 if (len < state->size) { in gzwrite()
213 strm->next_in = state->in; in gzwrite()
214 have = (unsigned)((strm->next_in + strm->avail_in) - state->in); in gzwrite()
215 copy = state->size - have; in gzwrite()
218 memcpy(state->in + have, buf, copy); in gzwrite()
220 state->x.pos += copy; in gzwrite()
223 if (len && gz_comp(state, Z_NO_FLUSH) == -1) in gzwrite()
229 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) in gzwrite()
235 state->x.pos += len; in gzwrite()
236 if (gz_comp(state, Z_NO_FLUSH) == -1) in gzwrite()
251 gz_statep state; in gzputc() local
257 state = (gz_statep)file; in gzputc()
258 strm = &(state->strm); in gzputc()
261 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzputc()
265 if (state->seek) { in gzputc()
266 state->seek = 0; in gzputc()
267 if (gz_zero(state, state->skip) == -1) in gzputc()
273 if (state->size) { in gzputc()
275 strm->next_in = state->in; in gzputc()
276 have = (unsigned)((strm->next_in + strm->avail_in) - state->in); in gzputc()
277 if (have < state->size) { in gzputc()
278 state->in[have] = c; in gzputc()
280 state->x.pos++; in gzputc()
313 gz_statep state; in gzvprintf() local
319 state = (gz_statep)file; in gzvprintf()
320 strm = &(state->strm); in gzvprintf()
323 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzvprintf()
327 if (state->size == 0 && gz_init(state) == -1) in gzvprintf()
331 if (state->seek) { in gzvprintf()
332 state->seek = 0; in gzvprintf()
333 if (gz_zero(state, state->skip) == -1) in gzvprintf()
338 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) in gzvprintf()
342 size = (int)(state->size); in gzvprintf()
343 state->in[size - 1] = 0; in gzvprintf()
346 (void)vsprintf((char *)(state->in), format, va); in gzvprintf()
348 if (state->in[len] == 0) break; in gzvprintf()
350 len = vsprintf((char *)(state->in), format, va); in gzvprintf()
354 (void)vsnprintf((char *)(state->in), size, format, va); in gzvprintf()
355 len = strlen((char *)(state->in)); in gzvprintf()
357 len = vsnprintf((char *)(state->in), size, format, va); in gzvprintf()
362 if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) in gzvprintf()
367 strm->next_in = state->in; in gzvprintf()
368 state->x.pos += len; in gzvprintf()
393 gz_statep state; in gzprintf() local
399 state = (gz_statep)file; in gzprintf()
400 strm = &(state->strm); in gzprintf()
407 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzprintf()
411 if (state->size == 0 && gz_init(state) == -1) in gzprintf()
415 if (state->seek) { in gzprintf()
416 state->seek = 0; in gzprintf()
417 if (gz_zero(state, state->skip) == -1) in gzprintf()
422 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) in gzprintf()
426 size = (int)(state->size); in gzprintf()
427 state->in[size - 1] = 0; in gzprintf()
430 sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, in gzprintf()
433 if (state->in[len] == 0) break; in gzprintf()
435 len = sprintf((char *)(state->in), format, a1, a2, a3, a4, a5, a6, a7, a8, in gzprintf()
440 snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, a7, a8, in gzprintf()
442 len = strlen((char *)(state->in)); in gzprintf()
444 len = snprintf((char *)(state->in), size, format, a1, a2, a3, a4, a5, a6, in gzprintf()
451 if (len <= 0 || len >= (int)size || state->in[size - 1] != 0) in gzprintf()
456 strm->next_in = state->in; in gzprintf()
457 state->x.pos += len; in gzprintf()
468 gz_statep state; in gzflush() local
473 state = (gz_statep)file; in gzflush()
476 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzflush()
484 if (state->seek) { in gzflush()
485 state->seek = 0; in gzflush()
486 if (gz_zero(state, state->skip) == -1) in gzflush()
491 gz_comp(state, flush); in gzflush()
492 return state->err; in gzflush()
501 gz_statep state; in gzsetparams() local
507 state = (gz_statep)file; in gzsetparams()
508 strm = &(state->strm); in gzsetparams()
511 if (state->mode != GZ_WRITE || state->err != Z_OK) in gzsetparams()
515 if (level == state->level && strategy == state->strategy) in gzsetparams()
519 if (state->seek) { in gzsetparams()
520 state->seek = 0; in gzsetparams()
521 if (gz_zero(state, state->skip) == -1) in gzsetparams()
526 if (state->size) { in gzsetparams()
528 if (strm->avail_in && gz_comp(state, Z_PARTIAL_FLUSH) == -1) in gzsetparams()
529 return state->err; in gzsetparams()
532 state->level = level; in gzsetparams()
533 state->strategy = strategy; in gzsetparams()
542 gz_statep state; in gzclose_w() local
547 state = (gz_statep)file; in gzclose_w()
550 if (state->mode != GZ_WRITE) in gzclose_w()
554 if (state->seek) { in gzclose_w()
555 state->seek = 0; in gzclose_w()
556 if (gz_zero(state, state->skip) == -1) in gzclose_w()
557 ret = state->err; in gzclose_w()
561 if (gz_comp(state, Z_FINISH) == -1) in gzclose_w()
562 ret = state->err; in gzclose_w()
563 if (state->size) { in gzclose_w()
564 if (!state->direct) { in gzclose_w()
565 (void)deflateEnd(&(state->strm)); in gzclose_w()
566 free(state->out); in gzclose_w()
568 free(state->in); in gzclose_w()
570 gz_error(state, Z_OK, NULL); in gzclose_w()
571 free(state->path); in gzclose_w()
572 if (close(state->fd) == -1) in gzclose_w()
574 free(state); in gzclose_w()