diff -r -c Makefile Makefile
*** Makefile	Sun Sep  7 10:35:40 1997
--- Makefile	Sat Aug 30 19:22:41 1997
***************
*** 248,254 ****
  install::
  	if test 'x$(PUBHDRS)' != x; then \
  		if test ! -d $(DESTDIR)$(includedir); then \
! 			mkdir -p $(DESTDIR)$(includedir); \
  		fi; \
  		for i in $(PUBHDRS)''; do \
  			$(INSTALL) -m 644 $(srcdir)/$$i \
--- 248,254 ----
  install::
  	if test 'x$(PUBHDRS)' != x; then \
  		if test ! -d $(DESTDIR)$(includedir); then \
! 			mkdir $(DESTDIR)$(includedir); \
  		fi; \
  		for i in $(PUBHDRS)''; do \
  			$(INSTALL) -m 644 $(srcdir)/$$i \
***************
*** 258,264 ****
  	fi
  	if test 'x$(INSTALLLIBS)' != x; then \
  		if test ! -d $(DESTDIR)$(libdir); then \
! 			mkdir -p $(DESTDIR)$(libdir); \
  		fi; \
  		for i in $(INSTALLLIBS)''; do \
  			$(INSTALL) -m 644 $$i $(DESTDIR)$(libdir); \
--- 258,264 ----
  	fi
  	if test 'x$(INSTALLLIBS)' != x; then \
  		if test ! -d $(DESTDIR)$(libdir); then \
! 			mkdir $(DESTDIR)$(libdir); \
  		fi; \
  		for i in $(INSTALLLIBS)''; do \
  			$(INSTALL) -m 644 $$i $(DESTDIR)$(libdir); \
***************
*** 267,273 ****
  	fi
  	if test 'x$(INSTALLPROGS)' != x; then \
  		if test ! -d $(DESTDIR)$(bindir); then \
! 			mkdir -p $(DESTDIR)$(bindir); \
  		fi; \
  		for i in $(INSTALLPROGS)''; do \
  			$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir); \
--- 267,273 ----
  	fi
  	if test 'x$(INSTALLPROGS)' != x; then \
  		if test ! -d $(DESTDIR)$(bindir); then \
! 			mkdir $(DESTDIR)$(bindir); \
  		fi; \
  		for i in $(INSTALLPROGS)''; do \
  			$(INSTALL) -m 755 $$i $(DESTDIR)$(bindir); \
diff -r -c apps/pgp/pgp.c apps/pgp/pgp.c
*** apps/pgp/pgp.c	Sat Aug  9 14:45:39 1997
--- apps/pgp/pgp.c	Thu Sep  4 12:49:01 1997
***************
*** 37,42 ****
--- 37,47 ----
  #endif
  #include <ctype.h>
  
+ #ifdef __NeXT__
+ #include <libc.h>
+ #include <sys/param.h>
+ #define PATH_MAX MAXPATHLEN
+ #endif
  #include "pgpDebug.h"
  #include "pgpArmrFil.h"
  #include "pgpBufMod.h"
***************
*** 80,86 ****
  #include "parsearg.h"
  #include "pass.h"
  
- 
  typedef enum _PGPInvokedType {
      Unknown = 0,
      PGPencrypt,
--- 85,90 ----
***************
*** 100,105 ****
--- 104,111 ----
  static struct PgpPubKey *publicKey = NULL;
  static struct RingPool *ringpool = NULL;
  
+ PgpEnv PGPKDBExport *pgpEnv;
+ 
  static struct PgpFile *
  openFile (void *arg, void const *base, unsigned num)
  {
***************
*** 545,550 ****
--- 551,558 ----
  				exitUsage(e);
  
  			while ((e = ringIterNextObject (ringiter, 1)) > 0) {
+ 			  int batchmode = pgpenvGetInt (ui_arg->arg.env, PGPENV_BATCHMODE,NULL, NULL);
+ 				
  			  ringobj = ringIterCurrentObject(ringiter, 1);
  			  if (ringObjectType (ringobj) != RINGTYPE_KEY) {
  #if 0
***************
*** 556,563 ****
  			  }
  			  /* Determine whether this key is OK to use
  			     for encryption */
! 			  if (ringTtyKeyOKToEncrypt (ringset,
! 										 ringobj)) {
  				prefAlgs = ringKeyFindSubpacket (ringobj, ringset,
  							SIGSUB_PREFERRED_ALGS,
  				            0, &numPrefAlgs, NULL, NULL, NULL, NULL, &e);
--- 564,573 ----
  			  }
  			  /* Determine whether this key is OK to use
  			     for encryption */
! 			  
! 
! 					   
! 			  if (ringTtyKeyOKToEncrypt (ringset, ringobj,batchmode )) {
  				prefAlgs = ringKeyFindSubpacket (ringobj, ringset,
  							SIGSUB_PREFERRED_ALGS,
  				            0, &numPrefAlgs, NULL, NULL, NULL, NULL, &e);
diff -r -c lib/pgp/compress/pgpZInflate.c lib/pgp/compress/pgpZInflate.c
*** lib/pgp/compress/pgpZInflate.c	Sat Aug  9 14:44:49 1997
--- lib/pgp/compress/pgpZInflate.c	Sat Aug 16 16:02:54 1997
***************
*** 268,275 ****
  
  #define base more.base
  #define next more.next
! #define exop word.what.exop
! #define bits word.what.bits
  
  
  /* Function prototypes */
--- 268,275 ----
  
  #define base more.base
  #define next more.next
! #define Exop word.what. exop
! #define Bits word.what. bits
  
  
  /* Function prototypes */
***************
*** 598,604 ****
  			return 3;		/* not enough memory */
  		}
  #if SECURE
! 		q->bits = (char)j;			/* Track size for free */
  	#endif
  		*t = q + 1;			/* link to list for huft_free() */
  		*(t = &(q->next)) = (struct huft *)NULL;
--- 598,604 ----
  			return 3;		/* not enough memory */
  		}
  #if SECURE
! 		q->Bits = (char)j;			/* Track size for free */
  	#endif
  		*t = q + 1;			/* link to list for huft_free() */
  		*(t = &(q->next)) = (struct huft *)NULL;
***************
*** 607,614 ****
  		/* connect to last table, if there is one */
  		if (h) {
  			x[h] = i;		/* save pattern for backing up */
! 			r.bits = (char)l;		/* bits to dump before this table */
! 			r.exop = -(char)j;		/* bits in this table */
  			r.next = q;		/* pointer to this table */
  			j = i >> (w - l);		/* (get around Turbo C bug) */
  			u[h-1][j] = r;		/* connect to last table */
--- 607,614 ----
  		/* connect to last table, if there is one */
  		if (h) {
  			x[h] = i;		/* save pattern for backing up */
! 			r.Bits = (char)l;		/* bits to dump before this table */
! 			r.Exop = -(char)j;		/* bits in this table */
  			r.next = q;		/* pointer to this table */
  			j = i >> (w - l);		/* (get around Turbo C bug) */
  			u[h-1][j] = r;		/* connect to last table */
***************
*** 616,629 ****
  		}
  
  		/* set up table entry in r */
! 		r.bits = (char)(k - w);
  		if (p >= v + n) {
! 		r.exop = -128; /* out of values--invalid code */
  		} else if (*p < s) {
! 		r.exop = (char)(*p < 256 ? 16 : 32); /* 256 is end-of-block code */
  		r.base = *p++; /* simple code is just the value */
  		} else {
! 		r.exop = (char)e[*p - s]; /* non-simple--look up in lists */
  		r.base = d[*p++ - s];
  		}
  
--- 616,629 ----
  		}
  
  		/* set up table entry in r */
! 		r.Bits = (char)(k - w);
  		if (p >= v + n) {
! 		r.Exop = -128; /* out of values--invalid code */
  		} else if (*p < s) {
! 		r.Exop = (char)(*p < 256 ? 16 : 32); /* 256 is end-of-block code */
  		r.base = *p++; /* simple code is just the value */
  		} else {
! 		r.Exop = (char)e[*p - s]; /* non-simple--look up in lists */
  		r.base = d[*p++ - s];
  		}
  
***************
*** 673,679 ****
  {
  q = (--p)->next;
  #if SECURE
! memset(p, 0, (1+(1<<p->bits)) * sizeof(*p));
  #endif
  pgpMemFree(p);
  	p = q;
--- 673,679 ----
  {
  q = (--p)->next;
  #if SECURE
! memset(p, 0, (1+(1<<p->Bits)) * sizeof(*p));
  #endif
  pgpMemFree(p);
  	p = q;
***************
*** 915,924 ****
  			/*FALLTHROUGH*/
  			case 1:
  			while (i < lim) {
! 			NEEDBITS2(bl, tl[(unsigned)b & m].bits,
  			 ctx->index=i; ctx->numbits=l; ctx->substate=1)
  			td = tl + ((unsigned)b & m);
! 			j = td->bits;
  			DUMPBITS(j);
  			j = td->base;
  			if (j < 16) {
--- 915,924 ----
  			/*FALLTHROUGH*/
  			case 1:
  			while (i < lim) {
! 			NEEDBITS2(bl, tl[(unsigned)b & m].Bits,
  			 ctx->index=i; ctx->numbits=l; ctx->substate=1)
  			td = tl + ((unsigned)b & m);
! 			j = td->Bits;
  			DUMPBITS(j);
  			j = td->base;
  			if (j < 16) {
***************
*** 1115,1130 ****
  		do {
  		GRABBITS(20) /* max bits for literal/length code */
  		t = tl + ((unsigned)b & ml);
! 		if ((e = t->exop) < 0) {
  		do {
  		if (e == -128)
  				return INFERR_BADINPUT;
! 				DUMPBITS(t->bits);
  				e = -e;
  				t = t->next + ((unsigned)b & mask[e]);
! 				} while ((e = t->exop) < 0);
  			}
! 			DUMPBITS(t->bits);
  			if (e & 16) { /* then it's a literal */
  			*w++ = (unsigned char)t->base;
  			continue;
--- 1115,1130 ----
  		do {
  		GRABBITS(20) /* max bits for literal/length code */
  		t = tl + ((unsigned)b & ml);
! 		if ((e = t->Exop) < 0) {
  		do {
  		if (e == -128)
  				return INFERR_BADINPUT;
! 				DUMPBITS(t->Bits);
  				e = -e;
  				t = t->next + ((unsigned)b & mask[e]);
! 				} while ((e = t->Exop) < 0);
  			}
! 			DUMPBITS(t->Bits);
  			if (e & 16) { /* then it's a literal */
  			*w++ = (unsigned char)t->base;
  			continue;
***************
*** 1141,1156 ****
  			/* decode distance of block to copy */
  			GRABBITS(15);
  			t = td + ((unsigned)b & md);
! 			if ((e = t->exop) < 0) {
  			do {
  			if (e == -128)
  			return INFERR_BADINPUT;
! 			DUMPBITS(t->bits);
  			e = -e;
  			t = t->next + ((unsigned)b & mask[e]);
! 			} while ((e = t->exop) < 0);
  			}
! 			DUMPBITS(t->bits);
  			GRABBITS((unsigned)e) /* get up to 13 extra bits */
  			d = t->base + ((unsigned)b & mask[e]);
  			DUMPBITS((unsigned)e);
--- 1141,1156 ----
  			/* decode distance of block to copy */
  			GRABBITS(15);
  			t = td + ((unsigned)b & md);
! 			if ((e = t->Exop) < 0) {
  			do {
  			if (e == -128)
  			return INFERR_BADINPUT;
! 			DUMPBITS(t->Bits);
  			e = -e;
  			t = t->next + ((unsigned)b & mask[e]);
! 			} while ((e = t->Exop) < 0);
  			}
! 			DUMPBITS(t->Bits);
  			GRABBITS((unsigned)e) /* get up to 13 extra bits */
  			d = t->base + ((unsigned)b & mask[e]);
  			DUMPBITS((unsigned)e);
***************
*** 1200,1215 ****
  		/* Pessimistic estimate of bits for literal/length: 15+5 */
  		GETBITSOR(20, goto getlitlength2)
  		t = tl + ((unsigned)b & ml);
! 		if ((e = t->exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;
! 		DUMPBITS(t->bits);
  		e = -e;
  		t = t->next + ((unsigned)b & mask[e]);
! 		} while ((e = t->exop) < 0);
  		}
! 		DUMPBITS(t->bits);
  		if (e & 16) { /* then it's a literal */
  		*w++ = (unsigned char)t->base;
  		if (--r == 0) {
--- 1200,1215 ----
  		/* Pessimistic estimate of bits for literal/length: 15+5 */
  		GETBITSOR(20, goto getlitlength2)
  		t = tl + ((unsigned)b & ml);
! 		if ((e = t->Exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;
! 		DUMPBITS(t->Bits);
  		e = -e;
  		t = t->next + ((unsigned)b & mask[e]);
! 		} while ((e = t->Exop) < 0);
  		}
! 		DUMPBITS(t->Bits);
  		if (e & 16) { /* then it's a literal */
  		*w++ = (unsigned char)t->base;
  		if (--r == 0) {
***************
*** 1234,1240 ****
  		* We don't have to try to fill the bit buffer, because we only get
  		* here if s (number of following input bytes) is supposed to be zero.
  		*/
! 		if (k < (unsigned)t->bits) {
  		ctx->outptr = w;
  		ctx->substate = 0;
  		SAVEBITBUFEMPTY;
--- 1234,1240 ----
  		* We don't have to try to fill the bit buffer, because we only get
  		* here if s (number of following input bytes) is supposed to be zero.
  		*/
! 		if (k < (unsigned)t->Bits) {
  		ctx->outptr = w;
  		ctx->substate = 0;
  		SAVEBITBUFEMPTY;
***************
*** 1242,1261 ****
  		}
  		/* Actually, s is set (see GETBITSOR comment) to -1, so reset it */
  		s = 0;
! 		if ((e = t->exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;
! 		DUMPBITS(t->bits);
  		e = -e;
  		t = t->next;
  		case 1:
! 		NEEDBITS2(e, t[(unsigned)b & mask[e]].bits,
  		ctx->t=t; ctx->outptr=w; ctx->numbits=e; ctx->substate=1)
  		t += (unsigned)b & mask[e];
! 		} while ((e = t->exop) < 0);
  		}
! 		DUMPBITS(t->bits);
  		if (e & 16) { /* then it's a literal */
  		*w++ = (unsigned char)t->base;
  		if (--r == 0) {
--- 1242,1261 ----
  		}
  		/* Actually, s is set (see GETBITSOR comment) to -1, so reset it */
  		s = 0;
! 		if ((e = t->Exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;
! 		DUMPBITS(t->Bits);
  		e = -e;
  		t = t->next;
  		case 1:
! 		NEEDBITS2(e, t[(unsigned)b & mask[e]].Bits,
  		ctx->t=t; ctx->outptr=w; ctx->numbits=e; ctx->substate=1)
  		t += (unsigned)b & mask[e];
! 		} while ((e = t->Exop) < 0);
  		}
! 		DUMPBITS(t->Bits);
  		if (e & 16) { /* then it's a literal */
  		*w++ = (unsigned char)t->base;
  		if (--r == 0) {
***************
*** 1286,1300 ****
  /* Get distance code - 15 is maximum code size */
  GETBITSOR(15, goto getdistance2)
  t = td + ((unsigned)b & md);
! /* Negative t->exop means there's a subtable of 2^-e entries */
! 		if ((e = t->exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;	/* Invalid code (static table case) */
! 		DUMPBITS(t->bits);
  		e = -e;
  		t = t->next + ((unsigned)b & mask[e]);
! 		} while ((e = t->exop) < 0);
  		}
  		goto gotdistance;
  
--- 1286,1300 ----
  /* Get distance code - 15 is maximum code size */
  GETBITSOR(15, goto getdistance2)
  t = td + ((unsigned)b & md);
! /* Negative t->Exop means there's a subtable of 2^-e entries */
! 		if ((e = t->Exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;	/* Invalid code (static table case) */
! 		DUMPBITS(t->Bits);
  		e = -e;
  		t = t->next + ((unsigned)b & mask[e]);
! 		} while ((e = t->Exop) < 0);
  		}
  		goto gotdistance;
  
***************
*** 1306,1312 ****
  * We don't have to try to fill the bit buffer, because we only get
  * here if s (number of following input bytes) is supposed to be zero.
  	*/
! if (k < (unsigned)t->bits) {
  ctx->outptr = w;
  ctx->copylen = n;
  ctx->substate = 3;
--- 1306,1312 ----
  * We don't have to try to fill the bit buffer, because we only get
  * here if s (number of following input bytes) is supposed to be zero.
  	*/
! if (k < (unsigned)t->Bits) {
  ctx->outptr = w;
  ctx->copylen = n;
  ctx->substate = 3;
***************
*** 1315,1338 ****
  }
  /* Actually (see GETBITSOR comment) s is set to -1, so reset it */
  s = 0;
! /* Negative t->exop means there's a subtable of 2^-e entries */
! 		if ((e = t->exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;	/* Invalid code (static table case) */
! 		DUMPBITS(t->bits);
  		e = -e;
  		t = t->next;
  	case 4:
! NEEDBITS2(e, t[(unsigned)b & mask[e]].bits, ctx->t=t; ctx->outptr=w;
  ctx->copylen = n; ctx->numbits=e; ctx->substate=4)
  		t += (unsigned)b & mask[e];
! 		} while ((e = t->exop) < 0);
  		}
  
  gotdistance:
  /* All data is available - compute the base distance */
! DUMPBITS(t->bits);
  d = t->base;
  /*FALLTHROUGH*/
  case 5:
--- 1315,1338 ----
  }
  /* Actually (see GETBITSOR comment) s is set to -1, so reset it */
  s = 0;
! /* Negative t->Exop means there's a subtable of 2^-e entries */
! 		if ((e = t->Exop) < 0) {
  		do {
  		if (e == -128)
  		return INFERR_BADINPUT;	/* Invalid code (static table case) */
! 		DUMPBITS(t->Bits);
  		e = -e;
  		t = t->next;
  	case 4:
! NEEDBITS2(e, t[(unsigned)b & mask[e]].Bits, ctx->t=t; ctx->outptr=w;
  ctx->copylen = n; ctx->numbits=e; ctx->substate=4)
  		t += (unsigned)b & mask[e];
! 		} while ((e = t->Exop) < 0);
  		}
  
  gotdistance:
  /* All data is available - compute the base distance */
! DUMPBITS(t->Bits);
  d = t->base;
  /*FALLTHROUGH*/
  case 5:
diff -r -c lib/pgp/helper/pgpGlobals.c lib/pgp/helper/pgpGlobals.c
*** lib/pgp/helper/pgpGlobals.c	Sun Aug 10 18:53:59 1997
--- lib/pgp/helper/pgpGlobals.c	Sun Aug 31 15:04:04 1997
***************
*** 16,22 ****
  
  char const pgpLibVersionString[] =
  #ifdef PGP_FREEWARE
!     "PGPfreeware 5.0i for non-commercial use";
  #else
      "PGP for Personal Privacy 5.0i";
  #endif
--- 16,22 ----
  
  char const pgpLibVersionString[] =
  #ifdef PGP_FREEWARE
!     "PGP 5.0";
  #else
      "PGP for Personal Privacy 5.0i";
  #endif
diff -r -c lib/pgp/helper/pgpTypes.h lib/pgp/helper/pgpTypes.h
*** lib/pgp/helper/pgpTypes.h	Sat Aug  9 14:44:57 1997
--- lib/pgp/helper/pgpTypes.h	Sat Aug 16 16:02:54 1997
***************
*** 48,53 ****
--- 48,56 ----
  #define 	alignof(type) (sizeof(struct{type _x; char _y;}) - sizeof(type))
  #endif
  
+ #if __NeXT__
+ typedef unsigned short mode_t;
+ #endif
  #endif /* ] PGPTYPES_H */
  
  /*
diff -r -c lib/pgp/keydb/pgpPrefUnix.c lib/pgp/keydb/pgpPrefUnix.c
*** lib/pgp/keydb/pgpPrefUnix.c	Sun Aug 10 17:05:32 1997
--- lib/pgp/keydb/pgpPrefUnix.c	Sat Aug 30 19:17:28 1997
***************
*** 12,17 ****
--- 12,20 ----
  
  #ifdef HAVE_SYS_STAT_H
  #include <sys/stat.h> /*for stat() to check for directory*/
+ #if __NeXT__ /* or "ifndef S_ISDIR", if you like */
+ #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
+ #endif
  #endif
  
  #include "pgpKDBint.h"
diff -r -c lib/pgp/pubkey/pgpRSAGlue1.c lib/pgp/pubkey/pgpRSAGlue1.c
*** lib/pgp/pubkey/pgpRSAGlue1.c	Sun Aug 10 17:02:45 1997
--- lib/pgp/pubkey/pgpRSAGlue1.c	Sat Aug 16 16:08:50 1997
***************
*** 44,50 ****
  #define bndPrintf printf
  #else
  #define bndPut(prompt, bn) ((void)(prompt),(void)(bn))
! #if __GNUC__ > 1
  /* Non-ANSI, but supresses warnings about expressions with no effect */
  #define bndPrintf(arg...) (void)0
  #else
--- 44,55 ----
  #define bndPrintf printf
  #else
  #define bndPut(prompt, bn) ((void)(prompt),(void)(bn))
! 
! 
! 
! #if 0
! 
! #if __GNUC__ >= 2 && __GNUC_MINOR__ > 5
  /* Non-ANSI, but supresses warnings about expressions with no effect */
  #define bndPrintf(arg...) (void)0
  #else
***************
*** 52,57 ****
--- 57,67 ----
  #define bndPrintf (void)
  #endif
  #endif
+ 
+ #endif /* if 0 */
+ 
+ #define bndPrintf (void)
+ 
  
  int
  rsaPublicEncrypt(struct BigNum *bn, byte const *in, unsigned len,
diff -r -c lib/pgp/pubkey/pgpRSAGlue2.c lib/pgp/pubkey/pgpRSAGlue2.c
*** lib/pgp/pubkey/pgpRSAGlue2.c	Sun Aug 10 17:02:45 1997
--- lib/pgp/pubkey/pgpRSAGlue2.c	Sat Aug 16 16:11:42 1997
***************
*** 46,52 ****
  #define bndPrintf printf
  #else
  #define bndPut(prompt, bn) ((void)(prompt),(void)(bn))
! #if __GNUC__ > 1
  /* Non-ANSI, but supresses warnings about expressions with no effect */
  #define bndPrintf(arg...) (void)0
  #else
--- 46,56 ----
  #define bndPrintf printf
  #else
  #define bndPut(prompt, bn) ((void)(prompt),(void)(bn))
! #if __GNUC__ >= 2 && __GNUC_MINOR__ > 5
! 
! 
! #if 0
! 
  /* Non-ANSI, but supresses warnings about expressions with no effect */
  #define bndPrintf(arg...) (void)0
  #else
***************
*** 54,59 ****
--- 58,68 ----
  #define bndPrintf (void)
  #endif
  #endif
+ 
+ #endif /* if 0 */
+ 
+ 
+ #define bndPrintf (void)
  
  
  /*
diff -r -c lib/pgp/utils/pgpConf.c lib/pgp/utils/pgpConf.c
*** lib/pgp/utils/pgpConf.c	Sun Aug 10 17:05:33 1997
--- lib/pgp/utils/pgpConf.c	Tue Sep  2 15:29:43 1997
***************
*** 69,104 ****
  /*	{ "pager",            PGPENV_PAGER,       OPT_STRING,     0, 255 },*/
  /*	{ "pkcs_compat",      PGPENV_PKCS_COMPAT, OPT_INT,      0, INT_MAX },*/
  	{ "pgp_mime",         PGPENV_PGPMIME,     OPT_BINARY,     0, 1 },
! 			{ "pgp_mimeparse",	PGPENV_PGPMIMEPARSEBODY, OPT_BINARY,0, 1 },
! 			{ "pubring",	PGPENV_PUBRING, OPT_STRING, 0, 0 },
! 			{ "randomdevice",	PGPENV_RANDOMDEVICE, OPT_STRING, 0, 0 },
! 			{ "randseed",	PGPENV_RANDSEED, OPT_STRING, 0, 0 },
  #ifdef UNIX
  	/*		{ "randsource",	FUNC_RANDSOURCE, OPT_STRING|OPT_FUNC, 0, 0 },*/
  #endif
! 			{ "secring",	PGPENV_SECRING,	OPT_STRING,	0, 0 },
! 			{ "showpass",	PGPENV_SHOWPASS,	OPT_BINARY,	0, 1 },
! 			{ "textmode",	PGPENV_TEXTMODE,	OPT_BINARY,	0, 1 },
! 			{ "tmp",	PGPENV_TMP,	OPT_STRING,	0, 0 },
  /* Temp for new trust - change to something better */
! 		{ "trusted",		PGPENV_TRUSTED,	OPT_INT,	0, 255 },
! 		{ "tzfix",		PGPENV_TZFIX,	OPT_INT,	-24, 24 },
! 		{ "verbose",		PGPENV_VERBOSE,	OPT_INT,	0, INT_MAX },
  /* Experimental XXX@@@ */
! 			{ "version",	PGPENV_VERSION,	OPT_INT,	2, 4 },
! 			{ "ciphernum",		PGPENV_CIPHER,		OPT_INT,		1, INT_MAX },
! 			{ "hashnum",		PGPENV_HASH,		OPT_INT,		1, INT_MAX },
! 			{ "fastkeygen",	PGPENV_FASTKEYGEN, OPT_BINARY,	0, 1 },
! 
! 			/* command line only */
! 			{ "batchmode",	PGPENV_BATCHMODE, OPT_BINARY|OPT_CMD, 0, 1 },
! 			{ "force",	PGPENV_FORCE,		OPT_BINARY|OPT_CMD, 0, 1 },
! 			{ "magic",	PGPENV_MAGIC,		OPT_BINARY|OPT_CMD, 0, 1 },
! 			{ "noout",	PGPENV_NOOUT,		OPT_BINARY|OPT_CMD, 0, 1 },
  	{ "license",          PGPENV_LICENSE,     OPT_BINARY|OPT_CMD,  0, 1 },
  	{ "headers",          PGPENV_HEADERS,     OPT_BINARY|OPT_CMD,  0, 1 },
! 			/* Null-terminated */
! 			{ (char const *)0,	0,	0,		0, 0 }
  };
  
  /* Case-insensitive memory compare */
--- 69,105 ----
  /*	{ "pager",            PGPENV_PAGER,       OPT_STRING,     0, 255 },*/
  /*	{ "pkcs_compat",      PGPENV_PKCS_COMPAT, OPT_INT,      0, INT_MAX },*/
  	{ "pgp_mime",         PGPENV_PGPMIME,     OPT_BINARY,     0, 1 },
! 	{ "pgp_mimeparse",	PGPENV_PGPMIMEPARSEBODY, OPT_BINARY,0, 1 },
! 	{ "pubring",	PGPENV_PUBRING, OPT_STRING, 0, 0 },
! 	{ "randomdevice",	PGPENV_RANDOMDEVICE, OPT_STRING, 0, 0 },
! 	{ "randseed",	PGPENV_RANDSEED, OPT_STRING, 0, 0 },
  #ifdef UNIX
  	/*		{ "randsource",	FUNC_RANDSOURCE, OPT_STRING|OPT_FUNC, 0, 0 },*/
  #endif
! 	{ "secring",	PGPENV_SECRING,	OPT_STRING,	0, 0 },
! 	{ "showpass",	PGPENV_SHOWPASS,	OPT_BINARY,	0, 1 },
! 	{ "textmode",	PGPENV_TEXTMODE,	OPT_BINARY,	0, 1 },
! 	{ "tmp",	PGPENV_TMP,	OPT_STRING,	0, 0 },
! 
  /* Temp for new trust - change to something better */
! 	{ "trusted",		PGPENV_TRUSTED,	OPT_INT,	0, 255 },
! 	{ "tzfix",		PGPENV_TZFIX,	OPT_INT,	-24, 24 },
! 	{ "verbose",		PGPENV_VERBOSE,	OPT_INT,	0, INT_MAX },
  /* Experimental XXX@@@ */
! 	{ "version",	PGPENV_VERSION,	OPT_INT,	2, 4 },
! 	{ "ciphernum",		PGPENV_CIPHER,		OPT_INT,		1, INT_MAX },
! 	{ "hashnum",		PGPENV_HASH,		OPT_INT,		1, INT_MAX },
! 	{ "fastkeygen",	PGPENV_FASTKEYGEN, OPT_BINARY,	0, 1 },
! 	
! /* command line only */
! 	{ "batchmode",	PGPENV_BATCHMODE,       OPT_BINARY|OPT_CMD, 0, 1 },
! 	{ "force",	PGPENV_FORCE,		OPT_BINARY|OPT_CMD, 0, 1 },
! 	{ "magic",	PGPENV_MAGIC,		OPT_BINARY|OPT_CMD, 0, 1 },
! 	{ "noout",	PGPENV_NOOUT,		OPT_BINARY|OPT_CMD, 0, 1 },
  	{ "license",          PGPENV_LICENSE,     OPT_BINARY|OPT_CMD,  0, 1 },
  	{ "headers",          PGPENV_HEADERS,     OPT_BINARY|OPT_CMD,  0, 1 },
! /* Null-terminated */
! 	{ (char const *)0,	0,	0,		0, 0 }
  };
  
  /* Case-insensitive memory compare */
diff -r -c lib/ttyui/Makefile lib/ttyui/Makefile
*** lib/ttyui/Makefile	Sun Sep  7 10:35:47 1997
--- lib/ttyui/Makefile	Sat Aug 30 17:25:35 1997
***************
*** 48,54 ****
  CFLAGS=	$(OPT) $(OSDEF)  -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -DHAVE_CONFIG_H $(DEFINES) $(LOCALDEFINES) \
  	$(RSAOPTS) \
  	-I$(top_builddir) -I$(buildinc) -I../include -I$(srcdir) \
! 	$(LOCALINCLUDES) $(CCOPTS) 
  LDFLAGS= -L$(buildlib)
  
  LIBPRE=	lib
--- 48,54 ----
  CFLAGS=	$(OPT) $(OSDEF)  -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -DHAVE_CONFIG_H $(DEFINES) $(LOCALDEFINES) \
  	$(RSAOPTS) \
  	-I$(top_builddir) -I$(buildinc) -I../include -I$(srcdir) \
! 	$(LOCALINCLUDES) $(CCOPTS) -traditional-cpp
  LDFLAGS= -L$(buildlib)
  
  LIBPRE=	lib
diff -r -c lib/ttyui/pgpKBUnix.c lib/ttyui/pgpKBUnix.c
*** lib/ttyui/pgpKBUnix.c	Sat Aug  9 14:45:20 1997
--- lib/ttyui/pgpKBUnix.c	Sat Aug 30 17:55:09 1997
***************
*** 20,25 ****
--- 20,30 ----
  #include <stdio.h>
  #include <sys/types.h>
  
+ #if __NeXT__
+ #define NOTERMIO
+ #undef TCIFLUSH
+ #include <libc.h>
+ #endif
  /* How to get cbreak mode */
  
  #if defined(NOTERMIO)
***************
*** 229,234 ****
--- 234,241 ----
  {
  	if (thorough)
  		sleep(1);
+ 
+ #if 0
  #if defined(TCIFLUSH)
  	tcflush(kbFd, TCIFLUSH);
  #elif defined(TIOCFLUSH)
***************
*** 237,242 ****
--- 244,252 ----
  #endif
  	ioctl(kbFd, TIOCFLUSH, FREAD);
  #endif
+ #endif
+ 
+ 	ioctl(kbFd, TIOCFLUSH, FREAD);
  }
  
  
diff -r -c lib/ttyui/pgpOutput.h lib/ttyui/pgpOutput.h
*** lib/ttyui/pgpOutput.h	Sat Aug  9 14:45:36 1997
--- lib/ttyui/pgpOutput.h	Sat Aug 16 16:02:56 1997
***************
*** 7,12 ****
--- 7,14 ----
   *
   * $Id: pgpOutput.h,v 1.1.2.1.2.1 1997/07/08 12:59:26 quark Exp $
   */
+ /* For struct PgpEnv */
+ #include <pgpUserIO.h>
  typedef enum PgpOutputTypes {
      OUTPUT_PRIMARY = 0,
      OUTPUT_INFORMATION,
diff -r -c lib/ttyui/pgpRingUI.c lib/ttyui/pgpRingUI.c
*** lib/ttyui/pgpRingUI.c	Sun Aug 10 17:05:33 1997
--- lib/ttyui/pgpRingUI.c	Thu Sep  4 12:50:13 1997
***************
*** 1713,1719 ****
  
  int
  ringTtyKeyOKToEncrypt (struct RingSet const *set,
! 		       union RingObject *key)
  {
      union RingObject *name;
      char const *namestring;
--- 1713,1719 ----
  
  int
  ringTtyKeyOKToEncrypt (struct RingSet const *set,
! 		       union RingObject *key, int batchmode)
  {
      union RingObject *name;
      char const *namestring;
***************
*** 1802,1808 ****
  		    warn = 1;
  		}
  	    }
! 	    if (warn) {
  		namestring = ringNameName (set, name, &len);
  		ringTtyPutString (namestring,
  				  len,
--- 1802,1808 ----
  		    warn = 1;
  		}
  	    }
! 	    if (warn && !batchmode) {
  		namestring = ringNameName (set, name, &len);
  		ringTtyPutString (namestring,
  				  len,
diff -r -c lib/ttyui/pgpRingUI.h lib/ttyui/pgpRingUI.h
*** lib/ttyui/pgpRingUI.h	Sun Aug 10 17:05:33 1997
--- lib/ttyui/pgpRingUI.h	Thu Sep  4 12:51:55 1997
***************
*** 156,162 ****
  
  int PGPTTYExport
  ringTtyKeyOKToEncrypt (struct RingSet const *set,
! 		       union RingObject *key);
  
  void PGPTTYExport
  ringTtyKeyOKToSign (struct RingSet const *set,
--- 156,162 ----
  
  int PGPTTYExport
  ringTtyKeyOKToEncrypt (struct RingSet const *set,
! 		       union RingObject *key, int batchmode);
  
  void PGPTTYExport
  ringTtyKeyOKToSign (struct RingSet const *set,
diff -r -c lib/ttyui/pgpScrUnix.c lib/ttyui/pgpScrUnix.c
*** lib/ttyui/pgpScrUnix.c	Sat Aug  9 14:45:21 1997
--- lib/ttyui/pgpScrUnix.c	Sat Aug 16 16:02:56 1997
***************
*** 46,51 ****
--- 46,54 ----
  
  #endif /* not SVR2 */
  
+ #if __NeXT__
+ #include <libc.h>
+ #endif
  #include "pgpUsuals.h"
  #include "pgpScreen.h"
  
diff -r -c lib/ttyui/pgpUserIO.c lib/ttyui/pgpUserIO.c
*** lib/ttyui/pgpUserIO.c	Sun Aug 10 17:05:33 1997
--- lib/ttyui/pgpUserIO.c	Fri Sep  5 15:55:16 1997
***************
*** 37,43 ****
--- 37,50 ----
  
  #if HAVE_SYS_STAT_H
  #include <sys/stat.h> /*for stat() to check for /dev/random*/
+ #if __NeXT__ /* or "ifndef S_IRWXG", if you prefer */
+ #define S_IRWXG 0070
+ #define S_IRWXO 0007
  #endif
+ #endif
+ #if __NeXT__
+ #include <libc.h>
+ #endif
  
  #include "pgpDebug.h"
  #include "pgpFileRef.h"
***************
*** 818,826 ****
  		return 0;
  
  	if (ui->passcache) {
! 		err = pgpPassCacheTryKey (ui->passcache, seckey);
! 		if (err > 0)
! 			return 0;
  	}
  
  	/*XXX Add code to detect if we're in batch mode without a passphrase*/
--- 825,839 ----
  		return 0;
  
  	if (ui->passcache) {
! 	    err = pgpPassCacheTryKey (ui->passcache, seckey);
! 	    if (err > 0) return 0;
! 	    else {
! 		/* If batchmode, bail out */
! 		if (pgpenvGetInt (ui->env, PGPENV_BATCHMODE, NULL, NULL)) {
! 		    StatusOutput(TRUE, "BAD_PASSPHRASE");
! 		    return -1;
! 		}
! 	    }
  	}
  
  	/*XXX Add code to detect if we're in batch mode without a passphrase*/
***************
*** 891,896 ****
--- 904,916 ----
  					 		key, keylen);
  				if (err > 0)
  					return 0; /* success */
+ 				else {
+ 				    /* If batchmode, bail out */
+ 				    if (pgpenvGetInt (ui->env, PGPENV_BATCHMODE, NULL, NULL)) {
+ 					StatusOutput(TRUE, "BAD_PASSPHRASE");
+ 					return PGPANN_PARSER_EATIT;
+ 				    }
+ 				}
  
  				/* Ignore errors, err < 0 */
  			}
