[comp.sources.misc] v20i068: procmail - mail processing program, Patch01

berg@messua.informatik.rwth-aachen.de (Stephen R. van den Berg) (06/26/91)

Submitted-by: Stephen R. van den Berg <berg@messua.informatik.rwth-aachen.de>
Posting-number: Volume 20, Issue 68
Archive-name: procmail/patch01
Patch-To: procmail: Volume 20, Issue 49-51
Environment: UNIX, sendmail

This patch file will upgrade procmail v2.02 to v2.03.

Fixes all the portability problems that have been reported to me.
Contains several cosmetic improvements.  Fixes two minor bugs.

Save the following in a file; cd procmail; and feed it to patch like in:
	patch -p < this_file_or_whatever_you_named_it

Check if no *.rej files were generated; rm all *.orig files in all
subdirectories. 
                              --
The latest version (currently v2.03) can be obtained directly from the
ftp-archive at:
	amaru.informatik.rwth-aachen.de (137.226.112.31)

	as compressed tar file:		pub/unix/procmail.tar.Z
	or in compressed shar format:	pub/unix/procmail.0?.Z

Stephen R. van den Berg.       
-----------------------------cut here------------------------------
diff -rc ../old/FEATURES ./FEATURES
*** ../old/FEATURES	Tue Jun 18 16:12:55 1991
--- ./FEATURES	Thu Jun 20 11:56:46 1991
***************
*** 49,54 ****
--- 49,55 ----
  	  standard mail programs)
  	+ Can split up mailboxes into the individual messages
  	+ Can split up digests into the individual messages
+ 	+ Can split up saved articles into the individual articles
  
  Feature summary for lockfile:
  	+ Provides NFS-secure lockfiles to shell script programmers
diff -rc ../old/HISTORY ./HISTORY
*** ../old/HISTORY	Tue Jun 18 16:12:55 1991
--- ./HISTORY	Thu Jun 20 11:56:47 1991
***************
*** 115,117 ****
--- 115,139 ----
  1991/06/12: v2.02
  	    Fixed typo in strstr replacement
  	    Fixed runaway line while logging long folder names
+ 1991/06/20: v2.03
+ 	    Added EX_OSFILE to include/sysexits.h (oversight)
+ 	    Slightly changed the terminate code in procmail (more reliable
+ 	       when forks did not succeed while filtering and signals arrived
+ 	       during a small window)
+ 	    Added a listing of all entries that can appear in autoconf.h
+ 	       to autoconf to simplify manual autoconf.h generation
+ 	    Changed formail to be able to split up collected articles (trivial)
+ 	    Edited include/string.h, strspn is of type int
+ 	    Changes to autoconf:
+ 	       Added strtol detection
+ 	       Enhanced const detection for braindamaged compilers
+ 	       Stopped using the function grepfor, changed it into a small
+ 		  script (Vltrix does not support functions in /bin/sh)
+ 	       Made the check for missing library parts more resistant against
+ 		  elaborate warnings from the C-compiler
+ 	    Fixed typo in retint.c (sleep with one redundant argument), hurray
+ 	       for prototypes
+ 	    Added MANSUFFIX macro to Makefile
+ 	    Avoided namespace conflict ("failurel") in lockfile.c for
+ 	       braindamaged compilers
+ 	    Renamed ultostr to avoided library conflict on some machines
diff -rc ../old/Makefile ./Makefile
*** ../old/Makefile	Tue Jun 18 16:12:46 1991
--- ./Makefile	Thu Jun 20 12:00:38 1991
***************
*** 1,10 ****
! #$Id: Makefile,v 2.0 1991/06/10 14:39:08 berg Rel $
  
  # change BASENAME to your home directory if need be
  BASENAME = /usr/local
  
  BINDIR	 = $(BASENAME)/bin
! MANDIR	 = $(BASENAME)/man/man1
  
  ########################################################################
  # Only edit below this line if you *think* you know what you are doing #
--- 1,11 ----
! #$Id: Makefile,v 2.3 1991/06/20 09:54:14 berg Rel $
  
  # change BASENAME to your home directory if need be
  BASENAME = /usr/local
  
  BINDIR	 = $(BASENAME)/bin
! MANSUFFIX= 1
! MANDIR	 = $(BASENAME)/man/man$(MANSUFFIX)
  
  ########################################################################
  # Only edit below this line if you *think* you know what you are doing #
***************
*** 41,52 ****
  formail: formail.$(O) common.$(O)
  	$(CC) $(CFLAGS) -o formail formail.$(O) common.$(O) ${LDFLAGS}
  
! _autotst: _autotst.c
! 	$(CC) $(CFLAGS) -o _autotst _autotst.c $(LDFLAGS)
  
  autoconf.h: autoconf Makefile
! 	/bin/sh autoconf
  
  $(OBJ): $(DEP)
  
  retint.$(O): $(DEP) exopen.h
--- 42,55 ----
  formail: formail.$(O) common.$(O)
  	$(CC) $(CFLAGS) -o formail formail.$(O) common.$(O) ${LDFLAGS}
  
! _autotst: _autotst.$(O)
! 	$(CC) $(CFLAGS) -o _autotst _autotst.$(O) $(LDFLAGS)
  
  autoconf.h: autoconf Makefile
! 	/bin/sh autoconf $(O)
  
+ Makefile:
+ 
  $(OBJ): $(DEP)
  
  retint.$(O): $(DEP) exopen.h
***************
*** 69,79 ****
  	$(CC) $(CFLAGS) -c $*.c
  
  install: all
! 	chmod 755 $(BINS)
  	cp $(BINS) $(BINDIR)
! 	chmod 644 man/procmail.1 man/lockfile.1 man/formail.1
! 	cp man/procmail.1 man/lockfile.1 man/formail.1 $(MANDIR)
  
  clean:
  	$(RM) $(OBJ) common.$(O) lockfile.$(O) exopen.$(O) retint.$(O) \
! formail.$(O) $(BINS) autoconf.h _autotst*
--- 72,86 ----
  	$(CC) $(CFLAGS) -c $*.c
  
  install: all
! 	chmod 0755 $(BINS)
  	cp $(BINS) $(BINDIR)
! 	chmod 0644 man/procmail.$(MANSUFFIX) man/lockfile.$(MANSUFFIX) \
! man/formail.$(MANSUFFIX)
! 	cp man/procmail.$(MANSUFFIX) man/lockfile.$(MANSUFFIX) \
! man/formail.$(MANSUFFIX) $(MANDIR)
  
+ again: all
+ 
  clean:
  	$(RM) $(OBJ) common.$(O) lockfile.$(O) exopen.$(O) retint.$(O) \
! formail.$(O) $(BINS) autoconf.h _autotst* grepfor
diff -rc ../old/README ./README
*** ../old/README	Tue Jun 18 16:12:28 1991
--- ./README	Thu Jun 20 11:56:57 1991
***************
*** 24,30 ****
  
  ------------------------------ DESCRIPTION -----------------------------------
  
! The procmail mail processing program. (v2.02 1991/06/12)
  
  Can be used to create mail-servers, mailing lists, sort your incoming mail
  into separate folders/files (real convenient when subscribing to one or more
--- 24,30 ----
  
  ------------------------------ DESCRIPTION -----------------------------------
  
! The procmail mail processing program. (v2.03 1991/06/20)
  
  Can be used to create mail-servers, mailing lists, sort your incoming mail
  into separate folders/files (real convenient when subscribing to one or more
***************
*** 73,78 ****
--- 73,86 ----
  	6369 ZG Simpelveld
  	The Netherlands
  
+ ----------------------
+ A recent version can be picked up at various comp.sources.misc archives.
+ The latest version can be obtained directly from the ftp-archive at:
+ 
+ 	amaru.informatik.rwth-aachen.de (137.226.112.31)
+ 
+ 	as compressed tar file:		pub/unix/procmail.tar.Z
+ 	or in compressed shar format:	pub/unix/procmail.0?.Z
  ----------------------
  
  P.S. I don't mind if you feed the program files through your favourite C
diff -rc ../old/autoconf ./autoconf
*** ../old/autoconf	Tue Jun 18 16:12:48 1991
--- ./autoconf	Thu Jun 20 11:56:59 1991
***************
*** 1,10 ****
- #!/bin/sh
- #$Id: autoconf,v 2.1 1991/06/11 12:59:16 berg Rel $
  
! SHELL=/bin/sh || exec /bin/sh <autoconf # we're in a csh, feed myself to sh
  
  ACONF=autoconf.h
! trap "rm $ACONF;exit 1" 1 2 3 15
  cat >$ACONF <<HERE
  /* This file was automagically generated by autoconf */
  
--- 1,37 ----
  
! #$Id: autoconf,v 2.4 1991/06/20 09:54:14 berg Rel $
  
+ SHELL=/bin/sh || exec /bin/sh autoconf $1 # we're in a csh, feed myself to sh
+ 
+ # All possible entries in autoconf.h:
+ #
+ #	#define const
+ #	#define volatile
+ #	#define void char
+ #	typedef int mode_t;
+ #	typedef int pid_t;
+ #	typedef unsigned size_t;
+ #	typedef long time_t;
+ #	#define NOmemmove
+ #	#define NObcopy
+ #	#define NOstrstr
+ #	#define strtol(str,ptr,base) ((long)atoi(str))
+ 
+ PATH=:$PATH
+ export SHELL
  ACONF=autoconf.h
! trap "exit 1" 1 2 3 15
! 
! cat >grepfor <<HERE
! if fgrep "\$1" _autotst.rrr >/dev/null
! then
!  echo "\$2" >>$ACONF
!  exit 0
! fi
! exit 1
! HERE
! chmod 0755 grepfor
! 
  cat >$ACONF <<HERE
  /* This file was automagically generated by autoconf */
  
***************
*** 14,43 ****
  #	   hence the const test has to precede all others.
  
  cat >_autotst.c <<HERE
! main(){const int i;return 0;}
  HERE
  
  echo 'Testing for const'
! if make _autotst >/dev/null 2>&1
! then
! :
! else
!  echo '#define const' >>$ACONF
! fi
! rm -f _autotst _autotst.o
  
  cat >_autotst.c <<HERE
  main(){volatile int i;return 0;}
  HERE
   
  echo 'Testing for volatile'
! if make _autotst >/dev/null 2>&1
  then
  :
  else
   echo '#define volatile' >>$ACONF
  fi
! rm -f _autotst _autotst.o
  
  cat >_autotst.c <<HERE
  main(){int i;i= -1;return i=-i;}
--- 41,68 ----
  #	   hence the const test has to precede all others.
  
  cat >_autotst.c <<HERE
! main(){const char*p;const char*q;
!  p="t";q=p;return 0;}
  HERE
  
  echo 'Testing for const'
! make _autotst.$1 >_autotst.rrr 2>&1
! rm -f _autotst.$1
  
+ grepfor const '#define const'
+ 
  cat >_autotst.c <<HERE
  main(){volatile int i;return 0;}
  HERE
   
  echo 'Testing for volatile'
! if make _autotst.$1 >/dev/null 2>&1
  then
  :
  else
   echo '#define volatile' >>$ACONF
  fi
! rm -f _autotst.$1
  
  cat >_autotst.c <<HERE
  main(){int i;i= -1;return i=-i;}
***************
*** 51,57 ****
   echo 'Aha, this one is genuine antique!'
   echo '#define void char' >>$ACONF
  fi
! rm -f _autotst _autotst.o
  
  
  cat >_autotst.c <<HERE
--- 76,82 ----
   echo 'Aha, this one is genuine antique!'
   echo '#define void char' >>$ACONF
  fi
! rm -f _autotst _autotst.$1
  
  
  cat >_autotst.c <<HERE
***************
*** 66,81 ****
  HERE
  
  echo 'Testing for void*,size_t,pid_t,time_t,mode_t'
! make _autotst >_autotst.rrr 2>&1
! rm -f _autotst _autotst.o
  
- grepfor(){
- if fgrep "$1" _autotst.rrr >/dev/null
- then
-  echo "$2" >>$ACONF
- fi
- }
- 
  grepfor void '#define void char'
  grepfor size_t 'typedef unsigned size_t;'
  grepfor pid_t 'typedef int pid_t;'
--- 91,99 ----
  HERE
  
  echo 'Testing for void*,size_t,pid_t,time_t,mode_t'
! make _autotst.$1 >_autotst.rrr 2>&1
! rm -f _autotst.$1
  
  grepfor void '#define void char'
  grepfor size_t 'typedef unsigned size_t;'
  grepfor pid_t 'typedef int pid_t;'
***************
*** 84,107 ****
  
  cat >_autotst.c <<HERE
  #include "includes.h"
! main(){char a[1];
!  setpwent();endpwent();memmove(a,"t",1);bcopy("t",a,1);strstr(a,"t");return 0;}
  HERE
  
! echo 'Testing for memmove & strstr'
  make _autotst >_autotst.rrr 2>&1
! rm -f _autotst _autotst.o
  
! if fgrep memmove _autotst.rrr >/dev/null
! then
!  echo '#define NOmemmove' >>$ACONF
!  grepfor bcopy '#define NObcopy'
! fi
  grepfor strstr '#define NOstrstr'
  grepfor setpwent '#define setpwent()'
  grepfor endpwent '#define endpwent()'
  
! rm -f _autotst*
  
  echo -----------------------------autoconf.h-----------------------------------
  cat autoconf.h
--- 102,124 ----
  
  cat >_autotst.c <<HERE
  #include "includes.h"
! main(){char a[2];
!  setpwent();endpwent();memmove(a,"0",1);bcopy("0",a,1);strstr(a,"0");
!  strtol("0",(char**)0,10);return 0;}
  HERE
  
! echo 'Testing for memmove, strstr & strtol'
! make _autotst.$1 >/dev/null 2>&1
  make _autotst >_autotst.rrr 2>&1
! rm -f _autotst _autotst.$1
  
! grepfor memmove '#define NOmemmove' && grepfor bcopy '#define NObcopy'
  grepfor strstr '#define NOstrstr'
  grepfor setpwent '#define setpwent()'
  grepfor endpwent '#define endpwent()'
+ grepfor strtol '#define strtol(str,ptr,base) ((long)atoi(str))'
  
! rm -f _autotst* grepfor
  
  echo -----------------------------autoconf.h-----------------------------------
  cat autoconf.h
diff -rc ../old/common.c ./common.c
*** ../old/common.c	Tue Jun 18 16:12:30 1991
--- ./common.c	Thu Jun 20 11:57:00 1991
***************
*** 9,15 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: common.c,v 2.0 1991/06/10 14:35:35 berg Rel $";
  #endif
  #include "includes.h"
  
--- 9,15 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: common.c,v 2.1 1991/06/19 17:41:41 berg Rel $";
  #endif
  #include "includes.h"
  
***************
*** 42,48 ****
  
  #include "shell.h"
  
! shexec(argv)const char *const*argv;{int i;const char**newargv,**p;
   execvp(*argv,argv);	 /* if this one fails, we retry it as a shell script */
   for(p=(const char**)argv,i=1;i++,*p++;);	      /* count the arguments */
   newargv=malloc(i*sizeof*p);
--- 42,48 ----
  
  #include "shell.h"
  
! shexec(argv)const char*const*argv;{int i;const char**newargv,**p;
   execvp(*argv,argv);	 /* if this one fails, we retry it as a shell script */
   for(p=(const char**)argv,i=1;i++,*p++;);	      /* count the arguments */
   newargv=malloc(i*sizeof*p);
diff -rc ../old/formail.c ./formail.c
*** ../old/formail.c	Tue Jun 18 16:12:51 1991
--- ./formail.c	Thu Jun 20 11:57:09 1991
***************
*** 11,19 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: formail.c,v 2.3 1991/06/12 10:50:21 berg Rel $";
  #endif
! static char rcsdate[]="$Date: 1991/06/12 10:50:21 $";
  #include "config.h"			/* I know, overkill, only need BinSh */
  #include "includes.h"
  
--- 11,19 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: formail.c,v 2.6 1991/06/19 17:47:00 berg Rel $";
  #endif
! static char rcsdate[]="$Date: 1991/06/19 17:47:00 $";
  #include "config.h"			/* I know, overkill, only need BinSh */
  #include "includes.h"
  
***************
*** 32,38 ****
  static const char From[]=FROM,replyto[]="Reply-To:",Fromm[]="From:",
   returnpath[]="Return-Path",sender[]="Sender:",outofmem[]="Out of memory\n",
   subject[]="Subject:",re[]=" Re:",couldntw[]="Couldn't write to stdout",
!  references[]="References:",messageid[]="Message-ID:",Date[]="Date:";
  const char binsh[]=BinSh;
  static struct {const char*const head;const int len,wrepl;}sest[]={
   {sender,STRLEN(sender),0},{replyto,STRLEN(replyto),4},
--- 32,39 ----
  static const char From[]=FROM,replyto[]="Reply-To:",Fromm[]="From:",
   returnpath[]="Return-Path",sender[]="Sender:",outofmem[]="Out of memory\n",
   subject[]="Subject:",re[]=" Re:",couldntw[]="Couldn't write to stdout",
!  references[]="References:",messageid[]="Message-ID:",Date[]="Date:",
!  article[]="Article ";
  const char binsh[]=BinSh;
  static struct {const char*const head;const int len,wrepl;}sest[]={
   {sender,STRLEN(sender),0},{replyto,STRLEN(replyto),4},
***************
*** 44,50 ****
  #define refr	rex[1]
  #define msid	rex[2]
  static struct {const char*const hedr;const int lnr;}cdigest[]={
!  {Fromm,STRLEN(Fromm)},{Date,STRLEN(Date)},{subject,STRLEN(subject)}};
  #define mxl(a,b)	mx(STRLEN(a),STRLEN(b))
  #define dig_HDR_LEN	mx(mxl(From,Fromm),mxl(Date,subject))
  static errout,oldstdout;
--- 45,52 ----
  #define refr	rex[1]
  #define msid	rex[2]
  static struct {const char*const hedr;const int lnr;}cdigest[]={
!  {Fromm,STRLEN(Fromm)},{Date,STRLEN(Date)},{subject,STRLEN(subject)},
!  {article,STRLEN(article)}};
  #define mxl(a,b)	mx(STRLEN(a),STRLEN(b))
  #define dig_HDR_LEN	mx(mxl(From,Fromm),mxl(Date,subject))
  static errout,oldstdout;
***************
*** 73,80 ****
  
  #include "shell.h"
  
! main(argc,argv)const char*const argv[];{time_t t;
!  int i,lastm,nowm,thelen=0,split=0,force=0,bogus=1,every=0,areply=0,
     trust=0,digest=0,nowait=0;
   size_t buflen,p=0,lnl=0,thename,ll;
   char*buf,*chp;
--- 75,82 ----
  
  #include "shell.h"
  
! main(lastm,argv)const char*const argv[];{time_t t;
!  int i,nowm,thelen=0,split=0,force=0,bogus=1,every=0,areply=0,
     trust=0,digest=0,nowait=0;
   size_t buflen,p=0,lnl=0,thename,ll;
   char*buf,*chp;
diff -rc ../old/goodies.c ./goodies.c
*** ../old/goodies.c	Tue Jun 18 16:12:36 1991
--- ./goodies.c	Thu Jun 20 11:57:11 1991
***************
*** 9,15 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: goodies.c,v 2.1 1991/06/11 12:59:16 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
--- 9,15 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: goodies.c,v 2.3 1991/06/19 17:41:41 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
***************
*** 34,40 ****
  	 if(got>NORMAL_TEXT)
  early_eof:  log(unexpeof);
  ready:	 if(got!=SKIPPING_SPACE||sarg)	  /* not terminated yet or sarg==2 ? */
! ready0:	    *p++='\0';
  	 *p=TMNATE;return;
        case '\\':
  	 if(got==SINGLE_QUOTED)
--- 34,40 ----
  	 if(got>NORMAL_TEXT)
  early_eof:  log(unexpeof);
  ready:	 if(got!=SKIPPING_SPACE||sarg)	  /* not terminated yet or sarg==2 ? */
! 	    *p++='\0';
  	 *p=TMNATE;return;
        case '\\':
  	 if(got==SINGLE_QUOTED)
***************
*** 108,114 ****
  	       *startb++=i;
  	    *startb='\0';
  	    if(i!='}'){
! badsubst:      log("Bad substitution of");logqnl(buf2);continue;}
  	    i='\0';}
  	 else if(alphanum(i)){					    /* $name */
  	    do *startb++=i;
--- 108,114 ----
  	       *startb++=i;
  	    *startb='\0';
  	    if(i!='}'){
! 	       log("Bad substitution of");logqnl(buf2);continue;}
  	    i='\0';}
  	 else if(alphanum(i)){					    /* $name */
  	    do *startb++=i;
***************
*** 117,123 ****
  	       i='\0';
  	    *startb='\0';}
  	 else if(i=='$'){					   /* $$=pid */
! 	    ultostr(0,(unsigned long)thepid,p);i='\0';goto eofstr;}
  	 else{
  	    *p++='$';goto newchar;}		       /* not a substitution */
  	 startb=(char*)tgetenv(buf2);
--- 117,123 ----
  	       i='\0';
  	    *startb='\0';}
  	 else if(i=='$'){					   /* $$=pid */
! 	    ultstr(0,(unsigned long)thepid,p);i='\0';goto eofstr;}
  	 else{
  	    *p++='$';goto newchar;}		       /* not a substitution */
  	 startb=(char*)tgetenv(buf2);
***************
*** 151,157 ****
     if(got<=SKIPPING_SPACE)		 /* should we bother to change mode? */
        got=NORMAL_TEXT;}}
  
! ultostr(minwidth,val,dest)unsigned long val;char*dest;{int i;unsigned long j;
   j=val;i=0;					   /* a beauty, isn't it :-) */
   do i++;					   /* determine needed width */
   while(j/=10);
--- 151,157 ----
     if(got<=SKIPPING_SPACE)		 /* should we bother to change mode? */
        got=NORMAL_TEXT;}}
  
! ultstr(minwidth,val,dest)unsigned long val;char*dest;{int i;unsigned long j;
   j=val;i=0;					   /* a beauty, isn't it :-) */
   do i++;					   /* determine needed width */
   while(j/=10);
diff -rc ../old/includes.h ./includes.h
*** ../old/includes.h	Tue Jun 18 16:12:26 1991
--- ./includes.h	Thu Jun 20 12:03:05 1991
***************
*** 1,4 ****
! /*$Id: includes.h,v 2.2 1991/06/11 13:06:52 berg Rel $*/
  
  #include "autoconf.h"
  	/* not all the "library identifiers" specified here need to be
--- 1,4 ----
! /*$Id: includes.h,v 2.3 1991/06/18 11:39:23 berg Rel $*/
  
  #include "autoconf.h"
  	/* not all the "library identifiers" specified here need to be
***************
*** 15,21 ****
  #include <stdlib.h>		/* getenv() malloc() realloc() free()
  				   strtol() */
  #include <time.h>		/* time() ctime() time_t */
! #include <fcntl.h>		/* O_RDONLY O_WRONLY O_APPEND */
  #include <pwd.h>		/* getpwuid() struct passwd */
  #include <sys/wait.h>		/* wait() */
  #include <sys/utsname.h>	/* uname() utsname */
--- 15,21 ----
  #include <stdlib.h>		/* getenv() malloc() realloc() free()
  				   strtol() */
  #include <time.h>		/* time() ctime() time_t */
! #include <fcntl.h>		/* O_RDONLY O_WRONLY O_APPEND O_CREAT O_EXCL */
  #include <pwd.h>		/* getpwuid() struct passwd */
  #include <sys/wait.h>		/* wait() */
  #include <sys/utsname.h>	/* uname() utsname */
***************
*** 26,32 ****
  				   strspn() strcspn() strchr() strcmp()
  				   strncmp() strpbrk() strstr() memmove() */
  #include <errno.h>		/* EINTR EEXIST EMFILE ENFILE */
! #include <sysexits.h>		/* EX_OK EX_UNAVAILABLE EX_OSERR
  				   EX_CANTCREAT EX_IOERR */
  #ifndef O_SYNC
  #define O_SYNC		0
--- 26,32 ----
  				   strspn() strcspn() strchr() strcmp()
  				   strncmp() strpbrk() strstr() memmove() */
  #include <errno.h>		/* EINTR EEXIST EMFILE ENFILE */
! #include <sysexits.h>		/* EX_OK EX_UNAVAILABLE EX_OSERR EX_OSFILE
  				   EX_CANTCREAT EX_IOERR */
  #ifndef O_SYNC
  #define O_SYNC		0
diff -rc ../old/lockfile.c ./lockfile.c
*** ../old/lockfile.c	Tue Jun 18 16:12:35 1991
--- ./lockfile.c	Thu Jun 20 11:57:13 1991
***************
*** 7,15 ****
   *	This file can be freely copied for any use.			*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: lockfile.c,v 2.1 1991/06/11 14:00:41 berg Rel $";
  #endif
! static char rcsdate[]="$Date: 1991/06/11 14:00:41 $";
  #include "config.h"		       /* overkill, I know, only need DIRSEP */
  #include "includes.h"
  
--- 7,15 ----
   *	This file can be freely copied for any use.			*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: lockfile.c,v 2.3 1991/06/19 17:41:41 berg Rel $";
  #endif
! static char rcsdate[]="$Date: 1991/06/19 17:41:41 $";
  #include "config.h"		       /* overkill, I know, only need DIRSEP */
  #include "includes.h"
  
***************
*** 21,27 ****
   exitflag=1;}
  
  main(argc,argv)const int argc;const char*argv[];{const char**p,*cp;
!  int sleepsec,retries,i,invert,force,suspend,retval=0;
   static char usage[]=
     "Usage: lockfile -nnn | -rnnn | -! | -lnnn | -snnn | file ...\n";
   sleepsec=8;force=retries=invert=0;suspend=16;thepid=getpid();
--- 21,27 ----
   exitflag=1;}
  
  main(argc,argv)const int argc;const char*argv[];{const char**p,*cp;
!  int sleepsec,retries,invert,force,suspend,retval=0;
   static char usage[]=
     "Usage: lockfile -nnn | -rnnn | -! | -lnnn | -snnn | file ...\n";
   sleepsec=8;force=retries=invert=0;suspend=16;thepid=getpid();
***************
*** 39,45 ****
         case 's':suspend=strtol(cp+2,(char**)0,10);break;
         default:
  	  if(cp[1]-'0'>(unsigned)9){
! 	     putse(usage);retval=EX_USAGE;goto failure;}
  	  if(sleepsec>=0)
  	     sleepsec=strtol(cp+1,(char**)0,10);}
      else
--- 39,45 ----
         case 's':suspend=strtol(cp+2,(char**)0,10);break;
         default:
  	  if(cp[1]-'0'>(unsigned)9){
! 	     putse(usage);retval=EX_USAGE;goto failurel;}
  	  if(sleepsec>=0)
  	     sleepsec=strtol(cp+1,(char**)0,10);}
      else
***************
*** 48,54 ****
        else{
  	 while(0>NFSxopen(cp)){struct stat buf;time_t t;
  	    if(exitflag||retries==1){
! failure:       sleepsec= -1;p[-1]=0;goto again;}
  	    if(force&&(t=time((time_t*)0),!stat(cp,&buf))&&
  	       force<t-buf.st_mtime){
  	       unlink(cp);putse("Forcing lock on \"");putse(cp);putse("\"\n");
--- 48,54 ----
        else{
  	 while(0>NFSxopen(cp)){struct stat buf;time_t t;
  	    if(exitflag||retries==1){
! failurel:      sleepsec= -1;p[-1]=0;goto again;}
  	    if(force&&(t=time((time_t*)0),!stat(cp,&buf))&&
  	       force<t-buf.st_mtime){
  	       unlink(cp);putse("Forcing lock on \"");putse(cp);putse("\"\n");
***************
*** 62,68 ****
  putse(a)char*a;{char*b;
   b=a-1;
   while(*++b);
!  write(STDERR,a,b-a);}
  
  #include "exopen.h"
  
--- 62,68 ----
  putse(a)char*a;{char*b;
   b=a-1;
   while(*++b);
!  write(STDERR,a,(size_t)(b-a));}
  
  #include "exopen.h"
  
***************
*** 79,86 ****
  void*tmalloc(len)const size_t len;{				     /* stub */
   return malloc(len);}
  
! ropen(name,mode,mask)const char*const name;const mode_t mask;{	     /* stub */
!  return open(name,mode,mask);}
  
  rclose(fd)const int fd;{					     /* stub */
   return close(fd);}
--- 79,86 ----
  void*tmalloc(len)const size_t len;{				     /* stub */
   return malloc(len);}
  
! ropen(name,mode,mask)const char*const name;const int mode;const mode_t mask;{
!  return open(name,mode,mask);}					     /* stub */
  
  rclose(fd)const int fd;{					     /* stub */
   return close(fd);}
diff -rc ../old/nonint.c ./nonint.c
*** ../old/nonint.c	Tue Jun 18 16:12:38 1991
--- ./nonint.c	Thu Jun 20 11:57:17 1991
***************
*** 9,15 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: nonint.c,v 2.0 1991/06/10 14:35:35 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
--- 9,15 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: nonint.c,v 2.2 1991/06/19 17:41:41 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
***************
*** 73,79 ****
  void sterminate(){static const char*const msg[]={newline,0,
   "memory\n","fork\n","file descriptor\n"};
   signal(SIGTERM,SIG_IGN);signal(SIGHUP,SIG_IGN);signal(SIGINT,SIG_IGN);
!  if(pidchild)		    /* don't kill what is not ours, we might be root */
     kill(pidchild,SIGTERM);
   if(!nextexit){
     nextexit=1;log("Terminating prematurely");
--- 73,79 ----
  void sterminate(){static const char*const msg[]={newline,0,
   "memory\n","fork\n","file descriptor\n"};
   signal(SIGTERM,SIG_IGN);signal(SIGHUP,SIG_IGN);signal(SIGINT,SIG_IGN);
!  if(pidchild>0)		    /* don't kill what is not ours, we might be root */
     kill(pidchild,SIGTERM);
   if(!nextexit){
     nextexit=1;log("Terminating prematurely");
***************
*** 84,91 ****
  
  void stermchild(){
   signal(SIGHUP,SIG_IGN);signal(SIGINT,SIG_IGN);signal(SIGQUIT,SIG_IGN);
!  signal(SIGTERM,SIG_IGN);kill(pidfilt,SIGTERM);kill(thepid,SIGQUIT);
!  log("Rescue of unfiltered data ");
   if(dump(PWRB,backblock,backlen)) /* pump back the data through the backpipe */
      log("failed\n");
   else
--- 84,93 ----
  
  void stermchild(){
   signal(SIGHUP,SIG_IGN);signal(SIGINT,SIG_IGN);signal(SIGQUIT,SIG_IGN);
!  signal(SIGTERM,SIG_IGN);
!  if(pidfilt>0)		    /* don't kill what is not ours, we might be root */
!    kill(pidfilt,SIGTERM);
!  kill(thepid,SIGQUIT);log("Rescue of unfiltered data ");
   if(dump(PWRB,backblock,backlen)) /* pump back the data through the backpipe */
      log("failed\n");
   else
***************
*** 174,180 ****
  char*tstrdup(a)const char*const a;{int i;
   i=strlen(a)+1;return tmemmove(malloc(i),a,i);}
  
! const char*tgetenv(a)const char*a;{const char*b;
   return(b=getenv(a))?b:"";}
  
  char*cstr(a,b)const char*const a,*const b;{	/* dynamic buffer management */
--- 176,182 ----
  char*tstrdup(a)const char*const a;{int i;
   i=strlen(a)+1;return tmemmove(malloc(i),a,i);}
  
! const char*tgetenv(a)const char*const a;{const char*b;
   return(b=getenv(a))?b:"";}
  
  char*cstr(a,b)const char*const a,*const b;{	/* dynamic buffer management */
diff -rc ../old/procmail.c ./procmail.c
*** ../old/procmail.c	Tue Jun 18 16:12:37 1991
--- ./procmail.c	Thu Jun 20 11:57:18 1991
***************
*** 11,17 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: procmail.c,v 2.3 1991/06/12 10:23:06 berg Rel $";
  #endif
  #include "config.h"
  #define MAIN
--- 11,17 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: procmail.c,v 2.6 1991/06/19 17:41:41 berg Rel $";
  #endif
  #include "config.h"
  #define MAIN
***************
*** 18,24 ****
  #include "procmail.h"
  #include "shell.h"
  
! #define VERSION "procmail v2.02 1991/06/12 written by Stephen R.van den Berg\n\
  \t\t\t\tberg@messua.informatik.rwth-aachen.de\n\
  \t\t\t\tberg@physik.tu-muenchen.de\n"
  
--- 18,24 ----
  #include "procmail.h"
  #include "shell.h"
  
! #define VERSION "procmail v2.03 1991/06/20 written by Stephen R.van den Berg\n\
  \t\t\t\tberg@messua.informatik.rwth-aachen.de\n\
  \t\t\t\tberg@physik.tu-muenchen.de\n"
  
***************
*** 58,64 ****
   if(0>opena(devnull)||0>opena(console))
     return EX_OSFILE;
   setbuf(stdin,(char*)0);buf=malloc(linebuf);buf2=malloc(linebuf);chdir(tmp);
!  ultostr(0,(unsigned long)(i=getuid()),buf);
   setpwent();
   {struct passwd*pass;
   if(pass=getpwuid(i)){			/* find user defaults in /etc/passwd */
--- 58,64 ----
   if(0>opena(devnull)||0>opena(console))
     return EX_OSFILE;
   setbuf(stdin,(char*)0);buf=malloc(linebuf);buf2=malloc(linebuf);chdir(tmp);
!  ultstr(0,(unsigned long)(i=getuid()),buf);
   setpwent();
   {struct passwd*pass;
   if(pass=getpwuid(i)){			/* find user defaults in /etc/passwd */
***************
*** 279,285 ****
   log(buf);i-=i%TABWIDTH;		     /* tell where we last dumped it */
   do log(TABCHAR);
   while((i+=TABWIDTH)<LENoffset);
!  ultostr(7,lastdump,buf);log(buf);log(newline);terminate();}
  
  dirmail(){struct stat stbuf;		/* directory name is expected in buf */
   strcpy(buf2,strcat(buf,MCDIRSEP));
--- 279,285 ----
   log(buf);i-=i%TABWIDTH;		     /* tell where we last dumped it */
   do log(TABCHAR);
   while((i+=TABWIDTH)<LENoffset);
!  ultstr(7,lastdump,buf);log(buf);log(newline);terminate();}
  
  dirmail(){struct stat stbuf;		/* directory name is expected in buf */
   strcpy(buf2,strcat(buf,MCDIRSEP));
diff -rc ../old/retint.c ./retint.c
*** ../old/retint.c	Tue Jun 18 16:12:40 1991
--- ./retint.c	Thu Jun 20 11:57:21 1991
***************
*** 9,15 ****
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: retint.c,v 2.0 1991/06/10 14:35:35 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
--- 9,15 ----
   *									*
   ************************************************************************/
  #ifdef	RCS
! static char rcsid[]="$Id: retint.c,v 2.4 1991/06/19 17:45:35 berg Rel $";
  #endif
  #include "config.h"
  #include "procmail.h"
***************
*** 52,59 ****
   while(!flaggerd)
     suspend();}					       /* to prevent polling */
  
! grepin(expr,source,len,casesens)const char*const expr,*const source;long len;{
!  pid_t pid;int poutfd[2];static const char*newargv[5]={0,"-e"};
   newargv[3]=casesens?(char*)0:"-i";*newargv=tgetenv(grep);newargv[2]=expr;
   rpipe(poutfd);
   if(!(pid=sfork())){					       /* start grep */
--- 52,60 ----
   while(!flaggerd)
     suspend();}					       /* to prevent polling */
  
! grepin(expr,source,len,casesens)const char*const expr,*const source;long len;
!  const int casesens;{pid_t pid;int poutfd[2];
!  static const char*newargv[5]={0,"-e"};
   newargv[3]=casesens?(char*)0:"-i";*newargv=tgetenv(grep);newargv[2]=expr;
   rpipe(poutfd);
   if(!(pid=sfork())){					       /* start grep */
***************
*** 153,159 ****
   while(0>(i=read(fd,a,(size_t)len))&&errno==EINTR);
   return i;}
  
! ropen(name,mode,mask)const char*const name;const mode_t mask;{int i,r;
   for(r=noresretry;0>(i=open(name,mode,mask));)	       /* a sysV secure open */
     if(errno!=EINTR)
        if(!((errno==EMFILE||errno==ENFILE)&&(r<0||r--)))
--- 154,161 ----
   while(0>(i=read(fd,a,(size_t)len))&&errno==EINTR);
   return i;}
  
! ropen(name,mode,mask)const char*const name;const int mode;const mode_t mask;{
!  int i,r;
   for(r=noresretry;0>(i=open(name,mode,mask));)	       /* a sysV secure open */
     if(errno!=EINTR)
        if(!((errno==EMFILE||errno==ENFILE)&&(r<0||r--)))
***************
*** 191,200 ****
  	 else{
  	    log("Forcing lock on");logqnl(name);suspend();}}}
     else{		       /* maybe filename too long, shorten and retry */
!       if(0<(i=strlen(name)-1)&&!strchr(dirsep,(name[i-1]))){
  	 name[i]='\0';continue;}
        log("Lockfailure on");logqnl(name);return;}
!    sleep(DEFlocksleep,locksleep);
     if(nextexit)
        goto term;}}
  
--- 193,202 ----
  	 else{
  	    log("Forcing lock on");logqnl(name);suspend();}}}
     else{		       /* maybe filename too long, shorten and retry */
!       if(0<(i=strlen(name)-1)&&!strchr(dirsep,name[i-1])){
  	 name[i]='\0';continue;}
        log("Lockfailure on");logqnl(name);return;}
!    sleep((unsigned)locksleep);
     if(nextexit)
        goto term;}}
  
diff -rc ../old/include/stdlib.h ./include/stdlib.h
*** ../old/include/stdlib.h	Tue Jun 18 16:12:14 1991
--- ./include/stdlib.h	Thu Jun 20 11:56:35 1991
***************
*** 1,3 ****
- #define strtol(str,ptr,base)    ((long)atoi(str))
  void*malloc(),*realloc();
  const char*getenv();
--- 1,2 ----
diff -rc ../old/include/string.h ./include/string.h
*** ../old/include/string.h	Tue Jun 18 16:12:18 1991
--- ./include/string.h	Thu Jun 20 11:56:36 1991
***************
*** 1,3 ****
  #include <strings.h>
  
! char*strchr(),*strpbrk(),*strspn(),*strcspn();
--- 1,3 ----
  #include <strings.h>
  
! char*strchr(),*strpbrk();
diff -rc ../old/include/sysexits.h ./include/sysexits.h
*** ../old/include/sysexits.h	Tue Jun 18 16:12:17 1991
--- ./include/sysexits.h	Thu Jun 20 11:56:36 1991
***************
*** 1,8 ****
!                 /* Standard exit codes, original list maintained
!                    by Eric Allman (eric@berkeley, ucbvax!eric)   */
! #define EX_OK           0
! #define EX_USAGE        64
! #define EX_UNAVAILABLE  69
! #define EX_OSERR        71
! #define EX_CANTCREAT    73
! #define EX_IOERR        74
--- 1,9 ----
! 		/* Standard exit codes, original list maintained
! 		   by Eric Allman (eric@berkeley, ucbvax!eric)	 */
! #define EX_OK		0
! #define EX_USAGE	64
! #define EX_UNAVAILABLE	69
! #define EX_OSERR	71
! #define EX_OSFILE	72
! #define EX_CANTCREAT	73
! #define EX_IOERR	74
diff -rc ../old/man/formail.1 ./man/formail.1
*** ../old/man/formail.1	Tue Jun 18 16:12:23 1991
--- ./man/formail.1	Thu Jun 20 11:57:15 1991
***************
*** 2,8 ****
  .ds Rv \\$3
  .ds Dt \\$4
  ..
! .Id $Id: formail.1,v 2.0 1991/06/10 17:37:18 berg Rel $
  .de Sh
  .br
  .ne 9
--- 2,8 ----
  .ds Rv \\$3
  .ds Dt \\$4
  ..
! .Id $Id: formail.1,v 2.1 1991/06/18 11:30:15 berg Rel $
  .de Sh
  .br
  .ne 9
***************
*** 42,48 ****
  .B formail
  is a filter that can be used to force mail into mailbox format, perform real
  rigorous `From ' escaping, generate auto-replying headers or split up a
! mailbox/digest file.  The mail/mailbox contents will be expected on stdin.
  .LP
  If formail is supposed to determine the sender of the mail, but is unable
  to find any, it will substitute `foo@bar'.
--- 42,49 ----
  .B formail
  is a filter that can be used to force mail into mailbox format, perform real
  rigorous `From ' escaping, generate auto-replying headers or split up a
! mailbox/digest/articles file.  The mail/mailbox/article contents will be
! expected on stdin.
  .LP
  If formail is supposed to determine the sender of the mail, but is unable
  to find any, it will substitute `foo@bar'.
***************
*** 85,91 ****
  message (this is normally not the case).
  .Tp
  .B \-d
! Enables formail to split up digests into their original messages.
  .Tp
  .I "\fB\+\fPskip"
  Skip the first
--- 86,92 ----
  message (this is normally not the case).
  .Tp
  .B \-d
! Enables formail to split up digests/articles into their original parts.
  .Tp
  .I "\fB\+\fPskip"
  Skip the first
-----------------------------cut here------------------------------


-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.