1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
/* DSTART */
/* */
/* maildrop - mail delivery agent with filtering abilities */
/* */
/* Copyright 1998, Double Precision Inc. */
/* */
/* This program is distributed under the terms of the GNU General Public */
/* License. See COPYING for additional information. */
/* DEND */
#include "log.h"
#include "mio.h"
#include "formatmbox.h"
#include "config.h"
#include "maildrop.h"
#include "mytime.h"
static const char rcsid[]="$Id: log.C 1.1 1998/04/16 23:53:22 mrsam Exp $";
#if CRLF_TERM
#define EOL "\r\n"
#else
#define EOL "\n"
#endif
void log(const char *mailbox, int status, class FormatMbox &msg)
{
time_t t;
Buffer tbuf;
Buffer szbuf;
if (maildrop.logfile.fd() < 0) return; // Logfile not open
time(&t);
tbuf=ctime(&t);
tbuf.pop(); // Drop trailing newline
msg.hdrfrom.Length(72);
msg.hdrsubject.Length(72);
maildrop.logfile << "Date: " << tbuf << EOL;
maildrop.logfile << "From: " << msg.hdrfrom << EOL;
maildrop.logfile << "Subj: " << msg.hdrsubject << EOL;
szbuf="(";
szbuf.append( (unsigned long)msg.msgsize);
szbuf += ")";
tbuf=mailbox;
int l= 72 - szbuf.Length();
while (tbuf.Length() < l-1)
tbuf.push(' ');
tbuf.Length(l-1);
tbuf.push(' ');
tbuf += szbuf;
maildrop.logfile << (status ? "!Err: ":"File: ") << tbuf << EOL << EOL;
maildrop.logfile.flush();
}
void log_line(const class Buffer &buf)
{
if (maildrop.logfile.fd() < 0) return; // Logfile not open
maildrop.logfile << buf;
maildrop.logfile.flush();
}
|