SANEI 1.3.1.72-4c77c
sanei_debug.h File Reference

Support for printing debug messages. More...

Go to the source code of this file.

Public macros

These macros can be used in backends and other SANE-related code.

Before including sanei_debug.h, the following macros must be set:

  • BACKEND_NAME - The name of your backend without double-quotes (must be set in any case)
  • STUBS - If this is defined, no macros will be included. Used in backends consisting of more than one .c file.
  • DEBUG_DECLARE_ONLY - Generates prototypes instead of functions. Used in backends consisting of more than one .c file.
  • DEBUG_NOT_STATIC - Doesn't generate static functions. Used in header files if they are include in more than one .c file.
#define ENTRY(name)
 Expands to sane_BACKEND_NAME_name. More...
 
#define DBG_LEVEL
 Current debug level. More...
 
#define DBG_INIT()
 Initialize sanei_debug. More...
 
#define DBG_LOCAL
 Expands to sane_BACKEND_NAME_name. More...
 
#define DBG
 Print a message at debug level ‘level’ or higher using a printf-like function. More...
 
#define IF_DBG(x)
 Compile code only if debugging is enabled. More...
 
void sanei_debug_msg (int level, int max_level, const char *be, const char *fmt, va_list ap)
 Expands to sane_BACKEND_NAME_name. More...
 
void sanei_init_debug (const char *backend, int *debug_level_var)
 Expands to sane_BACKEND_NAME_name. More...
 

Detailed Description

Support for printing debug messages.

Use the functions of this header file to print debug or warning messages.

Macro Definition Documentation

◆ ENTRY

#define ENTRY (   name)

Expands to sane_BACKEND_NAME_name.

Example: ENTRY(init) in mustek.c will expand to sane_mustek_init.

◆ DBG_LEVEL

#define DBG_LEVEL

Current debug level.

You can only read this "variable".

◆ DBG_INIT

#define DBG_INIT ( )

Initialize sanei_debug.

Call this function before you use any DBG function.

◆ DBG_LOCAL

#define DBG_LOCAL

Expands to sane_BACKEND_NAME_name.

Example: ENTRY(init) in mustek.c will expand to sane_mustek_init.

◆ DBG

#define DBG

Print a message at debug level ‘level’ or higher using a printf-like function.

Example: DBG(1, "sane_open: opening fd \%d\\n", fd).

Parameters
leveldebug level
fmtformat (see man 3 printf for details)
...additional arguments

◆ IF_DBG

#define IF_DBG (   x)

Compile code only if debugging is enabled.

Expands to x if debug support is enabled at compile-time. If NDEBUG is defined at compile-time this macro expands to nothing.

Parameters
xcode to expand when debugging is enabled

Function Documentation

◆ sanei_debug_msg()

void sanei_debug_msg ( int  level,
int  max_level,
const char *  be,
const char *  fmt,
va_list  ap 
)

Expands to sane_BACKEND_NAME_name.

Example: ENTRY(init) in mustek.c will expand to sane_mustek_init.

◆ sanei_init_debug()

void sanei_init_debug ( const char *  backend,
int *  debug_level_var 
)

Expands to sane_BACKEND_NAME_name.

Example: ENTRY(init) in mustek.c will expand to sane_mustek_init.