• Home
  • Raw
  • Download

Lines Matching refs:state

22 local int gz_init(state)  in gz_init()  argument
23 gz_statep state; in gz_init()
26 z_streamp strm = &(state.state->strm);
29 state.state->in = (unsigned char*)malloc(state.state->want << 1);
30 if (state.state->in == NULL) {
31 gz_error(state, Z_MEM_ERROR, "out of memory");
36 if (!state.state->direct) {
38 state.state->out = (unsigned char*)malloc(state.state->want);
39 if (state.state->out == NULL) {
40 free(state.state->in);
41 gz_error(state, Z_MEM_ERROR, "out of memory");
49 ret = deflateInit2(strm, state.state->level, Z_DEFLATED,
50 MAX_WBITS + 16, DEF_MEM_LEVEL, state.state->strategy);
52 free(state.state->out);
53 free(state.state->in);
54 gz_error(state, Z_MEM_ERROR, "out of memory");
61 state.state->size = state.state->want;
64 if (!state.state->direct) {
65 strm->avail_out = state.state->size;
66 strm->next_out = state.state->out;
67 state.state->x.next = strm->next_out;
78 local int gz_comp(state, flush) in gz_comp() argument
79 gz_statep state; in gz_comp()
84 z_streamp strm = &(state.state->strm);
87 if (state.state->size == 0 && gz_init(state) == -1)
91 if (state.state->direct) {
94 writ = (int)write(state.state->fd, strm->next_in, put);
96 gz_error(state, Z_ERRNO, zstrerror());
112 while (strm->next_out > state.state->x.next) {
113 put = strm->next_out - state.state->x.next > (int)max ? max :
114 (unsigned)(strm->next_out - state.state->x.next);
115 writ = (int)write(state.state->fd, state.state->x.next, put);
117 gz_error(state, Z_ERRNO, zstrerror());
120 state.state->x.next += writ;
123 strm->avail_out = state.state->size;
124 strm->next_out = state.state->out;
125 state.state->x.next = state.state->out;
133 gz_error(state, Z_STREAM_ERROR,
150 local int gz_zero(state, len) in gz_zero() argument
151 gz_statep state; in gz_zero()
156 z_streamp strm = &(state.state->strm);
159 if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
165 n = GT_OFF(state.state->size) || (z_off64_t)state.state->size > len ?
166 (unsigned)len : state.state->size;
168 memset(state.state->in, 0, n);
172 strm->next_in = state.state->in;
173 state.state->x.pos += n;
174 if (gz_comp(state, Z_NO_FLUSH) == -1)
183 local z_size_t gz_write(state, buf, len) in gz_write() argument
184 gz_statep state; in gz_write()
195 if (state.state->size == 0 && gz_init(state) == -1)
199 if (state.state->seek) {
200 state.state->seek = 0;
201 if (gz_zero(state, state.state->skip) == -1)
206 if (len < state.state->size) {
211 if (state.state->strm.avail_in == 0)
212 state.state->strm.next_in = state.state->in;
213 have = (unsigned)((state.state->strm.next_in + state.state->strm.avail_in) -
214 state.state->in);
215 copy = state.state->size - have;
218 memcpy(state.state->in + have, buf, copy);
219 state.state->strm.avail_in += copy;
220 state.state->x.pos += copy;
223 if (len && gz_comp(state, Z_NO_FLUSH) == -1)
229 if (state.state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
233 state.state->strm.next_in = (z_const Bytef *)buf;
238 state.state->strm.avail_in = (z_uInt)n;
239 state.state->x.pos += n;
240 if (gz_comp(state, Z_NO_FLUSH) == -1)
256 gz_statep state; local
261 state.file = file;
264 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
270 gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
275 return (int)gz_write(state, buf, len);
286 gz_statep state; local
292 state.file = file;
295 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
301 gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
306 return len ? gz_write(state, buf, len) / size : 0;
316 gz_statep state; local
322 state.file = file;
323 strm = &(state.state->strm);
326 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
330 if (state.state->seek) {
331 state.state->seek = 0;
332 if (gz_zero(state, state.state->skip) == -1)
338 if (state.state->size) {
340 strm->next_in = state.state->in;
341 have = (unsigned)((strm->next_in + strm->avail_in) - state.state->in);
342 if (have < state.state->size) {
343 state.state->in[have] = (unsigned char)c;
345 state.state->x.pos++;
352 if (gz_write(state, buf, 1) != 1)
364 gz_statep state; local
369 state.file = file;
372 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
377 ret = (int)gz_write(state, str, len);
390 gz_statep state; in gzvprintf() local
396 state.file = file; in gzvprintf()
397 strm = &(state.state->strm); in gzvprintf()
400 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK) in gzvprintf()
404 if (state.state->size == 0 && gz_init(state) == -1) in gzvprintf()
405 return state.state->err; in gzvprintf()
408 if (state.state->seek) { in gzvprintf()
409 state.state->seek = 0; in gzvprintf()
410 if (gz_zero(state, state.state->skip) == -1) in gzvprintf()
411 return state.state->err; in gzvprintf()
418 strm->next_in = state.state->in; in gzvprintf()
419 next = (char *)(state.state->in + (strm->next_in - state.state->in) + strm->avail_in); in gzvprintf()
420 next[state.state->size - 1] = 0; in gzvprintf()
424 for (len = 0; len < state.state->size; len++) in gzvprintf()
431 (void)vsnprintf(next, state.state->size, format, va); in gzvprintf()
434 len = vsnprintf(next, state.state->size, format, va); in gzvprintf()
439 if (len == 0 || (unsigned)len >= state.state->size || next[state.state->size - 1] != 0) in gzvprintf()
444 state.state->x.pos += len; in gzvprintf()
445 if (strm->avail_in >= state.state->size) { in gzvprintf()
446 left = strm->avail_in - state.state->size; in gzvprintf()
447 strm->avail_in = state.state->size; in gzvprintf()
448 if (gz_comp(state, Z_NO_FLUSH) == -1) in gzvprintf()
449 return state.state->err; in gzvprintf()
450 memcpy(state.state->in, state.state->in + state.state->size, left); in gzvprintf()
451 strm->next_in = state.state->in; in gzvprintf()
480 gz_statep state; local
486 state = (gz_statep)file;
487 strm = &(state.state->strm);
494 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
498 if (state.state->size == 0 && gz_init(state) == -1)
499 return state.state->error;
502 if (state.state->seek) {
503 state.state->seek = 0;
504 if (gz_zero(state, state.state->skip) == -1)
505 return state.state->error;
512 strm->next_in = state.state->in;
514 next[state.state->size - 1] = 0;
528 snprintf(next, state.state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
532 len = snprintf(next, state.state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
538 if (len == 0 || len >= state.state->size || next[state.state->size - 1] != 0)
543 state.state->x.pos += len;
544 if (strm->avail_in >= state.state->size) {
545 left = strm->avail_in - state.state->size;
546 strm->avail_in = state.state->size;
547 if (gz_comp(state, Z_NO_FLUSH) == -1)
548 return state.state->err;
549 memcpy(state.state->in, state.state->in + state.state->size, left);
550 strm->next_in = state.state->in;
563 gz_statep state; local
568 state.file = file;
571 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
579 if (state.state->seek) {
580 state.state->seek = 0;
581 if (gz_zero(state, state.state->skip) == -1)
582 return state.state->err;
586 (void)gz_comp(state, flush);
587 return state.state->err;
596 gz_statep state; local
602 state.file = file;
603 strm = &(state.state->strm);
606 if (state.state->mode != GZ_WRITE || state.state->err != Z_OK)
610 if (level == state.state->level && strategy == state.state->strategy)
614 if (state.state->seek) {
615 state.state->seek = 0;
616 if (gz_zero(state, state.state->skip) == -1)
617 return state.state->err;
621 if (state.state->size) {
623 if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
624 return state.state->err;
627 state.state->level = level;
628 state.state->strategy = strategy;
637 gz_statep state; local
642 state.file = file;
645 if (state.state->mode != GZ_WRITE)
649 if (state.state->seek) {
650 state.state->seek = 0;
651 if (gz_zero(state, state.state->skip) == -1)
652 ret = state.state->err;
656 if (gz_comp(state, Z_FINISH) == -1)
657 ret = state.state->err;
658 if (state.state->size) {
659 if (!state.state->direct) {
660 (void)deflateEnd(&(state.state->strm));
661 free(state.state->out);
663 free(state.state->in);
665 gz_error(state, Z_OK, NULL);
666 free(state.state->path);
667 if (close(state.state->fd) == -1)
669 free(state.state);