rawlog.c revision 7013075e208bc7aa87257df7d9664c84c7c220f3
/* Copyright (C) 2002 Timo Sirainen */
#include "lib.h"
#include "rawlog.h"
#ifdef BUILD_RAWLOG
#include "ioloop.h"
#include "network.h"
#include "write-full.h"
#include "process-title.h"
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#define TIMESTAMP_WAIT_TIME 5
#define TIMESTAMP_FORMAT " * OK [RAWLOG TIMESTAMP] %Y-%m-%d %H:%M:%S\n"
static time_t last_write = 0;
{
char buf[1024];
i_fatal("strftime() failed");
i_fatal("Can't write to log file: %m");
}
do {
} while (r_ret == 0);
if (r_ret < 0) {
if (r_ret == -1)
i_error("imap_in: net_receive() failed: %m");
/* disconnected */
return;
}
i_fatal("Can't write to log file: %m");
do {
if (s_ret < 0) {
if (s_ret == -1)
i_error("imap_in: net_transmit() failed: %m");
/* disconnected */
return;
}
} while (r_ret > 0);
}
{
}
{
}
{
char timestamp[50];
int sfd[2];
home = ".";
/* see if we want rawlog */
return;
}
/* yes, open the files. Do it before forking to make sure we don't
unneededly do it. */
i_fatal("strftime() failed");
if (log_in == -1) {
return;
}
if (log_out == -1) {
return;
}
/* we need to fork the rawlog writer to separate process since
imap process does blocking writes. */
i_fatal("socketpair() failed: %m");
parent_pid = getpid();
if (pid < 0)
i_fatal("fork() failed: %m");
if (pid > 0) {
/* parent */
return;
}
dec2str(parent_pid)));
/* child */
client_out = *hout;
lib_deinit();
exit(0);
}
#else
{
}
#endif