]> granicus.if.org Git - file/commitdiff
mime consistency fixes from Reuben Thomas <rrt@sc3d.org>
authorChristos Zoulas <christos@zoulas.com>
Sun, 19 Aug 2007 03:45:07 +0000 (03:45 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sun, 19 Aug 2007 03:45:07 +0000 (03:45 +0000)
ChangeLog
configure.in
magic/magic.mime
src/ascmagic.c
src/compress.c
src/is_tar.c
src/magic.c

index e2c8418e371f8fe2072ab74b632cfc68348ae800..803859888d8c095d541835ad86e5e19802a310da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2007-08-19  6:30 Christos Zoulas <christos@zoulas.com>
+
+       * Make mime format consistent so that it can
+         be easily parsed:
+             mimetype [charset=character-set] [encoding=encoding-mime-type]
+
+         Remove spurious extra text from some MIME type printouts 
+         (mostly in is_tar).
+
+         Fix one case where -i produced nothing at all (for a 1-byte file,
+         which is now classed as application/octet-stream).
+
+         Remove 7/8bit classifications, since they were arbitrary
+         and not based on the file data.
+
+         This work was done by Reuben Thomas
+
 2007-05-24 10:00 Christos Zoulas <christos@zoulas.com>
 
        * Fix another integer overflow (Colin Percival)
index 189edbd742a6cbdc7eec2923b91aabdbed732b3a..a0819c7eb1ea1a72049ae4a82bc91f453487b753 100644 (file)
@@ -106,12 +106,15 @@ AC_CHECK_TYPE_STDC(uint32_t, unsigned int)
 AC_CHECK_TYPE_STDC(int32_t, int)
 AC_C_LONG_LONG
 if test $ac_cv_c_long_long = yes; then
-  long64='unsigned long long';
+  ulong64='unsigned long long';
+  long64='long long';
 else
-  long64='unsigned long';
+  ulong64='unsigned long';
+  long64='long';
 fi
 dnl This needs a patch to autoconf 2.13 acgeneral.m4
-AC_CHECK_TYPE2_STDC(uint64_t, $long64)
+AC_CHECK_TYPE2_STDC(uint64_t, $ulong64)
+AC_CHECK_TYPE2_STDC(int64_t, $long64)
 
 AC_CHECK_SIZEOF_STDC_HEADERS(uint8_t, 0)
 AC_CHECK_SIZEOF_STDC_HEADERS(uint16_t, 0)
index 787a6c86ae3aaa4d326761215787ba690f16b60d..462f5eb1dcc79c4301157644309520a16c14a1b3 100644 (file)
 
 # XPM icons (Greg Roelofs, newt@uchicago.edu)
 # ideally should go into "images", but entries below would tag XPM as C source
-0      string          /*\ XPM         image/x-xpmi 7bit
+0      string          /*\ XPM         image/x-xpmi
 
 # 3DS (3d Studio files) Conflicts with diff output 0x3d '='
 #16    beshort         0x3d3d          image/x-3ds
 
 # PBMPLUS
 #                                      PBM file
-0      string          P1              image/x-portable-bitmap 7bit
+0      string          P1              image/x-portable-bitmap
 #                                      PGM file
-0      string          P2              image/x-portable-greymap        7bit
+0      string          P2              image/x-portable-greymap
 #                                      PPM file
-0      string          P3              image/x-portable-pixmap 7bit
+0      string          P3              image/x-portable-pixmap
 #                                      PBM "rawbits" file
 0      string          P4              image/x-portable-bitmap
 #                                      PGM "rawbits" file
 # lisp:  file(1) magic for lisp programs
 #
 # various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
-0      string  ;;                      text/plain      8bit
+0      string  ;;                      text/plain
 # Emacs 18 - this is always correct, but not very magical.
 0      string  \012(                   application/x-elc
 # Emacs 19
 # mail.news:  file(1) magic for mail and news
 #
 # There are tests to ascmagic.c to cope with mail and news.
-0      string          Relay-Version:  message/rfc822  7bit
-0      string          #!\ rnews       message/rfc822  7bit
-0      string          N#!\ rnews      message/rfc822  7bit
-0      string          Forward\ to     message/rfc822  7bit
-0      string          Pipe\ to        message/rfc822  7bit
-0      string          Return-Path:    message/rfc822  7bit
+0      string          Relay-Version:  message/rfc822
+0      string          #!\ rnews       message/rfc822
+0      string          N#!\ rnews      message/rfc822
+0      string          Forward\ to     message/rfc822
+0      string          Pipe\ to        message/rfc822
+0      string          Return-Path:    message/rfc822
 0      string          Received:       message/rfc822
-0      string          Path:           message/news    8bit
-0      string          Xref:           message/news    8bit
-0      string          From:           message/rfc822  7bit
-0      string          Article         message/news    8bit
+0      string          Path:           message/news
+0      string          Xref:           message/news
+0      string          From:           message/rfc822
+0      string          Article         message/news
 #------------------------------------------------------------------------------
 # msword: file(1) magic for MS Word files
 #
index 564556ddee359d8231fbeb9e12a1eb4d8f21311b..add8bf4cf00310b6f3a91f84868a78c931ce36b1 100644 (file)
@@ -49,7 +49,7 @@
 #include "names.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: ascmagic.c,v 1.50 2007/03/15 14:51:00 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.51 2007/08/19 03:45:07 christos Exp $")
 #endif /* lint */
 
 typedef unsigned long unichar;
@@ -281,7 +281,7 @@ subtype_identified:
                }
 
                if (code_mime) {
-                       if (file_printf(ms, "; charset=") == -1)
+                       if (file_printf(ms, " charset=") == -1)
                                goto done;
                        if (file_printf(ms, code_mime) == -1)
                                goto done;
index 2ccbef6e86e054d77629ac358b56f85b5beb0ac3..5f8a7bbcf0de369b8e699fc8924a68be50ac840f 100644 (file)
@@ -55,7 +55,7 @@
 
 
 #ifndef lint
-FILE_RCSID("@(#)$File: compress.c,v 1.51 2007/03/05 02:41:29 christos Exp $")
+FILE_RCSID("@(#)$File: compress.c,v 1.52 2007/08/19 03:45:08 christos Exp $")
 #endif
 
 private struct {
@@ -112,11 +112,13 @@ file_zmagic(struct magic_set *ms, int fd, const char *name,
                        rv = -1;
                        if (file_buffer(ms, -1, name, newbuf, nsz) == -1)
                                goto error;
-                       if (file_printf(ms, " (") == -1)
+                       if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
+                           " compressed-encoding=" : " (") == -1)
                                goto error;
                        if (file_buffer(ms, -1, NULL, buf, nbytes) == -1)
                                goto error;
-                       if (file_printf(ms, ")") == -1)
+                       if (!(ms->flags & MAGIC_MIME) &&
+                           file_printf(ms, ")") == -1)
                                goto error;
                        rv = 1;
                        break;
index c7d4d4d95c48efc79c92663beb1b1700c393e6e4..02ef975db3984479a5da0cf93ac7f925084af7e2 100644 (file)
@@ -45,7 +45,7 @@
 #include "tar.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$File: is_tar.c,v 1.27 2007/01/12 17:38:28 christos Exp $")
+FILE_RCSID("@(#)$File: is_tar.c,v 1.28 2007/08/19 03:45:08 christos Exp $")
 #endif
 
 #define        isodigit(c)     ( ((c) >= '0') && ((c) <= '7') )
@@ -68,13 +68,12 @@ file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
                return 1;
        case 2:
                if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
-                   "application/x-tar, POSIX" : "POSIX tar archive") == -1)
+                   "application/x-tar" : "POSIX tar archive") == -1)
                        return -1;
                return 1;
        case 3:
                if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
-                   "application/x-tar, POSIX (GNU)" :
-                   "POSIX tar archive (GNU)") == -1)
+                   "application/x-tar" : "POSIX tar archive (GNU)") == -1)
                        return -1;
                return 1;
        default:
index 54db48b1fe29d88cde9af3abfae42a9bfc55eb42..14feca7dff4682de6d8bf37999cbb895f6237996 100644 (file)
@@ -63,7 +63,7 @@
 #include "patchlevel.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: magic.c,v 1.41 2007/03/26 17:59:50 christos Exp $")
+FILE_RCSID("@(#)$File: magic.c,v 1.42 2007/08/19 03:45:08 christos Exp $")
 #endif /* lint */
 
 #ifdef __EMX__
@@ -331,7 +331,8 @@ magic_file(struct magic_set *ms, const char *inname)
                    "application/x-empty" : "empty") == -1)
                        goto done;
        } else if (nbytes == 1) {
-               if (file_printf(ms, "very short file (no magic)") == -1)
+               if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
+                       "application/octet-stream" : "very short file (no magic)") == -1)
                        goto done;
        } else {
                (void)memset(buf + nbytes, 0, SLOP); /* NUL terminate */