head 1.5;
access;
symbols
LMTP2NNTP_0_9_4:1.3
LMTP2NNTP_0_9_3:1.3
LMTP2NNTP_0_9_2:1.3
LMTP2NNTP_0_9_1:1.2
LMTP2NNTP_0_9_0:1.2;
locks; strict;
comment @ * @;
1.5
date 2001.09.07.15.02.09; author thl; state dead;
branches;
next 1.4;
1.4
date 2001.09.04.09.46.06; author rse; state Exp;
branches;
next 1.3;
1.3
date 2001.08.23.09.12.30; author rse; state Exp;
branches;
next 1.2;
1.2
date 2001.08.20.11.28.30; author rse; state Exp;
branches;
next 1.1;
1.1
date 2001.08.14.08.15.26; author thl; state Exp;
branches;
next ;
desc
@@
1.5
log
@Replace ad-hoc tracing with L2_LEVEL_TRACE based approach.
@
text
@/*
** Copyright (c) 2001 The OSSP Project
** Copyright (c) 2001 Cable & Wireless Deutschland
**
** This file is part of OSSP lmtp2nntp, an LMTP speaking local
** mailer which forwards mails as Usenet news articles via NNTP.
** It can be found at http://www.ossp.org/pkg/lmtp2nntp/.
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version
** 2.0 of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this file; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
** USA, or contact the OSSP project .
**
** trace.c: I/O tracing support
*/
#include
#include
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#if defined(HAVE_DMALLOC_H) && defined(DMALLOC)
#include "dmalloc.h"
#endif
#include "trace.h"
#ifndef _POSIX_PATH_MAX
#if defined(PATH_MAX)
#define _POSIX_PATH_MAX PATH_MAX
#elif defined(MAX_PATH)
#define _POSIX_PATH_MAX MAX_PATH
#else
#error "unable to determime maximum path limit"
#endif
#endif
/*
* tracing
*/
ssize_t trace_read(int d, void *buf, size_t nbytes)
{
ssize_t rc;
int tf;
static char tfn[_POSIX_PATH_MAX] = "/tmp/trace";
if ((d == -1) && (buf != NULL) && (nbytes == 0)) {
strncpy(tfn, buf, _POSIX_PATH_MAX-1);
}
rc = read(d, buf, nbytes);
if ((tf = open(tfn, O_CREAT|O_WRONLY|O_APPEND, 0664)) != -1) {
write(tf, buf, rc);
close(tf);
}
return rc;
}
ssize_t trace_write(int d, const void *buf, size_t nbytes)
{
ssize_t rc;
int tf;
static char tfn[_POSIX_PATH_MAX] = "/tmp/trace";
if ((d == -1) && (buf != NULL) && (nbytes == 0)) {
strncpy(tfn, buf, _POSIX_PATH_MAX-1);
}
rc = write(d, buf, nbytes);
if ((tf = open(tfn, O_CREAT|O_WRONLY|O_APPEND, 0664)) != -1) {
write(tf, buf, rc);
close(tf);
}
return rc;
}
@
1.4
log
@Finally apply GNU General Public License (GPL) to OSSP lmtp2nntp.
@
text
@@
1.3
log
@Add DMalloc support
@
text
@d1 25
@
1.2
log
@Autoconf phase 4
@
text
@d5 7
@
1.1
log
@cleanup msg.[ch], moved tracing to trace.[ch], added target to Makefile, added -t switch in lmtp2nntp.[c|pod], incorporated tracing into lmtp.[ch] and nntp.[ch], run.sh now using new tracing option
@
text
@d2 3
d7 10
d25 1
a25 1
static char tfn[PATH_MAX] = "/tmp/trace";
d28 1
a28 1
strncpy(tfn, buf, PATH_MAX-1);
d42 1
a42 1
static char tfn[PATH_MAX] = "/tmp/trace";
d45 1
a45 1
strncpy(tfn, buf, PATH_MAX-1);
@