]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
wrapper for snmplib_debug because the hook might be NULL
authorwessels <>
Thu, 26 Feb 1998 03:55:49 +0000 (03:55 +0000)
committerwessels <>
Thu, 26 Feb 1998 03:55:49 +0000 (03:55 +0000)
include/cache_snmp.h
include/snmp_debug.h
snmplib/Makefile.in
snmplib/mib.c
snmplib/parse.c
snmplib/snmplib_debug.c [new file with mode: 0644]

index 6459a5b74511daf3586ec0723914a0552b4e04b8..82fff92d7f6ff5c009b8cb6d3ea39057267108ee 100644 (file)
@@ -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 */
index aa315cac42a73e6718652d1638f5c35191d9a6fa..9211ca71d4d15b7f353a9deefbccf8c46806f441 100644 (file)
@@ -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
index 6617a2558c9e0231c1137122184d596a26cdb053..0949698e9f5d1764dd92f81b600a960fdc571bf3 100644 (file)
@@ -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@
index a7d69b23c4a7f830a21c05da9aa6765b49f8764d..5a46723bedf93647af67022f1ac1cf6afa8517ff 100644 (file)
@@ -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;
 
index 1c2769f2073c3f2badd19b54e42fc007bfe6f1db..da7aab8d01273583962c5122976e7f404a9b0c01 100644 (file)
@@ -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 (file)
index 0000000..dd70bbb
--- /dev/null
@@ -0,0 +1,36 @@
+#include "config.h"
+#if HAVE_STDIO_H
+#include <stdio.h>
+#endif
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#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);
+}
+