Discussion:
The "Sniffer"
(too old to reply)
Pete Goodeve
2003-10-26 05:33:29 UTC
Permalink
I've just been doing some exploring of the MIME facilities that I never
got around to before, and I'm a bit amazed at how much is undocumented.
Has anybody [unofficially?] domcumented things that aren't in the BeBook?

In particular I moted "GuessMimeType(...)" in the header, and find that
it works well. Can't find any docs, though.

I also found "GetSnifferRule(...)", which also returns rule strings for
things like zip files and source code (though not masic types like text/plain).
And there is a corresponding "SetSnifferRule(...)", so presumably these
rules must be kept somewhere on disc. However I'm damned if I can find
any trace of them in the file system... Does anyone know anything more?

-- Pete --
Pete Goodeve
2003-10-26 06:05:58 UTC
Permalink
...I also meant to ask if the syntax for Sniffer Rules is documented
anywhere. I assume they're similar to *nix 'file' rules, but I haven't
tried to compare them.
== Pete ==
Alexander G. M. Smith
2003-10-26 14:13:22 UTC
Permalink
....I also meant to ask if the syntax for Sniffer Rules is documented
anywhere. I assume they're similar to *nix 'file' rules, but I haven't
tried to compare them.
The sniffer rules are described in the Storage Kit release notes:
http://bang.dhs.org/be/bebook/Release%20Notes/StorageKit.html

- Alex
Pete Goodeve
2003-10-27 02:26:58 UTC
Permalink
Post by Alexander G. M. Smith
....I also meant to ask if the syntax for Sniffer Rules is documented
anywhere.
http://bang.dhs.org/be/bebook/Release%20Notes/StorageKit.html
Well, dunhhh... (:-/) It's funny, but with all the countless times
I've delved into the BeBook, my eyes seem to have skipped over [glazed
over?] the Release Notes section every time! There's quite a bit of
useful stuff in there.

Thanks. I'll remember to check there in future!

-- Pete --

[And I finally figured out that the sniff rule itself is an attribute
in the beos_mime/... settings folder!]
revol
2003-10-28 19:16:06 UTC
Permalink
Post by Pete Goodeve
Post by Alexander G. M. Smith
....I also meant to ask if the syntax for Sniffer Rules is documented
anywhere.
http://bang.dhs.org/be/bebook/Release%20Notes/StorageKit.html
Well, dunhhh... (:-/) It's funny, but with all the countless times
I've delved into the BeBook, my eyes seem to have skipped over [glazed
over?] the Release Notes section every time! There's quite a bit of
useful stuff in there.
Thanks. I'll remember to check there in future!
-- Pete --
[And I finally figured out that the sniff rule itself is an attribute
in the beos_mime/... settings folder!]
Also have a look at
setmime -dump

:-)

François.
Cedric Degea
2003-10-27 22:01:03 UTC
Permalink
Post by Pete Goodeve
I also found "GetSnifferRule(...)", which also returns rule strings for
things like zip files and source code (though not masic types like text/plain).
And there is a corresponding "SetSnifferRule(...)", so presumably these
rules must be kept somewhere on disc. However I'm damned if I can find
any trace of them in the file system... Does anyone know anything more?
A factoid that might help, dunno:

$ /bin/setmime -dump
[..]
/bin/setmime -set text/x-email -short "E-mail" -long "E-mail" -preferredAppSig application/x-vnd.Be-MAIL -sniffRule '0.20 ("Return-Path:")'
[.. etc]

I think 0.2 is the "certainty factor", and of course the subsequent
string is the thing to look for.
By looking at the dump, one may 'deduce' the syntax and stuff..
--
PGP key: http://cdegea.free.fr/degea_kagi_pubkey.txt | BeDev E-16870
"If you do not know which operating system you are running, most likely
it is Windows." -- Opera's registration page, circa 2001.
revol
2003-10-28 19:18:04 UTC
Permalink
Post by Cedric Degea
Post by Pete Goodeve
I also found "GetSnifferRule(...)", which also returns rule strings for
things like zip files and source code (though not masic types like text/plain).
And there is a corresponding "SetSnifferRule(...)", so presumably these
rules must be kept somewhere on disc. However I'm damned if I can find
any trace of them in the file system... Does anyone know anything more?
$ /bin/setmime -dump
[..]
/bin/setmime -set text/x-email -short "E-mail" -long "E-mail" -preferredAppSig application/x-vnd.Be-MAIL -sniffRule '0.20 ("Return-Path:")'
[.. etc]
I think 0.2 is the "certainty factor", and of course the subsequent
string is the thing to look for.
By looking at the dump, one may 'deduce' the syntax and stuff..
Eh, got the same idea..
Yeah teh 0.2 is the priority to account for this rule in case of other matches, I think.
One can also tell to look for certain bytes at certain places...

François.

Continue reading on narkive:
Loading...