Lines Matching defs:gz
45 # define GZ_SUFFIX "-gz"
49 # define GZ_SUFFIX "-gz"
127 # define GZ_SUFFIX ".gz"
142 /* for Z_SOLO, create simplified gz* functions using deflate and inflate */
197 gzFile gz;
200 gz = malloc(sizeof(gzFile));
201 if (gz == NULL)
203 gz->write = strchr(mode, 'w') != NULL;
204 gz->strm.zalloc = myalloc;
205 gz->strm.zfree = myfree;
206 gz->strm.opaque = Z_NULL;
207 if (gz->write)
208 ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0);
210 gz->strm.next_in = 0;
211 gz->strm.avail_in = Z_NULL;
212 ret = inflateInit2(&(gz->strm), 15 + 16);
215 free(gz);
218 gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
219 fopen(path, gz->write ? "wb" : "rb");
220 if (gz->file == NULL) {
221 gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm));
222 free(gz);
225 gz->err = 0;
226 gz->msg = "";
227 return gz;
232 int gzwrite(gz, buf, len)
233 gzFile gz;
240 if (gz == NULL || !gz->write)
242 strm = &(gz->strm);
249 fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
256 int gzread(gz, buf, len)
257 gzFile gz;
266 if (gz == NULL || gz->write)
268 if (gz->err)
270 strm = &(gz->strm);
274 got = fread(in, 1, 1, gz->file);
281 gz->err = Z_DATA_ERROR;
282 gz->msg = strm->msg;
293 int gzclose(gz)
294 gzFile gz;
299 if (gz == NULL)
301 strm = &(gz->strm);
302 if (gz->write) {
309 fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
315 fclose(gz->file);
316 free(gz);
322 const char *gzerror(gz, err)
323 gzFile gz;
326 *err = gz->err;
327 return gz->msg;
450 * Compress the given file: create a corresponding .gz file and remove the