* localtime_r() fixes
authorArt Cancro <ajc@citadel.org>
Tue, 5 Oct 2004 01:59:32 +0000 (01:59 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 5 Oct 2004 01:59:32 +0000 (01:59 +0000)
webcit/ChangeLog
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/event.c

index 50fe8974729a474afcd97973ac6163d5d418836a..0ac846ef07bcea366106b76efaead628cdbbb658 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 524.4  2004/10/05 01:59:31  ajc
+* localtime_r() fixes
+
 Revision 524.3  2004/10/03 02:56:35  ajc
 * Added a pthread_attr_destroy() in the appropriate place (thanks fleeb!)
 
@@ -2090,4 +2093,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 bea5fc10933e27fec9b5e24b918e542663615dd2..5b34a88c1d88f10070bacd6e895ce916d50d0e3c 100644 (file)
@@ -74,17 +74,17 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix) {
        int all_day_event = 0;
 
        now = time(NULL);
-       memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+       localtime_r(&now, &tm_now);
        this_year = tm_now.tm_year + 1900;
 
        if (t == NULL) return;
        if (t->is_date) all_day_event = 1;
        tt = icaltime_as_timet(*t);
        if (all_day_event) {
-               memcpy(&tm, gmtime(&tt), sizeof(struct tm));
+               gmtime_r(&tt, &tm);
        }
        else {
-               memcpy(&tm, localtime(&tt), sizeof(struct tm));
+               localtime_r(&tt, &tm);
        }
 
        wprintf("Month: ");
@@ -157,7 +157,7 @@ struct icaltimetype icaltime_from_webform(char *prefix) {
        char vname[SIZ];
 
        tt = time(NULL);
-       memcpy(&tm, localtime(&tt), sizeof(struct tm));
+       localtime_r(&tt, &tm);
 
        sprintf(vname, "%s_month", prefix);     tm.tm_mon = atoi(bstr(vname)) - 1;
        sprintf(vname, "%s_day", prefix);       tm.tm_mday = atoi(bstr(vname));
index 42829f9ab1aa43b38ff27c6608e0404c780f94e2..d89af86316f501b96ef3b8387e033f60290adeaf 100644 (file)
@@ -56,7 +56,7 @@ void calendar_month_view_display_events(time_t thetime) {
                return;
        }
 
-       memcpy(&today_tm, localtime(&thetime), sizeof(struct tm));
+       localtime_r(&thetime, &today_tm);
        month = today_tm.tm_mon + 1;
        day = today_tm.tm_mday;
        year = today_tm.tm_year + 1900;
@@ -72,10 +72,10 @@ void calendar_month_view_display_events(time_t thetime) {
                        else all_day_event = 0;
 
                        if (all_day_event) {
-                               memcpy(&event_tm, gmtime(&event_tt), sizeof(struct tm));
+                               gmtime_r(&event_tt, &event_tm);
                        }
                        else {
-                               memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+                               localtime_r(&event_tt, &event_tm);
                        }
 
 lprintf(9, "Event: %04d/%02d/%02d, Now: %04d/%02d/%02d\n",
@@ -149,7 +149,7 @@ void calendar_month_view(int year, int month, int day) {
        memcpy(&tm, &starting_tm, sizeof(struct tm));
        while (tm.tm_mday != 1) {
                thetime = thetime - (time_t)86400;      /* go back 24 hours */
-               memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+               localtime_r(&thetime, &tm);
        }
 
        /* Determine previous and next months ... for links */
@@ -157,10 +157,10 @@ void calendar_month_view(int year, int month, int day) {
        next_month = thetime + (time_t)(31L * 86400L);  /* ahead 31 days */
 
        /* Now back up until we're on a Sunday */
-       memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+       localtime_r(&thetime, &tm);
        while (tm.tm_wday != 0) {
                thetime = thetime - (time_t)86400;      /* go back 24 hours */
-               memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+               localtime_r(&thetime, &tm);
        }
 
        /* Outer table (to get the background color) */
@@ -178,7 +178,7 @@ void calendar_month_view(int year, int month, int day) {
 
        wprintf("<TD ALIGN=CENTER>");
 
-       memcpy(&tm, localtime(&previous_month), sizeof(struct tm));
+       localtime_r(&previous_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
        wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/back.gif\" BORDER=0></A>\n");
@@ -189,7 +189,7 @@ void calendar_month_view(int year, int month, int day) {
                "</FONT>"
                "&nbsp;&nbsp;", months[month-1], year);
 
-       memcpy(&tm, localtime(&next_month), sizeof(struct tm));
+       localtime_r(&next_month, &tm);
        wprintf("<A HREF=\"readfwd?calview=month&year=%d&month=%d&day=1\">",
                (int)(tm.tm_year)+1900, tm.tm_mon + 1);
        wprintf("<IMG ALIGN=MIDDLE SRC=\"/static/forward.gif\" BORDER=0></A>\n");
@@ -209,7 +209,7 @@ void calendar_month_view(int year, int month, int day) {
 
        /* Now do 35 days */
        for (i = 0; i < 35; ++i) {
-               memcpy(&tm, localtime(&thetime), sizeof(struct tm));
+               localtime_r(&thetime, &tm);
 
                /* Before displaying Sunday, start a new row */
                if ((i % 7) == 0) {
@@ -485,7 +485,7 @@ void calendar_summary_view(void) {
        }
 
        now = time(NULL);
-       memcpy(&today_tm, localtime(&now), sizeof(struct tm));
+       localtime_r(&now, &today_tm);
 
        for (i=0; i<(WC->num_cal); ++i) {
                p = icalcomponent_get_first_property(WC->disp_cal[i].cal,
@@ -497,10 +497,10 @@ void calendar_summary_view(void) {
                        fmt_time(timestring, event_tt);
 
                        if (all_day_event) {
-                               memcpy(&event_tm, gmtime(&event_tt), sizeof(struct tm));
+                               gmtime_r(&event_tt, &event_tm);
                        }
                        else {
-                               memcpy(&event_tm, localtime(&event_tt), sizeof(struct tm));
+                               localtime_r(&event_tt, &event_tm);
                        }
 
                        if ( (event_tm.tm_year == today_tm.tm_year)
@@ -546,7 +546,7 @@ void do_calendar_view(void) {
 
        /* In case no date was specified, go with today */
        now = time(NULL);
-       memcpy(&tm, localtime(&now), sizeof(struct tm));
+       localtime_r(&now, &tm);
        year = tm.tm_year + 1900;
        month = tm.tm_mon + 1;
        day = tm.tm_mday;
index d7ed702a619aa9cc0e6431d1f49bfe3ba24fae32..8f99da03aba5903646ed897509a33a9e9cf139ea 100644 (file)
@@ -145,7 +145,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum)
                }
        }
        else {
-               memcpy(&tm_now, localtime(&now), sizeof(struct tm));
+               localtime_r(&now, &tm_now);
                tm_now.tm_year = atoi(bstr("year")) - 1900;
                tm_now.tm_mon = atoi(bstr("month")) - 1;
                tm_now.tm_mday = atoi(bstr("day"));