2000-08-12 15:11:00 +00:00
|
|
|
#ifndef _SANEI_DEBUG_H
|
|
|
|
#define _SANEI_DEBUG_H
|
|
|
|
|
1999-08-09 18:05:43 +00:00
|
|
|
#include <sane/sanei.h>
|
|
|
|
|
2000-08-12 15:11:00 +00:00
|
|
|
#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
|
1999-08-09 18:05:43 +00:00
|
|
|
|
|
|
|
/* The cpp that comes with GNU C 2.5 seems to have troubles understanding
|
|
|
|
vararg macros. */
|
|
|
|
#if __GNUC__ - 0 > 2 || (__GNUC__ - 0 == 2 && __GNUC_MINOR__ > 5)
|
|
|
|
# define HAVE_VARARG_MACROS
|
|
|
|
#endif
|
|
|
|
|
2000-08-12 15:11:00 +00:00
|
|
|
extern void sanei_debug (int level, const char *msg, ...);
|
1999-08-09 18:05:43 +00:00
|
|
|
|
|
|
|
#ifdef NDEBUG
|
2000-08-12 15:11:00 +00:00
|
|
|
# define DBG_LEVEL (0)
|
|
|
|
# define DBG_INIT()
|
1999-08-09 18:05:43 +00:00
|
|
|
# ifdef HAVE_VARARG_MACROS
|
|
|
|
# define DBG(level, msg, args...)
|
|
|
|
# else
|
2000-08-12 15:11:00 +00:00
|
|
|
# define DBG if (0) sanei_debug
|
1999-08-09 18:05:43 +00:00
|
|
|
# endif
|
|
|
|
# define IF_DBG(x)
|
|
|
|
#else
|
|
|
|
# include <stdio.h>
|
|
|
|
|
2000-08-12 15:11:00 +00:00
|
|
|
#define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
|
1999-08-09 18:05:43 +00:00
|
|
|
|
|
|
|
#if defined(BACKEND_NAME) && !defined(STUBS)
|
2000-08-12 15:11:00 +00:00
|
|
|
int DBG_LEVEL;
|
1999-08-09 18:05:43 +00:00
|
|
|
#endif
|
|
|
|
|
2000-08-12 15:11:00 +00:00
|
|
|
# define DBG_INIT() \
|
|
|
|
sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
|
1999-08-09 18:05:43 +00:00
|
|
|
|
|
|
|
/* The cpp that comes with GNU C 2.5 seems to have troubles understanding
|
|
|
|
vararg macros. */
|
|
|
|
#ifdef HAVE_VARARG_MACROS
|
2000-08-12 15:11:00 +00:00
|
|
|
extern void sanei_debug_max (int level, int max_level, const char *msg, ...);
|
|
|
|
|
|
|
|
# define DBG(level, msg, args...) \
|
|
|
|
do { \
|
|
|
|
sanei_debug_max ( level, DBG_LEVEL, \
|
|
|
|
"[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \
|
1999-08-09 18:05:43 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
extern void sanei_init_debug (const char * backend, int * debug_level_var);
|
|
|
|
#else
|
2000-08-12 15:11:00 +00:00
|
|
|
# define DBG sanei_debug
|
|
|
|
#endif /* HAVE_VARARG_MACROS */
|
1999-08-09 18:05:43 +00:00
|
|
|
|
2000-08-12 15:11:00 +00:00
|
|
|
# define IF_DBG(x) x
|
|
|
|
#endif /* NDEBUG */
|
|
|
|
|
|
|
|
#endif /* _SANEI_DEBUG_H */
|