OpenVPN
Macros | Functions | Variables
error.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
Include dependency graph for error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define M_DEBUG_LEVEL   (0x0F) /* debug level mask */
 
#define M_FATAL   (1<<4) /* exit program */
 
#define M_NONFATAL   (1<<5) /* non-fatal error */
 
#define M_WARN   (1<<6) /* call syslog with LOG_WARNING */
 
#define M_DEBUG   (1<<7)
 
#define M_ERRNO   (1<<8) /* show errno description */
 
#define M_NOMUTE   (1<<11) /* don't do mute processing */
 
#define M_NOPREFIX   (1<<12) /* don't show date/time prefix */
 
#define M_USAGE_SMALL   (1<<13) /* fatal options error, call usage_small */
 
#define M_MSG_VIRT_OUT   (1<<14) /* output message through msg_status_output callback */
 
#define M_OPTERR   (1<<15) /* print "Options error:" prefix */
 
#define M_NOLF   (1<<16) /* don't print new line */
 
#define M_NOIPREFIX   (1<<17) /* don't print instance prefix */
 
#define M_ERR   (M_FATAL | M_ERRNO)
 
#define M_USAGE   (M_USAGE_SMALL | M_NOPREFIX | M_OPTERR)
 
#define M_CLIENT   (M_MSG_VIRT_OUT | M_NOMUTE | M_NOIPREFIX)
 
#define EXIT_FATAL(flags)   do { if ((flags) & M_FATAL) {_exit(1);}} while (false)
 
#define HAVE_VARARG_MACROS
 
#define msg(flags, ...)   do { if (msg_test(flags)) {x_msg((flags), __VA_ARGS__);} EXIT_FATAL(flags); } while (false)
 
#define dmsg(flags, ...)
 

Functions

bool dont_mute (unsigned int flags)
 Check muting filter. More...
 
void x_msg (const unsigned int flags, const char *format,...)
 
void x_msg_va (const unsigned int flags, const char *format, va_list arglist)
 
static bool check_debug_level (unsigned int level)
 
static bool msg_test (unsigned int flags)
 Return true if flags represent and enabled, not muted log level. More...
 

Variables

unsigned int x_debug_level
 
int x_msg_line_num
 

Macro Definition Documentation

◆ dmsg

#define dmsg (   flags,
  ... 
)

Definition at line 74 of file error.h.

◆ EXIT_FATAL

#define EXIT_FATAL (   flags)    do { if ((flags) & M_FATAL) {_exit(1);}} while (false)

Definition at line 67 of file error.h.

◆ HAVE_VARARG_MACROS

#define HAVE_VARARG_MACROS

Definition at line 69 of file error.h.

◆ M_CLIENT

#define M_CLIENT   (M_MSG_VIRT_OUT | M_NOMUTE | M_NOIPREFIX)

Definition at line 57 of file error.h.

◆ M_DEBUG

#define M_DEBUG   (1<<7)

Definition at line 42 of file error.h.

◆ M_DEBUG_LEVEL

#define M_DEBUG_LEVEL   (0x0F) /* debug level mask */

Definition at line 37 of file error.h.

Referenced by check_debug_level().

◆ M_ERR

#define M_ERR   (M_FATAL | M_ERRNO)

Definition at line 55 of file error.h.

◆ M_ERRNO

#define M_ERRNO   (1<<8) /* show errno description */

Definition at line 44 of file error.h.

◆ M_FATAL

#define M_FATAL   (1<<4) /* exit program */

Definition at line 39 of file error.h.

◆ M_MSG_VIRT_OUT

#define M_MSG_VIRT_OUT   (1<<14) /* output message through msg_status_output callback */

Definition at line 49 of file error.h.

◆ M_NOIPREFIX

#define M_NOIPREFIX   (1<<17) /* don't print instance prefix */

Definition at line 52 of file error.h.

◆ M_NOLF

#define M_NOLF   (1<<16) /* don't print new line */

Definition at line 51 of file error.h.

◆ M_NOMUTE

#define M_NOMUTE   (1<<11) /* don't do mute processing */

Definition at line 46 of file error.h.

◆ M_NONFATAL

#define M_NONFATAL   (1<<5) /* non-fatal error */

Definition at line 40 of file error.h.

◆ M_NOPREFIX

#define M_NOPREFIX   (1<<12) /* don't show date/time prefix */

Definition at line 47 of file error.h.

◆ M_OPTERR

#define M_OPTERR   (1<<15) /* print "Options error:" prefix */

Definition at line 50 of file error.h.

◆ M_USAGE

#define M_USAGE   (M_USAGE_SMALL | M_NOPREFIX | M_OPTERR)

Definition at line 56 of file error.h.

◆ M_USAGE_SMALL

#define M_USAGE_SMALL   (1<<13) /* fatal options error, call usage_small */

Definition at line 48 of file error.h.

◆ M_WARN

#define M_WARN   (1<<6) /* call syslog with LOG_WARNING */

Definition at line 41 of file error.h.

◆ msg

#define msg (   flags,
  ... 
)    do { if (msg_test(flags)) {x_msg((flags), __VA_ARGS__);} EXIT_FATAL(flags); } while (false)

Definition at line 70 of file error.h.

Function Documentation

◆ check_debug_level()

static bool check_debug_level ( unsigned int  level)
inlinestatic

Definition at line 84 of file error.h.

References M_DEBUG_LEVEL, and x_debug_level.

Referenced by msg_test().

◆ dont_mute()

bool dont_mute ( unsigned int  flags)

Check muting filter.

Definition at line 400 of file error.c.

References DECODE_MUTE_LEVEL, M_INFO, M_NOMUTE, msg, mute_category, mute_count, and mute_cutoff.

Referenced by x_msg_va().

◆ msg_test()

static bool msg_test ( unsigned int  flags)
inlinestatic

Return true if flags represent and enabled, not muted log level.

Definition at line 91 of file error.h.

References check_debug_level(), and dont_mute().

◆ x_msg()

void x_msg ( const unsigned int  flags,
const char *  format,
  ... 
)

Definition at line 215 of file error.c.

References x_msg_va().

◆ x_msg_va()

void x_msg_va ( const unsigned int  flags,
const char *  format,
va_list  arglist 
)

Variable Documentation

◆ x_debug_level

unsigned int x_debug_level

Definition at line 54 of file error.c.

Referenced by error_reset(), get_debug_level(), mock_set_debug_level(), and set_debug_level().

◆ x_msg_line_num

int x_msg_line_num

Definition at line 212 of file error.c.

Referenced by x_msg_va().