]> granicus.if.org Git - file/commitdiff
FIx windows icons and cursors (Christoph Biedl)
authorChristos Zoulas <christos@zoulas.com>
Sat, 8 Mar 2014 17:26:48 +0000 (17:26 +0000)
committerChristos Zoulas <christos@zoulas.com>
Sat, 8 Mar 2014 17:26:48 +0000 (17:26 +0000)
the detection of MS-Windows icon files was buggy and incomplete. Since
non-animated cursors have a very similar format, they are added here,
too.

Some details: Using only the very first four octets for determination
has always some risk of false detection. So additionally look at
offset 9 which should always be zero, but according to Wikipedia might
also be 0xff.

In "number of colors" at offset 8, the zero value previously was used
to describe "256 colors", according to Wikipedia this isn't true, so
it was dropped.

On a side node: This introduces another usage of name/use. I'm afraid
we might sooner or later end up in name clashes on these identifiers.
Feel free to extend them like prefixing with the file name "msdos-".

Also, I was a bit surprised no "message" in "use" is printed, I wanted
to do

    >>4 use     ico-dir     MS Windows icon resource

but that message gets lost. Hence the hackery

    >>0 byte    x           MS Windows icon resource
    >>4 use     ico-dir

So a feature request: Print any message in "use".

This patch by the way fixes Debian#562250. It just got a little
bigger.

magic/Magdir/msdos

index 08dd631b03fad75c262715aced19e82840ba4351..a5d8f641a97427f8a357810ac0ba5d5252e5159e 100644 (file)
@@ -1,6 +1,6 @@
 
 #------------------------------------------------------------------------------
-# $File: msdos,v 1.86 2014/01/08 22:10:18 christos Exp $
+# $File: msdos,v 1.87 2014/03/06 19:30:52 christos Exp $
 # msdos:  file(1) magic for MS-DOS files
 #
 
 #ico files
 0      string/b        \102\101\050\000\000\000\056\000\000\000\000\000\000\000        Icon for MS Windows
 
-# Windows icons (Ian Springer <ips@fpk.hp.com>)
-0      string/b        \000\000\001\000        MS Windows icon resource
+# Windows icons
+0   name    ico-dir
+# not entirely accurate, the number of icons is part of the header
+>0  byte    1   - 1 icon
+>0  ubyte   >1  - %d icons
+>2  byte    0   \b, 256x
+>2  byte    !0  \b, %dx
+>3  byte    0   \b256
+>3  byte    !0  \b%d
+>4  ubyte   !0  \b, %d colors
+
+0   belong  0x00000100
 !:mime image/x-icon
->4     byte    1                       - 1 icon
->4     byte    >1                      - %d icons
->>6    byte    >0                      \b, %dx
->>>7   byte    >0                      \b%d
->>8    byte    0                       \b, 256-colors
->>8    byte    >0                      \b, %d-colors
 
+>9  byte    0
+>>0 byte    x           MS Windows icon resource
+>>4 use     ico-dir
+>9  ubyte   0xff
+>>0 byte    x           MS Windows icon resource
+>>4 use     ico-dir
+
+# Windows non-animated cursors
+0   name    cur-dir
+# not entirely accurate, the number of icons is part of the header
+>0  byte        1   - 1 icon
+>0  ubyte       >1  - %d icons
+>2  byte        0   \b, 256x
+>2  byte        !0  \b, %dx
+>3  byte        0   \b256
+>3  byte        !0  \b%d
+>6  uleshort    x   \b, hotspot @%dx
+>8  uleshort    x   \b%d
+
+0   belong  0x00000200
+!:mime image/x-cur
+>9  byte    0
+>>0 byte    x           MS Windows cursor resource
+>>4 use     cur-dir
+>9  ubyte   0xff
+>>0 byte    x           MS Windows cursor resource
+>>4 use     cur-dir
 
 # .chr files
 0      string/b        PK\010\010BGI   Borland font