File: snmplib_debug.c

package info (click to toggle)
squid 2.6.5-6etch5
  • links: PTS
  • area: main
  • in suites: etch
  • size: 12,540 kB
  • ctags: 13,801
  • sloc: ansic: 105,278; sh: 6,083; makefile: 1,297; perl: 1,245; awk: 40
file content (52 lines) | stat: -rw-r--r-- 909 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "config.h"
#if HAVE_STDIO_H
#include <stdio.h>
#endif
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if STDC_HEADERS
#include <stdarg.h>
#else
#include <varargs.h>
#endif

#if !HAVE_SNPRINTF
#include "snprintf.h"
#endif

#include "snmp_debug.h"

#if STDC_HEADERS
void (*snmplib_debug_hook) (int, char *,...) = NULL;
#else
void (*snmplib_debug_hook) (va_alist) = NULL;
#endif

extern void
#if STDC_HEADERS
snmplib_debug(int lvl, const char *fmt,...)
{
    char buf[BUFSIZ];
    va_list args;
    va_start(args, fmt);
#else
snmplib_debug(va_alist)
     va_dcl
{
    va_list args;
    int lvl;
    char char *fmt;
    char buf[BUFSIZ];
    va_start(args);
    lvl = va_arg(args, int);
    fmt = va_arg(args, char *);
#endif
    if (snmplib_debug_hook != NULL) {
	vsnprintf(buf, BUFSIZ, fmt, args);
	snmplib_debug_hook(lvl, buf);
    } else {
	vfprintf(stderr, fmt, args);
    }
    va_end(args);
}