Lines Matching refs:pz

30 Pzstate_t	state = { "libpz:pz" };
39 Pz_t* pz = (Pz_t*)((char*)disc - offsetof(Pz_t, vmdisc));
45 if (pz->disc->errorf)
46 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "invalid pointer %p passed to free or realloc", obj);
49 if (pz->disc->errorf)
52 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "storage allocator out of space on %lu byte request ( region %lu segments %lu busy %lu:%lu:%lu free %lu:%lu:%lu )", (size_t)obj, st.extent, st.n_seg, st.n_busy, st.s_busy, st.m_busy, st.n_free, st.s_free, st.m_free);
64 pzfind(Pz_t* pz, const char* file, const char* suffix, const char* mode)
71 if (!pathfind(file, pz->disc->lib ? pz->disc->lib : pz->id, suffix, buf, sizeof(buf)))
73 if (pz->disc->errorf)
74 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "%s: cannot find %s file", file, suffix ? suffix : "data");
79 if (pz->disc->errorf)
80 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "%s: cannot read", buf);
88 * open a new pz stream
94 register Pz_t* pz;
100 pz = (Pz_t*)path;
101 pz->mainpart = 0;
102 pz->flags &= ~PZ_HEAD;
108 if (!(pz = vmnewof(vm, 0, Pz_t, 1, 0)) || !(pz->tmp = sfstropen()) || !(pz->str = sfstropen()) || (flags & PZ_WRITE) && !(pz->det = sfstropen()))
110 pz->vmdisc = *Vmdcheap;
111 pz->vmdisc.exceptf = nomalloc;
112 if (!vmdisc(vm, &pz->vmdisc))
114 tvgettime(&pz->start);
115 pz->major = PZ_MAJOR;
116 pz->minor = PZ_MINOR;
117 pz->id = state.id;
118 pz->disc = disc;
119 pz->flags = flags|PZ_MAINONLY;
120 pz->vm = vm;
121 pz->win = disc->window ? disc->window : PZ_WINDOW;
126 pz->path = "/dev/stdin";
127 if (!(pz->io = sfnew(NiL, NiL, SF_UNBOUND, sffileno(sfstdin), SF_READ)))
130 (*disc->errorf)(pz, disc, 2, "%s: cannot read", pz->path);
134 else if (!(pz->io = sfopen(NiL, pz->path = "/dev/null", "r")))
137 (*disc->errorf)(pz, disc, 2, "%s: cannot read", path);
141 pz->flags |= PZ_STREAM;
143 else if (pz->flags & PZ_STREAM)
145 pz->path = "stream";
146 pz->io = (Sfio_t*)path;
148 else if (!(pz->io = strneq(path, "pipe://", 7) ? sfpopen(NiL, path + 7, "r") : sfopen(NiL, path, "r")))
151 (*disc->errorf)(pz, disc, 2, "%s: cannot read", path);
154 else if (!(pz->path = vmstrdup(vm, path)))
158 * without this large .pz and .gz terminate short of EOF
161 if (!(pz->test & 0x00001000))
162 sfsetbuf(pz->io, (void*)pz->io, SF_UNBOUND);
163 if (pz->flags & PZ_DIO)
164 sfdcdio(pz->io, 0);
172 if (!fstat(sffileno(pz->io), &st) && S_ISFIFO(st.st_mode))
173 pz->flags &= ~PZ_CRC;
174 else if (!(pz->flags & PZ_POP) && (!(pz->flags & PZ_WRITE) && sfdcgzip(pz->io, (pz->flags & PZ_CRC) ? 0 : SFGZ_NOCRC) > 0 || (pz->flags & (PZ_PUSHED|PZ_WRITE)) == PZ_WRITE && sfdcpzip((Sfio_t*)pz, pz->path, pz->flags|PZ_FORCE|PZ_PUSHED|PZ_HANDLE, disc) > 0))
175 pz->flags |= PZ_POP;
177 pz->flags &= ~PZ_CRC;
178 pz->oip = pz->io;
179 if (disc->initf && !(*disc->initf)(pz, disc))
181 if (disc->options && (!(pz->options = vmstrdup(pz->vm, disc->options)) || pzoptions(pz, NiL, pz->options, 0) < 0))
184 if ((pz->flags & (PZ_READ|PZ_SPLIT|PZ_STAT)) || !disc->partition)
186 if (pzheadread(pz))
188 if ((pz->flags & PZ_SPLIT) && disc->partition && pzpartition(pz, disc->partition))
190 if (pz->options && pzoptions(pz, pz->part, pz->options, 1) < 0)
195 if (disc->partition && pzpartition(pz, disc->partition))
197 if (pz->disc->version >= PZ_VERSION_SPLIT && pz->disc->splitf)
199 pz->split.flags |= PZ_SPLIT_DEFLATE;
200 pz->flags |= PZ_ACCEPT|PZ_SECTION;
201 pz->flags &= ~PZ_SORT;
203 if (pz->options && pzoptions(pz, pz->part, pz->options, 1) < 0)
205 if ((pz->flags & (PZ_NOPZIP|PZ_UNKNOWN)) == PZ_UNKNOWN && !pz->disc->readf && !pz->disc->splitf)
207 if (pz->disc->errorf)
208 (*pz->disc->errorf)(pz, pz->disc, 2, "%s: unknown input format", pz->path);
217 pz->part = pz->mainpart;
218 if (pz->disc->eventf && (*pz->disc->eventf)(pz, (flags & PZ_AGAIN) ? PZ_REOPEN : PZ_OPEN, NiL, 0, pz->disc) < 0)
220 if (pz->disc->errorf)
221 (*pz->disc->errorf)(pz, pz->disc, -1, "%s: pzopen: flags=%08x win=(%I*u:%I*u) row=(%I*u:%I*u) buf=%p wrk=%p", pz->path, pz->flags, sizeof(pz->win), pz->win, sizeof(pz->mwin), pz->mwin, sizeof(pz->row), pz->row, sizeof(pz->mrow), pz->mrow, pz->buf, pz->wrk);
222 return pz;
224 pzclose(pz);
229 * close an open pz stream
233 pzclose(register Pz_t* pz)
241 if (!pz)
243 if (!(r = pzsync(pz)) && (op = pz->ws.io))
250 if (pz->ws.pc)
252 if (pz->disc->errorf)
253 (*pz->disc->errorf)(pz, pz->disc, 1, "last record incomplete %u/%u", pz->ws.pc, pz->row);
255 sfputu(op, pz->ws.pc);
256 sfwrite(op, pz->ws.pb, pz->ws.pc);
258 if (!(pz->flags & PZ_SECTION))
261 if (pz->disc->eventf && (*pz->disc->eventf)(pz, PZ_TAILWRITE, op, 0, pz->disc) < 0)
267 if (pz->disc->errorf)
268 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "write error");
272 if ((pz->flags & PZ_WRITE) && (pz->flags & (PZ_DUMP|PZ_VERBOSE|PZ_SUMMARY)) && pz->disc->errorf && pz->count.records)
274 if (!pz->count.uncompressed)
275 pz->count.uncompressed = pz->part->row * pz->count.records;
276 if (!pz->count.compressed)
278 pz->count.compressed = pz->count.uncompressed;
279 if (pz->oop)
281 if (!(pz->flags & PZ_NOGZIP))
282 while (sfdisc(pz->oop, SF_POPDISC));
283 if ((p = sfsize(pz->oop)) > 0)
284 pz->count.compressed = p;
287 if (pz->flags & PZ_REGRESS)
292 if (!(e = ((unsigned long)now.tv_sec - (unsigned long)pz->start.tv_sec) * 100 + ((long)now.tv_nsec - (long)pz->start.tv_nsec) / 10000000L))
295 sfprintf(pz->tmp, _("total %s rate %.2f time %s bpr %.2f bps %s size %I*u/%I*u windows %I*u")
296 , pz->path
297 , (double)((Sflong_t)pz->count.uncompressed) / (double)((Sflong_t)pz->count.compressed)
299 , (double)((Sflong_t)pz->count.compressed) / (double)((Sflong_t)pz->count.records)
300 , fmtnum((pz->count.uncompressed * 100) / e, 0)
301 , sizeof(pz->count.uncompressed)
302 , pz->count.uncompressed
303 , sizeof(pz->count.compressed)
304 , pz->count.compressed
305 , sizeof(pz->count.windows)
306 , pz->count.windows
308 if (pz->count.sections)
309 sfprintf(pz->tmp, _(" sections %I*u")
310 , sizeof(pz->count.sections)
311 , pz->count.sections
313 sfprintf(pz->tmp, _(" records %I*u")
314 , sizeof(pz->count.records)
315 , pz->count.records
317 if (pz->count.modules)
318 sfprintf(pz->tmp, _(" modules %I*u")
319 , sizeof(pz->count.modules)
320 , pz->count.modules
322 if (pz->count.converted)
323 sfprintf(pz->tmp, _(" converted %I*u")
324 , sizeof(pz->count.converted)
325 , pz->count.converted
327 if (pz->count.repaired)
328 sfprintf(pz->tmp, _(" repaired %I*u")
329 , sizeof(pz->count.repaired)
330 , pz->count.repaired
332 if (pz->count.truncated)
333 sfprintf(pz->tmp, _(" truncated %I*u")
334 , sizeof(pz->count.truncated)
335 , pz->count.truncated
337 if (pz->count.dropped)
338 sfprintf(pz->tmp, _(" dropped %I*u")
339 , sizeof(pz->count.dropped)
340 , pz->count.dropped
342 (*pz->disc->errorf)(pz, pz->disc, 0, "%s", sfstruse(pz->tmp));
344 if (pz->io)
346 if (pz->oip)
348 if (pz->disc->eventf)
349 r = (*pz->disc->eventf)(pz, PZ_CLOSE, NiL, 0, pz->disc);
350 if (!(pz->flags & PZ_STREAM))
352 if (sfclose(pz->oip) < 0)
354 if (pz->disc->errorf)
355 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "%s: data corrupted (close error)", pz->path);
359 else if (pz->flags & PZ_POP)
360 sfdisc(pz->oip, SF_POPDISC);
361 pz->oip = 0;
363 else if (pz->flags & PZ_POP)
365 sfdisc(pz->io, SF_POPDISC);
366 if (sferror(pz->io))
368 pz->flags |= PZ_ERROR;
369 if (pz->disc->errorf)
370 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, (pz->flags & PZ_WRITE) ? "write error" : "read error");
374 if (pz->flags & PZ_ERROR)
376 if (pz->partdict)
377 dtclose(pz->partdict);
378 if (pz->vm)
379 vmclose(pz->vm);
380 if (pz->tmp)
381 sfclose(pz->tmp);
382 if (pz->str)
383 sfclose(pz->str);
384 if (pz->det)
385 sfclose(pz->det);
394 pznospace(Pz_t* pz)
396 if (pz->disc->errorf)
397 (*pz->disc->errorf)(pz, pz->disc, ERROR_SYSTEM|2, "out of space");