00001 #ifndef SNMP_ASSERT_H
00002 #define SNMP_ASSERT_H
00003
00004 #ifdef NETSNMP_USE_ASSERT
00005 # include <assert.h>
00006 #else
00007 # include <net-snmp/library/snmp_logging.h>
00008 #endif
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __STRING
00019 # ifdef __STDC__
00020 # define __STRING(x) #x
00021 # else
00022 # define __STRING(x) "x"
00023 # endif
00024 #endif
00025
00026
00027
00028
00029 #ifdef NETSNMP_USE_ASSERT
00030
00031 # define netsnmp_assert(x) assert( x )
00032 #else
00033
00034
00035
00036 # ifndef SNMP_NO_DEBUGGING
00037 # ifdef HAVE_CPP_UNDERBAR_FUNCTION_DEFINED
00038 # define netsnmp_assert(x) do { \
00039 if ( x ) \
00040 ; \
00041 else \
00042 snmp_log(LOG_ERR,"netsnmp_assert %s failed %s:%d %s()\n", \
00043 __STRING(x),__FILE__,__LINE__,__FUNCTION__); \
00044 }while(0)
00045 # else
00046 # define netsnmp_assert(x) do { \
00047 if( x )\
00048 ; \
00049 else \
00050 snmp_log(LOG_ERR,"netsnmp_assert %s failed %s:%d\n", \
00051 __STRING(x),__FILE__,__LINE__); \
00052 }while(0)
00053 # endif
00054 # else
00055 # define netsnmp_assert(x)
00056 # endif
00057 #endif
00058
00059
00060 #endif