shared-mime-info test program: mimebreaker

david at david at
Mon May 24 09:05:04 EEST 2004

In the hope of improving the shared-mime-info database, I've written a
test program that reads a file, and tries to generate byte sequences that will match multiple sniff patterns.

In the default build it spits out all pairs of mimetypes containing
<match> elements for which it can generate a file matching both.  You
can also give it a list of mimetypes, and it will try to generate an
example of a file matching all of those mimetypes to stdout.  There are
other modes which can find n-way intersections, write xml reports of the
problems encountered, and which will fill directories with examples of
ambiguous files, though at the moment you have to hack the source to get
at these.

Currently it ignores the priorities and any bitmasks, so it's cheating
somewhat.  It also assumes that no two <glob> patterns will match, so it
might miss some possible ambiguities where they do.  The code is a
rather crude mixture of C++ and the STL, glib, and libxml2, but it seems
to work; there may be bugs, and I may have misinterpreted the spec.

The code can be downloaded here:

Dave Malcolm

More information about the xdg mailing list