failures.h revision 6a058aa8c986a8fbec5ddd72c141db9df0b64b2d
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainen/* Default exit status codes that we could use. */
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainen FATAL_LOGWRITE = 81, /* Can't write to log file */
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainen FATAL_LOGERROR = 82, /* Internal logging error */
311d3dd2078c1b711a0cef013ba43a94078c115cTimo Sirainen#define DEFAULT_FAILURE_STAMP_FORMAT "%b %d %H:%M:%S "
311d3dd2078c1b711a0cef013ba43a94078c115cTimo Sirainentypedef void failure_callback_t(const char *, va_list);
311d3dd2078c1b711a0cef013ba43a94078c115cTimo Sirainentypedef void fatal_failure_callback_t(int status, const char *, va_list);
311d3dd2078c1b711a0cef013ba43a94078c115cTimo Sirainenvoid i_panic(const char *format, ...) __attr_format__(1, 2) __attr_noreturn__;
311d3dd2078c1b711a0cef013ba43a94078c115cTimo Sirainenvoid i_fatal(const char *format, ...) __attr_format__(1, 2) __attr_noreturn__;
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_error(const char *format, ...) __attr_format__(1, 2);
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_warning(const char *format, ...) __attr_format__(1, 2);
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_info(const char *format, ...) __attr_format__(1, 2);
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainenvoid i_fatal_status(int status, const char *format, ...)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainen/* Change failure handlers. Make sure they don't modify errno. */
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_panic_handler(failure_callback_t *callback __attr_noreturn__);
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_fatal_handler(fatal_failure_callback_t *callback __attr_noreturn__);
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_error_handler(failure_callback_t *callback);
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_warning_handler(failure_callback_t *callback);
e563b8a1457be8c08cc7567043c9f06b8243a025Timo Sirainenvoid i_set_info_handler(failure_callback_t *callback);
e563b8a1457be8c08cc7567043c9f06b8243a025Timo Sirainen/* Send failures to syslog() */
e563b8a1457be8c08cc7567043c9f06b8243a025Timo Sirainenvoid i_syslog_panic_handler(const char *fmt, va_list args)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_syslog_fatal_handler(int status, const char *fmt, va_list args)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_syslog_error_handler(const char *fmt, va_list args)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_syslog_warning_handler(const char *fmt, va_list args)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_syslog_info_handler(const char *fmt, va_list args)
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainen/* Open syslog and set failure/info handlers to use it. */
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_failure_syslog(const char *ident, int options, int facility);
539977f9257bd8985be5a8093658da266ae9cd19Timo Sirainen/* Send failures to specified log file instead of stderr. */
f46fce070a135ec6bb3078c104f32651ea84cdefTimo Sirainenvoid i_set_failure_file(const char *path, const char *prefix);
void i_set_failure_internal(void);
void failures_deinit(void);