This is a patch for pgp5.0i-b8 to compile under NeXTSTEP 3.3.  It's based
on Marcel Waldvogels <mwa@tik.ee.ethz.ch> first patch, but has several
cleanups/modifications, including next font encoding and a small bugfix.

Here is Marcels original 'Readme':
> Here are some diffs to make PGP 5.0(i) b8 compile under NS 3.3 for
> Intel (and probably other versions of NS and OPENSTEP for Mach).

it does run under m68k and intel

> Several things were changed in the diff below:
> - In a number of files, ther is just an additional #include <libc.h>
>   if __NeXT__ is there (if more platforms need the same change, it
>   may be wise to autoconf a HAVE_LIBC_H)
> - "mode_t" is defined in pgpTypes.h (might be another candidate
>   for autoconf)
> - In pgpZInflate.c, the preprocessor expanded the "bits" and "exop"
>   macros too often when called in macro arguments, therefore they
>   were globally renamed to "Bits" and "Exop".
> - Only GCC versions starting around 2.5 supports "..." in macro
>   definitions.

both are problems with the NeXT cpp-precomp -> use /lib/cpp instead

> 
> Additionally, the following changes need to be made in the apps
> Makefiles:
> - src/apps/pgpk/Makefile:
>   For termcap, the LIBS= line needs to be changed to:
> LIBS=   $(LIBTTYUI) $(LIBPGP) $(LIBBN) $(LIBSIMPLE) -lm  -lsys_s -lposix
> - src/apps/pgp/Makefile: For termcap and to work around a linker
>   bug (?), the LIBS= line needs to be changed to:
> LIBS=   ../../lib/pgp/keydb/pgpKeyLib.o $(LIBTTYUI) $(LIBPGP) $(LIBBN)  
> $(LIBSIMPLE) -lm  -lsys_s -lposix
> 
> -Marcel

I removed the need for the (buggy) posix library and the problems with the
preprocessor.

With the original NeXT cc (gcc version 2.5.8) set CFLAGS to
'-traditional-cpp' before running 'configure' (don't forget to add your
favorite -arch ...)
The 'traditional' gcc will use cpp anyway.

Now change src/apps/pgp/Makefile to
LIBS= ../../lib/pgp/keydb/pgpKeyLib.o $(LIBTTYUI) $(LIBPGP) $(LIBBN) $(LIBSIMPLE) -lm


This patch will also add support for the NeXTSTEP font encoding and
fix a bug in printing keys with a '%' in the userid.

	Henrik
---
Henrik Hempelmann                   marsu@in-berlin.de (NeXT/MIME/PGP-Mail)
                                               http://home.pages.de/~marsu/
      individual network berlin - internet von privat fuer privat


diff -rc pgp50i-b8/src/apps/pgp/pgp.c pgp50i-b8.next/src/apps/pgp/pgp.c
*** pgp50i-b8/src/apps/pgp/pgp.c	Sat Aug  9 23:45:39 1997
--- pgp50i-b8.next/src/apps/pgp/pgp.c	Thu Aug 28 17:24:08 1997
***************
*** 36,41 ****
--- 36,46 ----
  #include <limits.h>		/* for PATH_MAX */
  #endif
  #include <ctype.h>
+ #ifdef __NeXT__
+ #include <libc.h>
+ #include <sys/param.h>
+ #define PATH_MAX MAXPATHLEN
+ #endif
  
  #include "pgpDebug.h"
  #include "pgpArmrFil.h"
diff -rc pgp50i-b8/src/apps/pgpk/pgpkUI.c pgp50i-b8.next/src/apps/pgpk/pgpkUI.c
*** pgp50i-b8/src/apps/pgpk/pgpkUI.c	Sat Aug  9 23:45:39 1997
--- pgp50i-b8.next/src/apps/pgpk/pgpkUI.c	Thu Aug 28 19:57:03 1997
***************
*** 295,301 ****
  	p = str;	/* Remember start of substring */
  	while (len) {
  	    c = (unsigned char)*str;
! 	    if (!isprint(c) || c == '\\' || c == q2)
  		break;
  	    str++;
  	    len--;
--- 295,301 ----
  	p = str;	/* Remember start of substring */
  	while (len) {
  	    c = (unsigned char)*str;
! 	    if (!isprint(c) || c == '\\' || c == q2 || c == '%')
  		break;
  	    str++;
  	    len--;
***************
*** 326,331 ****
--- 326,337 ----
  	len--;
  	str++;
  
+ 	/* special handling of '%' for vfprintf */
+ 	if (c == '%') {
+ 	    SpecifiedOutputString(FALSE, OutputType, 0, "%c", c);
+ 	    continue;
+ 	}
+ 	
  	/* Start with the obligatory backslash */
  	SpecifiedOutputString(FALSE, OutputType, 0, "\\");
  	if (!--remaining)
diff -rc pgp50i-b8/src/lib/pgp/helper/pgpCharMap.c pgp50i-b8.next/src/lib/pgp/helper/pgpCharMap.c
*** pgp50i-b8/src/lib/pgp/helper/pgpCharMap.c	Sat Aug  9 23:44:52 1997
--- pgp50i-b8.next/src/lib/pgp/helper/pgpCharMap.c	Thu Aug 28 17:24:10 1997
***************
*** 374,379 ****
--- 374,463 ----
  /* *INDENT-ON* */
  /**********************************************************************/
  
+ /* Conversion table from `latin1' charset to `next' charset.
+    Generated mechanically by GNU recode 3.4.
+ 
+    The recoding should be reversible.
+ */
+ 
+ unsigned char const latin1_to_next[256] =
+   {
+       0,   1,   2,   3,   4,   5,   6,   7,	/*   0 -   7 */
+       8,   9,  10,  11,  12,  13,  14,  15,	/*   8 -  15 */
+      16,  17,  18,  19,  20,  21,  22,  23,	/*  16 -  23 */
+      24,  25,  26,  27,  28,  29,  30,  31,	/*  24 -  31 */
+      32,  33,  34,  35,  36,  37,  38,  39,	/*  32 -  39 */
+      40,  41,  42,  43,  44,  45,  46,  47,	/*  40 -  47 */
+      48,  49,  50,  51,  52,  53,  54,  55,	/*  48 -  55 */
+      56,  57,  58,  59,  60,  61,  62,  63,	/*  56 -  63 */
+      64,  65,  66,  67,  68,  69,  70,  71,	/*  64 -  71 */
+      72,  73,  74,  75,  76,  77,  78,  79,	/*  72 -  79 */
+      80,  81,  82,  83,  84,  85,  86,  87,	/*  80 -  87 */
+      88,  89,  90,  91,  92,  93,  94,  95,	/*  88 -  95 */
+      96,  97,  98,  99, 100, 101, 102, 103,	/*  96 - 103 */
+     104, 105, 106, 107, 108, 109, 110, 111,	/* 104 - 111 */
+     112, 113, 114, 115, 116, 117, 118, 119,	/* 112 - 119 */
+     120, 121, 122, 123, 124, 125, 126, 127,	/* 120 - 127 */
+     169, 185, 193, 183, 195, 196, 197, 199,	/* 128 - 135 */
+     164, 178, 202, 184, 179, 205, 206, 207,	/* 136 - 143 */
+     208, 177, 188, 189, 172, 248, 198, 186,	/* 144 - 151 */
+     245, 254, 232, 170, 234, 166, 250, 255,	/* 152 - 159 */
+     128, 161, 162, 163, 168, 165, 181, 167,	/* 160 - 167 */
+     200, 160, 227, 171, 190, 173, 176, 175,	/* 168 - 175 */
+     174, 209, 201, 204, 194, 157, 182, 180,	/* 176 - 183 */
+     203, 192, 235, 187, 210, 211, 212, 191,	/* 184 - 191 */
+     129, 130, 131, 132, 133, 134, 225, 135,	/* 192 - 199 */
+     136, 137, 138, 139, 140, 141, 142, 143,	/* 200 - 207 */
+     144, 145, 146, 147, 148, 149, 150, 158,	/* 208 - 215 */
+     233, 151, 152, 153, 154, 155, 156, 251,	/* 216 - 223 */
+     213, 214, 215, 216, 217, 218, 241, 219,	/* 224 - 231 */
+     220, 221, 222, 223, 224, 226, 228, 229,	/* 232 - 239 */
+     230, 231, 236, 237, 238, 239, 240, 159,	/* 240 - 247 */
+     249, 242, 243, 244, 246, 247, 252, 253,	/* 248 - 255 */
+   };
+ 
+ /* Conversion table from `next' charset to `latin1' charset.
+    Generated mechanically by GNU recode 3.4.
+ 
+    The recoding should be reversible.
+ */
+ 
+ unsigned char const next_to_latin1[256] =
+   {
+       0,   1,   2,   3,   4,   5,   6,   7,	/*   0 -   7 */
+       8,   9,  10,  11,  12,  13,  14,  15,	/*   8 -  15 */
+      16,  17,  18,  19,  20,  21,  22,  23,	/*  16 -  23 */
+      24,  25,  26,  27,  28,  29,  30,  31,	/*  24 -  31 */
+      32,  33,  34,  35,  36,  37,  38,  39,	/*  32 -  39 */
+      40,  41,  42,  43,  44,  45,  46,  47,	/*  40 -  47 */
+      48,  49,  50,  51,  52,  53,  54,  55,	/*  48 -  55 */
+      56,  57,  58,  59,  60,  61,  62,  63,	/*  56 -  63 */
+      64,  65,  66,  67,  68,  69,  70,  71,	/*  64 -  71 */
+      72,  73,  74,  75,  76,  77,  78,  79,	/*  72 -  79 */
+      80,  81,  82,  83,  84,  85,  86,  87,	/*  80 -  87 */
+      88,  89,  90,  91,  92,  93,  94,  95,	/*  88 -  95 */
+      96,  97,  98,  99, 100, 101, 102, 103,	/*  96 - 103 */
+     104, 105, 106, 107, 108, 109, 110, 111,	/* 104 - 111 */
+     112, 113, 114, 115, 116, 117, 118, 119,	/* 112 - 119 */
+     120, 121, 122, 123, 124, 125, 126, 127,	/* 120 - 127 */
+     160, 192, 193, 194, 195, 196, 197, 199,	/* 128 - 135 */
+     200, 201, 202, 203, 204, 205, 206, 207,	/* 136 - 143 */
+     208, 209, 210, 211, 212, 213, 214, 217,	/* 144 - 151 */
+     218, 219, 220, 221, 222, 181, 215, 247,	/* 152 - 159 */
+     169, 161, 162, 163, 136, 165, 157, 167,	/* 160 - 167 */
+     164, 128, 155, 171, 148, 173, 176, 175,	/* 168 - 175 */
+     174, 145, 137, 140, 183, 166, 182, 131,	/* 176 - 183 */
+     139, 129, 151, 187, 146, 147, 172, 191,	/* 184 - 191 */
+     185, 130, 180, 132, 133, 134, 150, 135,	/* 192 - 199 */
+     168, 178, 138, 184, 179, 141, 142, 143,	/* 200 - 207 */
+     144, 177, 188, 189, 190, 224, 225, 226,	/* 208 - 215 */
+     227, 228, 229, 231, 232, 233, 234, 235,	/* 216 - 223 */
+     236, 198, 237, 170, 238, 239, 240, 241,	/* 224 - 231 */
+     154, 216, 156, 186, 242, 243, 244, 245,	/* 232 - 239 */
+     246, 230, 249, 250, 251, 152, 252, 253,	/* 240 - 247 */
+     149, 248, 158, 223, 254, 255, 153, 159,	/* 248 - 255 */
+   };
+ 
  /* Charset tables */
  static struct ConfMapping {
          char const *name;
***************
*** 383,388 ****
--- 467,473 ----
          { "ascii",      charMapIdentity,        latin1_to_ascii },
          { "cp850",      cp850_to_latin1,        latin1_to_cp850 },
          { "ebcdic",     ebcdic_to_latin1,       latin1_to_ebcdic },
+         { "next",       next_to_latin1,         latin1_to_next },
          { (char const *)0, 0, 0 }
  };
  
diff -rc pgp50i-b8/src/lib/pgp/helper/pgpTypes.h pgp50i-b8.next/src/lib/pgp/helper/pgpTypes.h
*** pgp50i-b8/src/lib/pgp/helper/pgpTypes.h	Sat Aug  9 23:44:57 1997
--- pgp50i-b8.next/src/lib/pgp/helper/pgpTypes.h	Thu Aug 28 17:24:10 1997
***************
*** 48,53 ****
--- 48,57 ----
  #define 	alignof(type) (sizeof(struct{type _x; char _y;}) - sizeof(type))
  #endif
  
+ #if __NeXT__
+ typedef unsigned short mode_t;
+ #endif
+ 
  #endif /* ] PGPTYPES_H */
  
  /*
diff -rc pgp50i-b8/src/lib/pgp/keydb/pgpPrefUnix.c pgp50i-b8.next/src/lib/pgp/keydb/pgpPrefUnix.c
*** pgp50i-b8/src/lib/pgp/keydb/pgpPrefUnix.c	Mon Aug 11 02:05:32 1997
--- pgp50i-b8.next/src/lib/pgp/keydb/pgpPrefUnix.c	Thu Aug 28 17:24:11 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 -rc pgp50i-b8/src/lib/pgp/utils/pgpEnv.c pgp50i-b8.next/src/lib/pgp/utils/pgpEnv.c
*** pgp50i-b8/src/lib/pgp/utils/pgpEnv.c	Sat Aug  9 23:44:33 1997
--- pgp50i-b8.next/src/lib/pgp/utils/pgpEnv.c	Thu Aug 28 17:24:11 1997
***************
*** 84,90 ****
--- 84,94 ----
  #ifdef MSDOS
  			pgpenvSetString (env, PGPENV_CHARSET, "cp850", PGPENV_PRI_PUBDEFAULT);
  #else
+ #ifdef __Next__
+ 			pgpenvSetString (env, PGPENV_CHARSET, "next", PGPENV_PRI_PUBDEFAULT);
+ #else
  			pgpenvSetString (env, PGPENV_CHARSET, "noconv", PGPENV_PRI_PUBDEFAULT);
+ #endif
  #endif
  		
  			return env;
diff -rc pgp50i-b8/src/lib/ttyui/pgpKBUnix.c pgp50i-b8.next/src/lib/ttyui/pgpKBUnix.c
*** pgp50i-b8/src/lib/ttyui/pgpKBUnix.c	Sat Aug  9 23:45:20 1997
--- pgp50i-b8.next/src/lib/ttyui/pgpKBUnix.c	Thu Aug 28 17:24:12 1997
***************
*** 20,25 ****
--- 20,29 ----
  #include <stdio.h>
  #include <sys/types.h>
  
+ #if __NeXT__
+ #define NOTERMIO 1
+ #endif
+ 
  /* How to get cbreak mode */
  
  #if defined(NOTERMIO)
***************
*** 230,236 ****
--- 234,242 ----
  	if (thorough)
  		sleep(1);
  #if defined(TCIFLUSH)
+ #ifndef __NeXT__
  	tcflush(kbFd, TCIFLUSH);
+ #endif
  #elif defined(TIOCFLUSH)
  #ifndef FREAD
  #define FREAD 1	/* The usual value */
diff -rc pgp50i-b8/src/lib/ttyui/pgpOutput.h pgp50i-b8.next/src/lib/ttyui/pgpOutput.h
*** pgp50i-b8/src/lib/ttyui/pgpOutput.h	Sat Aug  9 23:45:36 1997
--- pgp50i-b8.next/src/lib/ttyui/pgpOutput.h	Thu Aug 28 17:24:12 1997
***************
*** 7,12 ****
--- 7,16 ----
   *
   * $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 -rc pgp50i-b8/src/lib/ttyui/pgpRingUI.c pgp50i-b8.next/src/lib/ttyui/pgpRingUI.c
*** pgp50i-b8/src/lib/ttyui/pgpRingUI.c	Mon Aug 11 02:05:33 1997
--- pgp50i-b8.next/src/lib/ttyui/pgpRingUI.c	Thu Aug 28 21:11:54 1997
***************
*** 313,319 ****
  	p = str;	/* Remember start of substring */
  	while (len) {
  	    c = (unsigned char)*str;
! 	    if (!isprint(c) || c == '\\' || c == q2)
  		break;
  	    str++;
  	    len--;
--- 313,319 ----
  	p = str;	/* Remember start of substring */
  	while (len) {
  	    c = (unsigned char)*str;
! 	    if (!isprint(c) || c == '\\' || c == q2 || c == '%')
  		break;
  	    str++;
  	    len--;
***************
*** 344,349 ****
--- 344,355 ----
  	len--;
  	str++;
  
+ 	/* special handling of '%' for vfprintf */
+ 	if (c == '%') {
+ 	    SpecifiedOutputString(FALSE, OutputType, 0, "%c", c);
+ 	    continue;
+ 	}
+ 	
  	/* Start with the obligatory backslash */
  	SpecifiedOutputString(FALSE, OutputType, 0, "\\");
  	if (!--remaining)
diff -rc pgp50i-b8/src/lib/ttyui/pgpScrUnix.c pgp50i-b8.next/src/lib/ttyui/pgpScrUnix.c
*** pgp50i-b8/src/lib/ttyui/pgpScrUnix.c	Sat Aug  9 23:45:21 1997
--- pgp50i-b8.next/src/lib/ttyui/pgpScrUnix.c	Thu Aug 28 17:24:12 1997
***************
*** 26,31 ****
--- 26,35 ----
  #include <sys/ptem.h>
  #endif
  
+ #if __NeXT__
+ #define NOTERMIO 1
+ #endif
+ 
  #ifdef SVR2	/* SVR2 has wierd headers */
  
  #ifndef NOTERMIO
diff -rc pgp50i-b8/src/lib/ttyui/pgpUserIO.c pgp50i-b8.next/src/lib/ttyui/pgpUserIO.c
*** pgp50i-b8/src/lib/ttyui/pgpUserIO.c	Mon Aug 11 02:05:33 1997
--- pgp50i-b8.next/src/lib/ttyui/pgpUserIO.c	Thu Aug 28 17:24:12 1997
***************
*** 37,42 ****
--- 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"

