00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef XSH_ERROR_H
00028 #define XSH_ERROR_H
00029
00030
00037
00040
00041
00042
00043 #include <irplib_error.h>
00044
00045 #include <cpl.h>
00046
00047
00048
00049
00050
00051
00052
00053
00054 #define assure(CONDITION, ERROR_CODE, ...) \
00055 irplib_error_assure(CONDITION, ERROR_CODE, (__VA_ARGS__), goto cleanup)
00056
00058 #define assure_nomsg(BOOL, CODE) \
00059 assure(BOOL, CODE, " ")
00060
00061
00062 #define check_msg(COMMAND, ...) \
00063 irplib_error_assure((cpl_msg_indent_more(), \
00064 (COMMAND), \
00065 cpl_msg_indent_less(), \
00066 cpl_error_get_code() == CPL_ERROR_NONE), \
00067 cpl_error_get_code(), \
00068 (__VA_ARGS__), goto cleanup)
00069
00070
00071 #define check(COMMAND) check_msg(COMMAND, " ")
00072
00073 #define cknull_msg(NULLEXP, ...) \
00074 cpl_error_ensure((NULLEXP) != NULL, \
00075 CPL_ERROR_UNSPECIFIED, goto cleanup,__VA_ARGS__)
00076
00077 #define cknull(NULLEXP) cknull_msg(NULLEXP," ")
00078
00079 #define assure_mem(PTR) \
00080 assure((PTR) != NULL, CPL_ERROR_ILLEGAL_OUTPUT, "Memory allocation failure!")
00081
00082 #define passure(CONDITION, ...) assure(CONDITION, CPL_ERROR_UNSPECIFIED, \
00083 "Internal program error. Please report to " \
00084 PACKAGE_BUGREPORT " " __VA_ARGS__)
00085
00086
00087 #define xsh_error_reset() xsh_irplib_error_reset()
00088
00089
00090
00091
00092 #define xsh_error_dump(level) irplib_error_dump(level, level)
00093
00094 #define xsh_error_msg(...) \
00095 if(cpl_error_get_code()!= CPL_ERROR_NULL_INPUT){\
00096 irplib_error_push(cpl_error_get_code(), (__VA_ARGS__));\
00097 }
00098
00099 #define XSH_ASSURE_NOT_NULL(pointer) \
00100 assure(pointer != NULL, CPL_ERROR_NULL_INPUT,\
00101 "You have null pointer in input: " #pointer)
00102
00103 #define XSH_ASSURE_NOT_NULL_MSG(pointer,msg) \
00104 assure(pointer != NULL, CPL_ERROR_NULL_INPUT,\
00105 "You have null pointer in input: " #pointer "\n" msg)
00106
00107 #define XSH_ASSURE_NOT_ILLEGAL(cond) \
00108 assure(cond, CPL_ERROR_ILLEGAL_INPUT,\
00109 "condition failed: " #cond )
00110
00111 #define XSH_ASSURE_NOT_ILLEGAL_MSG(cond, msg) \
00112 assure(cond, CPL_ERROR_ILLEGAL_INPUT,\
00113 "condition failed: " #cond "\n" msg)
00114
00115 #define XSH_ASSURE_NOT_MISMATCH(cond) \
00116 assure(cond, CPL_ERROR_TYPE_MISMATCH,\
00117 "condition failed: "#cond )
00118
00119 #define XSH_CMP_INT(A, OPERATOR, B, SUFFIX ,...)\
00120 assure(A OPERATOR B, CPL_ERROR_ILLEGAL_INPUT,\
00121 "assertion failed: %s %s %s : %d %s %d\n"\
00122 #SUFFIX "", #A, #OPERATOR, #B , A, #OPERATOR, B __VA_ARGS__)
00123
00124 #define XSH_CHECK_COND(A, OPERATOR, B, SUFFIX, ...)\
00125 assure(A OPERATOR B, CPL_ERROR_ILLEGAL_INPUT,\
00126 "assertion failed: %s %s %s\n" #SUFFIX "", #A, #OPERATOR, #B, __VA_ARGS__)
00127
00128 #define XSH_CHECK_FRAMESET_SIZE(FRAMESET,OPERATOR,SIZE)\
00129 XSH_CHECK_COND(cpl_frameset_get_size(FRAMESET),OPERATOR,SIZE,\
00130 "%s","Frameset size invalid:")
00131
00132 #define XSH_REGDEBUG( ...)\
00133 xsh_msg_debug("<< REGDEBUG >> :" __VA_ARGS__)
00134
00135 #endif
00136