Lines Matching refs:gz
201 gzFile gz; local
204 gz = malloc(sizeof(struct gzFile_s));
205 if (gz == NULL)
207 gz->write = strchr(mode, 'w') != NULL;
208 gz->strm.zalloc = myalloc;
209 gz->strm.zfree = myfree;
210 gz->strm.opaque = Z_NULL;
211 if (gz->write)
212 ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0);
214 gz->strm.next_in = 0;
215 gz->strm.avail_in = Z_NULL;
216 ret = inflateInit2(&(gz->strm), 15 + 16);
219 free(gz);
222 gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
223 fopen(path, gz->write ? "wb" : "rb");
224 if (gz->file == NULL) {
225 gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm));
226 free(gz);
229 gz->err = 0;
230 gz->msg = "";
231 return gz;
236 int gzwrite(gz, buf, len) in gzwrite() argument
237 gzFile gz; in gzwrite()
244 if (gz == NULL || !gz->write)
246 strm = &(gz->strm);
253 fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
260 int gzread(gz, buf, len) in gzread() argument
261 gzFile gz; in gzread()
270 if (gz == NULL || gz->write)
272 if (gz->err)
274 strm = &(gz->strm);
278 got = fread(in, 1, 1, gz->file);
285 gz->err = Z_DATA_ERROR;
286 gz->msg = strm->msg;
297 int gzclose(gz) in gzclose() argument
298 gzFile gz; in gzclose()
303 if (gz == NULL)
305 strm = &(gz->strm);
306 if (gz->write) {
313 fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
319 fclose(gz->file);
320 free(gz);
326 const char *gzerror(gz, err) in gzerror() argument
327 gzFile gz; in gzerror()
330 *err = gz->err;
331 return gz->msg;