From: Christos Zoulas Date: Wed, 11 Nov 2015 22:22:19 +0000 (+0000) Subject: Print the compression program name or zlib. X-Git-Tag: FILE5_26~84 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b2422769807ffaf9eb7c947ffbd0329e8e2874f;p=file Print the compression program name or zlib. --- diff --git a/src/compress.c b/src/compress.c index d2d23dbf..196363e9 100644 --- a/src/compress.c +++ b/src/compress.c @@ -35,7 +35,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: compress.c,v 1.84 2015/11/10 22:52:07 christos Exp $") +FILE_RCSID("@(#)$File: compress.c,v 1.85 2015/11/11 21:19:12 christos Exp $") #endif #include "magic.h" @@ -175,6 +175,7 @@ private int uncompresszlib(const unsigned char *, unsigned char **, size_t *, private int uncompressgzipped(const unsigned char *, unsigned char **, size_t *); #endif +private const char *methodname(size_t); protected int file_zmagic(struct magic_set *ms, int fd, const char *name, @@ -214,8 +215,8 @@ file_zmagic(struct magic_set *ms, int fd, const char *name, case ERRDATA: ms->flags &= ~MAGIC_COMPRESS; if (rv == ERRDATA) - rv = file_printf(ms, "UNCOMPRESS ERROR: %s", - newbuf); + rv = file_printf(ms, "%s ERROR: %s", + methodname(i), newbuf); else rv = file_buffer(ms, -1, name, newbuf, nsz); if (rv == -1) @@ -605,6 +606,17 @@ filter_error(unsigned char *ubuf, ssize_t n) return n; } +private const char * +methodname(size_t method) +{ +#ifdef BUILTIN_DECOMPRESS + /* FIXME: This doesn't cope with bzip2 */ + if (method == 2 || compr[method].maglen == 0) + return "zlib"; +#endif + return compr[method].argv[0]; +} + private int uncompressbuf(int fd, size_t method, const unsigned char *old, unsigned char **newch, size_t* n)