Fixed bug with fopen not opening shapefiles as binary (thanks, Jay). Added extensive comments. Added boilerplate for other shape types.