#include #include /* error codes */ #define RERR_NONE 0 #define RERR_OPEN 1 /* cant open file */ #define RERR_READ 2 /* error reading from file */ #define RERR_WRITE 3 /* error writing to file */ #define RERR_NOMEMORY 4 /* out of memory */ #define RERR_NOCOLOR 5 /* out of color cells */ #define RERR_BADIMAGEFILE 6 /* image file is corrupted or invalid */ #define RERR_BADFORMAT 7 /* image file format is unknown */ #define RERR_BADINDEX 8 /* no such image index in file */ #define RERR_BADVISUALID 16 /* invalid visual ID requested for context */ #define RERR_STDCMAPFAIL 17 /* failed to created std colormap */ #define RERR_XERROR 127 /* internal X error */ #define RERR_INTERNAL 128 /* should not happen */ void wraster_report_error_code(int value); const char* wraster_current_error_message(); int wraster_current_error_code(); int main(int argc, char** argv) { assert(wraster_current_error_code() == RERR_NONE); assert(strcmp(wraster_current_error_message(), "no error") == 0); wraster_report_error_code(RERR_WRITE); assert(wraster_current_error_code() == RERR_WRITE); assert(strcmp(wraster_current_error_message(), "error writing to file") == 0); wraster_report_error_code(RERR_OPEN); assert(wraster_current_error_code() == RERR_OPEN); assert(strcmp(wraster_current_error_message(), "could not open file") == 0); }