Times and dates in the event log, fixing ltime() in the process.

[originally from svn r5250]
This commit is contained in:
Owen Dunn 2005-02-05 00:29:20 +00:00
Родитель 061cfb7ef3
Коммит 45700b21e8
2 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -1,4 +1,4 @@
/* $Id: macevlog.c,v 1.8 2003/05/04 14:18:18 simon Exp $ */ /* $Id$ */
/* /*
* Copyright (c) 2003 Ben Harris * Copyright (c) 2003 Ben Harris
* All rights reserved. * All rights reserved.
@ -106,6 +106,16 @@ void logevent(void *frontend, const char *str)
Session *s = frontend; Session *s = frontend;
ListBounds bounds, visible; ListBounds bounds, visible;
Cell cell = { 0, 0 }; 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) if (s->eventlog == NULL)
mac_createeventlog(s); mac_createeventlog(s);
@ -122,10 +132,11 @@ void logevent(void *frontend, const char *str)
cell.v = bounds.bottom; cell.v = bounds.bottom;
LAddRow(1, cell.v, s->eventlog); 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. */ /* ">=" and "2" because there can be a blank cell below the last one. */
if (visible.bottom >= bounds.bottom) if (visible.bottom >= bounds.bottom)
LScroll(0, 2, s->eventlog); LScroll(0, 2, s->eventlog);
sfree(string);
} }
static void mac_draweventloggrowicon(Session *s) static void mac_draweventloggrowicon(Session *s)

Просмотреть файл

@ -183,8 +183,8 @@ struct tm ltime(void)
tm.tm_min=d.minute; tm.tm_min=d.minute;
tm.tm_hour=d.hour; tm.tm_hour=d.hour;
tm.tm_mday=d.day; tm.tm_mday=d.day;
tm.tm_mon=d.month; tm.tm_mon=d.month-1;
tm.tm_year=d.year; tm.tm_year=d.year-1900;
tm.tm_wday=d.dayOfWeek; tm.tm_wday=d.dayOfWeek;
tm.tm_yday=1; /* GetTime doesn't tell us */ tm.tm_yday=1; /* GetTime doesn't tell us */
tm.tm_isdst=0; /* Have to do DST ourselves */ tm.tm_isdst=0; /* Have to do DST ourselves */