kolstad (02/14/83)
#N:parsec:42500001:000:928
parsec!kolstad Feb 12 22:50:00 1983
I was frustrated at receiving network mail that showed only the time our
system received it. I added the following lines to
/usr/src/cmd/ucbmail/send.c .
The purpose is to put a "Mailed: <date>" header on outgoing network mail.
It seems to work fine on our system and has been installed one other place.
=================================================
Old "To:" line print out...
> fprintf(fo, "To: "), fmt(hp->h_to, fo), gotcha++;
------------------------------------------------------
Its replacement:
< {
< /* put in the mailed at time if anyone on the network RK 2/3/83 */
< int t ; /* added RK 2/3/83 */
< char *ctime(), *p; /* added RK 2/3/83 */
< t = time(0); /* added RK 2/3/83 */
< fprintf(fo, "To: "); fmt(hp->h_to, fo); gotcha++;
< for (p=hp->h_to; *p; p++) {
< if(*p == '!' || *p == '@' || *p == ':' || *p == '.') {
< fprintf(fo, "Mailed: %s", ctime(&t));
< break;
< }
< }
< }
jim (02/16/83)
In reference to parsec!kolstad's mods to put the date in the header for ucbmail: Since a lot of mail gets gatewayed between Arpanet and uucp, it would seem preferable to put the date in standard Arpa format. Here are my mods to send.c: *** send.c_o Fri Jul 16 09:10:46 1982 --- send.c Wed Jul 14 13:36:30 1982 *************** *** 9,14 * Mail -- a mail program * * Mail to others. */ /* --- 9,18 ----- * Mail -- a mail program * * Mail to others. + * + * 14 July 82 Jim Rees + * Added the date in Arpa format to messages sent out. #ifdefed on + * ARPADATE. The routine arpadate() is stolen from Gosling's Emacs. */ #define ARPADATE *************** *** 11,16 * Mail to others. */ /* * Send message described by the passed pointer to the * passed output buffer. Return -1 on error, but normally --- 15,26 ----- * ARPADATE. The routine arpadate() is stolen from Gosling's Emacs. */ + #define ARPADATE + + #ifdef ARPADATE + #define GDATE 0x80 + #endif ARPADATE + /* * Send message described by the passed pointer to the * passed output buffer. Return -1 on error, but normally *************** *** 319,324 return(fi); } remove(tempMail); puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL); rewind(fi); c = getc(fi); --- 329,335 ----- return(fi); } remove(tempMail); + #ifndef ARPADATE puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL); #else ARPADATE puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL|GDATE); *************** *** 320,325 } remove(tempMail); puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL); rewind(fi); c = getc(fi); while (c != EOF) { --- 331,339 ----- remove(tempMail); #ifndef ARPADATE puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL); + #else ARPADATE + puthead(hp, nfo, GTO|GSUBJECT|GCC|GNL|GDATE); + #endif ARPADATE rewind(fi); c = getc(fi); while (c != EOF) { *************** *** 354,359 FILE *fo; { register int gotcha; gotcha = 0; if (hp->h_to != NOSTR && w & GTO) --- 368,376 ----- FILE *fo; { register int gotcha; + #ifdef ARPADATE + char *arpatime(); + #endif ARPADATE gotcha = 0; #ifdef ARPADATE *************** *** 356,361 register int gotcha; gotcha = 0; if (hp->h_to != NOSTR && w & GTO) fprintf(fo, "To: "), fmt(hp->h_to, fo), gotcha++; if (hp->h_subject != NOSTR && w & GSUBJECT) --- 373,382 ----- #endif ARPADATE gotcha = 0; + #ifdef ARPADATE + if (w & GDATE) + fprintf(fo, "Date: %s\n", arpatime()); + #endif ARPADATE if (hp->h_to != NOSTR && w & GTO) fprintf(fo, "To: "), fmt(hp->h_to, fo), gotcha++; if (hp->h_subject != NOSTR && w & GSUBJECT) *************** *** 368,373 putc('\n', fo); return(0); } /* * Format the given text to not exceed 72 characters. --- 389,421 ----- putc('\n', fo); return(0); } + + #ifdef ARPADATE + #include <time.h> + #include <sys/timeb.h> + + char *arpatime() + { + struct tm *tm, *localtime(); + struct timeb timeb; + static char *month[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + static char buf[100]; + + ftime(&timeb); + tm = localtime(&timeb.time); + sprintf(buf, "%d %s %d %d:%02d-%s", + tm->tm_mday, + month[tm->tm_mon], + tm->tm_year+1900, + tm->tm_hour, + tm->tm_min, + timezone (timeb.timezone, tm->tm_isdst)); + return buf; + } + #endif ARPADATE /* * Format the given text to not exceed 72 characters.
eric (02/22/83)
Why can't the date format be converted at the Arpa gateways? I personally like to see the date in a consistent format, and since this is a Unix network, I think Unix's format (the date command) is more suitable than Arpa's format.