/*! * @addtogroup common * \file error_handling.h * \brief 错误处理函数 * \date 2008/6/10 * \author James Pang */ #ifndef SIMPLE_ERR_H_INCLUDED #define SIMPLE_ERR_H_INCLUDED //! @headerfile Tceng ITK 头文件 #include #include #include #include #define ECHO(X) printf X; #define SYS_LOG(X) IMAN_write_syslog X; #define LOG_ECHO(X) printf X; IMAN_write_syslog X; /*! * \def CALL(x) * 打印错误信息 */ #define CALL(x) { \ int stat; \ char *err_string; \ if( (stat = (x)) != ITK_ok) \ { \ EMH_ask_error_text (stat, &err_string); \ LOG_ECHO( ("ERROR: %d ERROR MSG: %s.\n",stat, err_string) ) \ LOG_ECHO( ("Function: %s FILE: %s LINE: %d\n", #x, __FILE__, __LINE__ ) ) \ MEM_free (err_string); \ return (stat); \ } \ } /*! * \def DO(x) * 打印错误信息 */ #define DO(x) { \ int stat; \ char *err_string; \ if( (stat = (x)) != POM_ok) \ { \ EMH_ask_error_text (stat, &err_string); \ printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \ printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \ MEM_free (err_string); \ } \ } /*! * \def CALLRNULL(x) * 打印错误信息 */ #define CALLRNULL(x) { \ int stat; \ char *err_string; \ if( (stat = (x)) != ITK_ok) \ { \ EMH_ask_error_text (stat, &err_string); \ printf ("ERROR: %d ERROR MSG: %s.\n", stat, err_string); \ printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \ MEM_free (err_string); \ return ((char *)NULL); \ } \ } /*! * \def CALL2(x) * 打印错误信息 */ #define CALL2(x) { \ int stat, n_ifails, *serverities, *ifails, err_count; \ char *err_string, **texts; \ if( (stat = (x)) != ITK_ok) \ { \ printf ("Function: %s FILE: %s LINE: %d\n",#x, __FILE__, __LINE__); \ EMH_ask_errors( &n_ifails, (const int**)(&serverities), (const int**)(&ifails), (const char***)(&texts) );\ for( err_count=0; err_count