Support pkg-config for SSL libraries.
[exim.git] / src / src / debug.c
index 15b7917b1ea07c03a4f676de9903ca1b10f2c216..ebd932f64431314971d208195738cd6e6b5a8270 100644 (file)
@@ -1,10 +1,8 @@
-/* $Cambridge: exim/src/src/debug.c,v 1.2 2004/12/21 14:38:02 ph10 Exp $ */
-
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 *************************************************/
 
-/* Copyright (c) University of Cambridge 1995 - 2004 */
+/* Copyright (c) University of Cambridge 1995 - 2009 */
 /* See the file NOTICE for conditions of use and distribution. */
 
 
@@ -148,7 +146,7 @@ get interleaved. Since some calls to debug_printf() don't end with newline,
 we save up the text until we do get the newline. */
 
 void
-debug_printf(char *format, ...)
+debug_printf(const char *format, ...)
 {
 va_list ap;
 va_start(ap, format);
@@ -157,18 +155,23 @@ va_end(ap);
 }
 
 void
-debug_vprintf(char *format, va_list ap)
+debug_vprintf(const char *format, va_list ap)
 {
 if (debug_file == NULL) return;
 
-/* Various things can be inserted at the start of a line. */
+/* Various things can be inserted at the start of a line. Don't use the
+tod_stamp() function for the timestamp, because that will overwrite the
+timestamp buffer, which may contain something useful. (This was a bug fix: the
++memory debugging with +timestamp did cause a problem.) */
 
 if (debug_ptr == debug_buffer)
   {
   DEBUG(D_timestamp)
     {
-    uschar *ts = tod_stamp(tod_log_bare);
-    sprintf(CS debug_ptr, "%s ", ts + 11);
+    time_t now = time(NULL);
+    struct tm *t = timestamps_utc? gmtime(&now) : localtime(&now);
+    (void) sprintf(CS debug_ptr, "%02d:%02d:%02d ", t->tm_hour, t->tm_min,
+      t->tm_sec);
     while(*debug_ptr != 0) debug_ptr++;
     }