]> code.citadel.org Git - citadel.git/blobdiff - citadel/genstamp.c
* support autoconf 2.53
[citadel.git] / citadel / genstamp.c
index ce9575559059b3965dec7ee042e8f9f271ee1b04..b4300fe83b9236ca62ebfb32a0f38216cc09dcec 100644 (file)
@@ -9,6 +9,7 @@
 #define IN_LIBCIT
 #endif
 
+#include "sysdep.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
@@ -42,7 +43,7 @@ static char *weekdays[] = {
  * Supplied with a unix timestamp, generate an RFC822-compliant textual
  * time and date stamp.
  */
-void datestring(char *buf, time_t xtime, int which_format) {
+void datestring(char *buf, size_t n, time_t xtime, int which_format) {
        struct tm *t;
 
        long offset;
@@ -51,7 +52,11 @@ void datestring(char *buf, time_t xtime, int which_format) {
        t = localtime(&xtime);
 
        /* Convert "seconds west of GMT" to "hours/minutes offset" */
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
+       offset = t->tm_gmtoff;
+#else
        offset = timezone;
+#endif
        if (offset > 0) {
                offsign = '-';
        }
@@ -64,7 +69,7 @@ void datestring(char *buf, time_t xtime, int which_format) {
        switch(which_format) {
 
                case DATESTRING_RFC822:
-                       sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
+                       snprintf(buf, n, "%s, %02d %s %04d %02d:%02d:%02d %c%04ld",
                                weekdays[t->tm_wday],
                                t->tm_mday,
                                months[t->tm_mon],
@@ -77,7 +82,7 @@ void datestring(char *buf, time_t xtime, int which_format) {
                break;
 
                case DATESTRING_IMAP:
-                       sprintf(buf, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
+                       snprintf(buf, n, "%02d-%s-%04d %02d:%02d:%02d %c%04ld",
                                t->tm_mday,
                                months[t->tm_mon],
                                t->tm_year + 1900,