mailed date in network mail headers - (nf)

utzoo!decvax!microsof!uw-beave!jim utzoo!decvax!microsof!uw-beave!jim
Wed Feb 16 08:13:30 AEST 1983


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.



More information about the Comp.sources.unix mailing list