summaryrefslogtreecommitdiff
path: root/usr/src/cmd/sendmail/libsm/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/cmd/sendmail/libsm/debug.c')
-rw-r--r--usr/src/cmd/sendmail/libsm/debug.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/usr/src/cmd/sendmail/libsm/debug.c b/usr/src/cmd/sendmail/libsm/debug.c
index 1bc7e3ad2d..ea9cd846ac 100644
--- a/usr/src/cmd/sendmail/libsm/debug.c
+++ b/usr/src/cmd/sendmail/libsm/debug.c
@@ -7,10 +7,8 @@
* the sendmail distribution.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#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
@@ -19,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>
@@ -114,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, ...)
@@ -127,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);