Rearrange code

Signed-off-by: John Else <john.else@citrix.com>
Change semantics of the decoding functions

Functions now return both the decoded value, and the remaining part
of the bitstring.

Also rename decode_* to read_* in honour of the new semantics.

Signed-off-by: John Else <john.else@citrix.com>
Add string encoder/decoder

Signed-off-by: John Else <john.else@citrix.com>