summaryrefslogtreecommitdiff
path: root/rpmio/macro.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2007-11-23 10:05:49 +0200
committerPanu Matilainen <pmatilai@redhat.com>2007-11-23 10:05:49 +0200
commitff77bfa2a1951473edab1db8e3bd29be5d69443b (patch)
tree055b9af202f81c84675da089892e54dccd794ba6 /rpmio/macro.c
parentc1bcd633010cce22919dbc5c347fa401971d39a8 (diff)
downloadlibrpm-tizen-ff77bfa2a1951473edab1db8e3bd29be5d69443b.tar.gz
librpm-tizen-ff77bfa2a1951473edab1db8e3bd29be5d69443b.tar.bz2
librpm-tizen-ff77bfa2a1951473edab1db8e3bd29be5d69443b.zip
Move file compression stuff from rpmmacro.h to rpmfileutil.h
Diffstat (limited to 'rpmio/macro.c')
-rw-r--r--rpmio/macro.c58
1 files changed, 1 insertions, 57 deletions
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 <rpmio.h>
#include <rpmstring.h>
+#include <rpmfileutil.h>
#include <rpmurl.h>
#include <rpmmessages.h>
#include <rpmlog.h>
@@ -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, ...)
{