Added error checking to pipe functions, wrote packet caching

Pipe functions now print an error message upon failure instead of
simply returning. Packets will now be properly cached when they're
received, and old packets are freed.
Added thread-safety and meaningful error messages for cnt_errno

The functions get_error_string and write_error can be used to get
the error string and write to cnt_error in a thread-safe way.
Fixed compilation errors

The program now runs again. Still need to implement writing error messages
to the gameplay side instead of simply dying.