/* * error.h * * Summary: Exception handling functions. * * Author: David Hardy */ #ifndef H_ERROR #define H_ERROR #ifdef __cplusplus extern "C" { #endif #define MDIO_WARN_UNKNOWN 0x1 #define MDIO_WARN_COMMENT 0x2 #define MDIO_WARN_TRUNC 0x4 #define MDIO_ERR_LEVEL 0x400 /* unused, test whether warn or error */ #define MDIO_ERR_FORMAT 0x800 #define MDIO_ERR_MEMALLOC 0x1000 #define MDIO_ERR_OPEN 0x2000 #define MDIO_ERR_CLOSE 0x4000 #define MDIO_ERR_READ 0x8000 #define MDIO_ERR_WRITE 0x10000 #define MDIO_ERR_UNSUPPORTED 0x20000 int mdio_warn(const char *, ...); /* works like printf(), except to stderr */ int mdio_error(const char *, ...); void mdio_fatal(const char *, ...); /* terminates program using exit() */ const char *mdio_errmsg(int); /* returns string describing status */ #ifdef MDIO_DEBUG #define MDIO_ASSERT(x) /* use this like a function call */ \ if (!(x)) mdio_fatal("failed assertion: file %s, line %d\n",__FILE__,__LINE__) #else #define MDIO_ASSERT(x) #endif #if defined(MDIO_TEST) || defined(MDIO_MODULE_TEST) /* declare functions used to test module */ int error_test(void); #endif #ifdef __cplusplus } #endif #endif /* H_ERROR */