diff options
Diffstat (limited to 'src/openvpn/error.h')
-rw-r--r-- | src/openvpn/error.h | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/openvpn/error.h b/src/openvpn/error.h index 4024e5e..f43bc38 100644 --- a/src/openvpn/error.h +++ b/src/openvpn/error.h @@ -27,6 +27,11 @@ #include "basic.h" +#include <errno.h> +#include <stdbool.h> + +#include <assert.h> + /* #define ABORT_ON_ERROR */ #ifdef ENABLE_PKCS11 @@ -66,7 +71,7 @@ struct gc_arena; /* String and Error functions */ -#ifdef WIN32 +#ifdef _WIN32 # define openvpn_errno() GetLastError() # define openvpn_strerror(e, gc) strerror_win32(e, gc) const char *strerror_win32 (DWORD errnum, struct gc_arena *gc); @@ -138,12 +143,6 @@ extern int x_msg_line_num; /** Check muting filter */ bool dont_mute (unsigned int flags); -/** Return true if flags represent an enabled, not muted log level */ -static inline bool msg_test (unsigned int flags) -{ - return ((flags & M_DEBUG_LEVEL) <= x_debug_level) && dont_mute (flags); -} - /* Macro to ensure (and teach static analysis tools) we exit on fatal errors */ #define EXIT_FATAL(flags) do { if ((flags) & M_FATAL) _exit(1); } while (false) @@ -197,6 +196,8 @@ void error_reset (void); void errors_to_stderr (void); void set_suppress_timestamps (bool suppressed); +void set_machine_readable_output (bool parsable); + #define SDL_CONSTRAIN (1<<0) bool set_debug_level (const int level, const unsigned int flags); @@ -223,6 +224,14 @@ FILE *msg_fp(const unsigned int flags); void assert_failed (const char *filename, int line, const char *condition) __attribute__((__noreturn__)); +/* Poor-man's static_assert() for when not supplied by assert.h, taken from + * Linux's sys/cdefs.h under GPLv2 */ +#ifndef static_assert +#define static_assert(expr, diagnostic) \ + extern int (*__OpenVPN_static_assert_function (void)) \ + [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] +#endif + #ifdef ENABLE_DEBUG void crash (void); /* force a segfault (debugging only) */ #endif @@ -235,6 +244,12 @@ check_debug_level (unsigned int level) return (level & M_DEBUG_LEVEL) <= x_debug_level; } +/** Return true if flags represent an enabled, not muted log level */ +static inline bool msg_test (unsigned int flags) +{ + return check_debug_level (flags) && dont_mute (flags); +} + /* Call if we forked */ void msg_forked (void); @@ -246,7 +261,7 @@ void close_syslog (); /* log file output */ void redirect_stdout_stderr (const char *file, bool append); -#ifdef WIN32 +#ifdef _WIN32 /* get original stderr handle, even if redirected by --log/--log-append */ HANDLE get_orig_stderr (void); #endif @@ -341,7 +356,7 @@ static inline bool ignore_sys_error (const int err) { /* I/O operation pending */ -#ifdef WIN32 +#ifdef _WIN32 if (err == WSAEWOULDBLOCK || err == WSAEINVAL) return true; #else |