Lines Matching refs:gz
112 gzFile gz; in gz_open() local
117 gz = malloc(sizeof(struct gzFile_s)); in gz_open()
118 if (gz == NULL) in gz_open()
120 gz->write = strchr(mode, 'w') != NULL; in gz_open()
121 gz->strm.zalloc = myalloc; in gz_open()
122 gz->strm.zfree = myfree; in gz_open()
123 gz->strm.opaque = NULL; in gz_open()
124 gz->buf = malloc(gz->write ? BUFLENW : BUFLEN); in gz_open()
126 if (gz->buf == NULL) { in gz_open()
127 free(gz); in gz_open()
138 if (gz->write) in gz_open()
139 ret = deflateInit2(&(gz->strm), level, 8, 15 + 16, 8, 0); in gz_open()
141 gz->strm.next_in = NULL; in gz_open()
142 gz->strm.avail_in = 0; in gz_open()
143 ret = inflateInit2(&(gz->strm), 15 + 16); in gz_open()
146 free(gz); in gz_open()
149 gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") : in gz_open()
150 fopen(path, gz->write ? "wb" : "rb"); in gz_open()
151 if (gz->file == NULL) { in gz_open()
152 gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); in gz_open()
153 free(gz); in gz_open()
156 gz->err = 0; in gz_open()
157 gz->msg = ""; in gz_open()
158 return gz; in gz_open()
163 int gzwrite(gzFile gz, const void *buf, unsigned len) in gzwrite() argument
167 if (gz == NULL || !gz->write) in gzwrite()
169 strm = &(gz->strm); in gzwrite()
173 strm->next_out = gz->buf; in gzwrite()
176 fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file); in gzwrite()
183 int gzread(gzFile gz, void *buf, unsigned len) in gzread() argument
187 if (gz == NULL || gz->write || gz->err) in gzread()
189 strm = &(gz->strm); in gzread()
195 strm->next_in = gz->buf; in gzread()
196 strm->avail_in = (uint32_t)fread(gz->buf, 1, BUFLEN, gz->file); in gzread()
202 gz->err = ret; in gzread()
203 gz->msg = strm->msg; in gzread()
217 int gzclose(gzFile gz) in gzclose() argument
221 if (gz == NULL) in gzclose()
223 strm = &(gz->strm); in gzclose()
224 if (gz->write) { in gzclose()
228 strm->next_out = gz->buf; in gzclose()
231 fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file); in gzclose()
237 free(gz->buf); in gzclose()
238 fclose(gz->file); in gzclose()
239 free(gz); in gzclose()
245 const char *gzerror(gzFile gz, int *err) in gzerror() argument
247 *err = gz->err; in gzerror()
248 return gz->msg; in gzerror()