From: wessels <> Date: Thu, 26 Feb 1998 03:55:49 +0000 (+0000) Subject: wrapper for snmplib_debug because the hook might be NULL X-Git-Tag: SQUID_3_0_PRE1~3986 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e79c699f37ee8f4d18fc1a53d983c593d1be23a;p=thirdparty%2Fsquid.git wrapper for snmplib_debug because the hook might be NULL --- diff --git a/include/cache_snmp.h b/include/cache_snmp.h index 6459a5b745..82fff92d7f 100644 --- a/include/cache_snmp.h +++ b/include/cache_snmp.h @@ -14,9 +14,9 @@ /* debugging redirected to squid (DW approach) */ #ifdef __STDC__ -void (*snmplib_debug) (int,...); +void (*snmplib_debug_hook) (int,char *,...); #else -void (*snmplib_debug) (va_alist)); +void (*snmplib_debug_hook) (va_alist); #endif /* mib stuff here */ diff --git a/include/snmp_debug.h b/include/snmp_debug.h index aa315cac42..9211ca71d4 100644 --- a/include/snmp_debug.h +++ b/include/snmp_debug.h @@ -3,9 +3,11 @@ #ifndef SQUID_H #ifdef __STDC__ -extern void (*snmplib_debug) (int,char *,...); +extern void snmplib_debug(int,char *,...); +extern void (*snmplib_debug_hook) (int,char *,...); #else -extern void (*snmplib_debug) (va_alist); +extern void snmplib_debug(va_alist); +extern void (*snmplib_debug_hook) (va_alist); #endif #endif diff --git a/snmplib/Makefile.in b/snmplib/Makefile.in index 6617a2558c..0949698e9f 100644 --- a/snmplib/Makefile.in +++ b/snmplib/Makefile.in @@ -21,13 +21,13 @@ CSRCS = asn1.c parse.c snmp_dump.c snmp_vars.c \ coexistance.c snmp_api.c snmp_error.c \ mib.c snmp_api_error.c \ mibii.c snmp_api_util.c snmp_msg.c \ - snmp_pdu.c + snmp_pdu.c snmplib_debug.c OBJS = asn1.o parse.o snmp_dump.o snmp_vars.o \ coexistance.o snmp_api.o snmp_error.o \ mib.o snmp_api_error.o \ mibii.o snmp_api_util.o snmp_msg.o \ - snmp_pdu.o + snmp_pdu.o snmplib_debug.o CC = @CC@ AR_R = @AR_R@ diff --git a/snmplib/mib.c b/snmplib/mib.c index a7d69b23c4..5a46723bed 100644 --- a/snmplib/mib.c +++ b/snmplib/mib.c @@ -531,8 +531,7 @@ set_functions(subtree) void init_mib(char *file) { - if (snmplib_debug != NULL) - snmplib_debug(6, "init_mib: Called.\n"); + snmplib_debug(6, "init_mib: Called.\n"); if (Mib != NULL) return; diff --git a/snmplib/parse.c b/snmplib/parse.c index 1c2769f207..da7aab8d01 100644 --- a/snmplib/parse.c +++ b/snmplib/parse.c @@ -261,7 +261,6 @@ print_error(string, token, type) int type; { assert(string != NULL); - assert(snmplib_debug != NULL); if (type == ENDOFFILE) snmplib_debug(0, "%s(EOF): On or around line %d\n", string, Line); else if (token) diff --git a/snmplib/snmplib_debug.c b/snmplib/snmplib_debug.c new file mode 100644 index 0000000000..dd70bbbcef --- /dev/null +++ b/snmplib/snmplib_debug.c @@ -0,0 +1,36 @@ +#include "config.h" +#if HAVE_STDIO_H +#include +#endif +#ifdef __STDC__ +#include +#else +#include +#endif + +#include "snmp_debug.h" + +extern void +#ifdef __STDC__ +snmplib_debug(int lvl,char *fmt,...) +{ + va_list args; + va_start(args, fmt); +#else +snmplib_debug(va_alist) + va_dcl +{ + va_list args; + int lvl; + char char *fmt; + va_start(args); + lvl = va_arg(args, int); + fmt = va_arg(args, char *); +#endif + if (snmplib_debug_hook != NULL) + snmplib_debug_hook(lvl, fmt, args); + else + vfprintf(stderr, fmt, args); + va_end(args); +} +