]> code.citadel.org Git - citadel.git/commitdiff
* webcit.c: fixed a string bug that caused the whole system to not work
authorArt Cancro <ajc@citadel.org>
Wed, 11 May 2005 03:00:03 +0000 (03:00 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 11 May 2005 03:00:03 +0000 (03:00 +0000)
* messages.c: fullname only and brief date in summary view, so that it
  doesn't wrap onto two lines quite as often

webcit/ChangeLog
webcit/calendar.c
webcit/calendar_view.c
webcit/messages.c
webcit/tools.c
webcit/webcit.c
webcit/webcit.h

index 461541b40e1d5c9ec95cb7a23d559d9b8c2ea686..1af6a2f8e8fead60225cf52f5379e88c73b6a9fd 100644 (file)
@@ -1,4 +1,9 @@
 $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()
 
@@ -2512,4 +2517,3 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
-
index 07221154d19e4c0bbfc3cb052d08b6fa1a03189c..ed46e30ba51ce99c56fe3437772121904af8232a 100644 (file)
@@ -169,7 +169,7 @@ void cal_process_object(icalcomponent *cal,
                        }
                        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
@@ -181,7 +181,7 @@ void cal_process_object(icalcomponent *cal,
                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
                        );
index b180909003e55fa95101070303b77e4bc36fbd7c..f5ec03b6f2f001070a3cc514dc6f295ec53cb616 100644 (file)
@@ -649,7 +649,7 @@ void do_tasks_view(void) {
                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\"");
index df8d2b59723b1fbd6800f222f3c571bd1fc0b551..75d00be54b89612834c119ed0917238f1bf0f16c 100644 (file)
@@ -500,7 +500,7 @@ void read_message(long msgnum) {
                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);
                }
 
@@ -730,7 +730,8 @@ void summarize_message(long msgnum, int is_new) {
        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;
@@ -742,11 +743,11 @@ void summarize_message(long msgnum, int is_new) {
                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)
@@ -763,7 +764,7 @@ void summarize_message(long msgnum, int is_new) {
                }
 
                if (!strncasecmp(buf, "time=", 5)) {
-                       fmt_date(summ.date, atol(&buf[5]));
+                       fmt_date(summ.date, atol(&buf[5]), 1);  /* brief */
                }
        }
 
@@ -1642,7 +1643,7 @@ void display_enter(void)
        }
 
        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) {
index 3f445c9b07892e47718f60b2601d5fdc88acad2e..de89c9fbd7ece213453e7ebee085f03333a07774 100644 (file)
@@ -195,25 +195,51 @@ char ch;
 /*
  * 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")
+               );
+       }
 }
 
 
@@ -525,7 +551,7 @@ int CtdlDecodeBase64(char *dest, const char *source, size_t length)
                                return (dpos);
                        }
                        if (dtable[c] & 0x80) {
-                               /* Ignoring errors: discard invalid character. */
+                               /* Ignoring errors: discard invalid character */
                                i--;
                                continue;
                        }
index 5e8568cf604bb692e694644b1222267347da4231..b27dcc5ecab38052fd3d5ec48b786f94a6bd9890 100644 (file)
@@ -109,7 +109,7 @@ void addurls(char *url)
                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;
index b4cb23bebe33761f560f96e29b9108e48f925498..b35db8e4cecd8e1397679e5d07317f95bd4456e4 100644 (file)
@@ -374,7 +374,7 @@ void display_menubar(int);
 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);