From d3861822d4a742cf184d812d5c6fffdf2f8b035a Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Wed, 22 Dec 1999 04:46:34 +0000 Subject: [PATCH] * Fixed up the "Date:" headers to be RFC822-compliant --- citadel/ChangeLog | 4 +++ citadel/Makefile.in | 10 +++++--- citadel/genstamp.c | 46 +++++++++++++++++++++++++++++++++++ citadel/genstamp.h | 1 + citadel/internet_addressing.c | 2 ++ citadel/netmailer.c | 7 ++++-- 6 files changed, 64 insertions(+), 6 deletions(-) create mode 100644 citadel/genstamp.c create mode 100644 citadel/genstamp.h diff --git a/citadel/ChangeLog b/citadel/ChangeLog index eeb9daecb..431dbaaac 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -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 Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/Makefile.in b/citadel/Makefile.in index c6418adf0..4154518b6 100644 --- a/citadel/Makefile.in +++ b/citadel/Makefile.in @@ -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 index 000000000..b3e910bae --- /dev/null +++ b/citadel/genstamp.c @@ -0,0 +1,46 @@ +/* + * Function to generate RFC822-compliant textual time/date stamp + * + * $Id$ + * + */ + +#include +#include +#include +#include +#include +#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 index 000000000..747fb355c --- /dev/null +++ b/citadel/genstamp.h @@ -0,0 +1 @@ +void generate_rfc822_datestamp(char *buf, time_t xtime); diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index 99c834753..6e3ccbdea 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -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; } + diff --git a/citadel/netmailer.c b/citadel/netmailer.c index 90a8bb83e..7de5c419f 100644 --- a/citadel/netmailer.c +++ b/citadel/netmailer.c @@ -16,6 +16,7 @@ #include #include #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); -- 2.30.2