X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/cca89d7ce589d10a226c6dfa212e36cbcad25fd2..477b12ff719d3749b8d8f85035bd6384fee9be0d:/lib/log.h diff --git a/lib/log.h b/lib/log.h index bacccb3..d1445cf 100644 --- a/lib/log.h +++ b/lib/log.h @@ -28,12 +28,41 @@ struct log_output; void set_progname(char **argv); -void elog(int pri, int errno_value, const char *fmt, va_list ap); +/** @brief Possible error number spaces */ +enum error_class { + /** @brief Invalid number space */ + ec_none, + /** @brief @c errno number space */ + ec_errno, + + /** @brief Windows GetLastError/WSAGetLastError return value */ + ec_windows, + + /** @brief getaddrinfo() return value */ + ec_getaddrinfo, +}; + +#if _WIN32 +# define ec_native ec_windows +# define ec_socket ec_windows +#else +# define ec_native ec_errno +# define ec_socket ec_errno +#endif + +void elog(int pri, enum error_class, int errno_value, const char *fmt, va_list ap); + +declspec(noreturn) void disorder_fatal(int errno_value, const char *msg, ...) attribute((noreturn)) attribute((format (printf, 2, 3))); +declspec(noreturn) +void disorder_fatal_ec(enum error_class ec, int errno_value, const char *msg, ...) attribute((noreturn)) + attribute((format (printf, 3, 4))); void disorder_error(int errno_value, const char *msg, ...) attribute((format (printf, 2, 3))); +void disorder_error_ec(enum error_class ec, int errno_value, const char *msg, ...) + attribute((format (printf, 3, 4))); void disorder_info(const char *msg, ...) attribute((format (printf, 1, 2))); void disorder_debug(const char *msg, ...) @@ -41,6 +70,8 @@ void disorder_debug(const char *msg, ...) /* report a message of the given class. @errno_value@ if present an * non-zero is included. @fatal@ terminates the process. */ +const char *format_error(enum error_class ec, int err, char buffer[], size_t bufsize); + extern int debugging; /* set when debugging enabled */