Merge devel (v1.0.3) into head branch.

DEVEL_2_0_BRANCH-1
Petter Reinholdtsen 2000-08-12 15:11:00 +00:00
rodzic 5db918d2d2
commit 5420a147d5
1 zmienionych plików z 24 dodań i 21 usunięć

Wyświetl plik

@ -1,6 +1,9 @@
#ifndef _SANEI_DEBUG_H
#define _SANEI_DEBUG_H
#include <sane/sanei.h> #include <sane/sanei.h>
#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name) #define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
/* The cpp that comes with GNU C 2.5 seems to have troubles understanding /* The cpp that comes with GNU C 2.5 seems to have troubles understanding
vararg macros. */ vararg macros. */
@ -8,46 +11,46 @@
# define HAVE_VARARG_MACROS # define HAVE_VARARG_MACROS
#endif #endif
#ifndef HAVE_VARARG_MACROS extern void sanei_debug (int level, const char *msg, ...);
extern void sanei_debug (int level, const char *msg, ...);
#endif
#ifdef NDEBUG #ifdef NDEBUG
# define DBG_INIT(backend, var) # define DBG_LEVEL (0)
# define DBG_INIT()
# ifdef HAVE_VARARG_MACROS # ifdef HAVE_VARARG_MACROS
# define DBG(level, msg, args...) # define DBG(level, msg, args...)
# else # else
# define DBG if (0) sanei_debug # define DBG if (0) sanei_debug
# endif # endif
# define IF_DBG(x) # define IF_DBG(x)
#else #else
# include <stdio.h> # include <stdio.h>
#define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME) #define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
#if defined(BACKEND_NAME) && !defined(STUBS) #if defined(BACKEND_NAME) && !defined(STUBS)
int PASTE(sanei_debug_,BACKEND_NAME); int DBG_LEVEL;
#endif #endif
# define DBG_INIT() \ # define DBG_INIT() \
sanei_init_debug (STRINGIFY(BACKEND_NAME), \ sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
&PASTE(sanei_debug_,BACKEND_NAME))
/* The cpp that comes with GNU C 2.5 seems to have troubles understanding /* The cpp that comes with GNU C 2.5 seems to have troubles understanding
vararg macros. */ vararg macros. */
#ifdef HAVE_VARARG_MACROS #ifdef HAVE_VARARG_MACROS
# define DBG(level, msg, args...) \ extern void sanei_debug_max (int level, int max_level, const char *msg, ...);
do { \
if (DBG_LEVEL >= (level)){ \ # define DBG(level, msg, args...) \
fprintf (stderr, "[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \ do { \
fflush(stderr); \ sanei_debug_max ( level, DBG_LEVEL, \
} \ "[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \
} while (0) } while (0)
extern void sanei_init_debug (const char * backend, int * debug_level_var); extern void sanei_init_debug (const char * backend, int * debug_level_var);
#else #else
# define DBG sanei_debug # define DBG sanei_debug
#endif #endif /* HAVE_VARARG_MACROS */
# define IF_DBG(x) x # define IF_DBG(x) x
#endif #endif /* NDEBUG */
#endif /* _SANEI_DEBUG_H */