00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _NPT_RESULTS_H_
00011 #define _NPT_RESULTS_H_
00012
00013
00014
00015
00016 #if defined(NPT_DEBUG)
00017 #include "NptDebug.h"
00018 #define NPT_CHECK(_x) \
00019 do { \
00020 NPT_Result _result = (_x); \
00021 if (_result != NPT_SUCCESS) { \
00022 NPT_Debug("%s(%d): @@@ NPT_CHECK failed, result=%d\n", __FILE__, __LINE__, _result); \
00023 return _result; \
00024 } \
00025 } while(0)
00026 #define NPT_CHECK_POINTER(_p) \
00027 do { \
00028 if ((_p) == NULL) { \
00029 NPT_Debug("%s(%d): @@@ NULL pointer parameter\n", __FILE__, __LINE__); \
00030 return NPT_ERROR_INVALID_PARAMETERS; \
00031 } \
00032 } while(0)
00033 #define NPT_CHECK_LABEL(x, label) \
00034 do { \
00035 NPT_Result _result = (x); \
00036 if (_result != NPT_SUCCESS) { \
00037 NPT_Debug("%s(%d): @@@ NPT_CHECK failed, result=%d\n", __FILE__, __LINE__, _result); \
00038 goto label; \
00039 } \
00040 } while(0)
00041 #else
00042 #define NPT_CHECK(_x) \
00043 do { \
00044 NPT_Result _result = (_x); \
00045 if (_result != NPT_SUCCESS) { \
00046 return _result; \
00047 } \
00048 } while(0)
00049 #define NPT_CHECK_POINTER(_p) \
00050 do { \
00051 if ((_p) == NULL) return NPT_ERROR_INVALID_PARAMETERS; \
00052 } while(0)
00053 #define NPT_CHECK_LABEL(x, label) \
00054 do { \
00055 NPT_Result _result = (x); \
00056 if (_result != NPT_SUCCESS) { \
00057 goto label; \
00058 } \
00059 } while(0)
00060 #endif
00061
00062 #define NPT_FAILED(result) ((result) != NPT_SUCCESS)
00063 #define NPT_SUCCEEDED(result) ((result) == NPT_SUCCESS)
00064
00065
00066
00067
00069 #define NPT_SUCCESS 0
00070
00072 #define NPT_FAILURE (-1)
00073
00074 #if !defined(NPT_ERROR_BASE)
00075 #define NPT_ERROR_BASE -20000
00076 #endif
00077
00078
00079 const int NPT_ERROR_BASE_GENERAL = NPT_ERROR_BASE-0;
00080 const int NPT_ERROR_BASE_LIST = NPT_ERROR_BASE-100;
00081 const int NPT_ERROR_BASE_FILE = NPT_ERROR_BASE-200;
00082 const int NPT_ERROR_BASE_IO = NPT_ERROR_BASE-300;
00083 const int NPT_ERROR_BASE_SOCKET = NPT_ERROR_BASE-400;
00084 const int NPT_ERROR_BASE_INTERFACES = NPT_ERROR_BASE-500;
00085 const int NPT_ERROR_BASE_XML = NPT_ERROR_BASE-600;
00086 const int NPT_ERROR_BASE_UNIX = NPT_ERROR_BASE-700;
00087 const int NPT_ERROR_BASE_HTTP = NPT_ERROR_BASE-800;
00088 const int NPT_ERROR_BASE_THREADS = NPT_ERROR_BASE-900;
00089 const int NPT_ERROR_BASE_SERIAL_PORT = NPT_ERROR_BASE-1000;
00090
00091
00092 const int NPT_ERROR_INVALID_PARAMETERS = NPT_ERROR_BASE_GENERAL - 0;
00093 const int NPT_ERROR_PERMISSION_DENIED = NPT_ERROR_BASE_GENERAL - 1;
00094 const int NPT_ERROR_OUT_OF_MEMORY = NPT_ERROR_BASE_GENERAL - 2;
00095 const int NPT_ERROR_NO_SUCH_NAME = NPT_ERROR_BASE_GENERAL - 3;
00096 const int NPT_ERROR_NO_SUCH_PROPERTY = NPT_ERROR_BASE_GENERAL - 4;
00097 const int NPT_ERROR_NO_SUCH_ITEM = NPT_ERROR_BASE_GENERAL - 5;
00098 const int NPT_ERROR_NO_SUCH_CLASS = NPT_ERROR_BASE_GENERAL - 6;
00099 const int NPT_ERROR_OVERFLOW = NPT_ERROR_BASE_GENERAL - 7;
00100 const int NPT_ERROR_INTERNAL = NPT_ERROR_BASE_GENERAL - 8;
00101 const int NPT_ERROR_INVALID_STATE = NPT_ERROR_BASE_GENERAL - 9;
00102 const int NPT_ERROR_INVALID_FORMAT = NPT_ERROR_BASE_GENERAL - 10;
00103 const int NPT_ERROR_INVALID_SYNTAX = NPT_ERROR_BASE_GENERAL - 11;
00104 const int NPT_ERROR_NOT_IMPLEMENTED = NPT_ERROR_BASE_GENERAL - 12;
00105 const int NPT_ERROR_NOT_SUPPORTED = NPT_ERROR_BASE_GENERAL - 13;
00106 const int NPT_ERROR_TIMEOUT = NPT_ERROR_BASE_GENERAL - 14;
00107 const int NPT_ERROR_WOULD_BLOCK = NPT_ERROR_BASE_GENERAL - 15;
00108 const int NPT_ERROR_TERMINATED = NPT_ERROR_BASE_GENERAL - 16;
00109
00110 #endif // _NPT_RESULTS_H_