kopia lustrzana https://gitlab.com/sane-project/backends
2000-10-23 Jochen Eisinger <jochen.eisinger@gmx.net>
* sanei/sanei_init_debug.c include/sane/sanei_debug.h frontend/saned.c: removed vararg macrosDEVEL_2_0_BRANCH-1
rodzic
c6694e75ba
commit
b1e5ed14f9
|
@ -3,55 +3,91 @@
|
|||
|
||||
#include <sane/sanei.h>
|
||||
|
||||
/* this header file defines:
|
||||
*
|
||||
* DBG_INIT() - should be called before any other debug function
|
||||
* DBG(level, fmt, ...) - prints a message at debug level `level' or higher
|
||||
* using a printf-like function
|
||||
* IF_DBG(x) - expands to x if debug support is enabled at
|
||||
* compile-time, if NDEBUG is defined at compile-time
|
||||
* this macro expands to nothing
|
||||
*
|
||||
* ENTRY(name) - expands to sane_BACKEND_NAME_name
|
||||
*
|
||||
* before you include sanei_debug.h, you'll have to define
|
||||
*
|
||||
* BACKEND_NAME - the name of your backend without double-quotes
|
||||
* STUBS - if this is defined, nothing will happen
|
||||
* DEBUG_DECLARE_ONLY - generate prototypes instead of functions
|
||||
* DEBUG_NOT_STATIC - doesn't generate static functions
|
||||
*
|
||||
*/
|
||||
|
||||
#define ENTRY(name) PASTE(PASTE(PASTE(sane_,BACKEND_NAME),_),name)
|
||||
|
||||
/* 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
|
||||
|
||||
extern void sanei_debug (int level, const char *msg, ...);
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define DBG_LEVEL (0)
|
||||
|
||||
extern void sanei_debug_ndebug (int level, const char *msg, ...);
|
||||
|
||||
# define DBG_LEVEL (0)
|
||||
# define DBG_INIT()
|
||||
# ifdef HAVE_VARARG_MACROS
|
||||
# define DBG(level, msg, args...)
|
||||
# else
|
||||
# define DBG if (0) sanei_debug
|
||||
# endif
|
||||
# define IF_DBG(x)
|
||||
#else
|
||||
# include <stdio.h>
|
||||
# define DBG sanei_debug_ndebug
|
||||
# define IF_DBG(x)
|
||||
|
||||
#else /* !NDEBUG */
|
||||
|
||||
# define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
|
||||
|
||||
#define DBG_LEVEL PASTE(sanei_debug_,BACKEND_NAME)
|
||||
|
||||
#if defined(BACKEND_NAME) && !defined(STUBS)
|
||||
int DBG_LEVEL;
|
||||
#endif
|
||||
# if defined(BACKEND_NAME) && !defined(STUBS)
|
||||
# ifdef DEBUG_DECLARE_ONLY
|
||||
extern int DBG_LEVEL;
|
||||
# else /* !DEBUG_DECLARE_ONLY */
|
||||
int DBG_LEVEL = 0;
|
||||
# endif /* DEBUG_DECLARE_ONLY */
|
||||
# endif /* BACKEND_NAME && !STUBS */
|
||||
|
||||
# define DBG_INIT() \
|
||||
sanei_init_debug (STRINGIFY(BACKEND_NAME), &DBG_LEVEL)
|
||||
|
||||
/* The cpp that comes with GNU C 2.5 seems to have troubles understanding
|
||||
vararg macros. */
|
||||
#ifdef HAVE_VARARG_MACROS
|
||||
extern void sanei_debug_max (int level, int max_level, const char *msg, ...);
|
||||
# define DBG_LOCAL PASTE(DBG_LEVEL,_call)
|
||||
|
||||
# define DBG(level, msg, args...) \
|
||||
do { \
|
||||
sanei_debug_max ( level, DBG_LEVEL, \
|
||||
"[" STRINGIFY(BACKEND_NAME) "] " msg, ##args); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
# define DBG sanei_debug
|
||||
#endif /* HAVE_VARARG_MACROS */
|
||||
# ifndef STUBS
|
||||
|
||||
# ifdef DEBUG_DECLARE_ONLY
|
||||
|
||||
extern void DBG_LOCAL (int level, const char *msg, ...);
|
||||
|
||||
# else /* !DEBUG_DECLARE_ONLY */
|
||||
|
||||
# include <stdarg.h>
|
||||
|
||||
extern void sanei_debug_msg
|
||||
(int level, int max_level, const char *be, const char *fmt, va_list ap);
|
||||
|
||||
# ifndef DEBUG_NOT_STATIC
|
||||
static
|
||||
# endif /* !DEBUG_NOT_STATIC */
|
||||
void
|
||||
DBG_LOCAL (int level, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, msg);
|
||||
sanei_debug_msg (level, DBG_LEVEL, STRINGIFY(BACKEND_NAME), msg, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
|
||||
# endif /* DEBUG_NOT_STATIC */
|
||||
|
||||
# endif /* !STUBS */
|
||||
|
||||
# define DBG DBG_LOCAL
|
||||
|
||||
extern void sanei_init_debug (const char * backend, int * debug_level_var);
|
||||
|
||||
# define IF_DBG(x) x
|
||||
|
||||
#endif /* NDEBUG */
|
||||
|
||||
#endif /* _SANEI_DEBUG_H */
|
||||
|
|
Ładowanie…
Reference in New Issue