changeset 7041:cc70ab74f4f3 HEAD

Make failure_log_type_prefixes[] and failure_exit() public.
author Timo Sirainen <tss@iki.fi>
date Thu, 27 Dec 2007 22:51:28 +0200
parents 5e0f115665bf
children dcbf6afdf931
files src/lib/failures.c src/lib/failures.h
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/failures.c	Sun Dec 23 16:31:54 2007 +0200
+++ b/src/lib/failures.c	Thu Dec 27 22:51:28 2007 +0200
@@ -14,7 +14,7 @@
 #include <syslog.h>
 #include <time.h>
 
-static const char *log_type_prefixes[] = {
+const char *failure_log_type_prefixes[] = {
 	"Info: ",
 	"Warning: ",
 	"Error: ",
@@ -25,8 +25,6 @@
 	'I', 'W', 'E', 'F', 'P'
 };
 
-static void failure_exit(int status) ATTR_NORETURN;
-
 static void default_fatal_handler(enum log_type type, int status,
 				  const char *format, va_list args)
 	ATTR_NORETURN ATTR_FORMAT(3, 0);
@@ -52,7 +50,7 @@
 	return log_stamp_format;
 }
 
-static void failure_exit(int status)
+void failure_exit(int status)
 {
 	if (failure_exit_callback != NULL)
 		failure_exit_callback(&status);
@@ -152,7 +150,7 @@
 {
 	const char *backtrace;
 
-	if (default_handler(log_type_prefixes[type], log_fd, format,
+	if (default_handler(failure_log_type_prefixes[type], log_fd, format,
 			    args) < 0 && status == FATAL_DEFAULT)
 		status = FATAL_LOGWRITE;
 
@@ -172,7 +170,8 @@
 {
 	int fd = type == LOG_TYPE_INFO ? log_info_fd : log_fd;
 
-	if (default_handler(log_type_prefixes[type], fd, format, args) < 0)
+	if (default_handler(failure_log_type_prefixes[type],
+			    fd, format, args) < 0)
 		failure_exit(FATAL_LOGWRITE);
 }
 
--- a/src/lib/failures.h	Sun Dec 23 16:31:54 2007 +0200
+++ b/src/lib/failures.h	Thu Dec 27 22:51:28 2007 +0200
@@ -26,6 +26,8 @@
 typedef void fatal_failure_callback_t(enum log_type type, int status,
 				      const char *, va_list);
 
+extern const char *failure_log_type_prefixes[];
+
 void i_log_type(enum log_type type, const char *format, ...) ATTR_FORMAT(2, 3);
 
 void i_panic(const char *format, ...) ATTR_FORMAT(1, 2) ATTR_NORETURN;
@@ -75,6 +77,8 @@
 
 /* Call the callback before exit()ing. The callback may update the status. */
 void i_set_failure_exit_callback(void (*callback)(int *status));
+/* Call the exit callback and exit() */
+void failure_exit(int status) ATTR_NORETURN;
 
 void failures_deinit(void);