debug.c (7c478bd95313f5f23a4c958a745db2134aa03244) | debug.c (e9af4bc0b1cc30cea75d6ad4aa2fde97d985e9be) |
---|---|
1/* 2 * Copyright (c) 2000, 2001, 2003, 2004 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 | 1/* 2 * Copyright (c) 2000, 2001, 2003, 2004 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 |
10#pragma ident "%Z%%M% %I% %E% SMI" 11 | |
12#include <sm/gen.h> | 10#include <sm/gen.h> |
13SM_RCSID("@(#)$Id: debug.c,v 1.30 2004/08/03 20:10:26 ca Exp $") | 11SM_RCSID("@(#)$Id: debug.c,v 1.32 2009/09/20 05:38:46 ca Exp $") |
14 15/* 16** libsm debugging and tracing 17** For documentation, see debug.html. 18*/ 19 20#include <ctype.h> 21#include <stdlib.h> | 12 13/* 14** libsm debugging and tracing 15** For documentation, see debug.html. 16*/ 17 18#include <ctype.h> 19#include <stdlib.h> |
20#if _FFR_DEBUG_PID_TIME 21#include <unistd.h> 22#include <time.h> 23#endif /* _FFR_DEBUG_PID_TIME */ |
|
22#include <setjmp.h> 23#include <sm/io.h> 24#include <sm/assert.h> 25#include <sm/conf.h> 26#include <sm/debug.h> 27#include <sm/string.h> 28#include <sm/varargs.h> 29#include <sm/heap.h> --- 79 unchanged lines hidden (view full) --- 109** 110** Parameters: 111** fmt -- format for printf() 112** 113** Returns: 114** none. 115*/ 116 | 24#include <setjmp.h> 25#include <sm/io.h> 26#include <sm/assert.h> 27#include <sm/conf.h> 28#include <sm/debug.h> 29#include <sm/string.h> 30#include <sm/varargs.h> 31#include <sm/heap.h> --- 79 unchanged lines hidden (view full) --- 111** 112** Parameters: 113** fmt -- format for printf() 114** 115** Returns: 116** none. 117*/ 118 |
119#if _FFR_DEBUG_PID_TIME 120SM_DEBUG_T SmDBGPidTime = SM_DEBUG_INITIALIZER("sm_trace_pid_time", 121 "@(#)$Debug: sm_trace_pid_time - print pid and time in debug $"); 122#endif /* _FFR_DEBUG_PID_TIME */ 123 |
|
117void 118#if SM_VA_STD 119sm_dprintf(char *fmt, ...) 120#else /* SM_VA_STD */ 121sm_dprintf(fmt, va_alist) 122 char *fmt; 123 va_dcl 124#endif /* SM_VA_STD */ 125{ 126 SM_VA_LOCAL_DECL 127 128 if (SmDebugOutput == NULL) 129 return; | 124void 125#if SM_VA_STD 126sm_dprintf(char *fmt, ...) 127#else /* SM_VA_STD */ 128sm_dprintf(fmt, va_alist) 129 char *fmt; 130 va_dcl 131#endif /* SM_VA_STD */ 132{ 133 SM_VA_LOCAL_DECL 134 135 if (SmDebugOutput == NULL) 136 return; |
137#if _FFR_DEBUG_PID_TIME 138 /* note: this is ugly if the output isn't a full line! */ 139 if (sm_debug_active(&SmDBGPidTime, 1)) 140 { 141 static char str[32] = "[1900-00-00/00:00:00] "; 142 struct tm *tmp; 143 time_t currt; 144 145 currt = time((time_t *)0); 146 tmp = localtime(&currt); 147 snprintf(str, sizeof(str), "[%d-%02d-%02d/%02d:%02d:%02d] ", 148 1900 + tmp->tm_year, /* HACK */ 149 tmp->tm_mon + 1, 150 tmp->tm_mday, 151 tmp->tm_hour, tmp->tm_min, tmp->tm_sec); 152 sm_io_fprintf(SmDebugOutput, SmDebugOutput->f_timeout, 153 "%ld: %s ", (long) getpid(), str); 154 } 155#endif /* _FFR_DEBUG_PID_TIME */ 156 |
|
130 SM_VA_START(ap, fmt); 131 sm_io_vfprintf(SmDebugOutput, SmDebugOutput->f_timeout, fmt, ap); 132 SM_VA_END(ap); 133} 134 135/* 136** SM_DFLUSH -- Flush debug output. 137** --- 259 unchanged lines hidden --- | 157 SM_VA_START(ap, fmt); 158 sm_io_vfprintf(SmDebugOutput, SmDebugOutput->f_timeout, fmt, ap); 159 SM_VA_END(ap); 160} 161 162/* 163** SM_DFLUSH -- Flush debug output. 164** --- 259 unchanged lines hidden --- |