summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libsm/debug.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2010-01-26 04:41:15 +0000
committergshapiro <gshapiro@FreeBSD.org>2010-01-26 04:41:15 +0000
commit06af2946772550af5ad9eea974674de7bde4243b (patch)
tree6c6c3749a8b863bd3e7a5962fc9189f1a3e34f9c /contrib/sendmail/libsm/debug.c
parentc1aec8d8e06eaf4b4e5066794fecde82622b6366 (diff)
downloadFreeBSD-src-06af2946772550af5ad9eea974674de7bde4243b.zip
FreeBSD-src-06af2946772550af5ad9eea974674de7bde4243b.tar.gz
Merge sendmail 8.14.4 to HEAD
MFC after: 4 days
Diffstat (limited to 'contrib/sendmail/libsm/debug.c')
-rw-r--r--contrib/sendmail/libsm/debug.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/contrib/sendmail/libsm/debug.c b/contrib/sendmail/libsm/debug.c
index f9281fd..ea9cd84 100644
--- a/contrib/sendmail/libsm/debug.c
+++ b/contrib/sendmail/libsm/debug.c
@@ -8,7 +8,7 @@
*/
#include <sm/gen.h>
-SM_RCSID("@(#)$Id: debug.c,v 1.30 2004/08/03 20:10:26 ca Exp $")
+SM_RCSID("@(#)$Id: debug.c,v 1.32 2009/09/20 05:38:46 ca Exp $")
/*
** libsm debugging and tracing
@@ -17,6 +17,10 @@ SM_RCSID("@(#)$Id: debug.c,v 1.30 2004/08/03 20:10:26 ca Exp $")
#include <ctype.h>
#include <stdlib.h>
+#if _FFR_DEBUG_PID_TIME
+#include <unistd.h>
+#include <time.h>
+#endif /* _FFR_DEBUG_PID_TIME */
#include <setjmp.h>
#include <sm/io.h>
#include <sm/assert.h>
@@ -112,6 +116,11 @@ sm_debug_close()
** none.
*/
+#if _FFR_DEBUG_PID_TIME
+SM_DEBUG_T SmDBGPidTime = SM_DEBUG_INITIALIZER("sm_trace_pid_time",
+ "@(#)$Debug: sm_trace_pid_time - print pid and time in debug $");
+#endif /* _FFR_DEBUG_PID_TIME */
+
void
#if SM_VA_STD
sm_dprintf(char *fmt, ...)
@@ -125,6 +134,26 @@ sm_dprintf(fmt, va_alist)
if (SmDebugOutput == NULL)
return;
+#if _FFR_DEBUG_PID_TIME
+ /* note: this is ugly if the output isn't a full line! */
+ if (sm_debug_active(&SmDBGPidTime, 1))
+ {
+ static char str[32] = "[1900-00-00/00:00:00] ";
+ struct tm *tmp;
+ time_t currt;
+
+ currt = time((time_t *)0);
+ tmp = localtime(&currt);
+ snprintf(str, sizeof(str), "[%d-%02d-%02d/%02d:%02d:%02d] ",
+ 1900 + tmp->tm_year, /* HACK */
+ tmp->tm_mon + 1,
+ tmp->tm_mday,
+ tmp->tm_hour, tmp->tm_min, tmp->tm_sec);
+ sm_io_fprintf(SmDebugOutput, SmDebugOutput->f_timeout,
+ "%ld: %s ", (long) getpid(), str);
+ }
+#endif /* _FFR_DEBUG_PID_TIME */
+
SM_VA_START(ap, fmt);
sm_io_vfprintf(SmDebugOutput, SmDebugOutput->f_timeout, fmt, ap);
SM_VA_END(ap);
OpenPOWER on IntegriCloud