From a9e57941fdcac133756bbfec56971730d54cbb54 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Fri, 31 Aug 2018 14:21:06 +0300 Subject: [PATCH] lib: Move failure handler structs and typedefs to failures-private.h Also change the function typedefs to be non-pointers, like they usually are in Dovecot code. --- src/lib/Makefile.am | 1 + src/lib/failures-private.h | 26 ++++++++++++++++++++++++++ src/lib/failures.c | 20 +------------------- 3 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 src/lib/failures-private.h diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 648d8dbbb8..36b51b2ffa 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -188,6 +188,7 @@ headers = \ event-log.h \ execv-const.h \ failures.h \ + failures-private.h \ fd-util.h \ fdatasync-path.h \ fdpass.h \ diff --git a/src/lib/failures-private.h b/src/lib/failures-private.h new file mode 100644 index 0000000000..864247c935 --- /dev/null +++ b/src/lib/failures-private.h @@ -0,0 +1,26 @@ +#ifndef FAILURES_PRIVATE_H +#define FAILURES_PRIVATE_H + +typedef int +failure_write_to_file_t(enum log_type type, string_t *data, size_t prefix_len); +typedef string_t * +failure_format_str_t(const struct failure_context *ctx, size_t *prefix_len_r, + const char *format, va_list args); +typedef void failure_on_handler_failure_t(const struct failure_context *ctx); +typedef void failure_post_handler_t(const struct failure_context *ctx); + +struct failure_handler_vfuncs { + failure_write_to_file_t *write; + failure_format_str_t *format; + failure_on_handler_failure_t *on_handler_failure; + failure_post_handler_t *post_handler; +}; + +struct failure_handler_config { + int fatal_err_reset; + struct failure_handler_vfuncs *v; +}; + +extern struct failure_handler_config failure_handler; + +#endif diff --git a/src/lib/failures.c b/src/lib/failures.c index ff90135cc3..03c6445245 100644 --- a/src/lib/failures.c +++ b/src/lib/failures.c @@ -10,6 +10,7 @@ #include "backtrace-string.h" #include "printf-format-fix.h" #include "write-full.h" +#include "failures-private.h" #include #include @@ -60,13 +61,6 @@ static void log_prefix_add(const struct failure_context *ctx, string_t *str); static void i_failure_send_option(const char *key, const char *value); static int internal_send_split(string_t *full_str, size_t prefix_len); -typedef int (*failure_write_to_file_t)(enum log_type type, string_t *data, size_t prefix_len); -typedef string_t *(*failure_format_str_t)(const struct failure_context *ctx, - size_t *prefix_len_r, const char *format, - va_list args); -typedef void (*failure_on_handler_failure_t)(const struct failure_context *ctx); -typedef void (*failure_post_handler_t)(const struct failure_context *ctx); - static string_t * ATTR_FORMAT(3, 0) default_format(const struct failure_context *ctx, size_t *prefix_len_r ATTR_UNUSED, const char *format, @@ -223,18 +217,6 @@ static void internal_post_handler(const struct failure_context *ctx ATTR_UNUSED) { } -struct failure_handler_vfuncs { - failure_write_to_file_t write; - failure_format_str_t format; - failure_on_handler_failure_t on_handler_failure; - failure_post_handler_t post_handler; -}; - -struct failure_handler_config { - int fatal_err_reset; - struct failure_handler_vfuncs *v; -}; - static struct failure_handler_vfuncs default_handler_vfuncs = { .write = &default_write, .format = &default_format, -- 2.47.3