*** ./collect.c.orig	Mon Feb 24 23:07:00 1992
--- ./collect.c	Wed Dec  1 08:17:21 1993
***************
*** 67,74 ****
--- 67,75 ----
  {
  	register FILE *tf;
  	char buf[MAXFIELD+2];
  	register char *p;
+ 
  #ifdef BIT8
  	char buf1[MAXFIELD+2];
  	CHARSET *ch;
  	char *chname, *chesc;
***************
*** 114,121 ****
--- 115,124 ----
  	 * of that.
  	 */
  	(void) sfgets(buf, sizeof buf, InChannel);
  	fixcrlf(buf, FALSE);
+ 
+ 
  #ifndef NOTUNIX
  	if (!SaveFrom && strncmp(buf, "From ", 5) == 0)
  	{
  		eatfrom(buf);
***************
*** 141,148 ****
--- 144,152 ----
  
  	do {
  		int c;
  
+ 
  		/* drop out on error */
  		if (ferror(InChannel))
  			break;
  
***************
*** 185,198 ****
  		printf("EOH\n");
  
  	/* throw away a blank line */
  	if (buf[0] == '\0' && !ferror(InChannel))
! 		(void) sfgets(buf, sizeof(buf), InChannel);
  
  	/*
  	**  Collect the body of the message.
  	*/
  
  #ifdef BIT8
  	chname = hvalue("x-charset");
  	chesc = hvalue("x-char-esc");
  	if (!chesc)
--- 189,231 ----
  		printf("EOH\n");
  
  	/* throw away a blank line */
  	if (buf[0] == '\0' && !ferror(InChannel))
! 	  {
! 	    (void) sfgets(buf, sizeof(buf), InChannel);
! 	  }
  
  	/*
  	**  Collect the body of the message.
  	*/
  
+ #ifdef EMIL
+ 
+ 	/*  Connect collected header with MkMess_Root structure
+ 	 *  and run the TCL scripts.
+ 	 */
+ 	if (CurEnv->e_from.q_mailer->m_charset) {
+ #ifdef EMILDEBUG
+ 	  Mk_Log(LOG_DEBUG, "Setting fromcharset %s from mailer %s", 
+ 		 CurEnv->e_from.q_mailer->m_charset,
+ 		 CurEnv->e_from.q_mailer->m_name);
+ #endif
+ 	  MkMess_Root->fcharset = (char *)
+ 	    newstr(CurEnv->e_from.q_mailer->m_charset);
+ 	MkMess_Root->esc = (short)CurEnv->e_from.q_mailer->m_esc;
+ 	}
+ #ifdef EMILDEBUG
+ 	else
+ 	  Mk_Log(LOG_DEBUG, "No charset specified from this mailer: %s",
+ 		 CurEnv->e_from.q_mailer->m_name);
+ #endif
+ 	MkMess_Root->header = (HDR *)CurEnv->e_header;
+ 	MkMess_Root->washeaders = TRUE;
+ 	MkMess_Root->investigate = TRUE;
+ 	Mk_Eval_Header();
+ 	linecount = 0;
+ 	MkMess_Buf->in = buf;
+ #endif /* EMIL */
  #ifdef BIT8
  	chname = hvalue("x-charset");
  	chesc = hvalue("x-char-esc");
  	if (!chesc)
***************
*** 201,208 ****
--- 234,242 ----
  		ch = getchset(chname, atoi(chesc));
  	else
  		ch = CurEnv->e_from.q_mailer->m_charset;
  #endif /* BIT8 */
+ 
  #ifdef O_SYNC
  	if (SuperSafe)
  	{
  		int fd = fileno(tf);
***************
*** 226,234 ****
  			strncnv(ascii, ch, (CHAR8U *)buf1, (CHAR8U *)buf, sizeof buf1);
  			strncpy(buf, buf1, sizeof buf);
  		}
  #endif /* BIT8 */
- 
  		fixcrlf(buf, TRUE);
  
  		/* check for end-of-message */
  		if (!IgnrDot && buf[0] == '.' && (buf[1] == '\n' || buf[1] == '\0'))
--- 260,267 ----
***************
*** 237,244 ****
--- 270,278 ----
  		/* check for transparent dot */
  		if (OpMode == MD_SMTP && !IgnrDot && bp[0] == '.' && bp[1] == '.')
  			bp++;
  
+ 		
  		/*
  		**  Figure message length, output the line to the temp
  		**  file, and insert a newline if missing.
  		*/
***************
*** 247,255 ****
--- 281,296 ----
  		fputs(bp, tf);
  		putc('\n', tf);
  		if (ferror(tf))
  			tferror(tf);
+ #ifdef EMIL
+ 		mkcollect(buf, sizeof(buf), InChannel);
+ #endif /* EMIL */
  	} while (sfgets(buf, sizeof(buf), InChannel) != NULL);
+ 
+ #ifdef EMIL
+ 	mkcollqueueup();
+ #endif /* EMIL */
  
  	if (fflush(tf) != 0)
  		tferror(tf);
  	if (!sayok)
*** ./conf.h.orig	Sat Jul 25 21:44:00 1992
--- ./conf.h	Wed Dec  1 08:17:22 1993
***************
*** 73,81 ****
  ** osx.h ptx.h riscos.h s5r4.h sunos3.h sunos4.h ultrix3.h ultrix4.h
  ** umax.h unisoft.h usg.h xenix.h
  */
  
! # include "config/bsd44.h"
  
  /*
  **  Compilation options.
  **
--- 73,81 ----
  ** osx.h ptx.h riscos.h s5r4.h sunos3.h sunos4.h ultrix3.h ultrix4.h
  ** umax.h unisoft.h usg.h xenix.h
  */
  
! # include "config/sunos4.h"
  
  /*
  **  Compilation options.
  **
***************
*** 140,147 ****
--- 140,155 ----
   * sites.  Intended for sites whose character set is not US ASCII.  See
   * ../ida/charset.
   */
  # define BIT8		1	/* */
+ 
+ /*
+  * Add support for message conversion using Emil.
+  */
+ #define EMIL            1       /* */
+ #ifdef EMIL
+ # undef BIT8
+ #endif /* EMIL */
  
  /*
   * Enable the use of bind/hesiod for alias lookups.  Defining it here
   * and linking with -lhesiod only enables the code in sendmail.  To actually
*** ./deliver.c.orig	Mon Aug  3 22:35:00 1992
--- ./deliver.c	Wed Dec  1 08:17:22 1993
***************
*** 148,156 ****
  	char *pv[MAXPV+1];
  	char tobuf[MAXLINE-50];		/* text line of to people */
  	char buf[MAXNAME];
  	char tfrombuf[MAXNAME];		/* translated from person */
- 
  	errno = 0;
  	if (to == (ADDRESS *)NULL || bitset(QDONTSEND, to->q_flags))
  		return (0);
  
--- 148,155 ----
***************
*** 173,181 ****
  
  	if (tTd(10, 1))
  		printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n",
  			m->m_mno, host, to->q_user);
! 
  #ifdef BIT8
  	if (m->m_charset)
  	{
  		HDR *h;
--- 172,180 ----
  
  	if (tTd(10, 1))
  		printf("\n--deliver, mailer=%d, host=`%s', first user=`%s'\n",
  			m->m_mno, host, to->q_user);
! #ifndef EMIL
  #ifdef BIT8
  	if (m->m_charset)
  	{
  		HDR *h;
***************
*** 198,206 ****
  		else
  			addheader("x-char-esc", buf, e);
  	}
  #endif /* BIT8 */
! 
  	/*
  	**  If this mailer is expensive, and if we don't want to make
  	**  connections now, just mark these addresses and return.
  	**	This is useful if we want to batch connections to
--- 197,205 ----
  		else
  			addheader("x-char-esc", buf, e);
  	}
  #endif /* BIT8 */
! #endif /* !EMIL */
  	/*
  	**  If this mailer is expensive, and if we don't want to make
  	**  connections now, just mark these addresses and return.
  	**	This is useful if we want to batch connections to
***************
*** 312,319 ****
--- 311,320 ----
  
  	tobuf[0] = '\0';
  	e->e_to = tobuf;
  	ctladdr = NULL;
+ 
+ 
  	for (; to != NULL; to = to->q_next)
  	{
  		/* avoid sending multiple recipients to dumb mailers */
  		if (tobuf[0] != '\0' && !bitnset(M_MUSER, m->m_flags))
***************
*** 404,412 ****
  			continue;
  
  		/* save statistics.... */
  		markstats(e, to);
- 
  		/*
  		**  See if this user name is "special".
  		**	If the user name has a slash in it, assume that this
  		**	is a file -- send it off without further ado.  Note
--- 405,412 ----
***************
*** 458,466 ****
  				/* allow some space for trailing parms */
  				break;
  			}
  		}
! 	}
  
  	/* see if any addresses still exist */
  	if (tobuf[0] == '\0')
  	{
--- 458,466 ----
  				/* allow some space for trailing parms */
  				break;
  			}
  		}
!         }
  
  	/* see if any addresses still exist */
  	if (tobuf[0] == '\0')
  	{
***************
*** 805,816 ****
  	/*
  	**  Format and send message.
  	*/
  
  	putfromline(mfile, m);
  	(*e->e_puthdr)(mfile, m, e);
  	putline("", mfile, m);
! 	(*e->e_putbody)(mfile, m, e);
  	(void) fclose(mfile);
  	if (rfile != NULL)
  		(void) fclose(rfile);
  
--- 805,872 ----
  	/*
  	**  Format and send message.
  	*/
  
+ #ifdef EMIL
+ 
+ 	/*
+ 	 * Evaluate message and decide what conversions should
+ 	 * be done.
+ 	 */
+ 
+ 	mkdeleval(m->m_mtype);
+ 
+ #endif /* EMIL */
+ 
  	putfromline(mfile, m);
  	(*e->e_puthdr)(mfile, m, e);
  	putline("", mfile, m);
! 
! #ifdef EMIL
! 
! 	/*
! 	 * If MkMess_Root->dotunnel send message without conversions.
! 	 */
! 	  
! 	if (MkMess_Root->dotunnel) 
! #endif /* EMIL */
! 	  (*e->e_putbody)(mfile, m, e);
! #ifdef EMIL
! 	else
! 	  {
! 	    /* 
! 	     * Send off each bodypart.
! 	     */
! 	    linecount = 0;
! 	    MkMess_Curr = MkMess_Root;
! 	    do
! 	      {
! 		MkMess_Buf = MkMess_Curr->buf;
! 		if (MkMess_Curr != MkMess_Root)
! 		  Mk_Put_Headers(mfile, m, FALSE);
! 		MkMess_Curr->investigate = FALSE;
! 		(*e->e_putbody)(mfile, m, e);
! 		MkMess_Curr = MkMess_Curr->next;
! 	      } while (MkMess_Curr);
! 
! 	Mk_Log(LOG_DEBUG, "Munging boundaries");
! 	    
! 	    if (MkMess_Curr != MkMess_Root && MkMess_Root->dosubheaders)
! 	      while (MkMess_Root->bound != NULL) {
! 		char buf[BUFSIZE];
! 		char *boundbuf;
! 		boundbuf = (char *)getendbound();
! 		if (boundbuf) {
! 		  strcpy(buf, boundbuf);
! 		  boundbuf = buf;
! 		  putline(boundbuf, mfile, m);
! 		}
! 		rmlastbound();
! 	      }
! 	  }
! 	Mk_Log(LOG_DEBUG, "Processing done");
! 
! #endif /* EMIL */
  	(void) fclose(mfile);
  	if (rfile != NULL)
  		(void) fclose(rfile);
  
***************
*** 1497,1507 ****
  		}
  	}
  	if (e->e_dfp != NULL)
  	{
  		rewind(e->e_dfp);
! 		while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
  		{
  #ifdef BIT8
  			if (m->m_charset)
  			{
  				char buf1[MAXLINE];
--- 1553,1582 ----
  		}
  	}
  	if (e->e_dfp != NULL)
  	{
+ 
+ #ifdef EMIL
+ 	  /* Just in case it screwed up
+ 	   */
+ 	  if (MkMess_Curr == NULL) {
+ 	    MkMess_Curr = MkMess_Root;
+ 	    MkMess_Root->dotunnel = TRUE;
+ 	  }
+ 	  else
+ 	    /* Normal though */
+ 	    if (MkMess_Curr == MkMess_Root)
+ #endif
  		rewind(e->e_dfp);
! 
! #ifdef EMIL
! 		if (MkMess_Root->dotunnel) 
! 		  
! #endif /* EMIL */
! 
! 		  while (!ferror(fp) && fgets(buf, sizeof buf, e->e_dfp) != NULL)
  		{
+ #ifndef EMIL
  #ifdef BIT8
  			if (m->m_charset)
  			{
  				char buf1[MAXLINE];
***************
*** 1509,1522 ****
  				(void) strncpy(buf1, buf, sizeof buf1);
  				strncnv(m->m_charset, ascii, (CHAR8U *)buf, (CHAR8U *)buf1, sizeof buf);
  			}
  #endif /* BIT8 */
  			if (buf[0] == 'F' && bitnset(M_ESCFROM, m->m_flags) &&
  			    strncmp(buf, "From ", 5) == 0)
  				(void) putc('>', fp);
  			putline(buf, fp, m);
  		}
! 
  		if (ferror(e->e_dfp))
  		{
  			syserr("putbody: read error");
  			ExitStat = EX_IOERR;
--- 1584,1601 ----
  				(void) strncpy(buf1, buf, sizeof buf1);
  				strncnv(m->m_charset, ascii, (CHAR8U *)buf, (CHAR8U *)buf1, sizeof buf);
  			}
  #endif /* BIT8 */
+ #endif /* EMIL */
  			if (buf[0] == 'F' && bitnset(M_ESCFROM, m->m_flags) &&
  			    strncmp(buf, "From ", 5) == 0)
  				(void) putc('>', fp);
  			putline(buf, fp, m);
  		}
! #ifdef EMIL
! 	        else
! 		  mkputbodypart(e->e_dfp, fp, m);
! #endif /* EMIL */
  		if (ferror(e->e_dfp))
  		{
  			syserr("putbody: read error");
  			ExitStat = EX_IOERR;
***************
*** 1530,1537 ****
--- 1609,1617 ----
  		ExitStat = EX_IOERR;
  	}
  	errno = 0;
  }
+ 
  /*
  **  MAILFILE -- Send a message to a file.
  **
  **	If the file has the setuid/setgid bits set, but NO execute
***************
*** 1571,1579 ****
  	**	Note that we MUST use fork, not vfork, because of
  	**	the complications of calling subroutines, etc.
  	*/
  
! 	DOFORK(fork);
  
  	if (pid > 0 && tTd(4, 2))
  		printf("mailfile: forking (pid = %d)\n", pid);
  	if (pid < 0)
--- 1651,1659 ----
  	**	Note that we MUST use fork, not vfork, because of
  	**	the complications of calling subroutines, etc.
  	*/
  
!  	DOFORK(fork);
  
  	if (pid > 0 && tTd(4, 2))
  		printf("mailfile: forking (pid = %d)\n", pid);
  	if (pid < 0)
***************
*** 1687,1694 ****
--- 1767,1777 ----
  	register ADDRESS *q;
  	bool oldverbose, DoingMore;
  	int pid, cnt;
  	FILE *lockfp = NULL;
+ #ifdef EMIL
+ 	HDR *mkroothdr;
+ #endif /* EMIL */
  
  	/* determine actual delivery mode */
  	if (mode == SM_DEFAULT)
  	{
***************
*** 1757,1768 ****
  		**/
  		if (lockfp != NULL)
  			(void) flock(fileno(lockfp), LOCK_UN);
  #endif /* (FCNTL_FLOCK) || (LOCKF_FLOCK) */
! 		pid = fork();
  		if (pid > 0 && tTd(4, 2))
  			printf("sendall: forking (pid = %d)\n", pid);
! 		if (pid < 0)
  		{
  			mode = SM_DELIVER;
  			break;
  		}
--- 1840,1852 ----
  		**/
  		if (lockfp != NULL)
  			(void) flock(fileno(lockfp), LOCK_UN);
  #endif /* (FCNTL_FLOCK) || (LOCKF_FLOCK) */
! 
! 		pid = fork(); 
  		if (pid > 0 && tTd(4, 2))
  			printf("sendall: forking (pid = %d)\n", pid);
! 		if (pid < 0) 
  		{
  			mode = SM_DELIVER;
  			break;
  		}
***************
*** 1776,1784 ****
  		}
  
  		/* double fork to avoid zombies */
  		if (fork() > 0)
! 			exit(EX_OK);
  
  #if defined(FCNTL_FLOCK) || defined(LOCKF_FLOCK) 
  		/*
  		** re-lock tf file in child (again for flock() as lockf())
--- 1860,1868 ----
  		}
  
  		/* double fork to avoid zombies */
  		if (fork() > 0)
! 			exit(EX_OK); 
  
  #if defined(FCNTL_FLOCK) || defined(LOCKF_FLOCK) 
  		/*
  		** re-lock tf file in child (again for flock() as lockf())
***************
*** 1801,1808 ****
--- 1885,1905 ----
  	/*
  	**  Run through the list and send everything.
  	*/
  
+ #ifdef EMIL
+ 
+ 	/* 
+ 	 * Because Mk changes the headerstructure it is 
+ 	 * essential to refresh it for every copy to send 
+ 	 * if more than one.
+ 	 */
+ 	if (e->e_sendqueue->q_next != NULL)
+ 	  mkroothdr = e->e_header;
+ 	else
+ 	  mkroothdr = NULL;
+ 
+ #endif /* EMIL */
  	DoingMore = FALSE;
  	for (cnt = 0, q = e->e_sendqueue; q != NULL; q = q->q_next)
  	{
  		if (mode == SM_VERIFY)
***************
*** 1823,1830 ****
--- 1920,1936 ----
  			 * one delivery.
  			 */
  			FILE *newfile;
  
+ #ifdef EMIL
+ 			Mk_Log(LOG_DEBUG,"Copying header");
+ 			if (mkroothdr != NULL) {
+ 			  e->e_header = 
+ 			    (HDR *)Mk_CopyHdr(mkroothdr);
+ 			  Mk_Tcl();
+ 			}
+ 			Mk_Log(LOG_DEBUG,"Done");
+ #endif /* EMIL */
  			if (DoingMore && CheckpointInterval && cnt &&
  			    (cnt % CheckpointInterval) == 0)
  			{
  				if (tTd(13, 2))
***************
*** 1866,1873 ****
--- 1972,1989 ----
  
  		/* only send errors if the message failed */
  		if (!bitset(QBADADDR, q->q_flags))
  			continue;
+ #ifdef EMIL
+ 		Mk_Log(LOG_DEBUG,"Copying header");
+ 		if (mkroothdr != NULL) {
+ 		  e->e_header = 
+ 		    (HDR *)Mk_CopyHdr(mkroothdr);
+ 		  Mk_Tcl();
+ 		}
+ 		MkMess_Root->dotunnel = TRUE;
+ 		Mk_Log(LOG_DEBUG,"Done");
+ #endif /* EMIL */
  
  		/* we have an address that failed -- find the parent */
  		for (qq = q; qq != NULL; qq = qq->q_alias)
  		{
*** ./envelope.c.orig	Mon Aug  3 22:38:00 1992
--- ./envelope.c	Wed Dec  1 08:17:23 1993
***************
*** 154,162 ****
  	*/
  
  	if (failures > 0 && bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) &&
  	    ErrorMode != EM_QUIET)
! 		savemail(e);
  
  	/*
  	**  Instantiate or deinstantiate the queue.
  	*/
--- 154,162 ----
  	*/
  
  	if (failures > 0 && bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) &&
  	    ErrorMode != EM_QUIET)
! 	    savemail(e);
  
  	/*
  	**  Instantiate or deinstantiate the queue.
  	*/
***************
*** 169,176 ****
--- 169,180 ----
  			pintvl(curtime() - e->e_ctime, TRUE));
  #endif /* LOG */
  		if (e->e_df != NULL)
  			xunlink(e->e_df);
+ #ifdef EMIL
+ 		if (e->e_mf != NULL)
+ 		  xunlink(e->e_mf);
+ #endif /* EMIL */
  		xunlink(queuename(e, 'q'));
  	}
  	else if (queueit || !bitset(EF_INQUEUE, e->e_flags))
  	{
***************
*** 310,318 ****
  	define('c', cbuf, CurEnv);
  
  	/* time as integer, unix time, arpa time */
  	settime();
! 
  #ifdef TTYNAME
  	/* tty name (why does this exist?) */
  	if (macvalue('y', CurEnv) == NULL)
  	{
--- 314,324 ----
  	define('c', cbuf, CurEnv);
  
  	/* time as integer, unix time, arpa time */
  	settime();
! #ifdef EMIL
! 	Mk_Tcl();
! #endif /* EMIL */
  #ifdef TTYNAME
  	/* tty name (why does this exist?) */
  	if (macvalue('y', CurEnv) == NULL)
  	{
*** ./queue.c.orig	Tue Aug  4 19:39:00 1992
--- ./queue.c	Wed Dec  1 08:17:23 1993
***************
*** 166,174 ****
--- 166,188 ----
  	else if ((tfp = fdopen(fd, "w")) == NULL)
  		syserr("cannot fdopen(%s)", tf);
  	if (tTd(40, 1))
  		printf("queueing %s\n", e->e_id);
+ #ifdef EMIL
+ 	/*
+ 	**  If there is no message control file yet, create one.
+ 	*/
  
+ 	if (e->e_mf == NULL)
+ 	  {
+ 	    char *qp;
+ 
+ 	    /* newstr macro will call function arguments twice */
+ 	    qp = queuename(e, 'm');
+ 	    e->e_mf = newstr(qp);
+ 	  }
+ #endif /* EMIL */
+ 
  	/*
  	**  If there is no data file yet, create one.
  	*/
  
***************
*** 196,203 ****
--- 210,218 ----
  		if ((dfp = fdopen(fd, "w")) == NULL)
  			syserr("cannot fdopen(%s)", e->e_df);
  
  		(*e->e_putbody)(dfp, ProgMailer, e);
+ 
  		(void) fflush(dfp);
  #ifndef O_SYNC
  		if (SuperSafe && fsync(fileno(dfp)) < 0)
  			syserr("queueup: fsync() of dfp failed (%d)", errno);
***************
*** 205,212 ****
--- 220,228 ----
  		(void) fclose(dfp);
  		e->e_putbody = putbody;
  	}
  
+ 
  	/*
  	**  Output future work requests.
  	**	Priority and creation time should be first, since
  	**	they are required by orderq.
***************
*** 502,510 ****
  	*/
  
  	/* order the existing work requests */
  	(void) orderq(FALSE);
! 
  	/* process them once at a time */
  	while (WorkQ != NULL)
  	{
  		WORK *w = WorkQ;
--- 518,528 ----
  	*/
  
  	/* order the existing work requests */
  	(void) orderq(FALSE);
! #ifdef EMIL
! 	  Mk_Tcl();
! #endif
  	/* process them once at a time */
  	while (WorkQ != NULL)
  	{
  		WORK *w = WorkQ;
***************
*** 826,837 ****
  				exit(EX_OK);
  			else
  				return;
  		}
! 
  		CurEnv->e_flags |= EF_INQUEUE;
  		eatheader(CurEnv, NULL);
  
  		/* do the delivery */
  		if (!bitset(EF_FATALERRS, CurEnv->e_flags))
  			sendall(CurEnv, SM_DELIVER);
  
--- 844,877 ----
  				exit(EX_OK);
  			else
  				return;
  		}
! 		
  		CurEnv->e_flags |= EF_INQUEUE;
  		eatheader(CurEnv, NULL);
  
+ #ifdef EMIL
+ 
+ 		CurEnv->e_mf = newstr(queuename(CurEnv, 'm'));
+ 
+ 		if (TRUE)
+ 		  {
+ 		    
+ 		    FILE *mfp;
+ 		    if ((mfp = dfopen(CurEnv->e_mf, "r")) == NULL)
+ 		      {
+ 			syslog(LOG_NOTICE, "Mk: Cannot open %s ...using transparent mode", 
+ 			       CurEnv->e_mf);
+ 			MkMess_Root->dotunnel = TRUE;
+ 		      }
+ 		    else
+ 		      {
+ 			mkreadqf(mfp, MkMess_Root);
+ 			fclose(mfp);
+ 		      }
+ 		  }
+ #endif /* EMIL */
+ 		  
  		/* do the delivery */
  		if (!bitset(EF_FATALERRS, CurEnv->e_flags))
  			sendall(CurEnv, SM_DELIVER);
  
*** ./readcf.c.orig	Fri Jul 17 17:12:00 1992
--- ./readcf.c	Wed Dec  1 08:18:07 1993
***************
*** 463,470 ****
--- 463,471 ----
  **			   S -- the sender rewriting set
  **			   R -- the recipient rewriting set
  **			   E -- the eol string
  **			   M -- the maximum message size
+ **                         T -- the message type (#if EMIL)
  **			   C -- the default character set (#if BIT8)
  **			   X -- the default escape char (#if BIT8)
  **			The first word is the canonical name of the mailer.
  **
***************
*** 580,587 ****
--- 581,600 ----
  
  		  case 'M':		/* maximum message size */
  			m->m_maxsize = atol(p);
  			break;
+ #ifdef EMIL
+ 		  case 'T':		/* message type */
+ 			m->m_mtype = newstr(p);
+ 			break;
+ 		  case 'C':		/* default character set */
+ 			m->m_charset = newstr(p);
+ 			break;
+ 
+ 		  case 'X':		/* default escape char */
+ 			m->m_esc = atol(p);
+ 			break;
+ #endif /* EMIL */
  #ifdef BIT8
  		  case 'C':		/* default character set */
  			m->m_charset = getchset(newstr(p), 0);
  			break;
*** ./recipient.c.orig	Tue Jun 16 20:02:00 1992
--- ./recipient.c	Wed Dec  1 08:17:24 1993
***************
*** 287,294 ****
--- 287,295 ----
  		}
  		else
  			alias(a, sendq);
  	}
+ 	    
  
  	/*
  	**  If the user is local and still being sent, verify that
  	**  the address is good.  If it is, try to forward.
*** ./sendmail.h.orig	Thu Aug 13 16:53:00 1992
--- ./sendmail.h	Wed Dec  1 08:17:25 1993
***************
*** 206,213 ****
--- 206,218 ----
  	short	m_re_rwset;	/* rewriting ruleset for envelope recipients */
  	short	m_rh_rwset;	/* rewriting ruleset for header recipient */
  	char	*m_eol;		/* end of line string */
  	long	m_maxsize;	/* size limit on message to this mailer */
+ # ifdef EMIL
+ 	char    *m_mtype;       /* message type */
+ 	char	*m_charset;	/* originator's character set */
+ 	short	m_esc;		/* escape character */
+ # endif /* EMIL */
  # ifdef BIT8
  	CHARSET	*m_charset;	/* default character set */
  	short	m_esc;		/* escape character */
  # endif /* BIT8 */
***************
*** 322,329 ****
--- 327,338 ----
  	char		*e_df;		/* location of temp file */
  	FILE		*e_dfp;		/* temporary file */
  	char		*e_id;		/* code for this entry in queue */
  	FILE		*e_xfp;		/* transcript file */
+ #ifdef EMIL
+ 	char            *e_mf;          /* location of message file */
+ 	FILE            *e_mfp;         /* message file */
+ #endif /* EMIL */
  	char		*e_message;	/* error message */
  	char		*e_macro[128];	/* macro definitions */
  };
  
***************
*** 833,837 ****
--- 842,850 ----
  	char	metaval;
  };
  
  extern struct metamac	MetaMacros[];
+ # ifdef EMIL
+ #  include "../ida/emil/charset/charset.h"
+ #  include "../ida/emil/mkspec.h"
+ # endif /* EMIL */
  # include "def.h"
*** ./usersmtp.c.orig	Mon Feb 24 23:08:00 1992
--- ./usersmtp.c	Wed Dec  1 08:17:25 1993
***************
*** 371,382 ****
--- 371,420 ----
  		return (EX_UNAVAILABLE);
  	else if (r != 354 && r != 250)
  		return (EX_PROTOCOL);
  
+ #ifdef EMIL
+ 	mkdeleval(m->m_mtype);
+ 
+ #endif /* EMIL */
+ 
  	/* now output the actual message */
  	(*e->e_puthdr)(SmtpOut, m, CurEnv);
  	putline("", SmtpOut, m);
+ 
+ #ifdef EMIL
+ 	if (MkMess_Root->dotunnel) 
+ #endif /* EMIL */
  	(*e->e_putbody)(SmtpOut, m, CurEnv);
+ #ifdef EMIL
+ 	else
+ 	  {
+ 	    linecount = 0;
+ 	    MkMess_Curr = MkMess_Root;
+ 	    do
+ 	      {
+ 		MkMess_Buf = MkMess_Curr->buf;
+ 		if (MkMess_Curr != MkMess_Root)
+ 		  Mk_Put_Headers(SmtpOut, m, FALSE);
+ 		MkMess_Curr->investigate = FALSE;
+ 		(*e->e_putbody)(SmtpOut, m, CurEnv);
+ 		MkMess_Curr = MkMess_Curr->next;
+ 	      } while (MkMess_Curr);
+ 	    if (MkMess_Curr != MkMess_Root && MkMess_Root->dosubheaders)
+ 	      while (MkMess_Root->bound != NULL) {
+ 		char buf[BUFSIZE];
+ 		char *boundbuf;
+ 		boundbuf = (char *)getendbound();
+ 		if (boundbuf) {
+ 		  strcpy(buf, boundbuf);
+ 		  boundbuf = buf;
+ 		  putline(boundbuf, SmtpOut, m);
+ 		}
+ 		rmlastbound();
+ 	      }
+ 	  }
+ 	Mk_Log(LOG_DEBUG, "Processing done");
+ #endif /* EMIL */
  
  	/* terminate the message */
  	fprintf(SmtpOut, ".%s", m->m_eol);
  	if (Verbose && !HoldErrs)
*** ./util.c.orig	Fri May 29 08:14:00 1992
--- ./util.c	Wed Dec  1 08:17:26 1993
***************
*** 773,784 ****
--- 773,786 ----
  	{
  		buf[0] = '\0';
  		return (NULL);
  	}
+ #ifndef EMIL
  #ifndef BIT8
  	for (p = buf; *p != '\0'; p++)
  		*p &= ~0200;
  #endif /* !BIT8 */
+ #endif /* EMIL */
  	return (buf);
  }
  
  void
*** ./version.c.orig	Sun Feb 23 06:59:00 1992
--- ./version.c	Wed Dec  1 08:17:26 1993
***************
*** 44,64 ****
--- 44,73 ----
   *
   * Current source version: 5.67a
   * If Mail11v3 support is configured, append "+".
   * If 8-bit character set support is configured, append "8".
+  * If Emil support append "Emil1.0"
   * If you're right-handed and the temperature is above freezing, append xyzzy.
   * But I digress.
   */
  
  #ifdef MAIL11V3
  # ifdef BIT8
+ # ifdef EMIL
+ char	Version[] = "5.67a+-Emil1.1";
+ # else /* !EMIL */
  char	Version[] = "5.67a8+";
+ # endif /* EMIL */
  # else /* !BIT8 */
  char	Version[] = "5.67a+";
  # endif /* BIT8 */
  #else /* !MAIL11V3 */
  # ifdef BIT8
+ # ifdef EMIL
+ char	Version[] = "5.67a-Emil1.1";
+ # else /* !EMIL */
  char	Version[] = "5.67a8";
+ # endif /* EMIL */
  # else /* !BIT8 */
  char	Version[] = "5.67a";
  # endif /* BIT8 */
  #endif /* MAIL11V3 */
