add thread support

Signed-off-by: Mattias Andrée <maandree@operamail.com>
c version: make with WITH_WIPE=yes to wipe the state and message buffer before freeing

Signed-off-by: Mattias Andrée <maandree@operamail.com>
c version: make the state accessible

Signed-off-by: Mattias Andrée <maandree@operamail.com>