#endif
#ifndef lint
-FILE_RCSID("@(#)$Id: compress.c,v 1.43 2006/06/08 20:52:08 christos Exp $")
+FILE_RCSID("@(#)$Id: compress.c,v 1.44 2006/10/20 21:03:40 christos Exp $")
#endif
-
private struct {
const char *magic;
size_t maglen;
private int ncompr = sizeof(compr) / sizeof(compr[0]);
+#define NODATA ((size_t)~0)
+
private ssize_t swrite(int, const void *, size_t);
private size_t uncompressbuf(struct magic_set *, int, size_t,
continue;
if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0 &&
(nsz = uncompressbuf(ms, fd, i, buf, &newbuf,
- nbytes)) != 0) {
+ nbytes)) != NODATA) {
ms->flags &= ~MAGIC_COMPRESS;
rv = -1;
if (file_buffer(ms, -1, newbuf, nsz) == -1)
inflateEnd(&z);
/* let's keep the nul-terminate tradition */
- (*newch)[n++] = '\0';
+ (*newch)[n] = '\0';
return n;
}
if ((fd != -1 && pipe(fdin) == -1) || pipe(fdout) == -1) {
file_error(ms, errno, "cannot create pipe");
- return 0;
+ return NODATA;
}
switch (fork()) {
case 0: /* child */
/*NOTREACHED*/
case -1:
file_error(ms, errno, "could not fork");
- return 0;
+ return NODATA;
default: /* parent */
(void) close(fdout[1]);
n = r;
}
/* NUL terminate, as every buffer is handled here. */
- (*newch)[n++] = '\0';
+ (*newch)[n] = '\0';
err:
if (fdin[1] != -1)
(void) close(fdin[1]);