*** ./collect.c.orig	Mon Nov 29 22:35:30 1993
--- ./collect.c	Thu Feb  3 12:58:56 1994
***************
*** 74,81 ****
--- 74,82 ----
  {
  	register FILE *tf;
  	char buf[MAXFIELD+2];
  	register char *p;
+ 
  #ifdef BIT8
  	char buf1[MAXFIELD+2];
  	CHARSET *ch;
  	char *chname, *chesc;
***************
*** 121,128 ****
--- 122,131 ----
  	 * of that.
  	 */
  	(void) sfgets(buf, sizeof buf, InChannel);
  	fixcrlf(buf, FALSE);
+ 
+ 
  #ifndef NOTUNIX
  	if (!SaveFrom && strncmp(buf, "From ", 5) == 0)
  	{
  		eatfrom(buf);
***************
*** 148,155 ****
--- 151,159 ----
  
  	do {
  		int c;
  
+ 
  		/* drop out on error */
  		if (ferror(InChannel))
  			break;
  
***************
*** 192,205 ****
  		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)
--- 196,238 ----
  		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)
***************
*** 208,215 ****
--- 241,249 ----
  		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);
***************
*** 233,241 ****
  			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'))
--- 267,274 ----
***************
*** 244,251 ****
--- 277,285 ----
  		/* 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.
  		*/
***************
*** 254,262 ****
--- 288,308 ----
  		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
+ 	if (MkMess_Curr->wait)
+ 	  {
+ 	    MkMess_Curr->enc = ENC7BIT;
+ 	    MkMess_Curr->type = TYPETEXT;
+ 	  }
+ 	mkcollqueueup();
+ #endif /* EMIL */
  
  	if (fflush(tf) != 0)
  		tferror(tf);
  	if (!sayok)
*** ./deliver.c.orig	Thu Dec  2 05:11:22 1993
--- ./deliver.c	Tue Feb  1 13:04:25 1994
***************
*** 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_mflags))
***************
*** 406,414 ****
  			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
--- 407,414 ----
***************
*** 460,468 ****
  				/* allow some space for trailing parms */
  				break;
  			}
  		}
! 	}
  
  	/* see if any addresses still exist */
  	if (tobuf[0] == '\0')
  	{
--- 460,468 ----
  				/* allow some space for trailing parms */
  				break;
  			}
  		}
!         }
  
  	/* see if any addresses still exist */
  	if (tobuf[0] == '\0')
  	{
***************
*** 807,818 ****
  	/*
  	**  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);
  
--- 807,874 ----
  	/*
  	**  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);
  
***************
*** 1501,1511 ****
  		}
  	}
  	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];
--- 1557,1586 ----
  		}
  	}
  	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];
***************
*** 1513,1525 ****
--- 1588,1605 ----
  				(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_mflags) &&
  			    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");
***************
*** 1534,1541 ****
--- 1614,1622 ----
  		ExitStat = EX_IOERR;
  	}
  	errno = 0;
  }
+ 
  /*
  **  MAILFILE -- Send a message to a file.
  **
  **	If the file has the setuid/setgid bits set, but NO execute
***************
*** 1575,1583 ****
  	**	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)
--- 1656,1664 ----
  	**	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)
***************
*** 1691,1698 ****
--- 1772,1782 ----
  	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)
  	{
***************
*** 1761,1772 ****
  		**/
  		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;
  		}
--- 1845,1857 ----
  		**/
  		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;
  		}
***************
*** 1780,1788 ****
  		}
  
  		/* 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())
--- 1865,1873 ----
  		}
  
  		/* 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())
***************
*** 1805,1812 ****
--- 1890,1910 ----
  	/*
  	**  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)
***************
*** 1827,1834 ****
--- 1925,1941 ----
  			 * 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))
***************
*** 1871,1878 ****
--- 1978,1995 ----
  
  		/* 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	Thu Dec  2 05:11:23 1993
--- ./envelope.c	Tue Feb  1 13:06:17 1994
***************
*** 156,164 ****
  	*/
  
  	if (failures > 0 && bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) &&
  	    ErrorMode != EM_QUIET)
! 		savemail(e);
  
  	/*
  	**  Instantiate or deinstantiate the queue.
  	*/
--- 156,164 ----
  	*/
  
  	if (failures > 0 && bitset(EF_FATALERRS|EF_TIMEOUT, e->e_flags) &&
  	    ErrorMode != EM_QUIET)
! 	    savemail(e);
  
  	/*
  	**  Instantiate or deinstantiate the queue.
  	*/
***************
*** 172,179 ****
--- 172,183 ----
  				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))
  	{
***************
*** 308,315 ****
--- 312,322 ----
  	define('c', cbuf, CurEnv);
  
  	/* time as integer, unix time, arpa time */
  	settime();
+ #ifdef EMIL
+ 	Mk_Tcl();
+ #endif /* EMIL */
  }
  /*
  **  SETTIME -- set the current time.
  **
*** ./queue.c.orig	Thu Dec  2 05:11:24 1993
--- ./queue.c	Tue Feb  1 12:47:26 1994
***************
*** 165,173 ****
--- 165,187 ----
  	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.
  	*/
  
***************
*** 195,202 ****
--- 209,217 ----
  		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);
***************
*** 204,211 ****
--- 219,227 ----
  		(void) fclose(dfp);
  		e->e_putbody = putbody;
  	}
  
+ 
  	/*
  	**  Output future work requests.
  	**	Priority and creation time should be first, since
  	**	they are required by orderq.
***************
*** 501,509 ****
  	*/
  
  	/* order the existing work requests */
  	(void) orderq(FALSE);
! 
  	/* process them once at a time */
  	while (WorkQ != NULL)
  	{
  		WORK *w = WorkQ;
--- 517,527 ----
  	*/
  
  	/* 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;
***************
*** 825,836 ****
  				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);
  
--- 843,876 ----
  				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	Thu Jul  8 22:09:44 1993
--- ./readcf.c	Tue Feb  1 12:47:27 1994
***************
*** 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	Thu Dec  2 05:11:25 1993
--- ./recipient.c	Tue Feb  1 12:47:27 1994
***************
*** 300,307 ****
--- 300,308 ----
  		}
  		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 Dec  2 05:00:18 1993
--- ./sendmail.h	Tue Feb  1 12:47:27 1994
***************
*** 211,218 ****
--- 211,223 ----
  	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 */
***************
*** 327,334 ****
--- 332,343 ----
  	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 */
  };
  
***************
*** 839,843 ****
--- 848,856 ----
  	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	Thu Jul  8 22:09:48 1993
--- ./usersmtp.c	Tue Feb  1 12:47:28 1994
***************
*** 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	Thu Jul  8 22:09:47 1993
--- ./util.c	Tue Feb  1 12:47:28 1994
***************
*** 796,807 ****
--- 796,809 ----
  	{
  		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	Wed Nov 10 18:10:53 1993
--- ./version.c	Tue Feb  1 13:09:16 1994
***************
*** 52,64 ****
--- 52,72 ----
  #ifdef MAIL11V3
  # ifdef BIT8
  char	Version[] = "5.67b8+";
  # else /* !BIT8 */
+ #ifdef EMIL
+ char Version[] = "5.67b+-Emil1.1";
+ #else
  char	Version[] = "5.67b+";
+ #endif /* EMIL */
  # endif /* BIT8 */
  #else /* !MAIL11V3 */
  # ifdef BIT8
  char	Version[] = "5.67b8";
  # else /* !BIT8 */
+ #ifdef EMIL
+ char	Version[] = "5.67b-Emil1.1";
+ #else
  char	Version[] = "5.67b";
+ #endif /* EMIL */
  # endif /* BIT8 */
  #endif /* MAIL11V3 */
*** ./conf.h.orig	Thu Dec  2 19:58:53 1993
--- ./conf.h	Tue Feb  1 12:53:46 1994
***************
*** 138,145 ****
--- 138,153 ----
   */
  /*# 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
   * use it, "Oh" must be set in sendmail.cf.
   */
