From ff77bfa2a1951473edab1db8e3bd29be5d69443b Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 23 Nov 2007 10:05:49 +0200 Subject: Move file compression stuff from rpmmacro.h to rpmfileutil.h --- rpmio/macro.c | 58 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 57 deletions(-) (limited to 'rpmio/macro.c') diff --git a/rpmio/macro.c b/rpmio/macro.c index aac05fe5d..f3393ec6b 100644 --- a/rpmio/macro.c +++ b/rpmio/macro.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -1855,63 +1856,6 @@ rpmFreeMacros(rpmMacroContext mc) memset(mc, 0, sizeof(*mc)); } -/* =============================================================== */ -int isCompressed(const char * file, rpmCompressedMagic * compressed) -{ - FD_t fd; - ssize_t nb; - int rc = -1; - unsigned char magic[13]; - - *compressed = COMPRESSED_NOT; - - fd = Fopen(file, "r.ufdio"); - if (fd == NULL || Ferror(fd)) { - /* XXX Fstrerror */ - rpmlog(RPMLOG_ERR, _("File %s: %s\n"), file, Fstrerror(fd)); - if (fd) (void) Fclose(fd); - return 1; - } - nb = Fread(magic, sizeof(magic[0]), sizeof(magic), fd); - if (nb < 0) { - rpmlog(RPMLOG_ERR, _("File %s: %s\n"), file, Fstrerror(fd)); - rc = 1; - } else if (nb < sizeof(magic)) { - rpmlog(RPMLOG_ERR, _("File %s is smaller than %u bytes\n"), - file, (unsigned)sizeof(magic)); - rc = 0; - } - (void) Fclose(fd); - if (rc >= 0) - return rc; - - rc = 0; - - if ((magic[0] == 'B') && (magic[1] == 'Z')) { - *compressed = COMPRESSED_BZIP2; - } else if ((magic[0] == 0120) && (magic[1] == 0113) && - (magic[2] == 0003) && (magic[3] == 0004)) { /* pkzip */ - *compressed = COMPRESSED_ZIP; - } else if ((magic[ 9] == 0x00) && (magic[10] == 0x00) && - (magic[11] == 0x00) && (magic[12] == 0x00)) { - /* lzma */ - /* FIXME: lzma doesn't have a magic, - * consider to additionally check the filename */ - *compressed = COMPRESSED_LZMA; - } else if (((magic[0] == 0037) && (magic[1] == 0213)) || /* gzip */ - ((magic[0] == 0037) && (magic[1] == 0236)) || /* old gzip */ - ((magic[0] == 0037) && (magic[1] == 0036)) || /* pack */ - ((magic[0] == 0037) && (magic[1] == 0240)) || /* SCO lzh */ - ((magic[0] == 0037) && (magic[1] == 0235)) /* compress */ - ) { - *compressed = COMPRESSED_OTHER; - } - - return rc; -} - -/* =============================================================== */ - char * rpmExpand(const char *arg, ...) { -- cgit v1.2.3