Esempio n. 1
0
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;
}
Esempio n. 2
0
int ts_fclose(ts_file_t *fp)
{
  TS_TRY(fp);

  switch(fp->type)
    {
    case TS_FILE_STD: TS_TRY( 0 ==  fclose(fp->fp.std) ); break;
    case TS_FILE_ZLB: TS_TRY( 0 == gzclose(fp->fp.zlb) ); break;
    case TS_FILE_XZ:  TS_TRY( 0 == xzclose(fp->fp.xz)  ); break;
    default:
      (void)ts_warn(stderr, "\n");
      goto fail;
    }

  free(fp); fp=0;
	
  return(0);

 fail:
  return(EOF);
}