#ifndef _SPHO_ERR_H #define _SPHO_ERR_H #include #ifdef SPHO_DEBUG #include #endif #define SPHO_ERR_SYS 0x000001 #define SPHO_ERR_INTERNAL 0x010001 #define SPHO_ERR_TOOBIG 0x010002 #define SPHO_ERR_ARGINVAL 0x010003 #define SPHO_ERR_NOM_INUSE 0x020001 #define SPHO_ERR_NOM_NOTINSCOPE 0x020002 #define SPHO_ERR_BIND_DUPL 0x030001 #define SPHO_ERR_BIND_NOTFOUND 0x030002 #define SPHO_ERR_IS_SYSERR(err) (SPHO_ERR_SYS == err) #define SPHO_ERR_BUF_LEN 2048 #define SPHO_ERR(ctx, e) \ do { \ (ctx)->err = (e); \ if ((e) == SPHO_ERR_SYS) \ SPHO_ERR_INFO(ctx, e, errno); \ else \ SPHO_ERR_INFO(ctx, e, 0); \ } while (0) #ifdef SPHO_DEBUG #define SPHO_ERR_FILEBUF_LEN 128 #define SPHO_ERR_INFO(ctx, e, info) \ do { \ (ctx)->err = (e); \ (ctx)->err_info = (info); \ snprintf((ctx)->filebuf, sizeof((ctx)->filebuf), \ __FILE__); \ (ctx)->errline = __LINE__; \ } while (0) #else /* SPHO_DEBUG */ #define SPHO_ERR_INFO(ctx, e, info) \ do { \ (ctx)->err = (e); \ (ctx)->err_info = (info); \ } while (0) #define SPHO_PRECOND(cond) #define SPHO_ASSERT(cond) #define SPHO_POSTCOND(cond) #define SPHO_DEBUG_PRINT(fmt, ...) #endif /* SPHO_DEBUG */ #endif /* _SPHO_ERR_H */