recovery: add libcrecovery

This is modified for use in both C and C++ environments.