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 # if defined(__STDC__) || defined(_MSC_VER)
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 NETSNMP_NO_DEBUGGING
00037 # ifdef NETSNMP_FUNCTION
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__, \
00044 NETSNMP_FUNCTION); \
00045 }while(0)
00046 # else
00047 # define netsnmp_assert(x) do { \
00048 if( x )\
00049 ; \
00050 else \
00051 snmp_log(LOG_ERR,"netsnmp_assert %s failed %s:%d\n", \
00052 __STRING(x),__FILE__,__LINE__); \
00053 }while(0)
00054 # endif
00055 # else
00056 # define netsnmp_assert(x)
00057 # endif
00058 #endif
00059
00060
00061 #endif