* Changed a bunch of localtime() calls to localtime_r(), for great justice.
authorArt Cancro <ajc@citadel.org>
Tue, 5 Oct 2004 01:44:23 +0000 (01:44 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 5 Oct 2004 01:44:23 +0000 (01:44 +0000)
12 files changed:
citadel/ChangeLog
citadel/citadel.c
citadel/citserver.c
citadel/commands.c
citadel/genstamp.c
citadel/imap_misc.c
citadel/imap_tools.c
citadel/msgform.c
citadel/serv_expire.c
citadel/sysdep.c
citadel/tools.c
citadel/userlist.c

index ba00e3a416fcbd1e503afc08ef6203f08398db0d..9318267c2eef02287951c25e653efa689ab8c175 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 626.7  2004/10/05 01:44:20  ajc
+ * Changed a bunch of localtime() calls to localtime_r(), for great justice.
+
  Revision 626.6  2004/10/04 21:40:29  error
  * configure.ac: Add CFLAGS for icc Intel Compiler
 
@@ -6141,4 +6144,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 3915d8eb12e69f443ec37bf5f969bc610c1705af..7c09e40e28186910b3f1ad36008aebadb24cb663 100644 (file)
@@ -206,7 +206,7 @@ void userlist(CtdlIPC *ipc, char *patn)
 {
        char buf[SIZ];
        char fl[SIZ];
-       struct tm *tmbuf;
+       struct tm tmbuf;
        time_t lc;
        int r;                          /* IPC response code */
        char *listing = NULL;
@@ -230,11 +230,11 @@ void userlist(CtdlIPC *ipc, char *patn)
                        pprintf("%5ld %d ", extract_long(buf, 2),
                               extract_int(buf, 1));
                        lc = extract_long(buf, 3);
-                       tmbuf = (struct tm *) localtime(&lc);
+                       localtime_r(&lc, &tmbuf);
                        pprintf("%02d/%02d/%04d ",
-                              (tmbuf->tm_mon + 1),
-                              tmbuf->tm_mday,
-                              (tmbuf->tm_year + 1900));
+                              (tmbuf.tm_mon + 1),
+                              tmbuf.tm_mday,
+                              (tmbuf.tm_year + 1900));
                        pprintf("%5ld %5ld\n", extract_long(buf, 4), extract_long(buf, 5));
                    }
 
index 82e58d98860e08addcb99391a0db55302851b506..dcd1045d45cf537bed5fe7226e5299f340501590 100644 (file)
@@ -376,16 +376,16 @@ char CtdlCheckExpress(void) {
 void cmd_time(void)
 {
    time_t tv;
-   struct tm *tmp;
+   struct tm tmp;
    
    tv = time(NULL);
-   tmp = localtime(&tv);
+   localtime_r(&tv, &tmp);
    
    /* timezone and daylight global variables are not portable. */
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp->tm_gmtoff, tmp->tm_isdst);
+   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, tmp.tm_gmtoff, tmp.tm_isdst);
 #else
-   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp->tm_isdst);
+   cprintf("%d %ld|%ld|%d\n", CIT_OK, (long)tv, timezone, tmp.tm_isdst);
 #endif
 }
 
index ea3e527cb03695cddea6507830fd8b4919e6f750..758df4aa04a304ce356da10cad83e54416310b2b 100644 (file)
@@ -206,7 +206,7 @@ void print_instant(void)
        char buf[1024];
        FILE *outpipe;
        time_t timestamp;
-       struct tm *stamp;
+       struct tm stamp;
        int flags = 0;
        char sender[64];
        char node[64];
@@ -236,7 +236,7 @@ void print_instant(void)
                extract(node, buf, 4);
                strcpy(last_paged, sender);
        
-               stamp = localtime(&timestamp);
+               localtime_r(&timestamp, &stamp);
 
                /* If the page is a Logoff Request, honor it. */
                if (flags & 2) {
@@ -258,17 +258,17 @@ void print_instant(void)
                                else
                                        fprintf(outpipe, "Message ");
                                /* Timestamp.  Can this be improved? */
-                               if (stamp->tm_hour == 0 || stamp->tm_hour == 12)
+                               if (stamp.tm_hour == 0 || stamp.tm_hour == 12)
                                        fprintf(outpipe, "at 12:%02d%cm",
-                                               stamp->tm_min, 
-                                               stamp->tm_hour ? 'p' : 'a');
-                               else if (stamp->tm_hour > 12)           /* pm */
+                                               stamp.tm_min, 
+                                               stamp.tm_hour ? 'p' : 'a');
+                               else if (stamp.tm_hour > 12)            /* pm */
                                        fprintf(outpipe, "at %d:%02dpm",
-                                               stamp->tm_hour - 12,
-                                               stamp->tm_min);
+                                               stamp.tm_hour - 12,
+                                               stamp.tm_min);
                                else                                    /* am */
                                        fprintf(outpipe, "at %d:%02dam",
-                                               stamp->tm_hour, stamp->tm_min);
+                                               stamp.tm_hour, stamp.tm_min);
                                fprintf(outpipe, " from %s", sender);
                                if (strncmp(ipc_for_signal_handlers->ServInfo.nodename, node, 32))
                                        fprintf(outpipe, " @%s", node);
@@ -294,14 +294,14 @@ void print_instant(void)
                        scr_printf("Message ");
        
                /* Timestamp.  Can this be improved? */
-               if (stamp->tm_hour == 0 || stamp->tm_hour == 12)/* 12am/12pm */
-                       scr_printf("at 12:%02d%cm", stamp->tm_min, 
-                               stamp->tm_hour ? 'p' : 'a');
-               else if (stamp->tm_hour > 12)                   /* pm */
+               if (stamp.tm_hour == 0 || stamp.tm_hour == 12)/* 12am/12pm */
+                       scr_printf("at 12:%02d%cm", stamp.tm_min, 
+                               stamp.tm_hour ? 'p' : 'a');
+               else if (stamp.tm_hour > 12)                    /* pm */
                        scr_printf("at %d:%02dpm",
-                               stamp->tm_hour - 12, stamp->tm_min);
+                               stamp.tm_hour - 12, stamp.tm_min);
                else                                            /* am */
-                       scr_printf("at %d:%02dam", stamp->tm_hour, stamp->tm_min);
+                       scr_printf("at %d:%02dam", stamp.tm_hour, stamp.tm_min);
                
                /* Sender */
                scr_printf(" from %s", sender);
index 09fe1946957e645a249d391160de2badcf47ada4..e97fb97963fac9084ed1650310851009e73a5757 100644 (file)
@@ -44,16 +44,16 @@ static char *weekdays[] = {
  * time and date stamp.
  */
 void datestring(char *buf, size_t n, time_t xtime, int which_format) {
-       struct tm *t;
+       struct tm t;
 
        long offset;
        char offsign;
 
-       t = localtime(&xtime);
+       localtime_r(&xtime, &t);
 
        /* Convert "seconds west of GMT" to "hours/minutes offset" */
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-       offset = t->tm_gmtoff;
+       offset = t.tm_gmtoff;
 #else
        offset = timezone;
 #endif
@@ -70,25 +70,25 @@ void datestring(char *buf, size_t n, time_t xtime, int which_format) {
 
                case DATESTRING_RFC822:
                        snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
-                               weekdays[t->tm_wday],
-                               t->tm_mday,
-                               months[t->tm_mon],
-                               t->tm_year + 1900,
-                               t->tm_hour,
-                               t->tm_min,
-                               t->tm_sec,
+                               weekdays[t.tm_wday],
+                               t.tm_mday,
+                               months[t.tm_mon],
+                               t.tm_year + 1900,
+                               t.tm_hour,
+                               t.tm_min,
+                               t.tm_sec,
                                offsign, offset
                                );
                break;
 
                case DATESTRING_IMAP:
                        snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
-                               t->tm_mday,
-                               months[t->tm_mon],
-                               t->tm_year + 1900,
-                               t->tm_hour,
-                               t->tm_min,
-                               t->tm_sec,
+                               t.tm_mday,
+                               months[t.tm_mon],
+                               t.tm_year + 1900,
+                               t.tm_hour,
+                               t.tm_min,
+                               t.tm_sec,
                                offsign, offset
                                );
                break;
index 36ae353f89d41eaf188089c5b67c48e0d4af550f..b4299c583200b18f054f0fd9989964c1ad1ce1b5 100644 (file)
@@ -143,7 +143,7 @@ void imap_print_instant_messages(void) {
        char tmp[SIZ];
        int i;
        size_t size, size2;
-       struct tm *stamp;
+       struct tm stamp;
 
        if (CC->FirstExpressMessage == NULL) {
                return;
@@ -154,7 +154,7 @@ void imap_print_instant_messages(void) {
        end_critical_section(S_SESSION_TABLE);
 
        while (ptr != NULL) {
-               stamp = localtime(&(ptr->timestamp));
+               localtime_r(&(ptr->timestamp), &stamp);
                size = strlen(ptr->text) + SIZ;
                dumpomatic = malloc(size);
                strcpy(dumpomatic, "");
@@ -168,17 +168,17 @@ void imap_print_instant_messages(void) {
                        strcat(dumpomatic, "Message ");
 
                /* Timestamp.  Can this be improved? */
-               if (stamp->tm_hour == 0 || stamp->tm_hour == 12)
+               if (stamp.tm_hour == 0 || stamp.tm_hour == 12)
                        sprintf(tmp, "at 12:%02d%cm",
-                               stamp->tm_min, 
-                               stamp->tm_hour ? 'p' : 'a');
-               else if (stamp->tm_hour > 12)           /* pm */
+                               stamp.tm_min, 
+                               stamp.tm_hour ? 'p' : 'a');
+               else if (stamp.tm_hour > 12)            /* pm */
                        sprintf(tmp, "at %d:%02dpm",
-                               stamp->tm_hour - 12,
-                               stamp->tm_min);
+                               stamp.tm_hour - 12,
+                               stamp.tm_min);
                else                                    /* am */
                        sprintf(tmp, "at %d:%02dam",
-                               stamp->tm_hour, stamp->tm_min);
+                               stamp.tm_hour, stamp.tm_min);
                strcat(dumpomatic, tmp);
 
                size2 = strlen(dumpomatic);
index 597e50a6c4c1658b9ad4cede15fbc11fa50ae8c5..d1f2654fe40449c5e5a4e92cf0f558b249e19214 100644 (file)
@@ -415,7 +415,7 @@ int imap_datecmp(char *datestr, time_t msgtime) {
        }
 
        /* Extract day/month/year from message timestamp */
-       memcpy(&msgtm, localtime(&msgtime), sizeof(struct tm));
+       localtime_r(&msgtime, &msgtm);
        msgday = msgtm.tm_mday;
        msgmonth = msgtm.tm_mon;
        msgyear = msgtm.tm_year + 1900;
index ba6f2fdfce4ad17b36958b29d79fad0e1dff40c2..16df9aeb7fe4350b4df8fde986ff6c36747d5db3 100644 (file)
@@ -6,8 +6,8 @@
  * 
  * If the -q (quiet or qwk) flag is used, only the message text prints, and
  * then it stops at the end of the first message it prints.
- * This is used by the QWK reader for Citadel during message format
- * translation.
+ * 
+ * This utility isn't very useful anymore.
  *
  */
 
@@ -35,8 +35,8 @@
 
 int qwk = 0;
 
-int fpgetfield(FILE *fp, char *string);
-int fmout(int width, FILE *fp);
+int fpgetfield(FILE * fp, char *string);
+int fmout(int width, FILE * fp);
 
 
 #ifndef HAVE_STRERROR
@@ -47,121 +47,165 @@ char *strerror(int e)
 {
        static char buf[32];
 
-       snprintf(buf, sizeof buf, "errno = %d",e);
-       return(buf);
-       }
+       snprintf(buf, sizeof buf, "errno = %d", e);
+       return (buf);
+}
 #endif
 
 int main(int argc, char **argv)
 {
-       struct tm *tm;
-       int a,b,e,mtype,aflag;
+       struct tm tm;
+       int a, b, e, mtype, aflag;
        char bbb[1024];
        char subject[1024];
        FILE *fp;
        time_t now;
 
-       if (argc==2) if (!strcmp(argv[1],"-q")) qwk = 1;
-       fp=stdin;
-       if (argc==2) if (strcmp(argv[1],"-q")) {
-               fp = fopen(argv[1],"r");
-               if (fp==NULL) {
-                       fprintf(stderr,"%s: cannot open %s: %s\n",
-                               argv[0],argv[1],strerror(errno));
-                       exit(errno);
+       if (argc == 2)
+               if (!strcmp(argv[1], "-q"))
+                       qwk = 1;
+       fp = stdin;
+       if (argc == 2)
+               if (strcmp(argv[1], "-q")) {
+                       fp = fopen(argv[1], "r");
+                       if (fp == NULL) {
+                               fprintf(stderr, "%s: cannot open %s: %s\n",
+                                       argv[0], argv[1], strerror(errno));
+                               exit(errno);
                        }
                }
 
 TOP:   do {
-               e=getc(fp);
-               if (e<0) exit(0);
-               } while(e!=255);
-       strcpy(subject,"");
-       mtype=getc(fp); aflag=getc(fp);
-       if (qwk == 0) printf(" ");
-
-   do {
-       b=getc(fp);
-       if (b=='M') {
-               if (qwk==0) {
+               e = getc(fp);
+               if (e < 0)
+                       exit(0);
+       } while (e != 255);
+       strcpy(subject, "");
+       mtype = getc(fp);
+       aflag = getc(fp);
+       if (qwk == 0)
+               printf(" ");
+
+       do {
+               b = getc(fp);
+               if (b == 'M') {
+                       if (qwk == 0) {
                                printf("\n");
-                               if (strlen(subject)!=0)
-                                       printf("Subject: %s\n",subject);
-                               }
-               if (aflag!=1) fmout(80,fp);
-                  else while(a=getc(fp), a>0) {
-                       if (a==13) putc(10,stdout);
-                       else putc(a,stdout);
+                               if (strlen(subject) != 0)
+                                       printf("Subject: %s\n", subject);
                        }
+                       if (aflag != 1)
+                               fmout(80, fp);
+                       else
+                               while (a = getc(fp), a > 0) {
+                                       if (a == 13)
+                                               putc(10, stdout);
+                                       else
+                                               putc(a, stdout);
+                               }
                }
-       if ((b!='M')&&(b>0)) fpgetfield(fp,bbb);
-       if (b=='U') strcpy(subject,bbb);
-       if (qwk==0) {
-               if (b=='A') printf("from %s ",bbb);
-               if (b=='N') printf("@%s ",bbb);
-               if (b=='O') printf("in %s> ",bbb);
-               if (b=='R') printf("to %s ",bbb);
-               if (b=='T') {
-                       now=atol(bbb);
-                       tm=(struct tm *)localtime(&now);
-                       strcpy(bbb,asctime(tm)); bbb[strlen(bbb)-1]=0;
-                       printf("%s ",&bbb[4]);
+               if ((b != 'M') && (b > 0))
+                       fpgetfield(fp, bbb);
+               if (b == 'U')
+                       strcpy(subject, bbb);
+               if (qwk == 0) {
+                       if (b == 'A')
+                               printf("from %s ", bbb);
+                       if (b == 'N')
+                               printf("@%s ", bbb);
+                       if (b == 'O')
+                               printf("in %s> ", bbb);
+                       if (b == 'R')
+                               printf("to %s ", bbb);
+                       if (b == 'T') {
+                               now = atol(bbb);
+                               localtime_r(&now, &tm);
+                               strcpy(bbb, asctime(&tm));
+                               bbb[strlen(bbb) - 1] = 0;
+                               printf("%s ", &bbb[4]);
                        }
                }
-          } while ((b!='M')&&(b>0));
-       if (qwk==0) printf("\n"); 
-       if (qwk==1) exit(0);
+       } while ((b != 'M') && (b > 0));
+       if (qwk == 0)
+               printf("\n");
+       if (qwk == 1)
+               exit(0);
        goto TOP;
 }
 
-int fpgetfield(FILE *fp, char *string) /* level-2 break out next null-terminated string */
-         
-              
-{
-int a,b;
-strcpy(string,"");
-a=0;
+int fpgetfield(FILE * fp, char *string)
+
+{                              /* level-2 break out next null-terminated string */
+       int a, b;
+       strcpy(string, "");
+       a = 0;
        do {
-               b=getc(fp);
-               if (b<1) { string[a]=0; return(0); }
-               string[a]=b;
+               b = getc(fp);
+               if (b < 1) {
+                       string[a] = 0;
+                       return (0);
+               }
+               string[a] = b;
                ++a;
-               } while(b!=0);
-       return(0);
+       } while (b != 0);
+       return (0);
 }
 
-int fmout(int width, FILE *fp)
+int fmout(int width, FILE * fp)
 {
-       int a,b,c;
+       int a, b, c;
        int real = 0;
        int old = 0;
        char aaa[140];
-       
-       strcpy(aaa,""); old=255;
-       c=1; /* c is the current pos */
-FMTA:  old=real; a=getc(fp); real=a;
-       if (a<=0) goto FMTEND;
-       
-       if ( ((a==13)||(a==10)) && (old!=13) && (old!=10) ) a=32;
-       if ( ((old==13)||(old==10)) && (isspace(real)) ) {
-                                               printf("\n"); c=1; }
-       if (a>126) goto FMTA;
-
-       if (a>32) {
-       if ( ((strlen(aaa)+c)>(width-5)) && (strlen(aaa)>(width-5)) )
-               { printf("\n%s",aaa); c=strlen(aaa); aaa[0]=0; }
-        b=strlen(aaa); aaa[b]=a; aaa[b+1]=0; }
-       if (a==32) {    if ((strlen(aaa)+c)>(width-5)) { 
-                                                       printf("\n");
-                                                       c=1;
-                                                       }
-                       printf("%s ",aaa); ++c; c=c+strlen(aaa);
-                       strcpy(aaa,""); goto FMTA; }
-       if ((a==13)||(a==10)) {
-                               printf("%s\n",aaa); c=1;
-                               strcpy(aaa,""); goto FMTA; }
+
+       strcpy(aaa, "");
+       old = 255;
+       c = 1;                  /* c is the current pos */
+FMTA:  old = real;
+       a = getc(fp);
+       real = a;
+       if (a <= 0)
+               goto FMTEND;
+
+       if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
+               a = 32;
+       if (((old == 13) || (old == 10)) && (isspace(real))) {
+               printf("\n");
+               c = 1;
+       }
+       if (a > 126)
+               goto FMTA;
+
+       if (a > 32) {
+               if (((strlen(aaa) + c) > (width - 5))
+                   && (strlen(aaa) > (width - 5))) {
+                       printf("\n%s", aaa);
+                       c = strlen(aaa);
+                       aaa[0] = 0;
+               }
+               b = strlen(aaa);
+               aaa[b] = a;
+               aaa[b + 1] = 0;
+       }
+       if (a == 32) {
+               if ((strlen(aaa) + c) > (width - 5)) {
+                       printf("\n");
+                       c = 1;
+               }
+               printf("%s ", aaa);
+               ++c;
+               c = c + strlen(aaa);
+               strcpy(aaa, "");
+               goto FMTA;
+       }
+       if ((a == 13) || (a == 10)) {
+               printf("%s\n", aaa);
+               c = 1;
+               strcpy(aaa, "");
+               goto FMTA;
+       }
        goto FMTA;
 
 FMTEND:        printf("\n");
-       return(0);
+       return (0);
 }
index 80e4ea20288fef0063ca7c70bcfd1bf5721f7db9..2ee22eae2899edae45be8d16776928702b81b2ff 100644 (file)
@@ -632,7 +632,7 @@ void purge_databases(void) {
         * last twelve hours.  This is usually enough granularity.
         */
        now = time(NULL);
-       memcpy(&tm, localtime(&now), sizeof(struct tm));
+       localtime_r(&now, &tm);
        if (tm.tm_hour != config.c_purge_hour) return;
        if ((now - last_purge) < 43200) return;
 
index ce1a9dcad849d4fb53dd2014c8d41dbadce49895..21722e1736ca0d7b589fcfc2cf94175c82630b6b 100644 (file)
@@ -126,13 +126,13 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
        }
        else if (loglevel <= verbosity) { 
                struct timeval tv;
-               struct tm *tim;
+               struct tm tim;
                time_t unixtime;
 
                gettimeofday(&tv, NULL);
                /* Promote to time_t; types differ on some OSes (like darwin) */
                unixtime = tv.tv_sec;
-               tim = localtime(&unixtime);
+               localtime_r(&unixtime, &tim);
                /*
                 * Log provides millisecond accuracy.  If you need
                 * microsecond accuracy and your OS supports it, change
@@ -143,33 +143,33 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) {
                        /* Millisecond display */
                        fprintf(stderr,
                                "%04d/%02d/%02d %2d:%02d:%02d.%03ld [%3d] %s",
-                               tim->tm_year + 1900, tim->tm_mon + 1,
-                               tim->tm_mday, tim->tm_hour, tim->tm_min,
-                               tim->tm_sec, (long)tv.tv_usec / 1000,
+                               tim.tm_year + 1900, tim.tm_mon + 1,
+                               tim.tm_mday, tim.tm_hour, tim.tm_min,
+                               tim.tm_sec, (long)tv.tv_usec / 1000,
                                CC->cs_pid, buf);
 #endif
                        /* Microsecond display */
                        fprintf(stderr,
                                "%04d/%02d/%02d %2d:%02d:%02d.%06ld [%3d] %s",
-                               tim->tm_year + 1900, tim->tm_mon + 1,
-                               tim->tm_mday, tim->tm_hour, tim->tm_min,
-                               tim->tm_sec, (long)tv.tv_usec,
+                               tim.tm_year + 1900, tim.tm_mon + 1,
+                               tim.tm_mday, tim.tm_hour, tim.tm_min,
+                               tim.tm_sec, (long)tv.tv_usec,
                                CC->cs_pid, buf);
                } else {
 #if 0
                        /* Millisecond display */
                        fprintf(stderr,
                                "%04d/%02d/%02d %2d:%02d:%02d.%03ld %s",
-                               tim->tm_year + 1900, tim->tm_mon + 1,
-                               tim->tm_mday, tim->tm_hour, tim->tm_min,
-                               tim->tm_sec, (long)tv.tv_usec / 1000, buf);
+                               tim.tm_year + 1900, tim.tm_mon + 1,
+                               tim.tm_mday, tim.tm_hour, tim.tm_min,
+                               tim.tm_sec, (long)tv.tv_usec / 1000, buf);
 #endif
                        /* Microsecond display */
                        fprintf(stderr,
                                "%04d/%02d/%02d %2d:%02d:%02d.%06ld %s",
-                               tim->tm_year + 1900, tim->tm_mon + 1,
-                               tim->tm_mday, tim->tm_hour, tim->tm_min,
-                               tim->tm_sec, (long)tv.tv_usec, buf);
+                               tim.tm_year + 1900, tim.tm_mon + 1,
+                               tim.tm_mday, tim.tm_hour, tim.tm_min,
+                               tim.tm_sec, (long)tv.tv_usec, buf);
                }
                fflush(stderr);
        }
index 17fcb225d64cd1594f254466df7ec0961464e22d..3d980eaafa79552f7d38a50d96753aded0937e82 100644 (file)
@@ -366,34 +366,34 @@ int haschar(const char *st, int ch)
  * seconds is whether to print the seconds
  */
 void fmt_date(char *buf, size_t n, time_t thetime, int seconds) {
-       struct tm *tm;
+       struct tm tm;
        int hour;
 
        strcpy(buf, "");
-       tm = localtime(&thetime);
+       localtime_r(&thetime, &tm);
 
-       hour = tm->tm_hour;
+       hour = tm.tm_hour;
        if (hour == 0)  hour = 12;
        else if (hour > 12) hour = hour - 12;
 
        if (seconds) {
                snprintf(buf, n, "%s %d %4d %d:%02d:%02d%s",
-                       ascmonths[tm->tm_mon],
-                       tm->tm_mday,
-                       tm->tm_year + 1900,
+                       ascmonths[tm.tm_mon],
+                       tm.tm_mday,
+                       tm.tm_year + 1900,
                        hour,
-                       tm->tm_min,
-                       tm->tm_sec,
-                       ( (tm->tm_hour >= 12) ? "pm" : "am" )
+                       tm.tm_min,
+                       tm.tm_sec,
+                       ( (tm.tm_hour >= 12) ? "pm" : "am" )
                );
        } else {
                snprintf(buf, n, "%s %d %4d %d:%02d%s",
-                       ascmonths[tm->tm_mon],
-                       tm->tm_mday,
-                       tm->tm_year + 1900,
+                       ascmonths[tm.tm_mon],
+                       tm.tm_mday,
+                       tm.tm_year + 1900,
                        hour,
-                       tm->tm_min,
-                       ( (tm->tm_hour >= 12) ? "pm" : "am" )
+                       tm.tm_min,
+                       ( (tm.tm_hour >= 12) ? "pm" : "am" )
                );
        }
 }
index 9c23f189133d0bc3a1cd970c5e87a7ff7f99e41e..00534037d1a976634ae2fbc7586c05a321149917 100644 (file)
@@ -34,7 +34,7 @@ void logoff(int code)
 void userlist(CtdlIPC *ipc) { 
        char buf[SIZ];
        char fl[SIZ];
-       struct tm *tmbuf;
+       struct tm tmbuf;
        time_t lc;
        char *listing = NULL;
        int r;
@@ -54,11 +54,11 @@ void userlist(CtdlIPC *ipc) {
                printf("%5ld %d ",extract_long(buf,2),
                        extract_int(buf,1));
                lc = extract_long(buf,3);
-               tmbuf = (struct tm *)localtime(&lc);
+               localtime_r(&lc, &tmbuf);
                printf("%02d/%02d/%04d ",
-                       (tmbuf->tm_mon+1),
-                       tmbuf->tm_mday,
-                       (tmbuf->tm_year + 1900));
+                       (tmbuf.tm_mon+1),
+                       tmbuf.tm_mday,
+                       (tmbuf.tm_year + 1900));
                printf("%5ld %5ld\n",
                        extract_long(buf,4),extract_long(buf,5));
        }