30#define MERROR_OK 0x0000
38#define MERROR_USR 0x0001
40#define MERROR_OVERFLOW 0x0002
42#define MERROR_FILE 0x0004
44#define MERROR_ALLOC 0x0008
46#define MERROR_PARSE 0x0010
48#define MERROR_GUI 0x0020
50#define MERROR_SND MERROR_GUI
52#define MERROR_WAIT 0x0040
54#define MERROR_EXEC MERROR_WAIT
56#define MERROR_TIMEOUT 0x0080
67#define MERROR_PREEMPT (MERROR_EXEC | MERROR_TIMEOUT)
73#define MERROR_RESET (MERROR_EXEC | MERROR_PARSE)
79#define merror_sz_to_retval( sz ) ((sz) * -1)
81#define merror_retval_to_sz( retval ) ((retval) * -1)
83#define maug_cleanup_if_null_msg( type, ptr, err, msg ) \
84 if( (type)NULL == ptr ) { \
85 error_printf( msg ); \
90#define maug_cleanup_if_not_null( type, ptr, err ) \
91 if( (type)NULL == ptr ) { \
92 error_printf( #ptr " is not NULL!" ); \
97#define maug_cleanup_if_null( type, ptr, err ) \
98 maug_cleanup_if_null_msg( type, ptr, err, "failed to allocate " #ptr "!" )
100#define maug_cleanup_if_null_alloc( type, ptr ) \
101 maug_cleanup_if_null_msg( type, ptr, MERROR_ALLOC, "failed to allocate " #ptr "!" )
103#define maug_cleanup_if_null_lock( type, ptr ) \
104 maug_cleanup_if_null_msg( type, ptr, MERROR_ALLOC, "failed to lock " #ptr "!" )
106#define maug_cleanup_if_null_file( ptr ) \
107 maug_cleanup_if_null_msg( FILE*, ptr, MERROR_FILE, "failed to open FILE!" )
109#define maug_cleanup_if_not_ok() \
110 if( MERROR_OK != retval ) { \
114#define maug_cleanup_if_not_ok_msg( msg ) \
115 if( MERROR_OK != retval ) { \
116 error_printf( msg ); \
120#define maug_cleanup_if_lt( a, b, fmt, err ) \
122 error_printf( fmt " is less than " fmt "!", a, b ); \
127#define maug_cleanup_if_lt_overflow( a, b ) \
128 maug_cleanup_if_lt( a, b, SIZE_T_FMT, MERROR_OVERFLOW )
130#define maug_cleanup_if_ge( a, b, fmt, err ) \
132 error_printf( fmt " is greater or equal to " fmt "!", a, b ); \
137#define maug_cleanup_if_ge_overflow( a, b ) \
138 maug_cleanup_if_ge( a, (size_t)(b), SIZE_T_FMT, MERROR_OVERFLOW )
140#define maug_cleanup_if_eq( a, b, fmt, err ) \
142 error_printf( #a " " fmt " is equal to " #b " " fmt "!", a, b ); \
147#define maug_cleanup_if_ne( a, b, fmt, err ) \
149 error_printf( #a " " fmt " is NOT equal to " #b " " fmt "!", a, b ); \
uint16_t MERROR_RETVAL
Return type indicating function returns a value from this list.
Definition: merror.h:28
void maug_critical_error(const char *msg)
Display an error dialog. This is a minimal function that can be called early on (e....