* Fixed up the "Date:" headers to be RFC822-compliant
authorArt Cancro <ajc@citadel.org>
Wed, 22 Dec 1999 04:46:34 +0000 (04:46 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 22 Dec 1999 04:46:34 +0000 (04:46 +0000)
citadel/ChangeLog
citadel/Makefile.in
citadel/genstamp.c [new file with mode: 0644]
citadel/genstamp.h [new file with mode: 0644]
citadel/internet_addressing.c
citadel/netmailer.c

index eeb9daecb1c56929590037d9964b5f5ca6f87c01..431dbaaacd036dc5b4fbb081e1bd618da769f6db 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 1.430  1999/12/22 04:46:34  ajc
+* Fixed up the "Date:" headers to be RFC822-compliant
+
 Revision 1.429  1999/12/13 05:30:57  ajc
 * Removed our naive 'conv_date()' RFC822-to-unixtime conversion function
   and replaced it with the public domain 'parsedate()' function from UseNet
@@ -1496,3 +1499,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
        * Initial CVS import 
+
index c6418adf0be4a6dabeffc8878af1894a5f28475d..4154518b646ab7bdb381e588652633eaabbec6a1 100644 (file)
@@ -71,7 +71,7 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c commands.c \
        support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
        whobbs.c sendcommand.c mime_parser.c base64.c qpdecode.c getutline.c \
        auth.c chkpwd.c client_icq.c html.c vcard.c serv_upgrade.c \
-       serv_smtp.c internet_addressing.c parsedate.c
+       serv_smtp.c internet_addressing.c parsedate.c genstamp.c
 
 DEP_FILES=$(SOURCES:.c=.d)
 
@@ -107,7 +107,8 @@ netpoll: netpoll.o config.o ipc_c_tcp.o tools.o $(LIBOBJS)
 SERV_OBJS = citserver.ro user_ops.ro support.ro room_ops.ro file_ops.ro \
        msgbase.ro config.ro sysdep.ro locate_host.ro housekeeping.ro \
        database.ro control.ro logging.ro policy.ro dynloader.ro tools.ro \
-       mime_parser.ro html.ro internet_addressing.ro parsedate.ro \
+       mime_parser.ro html.ro internet_addressing.ro \
+       parsedate.ro genstamp.ro \
        $(AUTH) $(LIBOBJS:.o=.ro)
 
 citserver: $(SERV_OBJS)
@@ -172,8 +173,9 @@ aidepost: aidepost.o config.o $(LIBOBJS)
 # mail.  If it is not run setuid, all outgoing mail may always show as coming
 # from your BBSUID rather than the actual sending user.
 #
-netmailer: netmailer.o internetmail.o config.o
-       $(CC) netmailer.o config.o internetmail.o $(LDFLAGS) -o netmailer
+netmailer: netmailer.o internetmail.o config.o genstamp.o
+       $(CC) netmailer.o config.o internetmail.o genstamp.o \
+       $(LDFLAGS) -o netmailer
 
 netproc: netproc.o config.o ipc_c_tcp.o tools.o $(LIBOBJS)
        $(CC) netproc.o config.o ipc_c_tcp.o tools.o \
diff --git a/citadel/genstamp.c b/citadel/genstamp.c
new file mode 100644 (file)
index 0000000..b3e910b
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Function to generate RFC822-compliant textual time/date stamp
+ *
+ * $Id$
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <time.h>
+#include "genstamp.h"
+
+
+static char *months[] = {
+       "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+       "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+static char *weekdays[] = {
+       "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+};
+
+
+/*
+ * Supplied with a unix timestamp, generate an RFC822-compliant textual
+ * time and date stamp.
+ */
+void generate_rfc822_datestamp(char *buf, time_t xtime) {
+       struct tm *t;
+
+       t = localtime(&xtime);
+
+       sprintf(buf, "%s, %02d %s %04d %02d:%02d:%02d %s",
+               weekdays[t->tm_wday],
+               t->tm_mday,
+               months[t->tm_mon],
+               t->tm_year + 1900,
+               t->tm_hour,
+               t->tm_min,
+               t->tm_sec,
+               tzname[0]
+               );
+}
+
diff --git a/citadel/genstamp.h b/citadel/genstamp.h
new file mode 100644 (file)
index 0000000..747fb35
--- /dev/null
@@ -0,0 +1 @@
+void generate_rfc822_datestamp(char *buf, time_t xtime);
index 99c834753b9ae76a1423ecb58234fd4895f39479..6e3ccbdeaf62243791c6ce3d0a762f13d85717f4 100644 (file)
@@ -32,6 +32,7 @@
 #include "parsedate.h"
 
 
+
 /*
  * Return 0 if a given string fuzzy-matches a Citadel user account
  *
@@ -422,3 +423,4 @@ struct CtdlMessage *convert_internet_message(char *rfc822) {
 
        return msg;
 }
+
index 90a8bb83edae3c14a964ab44f368b04367cee843..7de5c419f68b4bd57fb2d29055b7eca7481c8621 100644 (file)
@@ -16,6 +16,7 @@
 #include <limits.h>
 #include <syslog.h>
 #include "citadel.h"
+#include "genstamp.h"
 
 void LoadInternetConfig(void);
 void get_config(void);
@@ -198,7 +199,8 @@ int main(int argc, char **argv)
        FILE *fp, *rmail;
        char sbuf[200], rbuf[200], cstr[100], fstr[128];
        char nbuf[64], pbuf[128], rmname[128], buf[128];
-       char subject[200];
+       char datestamp[256];
+       char subject[256];
        time_t mid_buf;
        time_t now;
        int mlist = 0;
@@ -286,7 +288,8 @@ int main(int argc, char **argv)
         */
        fprintf(rmail, "To: %s\n", rbuf);
        time(&now);
-       fprintf(rmail, "Date: %s", asctime(localtime(&now)));
+       generate_rfc822_datestamp(datestamp, now);
+       fprintf(rmail, "Date: %s\n", datestamp);
        fprintf(rmail, "Message-Id: <%ld@%s>\n", (long) mid_buf, nbuf);
        fprintf(rmail, "X-Mailer: %s\n", CITADEL);
        fprintf(rmail, "Subject: %s\n", subject);