[dovecot-cvs] dovecot/src/lib failures.c,1.4,1.5
cras at procontrol.fi
cras at procontrol.fi
Sun Dec 1 17:37:21 EET 2002
Update of /home/cvs/dovecot/src/lib
In directory danu:/tmp/cvs-serv24786
Modified Files:
failures.c
Log Message:
Changed so that we can use the functions before calling failures_init().
Index: failures.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib/failures.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- failures.c 4 Nov 2002 05:33:48 -0000 1.4
+++ failures.c 1 Dec 2002 15:37:19 -0000 1.5
@@ -32,22 +32,31 @@
#include <syslog.h>
#include <time.h>
-static FailureFunc panic_handler __attr_noreturn__, fatal_handler __attr_noreturn__;
-static FailureFunc error_handler, warning_handler;
-
-static FILE *log_fd;
-static char *log_prefix, *log_stamp_format;
-
static void default_panic_handler(const char *format, va_list args)
__attr_noreturn__;
static void default_fatal_handler(const char *format, va_list args)
__attr_noreturn__;
+static void default_error_handler(const char *format, va_list args);
+static void default_warning_handler(const char *format, va_list args);
+
+/* Initialize working defaults */
+static FailureFunc panic_handler __attr_noreturn__ = default_panic_handler;
+static FailureFunc fatal_handler __attr_noreturn__ = default_fatal_handler;
+static FailureFunc error_handler = default_error_handler;
+static FailureFunc warning_handler = default_warning_handler;
+
+static FILE *log_fd = NULL;
+static char *log_prefix = NULL, *log_stamp_format = NULL;
+
static void write_prefix(void)
{
struct tm *tm;
char str[256];
+ if (log_fd == NULL)
+ log_fd = stderr;
+
if (log_prefix != NULL)
fputs(log_prefix, log_fd);
@@ -222,19 +231,11 @@
void failures_init(void)
{
- log_fd = stderr;
- log_prefix = NULL;
- log_stamp_format = NULL;
-
- i_set_panic_handler(NULL);
- i_set_fatal_handler(NULL);
- i_set_error_handler(NULL);
- i_set_warning_handler(NULL);
}
void failures_deinit(void)
{
- if (log_fd != stderr) {
+ if (log_fd != NULL && log_fd != stderr) {
(void)fclose(log_fd);
log_fd = stderr;
}
More information about the dovecot-cvs
mailing list