Add #include <libgen.h> for using basename().
Add typedef for error_t if it's not defined.