Path: utzoo!attcan!uunet!wyse!vsi1!apple!rutgers!columbia!douglass!dupuy From: dupuy@douglass.columbia.edu (Alexander Dupuy) Newsgroups: comp.sources.bugs Subject: Re: v05i028: /etc/magic lines for compress Message-ID: <6021@columbia.edu> Date: 16 Nov 88 21:46:50 GMT References: <1033@investor.UUCP> <454@auspex.UUCP> <7714@boring.cwi.nl> Sender: news@columbia.edu Reply-To: dupuy@douglass.columbia.edu (Alexander Dupuy) Followup-To: comp.sources.bugs Organization: Columbia University Computer Science Dept. Lines: 32 In article <454@auspex.UUCP> guy@auspex.UUCP (Guy Harris) writes: > Unfortunately, "strings" in "/etc/magic" cannot, in the standard S5 > version, contain C-language escapes, so you can't do this: > > 0 string \037\235 compressed data > > which the SunOS version of the S5 'file" supports; this obviates the need > for byte-order-dependent versions of "/etc/magic". In article <7714@boring.cwi.nl> dik@cwi.nl (Dik T. Winter) replies: > Wouldn't it be better to allow specification like AR16W, AR32W and > AR32WR as happens in so many places in SysV (COFF comes to mind)? > Then each system can specify in its favourite order its own /etc/magic > part. Not only is this better, but the "strings" in even the SunOS version of magic can't contain null bytes (well actually, they can, but it doesn't do what you want), and can't be masked in the way which SunOS allows you to mask numbers. While I find AR32WR pretty incomprehensible (is it network order, or reversed?) it should be possible to write a file which converts the numbers and masks specified in /etc/magic into network order before doing any comparisons, and converts values read from the file into local byte order before performing %d substitutions on the descriptions in the /etc/magic file. If needed, special printf macros could be used to indicate substitutions for which the bytes needed to be swapped before the ntohl conversion was done. This should provide a portable file(1). @alex -- inet: dupuy@columbia.edu uucp: ...!rutgers!columbia!dupuy