1 #ifndef ETTERCAP_ERROR_H
2 #define ETTERCAP_ERROR_H
3 
4 #include <ec.h>
5 #include <errno.h>
6 
7 enum {
8    E_SUCCESS    = 0,
9    E_NOTFOUND   = 1,
10    E_NOMATCH    = 2,
11    E_NOTHANDLED = 3,
12    E_INVALID    = 4,
13    E_NOADDRESS  = 5,
14    E_DUPLICATE  = 6,
15    E_TIMEOUT    = 7,
16    E_INITFAIL   = 8,
17    E_FOUND      = 128,
18    E_BRIDGE     = 129,
19    E_VERSION    = 254,
20    E_FATAL      = 255,
21 };
22 
23 EC_API_EXTERN void error_msg(char *file, const char *function, int line, char *message, ...);
24 EC_API_EXTERN void warn_msg(char *file, const char *function, int line, char *message, ...);
25 EC_API_EXTERN void fatal_error(char *message, ...);
26 EC_API_EXTERN void bug(char *file, const char *function, int line, char *message);
27 
28 
29 #define WARN_MSG(x, ...) warn_msg(__FILE__, __FUNCTION__, __LINE__, x, ## __VA_ARGS__ )
30 #define ERROR_MSG(x, ...) error_msg(__FILE__, __FUNCTION__, __LINE__, x, ## __VA_ARGS__ )
31 
32 #define FATAL_ERROR(x, ...) do { fatal_error(x, ## __VA_ARGS__ ); } while(0)
33 
34 #define ON_ERROR(x, y, fmt, ...) do { if (x == y) ERROR_MSG(fmt, ## __VA_ARGS__ ); } while(0)
35 
36 #define BUG_IF(x) do { if (x) bug(__FILE__, __FUNCTION__, __LINE__, #x); }while(0)
37 
38 #define BUG(x) do { bug(__FILE__, __FUNCTION__, __LINE__, #x); }while(0)
39 
40 #define NOT_IMPLEMENTED() do { BUG("Not yet implemented, please contact the authors"); } while(0)
41 
42 
43 #endif
44 
45 /* EOF */
46 
47 // vim:ts=3:expandtab
48 
49