[comp.unix.admin] /etc/magic entry for GIF files?

nsayer@uop.edu (Nick Sayer) (10/24/90)

It is my understanding that GIF files are identified as such
by the first three letters of the file being GIF, and that the
version of GIF file is identified by the next 3. With that
in mind, I came up with this addition to /etc/magic:

0	string		GIF		GIF image
>3	byte&0x7f	x		(version %c
>4	byte&0x7f	x		%c
>5	byte&0x7f	x		%c)

Not only is this a little on the cumbersome side, it
results in:

foo.gif		GIF image (version 8 7 a)

What I REALLY want is:

0	string		GIF		GIF image
>3	string		xxx		(version %s)

but that doesn't work, obviously. Any ideas?

-- 
Nick Sayer               |  "Disclaimer? I don't think so!  | RIP: Mel Blanc
mrapple@quack.sac.ca.us  |   Homey don't play dat."         |   1908-1989
N6QQQ  [44.2.1.17]       |                                  |  May he never
209-952-5347 (Telebit)   |                --Homey the Clown |  be silenced.

matthew@sunpix.east.sun.com (Matthew Stier - Sun Visualization Products) (10/25/90)

In article <2725be7d.55aa@uop.uop.edu> nsayer@uop.edu (Nick Sayer) writes:
>What I REALLY want is:
>
>0	string		GIF		GIF image
>>3	string		xxx		(version %s)
>
>but that doesn't work, obviously. Any ideas?
>

To quote the man page:


               For string values, the byte string from  the  file
               must  match  the  specified  byte string; the byte
               string from the file which is matched is the  same
               length as the specified byte string.

In other words, your 'ideal' /etc/magic' entry is looking for the character
string 'xxx'.  To fix this problem, one would have to change 'file(1)' to
have some wildcard pattern for strings.  I get around the problem with these
lines:

0       string          GIF             GIF image 
>3      string          87a             (version 87a) 
>3      string          89a             (version 89a)

These are the only two version numbers currently authorized by Compuserve.


-- 
Matthew Lee Stier    (mstier@east.Sun.COM)   |
Sun Microsystems ---  RTP, NC  27709-3447    |     "Wisconsin   Escapee"
uucp:  sun!mstier or mcnc!rti!sunpix!matthew |
phone: (919) 469-8300 fax: (919) 460-8355    |

pim@cti-software.nl (Pim Zandbergen) (11/01/90)

matthew@sunpix.east.sun.com (Matthew Stier - Sun Visualization Products) writes:

	0       string          GIF             GIF image 
	>3      string          87a             (version 87a) 
	>3      string          89a             (version 89a)

This entry also lists the resolution of your GIF image:
(at least when your CPU has the same byte order as the 80386)

0x0	string		GIF		GIF picture
>0x3	string		87a		 - version %s
>0x3	string		89a		 - version %s
>0x6	short		>0		(%d
>0x8	short		>0		x %d)

Now if I only could list the number of colours!
-- 
Pim Zandbergen                          domain : pim@cti-software.nl
CTI Software BV                         uucp   : uunet!mcsun!hp4nl!ctisbv!pim
Laan Copes van Cattenburch 70           phone  : +31 70 3542302
2585 GD The Hague, The Netherlands      fax    : +31 70 3512837