From andyb@wndrsvr.la.ca.us Mon Jun  8 09:19:09 1992
Date: Sat, 6 Jun 92 12:38:41 PDT
From: Andy Brager <andyb@wndrsvr.la.ca.us>
To: Laurence Lundblade <lgl@cac.washington.edu>
Subject: Re: port to System V complete


c-client.   You're going to hate me for this one...some of these are
just header differences.  The makefile is undiffed, at the end.  Sorry.

-  Andy

*** bezerk.c	Sat Jun  6 12:29:28 1992
--- new/bezerk.c	Thu May 28 00:24:22 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: bezerk.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: bezerk.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: bezerk.c,v 1.2 1992/04/27 20:40:05 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: bezerk.c,v $
+  * Revision 1.2  1992/04/27  20:40:05  andyb
+  * Modified for ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 60,66 ****
--- 63,81 ----
  #include <errno.h>
  extern int errno;		/* just in case */
  #include <sys/types.h>
+ #ifdef ISC
+ #include <sys/fcntl.h>
+ #include <sys/unistd.h>
+ #define L_SET 	SEEK_SET
+ #define LOCK_NB	0101010	/* This is bogus but it doesn't really matter */
+ #define LOCK_EX	F_WRLCK /* These are really just dummy values, although */
+ #define LOCK_UN	F_UNLCK /* they're actually all correct except for the first */
+ #define LOCK_SH	F_RDLCK /* one which is a little trickier to do with fcntl() */
+ #define fsync sync
+ #define ftruncate chsize
+ #else
  #include <sys/file.h>
+ #endif
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
***************
*** 200,206 ****
  MAILSTREAM *bezerk_open (stream)
  	MAILSTREAM *stream;
  {
!   int i;
    int fd;
    char tmp[MAILTMPLEN];
    struct hostent *host_name;
--- 215,221 ----
  MAILSTREAM *bezerk_open (stream)
  	MAILSTREAM *stream;
  {
!   int i,ii;
    int fd;
    char tmp[MAILTMPLEN];
    struct hostent *host_name;
***************
*** 222,227 ****
--- 237,263 ----
  				/* build name of our lock file */
    sprintf (tmp,"/tmp/.%s",LOCAL->fname);
    for (i = 6; i < strlen (tmp); ++i) if (tmp[i] == '/') tmp[i] = '\\';
+ 
+ #ifdef ISC
+ 
+ {
+ int jj=0;
+ 
+   for (i = 6; i < strlen (tmp); ++i)
+ 	if (tmp[i] == '\\') 
+ 		jj=i; /* note position of last slash */
+ 
+    ++jj; /* get past slash */  	
+ /* 
+ 14 char filename limit, so if filename is too long leave room 
+ for 2 chars for .l ending to lock file...
+ */
+ 
+    if (strlen(&tmp[jj]) > 12)
+    	tmp[jj+12]=NULL;  /* cut it off */
+ }
+ #endif
+ 
    LOCAL->lname = cpystr (tmp);	/* note name for later */
    LOCAL->ld = NIL;		/* no state locking yet */
    LOCAL->filesize = 0;		/* initialize file information */
***************
*** 231,239 ****
    LOCAL->textsize = LOCAL->textend = 0;
    LOCAL->buf = (char *) fs_get ((LOCAL->buflen = MAXMESSAGESIZE) + 1);
    stream->sequence++;		/* bump sequence number */
- 
    LOCAL->dirty = NIL;		/* no update yet */
  				/* make lock for state */
    if ((i = open (LOCAL->lname,O_RDWR|O_CREAT,0666)) < 0)
      mm_log ("Can't open mailbox lock, access is readonly",WARN);
  				/* try lock it */
--- 267,321 ----
    LOCAL->textsize = LOCAL->textend = 0;
    LOCAL->buf = (char *) fs_get ((LOCAL->buflen = MAXMESSAGESIZE) + 1);
    stream->sequence++;		/* bump sequence number */
    LOCAL->dirty = NIL;		/* no update yet */
  				/* make lock for state */
+   /* 
+   Revelation!  I should have used #ifdef ISC_V3 everywhere. 
+   Oh well :(  Maybe when I'm feel real motivated I'll go back and
+   fix it.  Don't count on it.  I just want to get it working.  :) 
+   */
+ #ifdef ISC
+ 
+   /* I see no reason not to open and lock in one swell foop */
+ 
+   if ((ii = open (LOCAL->lname,O_RDWR|O_EXCL,0666)) < 0)	{
+ 	/* Hmmm.  This has gotten messy.  I'll have to remember to come
+ 	back and see if this mess can be collapsed somewhat */
+   	if (ENOENT == errno)	{
+   	/* It's an error to create a file that exists, under ISC V3 */
+   		if ((ii = open (LOCAL->lname,O_RDWR|O_CREAT|O_EXCL,0666)) < 0) {
+ 
+ 			/* Here's what's *really* wrong */
+     			mm_log (strerror (errno),WARN);	
+ 
+ 			/* and the file */
+     			printf("LOCAL->lname=:%s:\n",LOCAL->lname); 
+   		}
+ 		else 	{
+ 			chmod (LOCAL->lname ,0666);
+ 			LOCAL->ld=ii;
+ 		}
+ 	}
+ /*
+ #ifdef DEBUG
+ */
+ 	else	{
+ 		/* Here's what's *really* wrong */
+     		mm_log (strerror (errno),WARN);	
+ 
+ 		/* and the file */
+     		printf("LOCAL->lname=:%s:\n",LOCAL->lname); 
+ 	}
+ /*
+ #endif
+ */
+   }
+   else 	{
+ 	chmod (LOCAL->lname ,0666);
+ 	LOCAL->ld=ii;
+   }
+   i=ii;	/* Just in case */
+ #else
    if ((i = open (LOCAL->lname,O_RDWR|O_CREAT,0666)) < 0)
      mm_log ("Can't open mailbox lock, access is readonly",WARN);
  				/* try lock it */
***************
*** 242,255 ****
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);
    }
- 				/* got the lock, nobody else can alter state */
    else fchmod ((LOCAL->ld = i),0666);
  				/* parse mailbox */
    stream->nmsgs = stream->recent = 0;
  				/* will we be able to get write access? */
    if (LOCAL->ld && access (LOCAL->fname,W_OK) && (errno == EACCES)) {
      mm_log ("Can't get write access to mailbox, access is readonly",WARN);
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
      close (LOCAL->ld);		/* close the lock file */
      LOCAL->ld = NIL;		/* no more lock fd */
      unlink (LOCAL->lname);	/* delete it */
--- 324,342 ----
      mm_log ("Mailbox is open by another user or process, access is readonly",
  	    WARN);
    }
    else fchmod ((LOCAL->ld = i),0666);
+ #endif
+ 				/* got the lock, nobody else can alter state */
  				/* parse mailbox */
    stream->nmsgs = stream->recent = 0;
  				/* will we be able to get write access? */
    if (LOCAL->ld && access (LOCAL->fname,W_OK) && (errno == EACCES)) {
      mm_log ("Can't get write access to mailbox, access is readonly",WARN);
+ #ifdef ISC
+     fcntl (LOCAL->ld,F_SETLK,F_UNLCK);	/* release the lock */
+ #else
      flock (LOCAL->ld,LOCK_UN);	/* release the lock */
+ #endif
      close (LOCAL->ld);		/* close the lock file */
      LOCAL->ld = NIL;		/* no more lock fd */
      unlink (LOCAL->lname);	/* delete it */
***************
*** 261,266 ****
--- 348,354 ----
      mail_unlock (stream);
    }
    if (!LOCAL) return NIL;	/* failure if stream died */
+   /* DEBUG - is this where readonly status gets set?  Yup.  */
    stream->readonly = !LOCAL->ld;/* make sure upper level knows readonly */
  				/* notify about empty mailbox */
    if (!(stream->nmsgs || stream->silent)) mm_log ("Mailbox is empty",NIL);
***************
*** 281,287 ****
--- 369,379 ----
      stream->silent = T;		/* note this stream is dying */
  				/* lock mailbox and parse new messages */
      if (LOCAL->dirty && (fd = bezerk_parse (stream,lock)) >= 0) {
+ #ifdef ISC
+       fcntl (fd,F_SETLK,F_WRLCK);
+ #else
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* dump any changes not saved yet */
        if (bezerk_extend	(stream,fd,"Close failed to update mailbox"))
  	bezerk_save (stream,fd);
***************
*** 669,675 ****
--- 761,771 ----
  				/* parse and lock mailbox */
    if (LOCAL && LOCAL->ld && ((fd = bezerk_parse (stream,lock)) >= 0)) {
      if (LOCAL->dirty) {		/* only if checkpoint needed */
+ #ifdef ISC
+       fcntl (fd,F_SETLK,F_WRLCK);
+ #else
        flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* dump a checkpoint */
        if (bezerk_extend (stream,fd,"Unable to update mailbox"))
  	bezerk_save (stream,fd);
***************
*** 701,707 ****
--- 797,807 ----
        while ((j = (i<=stream->nmsgs)) && !(elt = mail_elt (stream,i))->deleted)
  	i++;			/* find first deleted message */
        if (j) {			/* found one? */
+ #ifdef ISC
+         fcntl (fd,F_SETLK,F_WRLCK);
+ #else
  	flock (fd,LOCK_EX);	/* upgrade the lock to exclusive access */
+ #endif
  				/* make sure we can do the worst case thing */
  	if (bezerk_extend (stream,fd,"Unable to expunge mailbox")) {
  	  do {			/* flush deleted messages */
***************
*** 799,805 ****
--- 899,909 ----
    if (LOCAL) {			/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
      if (LOCAL->ld) {		/* have a mailbox lock? */
+ #ifdef ISC
+       fcntl (LOCAL->ld,F_SETLK,F_UNLCK);
+ #else
        flock (LOCAL->ld,LOCK_UN);/* yes, release the lock */
+ #endif
        close (LOCAL->ld);	/* close the lock file */
        unlink (LOCAL->lname);	/* and delete it */
      }
***************
*** 837,843 ****
--- 941,951 ----
      uid = (pwd = getpwuid (geteuid ()))->pw_name;
      if (strcmp (ucase (dst),"INBOX")) sprintf (dst,"%s/%s",pwd->pw_dir,name);
  				/* INBOX becomes /usr/spool/mail/USER file */
+ #ifdef ISC
+     else sprintf (dst,"/usr/mail/%s",uid);
+ #else
      else sprintf (dst,"/usr/spool/mail/%s",uid);
+ #endif
    }
    return dst;
  }
***************
*** 857,875 ****
  	int op;
  {
    int fd,ld,j;
!   int i = LOCKTIMEOUT * 60 - 1;
    char tmp[MAILTMPLEN];
    struct timeval tp;
    struct stat sb;
  				/* build lock filename */
    strcat (bezerk_file (lock,file),".lock");
    do {				/* until OK or out of tries */
      gettimeofday (&tp,NIL);	/* get the time now */
  #if T
    /* SUN-OS had an NFS, As kludgy as an albatross;
     * And everywhere that it was installed, It was a total loss.  -- MRC 9/25/91
     */
  				/* build hitching post file name */
      sprintf (tmp,"%s.%d.%d.",lock,time (0),getpid ());
      j = strlen (tmp);		/* append local host name */
      gethostname (tmp + j,(MAILTMPLEN - j) - 1);
--- 965,1003 ----
  	int op;
  {
    int fd,ld,j;
!   int ii = LOCKTIMEOUT * 60 - 1;
    char tmp[MAILTMPLEN];
    struct timeval tp;
    struct stat sb;
  				/* build lock filename */
+ #ifdef ISC
+   strcat (bezerk_file (lock,file),".l");
+ #else
    strcat (bezerk_file (lock,file),".lock");
+ #endif
    do {				/* until OK or out of tries */
      gettimeofday (&tp,NIL);	/* get the time now */
+ /* Hmmmm.  T is #define 1 in mail.h which sort of defeats the purpose of T,
+ based on these lousy comments. */
  #if T
    /* SUN-OS had an NFS, As kludgy as an albatross;
     * And everywhere that it was installed, It was a total loss.  -- MRC 9/25/91
     */
  				/* build hitching post file name */
+ 
+ #ifdef JUNK
+ #ifdef ISC
+     sprintf (tmp,"%s.%d",lock,getpid ());
+     j = strlen (tmp);		/* append local host name */
+     /* strlen("/usr/mail/") == 10 */
+     if (j >= (14 + 10))	{
+ 	sprintf (tmp,"Filename too long '%s': %d",tmp,j);
+ 	mm_log(tmp,WARN);
+     }
+ /* 14 char file name limit */
+ #else
+ #endif
+ #endif
      sprintf (tmp,"%s.%d.%d.",lock,time (0),getpid ());
      j = strlen (tmp);		/* append local host name */
      gethostname (tmp + j,(MAILTMPLEN - j) - 1);
***************
*** 885,891 ****
--- 1013,1023 ----
        }
      }
      else {			/* got a hitching-post */
+ #ifdef ISC
+       chmod (tmp,0666);		/* make sure others can break the lock */
+ #else
        fchmod (ld,0666);		/* make sure others can break the lock */
+ #endif
        close (ld);		/* close the hitching-post */
        link (tmp,lock);		/* tie hitching-post to lock, ignore failure */
        stat (tmp,&sb);		/* get its data */
***************
*** 896,902 ****
        if ((ld = (sb.st_nlink != 2) ? -1 : 0) && (!stat (lock,&sb)) &&
  	  (tp.tv_sec > sb.st_ctime + LOCKTIMEOUT * 60)) unlink (lock);
      }
- 
  #else
    /* This works on modern Unix systems which are not afflicted with NFS mail.
     * "Modern" means that O_EXCL works.  I think that NFS mail is a terrible
--- 1028,1033 ----
***************
*** 903,909 ****
     * idea -- that's what IMAP is for -- but some people insist upon losing...
     */
  				/* try to get the lock */
!     if ((ld = open (lock,O_WRONLY|O_CREAT|O_EXCL,0666)) < 0) switch (errno) {
      case EEXIST:		/* if extant and old, grab it for ourselves */
        if ((!stat (lock,&sb)) && tp.tv_sec > sb.st_ctime + LOCKTIMEOUT * 60)
  	ld = open (lock,O_WRONLY|O_CREAT,0666);
--- 1034,1054 ----
     * idea -- that's what IMAP is for -- but some people insist upon losing...
     */
  				/* try to get the lock */
! #ifdef ISC
!     if ((ld = open (lock,O_WRONLY|O_EXCL,0666)) < 0)	switch (errno) {
! #else
!     if ((ld = open (lock,O_WRONLY|O_CREAT|O_EXCL,0666)) < 0)  switch (errno) {
! #endif
! #ifdef ISC
!     case ENOENT:
!       printf("lock=:%s:\n",lock); 
!   	/* It's an error to create a file that exists, under ISC V3 */
!       if ((ld = open (lock,O_WRONLY|O_CREAT|O_EXCL,0666)) < 0) {
!     	mm_log (strerror (errno),WARN);	
!       }
! 
!       break;
! #endif
      case EEXIST:		/* if extant and old, grab it for ourselves */
        if ((!stat (lock,&sb)) && tp.tv_sec > sb.st_ctime + LOCKTIMEOUT * 60)
  	ld = open (lock,O_WRONLY|O_CREAT,0666);
***************
*** 919,939 ****
        break;
      }
      if (ld >= 0) {		/* if made a lock file */
        fchmod (ld,0666);		/* make sure others can break the lock */
        close (ld);		/* close the lock file */
      }
  #endif
      if ((ld < 0) && *lock) {	/* if failed to make lock file and retry OK */
!       if (!(i%15)) {
  	sprintf (tmp,"Mailbox %s is locked, will override in %d seconds...",
! 		 file,i);
  	mm_log (tmp,WARN);
        }
        sleep (1);		/* wait 1 second before next try */
      }
!   } while (i-- && ld < 0 && *lock);
  				/* open file */
    if ((fd = open (file,flags,mode)) >= 0) flock (fd,op);
    else {			/* open failed */
      j = errno;			/* preserve error code */
      if (*lock) unlink (lock);	/* flush the lock file if any */
--- 1064,1110 ----
        break;
      }
      if (ld >= 0) {		/* if made a lock file */
+ #ifdef ISC
+       chmod (lock,0666);	/* make sure others can break the lock */
+ #else
        fchmod (ld,0666);		/* make sure others can break the lock */
+ #endif
        close (ld);		/* close the lock file */
      }
  #endif
      if ((ld < 0) && *lock) {	/* if failed to make lock file and retry OK */
!       if (!(ii%15)) {
  	sprintf (tmp,"Mailbox %s is locked, will override in %d seconds...",
! 		 file,ii);
  	mm_log (tmp,WARN);
        }
        sleep (1);		/* wait 1 second before next try */
      }
!   } while (ii-- && ld < 0 && *lock);
  				/* open file */
+ #ifdef ISC
+   if ((fd = open (file,flags,mode)) >= 0)	{
+   /* the only cases needed here are LOCK_SH and LOCK_EX but what the hell 
+      let's be complete.
+   */
+       switch (op)	{
+       case LOCK_UN:
+       	fcntl (fd,F_SETLK,F_UNLCK);
+       	break;
+       case LOCK_SH:
+       	fcntl (fd,F_SETLK,F_RDLCK);
+       	break;
+       case LOCK_EX:
+       	fcntl (fd,F_SETLK,F_WRLCK);
+       	break;
+       case LOCK_NB:
+       	fcntl (fd,F_SETLKW,F_UNLCK);
+       	break;
+       }
+   }
+ #else
    if ((fd = open (file,flags,mode)) >= 0) flock (fd,op);
+ #endif
    else {			/* open failed */
      j = errno;			/* preserve error code */
      if (*lock) unlink (lock);	/* flush the lock file if any */
***************
*** 964,972 ****
--- 1135,1150 ----
        tp[0].tv_sec - 1;
      tp[1].tv_usec = 0;		/* oh well */
  				/* set the times, note change */
+ #ifdef ISC
+ #else
      if (!utimes (stream->mailbox,tp)) LOCAL->filetime = tp[1].tv_sec;
+ #endif
    }
+ #ifdef ISC
+   fcntl (fd,F_SETLK,F_UNLCK);
+ #else
    flock (fd,LOCK_UN);		/* release flock'ers */
+ #endif
    close (fd);			/* close the file */
  				/* flush the lock file if any */
    if (lock && *lock) unlink (lock);
*** bezerk.h	Sat Jun  6 12:29:31 1992
--- new/bezerk.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: bezerk.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: bezerk.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: bezerk.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: bezerk.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** dummy.c	Sat Jun  6 12:29:33 1992
--- new/dummy.c	Tue May 19 19:57:07 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: dummy.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: dummy.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: dummy.c,v 1.2 1992/04/27 20:40:05 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: dummy.c,v $
+  * Revision 1.2  1992/04/27  20:40:05  andyb
+  * Modified for ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 49,55 ****
--- 52,62 ----
  extern int errno;		/* just in case */
  #include <pwd.h>
  #include <sys/types.h>
+ #ifdef ISC
+ #include <sys/fcntl.h>
+ #else
  #include <sys/file.h>
+ #endif
  #include <sys/uio.h>
  #include "osdep.h"
  #include "mail.h"
*** dummy.h	Sat Jun  6 12:29:35 1992
--- new/dummy.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: dummy.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: dummy.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: dummy.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: dummy.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** imap2.c	Sat Jun  6 12:29:37 1992
--- new/imap2.c	Tue May 19 19:57:07 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: imap2.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: imap2.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: imap2.c,v 1.2 1992/04/27 20:40:05 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: imap2.c,v $
+  * Revision 1.2  1992/04/27  20:40:05  andyb
+  * Modified for ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 54,60 ****
--- 57,67 ----
  #include <sys/types.h>
  #if unix
  #include <pwd.h>
+ #ifdef ISC
+ #include <sys/fcntl.h>
+ #else
  #include <sys/file.h>
+ #endif
  #include <sys/stat.h>
  #endif
  #include "osdep.h"
*** imap2.h	Sat Jun  6 12:29:23 1992
--- new/imap2.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: imap2.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: imap2.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: imap2.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: imap2.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** mail.c	Sat Jun  6 12:29:25 1992
--- new/mail.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: mail.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: mail.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: mail.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: mail.c,v $
*** mail.h	Sat Jun  6 12:29:29 1992
--- new/mail.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: mail.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: mail.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: mail.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: mail.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** misc.c	Sat Jun  6 12:29:31 1992
--- new/misc.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: misc.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: misc.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: misc.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: misc.c,v $
*** misc.h	Sat Jun  6 12:29:34 1992
--- new/misc.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: misc.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: misc.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: misc.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: misc.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** mtest.c	Sat Jun  6 12:29:35 1992
--- new/mtest.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: mtest.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: mtest.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: mtest.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: mtest.c,v $
*** news.c	Sat Jun  6 12:29:38 1992
--- new/news.c	Tue May 19 19:57:07 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: news.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: news.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: news.c,v 1.2 1992/04/27 20:40:05 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: news.c,v $
+  * Revision 1.2  1992/04/27  20:40:05  andyb
+  * Modified for ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 50,56 ****
--- 53,68 ----
  extern int errno;		/* just in case */
  #include <sys/types.h>
  #include <sys/dir.h>
+ #ifdef ISC
+ #include <sys/fcntl.h>
+ #include <sys/dirent.h>
+ #define L_SET	SEEK_SET
+ #define LOCK_EX	F_WRLCK	/* dummy value, though it just happens to be correct */
+ #define fsync sync
+ #define ftruncate chsize
+ #else
  #include <sys/file.h>
+ #endif
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
***************
*** 203,209 ****
--- 215,238 ----
    sprintf (s = tmp,"/usr/spool/news/%s",stream->mailbox + 1);
    while (s = strchr (s,'.')) *s = '/';
  				/* scan directory */
+ #ifdef ISC
+ 	{
+ 	int done;
+ 
+ 	nmsgs=0;
+ 	done=1;
+ 	fd=opendir(tmp);
+ 	while (NULL != done)	{
+ 		*names=malloc(sizeof(struct dirent));
+ 		memcpy(*names,done=readdir(fd));
+ 		names++;
+ 		nmsgs++;
+ 	}
+ 
+ 
+ #else
    if ((nmsgs = scandir (tmp,&names,news_select,news_numsort)) >= 0) {
+ #endif
      stream->local = fs_get (sizeof (NEWSLOCAL));
      LOCAL->dirty = NIL;		/* no update to .newsrc needed yet */
      LOCAL->dir = cpystr (tmp);	/* copy directory name for later */
***************
*** 707,713 ****
--- 736,746 ----
      mm_log ("Can't update .newsrc",ERROR);
      return;
    }
+ #ifdef ISC
+   fcntl (fd,F_SETLK,F_WRLCK);
+ #else
    flock (fd,LOCK_EX);		/* wait for exclusive access */
+ #endif
    fstat (fd,&sbuf);		/* get size of data */
  				/* ensure enough room */
    if (sbuf.st_size >= (LOCAL->buflen + 1))
***************
*** 772,778 ****
--- 805,815 ----
    lseek (fd,0,L_SET);		/* go to beginning of file */
    ftruncate (fd,iov[0].iov_len + iov[1].iov_len + iov[2].iov_len);
    writev (fd,iov,3);		/* write the new contents */
+ #ifdef ISC
+   fcntl (fd,F_SETLK,F_UNLCK);
+ #else
    flock (fd,LOCK_UN);		/* unlock the file */
+ #endif
    close (fd);			/* flush .newsrc file */
  }
  
*** news.h	Sat Jun  6 12:29:23 1992
--- new/news.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: news.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: news.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: news.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: news.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_aix.c	Sat Jun  6 12:29:25 1992
--- new/os_aix.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_aix.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_aix.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_aix.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_aix.c,v $
*** os_aix.h	Sat Jun  6 12:29:29 1992
--- new/os_aix.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_aix.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_aix.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_aix.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_aix.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_bsd.c	Sat Jun  6 12:29:32 1992
--- new/os_bsd.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_bsd.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_bsd.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_bsd.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_bsd.c,v $
*** os_bsd.h	Sat Jun  6 12:29:34 1992
--- new/os_bsd.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_bsd.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_bsd.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_bsd.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_bsd.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_dos.c	Sat Jun  6 12:29:36 1992
--- new/os_dos.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_dos.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_dos.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_dos.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_dos.c,v $
*** os_dos.h	Sat Jun  6 12:29:39 1992
--- new/os_dos.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_dos.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_dos.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_dos.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_dos.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_dyn.c	Sat Jun  6 12:29:24 1992
--- new/os_dyn.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_dyn.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_dyn.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_dyn.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_dyn.c,v $
*** os_dyn.h	Sat Jun  6 12:29:26 1992
--- new/os_dyn.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_dyn.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_dyn.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_dyn.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_dyn.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_mac.c	Sat Jun  6 12:29:34 1992
--- new/os_mac.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_mac.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_mac.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_mac.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_mac.c,v $
*** os_mac.h	Sat Jun  6 12:29:36 1992
--- new/os_mac.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_mac.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_mac.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_mac.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_mac.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_nxt.c	Sat Jun  6 12:29:39 1992
--- new/os_nxt.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_nxt.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_nxt.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_nxt.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_nxt.c,v $
*** os_nxt.h	Sat Jun  6 12:29:24 1992
--- new/os_nxt.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_nxt.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_nxt.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_nxt.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_nxt.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_s40.c	Sat Jun  6 12:29:26 1992
--- new/os_s40.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_s40.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_s40.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_s40.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_s40.c,v $
*** os_s40.h	Sat Jun  6 12:29:30 1992
--- new/os_s40.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_s40.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_s40.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_s40.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_s40.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_sun.c	Sat Jun  6 12:29:32 1992
--- new/os_sun.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_sun.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_sun.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_sun.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_sun.c,v $
*** os_sun.h	Sat Jun  6 12:29:35 1992
--- new/os_sun.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_sun.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_sun.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_sun.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_sun.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_t20.c	Sat Jun  6 12:29:36 1992
--- new/os_t20.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_t20.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_t20.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_t20.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_t20.c,v $
*** os_t20.h	Sat Jun  6 12:29:39 1992
--- new/os_t20.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_t20.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_t20.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_t20.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_t20.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** os_ult.c	Sat Jun  6 12:29:24 1992
--- new/os_ult.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: os_ult.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: os_ult.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: os_ult.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: os_ult.c,v $
*** os_ult.h	Sat Jun  6 12:29:26 1992
--- new/os_ult.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: os_ult.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: os_ult.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: os_ult.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: os_ult.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** rfc822.c	Sat Jun  6 12:29:33 1992
--- new/rfc822.c	Tue May 19 19:57:07 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: rfc822.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: rfc822.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: rfc822.c,v 1.2 1992/04/27 20:40:05 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: rfc822.c,v $
+  * Revision 1.2  1992/04/27  20:40:05  andyb
+  * Modified for ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 56,61 ****
--- 59,67 ----
  #include "mail.h"
  #include "rfc822.h"
  #include "misc.h"
+ #ifdef ISC
+ #define random rand
+ #endif
  
  /* RFC-822 static data */
  
*** rfc822.h	Sat Jun  6 12:29:35 1992
--- new/rfc822.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: rfc822.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: rfc822.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: rfc822.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: rfc822.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** smtp.c	Sat Jun  6 12:29:37 1992
--- new/smtp.c	Tue May 19 19:57:07 1992
***************
*** 1,4 ****
! static char rcsid[] = "$Id: smtp.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: smtp.c,v $
--- 1,4 ----
! static char rcsid[] = "$Id: smtp.c,v 1.1 1992/04/27 20:21:33 andyb Exp andyb $";
  
  #ifdef COMMENT
  $Log: smtp.c,v $
*** smtp.h	Sat Jun  6 12:29:40 1992
--- new/smtp.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: smtp.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: smtp.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: smtp.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: smtp.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** tcpsio.h	Sat Jun  6 12:29:25 1992
--- new/tcpsio.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: tcpsio.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: tcpsio.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: tcpsio.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: tcpsio.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
*** tenex.c	Sat Jun  6 12:29:27 1992
--- new/tenex.c	Tue May 19 19:57:07 1992
***************
*** 1,7 ****
! static char rcsid[] = "$Id: tenex.c,v 1.1 1992/04/27 20:21:33 andyb Exp $";
  
  #ifdef COMMENT
  $Log: tenex.c,v $
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
--- 1,10 ----
! static char rcsid[] = "$Id: tenex.c,v 1.2 1992/04/27 21:02:38 andyb Exp $";
  
  #ifdef COMMENT
  $Log: tenex.c,v $
+  * Revision 1.2  1992/04/27  21:02:38  andyb
+  * Modifications to make it work under ISC V3 3.0
+  *
   * Revision 1.1  1992/04/27  20:21:33  andyb
   * Initial revision
   *
***************
*** 50,56 ****
--- 53,66 ----
  #include <errno.h>
  extern int errno;		/* just in case */
  #include <sys/types.h>
+ #ifdef ISC
+ #include <sys/fcntl.h>
+ #define L_SET	SEEK_SET
+ #define fsync	sync
+ #define ftruncate	chsize
+ #else
  #include <sys/file.h>
+ #endif
  #include <sys/stat.h>
  #include <sys/time.h>
  #include <sys/uio.h>
***************
*** 244,250 ****
--- 254,264 ----
    LOCAL->host = cpystr ((host_name = gethostbyname (tmp)) ?
  			host_name->h_name : tmp);
  				/* bind and lock the file */
+ #ifdef ISC
+   fcntl (LOCAL->fd = fd,F_SETLK,F_RDLCK);
+ #else
    flock (LOCAL->fd = fd,LOCK_SH);
+ #endif
    LOCAL->filesize = 0;		/* initialize parsed file size */
    for (i = 0; i < MAXMESSAGES; ++i) LOCAL->msgs[i] = NIL;
    LOCAL->text = NIL;		/* no text yet */
***************
*** 268,274 ****
--- 282,292 ----
    int i;
    if (stream && LOCAL) {	/* only if a file is open */
      if (LOCAL->host) fs_give ((void **) &LOCAL->host);
+ #ifdef ISC
+     fcntl (LOCAL->fd,F_SETLK,F_UNLCK);
+ #else
      flock (LOCAL->fd,LOCK_UN);	/* unlock local file */
+ #endif
      close (LOCAL->fd);		/* close the local file */
  				/* free local cache */
      for (i = 0; i < MAXMESSAGES; ++i)
***************
*** 620,629 ****
--- 638,655 ----
  
      mm_critical (stream);	/* go critical */
  				/* calculate name of bezerk file */
+ #ifdef ISC
+     sprintf (LOCAL->buf,"/usr/mail/%s",getpwuid (geteuid ())->pw_name);
+ #else
      sprintf (LOCAL->buf,"/usr/spool/mail/%s",getpwuid (geteuid ())->pw_name);
+ #endif
      stat (LOCAL->buf,&sbuf);	/* see if anything there */
  				/* non-empty and we can lock our file? */
+ #ifdef ISC
+     if (sbuf.st_size && (-1 != fcntl (LOCAL->fd,F_SETLKW,F_WRLCK)) ) {
+ #else
      if (sbuf.st_size && !flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
+ #endif
        fstat (LOCAL->fd,&sbuf);	/* yes, get current file size */
  				/* sizes match and can get bezerk mailbox? */
        if ((sbuf.st_size == LOCAL->filesize) &&
***************
*** 654,660 ****
--- 680,690 ----
        }
        if (bezerk) mail_close (bezerk);
      }
+ #ifdef ISC
+     fcntl (LOCAL->fd,F_SETLK,F_RDLCK);
+ #else
      flock (LOCAL->fd,LOCK_SH);	/* back to shared access */
+ #endif
      mm_nocritical (stream);	/* release critical */
    }
  #endif
***************
*** 700,707 ****
--- 730,742 ----
      return;
    }
  				/* get exclusive access */
+ #ifdef ISC
+   if (fcntl (LOCAL->fd,F_SETLKW,F_WRLCK)) {
+     fcntl (LOCAL->fd,F_SETLK,F_RDLCK);
+ #else
    if (flock (LOCAL->fd,LOCK_EX|LOCK_NB)) {
      flock (LOCAL->fd,LOCK_SH);	/* recover previous lock */
+ #endif
      mm_log ("Expunge rejected: mailbox locked",ERROR);
      return;
    }
***************
*** 749,755 ****
--- 784,794 ----
  				/* notify upper level of new mailbox size */
    mail_exists (stream,stream->nmsgs);
    mail_recent (stream,recent);
+ #ifdef ISC
+   fcntl (LOCAL->fd,F_SETLK,F_RDLCK);
+ #else
    flock (LOCAL->fd,LOCK_SH);	/* allow sharers again */
+ #endif
  }
  
  /* Tenex mail copy message(s)
***************
*** 1044,1050 ****
--- 1083,1093 ----
      return NIL;
    }
    mm_critical (stream);		/* go critical */
+ #ifdef ISC
+   fcntl (fd,F_SETLK,F_WRLCK);
+ #else
    flock (fd,LOCK_EX);
+ #endif
    fstat (fd,&sbuf);		/* get current file size */
  				/* for each requested message */
    while (i < stream->nmsgs) if (s[i++]) {
***************
*** 1065,1071 ****
--- 1108,1118 ----
      }
    }
    fsync (fd);			/* force out the update */
+ #ifdef ISC
+   fcntl (fd,F_SETLK,F_UNLCK);
+ #else
    flock (fd,LOCK_UN);		/* unlock mailbox */
+ #endif
    close (fd);			/* close the file */
    mm_nocritical (stream);	/* release critical */
    return !j;
*** tenex.h	Sat Jun  6 12:29:31 1992
--- new/tenex.h	Tue May 19 19:57:07 1992
***************
*** 1,5 ****
  #ifdef COMMENT
! $Id: tenex.h,v 1.1 1992/04/27 20:21:45 andyb Exp $
  
  $Log: tenex.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb
--- 1,5 ----
  #ifdef COMMENT
! $Id: tenex.h,v 1.1 1992/04/27 20:21:45 andyb Exp andyb $
  
  $Log: tenex.h,v $
   * Revision 1.1  1992/04/27  20:21:45  andyb


# Program:	Portable C client makefile -- AIX version
#
# Author:	Mark Crispin
#		Networks and Distributed Computing
#		Computing & Communications
#		University of Washington
#		Administration Building, AG-44
#		Seattle, WA  98195
#		Internet: MRC@CAC.Washington.EDU
#
# Date:		11 May 1989
# Last Edited:	9 January 1992
#
# Copyright 1992 by the University of Washington
#
#  Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
# that the above copyright notice appears in all copies and that both the
# above copyright notice and this permission notice appear in supporting
# documentation, and that the name of the University of Washington not be
# used in advertising or publicity pertaining to distribution of the software
# without specific, written prior permission.  This software is made
# available "as is", and
# THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED,
# WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, AND IN
# NO EVENT SHALL THE UNIVERSITY OF WASHINGTON BE LIABLE FOR ANY SPECIAL,
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT
# (INCLUDING NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


CFLAGS = -g -DISC
LDFLAGS = -linet -lx
#LDFLAGS = -lbsd
RANLIB = echo

mtest: mtest.o c-client.a
	echo $(CFLAGS) >! CFLAGS
	echo $(LDFLAGS) >! LDFLAGS
	$(CC) $(CFLAGS) -o mtest mtest.o c-client.a $(LDFLAGS)

clean:
	rm -f *.o mtest c-client.a osdep.* CFLAGS LDFLAGS

mtest.o: mail.h smtp.h misc.h osdep.h

c-client.a: mail.o bezerk.o tenex.o imap2.o news.o dummy.o smtp.o rfc822.o \
	misc.o osdep.o
	rm -f c-client.a
	ar rc c-client.a mail.o bezerk.o tenex.o imap2.o news.o dummy.o \
	smtp.o rfc822.o misc.o osdep.o
	$(RANLIB) c-client.a

mail.o: mail.h misc.h osdep.h

bezerk.o: mail.h bezerk.h rfc822.h misc.h osdep.h

tenex.o: mail.h tenex.h rfc822.h misc.h osdep.h

imap2.o: mail.h imap2.h misc.h osdep.h

news.o: mail.h news.h misc.h osdep.h

dummy.o: mail.h dummy.h misc.h osdep.h

smtp.o: mail.h smtp.h rfc822.h misc.h osdep.h

rfc822.o: mail.h rfc822.h misc.h

misc.o: mail.h misc.h osdep.h

osdep.o: mail.h osdep.h os_isc.c
	$(CC) $(CFLAGS) -c os_isc.c
	mv os_isc.o osdep.o

osdep.h: os_isc.h
	rm -f osdep.h
	ln os_isc.h osdep.h

# A monument to a hack of long ago and far away...
love:
	@echo 'not war?'
