#ifndef __ZERR_HEADER #define __ZERR_HEADER /*****************************************************************************/ /* */ /* Copyright 2007 ZTEC Instruments, Incorporated. All rights reserved. */ /* */ /* ZTEC Instruments zerr ================================================== */ /* By: ZTEC Instruments, Albuquerque, NM */ /* Version History: : */ /* Rev Date Description and functions affected */ /* ---- -------- ------------------------------------------------------- */ /* 1.00 02/09/07 Initial Release */ /*****************************************************************************/ #if defined(__cplusplus) || defined(__cplusplus__) extern "C" { #endif #ifdef _WIN32 #pragma warning( disable : 4996 ) #endif /* * @enum ErrLevel * @brief message priority level */ typedef enum ErrLevel { LVL_ERROR = 0, /**< error message */ LVL_WARN, /**< warning message */ LVL_INFO, /**< information message */ LVL_TRACE, /**< trace message */ LVL_DEBUG /**< debug message */ } ErrLevel; /* * @enum Err * @brief error value */ typedef enum Err { ERR_NOERR = 0, /**< no error occured */ ERR_NOMEM = -1, /**< out of memory error */ ERR_INVALID_DATA = -2, /**< invalid data value */ ERR_INVALID_TYPE = -3, /**< invalid data type */ ERR_IO = -4, /**< io error occured */ ERR_NULL = -5 /**< null pointer encountered */ } Err; /* * @enum StatusType * @brief type of callback content */ typedef enum StatusType { STATUS_MESSAGE = 0 /**< status message */ } StatusType; /** * @struct StatusVal * @brief transfer status information for callback */ typedef struct StatusVal { int lvl; /**< priority level of the message */ int err; /**< error value (if any) */ const char * msg; /**< context for message */ } StatusVal; /*****************************************************************************/ /*= Completion and Error Codes ==============================================*/ /*****************************************************************************/ #define ZT_TRUE (1) #define ZT_FALSE (0) #define ZT_NULL (0x0) #define ZT_SUCCESS (0L) #define ZT_FAILURE (0xFFFFFFFF) #define ZT_WARNING (0x1) #define ZT_COERCE_WARN 100 #define ZT_SPRINTF_ERR -901 #define ZT_SSCANF_ERR -902 #define ZT_MALLOC_ERR -903 #define ZT_STR_FORMAT_ERROR -904 #define ZT_ID_CHECK_ERR -905 /* // zt_chk_error returns if an error occured, run GetLastError() to get the specific error code. // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp // or check winerror.h or call FormatMessage(...) for a text description of the error code // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/retrieving_the_last_error_code.asp // This logic is to allow zt_chk_error to be used in compound conditionals */ #define zt_chk_error(function) if ((error = (function)) >= ZT_SUCCESS) {/* do nothing */} else return error #define TO_BOOL(x) (x!=0? ZT_TRUE:ZT_FALSE) #if defined(__cplusplus) || defined(__cplusplus__) } #endif /*****************************************************************************/ /*=== END INCLUDE FILE ======================================================*/ /*****************************************************************************/ #endif