X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fgenstamp.c;h=9c5ba5f3d6e613c3c1f15ecb2781ac3438a49bb5;hb=0adb29d5fa73df9c3760478405aaf71fa37054c4;hp=09fe1946957e645a249d391160de2badcf47ada4;hpb=72da3285140821058a0155ca35d2264b45eb3b5c;p=citadel.git diff --git a/citadel/genstamp.c b/citadel/genstamp.c index 09fe19469..9c5ba5f3d 100644 --- a/citadel/genstamp.c +++ b/citadel/genstamp.c @@ -1,14 +1,7 @@ /* - * $Id$ - * * Function to generate RFC822-compliant textual time/date stamp - * */ -#ifdef DLL_EXPORT -#define IN_LIBCIT -#endif - #include "sysdep.h" #include #include @@ -43,17 +36,17 @@ static char *weekdays[] = { * Supplied with a unix timestamp, generate an RFC822-compliant textual * time and date stamp. */ -void datestring(char *buf, size_t n, time_t xtime, int which_format) { - struct tm *t; +long datestring(char *buf, size_t n, time_t xtime, int which_format) { + 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 @@ -69,30 +62,34 @@ void datestring(char *buf, size_t n, time_t xtime, int which_format) { switch(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, + return 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, 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, + return 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, offsign, offset ); break; } + return 0; } -