failures.c revision 7c424aa51c956c628e3512055841aa2f9eef4833
/*
failures.c : Failure manager
Copyright (c) 2001-2002 Timo Sirainen
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "lib.h"
#include "ioloop.h"
#include "fd-close-on-exec.h"
#include "printf-upper-bound.h"
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <time.h>
/* Initialize working defaults */
/* kludgy .. we want to trust log_stamp_format with -Wformat-nonliteral */
static const char *get_log_stamp_format(const char *unused)
{
return log_stamp_format;
}
static void write_prefix(FILE *f)
{
char str[256];
if (log_prefix != NULL)
fputs(log_prefix, f);
if (log_stamp_format != NULL) {
}
}
{
static int recursed = 0;
if (recursed == 2) {
/* we're being called from some signal handler, or
printf_string_upper_bound() killed us again */
return -1;
}
recursed++;
if (f == NULL) {
f = stderr;
}
t_push();
if (recursed == 2) {
/* write without fixing format, that probably killed us
last time. */
/* make sure there's no %n in there */
fputs(" - recursed!", f);
} else {
write_prefix(f);
/* make sure there's no %n in there */
}
fputc('\n', f);
t_pop();
recursed--;
return 0;
}
{
abort();
}
{
status == FATAL_DEFAULT)
}
{
}
{
}
{
if (fflush(log_info_fd) < 0)
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
}
{
static int recursed = 0;
if (recursed != 0)
return -1;
recursed++;
/* make sure there's no %n in there */
recursed--;
return 0;
}
{
abort();
}
{
}
{
}
{
}
{
}
{
}
{
else {
"Can't open log file %s: %m", path);
}
}
}
{
(void)fclose(log_info_fd);
}
void i_set_info_file(const char *path)
{
if (log_info_fd == log_fd)
log_info_fd = NULL;
}
void i_set_failure_timestamp_format(const char *fmt)
{
}
void failures_deinit(void)
{
if (log_info_fd == log_fd)
log_info_fd = NULL;
}
(void)fclose(log_info_fd);
}
}