static int xzdClose( /*@only@*/ void * cookie) /*@globals fileSystem, internalState @*/ /*@modifies fileSystem, internalState @*/ { FD_t fd = c2f(cookie); XZFILE *xzfile; const char * errcookie; int rc; xzfile = xzdFileno(fd); if (xzfile == NULL) return -2; errcookie = strerror(ferror(xzfile->fp)); fdstat_enter(fd, FDSTAT_CLOSE); /*@-dependenttrans@*/ rc = xzclose(xzfile); /*@=dependenttrans@*/ fdstat_exit(fd, FDSTAT_CLOSE, rc); if (fd && rc == -1) fd->errcookie = errcookie; DBGIO(fd, (stderr, "==>\txzdClose(%p) rc %lx %s\n", cookie, (unsigned long)rc, fdbg(fd))); if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "XZDIO", stderr); /*@-branchstate@*/ if (rc == 0) fd = fdFree(fd, "open (xzdClose)"); /*@=branchstate@*/ return rc; }
static int gzdClose(FD_t fd) { gzFile gzfile; int rc; gzfile = gzdFileno(fd); if (gzfile == NULL) return -2; /* XXX can't happen */ rc = gzclose(gzfile); /* XXX TODO: preserve fd if errors */ if (fd) { if (rc < 0) { fd->errcookie = "gzclose error"; if (rc == Z_ERRNO) { fd->syserrno = errno; fd->errcookie = strerror(fd->syserrno); } } } if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "GZDIO", stderr); if (rc == 0) fdFree(fd); return rc; }
static int bzdClose(FD_t fd) { BZFILE *bzfile; int rc; bzfile = bzdFileno(fd); if (bzfile == NULL) return -2; /* FIX: check rc */ BZ2_bzclose(bzfile); rc = 0; /* XXX FIXME */ /* XXX TODO: preserve fd if errors */ if (fd) { if (rc == -1) { int zerror = 0; fd->errcookie = BZ2_bzerror(bzfile, &zerror); } } if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "BZDIO", stderr); if (rc == 0) fdFree(fd); return rc; }
static int lzdClose(FD_t fd) { LZFILE *lzfile; int rc; lzfile = lzdFileno(fd); if (lzfile == NULL) return -2; rc = lzclose(lzfile); /* XXX TODO: preserve fd if errors */ if (fd) { if (rc == -1) { fd->errcookie = "lzclose error"; fd->syserrno = errno; fd->errcookie = strerror(fd->syserrno); } } if (_rpmio_debug || rpmIsDebug()) fdstat_print(fd, "XZDIO", stderr); if (rc == 0) fdFree(fd); return rc; }