Thanks to D H Becker for sending in an icon. I'd have liked to have
[u/mdw/putty] / mac / macevlog.c
index 60283ed..9c99f69 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: macevlog.c,v 1.6 2003/03/29 23:07:55 ben Exp $ */
+/* $Id$ */
 /*
  * Copyright (c) 2003 Ben Harris
  * All rights reserved.
@@ -101,18 +101,21 @@ void mac_freeeventlog(Session *s)
     }
 }
 
-/*
- * FIXME: logevent() should be passed a frontend handle, but backends have to
- * have a terminal handle instead, because they pass it to from_backend(),
- * so we accept a terminal handle here as well, and hope no-one tries to call
- * us with sensible arguments.
- */
-void logevent(void *frontend, char *str)
+void logevent(void *frontend, const char *str)
 {
-    Terminal *term = frontend;
-    Session *s = term->frontend;
+    Session *s = frontend;
     ListBounds bounds, visible;
     Cell cell = { 0, 0 };
+    char timebuf[40];
+    struct tm tm;
+    char *string;
+
+    tm=ltime();
+    strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", &tm);
+
+    string=snewn(strlen(timebuf) + strlen(str) +1, char);
+    strcpy(string, timebuf);
+    strcat(string, str);
 
     if (s->eventlog == NULL)
        mac_createeventlog(s);
@@ -129,10 +132,11 @@ void logevent(void *frontend, char *str)
 
     cell.v = bounds.bottom;
     LAddRow(1, cell.v, s->eventlog);
-    LSetCell(str, strlen(str), cell, s->eventlog);
+    LSetCell(string, strlen(string), cell, s->eventlog);
     /* ">=" and "2" because there can be a blank cell below the last one. */
     if (visible.bottom >= bounds.bottom)
        LScroll(0, 2, s->eventlog);
+    sfree(string);
 }
 
 static void mac_draweventloggrowicon(Session *s)