Port of DotDetector to C

Ported most functionality.