On Sun, 06 Jul 2008 17:20:12 EDT erik quanstrom <[EMAIL PROTECTED]>  wrote:
> what is the upside to an external magic file?  as you've shown, you
> can add a file type in 1 line of code.  while the external magic file
> isn't c, i would argue that it's still code.  

Yes it is code but the advantage is that the parser language
is factored out and anyone can add knowledge about new file
formats and it is easy to debug and experiment.

The main disadvantage of gnu file is performance.  As an
example, on about 6000 files totalling 200MB, gnu file takes
2s user, 1s system and 30s real time.  Compared to that p9p
file takes 1.65s user, 0.25s system and 1.9s real time.
Note: any cache effects have been accounted for by looking at
only the best 3 runs of of each test.  As per csh, there were
no page faults and no disk io.

The magic file should really be compiled and linked w/
file(1) -- if that was done right, the rest of file(1) code
would be pretty trivial.  On the other hand file is usually
not a performance bottleneck.  On the gripping hand there are
a lot of similarities between cracking file formats and
packet formats so may be there is value in factoring all that
out and sticking it in a library routine.

Reply via email to