This code probably does not fit your needs. Do not use this unless you have read and understood tor-spec.txt and really know what you are doing.
In here you will find an implementation of a subset of the TOR client protocol and a TOR consensus parser. As a rule, only the latest versons of the subprotocols are implemented.