$Log$
+Revision 610.4 2005/05/11 03:00:03 ajc
+* webcit.c: fixed a string bug that caused the whole system to not work
+* messages.c: fullname only and brief date in summary view, so that it
+ doesn't wrap onto two lines quite as often
+
Revision 610.3 2005/04/11 20:09:33 ajc
* Began an assault on strcpy()
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
-
}
else {
tt = icaltime_as_timet(t);
- fmt_date(buf, tt);
+ fmt_date(buf, tt, 0);
wprintf("<TR><TD><B>Starting date/time:"
"</B></TD><TD>"
"%s</TD></TR>", buf
if (p != NULL) {
t = icalproperty_get_dtend(p);
tt = icaltime_as_timet(t);
- fmt_date(buf, tt);
+ fmt_date(buf, tt, 0);
wprintf("<TR><TD><B>Ending date/time:</B></TD><TD>"
"%s</TD></TR>", buf
);
wprintf("</TD>\n");
due = get_task_due_date(WC->disp_cal[i].cal);
- fmt_date(buf, due);
+ fmt_date(buf, due, 0);
wprintf("<TD><FONT");
if (due < time(NULL)) {
wprintf(" COLOR=\"#FF0000\"");
if (!strncasecmp(buf, "rcpt=", 5))
wprintf("to %s ", &buf[5]);
if (!strncasecmp(buf, "time=", 5)) {
- fmt_date(now, atol(&buf[5]));
+ fmt_date(now, atol(&buf[5]), 0);
wprintf("%s ", now);
}
memset(&summ, 0, sizeof(summ));
strcpy(summ.subj, "(no subject)");
- sprintf(buf, "MSG0 %ld|3", msgnum); /* ask for headers only with no MIME */
+ /* ask for headers only with no MIME */
+ sprintf(buf, "MSG0 %ld|3", msgnum);
serv_puts(buf);
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
if (!strncasecmp(buf, "subj=", 5)) {
strcpy(summ.subj, &buf[5]);
}
- if (!strncasecmp(buf, "rfca=", 5)) {
+ /* if (!strncasecmp(buf, "rfca=", 5)) {
strcat(summ.from, " <");
strcat(summ.from, &buf[5]);
strcat(summ.from, ">");
- }
+ } */
if (!strncasecmp(buf, "node=", 5)) {
if ( ((WC->room_flags & QR_NETWORK)
}
if (!strncasecmp(buf, "time=", 5)) {
- fmt_date(summ.date, atol(&buf[5]));
+ fmt_date(summ.date, atol(&buf[5]), 1); /* brief */
}
}
}
now = time(NULL);
- fmt_date(buf, now);
+ fmt_date(buf, now, 0);
strcat(&buf[strlen(buf)], " <I>from</I> ");
stresc(&buf[strlen(buf)], WC->wc_username, 1, 1);
if (strlen(bstr("recp")) > 0) {
/*
* Format a date/time stamp for output
*/
-void fmt_date(char *buf, time_t thetime)
+void fmt_date(char *buf, time_t thetime, int brief)
{
- struct tm *tm;
+ struct tm tm;
+ struct tm today_tm;
+ time_t today_timet;
int hour;
- buf[0] = 0;
- tm = localtime(&thetime);
- hour = tm->tm_hour;
+ today_timet = time(NULL);
+ localtime_r(&today_timet, &today_tm);
+
+ localtime_r(&thetime, &tm);
+ hour = tm.tm_hour;
if (hour == 0)
hour = 12;
else if (hour > 12)
hour = hour - 12;
- sprintf(buf, "%s %d %d %2d:%02d%s",
- ascmonths[tm->tm_mon],
- tm->tm_mday,
- tm->tm_year + 1900,
- hour, tm->tm_min, ((tm->tm_hour >= 12) ? "pm" : "am")
- );
+ buf[0] = 0;
+
+ if (brief) {
+
+ if ((tm.tm_year == today_tm.tm_year)
+ &&(tm.tm_mon == today_tm.tm_mon)
+ &&(tm.tm_mday == today_tm.tm_mday)) {
+ sprintf(buf, "%2d:%02d%s",
+ hour, tm.tm_min,
+ ((tm.tm_hour >= 12) ? "pm" : "am")
+ );
+ }
+ else {
+ sprintf(buf, "%s %d %d",
+ ascmonths[tm.tm_mon],
+ tm.tm_mday,
+ tm.tm_year + 1900
+ );
+ }
+ }
+ else {
+ sprintf(buf, "%s %d %d %2d:%02d%s",
+ ascmonths[tm.tm_mon],
+ tm.tm_mday,
+ tm.tm_year + 1900,
+ hour, tm.tm_min, ((tm.tm_hour >= 12) ? "pm" : "am")
+ );
+ }
}
return (dpos);
}
if (dtable[c] & 0x80) {
- /* Ignoring errors: discard invalid character. */
+ /* Ignoring errors: discard invalid character */
i--;
continue;
}
strcpy(ptr, "");
u->url_data = malloc(strlen(up) + 2);
- safestrncpy(u->url_data, up, sizeof u->url_data);
+ safestrncpy(u->url_data, up, strlen(up) + 1);
u->url_data[b] = 0;
unescape_input(u->url_data);
up = ptr;
void smart_goto(char *);
void worker_entry(void);
void session_loop(struct httprequest *);
-void fmt_date(char *buf, time_t thetime);
+void fmt_date(char *buf, time_t thetime, int brief);
void fmt_time(char *buf, time_t thetime);
void httpdate(char *buf, time_t thetime);
void end_webcit_session(void);