2 ===================================================================
3 RCS file: /cvsroot/external/sane/ChangeLog,v
4 retrieving revision 1.1.1.1.2.115
5 diff -u -r1.1.1.1.2.115 ChangeLog
6 --- ChangeLog 2000/03/18 03:14:11 1.1.1.1.2.115
7 +++ ChangeLog 2000/03/18 03:19:11
9 2000-03-18 Petter Reinholdtsen <pere@td.org.uit.no>
11 + * include/sane/sanei_debug.h sanei/sanei_init_debug.c: Send debug
12 + messages to syslog if stderr is a socket.
14 +2000-03-18 Petter Reinholdtsen <pere@td.org.uit.no>
16 * backend/Makefile.in tools/libtool-get-dll-ext: New script to
17 detect shared library endings without using 'rev' which is missing
19 Index: include/sane/sanei_debug.h
20 ===================================================================
21 RCS file: /cvsroot/external/sane/include/sane/sanei_debug.h,v
22 retrieving revision 1.1.1.1.2.1
23 diff -u -r1.1.1.1.2.1 sanei_debug.h
24 --- sanei_debug.h 2000/01/25 15:37:55 1.1.1.1.2.1
25 +++ sanei_debug.h 2000/03/18 03:19:12
27 +#ifndef _SANEI_DEBUG_H
28 +#define _SANEI_DEBUG_H
30 #include <sane/sanei.h>
32 #define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
34 # define HAVE_VARARG_MACROS
37 -#ifndef HAVE_VARARG_MACROS
38 - extern void sanei_debug (int level, const char *msg, ...);
40 +extern void sanei_debug (int level, const char *msg, ...);
43 # define DBG_INIT(backend, var)
45 #define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
47 #if defined(BACKEND_NAME) && !defined(STUBS)
48 -int PASTE(sanei_debug_,BACKEND_NAME);
53 - sanei_init_debug (STRINGIFY(BACKEND_NAME), \
54 - &PASTE(sanei_debug_,BACKEND_NAME))
55 + sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
57 /* The cpp that comes with GNU C 2.5 seems to have troubles understanding
59 #ifdef HAVE_VARARG_MACROS
60 +extern void sanei_debug_max (int level, int max_level, const char *msg, ...);
62 # define DBG(level, msg, args...) \
64 - if (DBG_LEVEL >= (level)){ \
65 - fprintf (stderr, "[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \
68 + sanei_debug_max ( level, DBG_LEVEL, \
69 + "[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \
72 extern void sanei_init_debug (const char * backend, int * debug_level_var);
74 # define DBG sanei_debug
76 +#endif /* HAVE_VARARG_MACROS */
83 +# warning "sane/sanei_debug.h included more then once!"
84 +#endif /* _SANEI_DEBUG_H */
85 Index: sanei/sanei_init_debug.c
86 ===================================================================
87 RCS file: /cvsroot/external/sane/sanei/sanei_init_debug.c,v
88 retrieving revision 1.1.1.1
89 diff -u -r1.1.1.1 sanei_init_debug.c
90 --- sanei_init_debug.c 1999/08/09 18:05:59 1.1.1.1
91 +++ sanei_init_debug.c 2000/03/18 03:19:12
100 +#include <sys/syslog.h>
101 +#ifdef HAVE_SYS_SOCKET_H
102 +#include <sys/socket.h>
104 +#include <sys/stat.h>
111 +#define BACKEND_NAME sanei_debug
112 #include <sane/sanei_debug.h>
114 -#ifndef HAVE_VARARG_MACROS
115 - static int max_level = 0;
117 +static int global_max_level = 0;
121 sanei_init_debug (const char * backend, int * var)
123 char ch, buf[256] = "SANE_DEBUG_";
134 -#ifndef HAVE_VARARG_MACROS
135 - if (*var > max_level)
138 + if (*var > global_max_level)
139 + global_max_level = *var;
141 - fprintf (stderr, "[sanei_init_debug]: Setting debug level of %s to %d.\n",
143 + DBG (0, "Setting debug level of %s to %d.\n", backend, *var);
146 -#ifndef HAVE_VARARG_MACROS
150 +debug_msg (int level, int max_level, const char *fmt, va_list ap)
152 + if (max_level >= level)
154 + if ( 1 == isfdtype(fileno(stderr), S_IFSOCK) )
155 + vsyslog(LOG_DEBUG, fmt, ap);
157 + vfprintf (stderr, fmt, ap);
162 sanei_debug (int level, const char *fmt, ...)
166 - if (max_level >= level)
168 - va_start (ap, fmt);
169 - vfprintf (stderr, fmt, ap);
172 + va_start (ap, fmt);
173 + debug_msg (level, global_max_level, fmt, ap);
177 -#endif /* !HAVE_VARARG_MACROS */
179 +sanei_debug_max (int level, int max_level, const char *fmt, ...)
182 + va_start (ap, fmt);
183 + debug_msg (level, max_level, fmt, ap);