Whew, just starting here.
First things first, a list of a few pages I find interesting:
[mime type recognition in pure tcl] [mime type discriminator]