Lines Matching refs:state
76 gz_statep state) in gz_reset() argument
78 state->x.have = 0; /* no output data available */ in gz_reset()
79 if (state->mode == GZ_READ) { /* for reading ... */ in gz_reset()
80 state->eof = 0; /* not at end of file */ in gz_reset()
81 state->past = 0; /* have not read past end yet */ in gz_reset()
82 state->how = LOOK; /* look for gzip header */ in gz_reset()
84 state->seek = 0; /* no seek request pending */ in gz_reset()
85 gz_error(state, Z_OK, NULL); /* clear error */ in gz_reset()
86 state->x.pos = 0; /* no uncompressed data yet */ in gz_reset()
87 state->strm.avail_in = 0; /* no input data yet */ in gz_reset()
96 gz_statep state; in gz_open() local
111 state = (gz_statep)malloc(sizeof(gz_state)); in gz_open()
112 if (state == NULL) in gz_open()
114 state->size = 0; /* no buffers allocated yet */ in gz_open()
115 state->want = GZBUFSIZE; /* requested buffer size */ in gz_open()
116 state->msg = NULL; /* no error message yet */ in gz_open()
119 state->mode = GZ_NONE; in gz_open()
120 state->level = Z_DEFAULT_COMPRESSION; in gz_open()
121 state->strategy = Z_DEFAULT_STRATEGY; in gz_open()
122 state->direct = 0; in gz_open()
125 state->level = *mode - '0'; in gz_open()
129 state->mode = GZ_READ; in gz_open()
133 state->mode = GZ_WRITE; in gz_open()
136 state->mode = GZ_APPEND; in gz_open()
140 free(state); in gz_open()
155 state->strategy = Z_FILTERED; in gz_open()
158 state->strategy = Z_HUFFMAN_ONLY; in gz_open()
161 state->strategy = Z_RLE; in gz_open()
164 state->strategy = Z_FIXED; in gz_open()
167 state->direct = 1; in gz_open()
176 if (state->mode == GZ_NONE) { in gz_open()
177 free(state); in gz_open()
182 if (state->mode == GZ_READ) { in gz_open()
183 if (state->direct) { in gz_open()
184 free(state); in gz_open()
187 state->direct = 1; /* for empty file */ in gz_open()
200 state->path = (char *)malloc(len + 1); in gz_open()
201 if (state->path == NULL) { in gz_open()
202 free(state); in gz_open()
208 wcstombs(state->path, path, len + 1); in gz_open()
210 *(state->path) = 0; in gz_open()
214 snprintf(state->path, len + 1, "%s", (const char *)path); in gz_open()
216 strcpy(state->path, path); in gz_open()
230 (state->mode == GZ_READ ? in gz_open()
236 (state->mode == GZ_WRITE ? in gz_open()
241 state->fd = fd > -1 ? fd : ( in gz_open()
246 if (state->fd == -1) { in gz_open()
247 free(state->path); in gz_open()
248 free(state); in gz_open()
251 if (state->mode == GZ_APPEND) in gz_open()
252 state->mode = GZ_WRITE; /* simplify later checks */ in gz_open()
255 if (state->mode == GZ_READ) { in gz_open()
256 state->start = LSEEK(state->fd, 0, SEEK_CUR); in gz_open()
257 if (state->start == -1) state->start = 0; in gz_open()
261 gz_reset(state); in gz_open()
264 return (gzFile)state; in gz_open()
318 gz_statep state; in gzbuffer() local
323 state = (gz_statep)file; in gzbuffer()
324 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzbuffer()
328 if (state->size != 0) in gzbuffer()
334 state->want = size; in gzbuffer()
342 gz_statep state; in gzrewind() local
347 state = (gz_statep)file; in gzrewind()
350 if (state->mode != GZ_READ || in gzrewind()
351 (state->err != Z_OK && state->err != Z_BUF_ERROR)) in gzrewind()
355 if (LSEEK(state->fd, state->start, SEEK_SET) == -1) in gzrewind()
357 gz_reset(state); in gzrewind()
369 gz_statep state; in gzseek64() local
374 state = (gz_statep)file; in gzseek64()
375 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzseek64()
379 if (state->err != Z_OK && state->err != Z_BUF_ERROR) in gzseek64()
388 offset -= state->x.pos; in gzseek64()
389 else if (state->seek) in gzseek64()
390 offset += state->skip; in gzseek64()
391 state->seek = 0; in gzseek64()
394 if (state->mode == GZ_READ && state->how == COPY && in gzseek64()
395 state->x.pos + offset >= 0) { in gzseek64()
396 ret = LSEEK(state->fd, offset - state->x.have, SEEK_CUR); in gzseek64()
399 state->x.have = 0; in gzseek64()
400 state->eof = 0; in gzseek64()
401 state->past = 0; in gzseek64()
402 state->seek = 0; in gzseek64()
403 gz_error(state, Z_OK, NULL); in gzseek64()
404 state->strm.avail_in = 0; in gzseek64()
405 state->x.pos += offset; in gzseek64()
406 return state->x.pos; in gzseek64()
411 if (state->mode != GZ_READ) /* writing -- can't go backwards */ in gzseek64()
413 offset += state->x.pos; in gzseek64()
421 if (state->mode == GZ_READ) { in gzseek64()
422 n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? in gzseek64()
423 (unsigned)offset : state->x.have; in gzseek64()
424 state->x.have -= n; in gzseek64()
425 state->x.next += n; in gzseek64()
426 state->x.pos += n; in gzseek64()
432 state->seek = 1; in gzseek64()
433 state->skip = offset; in gzseek64()
435 return state->x.pos + offset; in gzseek64()
454 gz_statep state; in gztell64() local
459 state = (gz_statep)file; in gztell64()
460 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gztell64()
464 return state->x.pos + (state->seek ? state->skip : 0); in gztell64()
482 gz_statep state; in gzoffset64() local
487 state = (gz_statep)file; in gzoffset64()
488 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzoffset64()
492 offset = LSEEK(state->fd, 0, SEEK_CUR); in gzoffset64()
495 if (state->mode == GZ_READ) /* reading */ in gzoffset64()
496 offset -= state->strm.avail_in; /* don't count buffered input */ in gzoffset64()
514 gz_statep state; in gzeof() local
519 state = (gz_statep)file; in gzeof()
520 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzeof()
524 return state->mode == GZ_READ ? state->past : 0; in gzeof()
532 gz_statep state; in gzerror() local
537 state = (gz_statep)file; in gzerror()
538 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzerror()
543 *errnum = state->err; in gzerror()
544 return state->err == Z_MEM_ERROR ? "out of memory" : in gzerror()
545 (state->msg == NULL ? "" : state->msg); in gzerror()
552 gz_statep state; in gzclearerr() local
557 state = (gz_statep)file; in gzclearerr()
558 if (state->mode != GZ_READ && state->mode != GZ_WRITE) in gzclearerr()
562 if (state->mode == GZ_READ) { in gzclearerr()
563 state->eof = 0; in gzclearerr()
564 state->past = 0; in gzclearerr()
566 gz_error(state, Z_OK, NULL); in gzclearerr()
576 gz_statep state, in gz_error() argument
581 if (state->msg != NULL) { in gz_error()
582 if (state->err != Z_MEM_ERROR) in gz_error()
583 free(state->msg); in gz_error()
584 state->msg = NULL; in gz_error()
589 state->x.have = 0; in gz_error()
592 state->err = err; in gz_error()
601 if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == in gz_error()
603 state->err = Z_MEM_ERROR; in gz_error()
607 snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, in gz_error()
608 "%s%s%s", state->path, ": ", msg); in gz_error()
610 strcpy(state->msg, state->path); in gz_error()
611 strcat(state->msg, ": "); in gz_error()
612 strcat(state->msg, msg); in gz_error()