--- vnc-3.3.7.orig/rfb/Makefile.in
+++ vnc-3.3.7/rfb/Makefile.in
@@ -1,4 +1,9 @@
+# Debian
+LOBJS = vncauth.lo d3des.lo
+SHLIBLDFLAGS=-shared
+REV = 0.0
 
+# Original
 SRCS = d3des.c vncauth.c
 
 OBJS = d3des.o vncauth.o
@@ -7,11 +12,31 @@
 
 library = librfb.a
 
-all:: $(library)
+all:: $(library) libvncauth.so.$(REV) libvncauth.a
 
 $(library): $(OBJS)
 	rm -f $(library)
 	$(AR) $(library) $(OBJS)
 	$(RANLIB) $(library)
+
+# Debian, loadable library.
+$(LOBJS): %.lo: %.c
+	$(CC) -c -fPIC $(CFLAGS) $(ALL_CPPFLAGS) -o $@ $<
+
+libvncauth.a: $(OBJS) $(EXTRALIBRARYDEPS)
+	$(RM) $@
+	$(AR) $@ $(OBJS)
+	$(RANLIB) $@
+
+libvncauth.so.$(REV): $(LOBJS) $(EXTRALIBRARYDEPS)
+	$(RM) $@
+	@SONAME=`echo $@ | sed 's/\.[^\.]*$$//'`; set -x; \
+	$(CC) -o $@ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME $(LOBJS) $(REQUIREDLIBS) -lc; \
+	$(RM) $$SONAME; ln -s $@ $$SONAME 
+	$(RM) libvncauth.so 
+	ln -s $@ libvncauth.so
+
+clean::
+	-rm -f *.so* *.lo *.a
 
 # followed by boilerplate.mk
--- vnc-3.3.7.orig/Xvnc/lib/font/fc/fserve.c
+++ vnc-3.3.7/Xvnc/lib/font/fc/fserve.c
@@ -1232,6 +1232,9 @@
     int         err;
     fsGenericReply rep;
 
+    if (awaiting_reconnect) {
+	_fs_try_reconnect();
+    }
     /* see if there's any data to be read */
 
     /* 
--- vnc-3.3.7.orig/Xvnc/lib/Xdmcp/Wraphelp.c
+++ vnc-3.3.7/Xvnc/lib/Xdmcp/Wraphelp.c
@@ -0,0 +1,401 @@
+/*
+ * This program implements the
+ * Proposed Federal Information Processing
+ *  Data Encryption Standard.
+ * See Federal Register, March 17, 1975 (40FR12134)
+ */
+
+/*
+ * Initial permutation,
+ */
+static char    IP[] = {
+       58,50,42,34,26,18,10, 2,
+       60,52,44,36,28,20,12, 4,
+       62,54,46,38,30,22,14, 6,
+       64,56,48,40,32,24,16, 8,
+       57,49,41,33,25,17, 9, 1,
+       59,51,43,35,27,19,11, 3,
+       61,53,45,37,29,21,13, 5,
+       63,55,47,39,31,23,15, 7,
+};
+
+/*
+ * Final permutation, FP = IP^(-1)
+ */
+static char    FP[] = {
+       40, 8,48,16,56,24,64,32,
+       39, 7,47,15,55,23,63,31,
+       38, 6,46,14,54,22,62,30,
+       37, 5,45,13,53,21,61,29,
+       36, 4,44,12,52,20,60,28,
+       35, 3,43,11,51,19,59,27,
+       34, 2,42,10,50,18,58,26,
+       33, 1,41, 9,49,17,57,25,
+};
+
+/*
+ * Permuted-choice 1 from the key bits
+ * to yield C and D.
+ * Note that bits 8,16... are left out:
+ * They are intended for a parity check.
+ */
+static char    PC1_C[] = {
+       57,49,41,33,25,17, 9,
+        1,58,50,42,34,26,18,
+       10, 2,59,51,43,35,27,
+       19,11, 3,60,52,44,36,
+};
+
+static char    PC1_D[] = {
+       63,55,47,39,31,23,15,
+        7,62,54,46,38,30,22,
+       14, 6,61,53,45,37,29,
+       21,13, 5,28,20,12, 4,
+};
+
+/*
+ * Sequence of shifts used for the key schedule.
+*/
+static char    shifts[] = {
+       1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
+};
+
+/*
+ * Permuted-choice 2, to pick out the bits from
+ * the CD array that generate the key schedule.
+ */
+static char    PC2_C[] = {
+       14,17,11,24, 1, 5,
+        3,28,15, 6,21,10,
+       23,19,12, 4,26, 8,
+       16, 7,27,20,13, 2,
+};
+
+static char    PC2_D[] = {
+       41,52,31,37,47,55,
+       30,40,51,45,33,48,
+       44,49,39,56,34,53,
+       46,42,50,36,29,32,
+};
+
+/*
+ * The C and D arrays used to calculate the key schedule.
+ */
+
+static char    C[28];
+static char    D[28];
+
+/*
+ * The key schedule.
+ * Generated from the key.
+ */
+static char    KS[16][48];
+
+/*
+ * The E bit-selection table.
+ */
+static char    E[48];
+static char    e[] = {
+       32, 1, 2, 3, 4, 5,
+        4, 5, 6, 7, 8, 9,
+        8, 9,10,11,12,13,
+       12,13,14,15,16,17,
+       16,17,18,19,20,21,
+       20,21,22,23,24,25,
+       24,25,26,27,28,29,
+       28,29,30,31,32, 1,
+};
+
+/*
+ * Set up the key schedule from the key.
+ */
+
+static
+setkey(key)
+char *key;
+{
+       int     i, j, k;
+       int     t;
+       char    *ptr;
+
+       /*
+        * First, generate C and D by permuting
+        * the key.  The low order bit of each
+        * 8-bit char is not used, so C and D are only 28
+        * bits apiece.
+        */
+       for (i=0; i<28; i++) {
+               C[i] = key[PC1_C[i]-1];
+               D[i] = key[PC1_D[i]-1];
+       }
+       /*
+        * To generate Ki, rotate C and D according
+        * to schedule and pick up a permutation
+        * using PC2.
+        */
+       for (i=0; i<16; i++) {
+               /*
+                * rotate.
+                */
+               for (k=0; k<shifts[i]; k++) {
+                       t = C[0];
+                       ptr = C;
+                       for (j=0; j<28-1; j++)
+                       {
+                               *ptr = ptr[1];
+                               ptr++;
+                       }
+                       C[27] = t;
+                       t = D[0];
+                       ptr = D;
+                       for (j=0; j<28-1; j++)
+                       {
+                               *ptr = ptr[1];
+                               ptr++;
+                       }
+                       D[27] = t;
+               }
+               /*
+                * get Ki. Note C and D are concatenated.
+                */
+               ptr = &KS[i][0];
+               for (j=0; j<24; j++) {
+                       ptr[j] = C[PC2_C[j]-1];
+                       ptr[j+24] = D[PC2_D[j]-28-1];
+               }
+       }
+
+       for(i=0;i<48;i++)
+               E[i] = e[i];
+}
+
+/*
+ * The 8 selection functions.
+ * For some reason, they give a 0-origin
+ * index, unlike everything else.
+ */
+static char    S[8][64] = {
+       14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
+        0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
+        4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
+       15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
+
+       15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
+        3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
+        0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
+       13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
+
+       10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
+       13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
+       13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
+        1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
+
+        7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
+       13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
+       10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
+        3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
+
+        2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
+       14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
+        4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
+       11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
+
+       12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
+       10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
+        9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
+        4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
+
+        4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
+       13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
+        1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
+        6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
+
+       13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
+        1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
+        7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
+        2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
+};
+
+/*
+ * P is a permutation on the selected combination
+ * of the current L and key.
+ */
+static char    P[] = {
+       16, 7,20,21,
+       29,12,28,17,
+        1,15,23,26,
+        5,18,31,10,
+        2, 8,24,14,
+       32,27, 3, 9,
+       19,13,30, 6,
+       22,11, 4,25,
+};
+
+/*
+ * The current block, divided into 2 halves.
+ */
+
+static char    L[64];
+#define R   (L + 32)
+static char    tempL[32];
+static char    f[32];
+
+/*
+ * The combination of the key and the input, before selection.
+ */
+static char    preS[48];
+
+/*
+ * The payoff: encrypt a block.
+ */
+
+static
+encrypt (block, edflag)
+char *block;
+{
+       int i, ii;
+       register t, j, k;
+
+       /*
+        * First, permute the bits in the input
+        */
+       for (j=0; j<64; j++)
+               L[j] = block[IP[j]-1];
+       /*
+        * Perform an encryption operation 16 times.
+        */
+       for (ii=0; ii<16; ii++) {
+/*             print_bits ("L R", L); */
+               /*
+                * Set direction
+                */
+               if (edflag)
+                       i = 15-ii;
+               else
+                       i = ii;
+               /*
+                * Save the R array,
+                * which will be the new L.
+                */
+               for (j=0; j<32; j++)
+                       tempL[j] = R[j];
+               /*
+                * Expand R to 48 bits using the E selector;
+                * exclusive-or with the current key bits.
+                */
+               for (j=0; j<48; j++)
+                       preS[j] = R[E[j]-1] ^ KS[i][j];
+               /*
+                * The pre-select bits are now considered
+                * in 8 groups of 6 bits each.
+                * The 8 selection functions map these
+                * 6-bit quantities into 4-bit quantities
+                * and the results permuted
+                * to make an f(R, K).
+                * The indexing into the selection functions
+                * is peculiar; it could be simplified by
+                * rewriting the tables.
+                */
+               for (j=0; j<8; j++) {
+                       t = 6*j;
+                       k = S[j][(preS[t+0]<<5)+
+                               (preS[t+1]<<3)+
+                               (preS[t+2]<<2)+
+                               (preS[t+3]<<1)+
+                               (preS[t+4]<<0)+
+                               (preS[t+5]<<4)];
+                       t = 4*j;
+                       f[t+0] = (k>>3)&01;
+                       f[t+1] = (k>>2)&01;
+                       f[t+2] = (k>>1)&01;
+                       f[t+3] = (k>>0)&01;
+               }
+               /*
+                * The new R is L ^ f(R, K).
+                * The f here has to be permuted first, though.
+                */
+               for (j=0; j<32; j++)
+                       R[j] = L[j] ^ f[P[j]-1];
+               /*
+                * Finally, the new L (the original R)
+                * is copied back.
+                */
+               for (j=0; j<32; j++)
+                       L[j] = tempL[j];
+       }
+       /*
+        * The output L and R are reversed.
+        */
+       for (j=0; j<32; j++) {
+               t = L[j];
+               L[j] = R[j];
+               R[j] = t;
+       }
+       /*
+        * The final output
+        * gets the inverse permutation of the very original.
+        */
+       for (j=0; j<64; j++)
+               block[j] = L[FP[j]-1];
+}
+
+static
+bytes_to_bits (bytes, bits)
+    unsigned char   *bytes;
+    char           *bits;
+{
+    int            bit, byte, value;
+
+    for (byte = 0; byte < 8; byte++)
+    {
+       value = *bytes++;
+       for (bit = 0; bit < 8; bit++)
+           *bits++ = (value >> (7-bit)) & 1;
+    }
+}
+
+static
+bits_to_bytes (bits, bytes)
+    char           *bits;
+    unsigned char   *bytes;
+{
+    int            bit, byte, value;
+
+    for (byte = 0; byte < 8; byte++)
+    {
+       value = 0;
+       for (bit = 0; bit < 8; bit++)
+           value |= *bits++ << (7-bit);
+       *bytes++ = value;
+    }
+}
+
+/*
+ * Interface compatible with Kerberos DES implementation
+ */
+
+# include   "Wrap.h"
+
+/*ARGSUSED*/
+_XdmcpAuthSetup (key, schedule)
+    auth_cblock                key;
+    auth_wrapper_schedule      schedule;
+{
+    char    expand_key[64];
+
+    bytes_to_bits ((unsigned char *) key, expand_key);
+    setkey (expand_key);
+}
+
+/*ARGSUSED*/
+_XdmcpAuthDoIt (input, output, schedule, edflag)
+    auth_cblock                input, output;
+    auth_wrapper_schedule      schedule;
+    int                        edflag;
+{
+    char    expand_input[64];
+
+    bytes_to_bits ((unsigned char *) input, expand_input);
+    encrypt (expand_input, !edflag);
+    bits_to_bytes (expand_input, (unsigned char *) output);
+}
--- vnc-3.3.7.orig/Xvnc/lib/xtrans/Xtranssock.c
+++ vnc-3.3.7/Xvnc/lib/xtrans/Xtranssock.c
@@ -940,8 +940,8 @@
     oldUmask = umask (0);
 
 #ifdef UNIX_DIR
-    if (!mkdir (UNIX_DIR, 0777))
-        chmod (UNIX_DIR, 0777);
+    if (!mkdir (UNIX_DIR, 01777))
+        chmod (UNIX_DIR, 01777);
 #endif
 
     sockname.sun_family = AF_UNIX;
@@ -1029,8 +1029,8 @@
 	int oldUmask = umask (0);
 
 #ifdef UNIX_DIR
-	if (!mkdir (UNIX_DIR, 0777))
-	    chmod (UNIX_DIR, 0777);
+	if (!mkdir (UNIX_DIR, 01777))
+	    chmod (UNIX_DIR, 01777);
 #endif
 
 	close (ciptr->fd);
--- vnc-3.3.7.orig/Xvnc/lib/xtrans/Xtranslcl.c
+++ vnc-3.3.7/Xvnc/lib/xtrans/Xtranslcl.c
@@ -1046,8 +1046,8 @@
      */
 #define X_UNIX_DIR	"/tmp/.X11-unix"
     
-    if (!mkdir(X_UNIX_DIR, 0777))
-	chmod(X_UNIX_DIR, 0777);
+    if (!mkdir(X_UNIX_DIR, 01777))
+	chmod(X_UNIX_DIR, 01777);
     
     unlink(server_unix_path);
     
--- vnc-3.3.7.orig/Xvnc/Makefile
+++ vnc-3.3.7/Xvnc/Makefile
@@ -18,7 +18,7 @@
 DEPENDTOP = ../..
 IMAKETOP = ../..
 IRULESRC = $(CONFIGSRC)/cf
-IMAKE = $(IMAKESRC)/imake
+IMAKE = imake
 IMAKE_CMD = $(IMAKE) -I$(IRULESRC) $(IMAKE_DEFINES)
 MAKE_OPTS = -f xmakefile
 MAKE_CMD = $(MAKE) $(MAKE_OPTS)
--- vnc-3.3.7.orig/Xvnc/config/cf/Imake.cf
+++ vnc-3.3.7/Xvnc/config/cf/Imake.cf
@@ -1,5 +1,4 @@
-XCOMM $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $
-XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.34.2.3 1997/07/27 02:41:02 dawes Exp $
+XCOMM $Xorg: Imake.cf,v 1.4 2000/08/17 19:41:45 cpqbld Exp $
 /*
  * To add support for another platform:
  * 
@@ -18,6 +17,22 @@
  *
  *     4.  Create a .cf file with the name given by MacroFile.
  */
+XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.66 2001/04/18 16:13:17 dawes Exp $
+
+#if defined(__APPLE__)
+# undef __APPLE__
+# define MacroIncludeFile <darwin.cf>
+# define MacroFile darwin.cf
+# define DarwinArchitecture
+# ifdef __ppc__
+#  define PpcDarwinArchitecture
+#  undef __ppc__
+# endif
+# ifdef __i386__
+#  define i386DarwinArchitecture
+#  undef __i386__
+# endif
+#endif
 
 #if defined(clipper) || defined(__clipper__)
 # undef clipper
@@ -26,6 +41,17 @@
 # define IngrArchitecture
 #endif /* clipper */
 
+#ifdef __CYGWIN__
+#define MacroIncludeFile <cygwin.cf>
+#define MacroFile cygwin.cf
+#define cygwinArchitecture
+#define i386Architecture
+#undef i386
+#undef __i386__
+#undef _X86_
+#undef __CYGWIN__
+#endif /* CYGWIN */
+
 #ifdef ultrix
 # define MacroIncludeFile <ultrix.cf>
 # define MacroFile ultrix.cf
@@ -36,6 +62,7 @@
 # ifdef mips
 #  undef mips
 #  define MipsArchitecture
+#  define MipselArchitecture
 # endif
 # undef ultrix
 # define UltrixArchitecture
@@ -53,10 +80,19 @@
 # define MacroIncludeFile <bsdi.cf>
 # define MacroFile bsdi.cf
 # undef bsdi
-# define BSD386Architecture
-# define i386BsdArchitecture
-# define i386Architecture
-# undef i386
+# define BSDOSArchitecture
+# if defined(__i386__) || defined(i386)
+#  define i386BsdArchitecture
+#  define i386Architecture
+#  undef i386
+#  undef __i386__
+# endif
+# if defined(__sparc__) || defined(__sparc_v9__) || defined(sparc)
+#  define SparcArchitecture
+#  undef sparc
+#  undef __sparc__
+#  undef __sparc_v9__
+# endif
 #endif /* bsdi */
 
 #ifdef __OpenBSD__
@@ -114,6 +150,10 @@
 #  endif
 #  undef mc68000
 # endif
+# ifdef __powerpc__
+#  define PpcArchitecture
+#  undef __powerpc__
+# endif
 #endif /* OpenBSD */
 
 #ifdef __NetBSD__
@@ -142,6 +182,18 @@
 # ifdef mc68000
 #   define Mc68020Architecture
 # endif
+# ifdef __arm32__
+#   define Arm32Architecture
+#   undef __arm32__
+# endif
+# ifdef __vax__
+#   define VaxArchitecture
+#   undef __vax__
+# endif
+# ifdef __powerpc__
+#   define PpcArchitecture
+#   undef __powerpc__
+# endif
 #endif /* NetBSD */
 
 #ifdef __FreeBSD__
@@ -154,6 +206,11 @@
 #  define i386Architecture
 #  undef i386
 # endif
+# ifdef __alpha__
+#  define AlphaBsdArchitecture
+#  define AlphaArchitecture
+#  undef __alpha__
+# endif
 #endif /* __FreeBSD__ */
 
 #ifdef AMOEBA
@@ -319,6 +376,7 @@
 # undef sgi
 # define SGIArchitecture
 # undef mips
+# undef __mips
 # define MipsArchitecture
 # ifdef _SVR4
 #  undef _SVR4
@@ -400,7 +458,7 @@
 # endif
 #endif /* MOTOROLA */
 
-#ifdef SVR4
+#if defined(SVR4) && !defined(DGUX)
 # ifdef i386
 #  define i386Architecture
 #  undef i386
@@ -494,6 +552,8 @@
 #endif /* SYSV386 */
 
 #ifdef DGUX
+# define i386Architecture
+# define SVR4Architecture
 # define MacroIncludeFile <DGUX.cf>
 # define MacroFile DGUX.cf
 # undef DGUX
@@ -517,6 +577,7 @@
 # ifdef __mips__
 #  undef __mips__
 #  define MipsArchitecture
+#  define MipselArchitecture
 # endif
 # ifdef __alpha
 #  undef __alpha
@@ -545,17 +606,211 @@
 # undef linux
 # define LinuxArchitecture
 # ifdef i386
-#  define i386Architecture
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
 #  undef i386
-# endif /* i386 */
+XCOMM Keep cpp from replacing path elements containing i486/i586/i686
+#  ifdef i486
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#   undef i486
+#  endif
+#  ifdef i586
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#   undef i586
+#  endif
+#  ifdef i686
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#   undef i686
+#  endif
+#  ifdef k6
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#   undef k6
+#  endif
+# endif /* k6 */
+# ifdef __i386__
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i386__
+# endif /* __i386__ */
+# ifdef __i486__
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i486__
+# endif /* __i486__ */
+# ifdef __i586__
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i586__
+# endif /* __i586__ */
+# ifdef __i686__
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i686__
+# endif /* __i686__ */
+# ifdef __k6__
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __k6__
+# endif /* __k6__ */
+# ifdef __i386
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i386
+# endif /* __i386 */
+# ifdef __i486
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i486
+# endif /* __i486 */
+# ifdef __i586
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i586
+# endif /* __i586 */
+# ifdef __i686
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __i686
+# endif /* __i686 */
+# ifdef __k6
+#  ifndef i386Architecture
+#   define i386Architecture
+#  endif
+#  undef __k6
+# endif /* __k6 */
+# ifdef __s390__
+#   define s390Architecture
+#  undef __s390__
+# endif /* s390 */
 # ifdef __alpha
 #  define AlphaArchitecture
 #  undef __alpha
 # endif /* __alpha */
+# ifdef __alpha__
+#  ifndef AlphaArchitecture
+#   define AlphaArchitecture
+#  endif
+#  undef __alpha__
+# endif /* __alpha__ */
+# ifdef __arm__
+#  define Arm32Architecture
+#  undef arm
+#  undef __arm
+#  undef __arm__
+# endif
 # ifdef mc68000
 #  define Mc68020Architecture
 #  undef mc68000
 # endif /* mc68000 */
+# ifdef powerpc
+#  define PpcArchitecture
+#  undef powerpc
+# endif
+# ifdef __powerpc__
+#  ifndef PpcArchitecture
+#   define PpcArchitecture
+#  endif
+#  undef __powerpc__
+# endif
+# ifdef sparc
+#  define SparcArchitecture
+#  undef sparc
+# endif
+# ifdef __sparc__
+#  ifndef SparcArchitecture
+#   define SparcArchitecture
+#  endif
+#  undef __sparc__
+# endif
+# ifdef x86_64 
+#  define x86_64Architecture
+#  undef x86_64 
+# endif
+# ifdef __x86_64__
+#  ifndef x86_64Architecture
+#   define x86_64Architecture
+#  endif
+#  undef __x86_64__
+# endif
+# ifdef ia64 
+#  define ia64Architecture
+#  undef ia64 
+# endif
+# ifdef __ia64__
+#  ifndef ia64Architecture
+#   define ia64Architecture
+#  endif
+#  undef __ia64__
+# endif
+# if defined(mips) || defined(__mips__)
+#  define MipsArchitecture
+#  undef mips
+#  undef __mips__
+#  if defined(MIPSEL) || defined(_MIPSEL)
+#   define MipselArchitecture
+#  endif
+#  undef MIPSEL
+#  undef _MIPSEL
+# endif
+# ifdef __hppa__
+#  ifndef HPArchitecture
+#   define HPArchitecture
+#  endif
+#  undef __hppa__
+# endif /* __hppa__ */
+# ifdef __sh__
+#  ifndef SuperHArchitecture
+#   define SuperHArchitecture
+#  endif
+#  ifdef __BIG_ENDIAN__
+#   ifndef SuperHebArchitecture
+#    define SuperHebArchitecture
+#   endif
+#  endif
+#  undef __sh__
+# endif /* __sh__ */
+# if defined(__SH3__) || defined(__sh3__)
+#  ifndef SuperH3Architecture
+#   define SuperH3Architecture
+#  endif
+#  undef __SH3__
+#  undef __sh3__
+# endif /* __SH3__ or __sh3__ */
+# ifdef __SH4__
+#  ifdef __SH4_NOFPU__
+#   ifndef SuperH4NOFPUArchitecture
+#    define SuperH4NOFPUArchitecture
+#   endif
+#   undef __SH4_NOFPU__
+#  else
+#   ifndef SuperH4Architecture
+#    define SuperH4Architecture
+#   endif
+#  endif
+#  undef __SH4__
+# endif /* __SH4__ */
+XCOMM  for compatibility with 3.3.x 
+# ifdef PpcArchitecture
+#  define PowerPCArchitecture
+# endif
 #endif /* linux */
 
 #if (defined(__Lynx__) || defined(Lynx)) && (defined(i386) || defined(__i386__) || defined(__x86__) || defined(__powerpc__) || defined(__sparc__) || defined(sparc))
@@ -572,7 +827,7 @@
 #  undef __x86__
 # endif
 # ifdef __powerpc__
-#  define ppcArchitecture
+#  define PpcArchitecture
 #  undef __powerpc__
 # endif
 # if defined(sparc) || defined(__sparc__)
@@ -580,6 +835,10 @@
 #  undef sparc
 #  undef __sparc__
 # endif
+/* for compatibility with 3.3.x */
+# ifdef PpcArchitecture
+#  define PowerPCArchitecture
+# endif
 #endif /* LynxOS AT/PPC/microSPARC */
 
 #ifdef __uxp__
@@ -603,17 +862,14 @@
 # define mc68000Architecture
 #endif /* __sxg__ */
 
-#if defined(sequent) || defined(_SEQUENT_)
+#ifdef _SEQUENT_
+/* undefine assignments resulting from -DSVR4 */
+# undef MacroIncludeFile
 # define MacroIncludeFile <sequent.cf>
+# undef MacroFile
 # define MacroFile sequent.cf
-# ifdef sequent
-#  undef sequent
-#  define Dynix3Architecture
-# endif
-# ifdef _SEQUENT_
-#  undef _SEQUENT_
-#  define DynixPtxArchitecture
-# endif
+# undef _SEQUENT_
+# define DynixPtxArchitecture
 # define SequentArchitecture
 #endif
 
@@ -635,8 +891,14 @@
 #endif /* minix */
 
 #ifdef MACH
+#ifdef __GNU__
+#define MacroIncludeFile <gnu.cf>
+#define MacroFile gnu.cf
+#define GNUMachArchitecture
+#else
 #define MacroIncludeFile <mach.cf>
 #define MacroFile mach.cf
+#endif
 #undef MACH
 #ifdef	i386
 #define i386MachArchitecture
@@ -645,12 +907,53 @@
 #undef i386
 #endif /* MACH */
 
+/* On NetBSD, `unix' is not defined, and cpp emits a warning every time
+ * it sees a test using the `unix' symbol */
+#if !defined(NetBSDArchitecture) || (defined(NetBSDArchitecture) && DefaultOSMajorVersion == 1 && DefaultOSMinorVersion <= 3)
+#ifdef unix
+#undef unix
+#endif
+#endif
+
 #ifdef emxos2
 #define MacroIncludeFile <os2.cf>
 #define MacroFile os2.cf
 #define OS2Architecture
 #define i386Architecture
 #endif /* emxos2 */
+
+#if defined(__QNX__) && !defined(__QNXNTO__)
+#define MacroIncludeFile <QNX4.cf>
+#define MacroFile QNX4.cf
+#define QNX4Architecture
+#define i386Architecture
+#endif /* QNX4 */
+
+#ifdef __QNXNTO__
+#define MacroIncludeFile <nto.cf>
+#define MacroFile nto.cf
+#define NTOArchitecture
+#ifdef PPC
+# define PPCArchitecture
+# undef PPC
+#else
+#ifdef MIPS
+# define mipsArchitecture
+# undef MIPS
+#else
+#ifdef i386
+# define i386Architecture
+# undef i386
+#endif
+#endif
+#endif
+#endif /* QNX/Neutrino */
+
+#ifdef SparcArchitecture
+# if defined(__sparc_v9) || defined(__arch64__)
+#  define Sparc64Architecture
+# endif
+#endif
 
 #ifndef MacroIncludeFile
 XCOMM WARNING:  Imake.cf not configured; guessing at definitions!!!
--- vnc-3.3.7.orig/Xvnc/config/cf/site.def
+++ vnc-3.3.7/Xvnc/config/cf/site.def
@@ -98,7 +98,7 @@
 ================================================================*/
 
 /* Only set HasXdmAuth to YES if you have a Wraphelp.c file. */
-/* #define HasXdmAuth YES */
+#define HasXdmAuth YES
 
 /* #define PreIncDir DefaultGccIncludeDir */
 
--- vnc-3.3.7.orig/Xvnc/config/cf/svr3.cf
+++ vnc-3.3.7/Xvnc/config/cf/svr3.cf
@@ -51,7 +51,7 @@
 #endif
 
 #ifndef XmanSearchPath
-#define XmanSearchPath		/usr/man
+#define XmanSearchPath		/usr/share/man
 #endif
 
 /*
--- vnc-3.3.7.orig/Xvnc/config/cf/Imake.tmpl
+++ vnc-3.3.7/Xvnc/config/cf/Imake.tmpl
@@ -487,7 +487,7 @@
 #if SystemV4
 #define SystemManDirectory /usr/share/man
 #else
-#define SystemManDirectory /usr/man
+#define SystemManDirectory /usr/share/man
 #endif
 #endif
 #ifndef ManDirectoryRoot
--- vnc-3.3.7.orig/Xvnc/config/cf/xfree86.cf
+++ vnc-3.3.7/Xvnc/config/cf/xfree86.cf
@@ -73,6 +73,14 @@
 #ifndef XF86I128Server
 #define XF86I128Server		YES
 #endif
+#ifndef XF86GLINTServer
+#define XF86GLINTServer		YES
+#endif
+#if defined(LinuxArchitecture)
+#ifndef XF86FBDevServer
+#define XF86FBDevServer		YES
+#endif
+#endif
 #endif
 
 /*
@@ -101,12 +109,26 @@
 #ifndef XF86SVGAServer
 #define XF86SVGAServer		YES
 #endif
+#ifndef XF86VGA16Server
+#define XF86VGA16Server		YES
+#endif
 #ifndef XF86MonoServer
 #define XF86MonoServer		YES
 #endif
+#ifndef XF86GLINTServer
+#define XF86GLINTServer		YES
+#endif
+#if defined(LinuxArchitecture)
+#ifndef XF86FBDevServer
+#define XF86FBDevServer		YES
+#endif
+#endif
 #ifndef XF86SvgaDrivers
 #define XF86SvgaDrivers		mga s3v
 #endif
+#ifndef XF86Vga16Drivers
+#define XF86Vga16Drivers	generic
+#endif
 #ifndef XF86Vga2Drivers
 #define XF86Vga2Drivers		generic
 #endif
@@ -119,16 +141,104 @@
 #ifdef Mc68020Architecture
 #ifndef XF68FBDevServer
 #define XF68FBDevServer		YES
+#define XF68FBDev77C32		NO
+#define XF68FBDevIMSTT		NO
+#define XF68FBDevMach64		NO
+#define XF68FBDevPermedia2	NO
+#endif
+#ifndef BuildXF86Setup
+#define BuildXF86Setup		NO
 #endif
 #endif
 
-/* 
+/*
+ * For ARM platforms, the default is to build all X servers which
+ * are supported on this platform.
+ */
+#ifdef ArmArchitecture
+#ifndef XF68FBDevServer
+#define XF68FBDevServer		YES
+#define XF68FBDevCFB8		YES
+#define XF68FBDevCFB16		YES
+#define XF68FBDevCFB24		YES
+#define XF68FBDevCFB32		YES
+#define XF68FBDevIPLAN2p2	NO
+#define XF68FBDevIPLAN2p4	NO
+#define XF68FBDevIPLAN2p8	NO
+#define XF68FBDevILBM		NO
+#define XF68FBDevAFB		NO
+#define XF68FBDev77C32		NO
+#define XF68FBDevMach64		NO
+#define XF68FBDevIMSTT		NO
+#define XF68FBDevPermedia2	NO
+#endif
+#ifndef BuildXF86Setup
+#define BuildXF86Setup		NO
+#endif
+#endif
+
+/*
  * For Mips/Arc platforms, the default is to build all X servers which
- * are supported on this platform. 
+ * are supported on this platform.
  */
 #ifdef ArcArchitecture
 #ifndef XF86S3Server
-#define XF86S3Server          YES
+#define XF86S3Server		YES
+#endif
+#if defined(LinuxArchitecture)
+#ifndef XF86FBDevServer
+#define XF86FBDevServer		YES
+#endif
+#endif
+#ifndef BuildXF86Setup
+#define BuildXF86Setup		NO
+#endif
+#endif
+
+/*
+ * For PowerPC platforms, the default is to build all X servers which
+ * are supported on this platform.
+ */
+#ifdef PowerPCArchitecture
+#ifndef XF86SVGAServer
+#define XF86SVGAServer		NO
+#endif
+#ifndef XF86VGA16Server
+#define XF86VGA16Server		NO
+#endif
+#ifndef XF86S3Server
+#define XF86S3Server		NO
+#endif
+#ifndef XF68FBDevServer
+#define XF68FBDevServer		YES
+#define XF68FBDevCFB8		YES
+#define XF68FBDevCFB16		YES
+#define XF68FBDevCFB24		NO
+#define XF68FBDevCFB32		YES
+#define XF68FBDevIPLAN2p2	NO
+#define XF68FBDevIPLAN2p4	NO
+#define XF68FBDevIPLAN2p8	NO
+#define XF68FBDevILBM		NO
+#define XF68FBDevAFB		YES
+#define XF68FBDev77C32		YES
+#define XF68FBDevIMSTT		YES
+#define XF68FBDevMach64		YES
+#define XF68FBDevPermedia2	YES
+#endif
+#ifndef BuildXF86Setup
+#define BuildXF86Setup		NO
+#endif
+#endif
+
+/* For SPARC PCI platforms, the default is to build all X servers which are
+ * supported on this platform.
+ */
+#ifdef SparcArchitecture
+#ifndef XF86Mach64Server
+#define XF86Mach64Server	YES
+#endif
+#ifndef BuildXF86Setup
+#define BuildXF86Setup		NO
 #endif
 #endif
 
@@ -189,6 +299,10 @@
 # define XF86I128Server		NO
 #endif
 
+#ifndef XF86GLINTServer
+# define XF86GLINTServer	NO
+#endif
+
 #ifndef XF86TGAServer
 # define XF86TGAServer		NO
 #endif
@@ -253,6 +367,12 @@
 # define XF86I128Dir		/**/
 #endif
 
+#if XF86GLINTServer
+# define XF86GLINTDir		glint
+#else
+# define XF86GLINTDir		/**/
+#endif
+
 #if XF86TGAServer
 # define XF86TGADir		tga
 #else
@@ -347,12 +467,13 @@
 #define XF86AccelServerDirs	XF86S3Dir XF86S3VDir XF86I8514Dir \
 				XF86Mach8Dir XF86Mach32Dir XF86Mach64Dir \
 				XF86P9000Dir XF86AGXDir XF86W32Dir \
-				XF86I128Dir XF86TGADir
+				XF86I128Dir XF86GLINTDir XF86TGADir
 
 #undef XF86AccelServer
 #if XF86S3Server || XF86S3VServer || XF86I8514Server || XF86Mach8Server || \
     XF86Mach32Server || XF86Mach64Server || XF86P9000Server || \
-    XF86AGXServer || XF86W32Server || XF86I128Server || XF86TGAServer
+    XF86AGXServer || XF86W32Server || XF86I128Server || XF86TGAServer || \
+    XF86GLINTServer
 # define XF86AccelServer	YES
 #else
 # define XF86AccelServer	NO
@@ -373,12 +494,21 @@
  */
 #ifndef XF86SvgaDrivers
 # ifdef AlphaArchitecture
-#  define XF86SvgaDrivers	mga tvga8900 s3v
+#  define XF86SvgaDrivers	mga tvga8900 s3v nv
 # else
-#  define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga ati sis tvga8900 \
+#  if defined(LinuxArchitecture)
+#   define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga r128 ati sis tvga8900 \
+				cirrus ncr77c22 compaq mga oak al2101 \
+				ali cl64xx video7 ark mx realtek s3_savage s3v apm \
+				s3_svga neo chips cyrix rendition p9x00 \
+				spc8110 i740 i810 tdfx smi generic
+#  else
+#   define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga r128 ati sis tvga8900 \
 				cirrus ncr77c22 compaq mga oak al2101 \
-				ali cl64xx video7 ark mx realtek apm \
-				s3v s3_svga chips generic
+				ali cl64xx video7 ark mx realtek s3v apm \
+				s3_svga neo chips cyrix rendition p9x00 \
+				spc8110 i740 i810 tdfx smi generic
+#  endif
 # endif
 #endif
 
@@ -429,7 +559,7 @@
 # define XF86W32Drivers		et4000w32
 #endif
 
-#if XF68FBDevServer
+#if XF68FBDevServer || XF86FBDevServer
 # ifndef XF68FBDevIPLAN2p2
 #  define XF68FBDevIPLAN2p2	YES
 # endif
@@ -449,10 +579,30 @@
 #  define XF68FBDevCFB8		YES
 # endif
 # ifndef XF68FBDevCFB16
-#  define XF68FBDevCFB16	NO
+#  define XF68FBDevCFB16	YES
+# endif
+# ifndef XF68FBDevCFB24
+#  if defined(i386Architecture) || defined(AlphaArchitecture)
+#   define XF68FBDevCFB24	YES
+#  else
+#   define XF68FBDevCFB24	NO
+#  endif
 # endif
 # ifndef XF68FBDevCFB32
-#  define XF68FBDevCFB32	NO
+#  define XF68FBDevCFB32	YES
+# endif
+/* Accelerated stuff */
+# ifndef XF68FBDev77C32
+#  define XF68FBDev77C32	YES
+# endif
+# ifndef XF68FBDevIMSTT
+#  define XF68FBDevIMSTT	YES
+# endif
+# ifndef XF68FBDevMach64
+#  define XF68FBDevMach64	YES
+# endif
+# ifndef XF68FBDevPermedia2
+#  define XF68FBDevPermedia2	YES
 # endif
 #else
 # ifndef XF68FBDevIPLAN2p2
@@ -476,9 +626,24 @@
 # ifndef XF68FBDevCFB16
 #  define XF68FBDevCFB16	NO
 # endif
+# ifndef XF68FBDevCFB24
+#  define XF68FBDevCFB24	NO
+# endif
 # ifndef XF68FBDevCFB32
 #  define XF68FBDevCFB32	NO
 # endif
+# ifndef XF68FBDev77C32
+#  define XF68FBDev77C32	NO
+# endif
+# ifndef XF68FBDevIMSTT
+#  define XF68FBDevIMSTT	NO
+# endif
+# ifndef XF68FBDevMach64
+#  define XF68FBDevMach64	NO
+# endif
+# ifndef XF68FBDevPermedia2
+#  define XF68FBDevPermedia2	NO
+# endif
 #endif
 
 #ifndef XnestServer
@@ -519,7 +684,7 @@
 #if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
     XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
     XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
-    XF98MGAServer || XF98SVGAServer
+    XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
 #define BuildPexExt		YES
 #else
 #define BuildPexExt		NO
@@ -535,7 +700,7 @@
 #  if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
       XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
       XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
-      XF98MGAServer || XF98SVGAServer
+      XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
 #    define BuildGlxExt             YES
 #  else
 #    define BuildGlxExt             NO
@@ -550,7 +715,7 @@
 #if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
     XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
     XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
-    XF98MGAServer || XF98SVGAServer
+    XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
 #define BuildXIE		YES
 #else
 #define BuildXIE		NO
@@ -591,14 +756,33 @@
 #define WacomSupport		YES
 #endif
 #ifndef ElographicsSupport
-#define ElographicsSupport	YES 
+#define ElographicsSupport	YES
+#endif
+#ifndef DynaproSupport
+#define DynaproSupport		YES
+#endif
+#ifndef MicroTouchSupport
+#define MicroTouchSupport	YES
 #endif
 #ifndef SummaSketchSupport
 #define SummaSketchSupport	YES
 #endif
+#ifndef AceCadSupport
+#define AceCadSupport		YES
+#endif
+#ifndef DialBoxSupport
+#if SystemV || SystemV4
+#define DialBoxSupport		NO
+#else
+#define DialBoxSupport		YES
+#endif
+#endif
 #ifndef JoystickSupport
 #define JoystickSupport		NO
 #endif
+#ifndef CalcompSupport
+#define CalcompSupport		YES
+#endif
 
 /*
  * Build the extra extension libs even when not including the extra extensions
@@ -645,6 +829,17 @@
 #endif
 #endif
 
+/*
+ * Build Japanese versions of XF86Setup -- needs Japanised Tk and Tcl
+ */
+#ifndef BuildJpXF86Setup
+#if HasJpTk && HasJpTcl && BuildXF86VidModeLibrary && BuildXF86MiscLibrary && BuildXKBlib
+#define BuildJpXF86Setup		YES
+#else
+#define BuildJpXF86Setup		NO
+#endif
+#endif
+
 #ifndef XF86SetupUsesStaticTk
 #define XF86SetupUsesStaticTk		YES
 #endif
@@ -653,13 +848,6 @@
 #endif
 
 /*
- * Build the XKBui lib if building XF86Setup
- */
-#ifndef BuildXKBuilib
-#define BuildXKBuilib			BuildXF86Setup
-#endif
-
-/*
  * Build the XFree86 DGA support
  */
 #ifndef BuildXF86DGA
@@ -728,10 +916,17 @@
 #endif
 
 /*
+ * By default, create the local font directory
+ */
+#ifndef MakeLocalFontDir
+#define MakeLocalFontDir	YES
+#endif
+
+/*
  * Build scanpci?
  */
 #ifndef BuildScanpci
-#if SystemV || SystemV4 || (defined(LinuxArchitecture) && !defined(Mc68020Architecture)) || defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || defined(OS2Architecture)
+#if SystemV || SystemV4 || (defined(LinuxArchitecture) && !defined(Mc68020Architecture) && !defined(PowerPCArchitecture) && !defined(ArmArchitecture)) || defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || defined(OS2Architecture)
 #define BuildScanpci		YES
 #else
 #define BuildScanpci		NO
@@ -789,6 +984,15 @@
 #endif
 #endif
 
+/* Support for USB mouse */
+#ifndef UsbMouseSupport
+#define UsbMouseSupport	NO
+#endif
+/* Does this OS has libusb ? */
+#ifndef HasLibUsb
+#define HasLibUsb	NO
+#endif
+
 #ifndef UseServerLock
 #define UseServerLock	YES
 #endif
@@ -1015,6 +1219,10 @@
 
 #ifndef DontDefineXF86Contrib
 #define XF86Contrib
+#endif
+
+#ifndef HasMktemp
+#define HasMktemp	YES
 #endif
 
 #include <xf86.rules>
--- vnc-3.3.7.orig/Xvnc/config/cf/X11.tmpl
+++ vnc-3.3.7/Xvnc/config/cf/X11.tmpl
@@ -735,7 +735,7 @@
 #endif
 #endif
 #ifndef XAppLoadDir
-#define XAppLoadDir $(LIBDIR)/app-defaults
+#define XAppLoadDir /etc/app-defaults
 #endif
 #ifndef XtErrorPrefix
 #define XtErrorPrefix /* as empty string */
--- vnc-3.3.7.orig/Xvnc/config/cf/linux.cf
+++ vnc-3.3.7/Xvnc/config/cf/linux.cf
@@ -1,80 +1,179 @@
-XCOMM platform:  $TOG: linux.cf /main/36 1997/06/16 22:21:03 kaleb $
-XCOMM platform:  $XFree86: xc/config/cf/linux.cf,v 3.57.2.12 1998/03/01 01:57:10 dawes Exp $
+XCOMM platform:  $Xorg: linux.cf,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
+
+
+
+
+
+XCOMM platform:  $XFree86: xc/config/cf/linux.cf,v 3.165 2001/04/19 19:54:43 dawes Exp $
 
 #ifndef LinuxElfDefault
-#define LinuxElfDefault		YES
+# define LinuxElfDefault	YES
 #endif
 
 #ifndef UseElfFormat
-#define UseElfFormat		LinuxElfDefault
+# define UseElfFormat		LinuxElfDefault
 #endif
 
 #ifndef OSBinaryType
-#if UseElfFormat
-#define OSBinaryType		[ELF]
-#else
-#ifdef AlphaArchitecture
-#define OSBinaryType		[ECOFF]
-#else
-#define OSBinaryType		[a.out]
-#endif
-#endif
+# if UseElfFormat
+#  define OSBinaryType		[ELF]
+# else
+#  ifdef AlphaArchitecture
+#   define OSBinaryType		[ECOFF]
+#  else
+#   define OSBinaryType		[a.out]
+#  endif
+# endif
 #endif
 
 #ifndef OSName
-#define OSName			DefaultOSName OSBinaryType
+# define OSName			DefaultOSName OSBinaryType
 #endif
 
 #ifndef OSVendor
-#define OSVendor		/**/
+# define OSVendor		/**/
 #endif
 #ifndef OSMajorVersion
-#define OSMajorVersion		DefaultOSMajorVersion
+# define OSMajorVersion		DefaultOSMajorVersion
 #endif
 #ifndef OSMinorVersion
-#define OSMinorVersion		DefaultOSMinorVersion
+# define OSMinorVersion		DefaultOSMinorVersion
 #endif
 #ifndef OSTeenyVersion
-#define OSTeenyVersion		DefaultOSTeenyVersion
+# define OSTeenyVersion		DefaultOSTeenyVersion
 #endif
 
-/* Set some defaults for the Default* values in case imake doesn't find them */
-#ifndef DefaultLinuxCLibMajorVersion
-#ifdef AlphaArchitecture
-#define DefaultLinuxCLibMajorVersion	6
-#else
-#define DefaultLinuxCLibMajorVersion	5
-#endif
-#endif
-#ifndef DefaultLinuxCLibMinorVersion
-#if DefaultLinuxCLibMajorVersion > 5
-#define DefaultLinuxCLibMinorVersion	0
-#else
-#define DefaultLinuxCLibMinorVersion	4
-#endif
+#ifndef LinuxDistribution
+# define LinuxDistribution	DefaultLinuxDistribution
+/*
+  Add "#define LinuxDistribution Linux<mumble>" to your site.def or host.def.
+  Currently only LinuxSuSE, LinuxRedHat and LinuxDebian will be figured out
+  automatically.
+  Valid values are (from the list at www.linux.org in Oct. '97):
+    LinuxUnknown    (0)
+    LinuxSuSE       (1)
+    LinuxCaldera    (2)
+    LinuxCraftworks (3)
+    LinuxDebian     (4)
+    LinuxInfoMagic  (5)
+    LinuxKheops     (6)
+    LinuxPro        (7)
+    LinuxRedHat     (8)
+    LinuxSlackware  (9)
+    LinuxTurbo      (10)
+    LinuxWare       (11)
+    LinuxYggdrasil  (12)
+*/
 #endif
-#ifndef DefaultLinuxCLibTeenyVersion
-#define DefaultLinuxCLibTeenyVersion	0
+#ifndef LinuxDistName
+# define LinuxDistName		DefaultLinuxDistName
 #endif
-
 #ifndef LinuxCLibMajorVersion
-#define LinuxCLibMajorVersion	DefaultLinuxCLibMajorVersion
+# define LinuxCLibMajorVersion	DefaultLinuxCLibMajorVersion
 #endif
 #ifndef LinuxCLibMinorVersion
-#define LinuxCLibMinorVersion	DefaultLinuxCLibMinorVersion
+# define LinuxCLibMinorVersion	DefaultLinuxCLibMinorVersion
 #endif
 #ifndef LinuxCLibTeenyVersion
-#define LinuxCLibTeenyVersion	DefaultLinuxCLibTeenyVersion
+# define LinuxCLibTeenyVersion	DefaultLinuxCLibTeenyVersion
 #endif
 
 #ifndef LinuxBinUtilsMajorVersion
-#define LinuxBinUtilsMajorVersion	DefaultLinuxBinUtilsMajorVersion
+# define LinuxBinUtilsMajorVersion	DefaultLinuxBinUtilsMajorVersion
 #endif
 
 XCOMM operating system:  OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion)
 XCOMM libc:	(LinuxCLibMajorVersion./**/LinuxCLibMinorVersion./**/LinuxCLibTeenyVersion)
 XCOMM binutils:	(LinuxBinUtilsMajorVersion)
 
+#if LinuxDistribution == LinuxDebian
+# define SystemManDirectory	/usr/share/man
+# define HasPam			YES
+# define HasTk			YES
+# define TkLibDir		/usr/lib
+# define TkIncDir		/usr/include
+# define TkLibName		tk8.3
+# define XF86SetupUsesStaticTk	NO
+# define HasTcl			YES
+# define TclLibDir		/usr/lib
+# define TclIncDir		/usr/include
+# define TclLibName		tcl8.3
+# define XF86SetupUsesStaticTcl	NO
+/* un-comment this when it is un-broken */
+/* # define JoystickSupport YES */
+# define InstallXinitConfig	YES
+# define InstallXdmConfig	YES
+# define InstallFSConfig	YES
+# define DebuggableLibraries	YES
+# define ForceNormalLib		YES
+# define BuildSpecsDocs		YES
+# define SpecsDocDirs		CTEXT GL ICCCM X11 Xext Xv i18n xterm
+# define XAppLoadDir		EtcX11Directory/app-defaults
+# define XFileSearchPathDefault	Concat4(EtcX11Directory/%L/%T/%N%C,%S:EtcX11Directory/%l/%T/%N%C,%S:EtcX11Directory/%T/%N%C,%S:EtcX11Directory/%L/%T/%N%S:EtcX11Directory/%l/%T/%N%S:EtcX11Directory/%T/%N%S):Concat4($(LIBDIR)/%L/%T/%N%C,%S:$(LIBDIR)/%l/%T/%N%C,%S:$(LIBDIR)/%T/%N%C,%S:$(LIBDIR)/%L/%T/%N%S:$(LIBDIR)/%l/%T/%N%S:$(LIBDIR)/%T/%N%S)
+/* the relative symlink created by this rule causes problems for us */
+# if InstallAppDefFiles
+#  define InstallAppDefaultsLong(file,class)				@@\
+InstallNamedTarget(install,file.ad,$(INSTAPPFLAGS),$(XAPPLOADDIR),class)
+# else
+#  define InstallAppDefaultsLong(file,class)				@@\
+InstallNamedTargetNoClobber(install,file.ad,$(INSTAPPFLAGS),$(XAPPLOADDIR),class)
+# endif /* InstallAppDefFiles */
+# define SharedLibXdmGreet	NO
+# define LinkGLToUsrInclude	NO
+# define LinkGLToUsrLib		NO
+# define SharedLibFont		NO
+# define HasZlib		YES
+# define BuildGLXLibrary	YES
+# define BuildGLULibrary	YES
+# define BuildRman		NO
+# define BuildHtmlManPages	NO
+# define FSUseSyslog		YES
+
+/*
+ *
+ */
+# define DebianMaintainer	"xfree86@packages.debian.org"
+/*
+ *
+ */
+
+# ifdef DebianMaintainer
+#  define BuilderEMailAddr	"submit@bugs.debian.org"
+#  define XFree86Devel		YES
+#  define BuildAllSpecsDocs	YES
+/* we build-depend on libfreetype6-dev (FreeType 2.x) */
+#  define BuildFreetype2Library	NO
+#  define HasFreetype2		YES
+/* m68k has no 2.4 kernel yet */
+#  ifndef Mc68020Architecture
+#   define HasLinuxInput		YES
+#  endif
+#  define HasXdmAuth		YES
+#  define HasLatex		YES
+/* at present, glide2 only works on i386 */
+#  ifdef i386Architecture
+#   define HasGlide2		YES
+#   define Glide2IncDir		/usr/include/glide
+#  endif /* i386Architecture */
+/* at present, glide3 only works on alpha and i386 */
+#  if defined(i386Architecture) || defined(AlphaArchitecture)
+#   define HasGlide3		YES
+#   define Glide3IncDir		/usr/include/glide3
+#  endif /* i386Architecture || AlphaArchitecture */
+/* extended instruction set support */
+#  ifdef i386Architecture
+#   define HasMMXSupport	YES
+#   define Has3DNowSupport	YES
+/* 2.4 is not yet the official (or predominant) kernel in unstable */
+#   define HasKatmaiSupport	NO
+#  endif /* i386Architecture */
+# endif /* DebianMaintainer */
+#endif /* LinuxDebian */
+
+#if LinuxDistribution == LinuxRedHat
+#define FSUseSyslog		YES
+#endif
+
 /*
  * The Linux BinUtils major version.  25 => 2.5.x, which is what is included
  * with Slackware 3.0
@@ -83,45 +182,251 @@
  *
  */
 #ifndef BinUtilsMajorVersion
-#define BinUtilsMajorVersion	LinuxBinUtilsMajorVersion
+# define BinUtilsMajorVersion	LinuxBinUtilsMajorVersion
 #endif
 
-#if LinuxCLibMajorVersion >= 6 || \
-	(LinuxCLibMajorVersion == 5 && LinuxCLibMinorVersion == 99)
-#define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
-				-D_POSIX_SOURCE -D_XOPEN_SOURCE=500L \
-				-D_BSD_SOURCE -D_SVID_SOURCE
-#define XawI18nDefines		-DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H
-#if !defined(AlphaArchitecture)
-#define HasPosixThreads		YES
-#define ThreadedX		YES
-#define HasThreadSafeAPI	YES
-#define ThreadsLibraries	-lpthread
-#define SystemMTDefines		-D_REENTRANT
+#if (LinuxCLibMajorVersion >= 6 || LinuxDistribution == LinuxSuSE)
+# define LinuxLocaleDefines	/**/
+#else
+# define LinuxLocaleDefines	-DX_LOCALE
+#endif
+
+#ifndef  LinuxAdditionalIncludes
+# define LinuxAdditionalIncludes	/**/
 #endif
-#ifndef HasLibCrypt
-#define HasLibCrypt		YES
+
+#ifndef LinuxGnuSourceDefines
+# ifdef UseInstalled
+#  define LinuxGnuSourceDefines	/**/
+# else
+#  define LinuxGnuSourceDefines	-D_GNU_SOURCE
+# endif
 #endif
+
+#if LinuxCLibMajorVersion >= 6
+# define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
+				-D_POSIX_SOURCE -D_XOPEN_SOURCE \
+				-D_BSD_SOURCE -D_SVID_SOURCE \
+				LinuxAdditionalIncludes LinuxGnuSourceDefines \
+				LinuxLocaleDefines
+# define XawI18nDefines		-DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H
+# define HasPosixThreads	YES
+# define ThreadedX		YES
+# define HasThreadSafeAPI	YES
+# define ThreadsLibraries	-lpthread
+# define SystemMTDefines	-D_REENTRANT
+# ifndef HasLibCrypt
+#  define HasLibCrypt		YES
+# endif
+/* netscape wraps select but not poll as of communicator 4.72 */
+# ifndef HasPoll
+#  define HasPoll		NO
+# endif
 #else
-#define LinuxSourceDefines	-D_POSIX_SOURCE \
-				-D_BSD_SOURCE -D_SVID_SOURCE -DX_LOCALE
-#define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
-#ifndef HasLibCrypt
-#define HasLibCrypt		NO
+# define LinuxSourceDefines	-D_POSIX_SOURCE -D_POSIX_C_SOURCE=2 \
+				-D_BSD_SOURCE -D_SVID_SOURCE \
+				LinuxGnuSourceDefines LinuxLocaleDefines
+# define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
+# ifndef HasLibCrypt
+#  define HasLibCrypt		NO
+# endif
 #endif
+
+#ifndef InstallXloadSetGID
+#define InstallXloadSetGID	NO
+#endif
+
+/* <linux/input.h> support mainly for USB support */
+#ifndef HasLinuxInput
+# if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
+#  define HasLinuxInput YES
+# endif
+#endif
+
+/* On x86, determine whether to build with MTRR support */
+#ifndef HasMTRRSupport
+# ifdef i386Architecture
+/* There is no certain way to know if <asm/mtrr.h> is available,
+   but it made it into kernel 2.2, so... */
+#  if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
+#   define HasMTRRSupport	YES
+#  else
+#   define HasMTRRSupport	NO
+#  endif
+# else
+#  define HasMTRRSupport	NO	/* no for non-ix86 */
+# endif
+#endif
+
+#ifndef XF86INT10_BUILD
+# ifdef i386Architecture
+#  define XF86INT10_BUILD	X86VM
+# else
+#  define XF86INT10_BUILD	X86EMU_GENERIC
+# endif
+#endif
+
+/* The DRM module requires kernel services that appeared in late 2.1.x
+   kernels and are known to be present in 2.2.x kernels. */
+#ifndef BuildXF86DRI
+#  if defined(i386Architecture)
+#    if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
+#      define BuildXF86DRI	YES
+#    else
+#      define BuildXF86DRI	NO
+#    endif
+#  elif defined(AlphaArchitecture)
+#    define BuildXF86DRI	YES
+#  elif defined(Arm32Architecture)
+#    define BuildXF86DRI	NO
+#  elif defined(HPArchitecture)
+#    define BuildXF86DRI	NO
+#  elif defined(x86_64Architecture)
+#    define BuildXF86DRI	YES
+#  elif defined(ia64Architecture)
+#    define BuildXF86DRI	YES
+#  elif defined(Mc68020Architecture)
+#    define BuildXF86DRI	NO
+#  elif defined(MipsArchitecture)
+#    define BuildXF86DRI	NO
+#  elif defined(PpcArchitecture)
+#    define BuildXF86DRI	YES
+#  elif defined(s390Architecture)
+#    define BuildXF86DRI	NO
+#  elif defined(SparcArchitecture)
+#    define BuildXF86DRI	YES
+#  else
+#    define BuildXF86DRI	NO
+#  endif
+#endif
+
+/*
+ * Build shared libGL and the DRI modules without -fPIC.  This improves
+ * performance.  Do this only on architectures that can handle missing PIC
+ * symbols in shared libraries.
+ */
+#if BuildXF86DRI
+#  if defined(AlphaArchitecture) || defined(Arm32Architecture) || defined(i386Architecture) || defined(SparcArchitecture)
+#   define BuildLibGlxWithoutPIC	YES
+#  endif
+#endif
+
+/* The DRM module requires kernel services that appeared in late 2.1.x
+   kernels and are known to be present in 2.2.x kernels.  Unfortunately,
+   the kernel API is a moving target and the module may break with new
+   kernel revisions.  So, we'll only build the module for kernels that are
+   known to be supported by the module. */
+#ifndef BuildXF86DRM
+#  if defined(i386Architecture) || defined(x86_64Architecture) || defined(ia64Architecture) || defined(SparcArchitecture) || defined(AlphaArchitecture)
+#    if OSMajorVersion == 2
+       /* Only tested for Linux 2.2.0 through 2.2.12 */
+#      if OSMinorVersion == 2 && OSTeenyVersion <= 12
+#        define BuildXF86DRM	YES
+#      else
+         /* Only tested for Linux 2.3.0 through 2.3.18 */
+#        if OSMinorVersion == 3 && OSTeenyVersion <= 18
+#          define BuildXF86DRM	YES
+#        else
+           /* Note: add more conditions when 2.4.x and 2.5.x are released */
+#          define BuildXF86DRM	NO
+#        endif
+#      endif
+#    else
+       /* Note: add more conditions when 3.0.x and 3.1.x are released */
+#      define BuildXF86DRM	NO
+#    endif
+#  else
+#    define BuildXF86DRM	NO
+#  endif
+#endif
+
+#ifndef HasAgpGart
+#  if defined(i386Architecture) || defined(x86_64Architecture) || defined(ia64Architecture)
+     /* The AGPGART header file is included in os-support/linux, which
+        allows all drivers that depend on AGP to build properly. */
+#    define HasAgpGart	YES
+#  else
+#    define HasAgpGart	NO
+#  endif
+#endif
+
+/* Support for Intel's Katmai Native Instructions, also known as the
+ * Streaming SIMD Extensions, was introduced in the 2.4.x kernels.
+ */
+#ifndef HasKatmaiSupport
+#  ifdef i386Architecture
+#    if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
+#      define HasKatmaiSupport		YES
+#    else
+#      define HasKatmaiSupport		NO
+#    endif
+#  else
+#    define HasKatmaiSupport		NO
+#  endif
+#endif
+
+/*
+ * Support for MMX isn't present in the Assembler used in Red Hat 4.2, so
+ * don't enable it for libc5 as a reasonable default.
+ */
+#ifndef HasMMXSupport
+#  ifdef i386Architecture
+#    if (LinuxCLibMajorVersion > 5)
+#      define HasMMXSupport		YES
+#    else
+#      define HasMMXSupport		NO
+#    endif
+#  else
+#    define HasMMXSupport		NO
+#  endif
+#endif
+
+/*
+ * Support for 3DNow isn't present in the Assembler used in Red Hat 4.2, so
+ * don't enable it for libc5 as a reasonable default.
+ *
+ * XXX This is preliminary.
+ */
+#ifndef Has3DNowSupport
+#  ifdef i386Architecture
+#    if (LinuxCLibMajorVersion > 5)
+#      define Has3DNowSupport		YES
+#    else
+#      define Has3DNowSupport		NO
+#    endif
+#  else
+#    define Has3DNowSupport		NO
+#  endif
+#endif
+
+/*
+ * libGLU doesn't build correctly on a libc5 system.
+ */
+#if !defined(BuildGLULibrary) && (LinuxCLibMajorVersion < 6)
+# define BuildGLULibrary		NO
+#endif
+
+/*
+ * The Rush extension support.
+ */
+#ifndef BuildXF86RushExt
+# define BuildXF86RushExt	YES
+#endif
+
+#ifndef LinuxFBDevSupport
+# define LinuxFBDevSupport	YES
 #endif
 
 /* For compatibility */
 #define SourceDefines		LinuxSourceDefines
 
-#define HasGcc			YES
-#define HasGcc2			YES
-#ifndef HasGcc2ForCplusplus
-# define HasGcc2ForCplusplus	YES
-#endif
+#define BuildLibPathVar		LD_LIBRARY_PATH
 #define GccUsesGas		YES
 #define UseGas			YES
 #define GnuCpp			YES
+#if UseElfFormat
+# define HasDlopen		YES
+#endif
 #ifndef HasShadowPasswd
 # if UseElfFormat
 #  define HasShadowPasswd	YES
@@ -136,9 +441,21 @@
 #define HasSnprintf		YES
 #define HasMkstemp		YES
 #endif
+#if OSMajorVersion >= 2
+#define HasUsableFileMmap	YES
+#endif
+#ifndef HasNCurses
+#define HasNCurses		YES
+#endif
+
+#ifndef HasGroff
+#define HasGroff		YES
+#endif
 
 #define AvoidNullMakeCommand	YES
-#define StripInstalledPrograms	YES
+#ifndef DebuggableLibraries
+#define DebuggableLibraries	NO
+#endif
 #define CompressAllFonts	YES
 #define Malloc0ReturnsNull	YES
 #define NeedConstPrototypes	YES
@@ -154,125 +471,359 @@
 #define UseStaticTermcapLib	NO
 #endif
 
-#define MkdirHierCmd		mkdir -p
-#if LinuxElfDefault
-#if UseElfFormat
-#define CcCmd			gcc
-#define AsCmd			as
-#define LdCmd			ld
-#define AsmDefines		-D__ELF__
-#define CplusplusCmd		c++
-#if UseStaticTermcapLib
-#define TermcapLibrary		StaticLibrary(/usr/lib/termcap,termcap)
+#ifndef HasCookieMaker
+#define HasCookieMaker		YES
+#define MkCookieCmd		mcookie
 #endif
-#else
-#ifdef AlphaArchitecture
-#define CcCmd			gcc -b alpha-linuxecoff
-#define CplusplusCmd		g++ -b alpha-linuxecoff
-#define AsCmd			/usr/alpha-linuxecoff/bin/as
-#define LdCmd			/usr/alpha-linuxecoff/bin/ld -m alpha
-#define AsmDefines		-DUSE_GAS -U__ELF__
-#endif /* AlphaArchitecture */
-#ifdef i386Architecture
-#define CcCmd			gcc -b i486-linuxaout
-#define CplusplusCmd		g++ -b i486-linuxaout
-#define AsCmd			/usr/i486-linuxaout/bin/as
-#define LdCmd			/usr/i486-linuxaout/bin/ld -m i386linux
-#define AsmDefines		-DUSE_GAS -U__ELF__
-#endif /* i386Architecture */
-#ifdef Mc68020Architecture
-#define CcCmd			gcc -b m68k-linuxaout
-#define CplusplusCmd		g++ -b m68k-linuxaout
-#define AsCmd			/usr/m68k-linuxaout/bin/as
-#define LdCmd			/usr/m68k-linuxaout/bin/ld -m m68klinux
-#define AsmDefines		-DUSE_GAS -U__ELF__
-#endif /* Mc68020Architecture */
+
+#ifndef BourneShell
+/*
+ * This will cause builds/installs to terminate on errors, as on other
+ * platforms.
+ */
+#define BourneShell		/bin/sh -e
 #endif
+
+#define MkdirHierCmd		mkdir -p
+
+#if LinuxElfDefault
+# if UseElfFormat
+#  ifdef MipsArchitecture
+#   ifndef AsCmd
+#     define AsCmd		gcc -c -x assembler-with-cpp
+#   endif
+#   ifndef DoLoadableServer
+#     define DoLoadableServer	NO
+#   endif
+#  endif /* MipsArchitecure */
+#  ifndef CcCmd
+#   define CcCmd		gcc
+#  endif
+#  ifndef AsCmd
+#   define AsCmd		as
+#  endif
+#  ifndef LdCmd
+#   define LdCmd		ld
+#  endif
+#  define AsmDefines		-D__ELF__
+#  define CplusplusCmd		c++
+#  ifndef LinuxUsesNcurses
+#   if LinuxCLibMajorVersion >= 6 || (LinuxDistribution == LinuxSuSE)
+#    define LinuxUsesNcurses	YES
+#   else
+#    define LinuxUsesNcurses	NO
+#   endif
+#  endif
+#  ifndef TermcapLibrary
+#   if UseStaticTermcapLib
+#    if LinuxUsesNcurses
+#     define TermcapLibrary	StaticLibrary(/usr/lib,ncurses)
+#    else
+#     define TermcapLibrary	StaticLibrary(/usr/lib/termcap,termcap)
+#    endif
+#   else
+#    if LinuxUsesNcurses
+#     define TermcapLibrary	-lncurses
+#    else
+#     define TermcapLibrary	-ltermcap
+#    endif
+#   endif
+#  endif
+# else
+#  ifdef AlphaArchitecture
+#   define CcCmd		gcc -b alpha-linuxecoff
+#   define CplusplusCmd		g++ -b alpha-linuxecoff
+#   define AsCmd		/usr/alpha-linuxecoff/bin/as
+#   define LdCmd		/usr/alpha-linuxecoff/bin/ld -m alpha
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* AlphaArchitecture */
+#  ifdef HPArchitecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* HPArchitecture */
+#  ifdef x86_64Architecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* x86_64Architecture */
+#  ifdef ia64Architecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* ia64Architecture */
+#  ifdef i386Architecture
+#   define CcCmd		gcc -b i486-linuxaout
+#   define CplusplusCmd		g++ -b i486-linuxaout
+#   define AsCmd		/usr/i486-linuxaout/bin/as
+#   define LdCmd		/usr/i486-linuxaout/bin/ld -m i386linux
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* i386Architecture */
+#  ifdef Mc68020Architecture
+#   define CcCmd		gcc -b m68k-linuxaout
+#   define CplusplusCmd		g++ -b m68k-linuxaout
+#   define AsCmd		/usr/m68k-linuxaout/bin/as
+#   define LdCmd		/usr/m68k-linuxaout/bin/ld -m m68klinux
+#   define AsmDefines		-DUSE_GAS -U__ELF__
+#  endif /* Mc68020Architecture */
+# endif
 #else
-#if UseElfFormat
-#ifdef AlphaArchitecture
-#define CcCmd			gcc -b alpha-linux
-#define AsCmd			/usr/alpha-linux/bin/as
-#define LdCmd			ld -m elf64alpha
-#define AsmDefines		-D__ELF__
-#define CplusplusCmd		c++ -b alpha-linux
-#endif /* AlphaArchitecture */
-#ifdef i386Architecture
-#define CcCmd			gcc -b i486-linux
-#define AsCmd			/usr/i486-linux/bin/as
-#define LdCmd			ld -m elf_i386
-#define AsmDefines		-D__ELF__
-#define CplusplusCmd		c++ -b i486-linux
-#endif /* i386Architecture */
-#ifdef Mc68020Architecture
-#define CcCmd			gcc -b m68k-linux
-#define AsCmd			/usr/m68k-linux/bin/as
-#define LdCmd			ld -m m68kelf
-#define AsmDefines		-D__ELF__
-#define CplusplusCmd		c++ -b m68k-linux
-#endif /* Mc68020Architecture */
-#else
-#define CcCmd			gcc
-#define AsCmd			as
-#define LdCmd			ld
-#define AsmDefines		-DUSE_GAS
-#endif
+# if UseElfFormat
+#  ifdef AlphaArchitecture
+#   define CcCmd		gcc -b alpha-linux
+#   define AsCmd		/usr/alpha-linux/bin/as
+#   define LdCmd		ld -m elf64alpha
+#   define AsmDefines		-D__ELF__
+#   define CplusplusCmd		c++ -b alpha-linux
+#  endif /* AlphaArchitecture */
+#  ifdef x86_64Architecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-D__ELF__
+#  endif /* x86_64Architecture */
+#  ifdef ia64Architecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-D__ELF__
+#  endif /* ia64Architecture */
+#  ifdef HPArchitecture
+#   define CcCmd		gcc
+#   define CplusplusCmd		g++
+#   define AsCmd		as
+#   define LdCmd		ld
+#   define AsmDefines		-D__ELF__
+#   define SharedLibXau		YES
+#  endif /* HPArchitecture */
+#  ifdef i386Architecture
+#   define CcCmd		gcc -b i486-linux
+#   define AsCmd		/usr/i486-linux/bin/as
+#   define LdCmd		ld -m elf_i386
+#   define AsmDefines		-D__ELF__
+#   define CplusplusCmd		c++ -b i486-linux
+#  endif /* i386Architecture */
+#  ifdef Mc68020Architecture
+#   define CcCmd		gcc -b m68k-linux
+#   define AsCmd		/usr/m68k-linux/bin/as
+#   define LdCmd		ld -m m68kelf
+#   define AsmDefines		-D__ELF__
+#   define CplusplusCmd		c++ -b m68k-linux
+#  endif /* Mc68020Architecture */
+# else
+#  define CcCmd			gcc
+#  define AsCmd			as
+#  define LdCmd			ld
+#  define AsmDefines		-DUSE_GAS
+# endif
 #endif
 #if UseElfFormat
-#ifndef BuildDynamicLoading
-#define BuildDynamicLoading	YES
+# ifndef DoLoadableServer
+# ifdef HPArchitecture
+#  define DoLoadableServer	NO
+# else
+#  define DoLoadableServer	YES
+# endif
+# endif
 #endif
+#ifndef CppCmd
+# define CppCmd			/lib/cpp
 #endif
-#define CppCmd			/lib/cpp
-#ifdef USE_BYACC
-#define YaccCmd			byacc
-#else
+/* Some Linux distributions have yacc, some don't. All have bison. */
 #define YaccCmd			bison -y
-#endif
 #define LexCmd			flex -l
+#define HasFlex			YES
 #define LexLib			-lfl
 #define PreProcessCmd		CcCmd -E
 #define PostIncDir		DefaultGccIncludeDir
 #define LdCombineFlags		-r
-#define LdPostLib		/* Never needed */
+#ifndef LdPostLib
+# define LdPostLib		/* Never needed */
+#endif
 #define HasWChar32		YES
-#define StandardCppDefines	-traditional StandardDefines
+#define StandardCppOptions	-traditional
+#define StandardCppDefines	StandardDefines
+
+#define HasVarRun		YES
+#define VarDbDirectory		$(VARDIR)/lib
+
+#ifndef XF86OSCardDrivers
+# define XF86OSCardDrivers	v4l
+#endif
+
+#if UseElfFormat
+# define HasPlugin			YES
+# define VendorHasX11R6_3libXext	YES	/* XC or XFree86 >= 3.3.1 */
+#endif
 
 #ifdef i386Architecture
-#define OptimizedCDebugFlags	DefaultGcc2i386Opt
-#define LinuxMachineDefines	-D__i386__
-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O
+# endif
+# define LinuxMachineDefines	-D__i386__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
 #endif /* i386Architecture */
 
+#ifdef s390Architecture
+# define DefaultCCOptions	-fsigned-char
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__s390__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* s390Architecture */
+
 #ifdef AlphaArchitecture
-#define OptimizedCDebugFlags	-O2
-#define LinuxMachineDefines	-D__alpha__
-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O
+# endif
+# define LinuxMachineDefines	-D__alpha__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64 -DJENSEN_SUPPORT
+# ifdef UseCompaqMathLibrary
+#  define MathLibrary		-lcpml -lm
+# endif
 #endif /* AlphaArchitecture */
 
+#ifdef Arm32Architecture
+# define DefaultCCOptions	-fsigned-char
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O3
+# endif
+# define LinuxMachineDefines	-D__arm__ -D__arm32__ -U__arm -Uarm
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* Arm32Achitecture */
+
+#ifdef x86_64Architecture
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__x86_64__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+#endif /* x86_64Architecture */
+
+#ifdef ia64Architecture
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__ia64__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
+#endif /* ia64Architecture */
+
 #ifdef Mc68020Architecture
-#define OptimizedCDebugFlags	-O2
-#define LinuxMachineDefines 	-D__mc68000__
-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__mc68000__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
 #endif /* Mc68020Architecture */
 
-#define StandardDefines		-Dlinux LinuxMachineDefines LinuxSourceDefines
+#ifdef PpcArchitecture
+# define DefaultCCOptions	-fsigned-char
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O
+# endif
+# define LinuxMachineDefines	-D__powerpc__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif /* PpcArchitecture */
+
+#ifdef SparcArchitecture
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__sparc__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DHAVE_DOMAINS -DGCCUSESGAS XFree86ServerDefines
+# define AsVISOption		-Av9a
+# ifdef Sparc64Architecture
+#  define AsOutputArchSize	64
+# else
+#  define AsOutputArchSize	32
+# endif
+#endif
+
+#ifdef MipsArchitecture
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags	-O2
+# endif
+# define LinuxMachineDefines	-D__mips__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif
+
+#ifdef HPArchitecture
+# define OptimizedCDebugFlags	-O2
+# define LinuxMachineDefines	-D__hppa__
+# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#endif
+
+#ifdef SuperHArchitecture
+# ifndef SuperHArchOptFlags
+#  ifdef SuperH4Architecture
+#   define SuperHArchOptFlags   -m4
+#  elif defined(SuperH4NOFPUArchitecture)
+#   define SuperHArchOptFlags   -m4-nofpu
+#  else
+#   define SuperHArchOptFlags   -m3
+#  endif
+# endif 
+# ifndef SuperHebArchitecture
+#  ifdef SuperHebArchitecture
+#   define SuperHEndianFlags    -mb
+#  else
+#   define SuperHEndianFlags    -ml
+#  endif
+# endif
+# ifndef OptimizedCDebugFlags
+#  define OptimizedCDebugFlags  -O2 SuperHArchOptFlags SuperHEndianFlags
+# endif
+# define LinuxMachineDefines    -D__sh__
+# define ServerOSDefines        XFree86ServerOSDefines -DDDXTIME -DPART_NET
+# define ServerExtraDefines     -DGCCUSESGAS XFree86ServerDefines
+#endif
+
+#ifndef StandardDefines
+# define StandardDefines	-Dlinux LinuxMachineDefines LinuxSourceDefines
+#endif
 
 #if UseElfFormat
-#define DlLibrary		-rdynamic -ldl
+# define DlLibrary		-rdynamic -ldl
 #else
-#define DlLibrary		/**/
+# define DlLibrary		/**/
 #endif
 
-#if BuildDynamicLoading
-#define ServerExtraSysLibs	DlLibrary
-#else
 #define ServerExtraSysLibs	/**/
+
+#ifndef PamLibraries
+#define PamLibraries		-lpam DlLibrary
+#endif
+
+#ifndef PamMiscLibraries
+#define PamMiscLibraries	-lpam_misc
+#endif
+
+#if HasDECnet
+# define ConnectionFlags	-DUNIXCONN -DTCPCONN -DDNETCONN
+# define ExtraLibraries		-ldnet
+#else
+# define ConnectionFlags	-DUNIXCONN -DTCPCONN
 #endif
-#define ConnectionFlags		-DUNIXCONN -DTCPCONN
 
 /* Some of these man page defaults are overriden in the above OS sections */
 #ifndef ManSuffix
@@ -295,13 +846,38 @@
 #endif
 
 #ifndef StaticLibrary
-#define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic
+# define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic
+#endif
+
+#ifndef LinkGLToUsrLib
+# define LinkGLToUsrLib		YES
+#endif
+# ifndef LinkGLToUsrInclude
+# define LinkGLToUsrInclude	YES
 #endif
 
-#define HasGnuMake	YES
+
+#define HasGnuMake		YES
 
 #define MakeNamedTargetSubdir(dir,flags,subname)\
 	$(MAKE) -C dir $(MFLAGS) $(PARALLELMFLAGS) flags subname
 
+#define ArchitectureDefines	-DLINUX_ARCHITECTURE
+
+#define TtClientLibs $(TTLIB) $(XTOOLLIB) $(XLIB)
+#define TtClientDepLibs $(DEPTTLIB) $(DEPXTOOLLIB) $(DEPXLIB)
+
+#ifdef s390Architecture
+# define HasXServer	NO
+#endif
+
 #include <lnxLib.rules>
-#include <xfree86.cf>
+#ifdef KDriveXServer
+# include <kdrive.cf>
+#else
+# include <xfree86.cf>
+#endif
+
+#ifndef XFree86ServerOSDefines
+# define XFree86ServerOSDefines
+#endif
--- vnc-3.3.7.orig/Xvnc/config/cf/vnclibs.def
+++ vnc-3.3.7/Xvnc/config/cf/vnclibs.def
@@ -0,0 +1,24 @@
+/*
+ * vnclibs.def.in - tells Xvnc where to pick up external VNC libraries
+ *
+ * Whenever you change this file, you need to run configure and then remake
+ * the Makefiles in
+ * lib/font/fontfile, programs/Xserver and programs/Xserver/hw/vnc 
+ */
+
+CXX = c++
+CXXFLAGS = -O2 -Wall
+
+CCLINK = $(CXX)
+
+RFB_TOP = $(TOP)/..
+
+top_srcdir = $(RFB_TOP)
+
+ZLIB_INCLUDE = 
+
+VNCLIBS = $(RFB_TOP)/rdr/librdr.a $(RFB_TOP)/rfb/librfb.a -lz
+
+VNCSYSLIBS =
+
+VNCCPPFLAGS = -I$(RFB_TOP)
--- vnc-3.3.7.orig/Xvnc/config/imake/imakemdep.h
+++ vnc-3.3.7/Xvnc/config/imake/imakemdep.h
@@ -465,6 +465,9 @@
 # ifdef __i386__
 	"-D__i386__",
 # endif
+# ifdef __s390__
+	"-D__s390__",
+# endif
 # ifdef __GNUC__
 	"-traditional",
 # endif
--- vnc-3.3.7.orig/Xvnc/config/makedepend/def.h
+++ vnc-3.3.7/Xvnc/config/makedepend/def.h
@@ -137,7 +137,7 @@
 
 char			*copy();
 char			*base_name();
-char			*getline();
+char			*x_getline();
 struct symtab		**slookup();
 struct symtab		**isdefined();
 struct symtab		**fdefined();
--- vnc-3.3.7.orig/Xvnc/config/makedepend/main.c
+++ vnc-3.3.7/Xvnc/config/makedepend/main.c
@@ -548,7 +548,7 @@
  * Get the next line.  We only return lines beginning with '#' since that
  * is all this program is ever interested in.
  */
-char *getline(filep)
+char *x_getline(filep)
 	register struct filepointer	*filep;
 {
 	register char	*p,	/* walking pointer */
--- vnc-3.3.7.orig/Xvnc/config/makedepend/parse.c
+++ vnc-3.3.7/Xvnc/config/makedepend/parse.c
@@ -40,7 +40,7 @@
 	register char	*line;
 	register int	type;
 
-	while (line = getline(filep)) {
+	while (line = x_getline(filep)) {
 		switch(type = deftype(line, filep, file_red, file, FALSE)) {
 		case IF:
 		case IFFALSE:
@@ -529,7 +529,7 @@
 	register int	type;
 	boolean recfailOK;
 
-	while (line = getline(filep)) {
+	while (line = x_getline(filep)) {
 		switch(type = deftype(line, filep, file_red, file, TRUE)) {
 		case IF:
 		doif:
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/hw/vnc/sockets.c
+++ vnc-3.3.7/Xvnc/programs/Xserver/hw/vnc/sockets.c
@@ -409,30 +409,64 @@
 ListenOnTCPPort(port)
     int port;
 {
-    struct sockaddr_in addr;
     int sock;
     int one = 1;
+#ifdef AF_INET6
+    int ipv = 4;
+    struct sockaddr_in6 addr6;
+#endif
+    struct sockaddr_in addr;
 
     memset(&addr, 0, sizeof(addr));
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
+#ifdef AF_INET6
+    ipv = 6;
+    addr6.sin6_family = AF_INET6;
+    addr6.sin6_port = htons(port);
     if (rfbLocalhostOnly)
-        addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+	addr6.sin6_addr = in6addr_loopback;
     else
-        addr.sin_addr.s_addr = htonl(INADDR_ANY);
+        addr6.sin6_addr = in6addr_any;
 
-    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-	return -1;
+    /* Don't fail if an IPv6 socket cannot be established, but fall back to
+       IPv4 */
+    if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
+    {
+        ipv = 4;
+#endif
+        addr.sin_family = AF_INET;
+        addr.sin_port = htons(port);
+        if (rfbLocalhostOnly)
+            addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+        else
+            addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+            return -1;
+        }
+#ifdef AF_INET6
     }
+#endif
     if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
 		   (char *)&one, sizeof(one)) < 0) {
 	close(sock);
 	return -1;
     }
-    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+#ifdef AF_INET6
+    if (ipv == 6) {
+      if (bind(sock, (struct sockaddr *)&addr6, sizeof(addr6)) < 0) {
+	close(sock);
+	return -1;
+      }
+    }
+    else if (ipv == 4) {
+#endif
+      if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
 	close(sock);
 	return -1;
+      }      
+#ifdef AF_INET6
     }
+#endif
     if (listen(sock, 5) < 0) {
 	close(sock);
 	return -1;
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/os/xalloc.c
+++ vnc-3.3.7/Xvnc/programs/Xserver/os/xalloc.c
@@ -172,7 +172,7 @@
 #define SIZE_STEPS		(sizeof(double))
 #define SIZE_HEADER		(2*sizeof(long)) /* = sizeof(double) for 32bit */
 #ifdef XALLOC_DEBUG
-#if defined(__sparc__)
+#if defined(__sparc__) || defined(__hppa__)
 #define SIZE_TAIL		(2*sizeof(long)) /* = sizeof(double) for 32bit */
 #else
 #define SIZE_TAIL		(sizeof(long))
@@ -309,7 +309,7 @@
     }
 
     /* alignment check */
-#if defined(__alpha__) || defined(__sparc__) || defined(__mips__)
+#if defined(__alpha__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__)
     amount = (amount + (sizeof(long)-1)) & ~(sizeof(long)-1);
 #endif
 
@@ -390,7 +390,13 @@
 		ptr[1] = MAGIC;
 #endif /* XALLOC_DEBUG */
 #ifdef SIZE_TAIL
+# ifdef __hppa__
+		/* reserved space for 2 * sizeof(long), so use correct one */
+		/* see SIZE_TAIL macro */
+		((unsigned long *)((char *)ptr + amount))[-2] = MAGIC2;
+# else
 		((unsigned long *)((char *)ptr + amount))[-1] = MAGIC2;
+# endif /* __hppa__ */
 #endif /* SIZE_TAIL */
 		ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
 		LOG_ALLOC("Xalloc-L", amount, ptr);
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/os/connection.c
+++ vnc-3.3.7/Xvnc/programs/Xserver/os/connection.c
@@ -379,7 +379,8 @@
    BEGIN ORL VNC modification
    Don't use SIGUSR1 - linuxthread uses this internally */
 
-/* REMOVE
+/* apparently no longer true. */
+
     if (OsSignal (SIGUSR1, SIG_IGN) == SIG_IGN)
 	RunFromSmartParent = TRUE;
     ParentProcess = getppid ();
@@ -388,7 +389,7 @@
 	    kill (ParentProcess, SIGUSR1);
 	}
     }
-*/
+
 
 /* END ORL VNC modification
 ================================================================*/
@@ -449,13 +450,11 @@
    BEGIN ORL VNC modification
    Don't use SIGUSR1 - linuxthread uses this internally */
 
-/* REMOVE
     if (RunFromSmartParent) {
 	if (ParentProcess > 0) {
 	    kill (ParentProcess, SIGUSR1);
 	}
     }
-*/
 
 /* END ORL VNC modification
 ================================================================*/
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/os/rpcauth.c
+++ vnc-3.3.7/Xvnc/programs/Xserver/os/rpcauth.c
@@ -38,6 +38,7 @@
 
 #ifdef SECURE_RPC
 
+#include <stdlib.h>
 #include "X.h"
 #include "Xauth.h"
 #include "misc.h"
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/cfb/stipsparc.s
+++ vnc-3.3.7/Xvnc/programs/Xserver/cfb/stipsparc.s
@@ -85,7 +85,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
 #ifdef TETEXT
 #define	_cfbStippleStack	cfbStippleStackTE
 #else
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/cfb/stipsprc32.s
+++ vnc-3.3.7/Xvnc/programs/Xserver/cfb/stipsprc32.s
@@ -81,7 +81,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
 #ifdef TETEXT
 #define	_cfb32StippleStack	cfb32StippleStackTE
 #else
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/dix/dixfonts.c
+++ vnc-3.3.7/Xvnc/programs/Xserver/dix/dixfonts.c
@@ -1759,10 +1759,11 @@
 	    if (err != Successful) {
 		xfree(fpe->name);
 		xfree(fpe);
-		err = BadValue;
-		goto bail;
+		err = Successful;
+	    }
+	    else {
+	      fplist[valid_paths++] = fpe;
 	    }
-	    fplist[valid_paths++] = fpe;
 	} else {
 	    err = BadValue;
 	    goto bail;
--- vnc-3.3.7.orig/Xvnc/programs/Xserver/include/servermd.h
+++ vnc-3.3.7/Xvnc/programs/Xserver/include/servermd.h
@@ -336,7 +336,7 @@
 
 #endif /* luna */
 
-#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !defined(__mc68000__)) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
+#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !(defined(__mc68000__) || defined(PPC) || defined(__sparc__) || defined(__s390__))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
 
 #ifndef IMAGE_BYTE_ORDER
 #define IMAGE_BYTE_ORDER	LSBFirst
@@ -380,6 +380,48 @@
 #define GETLEFTBITS_ALIGNMENT  1
 
 #endif /* linux/m68k */
+
+#if defined (linux) && defined (PPC)
+
+#define IMAGE_BYTE_ORDER       MSBFirst
+#define BITMAP_BIT_ORDER       MSBFirst
+#define GLYPHPADBYTES          4
+#define GETLEFTBITS_ALIGNMENT  1
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+
+#endif /* linux/PPC */
+
+#if defined (linux) && defined (__sparc__)
+
+#define IMAGE_BYTE_ORDER       MSBFirst
+#define BITMAP_BIT_ORDER       MSBFirst
+#define GLYPHPADBYTES          4
+#define GETLEFTBITS_ALIGNMENT  1
+
+#endif /* linux/__sparc__ */
+
+#if defined (linux) && defined (__s390__)
+
+#define IMAGE_BYTE_ORDER       MSBFirst
+#define BITMAP_BIT_ORDER       MSBFirst
+#define GLYPHPADBYTES          4
+#define GETLEFTBITS_ALIGNMENT  1
+
+#endif /* linux/__s390__ */
+
+#if defined (linux) && defined (PPC)
+
+#define IMAGE_BYTE_ORDER       MSBFirst
+#define BITMAP_BIT_ORDER       MSBFirst
+#define GLYPHPADBYTES          4
+#define GETLEFTBITS_ALIGNMENT  1
+
+#define LARGE_INSTRUCTION_CACHE
+#define FAST_CONSTANT_OFFSET_MODE
+
+#endif /* linux/PPC */
 
 #ifdef sgi
 
--- vnc-3.3.7.orig/vncpasswd/vncpasswd.c
+++ vnc-3.3.7/vncpasswd/vncpasswd.c
@@ -25,9 +25,12 @@
  *              anyway.
  */
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 #include <unistd.h>
 #include <rfb/vncauth.h>
 
@@ -37,24 +40,44 @@
 }
 
 int main(int argc, char *argv[]) {
+  char *home_env;
   char *passwd;
   char *passwd1;
+  char *cp;
+  char passwdDir[256];
   char passwdFile[256];
   int i;
 
   if (argc == 1) {
-      if (getenv("HOME") == NULL) {
-	  fprintf(stderr,"Error: no HOME environment variable\n");
-	  exit(1);
-      }
-      sprintf(passwdFile,"%s/.vnc/passwd",getenv("HOME"));
+    home_env = getenv("HOME");
+    if (home_env == NULL) {
+      fprintf(stderr,"Error: no HOME environment variable\n");
+      exit(1);
+    }
+    if (strlen(home_env) > 240) {
+      fprintf(stderr,"Error: HOME environment variable string too long\n");
+      exit(1);
+    }
+    sprintf(passwdDir, "%s/.vnc", home_env);
+    sprintf(passwdFile, "%s/passwd", passwdDir);
 
   } else if (argc == 2) {
-
-      strcpy(passwdFile,argv[1]);
-
+    if (strlen(argv[1]) > 240) {
+      fprintf(stderr,"Error: Passwd file string too long\n");
+      exit(1);
+    }
+    strcpy(passwdFile,argv[1]);
+    strcpy(passwdDir,argv[1]);
+    cp = strrchr(passwdDir, '/');
+    if (cp == 0) {
+	/* no directory part */
+	passwdDir[0] = '\0';
+    } else {
+	/* cut filename */
+	*cp = '\0';
+    }
   } else {
-      usage(argv);
+    usage(argv);
   }
 
   while (1) {  
@@ -79,6 +102,13 @@
     }
 
     if (strcmp(passwd1, passwd) == 0) {
+      if (passwdDir[0] &&
+	  mkdir (passwdDir, (S_IRWXU | S_IRGRP | S_IXGRP |
+			     S_IROTH | S_IXOTH)) == -1 &&
+ 	  errno != EEXIST) {
+ 	perror (passwdDir);
+ 	exit (1);
+      }      
       if (vncEncryptAndStorePasswd(passwd, passwdFile) != 0) {
 	fprintf(stderr,"Cannot write password file %s\n",passwdFile);
 	exit(1);
--- vnc-3.3.7.orig/vncviewer/listen.c
+++ vnc-3.3.7/vncviewer/listen.c
@@ -41,17 +41,6 @@
 static void flashDisplay(Display *d, char *user);
 static Bool AllXEventsPredicate(Display *d, XEvent *ev, char *arg);
 
-static void
-removeArgs(int *argc, char** argv, int idx, int nargs)
-{
-  int i;
-  if ((idx+nargs) > *argc) return;
-  for (i = idx+nargs; i < *argc; i++) {
-    argv[i-nargs] = argv[i];
-  }
-  *argc -= nargs;
-}
-
 /*
  * listenForIncomingConnections() - listen for incoming connections from
  * servers, and fork a new process to deal with each connection.  We must do
--- vnc-3.3.7.orig/vncviewer/Makefile.in
+++ vnc-3.3.7/vncviewer/Makefile.in
@@ -12,6 +12,7 @@
   selection.c \
   shm.c \
   vncviewer.c \
+  tunnel.c \
   sockets.cxx \
   zrle.cxx
 
@@ -28,6 +29,7 @@
   selection.o \
   shm.o \
   vncviewer.o \
+  tunnel.o \
   sockets.o \
   zrle.o
 
--- vnc-3.3.7.orig/vncviewer/sockets.cxx
+++ vnc-3.3.7/vncviewer/sockets.cxx
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002-2003 RealVNC Ltd.
+ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
  *
  *  This is free software; you can redistribute it and/or modify
@@ -31,6 +32,9 @@
 #include <netdb.h>
 #include <fcntl.h>
 #include <assert.h>
+#ifdef HAVE_GETADDRINFO
+#include <netdb.h>
+#endif
 extern "C" {
 #include "vncviewer.h"
 }
@@ -165,8 +169,22 @@
 int ConnectToTcpAddr(const char* hostname, int port)
 {
   int sock;
-  struct sockaddr_in addr;
   int one = 1;
+#ifdef HAVE_GETADDRINFO
+  struct addrinfo *info, hints = { 0, PF_UNSPEC, SOCK_STREAM, 0 };
+  int error;
+  
+  if ((error = getaddrinfo(hostname, NULL, &hints, &info)) != 0) {
+    fprintf(stderr, "Couldn't convert '%s' to host address: %s\n", hostname,
+	    gai_strerror(error));
+    return -1;
+  }
+
+  ((struct sockaddr_in *)info->ai_addr)->sin_port = htons(port);
+
+  sock = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
+#else
+  struct sockaddr_in addr;
   unsigned int host;
 
   if (!StringToIPAddr(hostname, &host)) {
@@ -180,19 +198,28 @@
   addr.sin_addr.s_addr = host;
 
   sock = socket(AF_INET, SOCK_STREAM, 0);
+#endif
   if (sock < 0) {
     fprintf(stderr,programName);
     perror(": ConnectToTcpAddr: socket");
     return -1;
   }
 
+#ifdef HAVE_GETADDRINFO
+  if (connect(sock, info->ai_addr, info->ai_addrlen) < 0) {
+#else
   if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+#endif
     fprintf(stderr,programName);
     perror(": ConnectToTcpAddr: connect");
     close(sock);
     return -1;
   }
 
+#ifdef HAVE_GETADDRINFO
+  freeaddrinfo(info);
+#endif
+
   if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
 		 (char *)&one, sizeof(one)) < 0) {
     fprintf(stderr,programName);
@@ -204,6 +231,39 @@
   return sock;
 }
 
+
+/*
+ * FindFreeTcpPort tries to find unused TCP port in the range
+ * (TUNNEL_PORT_OFFSET, TUNNEL_PORT_OFFSET + 99]. Returns 0 on failure.
+ */
+
+int
+FindFreeTcpPort(void)
+{
+  int sock, port;
+  struct sockaddr_in addr;
+
+  addr.sin_family = AF_INET;
+  addr.sin_addr.s_addr = INADDR_ANY;
+
+  sock = socket(AF_INET, SOCK_STREAM, 0);
+  if (sock < 0) {
+    fprintf(stderr,programName);
+    perror(": FindFreeTcpPort: socket");
+    return 0;
+  }
+
+  for (port = TUNNEL_PORT_OFFSET + 99; port > TUNNEL_PORT_OFFSET; port--) {
+    addr.sin_port = htons((unsigned short)port);
+    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
+      close(sock);
+      return port;
+    }
+  }
+
+  close(sock);
+  return 0;
+}
 
 
 /*
--- vnc-3.3.7.orig/vncviewer/argsresources.c
+++ vnc-3.3.7/vncviewer/argsresources.c
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002-2003 RealVNC Ltd.
+ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
  *
  *  This is free software; you can redistribute it and/or modify
@@ -261,6 +262,22 @@
 
 
 /*
+ * removeArgs() is used to remove some of command line arguments.
+ */
+
+void
+removeArgs(int *argc, char** argv, int idx, int nargs)
+{
+  int i;
+  if ((idx+nargs) > *argc) return;
+  for (i = idx+nargs; i < *argc; i++) {
+    argv[i-nargs] = argv[i];
+  }
+  *argc -= nargs;
+}
+
+
+/*
  * usage() prints out the usage message.
  */
 
@@ -272,6 +289,7 @@
 	  "       %s [<options>] -listen [<display#>]\n"
 	  "\n"
 	  "<options> are standard Xt options, or:\n"
+	  "              -via <GATEWAY>\n"
 	  "              -shared\n"
 	  "              -viewonly\n"
 	  "              -fullscreen\n"
@@ -340,6 +358,8 @@
   } else {
     vncServerName = argv[1];
 
+    if (!isatty(0))
+      appData.passwordDialog = True;
     if (vncServerName[0] == '-')
       usage();
   }
@@ -349,9 +369,17 @@
     exit(1);
   }
 
-  for (i = 0; vncServerName[i] != ':' && vncServerName[i] != 0; i++);
+  //for (i = 0; vncServerName[i] != ':' && vncServerName[i] != 0; i++);
+  if (vncServerName[0] == '[') {
+    for (i = 1; vncServerName[i] != ']' && vncServerName[i] != 0; i++);
 
-  strncpy(vncServerHost, vncServerName, i);
+    strncpy(vncServerHost, vncServerName + 1, i - 1);
+    i++;
+  } else {
+    for (i = 0; vncServerName[i] != ':' && vncServerName[i] != 0; i++);
+    
+    strncpy(vncServerHost, vncServerName, i);
+  }
   vncServerHost[i] = 0;
 
   if (vncServerName[i] == ':') {
--- vnc-3.3.7.orig/vncviewer/vncviewer.c
+++ vnc-3.3.7/vncviewer/vncviewer.c
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002-2003 RealVNC Ltd.
+ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
  *
  *  This is free software; you can redistribute it and/or modify
@@ -55,6 +56,11 @@
   for (i = 1; i < argc; i++) {
     if (strcmp(argv[i], "-listen") == 0) {
       listenForIncomingConnections(&argc, argv, i);
+      break;
+    }
+    if (strcmp(argv[i], "-tunnel") == 0 || strcmp(argv[i], "-via") == 0) {
+      if (!createTunnel(&argc, argv, i))
+	exit(1);
       break;
     }
   }
--- vnc-3.3.7.orig/vncviewer/vncviewer.h
+++ vnc-3.3.7/vncviewer/vncviewer.h
@@ -1,5 +1,6 @@
 /*
  *  Copyright (C) 2002 RealVNC Ltd.
+ *  Copyright (C) 2000, 2001 Const Kaplinsky.  All Rights Reserved.
  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
  *
  *  This is free software; you can redistribute it and/or modify
@@ -51,8 +52,15 @@
 
 #define FLASH_PORT_OFFSET 5400
 #define LISTEN_PORT_OFFSET 5500
+#define TUNNEL_PORT_OFFSET 5500
 #define SERVER_PORT_OFFSET 5900
 
+#define DEFAULT_SSH_CMD "/usr/bin/ssh"
+#define DEFAULT_TUNNEL_CMD  \
+  (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20")
+#define DEFAULT_VIA_CMD     \
+  (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20")
+
 
 /* argsresources.c */
 
@@ -103,6 +111,8 @@
 extern XrmOptionDescRec cmdLineOptions[];
 extern int numCmdLineOptions;
 
+extern void removeArgs(int *argc, char** argv, int idx, int nargs);
+extern void usage();
 extern void GetArgsAndResources(int argc, char **argv);
 extern void SetFullScreenState(Widget w, XEvent *event, String *params,
 			       Cardinal *num_params);
@@ -233,10 +243,20 @@
 extern Bool ReadFromRFBServer(char *out, unsigned int n);
 extern Bool WriteToRFBServer(char *buf, int n);
 extern int ConnectToTcpAddr(const char* hostname, int port);
+extern int FindFreeTcpPort(void);
 extern int ListenAtTcpPort(int port);
 extern int AcceptTcpConnection(int listenSock);
 
 extern int StringToIPAddr(const char *str, unsigned int *addr);
+
+extern Bool SameMachine(int sock);
+
+/* tunnel.c */
+
+extern Bool tunnelSpecified;
+
+extern Bool createTunnel(int *argc, char **argv, int tunnelArgIndex);
+
 
 /* vncviewer.c */
 
--- vnc-3.3.7.orig/vncviewer/Vncviewer.ad
+++ vnc-3.3.7/vncviewer/Vncviewer.ad
@@ -19,8 +19,8 @@
 !
 
 Vncviewer.translations:\
-  <Enter>: SelectionToVNC()\n\
-  <Leave>: SelectionFromVNC()
+  <Enter>: SelectionToVNC(always)\n\
+  <Leave>: SelectionFromVNC(always)
 
 
 !
--- vnc-3.3.7.orig/vncviewer/vncviewer.man
+++ vnc-3.3.7/vncviewer/vncviewer.man
@@ -89,6 +89,11 @@
 on customisation below.
 
 .TP
+.B \-via \fIXgateway\fP
+Makes the connection go though SSH to a gateway host. The gateway should be the
+target host for best connection secrecy.
+
+.TP
 .B \-listen \fI[display-number]\fP
 Causes vncviewer to listen on port 5500 +
 .I display-number
--- vnc-3.3.7.orig/vncviewer/tunnel.c
+++ vnc-3.3.7/vncviewer/tunnel.c
@@ -0,0 +1,254 @@
+/*
+ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+ *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+ *
+ *  This is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This software is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this software; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ *  USA.
+ */
+
+/*
+ * tunnel.c - tunneling support (e.g. for using standalone SSH installation)
+ */
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <vncviewer/vncviewer.h>
+
+/* True if there was -tunnel or -via option in the command line. */
+Bool tunnelSpecified = False;
+
+/* True if it was -tunnel, not -via option. */
+static Bool tunnelOption = False;
+
+/* "Hostname:display" pair in the command line will be substituted
+   by this fake argument when tunneling is used. */
+static char lastArgv[32];
+
+
+static void processTunnelArgs(char **remoteHost,
+			      int *remotePort, int localPort,
+			      int *pargc, char **argv, int tunnelArgIndex);
+static void processViaArgs(char **gatewayHost, char **remoteHost,
+			   int *remotePort, int localPort,
+			   int *pargc, char **argv, int tunnelArgIndex);
+static char *getCmdPattern(void);
+static Bool fillCmdPattern(char *result, char *pattern,
+			   char *gatewayHost, char *remoteHost,
+			   char *remotePort, char *localPort);
+static Bool runCommand(char *cmd);
+
+
+Bool
+createTunnel(int *pargc, char **argv, int tunnelArgIndex)
+{
+  char *pattern;
+  char cmd[1024];
+  int localPort, remotePort;
+  char localPortStr[8];
+  char remotePortStr[8];
+  char *gatewayHost = "";
+  char *remoteHost = "localhost";
+
+  tunnelSpecified = True;
+  if (strcmp(argv[tunnelArgIndex], "-tunnel") == 0)
+    tunnelOption = True;
+
+  pattern = getCmdPattern();
+  if (!pattern)
+    return False;
+
+  localPort = FindFreeTcpPort();
+  if (localPort == 0)
+    return False;
+
+  if (tunnelOption) {
+    processTunnelArgs(&remoteHost, &remotePort, localPort,
+		      pargc, argv, tunnelArgIndex);
+  } else {
+    processViaArgs(&gatewayHost, &remoteHost, &remotePort, localPort,
+		   pargc, argv, tunnelArgIndex);
+  }
+
+  sprintf(localPortStr, "%d", localPort);
+  sprintf(remotePortStr, "%d", remotePort);
+
+  if (!fillCmdPattern(cmd, pattern, gatewayHost, remoteHost,
+		      remotePortStr, localPortStr))
+    return False;
+
+  if (!runCommand(cmd))
+    return False;
+
+  return True;
+}
+
+static void
+processTunnelArgs(char **remoteHost, int *remotePort, int localPort,
+		  int *pargc, char **argv, int tunnelArgIndex)
+{
+  char *pdisplay;
+  //int port;
+
+  if (tunnelArgIndex >= *pargc - 1)
+    usage();
+
+  pdisplay = strchr(argv[*pargc - 1], ':');
+  if (pdisplay == NULL || pdisplay == argv[*pargc - 1])
+    usage();
+
+  *pdisplay++ = '\0';
+  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
+    usage();
+
+  *remotePort = atoi(pdisplay);
+  if (*remotePort < 100)
+    *remotePort += SERVER_PORT_OFFSET;
+
+  sprintf(lastArgv, "localhost:%d", localPort);
+
+  *remoteHost = argv[*pargc - 1];
+  argv[*pargc - 1] = lastArgv;
+
+  removeArgs(pargc, argv, tunnelArgIndex, 1);
+}
+
+static void
+processViaArgs(char **gatewayHost, char **remoteHost,
+	       int *remotePort, int localPort,
+	       int *pargc, char **argv, int tunnelArgIndex)
+{
+  char *pdisplay;
+  //int port;
+
+  if (tunnelArgIndex >= *pargc - 2)
+    usage();
+
+  pdisplay = strchr(argv[*pargc - 1], ':');
+  if (pdisplay == NULL)
+    usage();
+
+  *pdisplay++ = '\0';
+  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
+    usage();
+
+  *remotePort = atoi(pdisplay);
+  if (*remotePort < 100)
+    *remotePort += SERVER_PORT_OFFSET;
+
+  sprintf(lastArgv, "localhost:%d", localPort);
+
+  *gatewayHost = argv[tunnelArgIndex + 1];
+
+  if (pdisplay != &argv[*pargc - 1][1])
+    *remoteHost = argv[*pargc - 1];
+
+  argv[*pargc - 1] = lastArgv;
+
+  removeArgs(pargc, argv, tunnelArgIndex, 2);
+}
+
+static char *
+getCmdPattern(void)
+{
+  struct stat st;
+  char *pattern;
+
+  pattern = getenv((tunnelOption) ? "VNC_TUNNEL_CMD" : "VNC_VIA_CMD");
+  if (pattern == NULL) {
+    if ( stat(DEFAULT_SSH_CMD, &st) != 0 ||
+	 !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) ) {
+      fprintf(stderr, "%s: Cannot establish SSH tunnel: missing %s binary.\n",
+	      programName, DEFAULT_SSH_CMD);
+      return NULL;
+    }
+    pattern = (tunnelOption) ? DEFAULT_TUNNEL_CMD : DEFAULT_VIA_CMD;
+  }
+
+  return pattern;
+}
+
+/* Note: in fillCmdPattern() result points to a 1024-byte buffer */
+
+static Bool
+fillCmdPattern(char *result, char *pattern,
+	       char *gatewayHost, char *remoteHost,
+	       char *remotePort, char *localPort)
+{
+  int i, j;
+  Bool H_found = False, G_found = False, R_found = False, L_found = False;
+
+  for (i=0, j=0; pattern[i] && j<1023; i++, j++) {
+    if (pattern[i] == '%') {
+      switch (pattern[++i]) {
+      case 'H':
+	strncpy(&result[j], remoteHost, 1024 - j);
+	j += strlen(remoteHost) - 1;
+	H_found = True;
+	continue;
+      case 'G':
+	strncpy(&result[j], gatewayHost, 1024 - j);
+	j += strlen(gatewayHost) - 1;
+	G_found = True;
+	continue;
+      case 'R':
+	strncpy(&result[j], remotePort, 1024 - j);
+	j += strlen(remotePort) - 1;
+	R_found = True;
+	continue;
+      case 'L':
+	strncpy(&result[j], localPort, 1024 - j);
+	j += strlen(localPort) - 1;
+	L_found = True;
+	continue;
+      case '\0':
+	i--;
+	continue;
+      }
+    }
+    result[j] = pattern[i];
+  }
+
+  if (pattern[i]) {
+    fprintf(stderr, "%s: Tunneling command is too long.\n", programName);
+    return False;
+  }
+
+  if (!H_found || !R_found || !L_found) {
+    fprintf(stderr, "%s: %%H, %%R or %%L absent in tunneling command.\n",
+	    programName);
+    return False;
+  }
+  if (!tunnelOption && !G_found) {
+    fprintf(stderr, "%s: %%G pattern absent in tunneling command.\n",
+	    programName);
+    return False;
+  }
+
+  result[j] = '\0';
+  return True;
+}
+
+static Bool
+runCommand(char *cmd)
+{
+  if (system(cmd) != 0) {
+    fprintf(stderr, "%s: Tunneling command failed: %s.\n",
+	    programName, cmd);
+    return False;
+  }
+  return True;
+}
+
--- vnc-3.3.7.orig/configure.in
+++ vnc-3.3.7/configure.in
@@ -75,6 +75,8 @@
 SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=int')
 AC_SUBST(SOCKLEN_T_DEFINE)
 
+AC_CHECK_FUNCS(getaddrinfo)
+
 AC_OUTPUT(Makefile:Makefile.in:boilerplate.mk \
          rdr/Makefile:rdr/Makefile.in:boilerplate.mk \
          rfb/Makefile:rfb/Makefile.in:boilerplate.mk \
--- vnc-3.3.7.orig/applied-patches
+++ vnc-3.3.7/applied-patches
@@ -0,0 +1,13 @@
+Applying debian/patches/vnc-3.3.3-10-xdm-auth-support.patch
+Applying debian/patches/vnc-3.3.3r2-debian-bug-128096-security-fix.patch
+Applying debian/patches/vnc-3.3.3r2-getline-fix.patch
+Applying debian/patches/vnc-3.3.3-x-gdm-fix.patch
+Applying debian/patches/vnc-3.3.3-x-manpath-lsb.patch
+Applying debian/patches/vnc-3.3.4-platform-fixes.patch
+Applying debian/patches/vnc-3.3.4-vncpasswd-filecreation-fix.patch
+Applying debian/patches/vnc-3.3.4-vncpasswd-possible-minor-security-fix.patch
+Applying debian/patches/vnc-3.3.5-dynlib.patch
+Applying debian/patches/vnc-3.3.6-dixfontsfix.patch
+Applying debian/patches/vnc-3.3.6-passwddialogwhennotty.patch
+Applying debian/patches/debian/vnc-3.3.3r2.xapploaddir.patch
+Applying debian/patches/vnc-3.3.7-tunnel-via-ssh-from-tightvnc-without-anuthing-else.patch
--- vnc-3.3.7.orig/debian/libvncauth0.links
+++ vnc-3.3.7/debian/libvncauth0.links
@@ -0,0 +1 @@
+usr/lib/libvncauth.so.0.0 usr/lib/libvncauth.so.0
--- vnc-3.3.7.orig/debian/rules
+++ vnc-3.3.7/debian/rules
@@ -0,0 +1,221 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper. 
+# GNU copyright 1997 by Joey Hess.
+#
+# This version is for a hypothetical package that builds an
+# architecture-dependant package, as well as an architecture-independent
+# package.
+
+# Uncomment this to turn on verbose mode. 
+#export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=3
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+	INSTALL_PROGRAM += -s
+endif
+
+config.status: configure
+	dh_testdir
+	# Add here commands to configure the package.
+	./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
+		--prefix=/usr \
+		--mandir=\$${prefix}/share/man \
+		--infodir=\$${prefix}/share/info \
+		--localstatedir=/var \
+		--with-installed-zlib \
+		--with-x
+
+build-arch:  config.status build-arch-stamp
+build-arch-stamp:
+	dh_testdir
+
+	# Add here command to compile/build the package.
+	# Build first things.
+	$(MAKE)
+	# Build Xvnc
+	#xmkmf
+	(cd Xvnc; $(MAKE) World)
+
+	lynx -dump debian/faq.html   | sed 's,file://.*/,,' > debian/faq.txt
+	lynx -dump debian/start.html | sed 's,file://.*/,,' > debian/start.txt
+
+	touch build-arch-stamp
+
+build-indep: config.status  build-indep-stamp
+build-indep-stamp:
+	dh_testdir
+
+	# Add here command to compile/build the arch indep package.
+	# It's ok not to do anything here, if you don't need to build
+	#  anything for this package.
+	#/usr/bin/docbook-to-man debian/vnc.sgml > vnc.1
+
+	touch build-indep-stamp
+
+build: build-arch build-indep
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-arch-stamp build-indep-stamp 
+	rm -f debian/faq.txt debian/start.txt
+
+	# Add here commands to clean up after the build process.
+	-rm -f config.log config.status config.cache config.guess config.sub
+	-$(MAKE) distclean
+	-$(MAKE) clean
+	-test -r /usr/share/misc/config.sub && \
+	  cp -f /usr/share/misc/config.sub config.sub
+	-test -r /usr/share/misc/config.guess && \
+	  cp -f /usr/share/misc/config.guess config.guess
+
+	#cd Xvnc; xmkmf
+	-cd Xvnc && $(MAKE) clean
+
+	-find . -type f -a -name Makefile -a ! -path '*Xvnc/Makefile' \
+		-exec rm -f '{}' ';'
+	-rmdir Xvnc/exports
+
+	dh_clean Xvnc/xmakefile \
+		Xvnc/config/cf/host.def \
+		Xvnc/config/imake/Makefile.proto
+
+install: DH_OPTIONS=
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	# Add here commands to install the package into debian/vnc.
+	#$(MAKE) install prefix=$(CURDIR)/debian/vnc/usr
+#	mkdir -p $(CURDIR)/debian/tmp
+#	./vncinstall $(CURDIR)/debian/tmp/
+# vnc-common
+	install -o root -g root -m 755 vncpasswd/vncpasswd \
+		$(CURDIR)/debian/vnc-common/usr/bin/realvncpasswd.real
+	install -o root -g root -m 755 debian/vncpasswd.wrapper \
+		$(CURDIR)/debian/vnc-common/usr/bin/realvncpasswd
+	install -o root -g root -m 644 debian/vncpasswd.1x \
+		$(CURDIR)/debian/vnc-common/usr/share/man/man1/realvncpasswd.1
+	install -o root -g root -m 644 debian/vnc.conf.5x \
+		$(CURDIR)/debian/vnc-common/usr/share/man/man5/vnc.conf.5x
+	install -o root -g root -m 644 debian/vnc.conf \
+		$(CURDIR)/debian/vnc-common/etc/vnc.conf
+
+# vncserver
+	install -o root -g root -m 755 Xvnc/programs/Xserver/Xvnc \
+		$(CURDIR)/debian/vncserver/usr/bin/Xrealvnc
+	install -o root -g root -m 755 debian/vncserver.wrapper \
+		$(CURDIR)/debian/vncserver/usr/bin/realvncserver
+	install -o root -g root -m 755 vncconnect/vncconnect \
+		$(CURDIR)/debian/vncserver/usr/bin/realvncconnect
+
+	install -o root -g root -m 644 debian/vncserver.1x \
+		$(CURDIR)/debian/vncserver/usr/share/man/man1/realvncserver.1x
+	install -o root -g root -m 644 vncconnect/vncconnect.man \
+		$(CURDIR)/debian/vncserver/usr/share/man/man1/realvncconnect.1
+#	install -o root -g root -m 644 debian/Xvnc.1x \
+#		$(CURDIR)/debian/vncserver/usr/share/man/man1/Xvnc.1x
+	install -o root -g root -m 644 Xvnc/programs/Xserver/Xvnc.man \
+		$(CURDIR)/debian/vncserver/usr/share/man/man1/Xrealvnc.1
+
+# libvncauth0
+	install -o root -g root -m 644 rfb/libvncauth.so.0.0 \
+		$(CURDIR)/debian/libvncauth0/usr/lib
+
+# libvncauth-dev
+	# Now moved to rfb dir.
+	#install -o root -g root -m 644 include/* \
+	#	$(CURDIR)/debian/libvncauth-dev/usr/include
+	install -o root -g root -m 644 rfb/libvncauth.a \
+		$(CURDIR)/debian/libvncauth-dev/usr/lib
+
+# xvncviewer
+	install -o root -g root -m 755 vncviewer/vncviewer \
+		$(CURDIR)/debian/xvncviewer/usr/bin/xrealvncviewer
+#	install -o root -g root -m 644 vncviewer/Vncviewer \
+#		$(CURDIR)/debian/xvncviewer/usr/X11R6/lib/X11/app-defaults/Xvncviewer
+	install -o root -g root -m 644 vncviewer/Vncviewer.ad \
+		$(CURDIR)/debian/xvncviewer/etc/X11/app-defaults/Xvncviewer
+#	install -o root -g root -m 644 debian/xvncviewer.1x \
+#		$(CURDIR)/debian/xvncviewer/usr/share/man/man1/xrealvncviewer.1x
+	install -o root -g root -m 644 vncviewer/vncviewer.man \
+		$(CURDIR)/debian/xvncviewer/usr/share/man/man1/xrealvncviewer.1
+
+#	dh_movefiles
+
+# Build architecture-independent files here.
+# Pass -i to all debhelper commands in this target to reduce clutter.
+binary-indep: build install
+
+binary-indep-keep:
+	dh_testdir -i
+	dh_testroot -i
+#	dh_installdebconf -i
+	dh_installdocs -i
+	dh_installexamples -i
+	dh_installmenu -i
+#	dh_installlogrotate -i
+#	dh_installemacsen -i
+#	dh_installpam -i
+#	dh_installmime -i
+#	dh_installinit -i
+	dh_installcron -i
+#	dh_installman -i
+	dh_installinfo -i
+#	dh_undocumented -i
+	dh_installchangelogs  -i
+	dh_link -i
+	dh_compress -i
+	dh_fixperms -i
+	dh_installdeb -i
+	dh_perl -i
+	dh_gencontrol -i
+	dh_md5sums -i
+	dh_builddeb -i
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir -a
+	dh_testroot -a
+#	dh_installdebconf -a
+	dh_installdocs -a
+	dh_installexamples -a
+	dh_installmenu -a
+#	dh_installlogrotate -a
+#	dh_installemacsen -a
+#	dh_installpam -a
+#	dh_installmime -a
+#	dh_installinit -a
+	dh_installcron -a
+#	dh_installman -a
+	dh_installinfo -a
+#	dh_undocumented -a
+	dh_installchangelogs  -a
+	dh_strip -a
+	dh_link -a
+	dh_compress -a
+	dh_fixperms -a
+	dh_makeshlibs -a
+	dh_installdeb -a
+	dh_perl -a
+#	dh_shlibdeps -a
+	dh_shlibdeps -l `pwd`/debian/libvncauth0/usr/lib -- -Ldebian/libvncauth0/DEBIAN/shlibs
+	dh_gencontrol -a
+	dh_md5sums -a
+	dh_builddeb -a
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install 
--- vnc-3.3.7.orig/debian/vncserver.wrapper
+++ vnc-3.3.7/debian/vncserver.wrapper
@@ -0,0 +1,688 @@
+#!/usr/bin/perl
+#
+#  This file is based on a vncserver script provided by:
+#
+#  Copyright (C) 1997, 1998 Olivetti & Oracle Research Laboratory
+#
+#  This is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This software is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this software; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+#  USA.
+#
+
+use File::Path;
+
+#
+# vncserver - wrapper script to start an X VNC server.
+#
+# This file was heavily edited by
+#                 Marcus Brinkmann
+#                 <Marcus.Brinkmann@ruhr-uni-bochum.de>
+# Clean option by Dirk Eddelbuettel
+#                 <edd@debian.org>
+
+# Please report all errors to me and not to ORL.
+
+#
+# First make sure we're operating in a sane environment.
+#
+
+&SanityCheck();
+
+#
+# Then source in configuration files, first the site wide one and then the
+# user specific one.
+#
+
+$Config_file = "/etc/vnc.conf";
+&ReadConfigFile();
+$Config_file = "$ENV{HOME}/.vncrc";
+&ReadConfigFile();
+
+if (!$vncClasses) {
+  if (-d "/usr/share/vnc-java") {
+    $vncClasses = "/usr/share/vnc-java";
+  }
+}
+if (!$xauthorityFile) {
+    if (!$ENV{XAUTHORITY}) {
+        $xauthorityFile = "$ENV{HOME}/.Xauthority";
+    } else {
+       $xauthorityFile = "$ENV{XAUTHORITY}";
+    }
+}
+if (!$vncUserDir) {
+  $vncUserDir = "$ENV{HOME}/.vnc";
+}
+if (!$vncPasswdFile) {
+  $vncPasswdFile = $vncUserDir . "/passwd";
+}
+if (!$defaultDesktopName) {
+  $defaultDesktopName = "X";
+}
+if (!$rfbwait) {
+  $rfbwait = "120000";
+}
+if (!$vncStartup) {
+  $vncStartup = "/etc/X11/Xsession";
+}
+if (!$XFConfigPath) {
+  $XFConfigPath = "/etc/X11/XF86Config";
+}
+if (!$fontPath) {
+  &ReadXFConfigFont;
+}
+if (!$fontPath) {
+  $fontPath = "/usr/X11R6/lib/X11/fonts/Type1/,".
+              "/usr/X11R6/lib/X11/fonts/Speedo/,".
+              "/usr/X11R6/lib/X11/fonts/misc/,".
+              "/usr/X11R6/lib/X11/fonts/75dpi/,".
+              "/usr/X11R6/lib/X11/fonts/100dpi/"
+}
+if (!$colorPath) {
+  &ReadXFConfigColor;
+}
+if (!$colorPath) {
+  $colorPath = "/usr/X11R6/lib/X11/rgb";
+}
+if ($geometry) {
+  $opt{'-geometry'} = $geometry;
+}
+if ($depth) {
+  $opt{'-depth'} = $depth;
+}
+if ($pixelformat) {
+  $opt{'-pixelformat'} = $pixelformat;
+}
+
+chop($host = `uname -n`);
+
+&ParseOptions("-geometry",1,"-depth",1,"-pixelformat",1,"-name",1,
+              "-help",0,"--help",0,"-h",0,
+              "-kill",1,"-clean",0, "-fp",1,
+	      "-alwaysshared",0, "-nevershared",0,
+	      "-httpport",1,"-basehttpport",1,
+	      "-startup",1,"-once",0);
+
+$useClasses = 0;
+if (defined $vncClasses) {
+  if(! -d $vncClasses) {
+    die "VNC class files can not be found at $vncClasses.";
+  }
+  $useClasses = 1;
+}
+
+&Usage() if (($opt{'-help'}) || ($opt{'-h'}) || ($opt{'--help'}));
+
+if (my $display = $opt{'-kill'}) {
+	if ($display !~ /^:\d+$/) {
+        	&Usage();
+	}
+    	&Kill($display);
+}
+
+&GetXDisplayDefaults();
+
+&CheckGeometryAndDepth();
+
+if (!$opt{'-fp'}) {
+    $opt{'-fp'} = $fontPath;
+}
+
+@fontPathElements = split(/\s*,\s*/, "$opt{'-fp'}");
+
+$fontPath = '';
+
+foreach $i (0.."$#fontPathElements") {
+    $tempFontPath = $fontPathElements[$i];
+    if ($tempFontPath !~ m!^[^/]*/[^/]*:\d+$!) {
+	$tempFontPath =~ s/:unscaled$//;
+	if (-r "$tempFontPath/fonts.dir") {
+	    $fontPath .= "$fontPathElements[$i],";
+	}
+    } else {
+	$fontPath .= "$fontPathElements[$i],";
+    }
+}
+chop $fontPath;
+
+if (!$opt{'-name'}) {
+    $opt{'-name'} = $defaultDesktopName; # default desktop name
+}
+
+if (!(-d $vncUserDir)) {
+    # Create the user's vnc directory if necessary.
+    if (-e $vncUserDir) {
+        die "$prog: Could not create $vncUserDir, file exists but is not a directory.\n";
+    }
+    if (!mkpath ($vncUserDir, 0, 0755)) {
+        die "$prog: Could not create $vncUserDir.\n";
+    }
+}
+
+# Make sure the user has a password.
+
+($z,$z,$mode) = stat("$vncPasswdFile");
+if (!(-e "$vncPasswdFile") || ($mode & 077)) {
+    warn "\nYou will require a password to access your desktops.\n\n";
+    system("vncpasswd $vncPasswdFile"); 
+    if (($? >> 8) != 0) {
+	exit 1;
+    }
+}
+
+# Find display number.
+
+if ((@ARGV > 0) && ($ARGV[0] =~ /^:(\d+)$/)) {
+    $displayNumber = $1;
+    shift(@ARGV);
+    if (!&CheckDisplayNumber($displayNumber)) {
+	die "A VNC server is already running as :$displayNumber\n";
+    }
+} elsif ((@ARGV > 0) && ($ARGV[0] !~ /^-/)) {
+    &Usage();
+} else {
+    $displayNumber = &GetDisplayNumber();
+}
+
+$vncPort = 5900 + $displayNumber;
+
+$desktopLog = "$vncUserDir/$host:$displayNumber.log";
+unlink($desktopLog);
+
+# Make an X server cookie
+
+srand(time+$$+unpack("L",`cat $vncUserDir/passwd`));
+$cookie = "";
+for (1..16) {
+    $cookie .= sprintf("%02x", int(rand(256)));
+}
+
+system("xauth -f $xauthorityFile add $host:$displayNumber . $cookie");
+system("xauth -f $xauthorityFile add $host/unix:$displayNumber . $cookie");
+
+# Now start the X VNC Server
+
+$cmd = "Xrealvnc :$displayNumber";
+$cmd .= " -desktop " . &quotedString($opt{'-name'});
+
+if ($useClasses) {
+  $cmd .= " -httpd $vncClasses";
+  print ("Found $vncClasses for http connections.\n");
+  if ($opt{'-httpport'}) {
+    $cmd .= " -httpport $opt{'-httpport'}";
+    print ("Listening to $opt{'-httpport'} for http connections.\n");
+  }
+  elsif ($opt{'-basehttpport'}) {
+    my $v = $opt{'-basehttpport'} + $displayNumber;
+    print ("Listening to $v for http connections.\n");
+    $cmd .= " -httpport $v";
+  }
+}
+$cmd .= " -auth $xauthorityFile";
+$cmd .= " -geometry $opt{'-geometry'}" if ($opt{'-geometry'});
+$cmd .= " -depth $opt{'-depth'}" if ($opt{'-depth'});
+$cmd .= " -pixelformat $opt{'-pixelformat'}" if ($opt{'-pixelformat'});
+$cmd .= " -rfbwait $rfbwait";
+$cmd .= " -rfbauth $vncPasswdFile";
+$cmd .= " -rfbport $vncPort";
+$cmd .= ' -fp "' . $fontPath . '"';
+$cmd .= " -co $colorPath" if ($colorPath);
+$cmd .= " -alwaysshared" if ($opt{'-alwaysshared'});
+$cmd .= " -nevershared" if ($opt{'-nevershared'});
+
+foreach $arg (@ARGV) {
+    $cmd .= " " . &quotedString($arg);
+}
+$cmd .= " >> " . &quotedString($desktopLog) . " 2>&1";
+
+# Run $cmd and record the process ID.
+
+$pidFile = "$vncUserDir/$host:$displayNumber.pid";
+system("$cmd & echo \$! >$pidFile");
+
+# Give Xvnc a chance to start up
+
+sleep(3);
+
+warn "\nNew '$opt{'-name'}' desktop is $host:$displayNumber\n\n";
+
+# Run the X startup script.
+
+$vncStartup = $opt{'-startup'} if exists $opt{'-startup'};
+warn "Starting applications specified in $vncStartup\n";
+warn "Log file is $desktopLog\n\n";
+
+$ENV{DISPLAY}= ":$displayNumber";
+$ENV{VNCDESKTOP}= $opt{'-name'};
+
+if (! -x $vncStartup) {
+	$vncStartup = "/bin/sh " . $vncStartup;
+}
+
+if ($opt{'-once'}) {
+	system("$vncStartup >> " . &quotedString($desktopLog) . " 2>&1");
+	&Kill(":" . $displayNumber);
+} else  {
+	system("$vncStartup >> " . &quotedString($desktopLog) . " 2>&1 &") if ($vncStartup);
+}
+exit;
+
+#########################################################################
+#
+# I thank Manoj for the code below. All errors are mine, though.
+#
+# ReadConfigFile reads in a config file and sets variables according to it.
+#
+
+sub ReadConfigFile
+{
+  open(CONFIG, "$Config_file") || return;
+  my $lineno = 0;
+  while (<CONFIG>) {
+      chomp;
+      $lineno++;
+      s/\#.*//og;
+      next if /^\s*$/og;
+      $_ .= ";" unless /;\s*$/;
+      if (/^\s*([^=]+)\s*=\s*(\S.*)$/o) {
+          my $ret = eval "$1=$2";
+          if ($@) {
+              print STDERR "Error parsing config file $Config_file!\n";
+              print STDERR "$lineno:$_\n";
+          }
+      }
+  }
+}
+
+sub ReadXFConfigFont
+{
+  open(CONFIG, "$XFConfigPath") || return;
+  my $lineno = 0;
+  while (<CONFIG>) {
+      chomp;
+      $lineno++;
+      s/\#.*//og;
+      next if /^\s*$/og;
+      if (/^\s*FontPath\s*"(\S.*)"\s*$/o) {
+          $fontPath .= "," if $fontPath;
+          $fontPath .= $1;
+      }
+  }
+}
+
+sub ReadXFConfigColor
+{
+  open(CONFIG, "$XFConfigPath") || return;
+  my $lineno = 0;
+  while (<CONFIG> && !$colorPath) {
+      chomp;
+      $lineno++;
+      s/\#.*//og;
+      next if /^\s*$/og;
+      if (/^\s*RgbPath\s*"(\S.*)"\s*$/o) {
+          $colorPath = $1;
+      }
+  }
+}
+
+
+###############################################################################
+#
+# CheckGeometryAndDepth simply makes sure that the geometry and depth values
+# are sensible.
+#
+
+sub CheckGeometryAndDepth
+{
+    if ($opt{'-geometry'}) {
+	if ($opt{'-geometry'} =~ /^(\d+)x(\d+)$/) {
+	    $width = $1; $height = $2;
+
+	    if (($width<1) || ($height<1)) {
+		die "$prog: geometry $opt{'-geometry'} is invalid\n";
+	    }
+
+	    while (($width % 4)!=0) {
+		$width = $width + 1;
+	    }
+
+	    while (($height % 2)!=0) {
+		$height = $height + 1;
+	    }
+
+	    $opt{-geometry} = "${width}x$height";
+	} else {
+	    die "$prog: geometry $opt{'-geometry'} is invalid\n";
+	}
+    }
+
+    if ($opt{'-depth'}) {
+	if (($opt{'-depth'} < "8") || ($opt{'-depth'} > 32)) {
+	    die "Depth must be between 8 and 32\n";
+	}
+    }
+}
+
+
+#
+# GetDisplayNumber gets the lowest available display number.  A display number
+# n is taken if something is listening on the VNC server port (5900+n) or the
+# X server port (6000+n).
+#
+
+sub GetDisplayNumber
+{
+    foreach $n (1..99) {
+	if (&CheckDisplayNumber($n)) {
+	    return $n;
+	}
+    }
+    
+    die "$prog: no free display number on $host.\n";
+}
+
+
+#
+# CheckDisplayNumber checks if the given display number is available.  A
+# display number n is taken if something is listening on the VNC server port
+# (5900+n) or the X server port (6000+n).
+#
+
+sub CheckDisplayNumber
+{
+    local ($n) = @_;
+
+    socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
+    if (!bind(S, pack('S n x12', $AF_INET, 6000 + $n))) {
+	close(S);
+	return 0;
+    }
+    close(S);
+
+    socket(S, $AF_INET, $SOCK_STREAM, 0) || die "$prog: socket failed: $!\n";
+    if (!bind(S, pack('S n x12', $AF_INET, 5900 + $n))) {
+	close(S);
+	return 0;
+    }
+    close(S);
+
+    if (-e "/tmp/.X$n-lock") {
+        warn "\nWarning: $host:$n is not taken because of /tmp/.X$n-lock\n";
+        warn "Remove this file if there is no X server $host:$n\n";
+        return 0;
+    }
+
+    if (-e "/tmp/.X11-unix/X$n") {
+        warn "\nWarning: $host:$n is not taken because of /tmp/.X11-unix/X$n\n";
+        warn "Remove this file if there is no X server $host:$n\n";
+        return 0;
+    }
+
+    return 1;
+}
+
+
+#
+# GetXDisplayDefaults uses xdpyinfo to find out the geometry, depth and pixel
+# format of the current X display being used.  If successful, it sets the
+# options as appropriate so that the X VNC server will use the same settings
+# (minus an allowance for window manager decorations on the geometry).  Using
+# the same depth and pixel format means that the VNC server won't have to
+# translate pixels when the desktop is being viewed on this X display (for
+# TrueColor displays anyway).
+#
+
+sub GetXDisplayDefaults
+{
+    local (@lines, @matchlines, $width, $height, $defaultVisualId, $i,
+	   $red, $green, $blue);
+
+    $wmDecorationWidth = 4;	# a guess at typical size for window manager
+    $wmDecorationHeight = 24;	# decoration size
+
+    return if (!$getDefaultFrom && !defined($ENV{DISPLAY}));
+
+    @lines = `xdpyinfo $getDefaultFrom 2>/dev/null`;
+
+    return if ($? != 0);
+
+    if (!$opt{'-geometry'}) {
+	@matchlines = grep(/dimensions/, @lines);
+	if (@matchlines) {
+	    ($width, $height) = ($matchlines[0] =~ /(\d+)x(\d+) pixels/);
+
+	    $width -= $wmDecorationWidth;
+	    $height -= $wmDecorationHeight;
+
+	    $opt{'-geometry'} = "${width}x$height";
+	}
+    }
+
+    if (!$opt{'-depth'} && !$opt{'-pixelformat'}) {
+	@matchlines = grep(/default visual id/, @lines);
+	if (@matchlines) {
+	    ($defaultVisualId) = ($matchlines[0] =~ /id:\s+(\S+)/);
+
+	    for ($i = 0; $i < @lines; $i++) {
+		if ($lines[$i] =~ /^\s*visual id:\s+$defaultVisualId$/) {
+		    if (($lines[$i+1] !~ /TrueColor/) ||
+			($lines[$i+2] !~ /depth/) ||
+			($lines[$i+4] !~ /red, green, blue masks/))
+		    {
+			return;
+		    }
+		    last;
+		}
+	    }
+
+	    return if ($i >= @lines);
+
+	    ($opt{'-depth'}) = ($lines[$i+2] =~ /depth:\s+(\d+)/);
+	    ($red,$green,$blue)
+		= ($lines[$i+4]
+		   =~ /masks:\s+0x([0-9a-f]+), 0x([0-9a-f]+), 0x([0-9a-f]+)/);
+
+	    $red = hex($red);
+	    $green = hex($green);
+	    $blue = hex($blue);
+
+	    if ($red > $blue) {
+		$red = int(log($red) / log(2)) - int(log($green) / log(2));
+		$green = int(log($green) / log(2)) - int(log($blue) / log(2));
+		$blue = int(log($blue) / log(2)) + 1;
+		$opt{'-pixelformat'} = "rgb$red$green$blue";
+	    } else {
+		$blue = int(log($blue) / log(2)) - int(log($green) / log(2));
+		$green = int(log($green) / log(2)) - int(log($red) / log(2));
+		$red = int(log($red) / log(2)) + 1;
+		$opt{'-pixelformat'} = "bgr$blue$green$red";
+	    }
+	}
+    }
+}
+
+
+#
+# quotedString returns a string which yields the original string when parsed
+# by a shell.
+#
+
+sub quotedString
+{
+    local ($in) = @_;
+
+    $in =~ s/\'/\'\"\'\"\'/g;
+
+    return "'$in'";
+}
+
+
+#
+# removeSlashes turns slashes into underscores for use as a file name.
+#               turns also spaces and tabs into underscores (Marcus).
+#
+
+sub removeSlashes
+{
+    local ($in) = @_;
+
+    $in =~ s|[/ 	]|_|g;		# space and tab
+
+    return "$in";
+}
+
+
+#
+# Usage
+#
+
+sub Usage
+{
+    die("usage: $prog [:<number>] [-name <desktop-name>] [-depth <depth>]\n".
+	"                 [-geometry <width>x<height>]\n".
+	"                 [-pixelformat rgbNNN|bgrNNN]\n".
+	"                 <Xvnc-options>...\n".
+        "       $prog [-clean] -kill :<number>\n");
+}
+
+
+#
+# Kill
+#
+
+sub Kill
+{
+    my $display = $_[0];
+    
+
+
+    $pidFile = "$vncUserDir/$host$display.pid";
+
+    if (! -r $pidFile) {
+        die "\nCan't find file $vncUserDir/$host$display.pid\n".
+            "You'll have to kill the Xvnc process manually\n\n";
+    }
+
+    $SIG{'HUP'} = 'IGNORE';
+    chop($pid = `cat $pidFile`);
+    warn "Killing Xvnc process ID $pid\n";
+    kill SIGTERM, $pid;
+    unlink $pidFile;
+
+    ## If option -clean is given, also remove the logfile
+    unlink "$vncUserDir/$host$display.log" if ($opt{'-clean'});
+
+    exit;
+}
+
+#
+# ParseOptions takes a list of possible options and a boolean indicating
+# whether the option has a value following, and sets up an associative array
+# %opt of the values of the options given on the command line. It removes all
+# the arguments it uses from @ARGV and returns them in @optArgs.
+#
+
+sub ParseOptions
+{
+    local (@optval) = @_;
+    local ($opt, @opts, %valFollows, @newargs);
+
+    while (@optval) {
+	$opt = shift(@optval);
+	push(@opts,$opt);
+	$valFollows{$opt} = shift(@optval);
+    }
+
+    @optArgs = ();
+
+    arg: while (($arg = shift(@ARGV)) ne "") {
+	foreach $opt (@opts) {
+	    if ($arg eq $opt) {
+		push(@optArgs, $arg);
+		if ($valFollows{$opt}) {
+		    if (@ARGV == 0) {
+			&Usage();
+		    }
+		    $opt{$opt} = shift(@ARGV);
+		    push(@optArgs, $opt{$opt});
+		} else {
+		    $opt{$opt} = 1;
+		}
+		next arg;
+	    }
+	}
+	push(@newargs,$arg);
+    }
+
+    @ARGV = @newargs;
+}
+
+
+#
+# Routine to make sure we're operating in a sane environment.
+#
+
+sub SanityCheck
+{
+    local ($cmd);
+
+    #
+    # Get the program name
+    #
+
+    ($prog) = ($0 =~ m|([^/]+)$|);
+
+    #
+    # Check we have all the commands we'll need on the path.
+    #
+
+ cmd:
+    foreach $cmd ("uname","xauth","Xvnc","vncpasswd") {
+	for (split(/:/,$ENV{PATH})) {
+	    if (-x "$_/$cmd") {
+		next cmd;
+	    }
+	}
+	die "$prog: couldn't find \"$cmd\" on your PATH.\n";
+    }
+
+    #
+    # Check the HOME environment variable is set
+    #
+
+    if (!defined($ENV{HOME})) {
+	die "$prog: The HOME environment variable is not set.\n";
+    }
+
+    #
+    # Check for socket constants and attempt to define suitable defaults
+    #
+
+    chop($os = `uname`);
+    chop($osrev = `name -r`);
+
+    use Socket;
+    if ($@) {
+	if (($os eq "SunOS") && ($osrev !~ /^4/)) {
+	    $AF_INET = 2;
+	    $SOCK_STREAM = 2;
+	} else {
+	    $AF_INET = 2;
+	    $SOCK_STREAM = 1;
+	}
+    } else {
+	$AF_INET = &AF_INET;
+	$SOCK_STREAM = &SOCK_STREAM;
+    }
+}
--- vnc-3.3.7.orig/debian/libvncauth0.dirs
+++ vnc-3.3.7/debian/libvncauth0.dirs
@@ -0,0 +1 @@
+usr/lib
--- vnc-3.3.7.orig/debian/xvncviewer.postinst
+++ vnc-3.3.7/debian/xvncviewer.postinst
@@ -0,0 +1,18 @@
+#!/bin/sh -e
+
+if [ "$1" = "configure" ]; then
+    MAN=/usr/share/man/man1
+    BIN=/usr/bin
+    update-alternatives --install \
+	$BIN/vncviewer       vncviewer       $BIN/xrealvncviewer 70 \
+	--slave \
+	$MAN/vncviewer.1.gz  vncviewer.1.gz  $MAN/xrealvncviewer.1.gz \
+	--slave \
+	$MAN/xvncviewer.1.gz xvncviewer.1.gz $MAN/xrealvncviewer.1.gz \
+	--slave \
+	$BIN/xvncviewer      xvncviewer      $BIN/xrealvncviewer
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/vncserver.dirs
+++ vnc-3.3.7/debian/vncserver.dirs
@@ -0,0 +1,3 @@
+usr/bin
+usr/share/man/man1
+usr/share/vncserver
--- vnc-3.3.7.orig/debian/vncserver.docs
+++ vnc-3.3.7/debian/vncserver.docs
@@ -0,0 +1 @@
+debian/README.inetd
--- vnc-3.3.7.orig/debian/vncviewer
+++ vnc-3.3.7/debian/vncviewer
@@ -0,0 +1,18 @@
+#!/bin/sh
+xvncviewer=`which xvncviewer`
+svncviewer=`which svncviewer`
+if [ -n "$DISPLAY" ]; then
+	if [ $xvncviewer ]; then 
+		$xvncviewer "$@"
+	else
+		echo $0: unable to execute xvncviewer
+		exit 0
+	fi
+else
+	if [ $svncviewer ]; then 
+		svncviewer "$@"
+	else
+		echo $0: unable to execute svncviewer
+		exit 0
+	fi
+fi
--- vnc-3.3.7.orig/debian/changelog
+++ vnc-3.3.7/debian/changelog
@@ -0,0 +1,590 @@
+vnc (3.3.7-3.backports.org.1) unstable; urgency=low
+
+  * recompiled for http://www.backports.org/
+
+ -- Norbert Tretkowski <tretkowski@inittab.de>  Mon, 16 Aug 2004 15:33:42 +0200
+
+vnc (3.3.7-4) unstable; urgency=low
+
+  * Problems with ipv6 support and vncserver. Applying patch from
+    'J.H.M. Dassen (Ray)' <fsmla@xinara.org> that make it revert to ipv4
+    if ipv6 do not work, closes: #265674.
+    Had to modify it some in order to make it compile and also to make
+    it work (probably) if AF_INET6 is not defined.
+
+ -- Ola Lundqvist <opal@debian.org>  Sat, 14 Aug 2004 19:11:39 +0200
+
+vnc (3.3.7-3) unstable; urgency=low
+
+  * Applied patch with ipv6 support, closes: #182085. Thanks to Robert
+    Bihlmeyer <robbe@orcus.priv.at> for that patch.
+  * Applied patch for vncserver manpage, closes: #208781.
+    Thanks to Martin Pool <mbp@sourcefrog.net>.
+  * Fix cutbuffer bug, closes: #214208.
+    Thanks to Jayen Ashar <jashar@picard.res.cmu.edu> for the workaround.
+  * Fixed so that /usr/share/man/man1/vncpasswd.real.1x.gz will not be a
+    dangling symlink, closes: #264748.
+  * Fixed so that it do not hog 100% cpu when xfs is restarted,
+    closes: #176562.
+    Thanks to Martin Koegler <e9925248@stud4.tuwien.ac.at> for the patch.
+  * Added -once and -startup option, closes: #222644.
+    Thanks to Steve Fosdick <dbugs@pelvoux.nildram.co.uk> for the patch.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 13 Aug 2004 09:38:32 +0200
+
+vnc (3.3.7-2) unstable; urgency=low
+
+  * Made vncpasswd using update-alternatives, in order to comply with
+    vnc4-common.
+  * Applied patch from Andreas Jochens <aj@andaco.de> to add amd64
+    support, closes: #254783.
+  * Fixed Xvnc manpage issue with update-alternatives,
+    closes: #227570, #244311. Thanks to Laurent.Bonnaud@inpg.fr for the fix.
+  * Applied patch from Roderick Schertler <roderick@argon.org> that fix
+    a path issue in vncpasswd, closes: #231282.
+  * Updated standards version to 3.6.1.
+
+ -- Ola Lundqvist <opal@debian.org>  Sun,  8 Aug 2004 21:28:16 +0200
+
+vnc (3.3.7-1) unstable; urgency=low
+
+  * New upstream version, closes: #199745.
+  * Fixed description so it is not so confusing about xserver,
+    closes: #192584.
+  * Fixed wrong display using patch from:
+    closes: #195376, #171697, #174463.
+  * Added dependency on perl-modules in vnc-common, closes: #182002.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 18 Jul 2003 16:23:55 +0200
+
+vnc (3.3.6-4) unstable; urgency=low
+
+  * Important security update regarding X cookies.
+  * Fixed menu issue, closes: #174522.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon, 27 Jan 2003 10:30:05 +0100
+
+vnc (3.3.6-3) unstable; urgency=low
+
+  * Added patch from William Thompson <wt@electro-mechanical.com> that
+    outputs an passwd dialog if no atty, closes: #145565, #173355.
+  * Added patch from Martin Koegler <e9925248@stud4.tuwien.ac.at> that
+    fixes font path issues, closes: #161358.
+
+ -- Ola Lundqvist <opal@debian.org>  Thu, 19 Dec 2002 08:49:26 +0100
+
+vnc (3.3.6-2) unstable; urgency=low
+
+  * Fix to make sure that the right server is started if tightvncserver
+    is installed used as the alternative.
+  * Xvnc now has a separate alternative.
+
+ -- Ola Lundqvist <opal@debian.org>  Wed, 11 Dec 2002 15:16:23 +0100
+
+vnc (3.3.6-1) unstable; urgency=low
+
+  * New upstream version.
+  * Removed some references to tightvnc from copyright.
+  * Removed build dep to jpeg library. Not needed because tightvnc
+    is no longer used in this package.
+  * Latest policy version 3.5.8 (no changes).
+  * Added perl dependencies for vncserver. I wonder why no one has
+    recognized this before (including myself).
+  * Moved vnc.conf to vnc-common (so that tightvnc can use it).
+  * Moved from /usr/X11R6/ to /usr.
+  * Started using alternatives for vncserver and vncclient.
+  * Started using some of the upstream manpages instead of the debian ones.
+  * Removed full stop from package descriptions.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon,  9 Dec 2002 12:38:04 +0100
+
+vnc (3.3.5-2) unstable; urgency=low
+
+  * Patched vnc to make the vncauth library. It just had moved to some
+    other place, closes: #168362.
+  * Removed build dependency on xlib6g-dev, closes: #170163.
+  * Fixed lintian error about shlibs information not generated correctly.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 22 Nov 2002 07:54:11 +0100
+
+vnc (3.3.5-1) unstable; urgency=low
+
+  * New upstream version, bugfix release.
+    Fix for "can no longer login problem",
+    closes: #167935, #168096, #168119.
+  * 256 color display problem fixed upstream as mentioned in #168063.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon, 11 Nov 2002 12:15:35 +0100
+
+vnc (3.3.4-1) unstable; urgency=low
+
+  * New upstream version. This is major build changes. It does for example
+    use automake/autoconf which hopefully will make some big changes to
+    the buildability. The big change to this version is that the tightvnc
+    patches is no longer used. The -via and -tunnel option is kept though.
+  * Major patch-splitting/merging work have been done and is available
+    in the debian/patches directory. All old patches (that have not been
+    fixed upstream) is kept, and sent to upstream. So even if this is a major
+    change (tightvnc->vnc) nobody should notice anything (I hope).
+  * Added some build dependencies that Kirk Madsen <madsenk@ieee.org> noticed.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon, 28 Oct 2002 08:57:57 +0100
+
+vnc (3.3.3r2-21) unstable; urgency=low
+
+  * Applied sh build patch, closes: #157385.
+    Thanks a lot to ISHIKAWA Mutsumi <ishikawa@linux.or.jp> for
+    providing the patch.
+  * Fix DoS problem in http server, closes: #143857.
+    Thanks to Tim Waugh <twaugh@redhat.com> for sending this patch to
+    the vnc mailinglist.
+  * Fixed allocation bug, closes: #152733.
+    Thanks to Herbert Thielen <HThielen@lucent.com> for the patch.
+  * Fixed minor warning bug, closes: #153012.
+    Thanks to Herbert Thielen <HThielen@lucent.com> for the patch.
+  * Call of rand instead of srand in vncserver wrapper, closes: #153877.
+    Thanks to Matthew Astley <mca-debbts@grantadesign.com> for the info.
+  * Fix passwd.real problem, closes: #152732.
+    Thanks to Herbert Thielen <HThielen@lucent.com> for the patch.
+  * Fixed vnc.conf manpage, closes: #162040.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 11 Oct 2002 07:29:34 +0200
+
+vnc (3.3.3r2-20) unstable; urgency=high
+
+  * Fixed s390 signed char problem, closes: #143425.
+  * Fixes copyright file.
+
+ -- Ola Lundqvist <opal@debian.org>  Thu, 18 Apr 2002 19:05:28 +0200
+
+vnc (3.3.3r2-19) unstable; urgency=low
+
+  * Fixed spelling issue, closes: #133371.
+  * Added README.inetd, written by John Lines <john@paladin.demon.co.uk>,
+    closes: #139164.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon,  8 Apr 2002 20:58:52 +0200
+
+vnc (3.3.3r2-18) unstable; urgency=low
+
+  * Fixing wrapper problems, closes: #127043, #134554.
+
+ -- Ola Lundqvist <opal@debian.org>  Sun,  7 Apr 2002 21:14:33 +0200
+
+vnc (3.3.3r2-17) unstable; urgency=low
+
+  * MU upload with the patch (last changelogentry) added, and with
+    some more fixes from Jones to make it work fine, closes: #114343.
+  * Now removes /etc/alternatives/xvncviewer if it exists
+    and is a dangling symlink, closes: #127043.
+  * Added a patch manually from Chris Tillman <tillman@azstarnet.com>,
+    had to fix it some because of the other patches, closes: #126974.
+  * Added a security patch from Oryn <oryn@fsck.tv>, closes: #128096.
+  * Fixed the xvncviewer man page, vncconnect is already in vncserver,
+    closes: #128569.
+  * Fixed vncconnect manpage, closes: #127555.
+  * Updated TODO.
+  * Added next tightvnc patch, no patch needed for java source because
+    nothing have changed there. This is just minor bug fixes,
+    closes: #126394.
+
+ -- Ola Lundqvist <opal@debian.org>  Wed, 16 Jan 2002 14:03:43 +0100
+
+vnc (3.3.3r2-16.1) unstable; urgency=low
+
+  * NMU
+  * Update Imake.cf, linux.cf, and makedepends (getline conflicted.)
+    Closes: #114343
+
+ -- LaMont Jones <lamont@debian.org>  Tue, 15 Jan 2002 22:57:20 -0700
+
+vnc (3.3.3r2-16) unstable; urgency=low
+
+  * More s390 fixes from Gerhard Tonn <GerhardTonn@swol.de>.
+  * Now includes vncconnect, closes: #115157.
+  * Now does not use wrapper for xvncviewer, closes: #125800.
+  * Fixed spelling error in libvncauth-dev, closes: #125067.
+
+ -- Ola Lundqvist <opal@debian.org>  Thu, 20 Dec 2001 15:51:37 +0100
+
+vnc (3.3.3r2-15) unstable; urgency=low
+
+  * Fixed build-dep problem, closes: #114343.
+  * No more use of installxaw, closes: #120229.
+  * Fixed author section of the manpage, closes: #122551.
+  * Added patch for s390 from Gerhard Tonn <GerhardTonn@swol.de>,
+    closes: #123806.
+  * Applied patch to work under gdm from Nick Phillips <nwp@lemon-
+    computing.com>, closes: #122561.
+  * Updated description to include note about TightVNC, closes: #114275.
+  * Really old bugs. No further reports. Probably fixed by now.
+    closes: #75599, #67409, #57325.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon, 17 Dec 2001 19:21:48 +0100
+
+vnc (3.3.3r2-14) unstable; urgency=low
+
+  * Fixed build problem, closes: #108419.
+  * Fixed another build problem, closes: #112953.
+  * Fixed path problem, thanks ijones@cis.ohio-state.edu for the patch
+    closes: #108333.
+  * Fixed passwd creation problem, thanks to
+    Isaac Jones <ijones@cis.ohio-state.edu> and Ohio State Opensource Club, 
+    closes: #110460.
+  * Documented the tightvnc options, closes: #105506.
+  * Fixed typo in description, closes: #109372.
+  * Applied the latest tightvnc patch, closes: #111886.
+
+ -- Ola Lundqvist <opal@debian.org>  Mon, 01 Oct 2001 10:47:24 +0200
+
+vnc (3.3.3r2-13) unstable; urgency=low
+
+  * Added build dependency on libjpeg62-dev, closes: #104300.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 13 Jul 2001 23:05:12 +0200
+
+vnc (3.3.3r2-12) unstable; urgency=low
+
+  * Fixed the manpage for xvncviewer with a updated one from
+    Terran Melconian <terran@consistent.org>, closes: #89469.
+  * Fixed dependency, closes: #96552.
+  * Applied a small patch from Isaac Jones
+    <ijones@syntax.cis.ohio-state.edu> that fixes error in the vncpasswd
+    wrapper so that the config files are actually used, closes: #99911.
+  * This should fix this woody bug too, closes: #100334.
+  * Added tight encoding, from http://www.ce.cctpu.edu.ru/vnc/download.html,
+    closes: #100172.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 2 Feb 2001 13:18:23 +0100
+
+vnc (3.3.3r2-11) unstable; urgency=low
+
+  * Added some more features to the server wrapper
+    (thanks to Jorge L. deLyra), closes: Bug#81670.
+
+ -- Ola Lundqvist <opal@debian.org>  Fri, 2 Feb 2001 13:18:23 +0100
+
+vnc (3.3.3r2-10) unstable; urgency=low
+
+  * Fixing typo in build dependency, closes: Bug#81297.
+  * Fix deferupdate problem (fix by John, jodaman@cegt201.bradley.edu),
+    closes: Bug#79792.
+  
+ -- Ola Lundqvist <opal@debian.org>  Fri, 5 Jan 2001 12:06:15 +0100
+
+vnc (3.3.3r2-9) unstable; urgency=low
+
+  * Fixing yet another build dependency, closes: Bug#80185.
+  
+ -- Ola Lundqvist <opal@debian.org>  Wed, 21 Dec 2000 11:08:21 +0100
+
+vnc (3.3.3r2-8) unstable; urgency=low
+
+  * Removed the java code from vncserver. It is not in a separate package
+    and are compiled separatly. A step in the right direction to handle 79759.
+  
+ -- Ola Lundqvist <opal@debian.org>  Wed, 19 Dec 2000 21:15:48 +0100
+
+vnc (3.3.3r2-7) unstable; urgency=low
+
+  * Fixed so that the http port can be specified and added that to the
+    documentation, closes: Bug#58350.
+  
+ -- Ola Lundqvist <opal@debian.org>  Wed, 13 Dec 2000 13:25:26 +0100
+
+vnc (3.3.3r2-6) unstable; urgency=low
+
+  * Applied patch from Rich Sahlender <rsahlen@debian.org>
+   and fixed it so that it applied cleanly, closes: Bug#74369.
+  
+ -- Ola Lundqvist <opal@debian.org>  Wed, 13 Dec 2000 13:25:26 +0100
+
+vnc (3.3.3r2-5) unstable; urgency=low
+
+  * Recompiled to get rid of xpm4.7 dependency, closes: Bug#78794.
+  
+ -- Ola Lundqvist <opal@debian.org>  Tue, 5 Dec 2000 09:14:11 +0100
+
+vnc (3.3.3r2-4) unstable; urgency=low
+
+  * Corrected some installissues in the new vnc-common packages.
+    - Added replaces, closes: Bug#77745, Bug#77811.
+    - Fixed .dhelp problem, problem with doc-base file,
+      closes: Bug#77759, Bug#77754.
+  * Fixed commented reference to Xsession in config, closes: Bug#77721.
+  * Misspelled changelog should be, closes: Bug#65700.
+  
+ -- Ola Lundqvist <opal@debian.org>  Thu, 23 Nov 2000 13:02:23 +0100
+
+vnc (3.3.3r2-3) unstable; urgency=low
+
+  * Recompiled without xlib6, closes: Bug#77501.
+    Thank you for the information about libc5.
+  * Fixed a man typo error in vncserver, closes: Bug#67920.
+  * Fixed garbled display on PowerPC,
+    thank you Kevin Puetz <puetzk@iastate.edu> for the patch,
+    closes: Bug#73022.
+  * Probably fixed in later version, closes: Bug#57706.
+  
+ -- Ola Lundqvist <opal@debian.org>  Sun, 19 Nov 2000 17:36:37 +0100
+
+vnc (3.3.3r2-2) unstable; urgency=low
+
+  * Fixed typo error in vnc.conf, closes: Bug#63557. 
+  * Created a vnc-common package, closes: Bug#65700.
+  
+ -- Ola Lundqvist <opal@debian.org>  Sun, 19 Nov 2000 17:36:37 +0100
+
+vnc (3.3.3r2-1) unstable; urgency=low
+
+  * Fixed so that it honors XAUTHORITY env variable, thanx to  Wolfram Gloger
+    <Wolfram.Gloger@dent.med.uni-muenchen.de> for the patch, closes: Bug#71440
+  * support XDM-AUTHORIZATION-1, thanx to Richard Kettlewell
+    <rjk@greenend.org.uk> for the patch, closes: Bug#69822
+  * Fixed the wrapper issue, closes: Bug#61074
+  * Fixed link in faq to point to the right place, closes: Bug#61224
+  * Fixed pre-depends problem, closes: Bug#63066, Bug#63080
+  * Changed to a new upstream version, that fixes some issues.
+  * Applied patch from Ian Jackson <iwj@ncipher.com> to cope
+    with 24bpp X servers, closes: Bug#76564
+  * App defaults moved to /etc/X11/app-defaults, closes: Bug#76699
+  
+ -- Ola Lundqvist <opal@debian.org>  Sat, 18 Nov 2000 20:40:48 +0100
+
+vnc (3.3.3-10) frozen unstable; urgency=low
+
+  * Thanks to Ben Collins for the NMU.
+  * Can now build on m68k thanks to a patch by Roman Hodek 
+    <Roman.Hodek@informatik.uni-erlangen.de> Closes: Bug#61168 (important).
+
+ -- Edward Betts <edward@debian.org>  Sun, 19 Mar 2000 13:23:52 +0000
+
+vnc (3.3.3-9.1) frozen unstable; urgency=low
+
+  * NMU
+  * Applied patch to imake config files, allows building on sparc, arm,
+    and probably fixes powerpc too, closes: #60529, #60532
+
+ -- Ben Collins <bcollins@debian.org>  Sat, 18 Mar 2000 08:14:28 -0700
+
+vnc (3.3.3-9) frozen unstable; urgency=low
+
+  * applied patch supplied by Jim Studt <jim@federated.com> to allow building
+    on ARM, closes: Bug#57838
+  * applied patch supplied by Bill Blunn <bill@tao-group.com> to support the
+    pixelformat option in the config file, closes: Bug#58338 
+
+ -- Edward Betts <edward@debian.org>  Thu, 24 Feb 2000 02:24:36 +0000
+
+vnc (3.3.3-8) frozen unstable; urgency=low
+
+  * debian/control: Build-Depends: s/zlib1g-dev/zlibg1-dev/ closes: Bug#56174
+  * debian/xvncviewer.xaw: added /usr/X11R6/lib/Xaw95 closes: Bug#55199
+
+ -- Edward Betts <edward@debian.org>  Fri, 28 Jan 2000 17:42:41 +0000
+
+vnc (3.3.3-7) unstable; urgency=low
+
+  * Xvnc/config/cf/vnclibs.def: single line changed to fix important bug:
+    #55277, filed by John Goerzen, `vnc: can't build from source'.
+  * debian/rules: added -Nlibvncauth-dev to dh_installchangelogs fixes
+    usr/share/doc/libvncauth0 -> usr/share/doc/libvncauth-dev symlink.
+
+ -- Edward Betts <edward@debian.org>  Sun, 16 Jan 2000 09:23:39 +0000
+
+vnc (3.3.3-6) unstable; urgency=low
+
+  * debian/libvncauth-dev.links: changed /usr/share/doc/libvncauth-dev to a
+        link to /usr/share/doc/libvncauth0
+  * debian/control: moved libvncauth0 from section x11 to libs and
+        libvncauth-dev from x11 to devel
+  * debian/control: updateded Standards-Version to 3.1.1
+  * debian/control: added Build-Depends.
+  * Xvnc/config/cf/vnc: modified so that Xvnc links with libvncauth.
+
+ -- Edward Betts <edward@debian.org>  Sun,  9 Jan 2000 07:58:23 +0000
+
+vnc (3.3.3-5) unstable; urgency=low
+
+  * Split svncviewer into seperate source package; both packages now have
+        pristine source.
+  * To handle source split, libvncauth is compiled as a shared library.
+  * debian/TODO: wrote a long Todo list and removed items as they were
+        completed, still some stuff left to do.
+  * debian/*.debian: renamed to debian/*.wrapper, make things a bit clearer.
+  * debian/*.dirs: removed the doc dirs, dh_installdocs creates them.
+  * debian/control: remove svncviewer.
+  * debian/control: add libvncauth0 and libvncauth-dev.
+  * debian/copyright: mention that I now maintain the package. 
+  * debian/copyright: change ORL to AT&T.
+  * debian/doc-base: added, for faq.html and start.html
+  * debian/docs: add start.html and start.txt
+  * debian/rules: simplifed build targets into one target.
+  * debian/rules: dh_compress + dh_link handle man pages instead of gzip + ln.
+  * debian/rules: install xvncviewer resources file.
+  * debian/rules: modifed find command to not erase Xvnc/Makefile on clean.
+  * debian/rules: remove the Xvnc/exports directory, and erase Xvnc/xmakefile, 
+        Xvnc/config/cf/host.def and Xvnc/config/imake/Makefile.proto on clean.
+  * debian/rules: create faq.txt and start.txt from faq.html and start.html in
+        the build target.
+  * debian/vnc.conf: changed location of java classes.
+  * debian/vncserver.wrapper: changed location of java classes. Fixes: #53506.
+  * debian/vncviewer: example script to run xvncviewer or svncviewer based on
+        $DISPLAY. If this is to go into /usr/bin it needs to have a man page 
+        and to be created in the postinst of xvncviewer and svncviewer. 
+        Fixes: #36594.
+  * debian/xvncviewer.README.Debian: removed, because it was unneeded. 
+  * debian/xvncviewer.menu: added menu item for xvncviewer. Fixes: #52921.
+  * libvncauth/Imakefile: extensive modification to build shared library.
+  * vncpasswd/Imakefile: modified to build against libvncauth shared library.
+  * vncviewer/Imakefile: modified to build against libvncauth shared library.
+
+ -- Edward Betts <edward@debian.org>  Tue, 28 Dec 1999 10:30:08 +0000
+
+vnc (3.3.3-4) unstable; urgency=low
+
+  * debian/xvncviewer.xaw: make xvncviewer use xaw-wrappers, fixes bug #50354.
+  * debian/control: vncserver needs the colour table file from xserver-common
+    so depend on xserver-common, thanks go to Jim Studt <jim@federated.com>
+    for spotting this one, fixes bug #33911 and half of bug #33910.
+  * debian/vncserver.debian: modification as suggested by previous
+    maintainer in bug #33910, fixes the other half of #33910.
+  * debian/vncserver.debian: added support for Xsession which is not
+    executable, thanks to journey@jps.net for spotting this one and the
+    implementation, fixes bug #51497.
+  * debian/rules & debian/vncserver.dirs: moved stuff out of /usr/X11R6/lib/ to
+    fix bug #33440, thanks go to Bernd Eckenfels <ecki@lina.inka.de> for
+    spotting this one.
+
+    vncpasswd.real -> /usr/X11R6/bin/ (vncpasswd modified, and man link added)
+    *.{class,jar}  -> /usr/share/vncserver (does anybody use these?)
+
+ -- Edward Betts <edward@debian.org>  Sun,  5 Dec 1999 17:18:06 +0000
+
+vvnc (3.3.3-3) unstable; urgency=low
+
+  * debian/rules: changed to debhelper
+  * FHS.
+  * Changed GPL location in copyright files
+  * Include source, as previous upload was accidently made without a diff
+  * There is no 3.3.3-2 because I messed up.
+
+ -- Edward Betts <edward@debian.org>  Sat,  6 Nov 1999 01:27:42 +0000
+
+vnc (3.3.3-1) unstable; urgency=low
+
+  * New upstream release.
+  * New maintainer.
+
+ -- Edward Betts <edward@debian.org>  Sat, 30 Oct 1999 19:57:42 +0100
+
+vnc (3.3.2r2-4) frozen unstable; urgency=low
+
+  * debian/vncserver.debian: Do not remove too many font pathes, that means,
+    check for :unscaled and font server.
+  * debian/control: Depend on xbase-clients, not xbase. closes: #33028, #32821.
+    The latter is an important bug and holding up the release of slink.
+  * debian/copyright.vnc: Update addresse of web page.
+
+ -- Marcus Brinkmann <brinkmd@debian.org>  Sun,  7 Feb 1999 23:35:19 +0100
+
+vnc (3.3.2r2-3) frozen unstable; urgency=low
+
+  * Bugfixes only. The memory leak (see below) make it worth to include it
+    in frozen.
+  * control (vncserver): Added dependency on xbase because xauth is used in
+    vncserver script (David Karlin) and fixed a small typo (lintian).
+  * Xvnc/programs/Xserver/hw/vnc/rfbserver.c: Fixed memory leak (#27624).
+  * Xvnc/config/cf/Imake.cf: Added Arm, Sparc, PowerPC architecture.
+    Xvnc/config/cf/linux.cf: Likewise.
+    (Tor Slettnes <tor@slett.net>, #29831 for Alpha and
+     Christian Meder <meder@isr.uni-stuttgart.de>, #30407 for Sparc,
+     Daniel Jacobowitz <drow@them.org>, #29833).
+  * Xvnc/programs/Xserver/cfb/stipsprc32.s: Additional Sparc changes (see above).
+    Xvnc/programs/Xserver/cfb/stipsparc.s: Likewise.
+  * debian/vncserver.debian: Remove invalid font pathes.
+    (Bruce A. Mah <bmah@CA.Sandia.GOV>, #21635)
+  * debian/vncserver.debian: Add '--help' and '-h' as alias for '-help'. (#26872)
+
+ -- Marcus Brinkmann <brinkmd@debian.org>  Sun, 27 Dec 1998 05:16:11 +0100
+
+vnc (3.3.2r2-2) unstable; urgency=low
+
+  * svncviewer.postinst: Changed suid-register 4775 to 4755. Fixes: #27228.
+
+ -- Marcus Brinkmann <brinkmd@debian.org>  Tue, 29 Sep 1998 22:13:12 +0200
+
+vnc (3.3.2r2-1) unstable; urgency=low
+
+  * New upstream release. Fixes: #26673.
+  * Fixed vncserver script one more time. Fixes: #25471, #26080, #26836.
+  * Added '-clean' option to vncserver and vncserver(1x)
+    (by Dirk Eddelbuettel). Fixes: #26871.
+  * Added Replaces: and Conflicts: vnc-doc to vncserver and xvnviewer.
+    Reason: vnc-doc is obsolete and should be removed from Debian (already
+    reported as a bug against ftp.debian.org). The documentation is out of
+    date and new documentation is included in the packages themselve.
+
+ -- Marcus Brinkmann <brinkmd@debian.org>  Thu, 24 Sep 1998 04:32:49 +0200
+
+vnc (3.3.2-1) unstable; urgency=low
+
+  * New upstream version, based on X11R6.3 source code:
+    + Now native support for gzip'd fonts.
+    + Fixed Keyboard handling (hopefully).
+  * Added (slightly modified) FAQ from the web site.
+
+ -- Marcus Brinkmann <brinkmd@debian.org>  Fri, 12 Jun 1998 22:54:15 +0200
+
+vnc (3.3.1-5) frozen unstable; urgency=low
+
+  * Now the cool configuration files will actually be parsed. Sorry for
+    this. Fixes: #21062.
+
+ -- Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>  Mon, 13 Apr 1998 19:51:18 +0200
+
+vnc (3.3.1-4) frozen unstable; urgency=low
+
+  * This should be in frozen. It fixes many bugs and violations of policy.
+    Indeed it is the first usable release of vnc.
+  * Added patch by Mark Spencer <markster@marko.net> to
+    support gzip'd fonts. xfs cludge no longer necessary.
+  * Removed rpath-link from upstream config file.
+  * Changed vncserver to parse config files in /etc/vnc.conf and ~/.vncrc.
+  * Changed vncpasswd to parse config files and get the default passwd file
+    location from there. Also made it verbose if file could not be written.
+  * Wrote six man pages. Please read them, I spent a lot of time on them.
+  * Changed rule files to make three packages, one server and two clients.
+      vncserver is now the X server.  
+      xvncviewer is now the client for X.
+      svncviewer is now the client for svgalib.
+
+ -- Marcus Brinkmann <Marcus.Brinkmann@ruhr-uni-bochum.de>  Sun, 15 Mar 1998 03:33:58 +0100
+
+vnc (3.3.1-3) unstable; urgency=low
+
+  * Move /usr/vnc to /usr/lib/vnc.
+  * Suggest vnc-doc.
+  * Clean up crud from experimental phase.
+
+ -- Christoph Lameter <clameter@debian.org>  Tue, 24 Feb 1998 16:05:10 -0800
+
+vnc (3.3.1-2) unstable; urgency=low
+
+  * Include description from slashdot on how to circumvent the font
+    compression problem using xfs. Move to unstable.
+
+ -- Christoph Lameter <clameter@debian.org>  Tue, 24 Feb 1998 07:00:14 -0800
+
+vnc (3.3.1-1) experimental; urgency=low
+
+  * Broken font handling. Both the binary from the upstream site and the
+    build sourcecode fail when setting the fontpath in the X server.
+    Thus experimental. Poked around but found no clue. If someone else
+    has time. HELP!
+
+ -- Christoph Lameter <clameter@debian.org>  Mon, 23 Feb 1998 15:00:26 -0800
+
+Local variables:
+mode: debian-changelog
+End:
--- vnc-3.3.7.orig/debian/vncpasswd.1x
+++ vnc-3.3.7/debian/vncpasswd.1x
@@ -0,0 +1,87 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for vncpasswd
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH vncpasswd 1 "March 16th, 1998" "3.3.1" "Virtual Network Computing X server"
+.SH NAME
+vncpasswd \- creating and changing password files to be used with VNC
+.SH SYNOPSIS
+.\" The general command line
+.B vncpasswd
+.RI [\| file \|]
+
+.SH DESCRIPTION
+.B vncpasswd
+should be used to create and change passwords for the
+.B Virtual Network Computing
+(VNC) server authentication.
+
+.SH EXAMPLES
+.TP \w'vncpasswd\ 'u
+.B vncpasswd
+Invoke vncpasswd and create or change the default password file.
+.TP
+.BI vncpasswd\ \| /tmp/foo
+Invoke vncpasswd and create or change the password in file
+.IR /tmp/foo .
+
+.SH OVERVIEW
+.B Xvnc
+is a free X server that can be used to display and control X sessions
+platform independent over the network. To connect to a VNC X server, the
+client viewer will request a password from the user. This password will be
+compared with the password in the file specified with the
+.I \-rfbauth
+option to the VNC server.
+
+The password has to be longer than five characters. Only the first eight
+characters are significant. If the password is too short or if the password
+file can't be opened for writing, the program will abort and exit with error
+code 1.
+
+.SH DEFAULTS
+.B vncpasswd
+without a command line argument will look for a
+.I $vncPasswdFile
+variable in
+.I /etc/vnc.conf
+and in
+.IR ~/.vncrc .
+If this is found, the password in the specified file will be changed.
+
+If not, the password file to be changed or created will default to
+.IR ~/.vnc/passwd .
+
+.SH OPTIONS
+.TP
+.I file
+The password file to create or change.
+
+.SH FILES
+.TP
+.IR /etc/vnc.conf ,\ \| ~/.vncrc
+This files will be scanned for $vncPasswdFile. The last occurence specifies
+the password file to create or change. If no variable with this name is
+found and no filename on the command line specified, the default name will
+be used (see above).
+
+.SH "SEE ALSO"
+.BR vncserver (1x), 
+.BR Xvnc (1x),
+.BR vnc.conf (5).
+
+.SH AUTHOR
+VNC developed at Olivetti Research Labs, Cambridge (now AT&T
+Laboratories, Cambridge) by Tristan Richardson, Ken Wood,
+James Weatherall, Andy Harter, Charlie McLachlan, Paul Webster,
+Quentin Stafford-Fraser and others.
+.BR
+This manpage written by Marcus Brinkmann for the Debian GNU/Linux
+distribution.
+.BR
--- vnc-3.3.7.orig/debian/vncserver.postinst
+++ vnc-3.3.7/debian/vncserver.postinst
@@ -0,0 +1,22 @@
+#!/bin/sh -e
+
+if [ "$1" = "configure" ]; then
+    MAN=/usr/share/man/man1
+    BIN=/usr/bin
+    update-alternatives --install \
+	$BIN/vncserver       vncserver       $BIN/realvncserver 70 \
+	--slave \
+	$MAN/vncserver.1.gz  vncserver.1.gz  $MAN/realvncserver.1x.gz \
+	--slave \
+	$BIN/vncconnect      vncconnect      $BIN/realvncconnect \
+	--slave \
+	$MAN/vncconnect.1.gz vncconnect.1.gz $MAN/realvncconnect.1.gz
+    update-alternatives --install \
+	$BIN/Xvnc            Xvnc            $BIN/Xrealvnc 70 \
+	--slave \
+	$MAN/Xvnc            Xvnc.1.gz       $MAN/Xrealvnc.1.gz
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/faq.html
+++ vnc-3.3.7/debian/faq.html
@@ -0,0 +1,812 @@
+<html>
+<head>
+
+   <meta name="keywords" content="VNC, AT&T Laboratories Cambridge, Virtual Network Computing, thin-client, FAQ">
+
+
+
+<title>
+
+VNC Frequently Asked Questions (FAQ)
+
+</title>
+
+</head>
+
+<body bgcolor="#FFFFFF" vlink="#000080" marginheight="0" topmargin="0" leftmargin="0" marginwidth="0">
+
+<center>
+
+<h1>
+
+Virtual Network Computing</h1></center>
+
+<hr>
+<h2>Note</h2>
+<p> This version was edited by 
+ <A HREF="mailto:edward@debian.org">Edward Betts</A> and <A HREF="mailto:opal@debian.org">Ola Lundqvist</A> for the Debian Operating 
+ System. The original version is available at the 
+ <a href="http://www.uk.research.att.com/vnc/faq.html">VNC Home Page (extern)</a>. </p>
+<hr>
+
+<H1>VNC Frequently Asked Questions (FAQ)</H1>
+
+
+
+This isn't intended to be an introduction to VNC - have a look at the <a href="start.html">Getting
+
+Started</a> page first.
+
+<p>This list is being updated regularly, so, particularly as you are reading
+
+a mirrored copy, it's worth checking <a href="http://www.uk.research.att.com/vnc/faq.html">the
+
+original</a> from time to time.  The <a href="http://www.uk.research.att.com/vnc/archives/">archives</a>
+
+of the <a href="http://www.uk.research.att.com/vnc/intouch.html">mailing list</a> are also available, and
+
+they can be a good source of help - try searching them <a href="http://www.uk.research.att.com/search.html">here</a>.</p>
+
+<p><b>Historical Note</b>:  With the release of 3.3.2 we have moved
+
+some of the old questions into the <a href="http://www.uk.research.att.com/vnc/oldfaq.html">Old FAQ page</a>
+
+because they should not apply to recent versions.  As with most software,
+
+it's worth checking to make sure you've got the lastest version.</p>
+
+
+
+
+
+<H1>VNC Frequently Asked Questions</H1>
+
+<H2>Getting Started</H2><DL>
+
+<DT> <B>
+Where can I get VNC?</B></DT>
+
+<DD>The latest versions of VNC and this documentation are
+always available from the AT&T Laboratories Cambridge web site at <a href="http://www.uk.research.att.com/vnc">http://www.uk.research.att.com/vnc</a>.
+In addition, various add-ons, extras, and ports to other platforms can
+be found on the <a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a> page.</DD>
+
+<DT> <B>
+I thought this was something to do with ORL? What's the Olivetti/Oracle
+link here?</B></DT>
+
+<DD>In January 1999, <a href="http://www.att.com/">AT&T</a>
+acquired ORL, the Olivetti Research Laboratory founded 12 years earlier,
+and recently jointly funded by <a href="http://www.oracle.com">Oracle</a>,
+to create AT&T Laboratories Cambridge. </DD>
+<DT> <B>
+I started the X server using vncserver, but it dies with a message "Could
+not open default font 'fixed'. "</B></DT>
+
+<DD>The 'fixed' font is needed for the server to start
+- if it can't find it, you need to specify the correct font path for your
+machine in the 'vncserver' script.  If you're not sure what the path
+should be, type 'xset q'  from within a normal X session. One of the
+things reported is the font path used by your current X server, which is
+generally the right thing to use for Xvnc.  On some platforms you
+may need to use a colon as a separator in the font path instead of a comma.
+If you're on a recent version of Linux but still using VNC version 3.3.1,
+you may have compressed fonts which VNC doesn't understand. Either upgrade
+or see the <a href="http://www.uk.research.att.com/vnc/oldfaq.html">Old FAQ</a>.</DD>
+
+<DD>The VNC server can also get upset if you have directories on
+your font path which don't actually exist on your system.  Make sure
+you remove those. Also note that older versions of the Xvnc server, by
+default, act as if they had a resolution of 100dpi.  Some RedHat
+installations, for example, only install 75dpi fonts, so you may need
+to install the missing font RPMs from your distribution or use the
+-dpi option to Xvnc, or update to the latest version. </DD>
+
+<DT> <B>I get errors like "failed to bind listener" and "Failed to establish
+all listening sockets" in the log file.</B></DT>
+
+<DD>This is probably due to the permissions on /tmp/.X11-unix.
+You may well see this if you update to Solaris 2.7 or Redhat 6.0, for
+example. See the section below entitled "Why can I only run
+vncserver/Xvnc as root?".</DD>
+
+<DT> <B>Vncserver seems to be dying quietly without putting any messages in
+the log file.</B></DT>
+
+<DD>Check that the Xvnc process really has died. If so, then check
+that your VNC font path (set by uncommenting lines in the vncserver
+script) only includes directories which actually exist.  The XFree86
+code in older versions of Xvnc seems to have a problem which causes
+the server to die quietly if non-existent directories are
+searched. Upgrading to 3.3.3 or later should reduce these
+problems.</DD>
+<DT> <B>
+ I connected to my Unix VNC server and I just see a grey desktop with
+a cursor.</B></DT>
+
+<DD>After the vncserver script has started the Xvnc server,
+it then runs your ~/.vnc/xstartup script.  By default this will try
+to start the twm window manager, but if twm isn't on your path, or if you
+prefer something else, you can edit xstartup.  The log file may also
+give you clues about what is happening.</DD>
+
+<DT> <B>
+The log file is showing an error message from xrdb / Xlib.</B></DT>
+
+<DD>By default, the first thing your xstartup script does
+is to run xrdb to load your resources.  So if the Xvnc server has
+not started for any reason, the xrdb is often the first thing to notice
+it and print an error.  (Though if you're getting a 'command not found'
+message, then xrdb is probably not on your path - you need to find where
+it is on your system and add it.)</DD>
+
+<DD>If you get something like 'connection refused' or 'Can't
+connect: errno = 111', the Xvnc server probably isn't there.  So you
+should check whether the Xvnc process is actually running, and whether
+there is anything earlier in the log file indicating why it might have
+died.  By far the most common reason for the server not starting is
+that it can't find the 'fixed' font (see above). Other possibilities are
+that the server has quietly crashed, or that it is taking a very long time
+to start up.  The vncserver script has a 3-second delay before running
+xstartup, but in extreme cases this may not be enough.  Lastly, the
+DISPLAY variable used by vncserver is based on the results given by the
+'uname - n' command. If your applications cannot resolve this to the right
+IP address, perhaps because of funny settings in /etc/hosts, then they
+won't be able to connect. </DD>
+
+<DD>If you get a 'Client is not authorized to connect to
+Server' or similar message, there's something wrong with the X authority
+setup - perhaps xauth is not on your path? You could try using xhost to
+bypass this temporarily, but we wouldn't recomend this as a long-term solution. 
+There should be some indication in the log file if xauth has failed.</DD>
+
+<DT> <B>
+The Java client doesn't work in my browser.</B></DT>
+
+<DD>Several Java implementations have bugs which upset the VNC
+applet.  Try pressing Reload. We've seen this problem on Netscape
+Navigator 3 and Internet Explorer 5.  Note, too, that the Java applet
+often won't work if you are accessing the server via a web proxy. Make
+a direct connection if you can.
+</DD>
+
+<DT> <B>
+My viewer failed to connect to my server!</B></DT>
+
+<DD>VNC relies on a correctly-configured and operational
+TCP/IP network, so please make 100% sure that your TCP/IP setup is right
+before you start asking questions on the mailing list.  Here are some
+things you should check before assuming it's a VNC problem; consult your
+local expert if you don't know how to check them:
+
+<ul>
+<li>
+Can you ping the server machine from the client?</li>
+
+<li>
+Is the VNC server definitely running on the server machine?</li>
+
+<li>
+The server listens on port 5900+displaynumber. Can you telnet to this port
+from the client machine?</li>
+
+<li>
+Have you specified the address correctly to the viewer? If you're using a display number other than zero for the server, (usually the case on Unix machines), did you remember to specify it?</li>
+
+<li>
+Is the server name known to the DNS?  Try using an explicit IP address
+instead of a name (eg. 123.456.78.9:0 instead of snoopy:0).</li>
+
+<li>
+Do you have any firewalls or proxies in the way that could be blocking
+acess?</li>
+
+<li>
+If using the java client, did you remember to specify the correct port
+as part of the URL? (eg. <a href="http://snoopy:5800">http://snoopy:5800</a>)?</li>
+
+<li>
+Can you try running either the server, or the client, or both, on different
+machines on your network to find whether the problem is at one end or the
+other?</li>
+
+<li>
+Can you try running the software on a different architecture?  eg.,
+if you are  having problems viewing a PC from another PC, can you
+try connecting from a Unix machine?</li>
+</ul>
+
+</DD>
+
+</DL><HR>
+
+<H2>Running the programs</H2><DL>
+
+<DT> <B>My X VNC server is working, but I don't see my normal environment. How can I change the Window manager etc?</B></DT>
+
+<DD>The window manager is started by the ~/.vnc/xstartup script.  We use
+twm, as this is available on almost all Unix platforms.  Edit the
+script if you'd rather replace it with something else.  On many platforms
+you can, as an alternative, just make xstartup a link to whatever script
+normally starts your X environment.
+<br></br>If you want to be more sophisticated, you can specify the -name option
+to vncserver, and then take different actions in the xstartup script based
+on the name given. For example:
+<pre>case "$VNCDESKTOP" in
+kde)
+        startkde &
+        ;;
+*)
+        xterm -geometry 40x10+40+40 -ls -title "$VNCDESKTOP Desktop" &
+        twm &
+        ;;
+esac
+</pre>
+</DD>
+
+<DT> <B>
+Why can I only run vncserver/Xvnc as root?</B></DT>
+
+<DD>The most likely reason for this is that Xvnc can't
+create the unix domain socket (the path for this unix domain socket is
+usually /tmp/.X11-unix/Xn).  Try making sure that users can write
+to this directory by making it world-writable, i.e. <br></br>
+<tt>chmod 01777 /tmp/.X11-unix</tt><br></br> 
+An alternative is to set the Xvnc binary to have the same
+permissions as your normal X server, but this may be more of a security
+risk.</DD>
+
+<DT> <B>
+Can I remote the normal X display of my workstation (display :0) in
+the same way as the Windows server does?</B></DT>
+
+<DD>It would be possible to add VNC support to a standard
+X server, so that it operated this way, but we have no plans to do so. 
+It shouldn't be too difficult, if you have the full source code for your
+X server.  Xvnc is basically XFree86 with the hardware-dependent bits
+taken out and VNC put in their place, so it doesn't have drivers for any
+graphics cards. You could have a look at the Xvnc source code to see which
+bits have been added to the standard XFree86, and make the equivalent changes
+on <i>your</i> X server.
+<br></br>We tend to run all our X sessions as VNC sessions and only use the
+local X server to run the viewer.  It's very fast when on the same
+machine as the server! If you feel that it's overkill to run two X servers
+on the same machine, you might consider Ganesh Varadarajan's  svgalib-based
+viewer, available from the <a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a> page.</DD>
+
+<DT> <B>
+What X Visual does Xvnc use?</B></DT>
+
+<DD>By default, vncserver will start Xvnc with the same
+depth as the current X display, if there is one, or 8 bits deep if there
+isn't.  We've tried to steer clear of colour maps as much as possible
+and normally use "true colour", even when there are only 8 bits per pixel.</DD>
+
+<DD>Unfortunately some X applications don't cope too well
+with an 8 bit TrueColor visual.   You can make Xvnc use the more
+normal PseudoColor visual by giving a "-cc 3" option to vncserver.</DD>
+
+<DT> <B>
+Can I cut and paste between the viewer and the server?</B></DT>
+
+<DD>VNC supports copying and pasting of ASCII text in both
+directions, provided the viewer and server allow it.  When the clipboard
+changes on the machine running the viewer, the changes are copied to the
+server and vice versa.  Some notable exceptions:</DD>
+
+<ul>
+<li>
+X has more than one method of using the clipboard and different applications
+do it different ways. Emacs and xterm should just work. If you find that
+your X application doesn't work via VNC, you can generally use the
+<tt>xcutsel</tt>
+program to copy the clipboard between the different X methods.  VNC
+uses Cut_Buffer0, so if you select text in Unix Netscape, for example,
+you may need to click 'Copy PRIMARY to 0' before it is accessible at the
+other end of the VNC link.  You can use X resources to make the button labels more meaningful. For example, here's a script:
+<pre>
+#!/bin/sh
+exec xcutsel \
+	-xrm '*quit.borderWidth:0' \
+	-xrm '*quit.height: 1' \
+	-xrm '*quit.label:' \
+	-xrm '*sel-cut.label: Clipboard: out of netscape' \
+	-xrm '*cut-sel.label: Clipboard: into netscape' \
+        -xrm '*font: -*-helvetica-*-r-*-*-*-*-*-*-*-*-*-*'
+</pre>
+</li>
+
+<li>
+Java applets running in the browser cannot access the clipboard of the
+machine on which they are running, so the Java viewer has a clipboard button. 
+This pops up a window displaying the contents of the remote clipboard,
+which should allow you to manipulate it locally.</li>
+</ul>
+
+<DD>The code to do copying <i>from</i> the X server <i>to</i>
+the viewer didn't make it in the original version 3.3.2.  It's back
+in 3.3.2R2 and later, so upgrade if you haven't already!</DD>
+
+<DT> <B>
+There's a memory leak in Xvnc!</B></DT>
+
+<DD>This is fixed in versions 3.3.2r3 and later.   If you're using an older
+distribution you can find a patch for it <a href="http://www.uk.research.att.com/vnc/archives/1998-09/0160.html">here</a>.</DD>
+
+<br></br> 
+<DT> <B>
+Why doesn't Ctrl-Alt-Del work? Why can't I unlock my NT workstation remotely? Why can't I stop the screensaver remotely?</B></DT>
+
+<DD>Make sure you are running a recent version of VNC,
+<b>and
+that you are running it as a service</b>.  From some platforms you
+will not be able to type Ctrl-Alt-Del directly, because it will be caught
+by the local machine. The Windows viewer, for example, has an option on
+its menu to send a Ctrl-Alt-Del to the remote host. In some situations,
+you will find that something like Ctrl-Alt-Backspace or Ctrl-Alt-<Numeric
+keypad Del> may work instead. Screensavers sometimes use a different resolution
+and so can disconnect you when they stop or start - see the next question.</DD>
+
+<DT> <B>When I connect using VNC and then log into my Windows
+machine, I get disconnected and have to reconnect!</B></DT>
+
+<DD>Sometimes logging in will involve a change in screen
+resolution, if the user's display settings are different from the
+defaults. If this happens, the server will disconnect you and you will
+need to reconnect to get the new screen size. Just occasionally on NT,
+the mode seems to change resolution temporarily as you log in, and if
+WinVNC happens to see this you can also be disconnected, even if the
+final resolution changes.  
+<br></br>If the user has set a different
+display number in their personal WinVNC properties dialog you will
+also be disconnected.</DD>
+
+<DT> <B>The dead keys don't work on my keyboard</B></DT>
+
+<DD>It's quite a challenge working out how to do international
+keyboard support across different platforms.  We'll sort out dead
+keys, but if you'd like to work out how to do them, we'd be
+grateful.</DD>
+
+<DT> <B>The keyboard doesn't work / keys do strange things!</B></DT>
+
+<DD>There is one common problem which can cause this. 
+If a modifier key, such as Shift, Ctrl or Alt, is pressed, and the viewer
+window then loses focus or dies, the 'key release' message never gets to
+the viewer and hence never gets to the remote server.   The remote
+machine will then think that M is Ctrl-M etc.  We have done various
+things to reduce the chance of this happening; the viewers release various
+modifiers automatically when they lose focus, for example, but it can still
+occur and can be confusing when it does.  The solution is easy: simply
+press and release the modifier key which is stuck.  If you don't know
+which it is, then try them one at a time.</DD>
+
+<H2>General Questions</H2><DL>
+<DT> <B>
+How do I make VNC go faster?</B></DT>
+
+<DD>
+<p>We find VNC to be perfectly acceptable as our normal method of
+accessing Unix desktops on a daily basis.  This is over a 10 Mbit/s
+ethernet on reasonably modern machines, using the X or Win32 viewer.
+Because Windows gives us fewer hints about what it's doing, and
+because we don't have the source code for Windows in the same way that
+we do for X, the WinVNC server has to work harder to find out what's
+changed, and so a really fast machine should make a big speed
+difference.  For more information about how the Windows server works,
+see the <a href="http://www.uk.research.att.com/vnc/winvnc.html">WinVNC documentation</a>.  But if you've
+been disappointed by the speed of the Windows server, don't give up.
+We're improving it gradually, but it'll be a while before it's as fast
+as on Unix. </p>
+
+<p>There are several things that can slow any VNC session
+down, however, and you may like to consider these if you find it too slow:</p>
+
+<ul> 
+<li>
+Unusually 'busy' desktops.  The VNC protocol is very efficient at
+rendering areas of a single colour, such as you generally find on window
+title bars, scrollbars, backgrounds of pages etc. But if, for example,
+you have pretty 24-bit photographs of your girlfriend as your screen background,
+or dithered title-bars on your windows, you may pay a price for the aesthetics.
+<b>A
+colourful or patterned desktop background will probably slow down VNC more
+than any other single factor.</b> We have some suggestions on
+<a href="http://www.uk.research.att.com/vnc/twmideas.html">speeding
+up the twm window manager</a>, some of which will also apply to other environments.</li>
+
+<li>
+Hi-colour desktops.   Don't use 24-bit colour if you can use
+16 or 8 equally well. Remember, on Unix you can run multiple servers, so
+I have a big 16-bit desktop for normal work and a small 8-bit one for when
+I log in from home.  The server can send out a wide range of pixel
+formats, and some viewers will allow you to request a specific format for
+that session. On the Windows viewer, for example, if you click Options...
+when making the connection, you can request only 8-bit pixels from the
+server - useful if the network gets slow.  If you are using a modem,
+I recommend changing the shortcut in the Start menu to include the /8bit
+option - this will then be the default.  Similarly, if you regularly
+connect to a remote WinVNC server, consider whether you could run happily
+at lower resolution. A 1280x1024 screen has more then 4 times as many pixels
+as a 640x480 one, and if all you are doing is checking a printer queue
+you probably don't need them all! Note, though, that on WinVNC, 16-bit
+colour is usually the best to use. See below.</li>
+
+<li>
+Elderly graphics cards or drivers may make quite a difference; this is
+a graphics-intensive application!  On Windows the graphics system
+on the server will affect the speed as well as the one on the viewer.</li>
+
+<li>
+Some applications are not very economical about redrawing their display. 
+Early versions of Unix Netscape, for example, tended to draw everything
+twice when scrolling, which did nothing to help the smoothness under VNC.
+X11Amp flashes its display very fast when in 'pause' mode.</li>
+
+<li>
+Some Java Virtual Machines are particularly fast at reading from the network
+and particularly slow at drawing to the screen, or vice versa.  With
+the Java viewer it is worth experimenting with the encodings available
+from the Options menu, as we sometimes find big differences in speed.</li>
+
+<li>
+If you are connecting to WinVNC, don't change the default settings in the
+Properties box unless you need to.</li>
+
+<li>
+All the standard clients can do local rectangle copying, and this generally
+means that dragging a full window on X is much faster than dragging its
+outline.  If your window manager allows this, it may speed things
+up.   Roman Mitnitski also reports that when he increased the
+mouse dragging threshold (-t option of the server) the performance was
+improved.</li>
+
+<li>
+Generally, with WinVNC, use 16-bit colour (65536 colours) on the server
+if you can. 16-bit is <i>almost</i> always the best depth to use, because:</li>
+
+<ol>
+<li>
+256-colour screens have to be palette-converted before they can be transmitted
+to truecolour clients. Only if the client is 256-colour palette- based
+will you see any performance increase. Even if the client is 256 colour
+truecolour, it'll have to convert via a 32-bit truecolour palette!</li>
+
+<li>
+24-bit screens have to be specially munged via 32-bit since VNC's internal
+colour-handling routines don't work with 24-bit directly.</li>
+
+<li>
+24 and 32-bit screens have to have each pixel looked up in three tables
+to get the converted value.</li>
+
+<li>
+Graphics cards claiming to do 24-bit often actually do 32-bit with munging
+- this in many cases makes 24-bit slower just for general use than 32-bit!</li>
+
+<li>
+Finally, 16-bit involves no palette processing and a single lookup in a
+cached src_format to dest_format table to convert the pixels.</li>
+</ol>
+</ul>
+On slow links, you may also want to use some software to compress the data
+between the two ends. SSH is good for this. See the section on security
+below. 
+</DD>
+
+<DT> <B>Will VNC work through a firewall?</B></DT>
+
+<DD>It depends on your firewall, and whether you want to
+access a server inside your firewall from elsewhere, or a server outside
+your firewall from inside.</DD>
+
+<DD>Generally firewalls are designed to prevent incoming
+connections except to certain well-known machines and ports.  If you
+can configure these to include your VNC server, then you will be able to
+access it from anywhere in the world.  There is a good argument to
+be made for the fact that VNC is less of a security risk than X, so if
+your site doesn't allow X in or out it may still allow VNC. </DD>
+
+<DD>Many modern firewalls will allow outgoing connections
+initiated from inside, so you can often access servers on outside machines. 
+It is straightforward, for example, to recompile the viewer source to include
+SOCKS support, or to make other special arrangements. See the <a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a>
+page. </DD>
+
+<DD>It's a pity that Java within a browser doesn't automatically
+use SOCKS if the browser is configured to use it.  There's probably
+Java SOCKS support out there somewhere... </DD>
+
+<DD>If your internet access is through a router which does
+Network Address Translation, you may be able to configure the router to
+redirect particular incoming ports to particular machines. So you could
+run WinVNC with a display number of 0 on machine snoopy, and with display
+1 on machine woodstock, then set your router to send port 5900 to snoopy
+and 5901 to woodstock.  See below for information on the other port
+numbers used by VNC.</DD>
+
+<DT> <B>
+Which TCP/IP ports does VNC use?</B></DT>
+
+<DD>A VNC server listens on two ports. The exact port numbers
+depend on the VNC display number, because a single machine may run multiple
+servers. The most important one is 59xx, where xx is the display number. 
+The VNC protocol itself runs over this port. So for most PC servers, the
+port will be 5900, because they use display 0 by default.</DD>
+
+<DD>In addition, VNC servers normally have a small and
+very restricted web server built in, which allows you to connect a browser
+to them and use the Java viewer.  This runs on port 58xx.  Note
+that this is the HTTP port used for downloading pages and applets, but
+once the applet is running it uses 59xx for VNC just like any other viewer. </DD>
+
+<DD>The servers can be changed to listen on other ports
+if, for any reason, these are not suitable for you.  See the server's
+<a href="http://www.uk.research.att.com/vnc/docs.html">documentation</a>
+for more details.  Most of the viewers, if given a display number
+larger than 99, will interpret it as a direct port number and will not
+add 5900. See also the next question.</DD>
+
+<DD>If you are running a viewer in 'listening' mode, where
+it accepts connections initiated by the server, it will listen for incoming
+VNC on port 5500. </DD>
+
+<DT> <B>Can I run VNC over a port normally used for a standard service? (eg. port 21, or port 80)</B></DT>
+
+<DD>In rare circumstances, people may want to do this, perhaps because they have a firewall which only allows connections to certain ports. This can be done, at least for the Windows and Unix servers (see their <a href="http://www.uk.research.att.com/vnc/docs.html">documentation</a>), but the following points need to be borne in mind:
+<ul>
+
+<li>On some systems (eg. most forms of Unix), ordinary users are not
+allowed to run servers on ports below 1024.</li>
+
+<li>You obviously can't run a VNC server on a port that's already
+being used for other things.</li>
+
+<li>Many VNC servers use two ports: one for the VNC server, and one
+for the HTTP server that provides the Java applet (see previous
+question). If you plan to use the Java viewer, you may want to change
+both. Not all servers will allow this at present.</li>
+
+<li>You need to tell the viewer the right display number. Normally,
+display numbers come between 0 and 99. If you specify any number
+smaller than 99, the viewers add 5900 to get the port number. If you
+specify a larger number, the viewers take it as a port number
+directly. So how do you use port numbers lower than 99? You have to
+specify a negative display number!  For example, to connect to a
+server running on port 80 on machine 'snoopy':<br></br>
+
+	<tt> vncviewer snoopy:-5820 </tt><br></br>
+
+because -5820 + 5900 = 80. This may not work with all viewers, but Unix and Windows seem to be fine.
+</li>
+</ul> </DD>
+
+<DT> <B>
+How secure is VNC?</B></DT>
+
+<DD>Access to your VNC desktop generally allows access
+to your whole environment, so security is obviously important. VNC uses
+a challenge-response password scheme to make the initial connection: the
+server sends a random series of bytes, which are encrypted using the password
+typed in, and then returned to the server, which checks them against the
+'right' answer. After that the data is unencrypted and could, in theory,
+be watched by other malicious users, though it's a bit harder to snoop
+a VNC session than, say, a telnet, rlogin, or X session.  Since VNC
+runs over a simple single TCP/IP socket, it is easy to add support for
+SSL or some other encryption scheme if this is important to you, or to
+tunnel it through something like SSH.  
+<p>SSH allows you to redirect remote TCP/IP ports so that all
+traffic is strongly encrypted, and this can be combined with VNC.
+SSH can also compress the encrypted data - this can
+be very useful if using VNC over slow links. See the '<A HREF="http://www.uk.research.att.com/vnc/sshvnc.html">Using SSH with VNC</A>' page.</p>
+</DD>
+
+<DD>While we're on the subject of security, you should
+also be aware that only the first 8 characters of VNC passwords are significant. 
+This is because the 'getpass' call used in the Unix server to read a password
+has this restriction, and the other platforms have been made compatible
+with this. </DD>
+
+<DD> 
+Ray Jones &lt;<a href="mailto:rjones@pobox.com">rjones@pobox.com&gt;
+</a>has
+built a version of VNC which uses SSLeay public key encryption, and Wolfram
+Gloger &lt;<a href="mailto:wmglo@dent.med.uni-muenchen.de">wmglo@dent.med.uni-muenchen.de</a>&gt;
+has built Xvnc with the TCP Wrapper library, allowing you more control
+over which hosts are allowed to connect. See the <a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a>
+page for details.</DD>
+
+<DT> <B>Are you going to make it more secure?</B></DT>
+
+<DD>We do hope eventually to add better security to VNC, but
+there's also a good argument for <i>not</i> doing so.  If security is
+a concern, it can be better to use a single system such as SSH or
+FreeS/WAN to encrypt all your traffic, rather than relying on the
+individual packages to do the right thing.  Then, if you decide in a
+year's time that one system is too easily crackable, you can replace
+it yourself and all of your communications will benefit.  It may also
+be easier to fit in with corporate security systems this way.</DD>
+
+<DT> <B>Could you do file transfer (e.g. by drag & drop) between the two ends?</B></DT>
+
+<DD>
+<p>
+It's certainly possible, but we aren't going to do it.  File transfer
+seems simple, but is actually rather complicated to do in a cross-
+platform way.  Some examples: How do you map filenames between
+platforms with wildly different naming conventions? How do you cope
+with running out of disk space?  What about permissions?  How do you
+do it on platforms which don't have a concept of drag and drop? Can you interrupt the transfer if it's taking too long? Can you restart it if it gets interrupted?
+</p>
+
+<p>
+Since there are a very large number of perfectly good systems out
+there for transferring files over IP, we aren't planning to
+incorporate it in VNC.  It would probably more than double the size of
+the code, and would introduce all sorts of issues that we, quite
+frankly, aren't interested in! So use the standard file transfer built
+into Windows, or use FTP, or netcat, or the web, or rcp, or ssh, or...
+</p>
+</DD>
+ 
+<DT> <B>Are you planning support for AIX, EPOC,HP-UX, SGI, Win 3.1,
+or my favourite platform ?</B></DT>
+
+<DD>We have provided VNC on all the platforms we use here, and
+it's difficult to provide binaries for anything we don't have, and it
+takes a while to get up to speed on new platforms.  Information about
+third-party ports of VNC to a large number of other platforms can be
+found on the '<a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a>' page, so check
+there first. Remember that a viewer is available for any platform
+which runs Java, though the speed may vary quite a bit. But for many
+platforms it should not be difficult to compile at least the
+viewer. If anyone tailors the sources for a particular platform we
+will happily either incorporate the changes in the main source
+distributions or make the patches available from our site.  </DD>
+
+<DT> <B>
+Would things work better if you compressed the stream?</B></DT>
+
+<DD><p>VNC incorporates really quite efficient compression
+in the sense that we generally send a tiny fraction of the raw data, probably
+something like 1/20 on average. The details are in the protocol spec if
+anyone's interested.  On a couple of test screen dumps we found that
+the Hextile encoding was more efficient than GIF!  I don't know whether
+this is true in general. </p>
+
+<p>But we haven't done more general encoding after that;
+we've tended to the view that (a) it might introduce too much latency and
+(b) most modems compress pretty well anyway.   We are planning
+some zlib-compression experiments in the near future to see how this affects
+things. Because different bits of the screen can be sent using different
+encodings, the server could, in theory, detect that one bit would be most
+efficiently sent as JPEG, while another would be better hextiled. </p>
+
+<p>The question is always how much work it's worth doing
+at the server to find this out.  To some degree you can control this
+already, because the viewers allow you to specify your preferred encoding.
+Under X, if your viewer and server are on the same machine the viewer will
+use the raw encoding by default, otherwise it will use hextile.  You
+may find that by selecting different encodings on the command line you
+get better performance. </p>
+
+<p>See also the suggestions above about using ssh, which also
+provides compression.</p></DD>
+
+<DT> <B>
+Have you thought about caching bits of the screen at the viewer end?</B></DT>
+
+<DD>Yes, that could also be good. You could have an off-screen
+cache in the viewer and the server could copy things from there to the
+screen.  Management of this would add a certain amount of complexity,
+though. </DD>
+
+<DD>Since there is already a CopyRect primitive in VNC,
+an alternative approach would be to copy updates from another part of the
+screen if they already exist there, rather than resending them. Again,
+to make the server find out efficiently when this is worth doing would
+be an interesting challenge, and volunteers for the project are welcome! </DD>
+
+<DT> <B>
+Can I use VNC over a modem without using TCP/IP?</B></DT>
+
+<DD>Not at present. VNC could run over other transports such as
+RS232, firewire, USB, modems, IrDA etc, in fact, anything which gives
+a reliable 2-way connection. At present we just use TCP/IP, because
+it's convenient, ubiquitous, and easy to route.  This means that you
+can use VNC over anything which supports TCP/IP, so using it over a
+modem is just the same as any other network, once you have Dial-Up
+Networking set up.  If you need to communicate directly between two
+machines without going via the internet/intranet, then set up a remote
+access server on one and dial in from the other.</DD>
+
+<DT> <B>
+Does VNC have any Y2K (Year 2000) bugs?</B></DT>
+
+<DD>The WinVNC server and Windows viewer have been tested
+on a PC with its date running through the 2000 boundary without any problems,
+so unless the underlying OS or BIOS has difficulties, VNC on a PC should
+be fine.  The VNC part of the X-based Unix VNC server only uses dates 
+when writing the log files; the logfile entries are timestamped with a
+two-digit year, but the format is easy to change if required and the entries
+are not intended to be machine-readable. The developers of  the XFree86
+server on which Xvnc is based state that there are no Y2K problems (see 
+http://www.xfree86.org/FAQ/). We therefore issue the standard disclaimer:
+we believe the VNC code, in its entirety, to be free from Year 2000 problems,
+subject to the other components of the systems on which it is running.</DD>
+
+<DT> <B>
+Any other tips?</B></DT>
+
+<DD>Several people have indicated that they have to use
+Windows occasionally but prefer to use Unix most of the time, and so want
+to access a PC under the desk from the Unix box. </DD>
+
+<DD>
+<p>Here's a suggestion: all other things being equal,
+I recommend using the Windows box to view the Unix machine rather than
+the other way around.  This is chiefly because Windows generally works
+better as a client than as a server, and also because PC graphics cards
+are often better than those in Unix workstations.  Remember, you can
+create a VNC session of any size and pixel depth you like.</p>
+
+<p>If you're very anti-Windows you can make your VNC desktop
+the same size as the local screen and set the taskbar to 'Auto hide' and just
+pretend you're on an X terminal, but pop up the Start menu when you have
+to use PowerPoint.... The Windows viewer also now has a proper
+'full-screen mode', so you don't even need to bother with auto-hide.
+</p></DD>
+
+<DT> <B>
+You misspelled 'organization' on the download page!</B></DT>
+
+<DD>No we didn't. We spell it like that in the UK. 
+Actually, we spell it both ways, but the 's' spelling is more common, despite
+what the OED says! Now, as for 'misspelt'...</DD>
+
+</DL><HR>
+<H2>Compiling the source</H2><DL>
+
+<DT> <B>
+I'm having trouble compiling VNC on my platform...</B></DT>
+
+<DD>Have you checked the <a href="http://www.uk.research.att.com/vnc/contribs.html">contribs</a>
+page?  Several people have provided hints on how to build VNC on other
+platforms.  If yours is not listed there, you might at least get some
+clues..</DD>
+</DL><HR>
+</DL>
+
+
+
+
+
+
+
+
+
+
+
+
+
+<!-- Ruler here? -->
+
+<center>
+
+<p><i><font size=-1>For comments, feedback, etc, please see the '<a href="http://www.uk.research.att.com/vnc/intouch.html">Keeping
+
+in touch</a>' page</font>.</i>
+
+<br><i><font size=-1>Copyright 1999 - AT&amp;T Laboratories Cambridge
+
+</font></i></center>
+
+
+
+
+
+
+</body>
+
+</html>
+
--- vnc-3.3.7.orig/debian/libvncauth-dev.dirs
+++ vnc-3.3.7/debian/libvncauth-dev.dirs
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
--- vnc-3.3.7.orig/debian/vncserver.prerm
+++ vnc-3.3.7/debian/vncserver.prerm
@@ -0,0 +1,13 @@
+#!/bin/sh -e
+
+if [ "$1" = "remove" ] ; then
+    BIN=/usr/bin
+    update-alternatives --remove \
+	vncserver $BIN/realvncserver
+    update-alternatives --remove \
+	Xvnc $BIN/Xrealvnc
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/libvncauth-dev.links
+++ vnc-3.3.7/debian/libvncauth-dev.links
@@ -0,0 +1 @@
+usr/lib/libvncauth.so.0.0 usr/lib/libvncauth.so
--- vnc-3.3.7.orig/debian/vnc.conf.5x
+++ vnc-3.3.7/debian/vnc.conf.5x
@@ -0,0 +1,176 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for Xvnc
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH vnc.conf 5x "March 16th, 1998" "3.3.1" "Virtual Network Computing X client"
+.SH NAME
+vnc.conf \- configuration file for Virtual Network Computing
+.SH SYNOPSIS
+.IR $variable\ \| =\ " someValue """;
+
+.IR $variable\ \| =\ " someValue """;
+
+.IR $variable\ \| .=\ " someValue """;
+
+.IR $variable\ \| =\ \| $var1\ \| .\ \| $var2 ;
+
+.SH DESCRIPTION
+.I /etc/vnc.conf
+is the site wide configuration file for
+.BR vncserver (1),
+the free X server for
+.B Virtual Network Computing
+(VNC). It can be used to change the behaviour of the server at startup time,
+although for all values exist suitable default values.
+
+.I vnc.conf
+will be parsed by vncserver. Then vncserver will proceed and read
+.IR ~/.vncrc ,
+a file that can be changed on a per-user base. It has the some syntax and
+options as the file described in this document.
+
+.SH EXAMPLES
+A sample examplae file should come with the Debian package, under
+.IR /usr/share/doc/vncserver/examples/vnc.conf.gz. It is pretty self-descriptive, and this
+document will mainly repeat the information that already can be found there.
+
+.SH OVERVIEW
+The file is in
+.BR perl (1)
+syntax, although only variable assignment is allowed for your safety and
+convenience. But there still a variety of possibilities to set the string
+variables.
+
+All variable names are prefixed by `$'. You can assign a string to a
+variable using the `=' operator, and you can append a string to a variable
+using the `.=' operator. You can concatenate two strings using the `.'
+operator. You can substitute variables even inside quotes. You can access
+the environment variables using the notation
+.IR $ENV{VARIABLE} .
+
+You can unset a variable by assigning the empty string "" to it. Use this to
+return the state of the variable from `set' to `use default'.
+
+You may or may not end a line with a semicolon.
+
+.SH OPTIONS
+The options are given with their default value if this is known.
+
+.TP
+.IR $vncClasses\ \| =\ " /usr/X11R6/lib/vncserver """;
+Should be the path to the java classes of the server.
+.TP
+.IR $XFConfigPath\ \| =\ "/etc/X11/XF86Config """; 
+
+Can be set to the global
+.I XF86Config
+file. This will be
+parsed to gain default values for
+.I $fontPath
+and
+.IR $colorPath .
+If you want to disable this feature, point it to an
+invalid file,
+.I /foo
+for example.
+.TP
+.IR $fontPath
+Should a comma seperated list of fonts to be added to the font
+path. If not specified, and
+.I $XFConfigPath
+is valid, vncserver will read the $fontPath from there. If both are
+not set, the default will apply.
+.TP
+.IR $colorPath
+should be the RGB file to be used by X. This can also be taken from the
+.I XF86Config
+file if specified by
+.IR $XFConfigPath .
+.TP
+.IR $vncUserDir\ \| =\ " $ENV{HOME}/.vnc """;
+Contains the filename for the log files directory of Xvnc
+(the server) and the viewers that are connected to it.
+.TP
+.IR $vncPasswdFile\ \| =\ \| $vncUserDir\ \| .\ " /passwd """;
+Contains the filename of the password file for Xvnc.
+.TP
+.IR $vncStartup\ \| =\ " /etc/X11/XSession """;
+Points to a script that will be started at the very beginning of the Xvnc
+session.
+.TP
+.IR $xauthorityFile\ \| =\ " $ENV{HOME}/.Xauthority """;
+Specifies the path to the X authority file that should be used
+by your Xvnc server.
+.TP
+.IR $defaultDesktopName\ \| =\ " X """;
+Should be set to the default name of the desktop.
+This can be changed at the command line with
+.IR -name .
+.TP
+.I $geometry\ \| =\ " 640x400 """;
+This sets framebuffer width & height. Default will be calculated if
+server is started from within a running X servers. Can be changed at
+the commandline (
+.IR -geometry ).
+A fixed default will be used if vncserver is not invoked in
+a running X session.
+.TP
+.IR $depth\ \| =\ " 16 """;
+.TP
+.IR $pixelformat\ \| =\ " rgb565 """;
+.I $depth
+sets the framebuffer color depth. Must be an integer value between 8 and 32.
+.I $pixelformat
+sets the default pixelformat.
+
+The default values will be calculated if none of both are specified
+and when vncserver is called from within a running X servers.
+Can be changed at the command line with option
+.IR -depth .
+A fixed default value will be used if vncserver is not
+invoked in a running X session.
+.TP
+.I $getDefaultFrom
+This option lets you set the display from which you can query the default of
+the above three options, if you don't want to start vncserver
+from within a running X server. It will be added to the call of xdpyinfo.
+It is useful to get the default from the X server you will run xvncviewer
+in, because the data has not to be recalculated then.
+
+.I $getDefaultFrom\ \| =\ " \-display\ localhost:0 """;
+is an example how to do this.
+.TP
+.IR $rfbwait\ \| =\ " 120000 """;
+Sets the maximum time in msec to wait for vnc client viewer.
+
+.SH FILES
+.TP
+.B /usr/bin/vncserver
+A wrapper script around
+.B Xvnc
+to start the server with appropriate defaults.
+.TP
+.TP
+.B /usr/bin/vncpasswd
+Command to create and change password files to be used by the RFB protocol
+(can be specified in the
+.I $vncPasswdFile
+variable).
+.B /usr/bin/Xvnc
+The real server. Will be invoked by vncserver.
+.SH "SEE ALSO"
+.BR vncserver (1x),
+.BR Xvnc (1x),
+.BR vncpasswd (1x),
+.BR xvncviewer (1),
+.BR svncviewer (1).
+
+.SH AUTHOR
+1998 \- Originally written by Marcus Brinkmann (Marcus.Brinkmann@ruhr-uni-bochum.de)
+for the Debian GNU/Linux Distribution.
--- vnc-3.3.7.orig/debian/xvncviewer.preinst
+++ vnc-3.3.7/debian/xvncviewer.preinst
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+case "$1" in
+    install|upgrade)
+    # This two checks is for converting from wrapper to real scripts.
+    if [ -L /usr/X11R6/bin/xvncviewer ] ; then
+	rm -f /etc/X11R6/bin/xvncviewer
+    fi
+    ;;
+    
+    abort-upgrade)
+    ;;
+    
+    *)
+    echo "preinst called with unknown argument \`$1'" >&2
+    exit 1
+    ;;
+esac
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/start.html
+++ vnc-3.3.7/debian/start.html
@@ -0,0 +1,155 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<base href="http://www.uk.research.att.com/vnc/faq.html">
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="GENERATOR" content="Mozilla/4.51 [en] (X11; I; Linux 2.2.6 i686) [Netscape]">
+   <meta name="keywords" content="VNC, AT&T Laboratories Cambridge, Virtual Network Computing, WinVNC, thin-client, hydra, citrix, ntrigue, ica">
+   <title>Getting Started with VNC</title>
+</head>
+<body bgcolor="#FFFFFF" vlink="#000080" marginheight="0" topmargin="0" leftmargin="0" marginwidth="0">
+<!--webbot bot="Include" U-Include="_private/header.html" TAG="BODY" startspan -->
+<center>
+<h1>
+Virtual Network Computing</h1></center>
+
+<hr>
+<h2>Note</h2>
+<p> This version was edited by 
+ <A HREF="mailto:edward@debian.org">Edward Betts</A> for the Debian Operating 
+ System. The original version is available at the 
+ <a href="http://www.uk.research.att.com/vnc/start.html">VNC Home Page (extern)</a>. </p>
+<hr>
+
+<h2>
+Getting Started with VNC</h2>
+VNC consists of two types of component.&nbsp; A <i>server</i>, which generates
+a display, and a <i>viewer</i>, which actually draws the display on your
+screen.&nbsp;&nbsp; There are two important features of VNC:
+<ul>
+<li>
+The server and the viewer&nbsp; may be on different machines and on different
+architectures.&nbsp; We expect the most common use to be the display of
+a Unix X desktop on a PC, for example.&nbsp; The protocol which connects
+the server and viewer is simple, open, and platform- independent.</li>
+
+<li>
+No state is stored at the viewer. Breaking the viewer's connection to the
+server and then reconnecting will not result in any loss of data.&nbsp;
+Because the connection can be remade from somewhere else, you have easy
+mobility.</li>
+</ul>
+So, to get started with VNC you need to run a server, and then connect
+to it with a viewer.  Get the packages for the platforms you use from the
+<A HREF="download.html">download page</A>, if you haven't already, and install them.
+The current VNC software requires a TCP/IP connection
+between the server and the viewer, though there is no reason why the software
+couldn't be modified to use, for example, RS232 or Firewire.&nbsp; We have
+internal versions that use other network transport layers. But for now
+you'll need to know the name or the IP address of the server machine.
+<p>Most people will be running either a Unix server or a Windows server,
+though similar principles will apply to other platforms.
+<br>
+<hr WIDTH="100%">
+
+<h3>Running a Unix server</h3>
+A VNC server appears, to the Unix applications which appear on it,&nbsp;
+to be a standard X display just like the one you sit in front of; but it
+doesn't have a physical screen attached.&nbsp; The applications don't know
+this.&nbsp; They just carry on running whether or not a viewer is connected,
+in the same way as they would regardless of whether you were actually looking
+at your physical screen.
+<p>You can start a new VNC server by typing:
+<blockquote><tt>vncserver</tt></blockquote>
+on a Unix machine.&nbsp; (If you're sitting at a PC you may need to telnet
+to the Unix machine to get a command shell into which you can type this.)&nbsp;
+The <tt>vncserver</tt> program is a Perl script which you may need to edit
+to set up the directories appropriate for your local installation.
+<p>If you haven't run a VNC server before you will be prompted for a password,
+which you will need to use when connecting to this server. All your servers
+will use the same password, and you can change it at a later date using&nbsp;
+<blockquote><tt>vncpasswd</tt></blockquote>
+With a normal X system, the main X display of a workstation called 'snoopy<i>'</i>
+is usually <b>snoopy:0.</b> You can also run as many VNC servers on a Unix
+machine as you like, and they will appear as <b>snoopy:1</b>, <b>snoopy:2</b>
+etc, as if they were just additional displays.&nbsp; You can cause applications
+to use them by setting the DISPLAY environment variable to the VNC server
+you want, or by starting the application with the <tt>-display</tt> option.
+For example:
+<blockquote><tt>xterm -display snoopy:2 &amp;</tt></blockquote>
+Normally <tt>vncserver</tt> will choose the first available display number
+and tell you what it is, but you can specify a display number if you always
+wish to use the same one:
+<blockquote><tt>vncserver :2</tt></blockquote>
+Nothing will appear immediately as a result of starting a server. To see
+anything you need to connect a viewer to the server. See below.&nbsp; The
+server will generate a log in your <tt>~/.vnc </tt>directory. If you have
+problems at this stage, see the full <a href="docs.html">documentation</a>
+and the <a href="faq.html">FAQ</a> .
+<h4>
+Killing a Unix server</h4>
+You can kill a Unix VNC server using, for example:
+<blockquote><tt>vncserver -kill :2</tt></blockquote>
+</TD>
+<TD VALIGN=TOP BGCOLOR=#E0E0FF WIDTH=50%>
+
+<h3>
+Running a Windows server</h3>
+<p>Install
+the Windows server, WinVNC, by running the Setup program included in the
+distribution.&nbsp; This will create a VNC group in your Start Menu.</p>
+<p>Install the default registry settings using the option in the VNC group.</P>
+<p>Run the WinVNC server. If this is the first time you've used WinVNC
+on this machine you'll be prompted to set a password, which you'll need when you connect to the machine from a remote location.
+Normally you'll want to leave the other options on their default settings.&nbsp;
+(Note that the default display number is 0 on a PC.&nbsp; You'll need to
+specify this to the viewer when you connect.)&nbsp; Click OK and the server
+should be running.&nbsp; It will install a small icon on the system tray,
+and by right-clicking on this you can control most aspects of the server.&nbsp;
+(Full instructions for installing and running the <a href="winvnc.html">WinVNC
+server</a> can be found under the <a href="docs.html">main documentation</a>.)</p>
+<p>You can now go to another machine and connect a viewer to the server. (see below)</p>
+</TD></TR>
+</TABLE>
+<HR>
+<h3>Running a viewer</h3>
+When you run the viewer, you need to specify the name of the server and the number of the desktop. If, for example, you have started a server as display 2 on a machine called 'snoopy',
+you can start a viewer for it by typing:
+<blockquote><tt>vncviewer snoopy:2</tt></blockquote>
+With the Windows viewer, you can run it from the command line, but you
+will more typically run it from the VNC group on the Start Menu. In this case,  you will
+be prompted for the host name and display number.
+
+<p>Enter it and click OK, and you will be prompted for your password, after
+which you should see the remote display.&nbsp; (If you are connecting to
+a Windows or Mac server, the display number will be 0, unless you have
+explicitly changed it).
+<p>If the machine running the server does not have a proper DNS entry,
+you probably won't be able to use the name and will have to replace <tt>snoopy:2</tt>
+with something like <tt>192.168.1.2:2</tt> .&nbsp; You can get round this
+on most platforms by creating a 'hosts' file which maps names onto IP addresses.&nbsp;
+Consult your local guru for help with this.
+<HR>
+<h3>
+Using a web browser as a viewer</h3>
+The VNC servers also contain a small web server.  If you connect to this with a web browser, you can download the Java version of the viewer, and use this to view the server.
+ You can then see your desktop from any Java-capable browser! (unless you are using a proxy to connect to the web).
+ The server listens for HTTP connections on port 5800+display
+number.&nbsp; So to view display 2 on machine 'snoopy', you would point
+your web browser at:
+<blockquote><tt>http://snoopy:5802/</tt></blockquote>
+The applet will prompt you for your password, and should then display the desktop.
+<p><i>That's it!&nbsp; For more details see <a href="docs.html">the documentation</a>.
+The answers to lots of common questions can be found in the <a href="faq.html">FAQ</a>
+.</i>
+<p>&nbsp;
+
+
+<!-- Ruler here? -->
+<center>
+<p><i><font size=-1>For comments, feedback, etc, please see the '<a href="intouch.html">Keeping
+in touch</a>' page</font>.</i>
+<br><i><font size=-1>Copyright 1999 - AT&amp;T Laboratories Cambridge</font></i></center>
+
+</body>
+</html>
--- vnc-3.3.7.orig/debian/xvncviewer.examples
+++ vnc-3.3.7/debian/xvncviewer.examples
@@ -0,0 +1 @@
+debian/vncviewer
--- vnc-3.3.7.orig/debian/xvncviewer.1x
+++ vnc-3.3.7/debian/xvncviewer.1x
@@ -0,0 +1,232 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for Xvnc
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH xvncviewer 1x "January 2000" "3.3.3" "VNC X client"
+.SH NAME
+xvncviewer \- a X viewer client for Virtual Network Computing
+.SH SYNOPSIS
+.\" The general command line
+.B xvncviewer
+.RI [\| options \|]
+.RI [\| host:display \|]
+
+.B xvncviewer
+.RI [\| options \|]
+.IR \-listen\ 
+.RI [\| display \|]
+
+.BR options\ \| are
+.RI [\| \-shared \|]
+.RI [\| \-viewonly \|]
+.RI [\| \-fullscreen \|]
+.RI [\| \-passwd\ file \|]
+.RI [\| \-encodings\ encoding\-names \|]
+.RI [\| \-bgr233 \|]
+.RI [\| \-owncmap \|]
+.RI [\| \-truecolour \|]
+.RI [\| \-depth\ num \|]
+.RI [\| \-display\ display \|]
+.RI [\| \-geometry\ geom \|]
+.RI [\| \-help \|]
+
+.SH DESCRIPTION
+.B xvncviewer
+is a X viewer client for
+.BR Xvnc,
+the free X server for
+.B Virtual Network Computing
+(VNC). It can connect to a running Xvnc server and display it in a X window.
+Further it can transmit mouse and keyevents to the server.
+
+There are viewers for a variety of other plattforms, e.g. SVGAlib and Windows.
+For Linux and Windows also a server exists. With the built-in Java classes,
+you can even use a Java capable Internet browser to connect to Xvnc.
+
+.SH EXAMPLES
+.TP \w'xvncviewer\ 'u
+.BI xvncviewer\ \| localhost:1
+Connects to a running Xvnc session on the local workstation and displays its
+content in a X window.
+.TP
+.BI xvncviewer\ \| -display\ :0\ flora:1
+Connects to a running Xvnc on host
+.I flora
+and displays its content in a X window of display :0 at localhost.
+
+.SH OPTIONS
+.TP
+.I \-help
+Prints a short usage notice to stderr.
+.TP
+.I \-shared
+When you make a connection to a VNC server, all other existing connections are
+normally closed.  This option requests that they be left open, allowing you to
+share the desktop with someone already using it.
+.TP
+.I \-viewonly
+This option disables transfer of mouse and key events from the client to the
+server.  This does not automatically imply \-shared.
+.TP
+.I \-fullscreen
+Start in fullscreen mode.
+.TP
+.I \-passwd\ file
+If you are on a filesystem which gives you access to the password file used
+by the server, you can specify it here to avoid typing it in.
+.TP
+.I \-encodings\ encoding\-names
+VNC provides several different compression encodings; this option specifies
+a set of them in order of preference.  Encodings are specified separated
+with spaces, and must thus be enclosed in quotes if more than one is
+specified.  Available encodings, in default order for a remote connection, are
+copyrect, hextile, corre, rre, and raw.  For a local connection (to the same
+machine), the default order to try is raw, copyrect, hextile, corre, and rre.
+.TP
+.I \-bgr233
+Tells the VNC server to send pixels 8-bits deep.  This reduces network
+traffic, but increases CPU utilization on servers deeper than 8 bits due
+to the translation required.  Additionally, the colors are sometimes wrong.
+The bgr233 format is an 8-bit "true color" format, with 2 bits blue,
+3 bits green, and 3 bits red.  This is also the format used by the Java
+client.
+.TP
+.I \-owncmap
+This makes the viewer to install a private colormap on displays with a color
+depth of 8 bits.
+.TP
+.I \-truecolour
+Attempt to use a truecolour visual.  (Americans should note the spelling
+of "colour".)
+.TP
+.I \-depth
+On an X-server which supports multiple true-color depths, attempt to use
+the specified one; if successful, this is the depth which will be requested
+from the VNC server.  To force a particular depth from the vnc server,
+see the \-bgr233 option.
+.TP
+.I \-listen
+This causes the viewer to listen on port 5500+displaynumber for reverse
+connections from a server.  WinVNC supports reverse connections using the
+"Add New Client" menu option, or the -connect command line option.
+.P
+.B Standard\ Xt\ Options \-
+xvncviewer accepts the usual options; see X(3x) for more information.  A
+few extremely common options are listed below.
+.TP
+.I \-display\ num
+This allows you to specify the X display on which the VNCviewer window should
+appear.
+.TP
+.I \-geometry\ geometry\-string
+This specifies the initial size and location of the viewer window.
+.TP
+.I \-compresslevel
+Specifies the compression level to use (TightVNC).
+.TP
+.I \-quality
+Set the quality of the output (TightVNC).
+.TP
+.I \-nocursorshape
+Do not show the cursor from the workspace (TightVNC).
+.TP
+.I \-noshared
+Disallow sharing of the workspace.
+.TP
+.I \-tunnel
+
+.SH ENCODINGS
+The server supplies information in whatever format is desired by the client,
+in order to make the client as easy as possible to implement.  If the client
+represents itself as able to use multiple formats, the server will choose one.
+
+.B Pixel format
+refers to the representation of an individual pixel.  The most
+common formats are 24 and 16 bit "true-color" values, and 8-bit "color map"
+representations, where an arbitrary map converts the color number to
+RGB values.
+
+.B Encoding
+refers to how a rectangle of pixels are sent (all information in VNC is sent
+as rectangles).  All rectangles come with a header giving the location and
+size of the rectangle and an encoding type used by the data which follows.
+These types are listed below.
+.TP
+.I raw
+The raw encoding simply sends width*height pixel values.  All clients are
+required to support this encoding type.  Raw is also the fastest when
+the server and viewer are on the same machine, as the connection speed is
+essentially infinite and raw encoding minimizes processing time.
+.TP
+.I copyrect
+The Copy Rectangle encoding is efficient when something is being moved; the
+only data sent is the location of a rectangle from which data should be copied
+to the current location.  Copyrect could also be used to efficiently transmit
+a repeated pattern.
+.TP
+.I RRE
+The Rise-and-Run-length-Encoding is basically a 2D version of run-length
+encoding (RLE).  In this encoding, a sequence of identical pixels are compressed
+to a single value and repeat count.  In VNC, this is implemented with a
+background color, and then specifications of an arbitrary number of
+subrectangles and color for each.  This is an efficient encoding for large
+blocks of constant color.
+.TP
+.I CoRRE
+This is a minor variation on RRE, using a maximum of 255x255 pixel
+rectangles.  This allows for single-byte values to be used, reducing
+packet size.  This is in general more efficient, because the savings from
+sending 1-byte values generally outweighs the losses from the (relatively
+rare) cases where very large regions are painted the same color.
+.TP
+.I Hextile
+Here, rectangles are split up in to 16x16 tiles, which are sent in a
+predetermined order.  The data within the tiles is sent either raw or as
+a variant on RRE.
+.TP
+.I Other
+Additional encodings, such as zlib, have been written, but are not a stock
+part of VNC.  See http://www.uk.research.att.com/vnc/extras.html#zlib for
+more information.
+
+.SH FILES
+.TP
+.B /usr/bin/vncpasswd
+Command to create and change password files to be used by the RFB protocol
+(can be specified with the
+.I \-passwd
+option).
+.TP
+.B /usr/bin/vncserver
+A wrapper script around
+.B Xvnc
+to start the server with appropriate defaults.
+.TP
+.B /usr/bin/Xvnc
+The real server. Will be invoked by vncserver.
+.SH "SEE ALSO"
+.BR svncviewer (1),
+.BR vncpasswd (1x),
+.BR vncserver (1x),
+.BR Xvnc (1x), 
+.BR vnc.conf (5).
+.br
+http://www.uk.research.att.com/vnc/xvncviewer.html
+.br
+http://www.uk.research.att.com/vnc/protocol.html
+
+.SH AUTHOR
+VNC developed at Olivetti Research Labs, Cambridge (now AT&T
+Laboratories, Cambridge) by Tristan Richardson, Ken Wood,
+James Weatherall, Andy Harter, Charlie McLachlan, Paul Webster,
+Quentin Stafford-Fraser and others.
+.BR
+This manpage written by Marcus Brinkmann for the Debian GNU/Linux
+distribution.
+.BR
--- vnc-3.3.7.orig/debian/vncconnect.1x
+++ vnc-3.3.7/debian/vncconnect.1x
@@ -0,0 +1,37 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for vncconnect
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"                2000, opal@debian.org
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH vncconnect 1x "March 16th, 1998" "3.3.1" "Virtual Network Computing X server"
+.SH NAME
+vncconnect \- Tells Xvnc to connect to a listening VNC viewer on the given
+host and port
+.SH USAGE
+.\" The general command line
+.B xvncviewer
+.RI [\| options \|]
+.RI host[\| \|:port \|]
+
+.SH "SEE ALSO"
+.BR Xvnc (1x), 
+.BR vncpasswd (1x),
+.BR vnc.conf (5),
+.BR xvncviewer (1x),
+.BR svncviewer (1x).
+
+.SH AUTHOR
+VNC developed at Olivetti Research Labs, Cambridge (now AT&T
+Laboratories, Cambridge) by Tristan Richardson, Ken Wood,
+James Weatherall, Andy Harter, Charlie McLachlan, Paul Webster,
+Quentin Stafford-Fraser and others.
+.BR
+This manpage written by Ola Lundqvist for the Debian GNU/Linux
+distribution.
+.BR
--- vnc-3.3.7.orig/debian/Xvnc.1x
+++ vnc-3.3.7/debian/Xvnc.1x
@@ -0,0 +1,405 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for Xvnc
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH Xvnc 1 "March 16th, 1998" "3.3.1" "Virtual Network Computing X server"
+.SH NAME
+Xvnc \- a X server for Virtual Network Computing
+.SH SYNOPSIS
+.\" The general command line
+.B Xvnc 
+.RI [\| :display \|]
+.RI [\| \-a \|
+.IR pixel \|]
+.RI [\| \-ac \|]
+.RI [\| \-audit \|
+.IR int \|]
+.RI [\| \-auth \|
+.IR file \|] 
+.RI [\| bc \|] 
+.RI [\| \-bs \|] 
+.RI [\| \-c \|] 
+.RI [\| c \|
+.IR int \|] 
+.RI [\| \-cc \|
+.IR int \|]
+.RI [\| \-co \|
+.IR file \|]
+.\" .RI [\| \-config \|
+.\" .IR file \|]
+.RI [\| \-core \|]
+.RI [\| \-dpi \|
+.IR int \|]
+.RI [\| \-deferglyphs \|
+.IR \|
+.RI [\| none \||\| all \||\| 16 \|]]
+.RI [\| \-f \|
+.IR int \|]
+.RI [\| \-fc \|
+.IR string \|]
+.RI [\| \-fn \|
+.IR string \|]
+.RI [\| \-fp \|
+.IR string \|]
+.RI [\| \-help \|]
+.RI [\| \-I \|]
+.\" .RI [\| \-kb \|]
+.RI [\| \-ld \|
+.IR int \|]
+.RI [\| \-lf \|
+.IR int \|]
+.RI [\| \-ls \|
+.IR int \|]
+.RI [\| \-nolock \|]
+.RI [\| \-logo \|]
+.RI [\| nologo \|]
+.RI [\| \-nolisten
+.IR string \|]
+.RI [\| \-p \|
+.IR minutes \|]
+.RI [\| \-pn \|]
+.RI [\| \-nopn \|]
+.RI [\| \-r \|]
+.RI [\| r \|]
+.RI [\| \-s \|
+.IR min \|]
+.RI [\| \-su \|]
+.RI [\| \-t \|
+.IR int \|]
+.RI [\| \-terminate \|]
+.RI [\| \-to \|
+.IR int \|]
+.RI [\| \-tst \|]
+.RI [\| ttyxx  \|]
+.RI [\| v \|]
+.RI [\| \-v \|]
+.RI [\| \-wm \|]
+.RI [\| \-x \|
+.IR string \|]
+.RI [\| \-query \|
+.IR hostname \|]
+.RI [\| \-broadcast \|]
+.RI [\| \-indirect \|
+.IR hostname \|]
+.RI [\| \-port \|
+.IR num \|]
+.RI [\| \-once \|]
+.RI [\| \-class \|
+.IR display-class \|]
+.RI [\| \-displayID \|
+.IR display-id \|]
+.RI [\| \-geometry \|
+.IR WxH \|]
+.RI [\| \-depth \|
+.IR int \|]
+.RI [\| \-pixelformat \|
+.RI [\| bgrnnn \||\| rgbnnn \|]]
+.RI [\| \-udpinputport \|
+.IR num \|]
+.RI [\| \-rfbport \|
+.IR num \|]
+.RI [\| \-rfbwait \|
+.IR ms \|]
+.RI [\| \-nocursor \|]
+.RI [\| \-rfbauth \|
+.IR file \|]
+.RI [\| \-httpd \|
+.IR dir \|]
+.RI [\| \-httpport
+.IR num \|]
+.RI [\| \-economictranslate \|]
+.RI [\| \-desktop \|
+.IR name \|]
+
+.SH DESCRIPTION
+.B Xvnc
+is a free X server for
+.B Virtual Network Computing
+(VNC). It provides all the capabilities of a X server, but does not connect
+to a display for itself. You need a
+.B vncviewer
+to view and control the applications that run on the server.
+
+There are viewers for a variety of plattforms, e.g. X, svgalib and Windows.
+For Linux and Windows also a server exists. With the built-in Java classes,
+you can even use a Java capable Internet browser to connect to Xvnc.
+
+.SH EXAMPLES
+.TP \w'Xvnc\ 'u
+.BI Xvnc\ \| :1
+Invoke Xvnc on display :1 at localhost.
+.TP
+.BI Xvnc\ \| \-geometry\ 640x480\ \-once\ \-httpd\ /usr/X11R6/lib/vncserver
+Invoke Xvnc for one session, with a framebuffer size of 640x480. Use the
+Java classes in
+.IR /usr/X11R6/lib/vncserver .
+
+.SH OVERVIEW
+Many options are available to 
+.B Xvnc
+in order to give as much flexibility as possible to the user.
+Most of the options are standard options for X server, and Xvnc provides a
+few additional options dsigned for its special purpose.
+
+Normally, you will not invoke Xvnc itself but
+.BR vncserver (1x),
+which is a wrapper script to parse configuration files and calculate
+appropriate default values for lots of options of
+.B Xvnc.
+
+.SH DEFAULTS
+.B Xvnc
+will use some built-in defaults for a variety of options. But it is better
+not to rely on them. Instead you should use
+.BR vncserver (1x),
+to call Xvnc with the right options for your system. This has the advantage
+that you can use configuration files to adjust Xvnc to your system.
+Please see the manpage of
+.BR vncserver (1x)
+for details.
+
+.SH OPTIONS
+There are a lot of options for
+.BR Xvnc .
+As this man page is provided by the Debian maintainer and not by the
+upstream author, this man page can't be very descriptive. Please check the
+man pages of the X windows system for a detailed explanation of the standard
+X server options.
+
+.TP
+.I \-a\ pixel
+This sets the mouse acceleration in pixel.
+.TP
+.I \-ac
+Use this option to disable access control restrictions.
+.TP
+.I \-audit\ int
+Set audit trail level.
+.TP
+.I \-auth\ filename
+Specifies the filename of the X authorization file.
+.TP
+.I bc
+Enables bug compatibility.
+.TP
+.I \-bs
+Disable any backing store support.
+.TP
+.I \-c
+This option turns off key clicking.
+.TP
+.I c\ int
+This option specifies the key clicking volume and maybe an integer value
+from 0 to 100.
+.TP
+.I \-cc\ int
+Specifies the default color visual class.
+.TP
+.I \-co\ file
+This should be the filename of a valid X color database file, as it is
+specified in the RgbPath field of the
+.I XF86Config
+file.
+.TP
+.\" .I \-config\ file
+.\" With this argument you can read further options from a file.
+.\" .TP
+.I \-core
+If you specify this option,
+.I Xvnc
+will generate a core dump on fatal error.
+.TP
+.I \-dpi\ int
+Set the screen resolution in dots per inch.
+.TP
+.I \-deferglyphs [\|none\||\|all\||\|16\|]
+Defer loading of no, all or 16-bit glyphs.
+.TP
+.I \-f\ int
+Bell base. Mabye an integer value from 0 to 100.
+.TP
+.I \-fc\ string
+This sets the cursor font.
+.TP
+.I \-fn\ string
+This sets the default font name.
+.TP
+.I \-fp\ string
+This specifies the default font path.
+.TP
+.I \-help
+This will print a help message with all legal options on stderr.
+.TP
+.I \-I
+After this option, all remaining arguments will be ignored.
+.TP
+.\" .I \-kb
+.\" Disable XKB extension.
+.\" .TP
+.I \-ld\ int
+With this option you can limit the data space to N KByte.
+.TP
+.I \-lf\ int
+With this option you can limit the number of open files to N.
+.TP
+.I \-ls\ int
+With this option you can limit the stack space to N KByte.
+.TP
+.I \-nolock
+Disables the locking mechanism.
+.TP
+.I \-logo
+Enables logo in screen saver.
+.TP
+.I nologo
+Disables logo in screen saver.
+.TP
+.I \-nolisten\ string
+Don't listen on protocol.
+.TP
+.I \-p\ minutes
+Screen-saver pattern duration in minutes.
+.TP
+.I \-pn
+Accept failure to listen on all ports.
+.TP
+.I \-nopn
+Reject failure to listen on all ports.
+.TP
+.I \-r
+Turns auto-repeat off.
+.TP
+.I r
+Turns on auto-repeat on.
+.TP
+.I \-s\ minutes
+Screen-saver timeout in minutes.
+.TP
+.I \-su
+Disable any save under support.
+.TP
+.I \-t\ pixel
+This option specifies the mouse threshold in pixels.
+.TP
+.I \-terminate
+Terminate at server reset.
+.TP
+.I \-to\ int
+Connection time out.
+.TP
+.I \-tst
+Disable testing extensions.
+.TP
+.I ttyxx
+Server started from init on /dev/ttyxx.
+.TP
+.I v
+Enablevideo blanking for screen-saver.
+.TP
+.I \-v
+Screen-saver without video blanking.
+.TP
+.I \-wm
+WhenMapped default backing-store.
+.TP
+.I \-x string 
+Loads named extension at init time.
+.TP
+.I \-query\ hostname
+Contact named host for XDMCP.
+.TP
+.I \-broadcast
+Broadcast for XDMCP.
+.TP
+.I \-indirect\ hostname
+Contact named host for indirect XDMCP.
+.TP
+.I \-port\ num
+UDP port number to send messages to.
+.TP
+.I \-once
+Terminate server after one session. When the viewer disconnects, the server
+will terminate.
+.TP
+.I \-class\ display-class
+Specify display class to send in manage.
+.TP
+.I \-displayID\ display-id
+Manufacturer display ID for request.
+.TP
+.I \-geometry\ WxH
+Set framebuffer width & height.
+.TP
+.I \-depth\ num
+Set framebuffer depth. Must be a value between 8 and 32.
+.TP
+.I \-pixelformat\ format
+Set pixel format (BGRnnn or RGBnnn). The viewer can do the conversion to any
+other pixel format, but it is faster if the depth and pixelformat of the
+server is the same as the aequivalent values on the viewer display.
+.TP
+.I \-udpinputport\ port
+UDP port for keyboard/pointer data.
+.TP
+.I \-rfbport\ port
+TCP port for RFB protocol. The RFB protocol is the VNC server/client
+protocoll.
+.TP
+.I \-rfbwait\ time
+Maximum time in milli seconds to wait for RFB client. The RFB client is the
+VNC viewer.
+.TP
+.I \-nocursor
+Don't put up a cursor.
+.TP
+.I \-rfbauth\ passwd-file
+When using authentication on RFB protocol, compare the password with the
+password saved in passwd-file.
+.TP
+.I \-httpd\ dir
+Specify the directory in which the java classes are stored with this
+option.
+.TP
+.I \-httpport\ port
+With this option you can specify the port on which Xvnc should listen for
+incoming http connections (to be used by any Java capable browser).
+.TP
+.I \-economictranslate
+Less memory-hungry translation.
+.TP
+.I \-desktop\ name
+Name of the VNC desktop (default x11).
+
+.SH FILES
+.TP
+.I /usr/bin/vncserver
+Wrapper script for convenient invocation.
+.TP
+.I /usr/bin/vncpasswd
+Command to create and change password files to be used by the RFB protocol
+(can be specified with the
+.I \-rfbauth
+option).
+.TP
+.I /usr/X11R6/lib/vncserver/
+This directory contains the Java classes for incoming Http connections.
+.SH "SEE ALSO"
+.BR vncserver (1x), 
+.BR vncpasswd (1x),
+.BR vnc.conf (5).
+
+.SH AUTHOR
+VNC developed at Olivetti Research Labs, Cambridge (now AT&T
+Laboratories, Cambridge) by Tristan Richardson, Ken Wood,
+James Weatherall, Andy Harter, Charlie McLachlan, Paul Webster,
+Quentin Stafford-Fraser and others.
+.BR
+This manpage written by Marcus Brinkmann for the Debian GNU/Linux
+distribution.
+.BR
--- vnc-3.3.7.orig/debian/README.inetd
+++ vnc-3.3.7/debian/README.inetd
@@ -0,0 +1,45 @@
+This is what works for me.
+
+In /etc/services I have
+
+vnc-640x480x8   5950/tcp
+vnc-800x600x8   5951/tcp
+vnc-800x600x16  5952/tcp
+vnc-1024x768x16 5953/tcp
+
+These correspond to the various resultions for VNC windows.
+
+In  /etc/inetd.conf I have
+
+
+vnc-640x480x8   stream  tcp     nowait  nobody.tty      /usr/bin/X11/Xvnc Xvnc -inetd -query localhost -once -geometry 640x480 -depth 8
+vnc-800x600x8   stream  tcp     nowait  nobody.tty      /usr/bin/X11/Xvnc Xvnc -inetd -query localhost -once -geometry 800x600 -depth 8
+vnc-800x600x16  stream  tcp     nowait  nobody.tty      /usr/bin/X11/Xvnc Xvnc -inetd -query localhost -once -geometry 800x600 -depth 16
+vnc-1024x768x16 stream  tcp     nowait  nobody.tty      /usr/bin/X11/Xvnc Xvnc -inetd -query localhost -once -geometry 1024x768 -depth 16
+
+These arrange for VNC to be started at the appropriate resolutions.
+
+
+The -query localhost tells the X server which Xvnc starts to send an XDMCP
+query to localhost to get a display manager.
+
+I use KDM on my system, and so I had to alter/etc/kde2/kdm/kdmrc to change
+Enable=false to Enable=true
+
+I also changed /etc/kde2/kdm/kdmrc/Xaccess to allow connections.
+
+Also need to reload inetd (update-inetd may handle this in a package) and
+restart kdm
+
+You can then use a VNC connection to display 50 (i.e. systemname:50 in the
+vnc viewer) to get a  640x480x8 session.
+
+For GDM you need to change Enable=false to Enable=true in /etc/gdm/gdm.conf
+(but I have not tested this to see if anything else is needed)
+
+
+
+Using VNC this way has been useful for me - I hope it may be useful for
+someone else also.
+
+John Lines <john@paladin.demon.co.uk>
--- vnc-3.3.7.orig/debian/vnc-common.doc-base
+++ vnc-3.3.7/debian/vnc-common.doc-base
@@ -0,0 +1,12 @@
+Document: vnc
+Title: vnc: Virtual network computing
+Author: Ola Lundqvist <opal@debian.org>
+Abstract: VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+Section: Apps/Net
+
+Format: HTML
+Index: /usr/share/doc/vnc-common/faq.html
+Files: /usr/share/doc/vnc-common/*.html
--- vnc-3.3.7.orig/debian/vnc.conf
+++ vnc-3.3.7/debian/vnc.conf
@@ -0,0 +1,103 @@
+# /etc/vnc.conf written by Marcus Brinkmann. This file is in the Public Domain.
+#
+# This is the configuration file for the vncserver package.
+# It is perl syntax, but only variable assignment is allowed.
+# A semicolon will be added if missing.
+# Every value has suitable defaults, so you probably don't need any file.
+#
+# This file will be sourced by `vncserver' and `vncpasswd'.
+# After this file, $(HOME)/.vncrc will be sourced, so values can be
+# overwritten on a per-user basis. If you want to reactivate the default
+# value there, you have to specify an empty value. For example, $fontPath
+# will set to the default value after
+#
+# $fontPath = "/foo";
+# $fontPath = "";
+#
+# If you are missing something, please let me know.
+# Marcus.Brinkmann@ruhr-uni-bochum.de
+
+# System configuration
+# --------------------
+#
+# This section contains entries that should be true for all users.
+
+# $vncClasses should be the path to the java classes of server.
+# $vncClasses = "/usr/share/vncserver";
+
+# $XFConfigPath   can be set to the global XF86Config file. This will be
+#                 parsed to gain default values for $fontPath and $colorPath.
+#                 If you want to disable this feature, point it to an
+#                 invalid file, "/foo" for example.
+# $XFConfigPath = "/etc/X11/XF86Config";
+
+# $fontPath should be a comma seperated list of fonts to be added to the font
+#           path. If not specified, and $XFConfigPath is valid, vncserver
+#           will read the $fontPath from there. If both are not set, the
+#           default will apply.
+# Example: $fontPath = "tcp/localhost:7100";     # would make vnc to use xfs.
+# Example: $fontPath = "";
+#	$fontPath .= "/usr/X11R6/lib/X11/fonts/misc/,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/Type1/,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/Speedo/,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/75dpi/,";
+# 	$fontPath .= "/usr/X11R6/lib/X11/fonts/100dpi/,";
+#	$fontPath .= "/usr/X11R6/lib/X11/fonts/freefont/,";
+#	$fontPath .= "/usr/X11R6/lib/X11/fonts/sharefont/";
+# I don't know what the default is, though.
+
+# $colorPath should be the RGB file to be used by X. This can also be taken from
+#            XF86Config file if specified by $XFConfigPath
+# $colorPath = "/usr/X11R6/lib/X11/rgb";
+
+# User configuration
+# ------------------
+#
+# This section contains entries that may change from user to user.
+
+# $vncUserDir contains the filename for the log files directory of Xvnc
+#             (the server) and the viewers that are connected to it.
+# $vncUserDir = "$ENV{HOME}/.vnc";
+
+# $vncPasswdFile contains the filename of the password file for Xvnc.
+# $vncPasswdFile = $vncUserDir . "/passwd";
+
+# $vncStartup points to a script that will be started at the very beginning.
+# $vncStartup = "/etc/X11/Xsession";
+
+# $xauthorityFile should be the path to the authority file that should be used
+#                 by your vnc X server.
+# $xauthorityFile = "$ENV{HOME}/.Xauthority";
+
+# $defaultDesktopName should be set to the default name of the desktop.
+#                     This can be changed at the command line with -name.
+# $defaultDesktopName = "X";
+
+# $geometry sets framebuffer width & height. Default will be calculated if
+#           server is started from within a running X servers. Can be changed at
+#           the commandline (-geometry). A fixed default will be used if
+#           vncserver is not invoked in a running X session.
+# Example:  $geometry ="640x480";
+
+# $depth       sets the framebuffer color depth. Must be between 8 and 32.
+# $pixelformat sets the default pixelformat.
+#              The default will be calculated if none of both is specified
+#              and when vncserver is called from within a running X servers.
+#              Can be changed at the command line with option -depth.
+#              A fixed default value will be used if vncserver is not
+#              invoked in a running X session.
+# Example:  $depth = "16";
+#           $pixelformat = "rgb565";
+
+# $getDefaultFrom sets the display from which you can query the default of
+#                 the above three options, if you don't want to start vncserver
+#                 from within a running X server. It will be added to the call
+#                 of xdpyinfo.
+#                 It is useful to get the default from the X server you will
+#                 run xvncviewer in.
+# Example:  $getDefaultFrom = "-display localhost:0"
+
+# $rfbwait sets the maximum time in msec to wait for vnc client viewer.
+# $rfbwait = "120000";
--- vnc-3.3.7.orig/debian/vnc-common.README.Debian
+++ vnc-3.3.7/debian/vnc-common.README.Debian
@@ -0,0 +1,12 @@
+vnc for Debian
+--------------
+
+ This version of VNC is an enhanced version of the RealVNC sources. Lot
+ of patches that fix different issues. The upstream development have now
+ started again so the debian fixes will soon be integrated into the upstream
+ code.
+
+ The biggest difference is portablity and the -via and -tunnel options from
+ TightVNC.
+
+ -- Ola Lundqvist <opal@debian.org>, Mon, 28 Oct 2002 08:57:57 +0100
--- vnc-3.3.7.orig/debian/vncserver.examples
+++ vnc-3.3.7/debian/vncserver.examples
@@ -0,0 +1 @@
+debian/vnc.conf
--- vnc-3.3.7.orig/debian/vnc-common.dirs
+++ vnc-3.3.7/debian/vnc-common.dirs
@@ -0,0 +1,4 @@
+etc
+usr/bin
+usr/share/man/man1
+usr/share/man/man5
--- vnc-3.3.7.orig/debian/vnc-common.docs
+++ vnc-3.3.7/debian/vnc-common.docs
@@ -0,0 +1,4 @@
+debian/faq.html
+debian/faq.txt
+debian/start.html
+debian/start.txt
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3-10-xdm-auth-support.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.3-10-xdm-auth-support.patch
@@ -0,0 +1,416 @@
+--- orig/vnc-3.3.3/Xvnc/config/cf/site.def      Thu May  7 17:13:57 1998
++++ vnc-3.3.3/Xvnc/config/cf/site.def   Tue Aug 22 22:34:54 2000
+@@ -98,7 +98,7 @@
+ ================================================================*/
+ 
+ /* Only set HasXdmAuth to YES if you have a Wraphelp.c file. */
+-/* #define HasXdmAuth YES */
++#define HasXdmAuth YES
+ 
+ /* #define PreIncDir DefaultGccIncludeDir */
+ 
+diff -x *~ -ruN orig/vnc-3.3.3/Xvnc/lib/Xdmcp/Wraphelp.c vnc-3.3.3/Xvnc/lib/Xdmcp/Wraphelp.c
+--- orig/vnc-3.3.3/Xvnc/lib/Xdmcp/Wraphelp.c    Thu Jan  1 01:00:00 1970
++++ vnc-3.3.3/Xvnc/lib/Xdmcp/Wraphelp.c Tue Aug 22 22:33:49 2000
+@@ -0,0 +1,401 @@
++/*
++ * This program implements the
++ * Proposed Federal Information Processing
++ *  Data Encryption Standard.
++ * See Federal Register, March 17, 1975 (40FR12134)
++ */
++
++/*
++ * Initial permutation,
++ */
++static char    IP[] = {
++       58,50,42,34,26,18,10, 2,
++       60,52,44,36,28,20,12, 4,
++       62,54,46,38,30,22,14, 6,
++       64,56,48,40,32,24,16, 8,
++       57,49,41,33,25,17, 9, 1,
++       59,51,43,35,27,19,11, 3,
++       61,53,45,37,29,21,13, 5,
++       63,55,47,39,31,23,15, 7,
++};
++
++/*
++ * Final permutation, FP = IP^(-1)
++ */
++static char    FP[] = {
++       40, 8,48,16,56,24,64,32,
++       39, 7,47,15,55,23,63,31,
++       38, 6,46,14,54,22,62,30,
++       37, 5,45,13,53,21,61,29,
++       36, 4,44,12,52,20,60,28,
++       35, 3,43,11,51,19,59,27,
++       34, 2,42,10,50,18,58,26,
++       33, 1,41, 9,49,17,57,25,
++};
++
++/*
++ * Permuted-choice 1 from the key bits
++ * to yield C and D.
++ * Note that bits 8,16... are left out:
++ * They are intended for a parity check.
++ */
++static char    PC1_C[] = {
++       57,49,41,33,25,17, 9,
++        1,58,50,42,34,26,18,
++       10, 2,59,51,43,35,27,
++       19,11, 3,60,52,44,36,
++};
++
++static char    PC1_D[] = {
++       63,55,47,39,31,23,15,
++        7,62,54,46,38,30,22,
++       14, 6,61,53,45,37,29,
++       21,13, 5,28,20,12, 4,
++};
++
++/*
++ * Sequence of shifts used for the key schedule.
++*/
++static char    shifts[] = {
++       1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
++};
++
++/*
++ * Permuted-choice 2, to pick out the bits from
++ * the CD array that generate the key schedule.
++ */
++static char    PC2_C[] = {
++       14,17,11,24, 1, 5,
++        3,28,15, 6,21,10,
++       23,19,12, 4,26, 8,
++       16, 7,27,20,13, 2,
++};
++
++static char    PC2_D[] = {
++       41,52,31,37,47,55,
++       30,40,51,45,33,48,
++       44,49,39,56,34,53,
++       46,42,50,36,29,32,
++};
++
++/*
++ * The C and D arrays used to calculate the key schedule.
++ */
++
++static char    C[28];
++static char    D[28];
++
++/*
++ * The key schedule.
++ * Generated from the key.
++ */
++static char    KS[16][48];
++
++/*
++ * The E bit-selection table.
++ */
++static char    E[48];
++static char    e[] = {
++       32, 1, 2, 3, 4, 5,
++        4, 5, 6, 7, 8, 9,
++        8, 9,10,11,12,13,
++       12,13,14,15,16,17,
++       16,17,18,19,20,21,
++       20,21,22,23,24,25,
++       24,25,26,27,28,29,
++       28,29,30,31,32, 1,
++};
++
++/*
++ * Set up the key schedule from the key.
++ */
++
++static
++setkey(key)
++char *key;
++{
++       int     i, j, k;
++       int     t;
++       char    *ptr;
++
++       /*
++        * First, generate C and D by permuting
++        * the key.  The low order bit of each
++        * 8-bit char is not used, so C and D are only 28
++        * bits apiece.
++        */
++       for (i=0; i<28; i++) {
++               C[i] = key[PC1_C[i]-1];
++               D[i] = key[PC1_D[i]-1];
++       }
++       /*
++        * To generate Ki, rotate C and D according
++        * to schedule and pick up a permutation
++        * using PC2.
++        */
++       for (i=0; i<16; i++) {
++               /*
++                * rotate.
++                */
++               for (k=0; k<shifts[i]; k++) {
++                       t = C[0];
++                       ptr = C;
++                       for (j=0; j<28-1; j++)
++                       {
++                               *ptr = ptr[1];
++                               ptr++;
++                       }
++                       C[27] = t;
++                       t = D[0];
++                       ptr = D;
++                       for (j=0; j<28-1; j++)
++                       {
++                               *ptr = ptr[1];
++                               ptr++;
++                       }
++                       D[27] = t;
++               }
++               /*
++                * get Ki. Note C and D are concatenated.
++                */
++               ptr = &KS[i][0];
++               for (j=0; j<24; j++) {
++                       ptr[j] = C[PC2_C[j]-1];
++                       ptr[j+24] = D[PC2_D[j]-28-1];
++               }
++       }
++
++       for(i=0;i<48;i++)
++               E[i] = e[i];
++}
++
++/*
++ * The 8 selection functions.
++ * For some reason, they give a 0-origin
++ * index, unlike everything else.
++ */
++static char    S[8][64] = {
++       14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
++        0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
++        4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
++       15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
++
++       15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
++        3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
++        0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
++       13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
++
++       10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
++       13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
++       13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
++        1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
++
++        7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
++       13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
++       10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
++        3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
++
++        2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
++       14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
++        4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
++       11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
++
++       12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
++       10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
++        9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
++        4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
++
++        4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
++       13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
++        1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
++        6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
++
++       13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
++        1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
++        7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
++        2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
++};
++
++/*
++ * P is a permutation on the selected combination
++ * of the current L and key.
++ */
++static char    P[] = {
++       16, 7,20,21,
++       29,12,28,17,
++        1,15,23,26,
++        5,18,31,10,
++        2, 8,24,14,
++       32,27, 3, 9,
++       19,13,30, 6,
++       22,11, 4,25,
++};
++
++/*
++ * The current block, divided into 2 halves.
++ */
++
++static char    L[64];
++#define R   (L + 32)
++static char    tempL[32];
++static char    f[32];
++
++/*
++ * The combination of the key and the input, before selection.
++ */
++static char    preS[48];
++
++/*
++ * The payoff: encrypt a block.
++ */
++
++static
++encrypt (block, edflag)
++char *block;
++{
++       int i, ii;
++       register t, j, k;
++
++       /*
++        * First, permute the bits in the input
++        */
++       for (j=0; j<64; j++)
++               L[j] = block[IP[j]-1];
++       /*
++        * Perform an encryption operation 16 times.
++        */
++       for (ii=0; ii<16; ii++) {
++/*             print_bits ("L R", L); */
++               /*
++                * Set direction
++                */
++               if (edflag)
++                       i = 15-ii;
++               else
++                       i = ii;
++               /*
++                * Save the R array,
++                * which will be the new L.
++                */
++               for (j=0; j<32; j++)
++                       tempL[j] = R[j];
++               /*
++                * Expand R to 48 bits using the E selector;
++                * exclusive-or with the current key bits.
++                */
++               for (j=0; j<48; j++)
++                       preS[j] = R[E[j]-1] ^ KS[i][j];
++               /*
++                * The pre-select bits are now considered
++                * in 8 groups of 6 bits each.
++                * The 8 selection functions map these
++                * 6-bit quantities into 4-bit quantities
++                * and the results permuted
++                * to make an f(R, K).
++                * The indexing into the selection functions
++                * is peculiar; it could be simplified by
++                * rewriting the tables.
++                */
++               for (j=0; j<8; j++) {
++                       t = 6*j;
++                       k = S[j][(preS[t+0]<<5)+
++                               (preS[t+1]<<3)+
++                               (preS[t+2]<<2)+
++                               (preS[t+3]<<1)+
++                               (preS[t+4]<<0)+
++                               (preS[t+5]<<4)];
++                       t = 4*j;
++                       f[t+0] = (k>>3)&01;
++                       f[t+1] = (k>>2)&01;
++                       f[t+2] = (k>>1)&01;
++                       f[t+3] = (k>>0)&01;
++               }
++               /*
++                * The new R is L ^ f(R, K).
++                * The f here has to be permuted first, though.
++                */
++               for (j=0; j<32; j++)
++                       R[j] = L[j] ^ f[P[j]-1];
++               /*
++                * Finally, the new L (the original R)
++                * is copied back.
++                */
++               for (j=0; j<32; j++)
++                       L[j] = tempL[j];
++       }
++       /*
++        * The output L and R are reversed.
++        */
++       for (j=0; j<32; j++) {
++               t = L[j];
++               L[j] = R[j];
++               R[j] = t;
++       }
++       /*
++        * The final output
++        * gets the inverse permutation of the very original.
++        */
++       for (j=0; j<64; j++)
++               block[j] = L[FP[j]-1];
++}
++
++static
++bytes_to_bits (bytes, bits)
++    unsigned char   *bytes;
++    char           *bits;
++{
++    int            bit, byte, value;
++
++    for (byte = 0; byte < 8; byte++)
++    {
++       value = *bytes++;
++       for (bit = 0; bit < 8; bit++)
++           *bits++ = (value >> (7-bit)) & 1;
++    }
++}
++
++static
++bits_to_bytes (bits, bytes)
++    char           *bits;
++    unsigned char   *bytes;
++{
++    int            bit, byte, value;
++
++    for (byte = 0; byte < 8; byte++)
++    {
++       value = 0;
++       for (bit = 0; bit < 8; bit++)
++           value |= *bits++ << (7-bit);
++       *bytes++ = value;
++    }
++}
++
++/*
++ * Interface compatible with Kerberos DES implementation
++ */
++
++# include   "Wrap.h"
++
++/*ARGSUSED*/
++_XdmcpAuthSetup (key, schedule)
++    auth_cblock                key;
++    auth_wrapper_schedule      schedule;
++{
++    char    expand_key[64];
++
++    bytes_to_bits ((unsigned char *) key, expand_key);
++    setkey (expand_key);
++}
++
++/*ARGSUSED*/
++_XdmcpAuthDoIt (input, output, schedule, edflag)
++    auth_cblock                input, output;
++    auth_wrapper_schedule      schedule;
++    int                        edflag;
++{
++    char    expand_input[64];
++
++    bytes_to_bits ((unsigned char *) input, expand_input);
++    encrypt (expand_input, !edflag);
++    bits_to_bytes (expand_input, (unsigned char *) output);
++}
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.4-vncpasswd-filecreation-fix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.4-vncpasswd-filecreation-fix.patch
@@ -0,0 +1,78 @@
+--- vnc-3.3.4-unixsrc/vncpasswd/vncpasswd.c.old	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4-unixsrc/vncpasswd/vncpasswd.c	2002-10-28 20:31:34.000000000 +0100
+@@ -25,9 +25,12 @@
+  *              anyway.
+  */
+ 
++#include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/stat.h>
++#include <sys/types.h>
+ #include <unistd.h>
+ #include <rfb/vncauth.h>
+ 
+@@ -37,24 +40,40 @@
+ }
+ 
+ int main(int argc, char *argv[]) {
++  char *home_env;
+   char *passwd;
+   char *passwd1;
++  char *cp;
++  char passwdDir[256];
+   char passwdFile[256];
+   int i;
+ 
+   if (argc == 1) {
+-      if (getenv("HOME") == NULL) {
+-	  fprintf(stderr,"Error: no HOME environment variable\n");
+-	  exit(1);
+-      }
+-      sprintf(passwdFile,"%s/.vnc/passwd",getenv("HOME"));
++    home_env = getenv("HOME");
++    if (home_env == NULL) {
++      fprintf(stderr,"Error: no HOME environment variable\n");
++      exit(1);
++    }
++    if (strlen(home_env) > 240) {
++      fprintf(stderr,"Error: HOME environment variable string too long\n");
++      exit(1);
++    }
++    sprintf(passwdDir, "%s/.vnc", home_env);
++    sprintf(passwdFile, "%s/passwd", passwdDir);
+ 
+   } else if (argc == 2) {
+-
+-      strcpy(passwdFile,argv[1]);
+-
++    strcpy(passwdFile,argv[1]);
++    strcpy(passwdDir,argv[1]);
++    cp = strrchr(passwdDir, '/');
++    if (cp == 0) {
++	/* no directory part */
++	passwdDir[0] = '\0';
++    } else {
++	/* cut filename */
++	*cp = '\0';
++    }
+   } else {
+-      usage(argv);
++    usage(argv);
+   }
+ 
+   while (1) {  
+@@ -79,6 +98,12 @@
+     }
+ 
+     if (strcmp(passwd1, passwd) == 0) {
++      if (mkdir (passwdDir, (S_IRWXU | S_IRGRP | S_IXGRP |
++ 			     S_IROTH | S_IXOTH)) == -1 &&
++ 	  errno != EEXIST) {
++ 	perror (passwdDir);
++ 	exit (1);
++      }      
+       if (vncEncryptAndStorePasswd(passwd, passwdFile) != 0) {
+ 	fprintf(stderr,"Cannot write password file %s\n",passwdFile);
+ 	exit(1);
--- vnc-3.3.7.orig/debian/patches/1.txt
+++ vnc-3.3.7/debian/patches/1.txt
@@ -0,0 +1,49 @@
+--- vnc-3.3.7.orig/vncviewer/argsresources.c	2003-02-28 19:47:10.000000000 +0100
++++ vnc-3.3.7/vncviewer/argsresources.c	2003-07-18 16:09:25.000000000 +0200
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002-2003 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -261,6 +262,22 @@
+ 
+ 
+ /*
++ * removeArgs() is used to remove some of command line arguments.
++ */
++
++void
++removeArgs(int *argc, char** argv, int idx, int nargs)
++{
++  int i;
++  if ((idx+nargs) > *argc) return;
++  for (i = idx+nargs; i < *argc; i++) {
++    argv[i-nargs] = argv[i];
++  }
++  *argc -= nargs;
++}
++
++
++/*
+  * usage() prints out the usage message.
+  */
+ 
+@@ -272,6 +289,7 @@
+ 	  "       %s [<options>] -listen [<display#>]\n"
+ 	  "\n"
+ 	  "<options> are standard Xt options, or:\n"
++	  "              -via <GATEWAY>\n"
+ 	  "              -shared\n"
+ 	  "              -viewonly\n"
+ 	  "              -fullscreen\n"
+@@ -340,6 +358,8 @@
+   } else {
+     vncServerName = argv[1];
+ 
++    if (!isatty(0))
++      appData.passwordDialog = True;
+     if (vncServerName[0] == '-')
+       usage();
+   }
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3-10-xdm-auth-support.author
+++ vnc-3.3.7/debian/patches/vnc-3.3.3-10-xdm-auth-support.author
@@ -0,0 +1 @@
+Richard Kettlewell <rjk@greenend.org.uk>  Tue, 22 Aug 2000 22:36:48 +0100
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3-x-gdm-fix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.3-x-gdm-fix.patch
@@ -0,0 +1,44 @@
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/os/connection.c	Mon May 11 18:02:17 1998
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/os/connection.c	Thu Dec  6 10:03:32 2001
+@@ -377,20 +377,21 @@
+ #ifndef WIN32
+ /*================================================================
+    BEGIN ORL VNC modification
+    Don't use SIGUSR1 - linuxthread uses this internally */
+ 
+-/* REMOVE
++/* apparently no longer true. */
++
+     if (OsSignal (SIGUSR1, SIG_IGN) == SIG_IGN)
+ 	RunFromSmartParent = TRUE;
+     ParentProcess = getppid ();
+     if (RunFromSmartParent) {
+ 	if (ParentProcess > 0) {
+ 	    kill (ParentProcess, SIGUSR1);
+ 	}
+     }
+-*/
++
+ 
+ /* END ORL VNC modification
+ ================================================================*/
+ #endif
+ #ifdef XDMCP
+@@ -447,17 +448,15 @@
+ #ifndef WIN32
+ /*================================================================
+    BEGIN ORL VNC modification
+    Don't use SIGUSR1 - linuxthread uses this internally */
+ 
+-/* REMOVE
+     if (RunFromSmartParent) {
+ 	if (ParentProcess > 0) {
+ 	    kill (ParentProcess, SIGUSR1);
+ 	}
+     }
+-*/
+ 
+ /* END ORL VNC modification
+ ================================================================*/
+ #endif
+     /*
--- vnc-3.3.7.orig/debian/patches/applythem
+++ vnc-3.3.7/debian/patches/applythem
@@ -0,0 +1,11 @@
+#!/bin/sh
+touch applied-patches
+for A in debian/patches/*.patch debian/patches/debian/*.patch ; do
+    if grep -q " $A" applied-patches ; then
+	echo "Already applied $A."
+    else
+	echo "Applying $A."
+	echo "Applying $A" >> applied-patches
+	patch -p1 < $A
+    fi
+done
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.4-platform-fixes.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.4-platform-fixes.patch
@@ -0,0 +1,2298 @@
+
++ * Permuted-choice 2, to pick out the bits from
++ * the CD array that generate the key schedule.
++ */
++static char    PC2_C[] = {
++       14,17,11,24, 1, 5,
++        3,28,15, 6,21,10,
++       23,19,12, 4,26, 8,
++       16, 7,27,20,13, 2,
++};
++
++static char    PC2_D[] = {
++       41,52,31,37,47,55,
++       30,40,51,45,33,48,
++       44,49,39,56,34,53,
++       46,42,50,36,29,32,
++};
++
++/*
++ * The C and D arrays used to calculate the key schedule.
++ */
++
++static char    C[28];
++static char    D[28];
++
++/*
++ * The key schedule.
++ * Generated from the key.
++ */
++static char    KS[16][48];
++
++/*
++ * The E bit-selection table.
++ */
++static char    E[48];
++static char    e[] = {
++       32, 1, 2, 3, 4, 5,
++        4, 5, 6, 7, 8, 9,
++        8, 9,10,11,12,13,
++       12,13,14,15,16,17,
++       16,17,18,19,20,21,
++       20,21,22,23,24,25,
++       24,25,26,27,28,29,
++       28,29,30,31,32, 1,
++};
++
++/*
++ * Set up the key schedule from the key.
++ */
++
++static
++setkey(key)
++char *key;
++{
++       int     i, j, k;
++       int     t;
++       char    *ptr;
++
++       /*
++        * First, generate C and D by permuting
++        * the key.  The low order bit of each
++        * 8-bit char is not used, so C and D are only 28
++        * bits apiece.
++        */
++       for (i=0; i<28; i++) {
++               C[i] = key[PC1_C[i]-1];
++               D[i] = key[PC1_D[i]-1];
++       }
++       /*
++        * To generate Ki, rotate C and D according
++        * to schedule and pick up a permutation
++        * using PC2.
++        */
++       for (i=0; i<16; i++) {
++               /*
++                * rotate.
++                */
++               for (k=0; k<shifts[i]; k++) {
++                       t = C[0];
++                       ptr = C;
++                       for (j=0; j<28-1; j++)
++                       {
++                               *ptr = ptr[1];
++                               ptr++;
++                       }
++                       C[27] = t;
++                       t = D[0];
++                       ptr = D;
++                       for (j=0; j<28-1; j++)
++                       {
++                               *ptr = ptr[1];
++                               ptr++;
++                       }
++                       D[27] = t;
++               }
++               /*
++                * get Ki. Note C and D are concatenated.
++                */
++               ptr = &KS[i][0];
++               for (j=0; j<24; j++) {
++                       ptr[j] = C[PC2_C[j]-1];
++                       ptr[j+24] = D[PC2_D[j]-28-1];
++               }
++       }
++
++       for(i=0;i<48;i++)
++               E[i] = e[i];
++}
++
++/*
++ * The 8 selection functions.
++ * For some reason, they give a 0-origin
++ * index, unlike everything else.
++ */
++static char    S[8][64] = {
++       14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
++        0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
++        4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
++       15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
++
++       15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
++        3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
++        0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
++       13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
++
++       10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
++       13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
++       13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
++        1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
++
++        7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
++       13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
++       10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
++        3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
++
++        2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
++       14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
++        4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
++       11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
++
++       12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
++       10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
++        9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
++        4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
++
++        4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
++       13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
++        1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
++        6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
++
++       13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
++        1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
++        7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
++        2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
++};
++
++/*
++ * P is a permutation on the selected combination
++ * of the current L and key.
++ */
++static char    P[] = {
++       16, 7,20,21,
++       29,12,28,17,
++        1,15,23,26,
++        5,18,31,10,
++        2, 8,24,14,
++       32,27, 3, 9,
++       19,13,30, 6,
++       22,11, 4,25,
++};
++
++/*
++ * The current block, divided into 2 halves.
++ */
++
++static char    L[64];
++#define R   (L + 32)
++static char    tempL[32];
++static char    f[32];
++
++/*
++ * The combination of the key and the input, before selection.
++ */
++static char    preS[48];
++
++/*
++ * The payoff: encrypt a block.
++ */
++
++static
++encrypt (block, edflag)
++char *block;
++{
++       int i, ii;
++       register t, j, k;
++
++       /*
++        * First, permute the bits in the input
++        */
++       for (j=0; j<64; j++)
++               L[j] = block[IP[j]-1];
++       /*
++        * Perform an encryption operation 16 times.
++        */
++       for (ii=0; ii<16; ii++) {
++/*             print_bits ("L R", L); */
++               /*
++                * Set direction
++                */
++               if (edflag)
++                       i = 15-ii;
++               else
++                       i = ii;
++               /*
++                * Save the R array,
++                * which will be the new L.
++                */
++               for (j=0; j<32; j++)
++                       tempL[j] = R[j];
++               /*
++                * Expand R to 48 bits using the E selector;
++                * exclusive-or with the current key bits.
++                */
++               for (j=0; j<48; j++)
++                       preS[j] = R[E[j]-1] ^ KS[i][j];
++               /*
++                * The pre-select bits are now considered
++                * in 8 groups of 6 bits each.
++                * The 8 selection functions map these
++                * 6-bit quantities into 4-bit quantities
++                * and the results permuted
++                * to make an f(R, K).
++                * The indexing into the selection functions
++                * is peculiar; it could be simplified by
++                * rewriting the tables.
++                */
++               for (j=0; j<8; j++) {
++                       t = 6*j;
++                       k = S[j][(preS[t+0]<<5)+
++                               (preS[t+1]<<3)+
++                               (preS[t+2]<<2)+
++                               (preS[t+3]<<1)+
++                               (preS[t+4]<<0)+
++                               (preS[t+5]<<4)];
++                       t = 4*j;
++                       f[t+0] = (k>>3)&01;
++                       f[t+1] = (k>>2)&01;
++                       f[t+2] = (k>>1)&01;
++                       f[t+3] = (k>>0)&01;
++               }
++               /*
++                * The new R is L ^ f(R, K).
++                * The f here has to be permuted first, though.
++                */
++               for (j=0; j<32; j++)
++                       R[j] = L[j] ^ f[P[j]-1];
++               /*
++                * Finally, the new L (the original R)
++                * is copied back.
++                */
++               for (j=0; j<32; j++)
++                       L[j] = tempL[j];
++       }
++       /*
+--- vnc-3.3.3r2.orig/Xvnc/Makefile
++++ vnc-3.3.3r2/Xvnc/Makefile
+@@ -18,7 +18,7 @@
+ DEPENDTOP = ../..
+ IMAKETOP = ../..
+ IRULESRC = $(CONFIGSRC)/cf
+-IMAKE = $(IMAKESRC)/imake
++IMAKE = imake
+ IMAKE_CMD = $(IMAKE) -I$(IRULESRC) $(IMAKE_DEFINES)
+ MAKE_OPTS = -f xmakefile
+ MAKE_CMD = $(MAKE) $(MAKE_OPTS)
+--- vnc-3.3.3r2.orig/Xvnc/config/cf/Imake.cf
++++ vnc-3.3.3r2/Xvnc/config/cf/Imake.cf
+@@ -1,5 +1,4 @@
+-XCOMM $TOG: Imake.cf /main/28 1997/06/25 08:31:36 barstow $
+-XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.34.2.3 1997/07/27 02:41:02 dawes Exp $
++XCOMM $Xorg: Imake.cf,v 1.4 2000/08/17 19:41:45 cpqbld Exp $
+ /*
+  * To add support for another platform:
+  * 
+@@ -18,6 +17,22 @@
+  *
+  *     4.  Create a .cf file with the name given by MacroFile.
+  */
++XCOMM $XFree86: xc/config/cf/Imake.cf,v 3.66 2001/04/18 16:13:17 dawes Exp $
++
++#if defined(__APPLE__)
++# undef __APPLE__
++# define MacroIncludeFile <darwin.cf>
++# define MacroFile darwin.cf
++# define DarwinArchitecture
++# ifdef __ppc__
++#  define PpcDarwinArchitecture
++#  undef __ppc__
++# endif
++# ifdef __i386__
++#  define i386DarwinArchitecture
++#  undef __i386__
++# endif
++#endif
+ 
+ #if defined(clipper) || defined(__clipper__)
+ # undef clipper
+@@ -26,6 +41,17 @@
+ # define IngrArchitecture
+ #endif /* clipper */
+ 
++#ifdef __CYGWIN__
++#define MacroIncludeFile <cygwin.cf>
++#define MacroFile cygwin.cf
++#define cygwinArchitecture
++#define i386Architecture
++#undef i386
++#undef __i386__
++#undef _X86_
++#undef __CYGWIN__
++#endif /* CYGWIN */
++
+ #ifdef ultrix
+ # define MacroIncludeFile <ultrix.cf>
+ # define MacroFile ultrix.cf
+@@ -36,6 +62,7 @@
+ # ifdef mips
+ #  undef mips
+ #  define MipsArchitecture
++#  define MipselArchitecture
+ # endif
+ # undef ultrix
+ # define UltrixArchitecture
+@@ -53,10 +80,19 @@
+ # define MacroIncludeFile <bsdi.cf>
+ # define MacroFile bsdi.cf
+ # undef bsdi
+-# define BSD386Architecture
+-# define i386BsdArchitecture
+-# define i386Architecture
+-# undef i386
++# define BSDOSArchitecture
++# if defined(__i386__) || defined(i386)
++#  define i386BsdArchitecture
++#  define i386Architecture
++#  undef i386
++#  undef __i386__
++# endif
++# if defined(__sparc__) || defined(__sparc_v9__) || defined(sparc)
++#  define SparcArchitecture
++#  undef sparc
++#  undef __sparc__
++#  undef __sparc_v9__
++# endif
+ #endif /* bsdi */
+ 
+ #ifdef __OpenBSD__
+@@ -114,6 +150,10 @@
+ #  endif
+ #  undef mc68000
+ # endif
++# ifdef __powerpc__
++#  define PpcArchitecture
++#  undef __powerpc__
++# endif
+ #endif /* OpenBSD */
+ 
+ #ifdef __NetBSD__
+@@ -142,6 +182,18 @@
+ # ifdef mc68000
+ #   define Mc68020Architecture
+ # endif
++# ifdef __arm32__
++#   define Arm32Architecture
++#   undef __arm32__
++# endif
++# ifdef __vax__
++#   define VaxArchitecture
++#   undef __vax__
++# endif
++# ifdef __powerpc__
++#   define PpcArchitecture
++#   undef __powerpc__
++# endif
+ #endif /* NetBSD */
+ 
+ #ifdef __FreeBSD__
+@@ -154,6 +206,11 @@
+ #  define i386Architecture
+ #  undef i386
+ # endif
++# ifdef __alpha__
++#  define AlphaBsdArchitecture
++#  define AlphaArchitecture
++#  undef __alpha__
++# endif
+ #endif /* __FreeBSD__ */
+ 
+ #ifdef AMOEBA
+@@ -319,6 +376,7 @@
+ # undef sgi
+ # define SGIArchitecture
+ # undef mips
++# undef __mips
+ # define MipsArchitecture
+ # ifdef _SVR4
+ #  undef _SVR4
+@@ -400,7 +458,7 @@
+ # endif
+ #endif /* MOTOROLA */
+ 
+-#ifdef SVR4
++#if defined(SVR4) && !defined(DGUX)
+ # ifdef i386
+ #  define i386Architecture
+ #  undef i386
+@@ -494,6 +552,8 @@
+ #endif /* SYSV386 */
+ 
+ #ifdef DGUX
++# define i386Architecture
++# define SVR4Architecture
+ # define MacroIncludeFile <DGUX.cf>
+ # define MacroFile DGUX.cf
+ # undef DGUX
+@@ -517,6 +577,7 @@
+ # ifdef __mips__
+ #  undef __mips__
+ #  define MipsArchitecture
++#  define MipselArchitecture
+ # endif
+ # ifdef __alpha
+ #  undef __alpha
+@@ -545,17 +606,201 @@
+ # undef linux
+ # define LinuxArchitecture
+ # ifdef i386
+-#  define i386Architecture
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
+ #  undef i386
+-# endif /* i386 */
++XCOMM Keep cpp from replacing path elements containing i486/i586/i686
++#  ifdef i486
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#   undef i486
++#  endif
++#  ifdef i586
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#   undef i586
++#  endif
++#  ifdef i686
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#   undef i686
++#  endif
++#  ifdef k6
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#   undef k6
++#  endif
++# endif /* k6 */
++# ifdef __i386__
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i386__
++# endif /* __i386__ */
++# ifdef __i486__
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i486__
++# endif /* __i486__ */
++# ifdef __i586__
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i586__
++# endif /* __i586__ */
++# ifdef __i686__
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i686__
++# endif /* __i686__ */
++# ifdef __k6__
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __k6__
++# endif /* __k6__ */
++# ifdef __i386
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i386
++# endif /* __i386 */
++# ifdef __i486
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i486
++# endif /* __i486 */
++# ifdef __i586
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i586
++# endif /* __i586 */
++# ifdef __i686
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __i686
++# endif /* __i686 */
++# ifdef __k6
++#  ifndef i386Architecture
++#   define i386Architecture
++#  endif
++#  undef __k6
++# endif /* __k6 */
++# ifdef __s390__
++#   define s390Architecture
++#  undef __s390__
++# endif /* s390 */
+ # ifdef __alpha
+ #  define AlphaArchitecture
+ #  undef __alpha
+ # endif /* __alpha */
++# ifdef __alpha__
++#  ifndef AlphaArchitecture
++#   define AlphaArchitecture
++#  endif
++#  undef __alpha__
++# endif /* __alpha__ */
++# ifdef __arm__
++#  define Arm32Architecture
++#  undef arm
++#  undef __arm
++#  undef __arm__
++# endif
+ # ifdef mc68000
+ #  define Mc68020Architecture
+ #  undef mc68000
+ # endif /* mc68000 */
++# ifdef powerpc
++#  define PpcArchitecture
++#  undef powerpc
++# endif
++# ifdef __powerpc__
++#  ifndef PpcArchitecture
++#   define PpcArchitecture
++#  endif
++#  undef __powerpc__
++# endif
++# ifdef sparc
++#  define SparcArchitecture
++#  undef sparc
++# endif
++# ifdef __sparc__
++#  ifndef SparcArchitecture
++#   define SparcArchitecture
++#  endif
++#  undef __sparc__
++# endif
++# ifdef ia64 
++#  define ia64Architecture
++#  undef ia64 
++# endif
++# ifdef __ia64__
++#  ifndef ia64Architecture
++#   define ia64Architecture
++#  endif
++#  undef __ia64__
++# endif
++# if defined(mips) || defined(__mips__)
++#  define MipsArchitecture
++#  undef mips
++#  undef __mips__
++#  if defined(MIPSEL) || defined(_MIPSEL)
++#   define MipselArchitecture
++#  endif
++#  undef MIPSEL
++#  undef _MIPSEL
++# endif
++# ifdef __hppa__
++#  ifndef HPArchitecture
++#   define HPArchitecture
++#  endif
++#  undef __hppa__
++# endif /* __hppa__ */
++# ifdef __sh__
++#  ifndef SuperHArchitecture
++#   define SuperHArchitecture
++#  endif
++#  ifdef __BIG_ENDIAN__
++#   ifndef SuperHebArchitecture
++#    define SuperHebArchitecture
++#   endif
++#  endif
++#  undef __sh__
++# endif /* __sh__ */
++# if defined(__SH3__) || defined(__sh3__)
++#  ifndef SuperH3Architecture
++#   define SuperH3Architecture
++#  endif
++#  undef __SH3__
++#  undef __sh3__
++# endif /* __SH3__ or __sh3__ */
++# ifdef __SH4__
++#  ifdef __SH4_NOFPU__
++#   ifndef SuperH4NOFPUArchitecture
++#    define SuperH4NOFPUArchitecture
++#   endif
++#   undef __SH4_NOFPU__
++#  else
++#   ifndef SuperH4Architecture
++#    define SuperH4Architecture
++#   endif
++#  endif
++#  undef __SH4__
++# endif /* __SH4__ */
++XCOMM  for compatibility with 3.3.x 
++# ifdef PpcArchitecture
++#  define PowerPCArchitecture
++# endif
+ #endif /* linux */
+ 
+ #if (defined(__Lynx__) || defined(Lynx)) && (defined(i386) || defined(__i386__) || defined(__x86__) || defined(__powerpc__) || defined(__sparc__) || defined(sparc))
+@@ -572,7 +817,7 @@
+ #  undef __x86__
+ # endif
+ # ifdef __powerpc__
+-#  define ppcArchitecture
++#  define PpcArchitecture
+ #  undef __powerpc__
+ # endif
+ # if defined(sparc) || defined(__sparc__)
+@@ -580,6 +825,10 @@
+ #  undef sparc
+ #  undef __sparc__
+ # endif
++/* for compatibility with 3.3.x */
++# ifdef PpcArchitecture
++#  define PowerPCArchitecture
++# endif
+ #endif /* LynxOS AT/PPC/microSPARC */
+ 
+ #ifdef __uxp__
+@@ -603,17 +852,14 @@
+ # define mc68000Architecture
+ #endif /* __sxg__ */
+ 
+-#if defined(sequent) || defined(_SEQUENT_)
++#ifdef _SEQUENT_
++/* undefine assignments resulting from -DSVR4 */
++# undef MacroIncludeFile
+ # define MacroIncludeFile <sequent.cf>
++# undef MacroFile
+ # define MacroFile sequent.cf
+-# ifdef sequent
+-#  undef sequent
+-#  define Dynix3Architecture
+-# endif
+-# ifdef _SEQUENT_
+-#  undef _SEQUENT_
+-#  define DynixPtxArchitecture
+-# endif
++# undef _SEQUENT_
++# define DynixPtxArchitecture
+ # define SequentArchitecture
+ #endif
+ 
+@@ -635,8 +881,14 @@
+ #endif /* minix */
+ 
+ #ifdef MACH
++#ifdef __GNU__
++#define MacroIncludeFile <gnu.cf>
++#define MacroFile gnu.cf
++#define GNUMachArchitecture
++#else
+ #define MacroIncludeFile <mach.cf>
+ #define MacroFile mach.cf
++#endif
+ #undef MACH
+ #ifdef	i386
+ #define i386MachArchitecture
+@@ -645,6 +897,14 @@
+ #undef i386
+ #endif /* MACH */
+ 
++/* On NetBSD, `unix' is not defined, and cpp emits a warning every time
++ * it sees a test using the `unix' symbol */
++#if !defined(NetBSDArchitecture) || (defined(NetBSDArchitecture) && DefaultOSMajorVersion == 1 && DefaultOSMinorVersion <= 3)
++#ifdef unix
++#undef unix
++#endif
++#endif
++
+ #ifdef emxos2
+ #define MacroIncludeFile <os2.cf>
+ #define MacroFile os2.cf
+@@ -652,6 +912,39 @@
+ #define i386Architecture
+ #endif /* emxos2 */
+ 
++#if defined(__QNX__) && !defined(__QNXNTO__)
++#define MacroIncludeFile <QNX4.cf>
++#define MacroFile QNX4.cf
++#define QNX4Architecture
++#define i386Architecture
++#endif /* QNX4 */
++
++#ifdef __QNXNTO__
++#define MacroIncludeFile <nto.cf>
++#define MacroFile nto.cf
++#define NTOArchitecture
++#ifdef PPC
++# define PPCArchitecture
++# undef PPC
++#else
++#ifdef MIPS
++# define mipsArchitecture
++# undef MIPS
++#else
++#ifdef i386
++# define i386Architecture
++# undef i386
++#endif
++#endif
++#endif
++#endif /* QNX/Neutrino */
++
++#ifdef SparcArchitecture
++# if defined(__sparc_v9) || defined(__arch64__)
++#  define Sparc64Architecture
++# endif
++#endif
++
+ #ifndef MacroIncludeFile
+ XCOMM WARNING:  Imake.cf not configured; guessing at definitions!!!
+ XCOMM This might mean that BOOTSTRAPCFLAGS was not set when building imake.
+--- vnc-3.3.3r2.orig/Xvnc/config/cf/xfree86.cf
++++ vnc-3.3.3r2/Xvnc/config/cf/xfree86.cf
+@@ -73,6 +73,14 @@
+ #ifndef XF86I128Server
+ #define XF86I128Server		YES
+ #endif
++#ifndef XF86GLINTServer
++#define XF86GLINTServer		YES
++#endif
++#if defined(LinuxArchitecture)
++#ifndef XF86FBDevServer
++#define XF86FBDevServer		YES
++#endif
++#endif
+ #endif
+ 
+ /*
+@@ -101,12 +109,26 @@
+ #ifndef XF86SVGAServer
+ #define XF86SVGAServer		YES
+ #endif
++#ifndef XF86VGA16Server
++#define XF86VGA16Server		YES
++#endif
+ #ifndef XF86MonoServer
+ #define XF86MonoServer		YES
+ #endif
++#ifndef XF86GLINTServer
++#define XF86GLINTServer		YES
++#endif
++#if defined(LinuxArchitecture)
++#ifndef XF86FBDevServer
++#define XF86FBDevServer		YES
++#endif
++#endif
+ #ifndef XF86SvgaDrivers
+ #define XF86SvgaDrivers		mga s3v
+ #endif
++#ifndef XF86Vga16Drivers
++#define XF86Vga16Drivers	generic
++#endif
+ #ifndef XF86Vga2Drivers
+ #define XF86Vga2Drivers		generic
+ #endif
+@@ -119,16 +141,104 @@
+ #ifdef Mc68020Architecture
+ #ifndef XF68FBDevServer
+ #define XF68FBDevServer		YES
++#define XF68FBDev77C32		NO
++#define XF68FBDevIMSTT		NO
++#define XF68FBDevMach64		NO
++#define XF68FBDevPermedia2	NO
++#endif
++#ifndef BuildXF86Setup
++#define BuildXF86Setup		NO
+ #endif
+ #endif
+ 
+-/* 
++/*
++ * For ARM platforms, the default is to build all X servers which
++ * are supported on this platform.
++ */
++#ifdef ArmArchitecture
++#ifndef XF68FBDevServer
++#define XF68FBDevServer		YES
++#define XF68FBDevCFB8		YES
++#define XF68FBDevCFB16		YES
++#define XF68FBDevCFB24		YES
++#define XF68FBDevCFB32		YES
++#define XF68FBDevIPLAN2p2	NO
++#define XF68FBDevIPLAN2p4	NO
++#define XF68FBDevIPLAN2p8	NO
++#define XF68FBDevILBM		NO
++#define XF68FBDevAFB		NO
++#define XF68FBDev77C32		NO
++#define XF68FBDevMach64		NO
++#define XF68FBDevIMSTT		NO
++#define XF68FBDevPermedia2	NO
++#endif
++#ifndef BuildXF86Setup
++#define BuildXF86Setup		NO
++#endif
++#endif
++
++/*
+  * For Mips/Arc platforms, the default is to build all X servers which
+- * are supported on this platform. 
++ * are supported on this platform.
+  */
+ #ifdef ArcArchitecture
+ #ifndef XF86S3Server
+-#define XF86S3Server          YES
++#define XF86S3Server		YES
++#endif
++#if defined(LinuxArchitecture)
++#ifndef XF86FBDevServer
++#define XF86FBDevServer		YES
++#endif
++#endif
++#ifndef BuildXF86Setup
++#define BuildXF86Setup		NO
++#endif
++#endif
++
++/*
++ * For PowerPC platforms, the default is to build all X servers which
++ * are supported on this platform.
++ */
++#ifdef PowerPCArchitecture
++#ifndef XF86SVGAServer
++#define XF86SVGAServer		NO
++#endif
++#ifndef XF86VGA16Server
++#define XF86VGA16Server		NO
++#endif
++#ifndef XF86S3Server
++#define XF86S3Server		NO
++#endif
++#ifndef XF68FBDevServer
++#define XF68FBDevServer		YES
++#define XF68FBDevCFB8		YES
++#define XF68FBDevCFB16		YES
++#define XF68FBDevCFB24		NO
++#define XF68FBDevCFB32		YES
++#define XF68FBDevIPLAN2p2	NO
++#define XF68FBDevIPLAN2p4	NO
++#define XF68FBDevIPLAN2p8	NO
++#define XF68FBDevILBM		NO
++#define XF68FBDevAFB		YES
++#define XF68FBDev77C32		YES
++#define XF68FBDevIMSTT		YES
++#define XF68FBDevMach64		YES
++#define XF68FBDevPermedia2	YES
++#endif
++#ifndef BuildXF86Setup
++#define BuildXF86Setup		NO
++#endif
++#endif
++
++/* For SPARC PCI platforms, the default is to build all X servers which are
++ * supported on this platform.
++ */
++#ifdef SparcArchitecture
++#ifndef XF86Mach64Server
++#define XF86Mach64Server	YES
++#endif
++#ifndef BuildXF86Setup
++#define BuildXF86Setup		NO
+ #endif
+ #endif
+ 
+@@ -189,6 +299,10 @@
+ # define XF86I128Server		NO
+ #endif
+ 
++#ifndef XF86GLINTServer
++# define XF86GLINTServer	NO
++#endif
++
+ #ifndef XF86TGAServer
+ # define XF86TGAServer		NO
+ #endif
+@@ -253,6 +367,12 @@
+ # define XF86I128Dir		/**/
+ #endif
+ 
++#if XF86GLINTServer
++# define XF86GLINTDir		glint
++#else
++# define XF86GLINTDir		/**/
++#endif
++
+ #if XF86TGAServer
+ # define XF86TGADir		tga
+ #else
+@@ -347,12 +467,13 @@
+ #define XF86AccelServerDirs	XF86S3Dir XF86S3VDir XF86I8514Dir \
+ 				XF86Mach8Dir XF86Mach32Dir XF86Mach64Dir \
+ 				XF86P9000Dir XF86AGXDir XF86W32Dir \
+-				XF86I128Dir XF86TGADir
++				XF86I128Dir XF86GLINTDir XF86TGADir
+ 
+ #undef XF86AccelServer
+ #if XF86S3Server || XF86S3VServer || XF86I8514Server || XF86Mach8Server || \
+     XF86Mach32Server || XF86Mach64Server || XF86P9000Server || \
+-    XF86AGXServer || XF86W32Server || XF86I128Server || XF86TGAServer
++    XF86AGXServer || XF86W32Server || XF86I128Server || XF86TGAServer || \
++    XF86GLINTServer
+ # define XF86AccelServer	YES
+ #else
+ # define XF86AccelServer	NO
+@@ -373,12 +494,21 @@
+  */
+ #ifndef XF86SvgaDrivers
+ # ifdef AlphaArchitecture
+-#  define XF86SvgaDrivers	mga tvga8900 s3v
++#  define XF86SvgaDrivers	mga tvga8900 s3v nv
+ # else
+-#  define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga ati sis tvga8900 \
++#  if defined(LinuxArchitecture)
++#   define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga r128 ati sis tvga8900 \
++				cirrus ncr77c22 compaq mga oak al2101 \
++				ali cl64xx video7 ark mx realtek s3_savage s3v apm \
++				s3_svga neo chips cyrix rendition p9x00 \
++				spc8110 i740 i810 tdfx smi generic
++#  else
++#   define XF86SvgaDrivers	nv et4000 et3000 pvga1 gvga r128 ati sis tvga8900 \
+ 				cirrus ncr77c22 compaq mga oak al2101 \
+-				ali cl64xx video7 ark mx realtek apm \
+-				s3v s3_svga chips generic
++				ali cl64xx video7 ark mx realtek s3v apm \
++				s3_svga neo chips cyrix rendition p9x00 \
++				spc8110 i740 i810 tdfx smi generic
++#  endif
+ # endif
+ #endif
+ 
+@@ -429,7 +559,7 @@
+ # define XF86W32Drivers		et4000w32
+ #endif
+ 
+-#if XF68FBDevServer
++#if XF68FBDevServer || XF86FBDevServer
+ # ifndef XF68FBDevIPLAN2p2
+ #  define XF68FBDevIPLAN2p2	YES
+ # endif
+@@ -449,10 +579,30 @@
+ #  define XF68FBDevCFB8		YES
+ # endif
+ # ifndef XF68FBDevCFB16
+-#  define XF68FBDevCFB16	NO
++#  define XF68FBDevCFB16	YES
++# endif
++# ifndef XF68FBDevCFB24
++#  if defined(i386Architecture) || defined(AlphaArchitecture)
++#   define XF68FBDevCFB24	YES
++#  else
++#   define XF68FBDevCFB24	NO
++#  endif
+ # endif
+ # ifndef XF68FBDevCFB32
+-#  define XF68FBDevCFB32	NO
++#  define XF68FBDevCFB32	YES
++# endif
++/* Accelerated stuff */
++# ifndef XF68FBDev77C32
++#  define XF68FBDev77C32	YES
++# endif
++# ifndef XF68FBDevIMSTT
++#  define XF68FBDevIMSTT	YES
++# endif
++# ifndef XF68FBDevMach64
++#  define XF68FBDevMach64	YES
++# endif
++# ifndef XF68FBDevPermedia2
++#  define XF68FBDevPermedia2	YES
+ # endif
+ #else
+ # ifndef XF68FBDevIPLAN2p2
+@@ -476,9 +626,24 @@
+ # ifndef XF68FBDevCFB16
+ #  define XF68FBDevCFB16	NO
+ # endif
++# ifndef XF68FBDevCFB24
++#  define XF68FBDevCFB24	NO
++# endif
+ # ifndef XF68FBDevCFB32
+ #  define XF68FBDevCFB32	NO
+ # endif
++# ifndef XF68FBDev77C32
++#  define XF68FBDev77C32	NO
++# endif
++# ifndef XF68FBDevIMSTT
++#  define XF68FBDevIMSTT	NO
++# endif
++# ifndef XF68FBDevMach64
++#  define XF68FBDevMach64	NO
++# endif
++# ifndef XF68FBDevPermedia2
++#  define XF68FBDevPermedia2	NO
++# endif
+ #endif
+ 
+ #ifndef XnestServer
+@@ -519,7 +684,7 @@
+ #if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
+     XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
+     XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
+-    XF98MGAServer || XF98SVGAServer
++    XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
+ #define BuildPexExt		YES
+ #else
+ #define BuildPexExt		NO
+@@ -535,7 +700,7 @@
+ #  if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
+       XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
+       XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
+-      XF98MGAServer || XF98SVGAServer
++      XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
+ #    define BuildGlxExt             YES
+ #  else
+ #    define BuildGlxExt             NO
+@@ -550,7 +715,7 @@
+ #if XF86AccelServer || XF86SVGAServer || XF98AccelServer || \
+     XF98GANBWAPServer || XF98NEC480Server || XF98NKVNECServer || \
+     XF98WABSServer || XF98WABEPServer || XF98WSNAServer || XF98TGUIServer || \
+-    XF98MGAServer || XF98SVGAServer
++    XF98MGAServer || XF98SVGAServer || XF68FBDevServer || XF86FBDevServer
+ #define BuildXIE		YES
+ #else
+ #define BuildXIE		NO
+@@ -591,14 +756,33 @@
+ #define WacomSupport		YES
+ #endif
+ #ifndef ElographicsSupport
+-#define ElographicsSupport	YES 
++#define ElographicsSupport	YES
++#endif
++#ifndef DynaproSupport
++#define DynaproSupport		YES
++#endif
++#ifndef MicroTouchSupport
++#define MicroTouchSupport	YES
+ #endif
+ #ifndef SummaSketchSupport
+ #define SummaSketchSupport	YES
+ #endif
++#ifndef AceCadSupport
++#define AceCadSupport		YES
++#endif
++#ifndef DialBoxSupport
++#if SystemV || SystemV4
++#define DialBoxSupport		NO
++#else
++#define DialBoxSupport		YES
++#endif
++#endif
+ #ifndef JoystickSupport
+ #define JoystickSupport		NO
+ #endif
++#ifndef CalcompSupport
++#define CalcompSupport		YES
++#endif
+ 
+ /*
+  * Build the extra extension libs even when not including the extra extensions
+@@ -645,6 +829,17 @@
+ #endif
+ #endif
+ 
++/*
++ * Build Japanese versions of XF86Setup -- needs Japanised Tk and Tcl
++ */
++#ifndef BuildJpXF86Setup
++#if HasJpTk && HasJpTcl && BuildXF86VidModeLibrary && BuildXF86MiscLibrary && BuildXKBlib
++#define BuildJpXF86Setup		YES
++#else
++#define BuildJpXF86Setup		NO
++#endif
++#endif
++
+ #ifndef XF86SetupUsesStaticTk
+ #define XF86SetupUsesStaticTk		YES
+ #endif
+@@ -653,13 +848,6 @@
+ #endif
+ 
+ /*
+- * Build the XKBui lib if building XF86Setup
+- */
+-#ifndef BuildXKBuilib
+-#define BuildXKBuilib			BuildXF86Setup
+-#endif
+-
+-/*
+  * Build the XFree86 DGA support
+  */
+ #ifndef BuildXF86DGA
+@@ -728,10 +916,17 @@
+ #endif
+ 
+ /*
++ * By default, create the local font directory
++ */
++#ifndef MakeLocalFontDir
++#define MakeLocalFontDir	YES
++#endif
++
++/*
+  * Build scanpci?
+  */
+ #ifndef BuildScanpci
+-#if SystemV || SystemV4 || (defined(LinuxArchitecture) && !defined(Mc68020Architecture)) || defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || defined(OS2Architecture)
++#if SystemV || SystemV4 || (defined(LinuxArchitecture) && !defined(Mc68020Architecture) && !defined(PowerPCArchitecture) && !defined(ArmArchitecture)) || defined(i386BsdArchitecture) || defined(LynxOSArchitecture) || defined(OS2Architecture)
+ #define BuildScanpci		YES
+ #else
+ #define BuildScanpci		NO
+@@ -789,6 +984,15 @@
+ #endif
+ #endif
+ 
++/* Support for USB mouse */
++#ifndef UsbMouseSupport
++#define UsbMouseSupport	NO
++#endif
++/* Does this OS has libusb ? */
++#ifndef HasLibUsb
++#define HasLibUsb	NO
++#endif
++
+ #ifndef UseServerLock
+ #define UseServerLock	YES
+ #endif
+@@ -1017,4 +1221,8 @@
+ #define XF86Contrib
+ #endif
+ 
++#ifndef HasMktemp
++#define HasMktemp	YES
++#endif
++
+ #include <xf86.rules>
+--- vnc-3.3.3r2.orig/Xvnc/config/imake/imakemdep.h
++++ vnc-3.3.3r2/Xvnc/config/imake/imakemdep.h
+@@ -465,6 +465,9 @@
+ # ifdef __i386__
+ 	"-D__i386__",
+ # endif
++# ifdef __s390__
++	"-D__s390__",
++# endif
+ # ifdef __GNUC__
+ 	"-traditional",
+ # endif
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/os/xalloc.c
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/os/xalloc.c
+@@ -172,7 +172,7 @@
+ #define SIZE_STEPS		(sizeof(double))
+ #define SIZE_HEADER		(2*sizeof(long)) /* = sizeof(double) for 32bit */
+ #ifdef XALLOC_DEBUG
+-#if defined(__sparc__)
++#if defined(__sparc__) || defined(__hppa__)
+ #define SIZE_TAIL		(2*sizeof(long)) /* = sizeof(double) for 32bit */
+ #else
+ #define SIZE_TAIL		(sizeof(long))
+@@ -309,7 +309,7 @@
+     }
+ 
+     /* alignment check */
+-#if defined(__alpha__) || defined(__sparc__) || defined(__mips__)
++#if defined(__alpha__) || defined(__sparc__) || defined(__mips__) || defined(__hppa__)
+     amount = (amount + (sizeof(long)-1)) & ~(sizeof(long)-1);
+ #endif
+ 
+@@ -390,7 +390,13 @@
+ 		ptr[1] = MAGIC;
+ #endif /* XALLOC_DEBUG */
+ #ifdef SIZE_TAIL
++# ifdef __hppa__
++		/* reserved space for 2 * sizeof(long), so use correct one */
++		/* see SIZE_TAIL macro */
++		((unsigned long *)((char *)ptr + amount))[-2] = MAGIC2;
++# else
+ 		((unsigned long *)((char *)ptr + amount))[-1] = MAGIC2;
++# endif /* __hppa__ */
+ #endif /* SIZE_TAIL */
+ 		ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
+ 		LOG_ALLOC("Xalloc-L", amount, ptr);
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/os/rpcauth.c
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/os/rpcauth.c
+@@ -38,6 +38,7 @@
+ 
+ #ifdef SECURE_RPC
+ 
++#include <stdlib.h>
+ #include "X.h"
+ #include "Xauth.h"
+ #include "misc.h"
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/cfb/stipsparc.s
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/cfb/stipsparc.s
+@@ -85,7 +85,7 @@
+ #define ForEachBits	LY4
+ #define NextBits	LY5
+ 
+-#ifdef SVR4
++#if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
+ #ifdef TETEXT
+ #define	_cfbStippleStack	cfbStippleStackTE
+ #else
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/cfb/stipsprc32.s
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/cfb/stipsprc32.s
+@@ -81,7 +81,7 @@
+ #define ForEachBits	LY4
+ #define NextBits	LY5
+ 
+-#ifdef SVR4
++#if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
+ #ifdef TETEXT
+ #define	_cfb32StippleStack	cfb32StippleStackTE
+ #else
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/include/servermd.h
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/include/servermd.h
+@@ -336,7 +336,7 @@
+ 
+ #endif /* luna */
+ 
+-#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !defined(__mc68000__)) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
++#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !(defined(__mc68000__) || defined(PPC) || defined(__sparc__) || defined(__s390__))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
+ 
+ #ifndef IMAGE_BYTE_ORDER
+ #define IMAGE_BYTE_ORDER	LSBFirst
+@@ -381,6 +381,48 @@
+ 
+ #endif /* linux/m68k */
+ 
++#if defined (linux) && defined (PPC)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#define LARGE_INSTRUCTION_CACHE
++#define FAST_CONSTANT_OFFSET_MODE
++
++#endif /* linux/PPC */
++
++#if defined (linux) && defined (__sparc__)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#endif /* linux/__sparc__ */
++
++#if defined (linux) && defined (__s390__)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#endif /* linux/__s390__ */
++
++#if defined (linux) && defined (PPC)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#define LARGE_INSTRUCTION_CACHE
++#define FAST_CONSTANT_OFFSET_MODE
++
++#endif /* linux/PPC */
++
+ #ifdef sgi
+ 
+ #define IMAGE_BYTE_ORDER	MSBFirst
+--- vnc-3.3.4/Xvnc/config/cf/linux.cf	2002-08-08 13:14:31.000000000 +0200
++++ vnc-3.3.4-unixsrc/Xvnc/config/cf/linux.cf	2002-10-28 20:05:35.000000000 +0100
+@@ -1,80 +1,179 @@
+-XCOMM platform:  $TOG: linux.cf /main/36 1997/06/16 22:21:03 kaleb $
+-XCOMM platform:  $XFree86: xc/config/cf/linux.cf,v 3.57.2.12 1998/03/01 01:57:10 dawes Exp $
++XCOMM platform:  $Xorg: linux.cf,v 1.3 2000/08/17 19:41:47 cpqbld Exp $
++
++
++
++
++
++XCOMM platform:  $XFree86: xc/config/cf/linux.cf,v 3.165 2001/04/19 19:54:43 dawes Exp $
+ 
+ #ifndef LinuxElfDefault
+-#define LinuxElfDefault		YES
++# define LinuxElfDefault	YES
+ #endif
+ 
+ #ifndef UseElfFormat
+-#define UseElfFormat		LinuxElfDefault
++# define UseElfFormat		LinuxElfDefault
+ #endif
+ 
+ #ifndef OSBinaryType
+-#if UseElfFormat
+-#define OSBinaryType		[ELF]
+-#else
+-#ifdef AlphaArchitecture
+-#define OSBinaryType		[ECOFF]
+-#else
+-#define OSBinaryType		[a.out]
+-#endif
+-#endif
++# if UseElfFormat
++#  define OSBinaryType		[ELF]
++# else
++#  ifdef AlphaArchitecture
++#   define OSBinaryType		[ECOFF]
++#  else
++#   define OSBinaryType		[a.out]
++#  endif
++# endif
+ #endif
+ 
+ #ifndef OSName
+-#define OSName			DefaultOSName OSBinaryType
++# define OSName			DefaultOSName OSBinaryType
+ #endif
+ 
+ #ifndef OSVendor
+-#define OSVendor		/**/
++# define OSVendor		/**/
+ #endif
+ #ifndef OSMajorVersion
+-#define OSMajorVersion		DefaultOSMajorVersion
++# define OSMajorVersion		DefaultOSMajorVersion
+ #endif
+ #ifndef OSMinorVersion
+-#define OSMinorVersion		DefaultOSMinorVersion
++# define OSMinorVersion		DefaultOSMinorVersion
+ #endif
+ #ifndef OSTeenyVersion
+-#define OSTeenyVersion		DefaultOSTeenyVersion
++# define OSTeenyVersion		DefaultOSTeenyVersion
+ #endif
+ 
+-/* Set some defaults for the Default* values in case imake doesn't find them */
+-#ifndef DefaultLinuxCLibMajorVersion
+-#ifdef AlphaArchitecture
+-#define DefaultLinuxCLibMajorVersion	6
+-#else
+-#define DefaultLinuxCLibMajorVersion	5
+-#endif
+-#endif
+-#ifndef DefaultLinuxCLibMinorVersion
+-#if DefaultLinuxCLibMajorVersion > 5
+-#define DefaultLinuxCLibMinorVersion	0
+-#else
+-#define DefaultLinuxCLibMinorVersion	4
+-#endif
++#ifndef LinuxDistribution
++# define LinuxDistribution	DefaultLinuxDistribution
++/*
++  Add "#define LinuxDistribution Linux<mumble>" to your site.def or host.def.
++  Currently only LinuxSuSE, LinuxRedHat and LinuxDebian will be figured out
++  automatically.
++  Valid values are (from the list at www.linux.org in Oct. '97):
++    LinuxUnknown    (0)
++    LinuxSuSE       (1)
++    LinuxCaldera    (2)
++    LinuxCraftworks (3)
++    LinuxDebian     (4)
++    LinuxInfoMagic  (5)
++    LinuxKheops     (6)
++    LinuxPro        (7)
++    LinuxRedHat     (8)
++    LinuxSlackware  (9)
++    LinuxTurbo      (10)
++    LinuxWare       (11)
++    LinuxYggdrasil  (12)
++*/
+ #endif
+-#ifndef DefaultLinuxCLibTeenyVersion
+-#define DefaultLinuxCLibTeenyVersion	0
++#ifndef LinuxDistName
++# define LinuxDistName		DefaultLinuxDistName
+ #endif
+-
+ #ifndef LinuxCLibMajorVersion
+-#define LinuxCLibMajorVersion	DefaultLinuxCLibMajorVersion
++# define LinuxCLibMajorVersion	DefaultLinuxCLibMajorVersion
+ #endif
+ #ifndef LinuxCLibMinorVersion
+-#define LinuxCLibMinorVersion	DefaultLinuxCLibMinorVersion
++# define LinuxCLibMinorVersion	DefaultLinuxCLibMinorVersion
+ #endif
+ #ifndef LinuxCLibTeenyVersion
+-#define LinuxCLibTeenyVersion	DefaultLinuxCLibTeenyVersion
++# define LinuxCLibTeenyVersion	DefaultLinuxCLibTeenyVersion
+ #endif
+ 
+ #ifndef LinuxBinUtilsMajorVersion
+-#define LinuxBinUtilsMajorVersion	DefaultLinuxBinUtilsMajorVersion
++# define LinuxBinUtilsMajorVersion	DefaultLinuxBinUtilsMajorVersion
+ #endif
+ 
+ XCOMM operating system:  OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion)
+ XCOMM libc:	(LinuxCLibMajorVersion./**/LinuxCLibMinorVersion./**/LinuxCLibTeenyVersion)
+ XCOMM binutils:	(LinuxBinUtilsMajorVersion)
+ 
++#if LinuxDistribution == LinuxDebian
++# define SystemManDirectory	/usr/share/man
++# define HasPam			YES
++# define HasTk			YES
++# define TkLibDir		/usr/lib
++# define TkIncDir		/usr/include
++# define TkLibName		tk8.3
++# define XF86SetupUsesStaticTk	NO
++# define HasTcl			YES
++# define TclLibDir		/usr/lib
++# define TclIncDir		/usr/include
++# define TclLibName		tcl8.3
++# define XF86SetupUsesStaticTcl	NO
++/* un-comment this when it is un-broken */
++/* # define JoystickSupport YES */
++# define InstallXinitConfig	YES
++# define InstallXdmConfig	YES
++# define InstallFSConfig	YES
++# define DebuggableLibraries	YES
++# define ForceNormalLib		YES
++# define BuildSpecsDocs		YES
++# define SpecsDocDirs		CTEXT GL ICCCM X11 Xext Xv i18n xterm
++# define XAppLoadDir		EtcX11Directory/app-defaults
++# define XFileSearchPathDefault	Concat4(EtcX11Directory/%L/%T/%N%C,%S:EtcX11Directory/%l/%T/%N%C,%S:EtcX11Directory/%T/%N%C,%S:EtcX11Directory/%L/%T/%N%S:EtcX11Directory/%l/%T/%N%S:EtcX11Directory/%T/%N%S):Concat4($(LIBDIR)/%L/%T/%N%C,%S:$(LIBDIR)/%l/%T/%N%C,%S:$(LIBDIR)/%T/%N%C,%S:$(LIBDIR)/%L/%T/%N%S:$(LIBDIR)/%l/%T/%N%S:$(LIBDIR)/%T/%N%S)
++/* the relative symlink created by this rule causes problems for us */
++# if InstallAppDefFiles
++#  define InstallAppDefaultsLong(file,class)				@@\
++InstallNamedTarget(install,file.ad,$(INSTAPPFLAGS),$(XAPPLOADDIR),class)
++# else
++#  define InstallAppDefaultsLong(file,class)				@@\
++InstallNamedTargetNoClobber(install,file.ad,$(INSTAPPFLAGS),$(XAPPLOADDIR),class)
++# endif /* InstallAppDefFiles */
++# define SharedLibXdmGreet	NO
++# define LinkGLToUsrInclude	NO
++# define LinkGLToUsrLib		NO
++# define SharedLibFont		NO
++# define HasZlib		YES
++# define BuildGLXLibrary	YES
++# define BuildGLULibrary	YES
++# define BuildRman		NO
++# define BuildHtmlManPages	NO
++# define FSUseSyslog		YES
++
++/*
++ *
++ */
++# define DebianMaintainer	"xfree86@packages.debian.org"
++/*
++ *
++ */
++
++# ifdef DebianMaintainer
++#  define BuilderEMailAddr	"submit@bugs.debian.org"
++#  define XFree86Devel		YES
++#  define BuildAllSpecsDocs	YES
++/* we build-depend on libfreetype6-dev (FreeType 2.x) */
++#  define BuildFreetype2Library	NO
++#  define HasFreetype2		YES
++/* m68k has no 2.4 kernel yet */
++#  ifndef Mc68020Architecture
++#   define HasLinuxInput		YES
++#  endif
++#  define HasXdmAuth		YES
++#  define HasLatex		YES
++/* at present, glide2 only works on i386 */
++#  ifdef i386Architecture
++#   define HasGlide2		YES
++#   define Glide2IncDir		/usr/include/glide
++#  endif /* i386Architecture */
++/* at present, glide3 only works on alpha and i386 */
++#  if defined(i386Architecture) || defined(AlphaArchitecture)
++#   define HasGlide3		YES
++#   define Glide3IncDir		/usr/include/glide3
++#  endif /* i386Architecture || AlphaArchitecture */
++/* extended instruction set support */
++#  ifdef i386Architecture
++#   define HasMMXSupport	YES
++#   define Has3DNowSupport	YES
++/* 2.4 is not yet the official (or predominant) kernel in unstable */
++#   define HasKatmaiSupport	NO
++#  endif /* i386Architecture */
++# endif /* DebianMaintainer */
++#endif /* LinuxDebian */
++
++#if LinuxDistribution == LinuxRedHat
++#define FSUseSyslog		YES
++#endif
++
+ /*
+  * The Linux BinUtils major version.  25 => 2.5.x, which is what is included
+  * with Slackware 3.0
+@@ -83,45 +182,249 @@
+  *
+  */
+ #ifndef BinUtilsMajorVersion
+-#define BinUtilsMajorVersion	LinuxBinUtilsMajorVersion
++# define BinUtilsMajorVersion	LinuxBinUtilsMajorVersion
+ #endif
+ 
+-#if LinuxCLibMajorVersion >= 6 || \
+-	(LinuxCLibMajorVersion == 5 && LinuxCLibMinorVersion == 99)
+-#define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
+-				-D_POSIX_SOURCE -D_XOPEN_SOURCE=500L \
+-				-D_BSD_SOURCE -D_SVID_SOURCE
+-#define XawI18nDefines		-DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H
+-#if !defined(AlphaArchitecture)
+-#define HasPosixThreads		YES
+-#define ThreadedX		YES
+-#define HasThreadSafeAPI	YES
+-#define ThreadsLibraries	-lpthread
+-#define SystemMTDefines		-D_REENTRANT
++#if (LinuxCLibMajorVersion >= 6 || LinuxDistribution == LinuxSuSE)
++# define LinuxLocaleDefines	/**/
++#else
++# define LinuxLocaleDefines	-DX_LOCALE
+ #endif
+-#ifndef HasLibCrypt
+-#define HasLibCrypt		YES
++
++#ifndef  LinuxAdditionalIncludes
++# define LinuxAdditionalIncludes	/**/
+ #endif
++
++#ifndef LinuxGnuSourceDefines
++# ifdef UseInstalled
++#  define LinuxGnuSourceDefines	/**/
++# else
++#  define LinuxGnuSourceDefines	-D_GNU_SOURCE
++# endif
++#endif
++
++#if LinuxCLibMajorVersion >= 6
++# define LinuxSourceDefines	-D_POSIX_C_SOURCE=199309L \
++				-D_POSIX_SOURCE -D_XOPEN_SOURCE \
++				-D_BSD_SOURCE -D_SVID_SOURCE \
++				LinuxAdditionalIncludes LinuxGnuSourceDefines \
++				LinuxLocaleDefines
++# define XawI18nDefines		-DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H
++# define HasPosixThreads	YES
++# define ThreadedX		YES
++# define HasThreadSafeAPI	YES
++# define ThreadsLibraries	-lpthread
++# define SystemMTDefines	-D_REENTRANT
++# ifndef HasLibCrypt
++#  define HasLibCrypt		YES
++# endif
++/* netscape wraps select but not poll as of communicator 4.72 */
++# ifndef HasPoll
++#  define HasPoll		NO
++# endif
+ #else
+-#define LinuxSourceDefines	-D_POSIX_SOURCE \
+-				-D_BSD_SOURCE -D_SVID_SOURCE -DX_LOCALE
+-#define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
+-#ifndef HasLibCrypt
+-#define HasLibCrypt		NO
++# define LinuxSourceDefines	-D_POSIX_SOURCE -D_POSIX_C_SOURCE=2 \
++				-D_BSD_SOURCE -D_SVID_SOURCE \
++				LinuxGnuSourceDefines LinuxLocaleDefines
++# define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
++# ifndef HasLibCrypt
++#  define HasLibCrypt		NO
++# endif
+ #endif
++
++#ifndef InstallXloadSetGID
++#define InstallXloadSetGID	NO
++#endif
++
++/* <linux/input.h> support mainly for USB support */
++#ifndef HasLinuxInput
++# if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
++#  define HasLinuxInput YES
++# endif
++#endif
++
++/* On x86, determine whether to build with MTRR support */
++#ifndef HasMTRRSupport
++# ifdef i386Architecture
++/* There is no certain way to know if <asm/mtrr.h> is available,
++   but it made it into kernel 2.2, so... */
++#  if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
++#   define HasMTRRSupport	YES
++#  else
++#   define HasMTRRSupport	NO
++#  endif
++# else
++#  define HasMTRRSupport	NO	/* no for non-ix86 */
++# endif
++#endif
++
++#ifndef XF86INT10_BUILD
++# ifdef i386Architecture
++#  define XF86INT10_BUILD	X86VM
++# else
++#  define XF86INT10_BUILD	X86EMU_GENERIC
++# endif
++#endif
++
++/* The DRM module requires kernel services that appeared in late 2.1.x
++   kernels and are known to be present in 2.2.x kernels. */
++#ifndef BuildXF86DRI
++#  if defined(i386Architecture)
++#    if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
++#      define BuildXF86DRI	YES
++#    else
++#      define BuildXF86DRI	NO
++#    endif
++#  elif defined(AlphaArchitecture)
++#    define BuildXF86DRI	YES
++#  elif defined(Arm32Architecture)
++#    define BuildXF86DRI	NO
++#  elif defined(HPArchitecture)
++#    define BuildXF86DRI	NO
++#  elif defined(ia64Architecture)
++#    define BuildXF86DRI	YES
++#  elif defined(Mc68020Architecture)
++#    define BuildXF86DRI	NO
++#  elif defined(MipsArchitecture)
++#    define BuildXF86DRI	NO
++#  elif defined(PpcArchitecture)
++#    define BuildXF86DRI	YES
++#  elif defined(s390Architecture)
++#    define BuildXF86DRI	NO
++#  elif defined(SparcArchitecture)
++#    define BuildXF86DRI	YES
++#  else
++#    define BuildXF86DRI	NO
++#  endif
++#endif
++
++/*
++ * Build shared libGL and the DRI modules without -fPIC.  This improves
++ * performance.  Do this only on architectures that can handle missing PIC
++ * symbols in shared libraries.
++ */
++#if BuildXF86DRI
++#  if defined(AlphaArchitecture) || defined(Arm32Architecture) || defined(i386Architecture) || defined(SparcArchitecture)
++#   define BuildLibGlxWithoutPIC	YES
++#  endif
++#endif
++
++/* The DRM module requires kernel services that appeared in late 2.1.x
++   kernels and are known to be present in 2.2.x kernels.  Unfortunately,
++   the kernel API is a moving target and the module may break with new
++   kernel revisions.  So, we'll only build the module for kernels that are
++   known to be supported by the module. */
++#ifndef BuildXF86DRM
++#  if defined(i386Architecture) || defined(ia64Architecture) || defined(SparcArchitecture) || defined(AlphaArchitecture)
++#    if OSMajorVersion == 2
++       /* Only tested for Linux 2.2.0 through 2.2.12 */
++#      if OSMinorVersion == 2 && OSTeenyVersion <= 12
++#        define BuildXF86DRM	YES
++#      else
++         /* Only tested for Linux 2.3.0 through 2.3.18 */
++#        if OSMinorVersion == 3 && OSTeenyVersion <= 18
++#          define BuildXF86DRM	YES
++#        else
++           /* Note: add more conditions when 2.4.x and 2.5.x are released */
++#          define BuildXF86DRM	NO
++#        endif
++#      endif
++#    else
++       /* Note: add more conditions when 3.0.x and 3.1.x are released */
++#      define BuildXF86DRM	NO
++#    endif
++#  else
++#    define BuildXF86DRM	NO
++#  endif
++#endif
++
++#ifndef HasAgpGart
++#  if defined(i386Architecture) || defined(ia64Architecture)
++     /* The AGPGART header file is included in os-support/linux, which
++        allows all drivers that depend on AGP to build properly. */
++#    define HasAgpGart	YES
++#  else
++#    define HasAgpGart	NO
++#  endif
++#endif
++
++/* Support for Intel's Katmai Native Instructions, also known as the
++ * Streaming SIMD Extensions, was introduced in the 2.4.x kernels.
++ */
++#ifndef HasKatmaiSupport
++#  ifdef i386Architecture
++#    if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 4)
++#      define HasKatmaiSupport		YES
++#    else
++#      define HasKatmaiSupport		NO
++#    endif
++#  else
++#    define HasKatmaiSupport		NO
++#  endif
++#endif
++
++/*
++ * Support for MMX isn't present in the Assembler used in Red Hat 4.2, so
++ * don't enable it for libc5 as a reasonable default.
++ */
++#ifndef HasMMXSupport
++#  ifdef i386Architecture
++#    if (LinuxCLibMajorVersion > 5)
++#      define HasMMXSupport		YES
++#    else
++#      define HasMMXSupport		NO
++#    endif
++#  else
++#    define HasMMXSupport		NO
++#  endif
++#endif
++
++/*
++ * Support for 3DNow isn't present in the Assembler used in Red Hat 4.2, so
++ * don't enable it for libc5 as a reasonable default.
++ *
++ * XXX This is preliminary.
++ */
++#ifndef Has3DNowSupport
++#  ifdef i386Architecture
++#    if (LinuxCLibMajorVersion > 5)
++#      define Has3DNowSupport		YES
++#    else
++#      define Has3DNowSupport		NO
++#    endif
++#  else
++#    define Has3DNowSupport		NO
++#  endif
++#endif
++
++/*
++ * libGLU doesn't build correctly on a libc5 system.
++ */
++#if !defined(BuildGLULibrary) && (LinuxCLibMajorVersion < 6)
++# define BuildGLULibrary		NO
++#endif
++
++/*
++ * The Rush extension support.
++ */
++#ifndef BuildXF86RushExt
++# define BuildXF86RushExt	YES
++#endif
++
++#ifndef LinuxFBDevSupport
++# define LinuxFBDevSupport	YES
+ #endif
+ 
+ /* For compatibility */
+ #define SourceDefines		LinuxSourceDefines
+ 
+-#define HasGcc			YES
+-#define HasGcc2			YES
+-#ifndef HasGcc2ForCplusplus
+-# define HasGcc2ForCplusplus	YES
+-#endif
++#define BuildLibPathVar		LD_LIBRARY_PATH
+ #define GccUsesGas		YES
+ #define UseGas			YES
+ #define GnuCpp			YES
++#if UseElfFormat
++# define HasDlopen		YES
++#endif
+ #ifndef HasShadowPasswd
+ # if UseElfFormat
+ #  define HasShadowPasswd	YES
+@@ -136,9 +439,21 @@
+ #define HasSnprintf		YES
+ #define HasMkstemp		YES
+ #endif
++#if OSMajorVersion >= 2
++#define HasUsableFileMmap	YES
++#endif
++#ifndef HasNCurses
++#define HasNCurses		YES
++#endif
++
++#ifndef HasGroff
++#define HasGroff		YES
++#endif
+ 
+ #define AvoidNullMakeCommand	YES
+-#define StripInstalledPrograms	YES
++#ifndef DebuggableLibraries
++#define DebuggableLibraries	NO
++#endif
+ #define CompressAllFonts	YES
+ #define Malloc0ReturnsNull	YES
+ #define NeedConstPrototypes	YES
+@@ -154,125 +469,336 @@
+ #define UseStaticTermcapLib	NO
+ #endif
+ 
+-#define MkdirHierCmd		mkdir -p
+-#if LinuxElfDefault
+-#if UseElfFormat
+-#define CcCmd			gcc
+-#define AsCmd			as
+-#define LdCmd			ld
+-#define AsmDefines		-D__ELF__
+-#define CplusplusCmd		c++
+-#if UseStaticTermcapLib
+-#define TermcapLibrary		StaticLibrary(/usr/lib/termcap,termcap)
++#ifndef HasCookieMaker
++#define HasCookieMaker		YES
++#define MkCookieCmd		mcookie
+ #endif
+-#else
+-#ifdef AlphaArchitecture
+-#define CcCmd			gcc -b alpha-linuxecoff
+-#define CplusplusCmd		g++ -b alpha-linuxecoff
+-#define AsCmd			/usr/alpha-linuxecoff/bin/as
+-#define LdCmd			/usr/alpha-linuxecoff/bin/ld -m alpha
+-#define AsmDefines		-DUSE_GAS -U__ELF__
+-#endif /* AlphaArchitecture */
+-#ifdef i386Architecture
+-#define CcCmd			gcc -b i486-linuxaout
+-#define CplusplusCmd		g++ -b i486-linuxaout
+-#define AsCmd			/usr/i486-linuxaout/bin/as
+-#define LdCmd			/usr/i486-linuxaout/bin/ld -m i386linux
+-#define AsmDefines		-DUSE_GAS -U__ELF__
+-#endif /* i386Architecture */
+-#ifdef Mc68020Architecture
+-#define CcCmd			gcc -b m68k-linuxaout
+-#define CplusplusCmd		g++ -b m68k-linuxaout
+-#define AsCmd			/usr/m68k-linuxaout/bin/as
+-#define LdCmd			/usr/m68k-linuxaout/bin/ld -m m68klinux
+-#define AsmDefines		-DUSE_GAS -U__ELF__
+-#endif /* Mc68020Architecture */
++
++#ifndef BourneShell
++/*
++ * This will cause builds/installs to terminate on errors, as on other
++ * platforms.
++ */
++#define BourneShell		/bin/sh -e
+ #endif
++
++#define MkdirHierCmd		mkdir -p
++
++#if LinuxElfDefault
++# if UseElfFormat
++#  ifdef MipsArchitecture
++#   ifndef AsCmd
++#     define AsCmd		gcc -c -x assembler-with-cpp
++#   endif
++#   ifndef DoLoadableServer
++#     define DoLoadableServer	NO
++#   endif
++#  endif /* MipsArchitecure */
++#  ifndef CcCmd
++#   define CcCmd		gcc
++#  endif
++#  ifndef AsCmd
++#   define AsCmd		as
++#  endif
++#  ifndef LdCmd
++#   define LdCmd		ld
++#  endif
++#  define AsmDefines		-D__ELF__
++#  define CplusplusCmd		c++
++#  ifndef LinuxUsesNcurses
++#   if LinuxCLibMajorVersion >= 6 || (LinuxDistribution == LinuxSuSE)
++#    define LinuxUsesNcurses	YES
++#   else
++#    define LinuxUsesNcurses	NO
++#   endif
++#  endif
++#  ifndef TermcapLibrary
++#   if UseStaticTermcapLib
++#    if LinuxUsesNcurses
++#     define TermcapLibrary	StaticLibrary(/usr/lib,ncurses)
++#    else
++#     define TermcapLibrary	StaticLibrary(/usr/lib/termcap,termcap)
++#    endif
++#   else
++#    if LinuxUsesNcurses
++#     define TermcapLibrary	-lncurses
++#    else
++#     define TermcapLibrary	-ltermcap
++#    endif
++#   endif
++#  endif
++# else
++#  ifdef AlphaArchitecture
++#   define CcCmd		gcc -b alpha-linuxecoff
++#   define CplusplusCmd		g++ -b alpha-linuxecoff
++#   define AsCmd		/usr/alpha-linuxecoff/bin/as
++#   define LdCmd		/usr/alpha-linuxecoff/bin/ld -m alpha
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* AlphaArchitecture */
++#  ifdef HPArchitecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* HPArchitecture */
++#  ifdef ia64Architecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* ia64Architecture */
++#  ifdef i386Architecture
++#   define CcCmd		gcc -b i486-linuxaout
++#   define CplusplusCmd		g++ -b i486-linuxaout
++#   define AsCmd		/usr/i486-linuxaout/bin/as
++#   define LdCmd		/usr/i486-linuxaout/bin/ld -m i386linux
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* i386Architecture */
++#  ifdef Mc68020Architecture
++#   define CcCmd		gcc -b m68k-linuxaout
++#   define CplusplusCmd		g++ -b m68k-linuxaout
++#   define AsCmd		/usr/m68k-linuxaout/bin/as
++#   define LdCmd		/usr/m68k-linuxaout/bin/ld -m m68klinux
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* Mc68020Architecture */
++# endif
+ #else
+-#if UseElfFormat
+-#ifdef AlphaArchitecture
+-#define CcCmd			gcc -b alpha-linux
+-#define AsCmd			/usr/alpha-linux/bin/as
+-#define LdCmd			ld -m elf64alpha
+-#define AsmDefines		-D__ELF__
+-#define CplusplusCmd		c++ -b alpha-linux
+-#endif /* AlphaArchitecture */
+-#ifdef i386Architecture
+-#define CcCmd			gcc -b i486-linux
+-#define AsCmd			/usr/i486-linux/bin/as
+-#define LdCmd			ld -m elf_i386
+-#define AsmDefines		-D__ELF__
+-#define CplusplusCmd		c++ -b i486-linux
+-#endif /* i386Architecture */
+-#ifdef Mc68020Architecture
+-#define CcCmd			gcc -b m68k-linux
+-#define AsCmd			/usr/m68k-linux/bin/as
+-#define LdCmd			ld -m m68kelf
+-#define AsmDefines		-D__ELF__
+-#define CplusplusCmd		c++ -b m68k-linux
+-#endif /* Mc68020Architecture */
+-#else
+-#define CcCmd			gcc
+-#define AsCmd			as
+-#define LdCmd			ld
+-#define AsmDefines		-DUSE_GAS
+-#endif
++# if UseElfFormat
++#  ifdef AlphaArchitecture
++#   define CcCmd		gcc -b alpha-linux
++#   define AsCmd		/usr/alpha-linux/bin/as
++#   define LdCmd		ld -m elf64alpha
++#   define AsmDefines		-D__ELF__
++#   define CplusplusCmd		c++ -b alpha-linux
++#  endif /* AlphaArchitecture */
++#  ifdef ia64Architecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-D__ELF__
++#  endif /* ia64Architecture */
++#  ifdef HPArchitecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-D__ELF__
++#   define SharedLibXau		YES
++#  endif /* HPArchitecture */
++#  ifdef i386Architecture
++#   define CcCmd		gcc -b i486-linux
++#   define AsCmd		/usr/i486-linux/bin/as
++#   define LdCmd		ld -m elf_i386
++#   define AsmDefines		-D__ELF__
++#   define CplusplusCmd		c++ -b i486-linux
++#  endif /* i386Architecture */
++#  ifdef Mc68020Architecture
++#   define CcCmd		gcc -b m68k-linux
++#   define AsCmd		/usr/m68k-linux/bin/as
++#   define LdCmd		ld -m m68kelf
++#   define AsmDefines		-D__ELF__
++#   define CplusplusCmd		c++ -b m68k-linux
++#  endif /* Mc68020Architecture */
++# else
++#  define CcCmd			gcc
++#  define AsCmd			as
++#  define LdCmd			ld
++#  define AsmDefines		-DUSE_GAS
++# endif
+ #endif
+ #if UseElfFormat
+-#ifndef BuildDynamicLoading
+-#define BuildDynamicLoading	YES
++# ifndef DoLoadableServer
++# ifdef HPArchitecture
++#  define DoLoadableServer	NO
++# else
++#  define DoLoadableServer	YES
++# endif
++# endif
+ #endif
++#ifndef CppCmd
++# define CppCmd			/lib/cpp
+ #endif
+-#define CppCmd			/lib/cpp
+-#ifdef USE_BYACC
+-#define YaccCmd			byacc
+-#else
++/* Some Linux distributions have yacc, some don't. All have bison. */
+ #define YaccCmd			bison -y
+-#endif
+ #define LexCmd			flex -l
++#define HasFlex			YES
+ #define LexLib			-lfl
+ #define PreProcessCmd		CcCmd -E
+ #define PostIncDir		DefaultGccIncludeDir
+ #define LdCombineFlags		-r
+-#define LdPostLib		/* Never needed */
++#ifndef LdPostLib
++# define LdPostLib		/* Never needed */
++#endif
+ #define HasWChar32		YES
+-#define StandardCppDefines	-traditional StandardDefines
++#define StandardCppOptions	-traditional
++#define StandardCppDefines	StandardDefines
++
++#define HasVarRun		YES
++#define VarDbDirectory		$(VARDIR)/lib
++
++#ifndef XF86OSCardDrivers
++# define XF86OSCardDrivers	v4l
++#endif
++
++#if UseElfFormat
++# define HasPlugin			YES
++# define VendorHasX11R6_3libXext	YES	/* XC or XFree86 >= 3.3.1 */
++#endif
+ 
+ #ifdef i386Architecture
+-#define OptimizedCDebugFlags	DefaultGcc2i386Opt
+-#define LinuxMachineDefines	-D__i386__
+-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O
++# endif
++# define LinuxMachineDefines	-D__i386__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+ #endif /* i386Architecture */
+ 
++#ifdef s390Architecture
++# define DefaultCCOptions	-fsigned-char
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__s390__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++#endif /* s390Architecture */
++
+ #ifdef AlphaArchitecture
+-#define OptimizedCDebugFlags	-O2
+-#define LinuxMachineDefines	-D__alpha__
+-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O
++# endif
++# define LinuxMachineDefines	-D__alpha__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64 -DJENSEN_SUPPORT
++# ifdef UseCompaqMathLibrary
++#  define MathLibrary		-lcpml -lm
++# endif
+ #endif /* AlphaArchitecture */
+ 
++#ifdef Arm32Architecture
++# define DefaultCCOptions	-fsigned-char
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O3
++# endif
++# define LinuxMachineDefines	-D__arm__ -D__arm32__ -U__arm -Uarm
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++#endif /* Arm32Achitecture */
++
++#ifdef ia64Architecture
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__ia64__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
++#endif /* ia64Architecture */
++
+ #ifdef Mc68020Architecture
+-#define OptimizedCDebugFlags	-O2
+-#define LinuxMachineDefines 	-D__mc68000__
+-#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+-#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__mc68000__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+ #endif /* Mc68020Architecture */
+ 
+-#define StandardDefines		-Dlinux LinuxMachineDefines LinuxSourceDefines
++#ifdef PpcArchitecture
++# define DefaultCCOptions	-fsigned-char
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O
++# endif
++# define LinuxMachineDefines	-D__powerpc__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++#endif /* PpcArchitecture */
++
++#ifdef SparcArchitecture
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__sparc__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DHAVE_DOMAINS -DGCCUSESGAS XFree86ServerDefines
++# define AsVISOption		-Av9a
++# ifdef Sparc64Architecture
++#  define AsOutputArchSize	64
++# else
++#  define AsOutputArchSize	32
++# endif
++#endif
++
++#ifdef MipsArchitecture
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__mips__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++#endif
++
++#ifdef HPArchitecture
++# define OptimizedCDebugFlags	-O2
++# define LinuxMachineDefines	-D__hppa__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
++#endif
++
++#ifdef SuperHArchitecture
++# ifndef SuperHArchOptFlags
++#  ifdef SuperH4Architecture
++#   define SuperHArchOptFlags   -m4
++#  elif defined(SuperH4NOFPUArchitecture)
++#   define SuperHArchOptFlags   -m4-nofpu
++#  else
++#   define SuperHArchOptFlags   -m3
++#  endif
++# endif 
++# ifndef SuperHebArchitecture
++#  ifdef SuperHebArchitecture
++#   define SuperHEndianFlags    -mb
++#  else
++#   define SuperHEndianFlags    -ml
++#  endif
++# endif
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags  -O2 SuperHArchOptFlags SuperHEndianFlags
++# endif
++# define LinuxMachineDefines    -D__sh__
++# define ServerOSDefines        XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines     -DGCCUSESGAS XFree86ServerDefines
++#endif
++
++#ifndef StandardDefines
++# define StandardDefines	-Dlinux LinuxMachineDefines LinuxSourceDefines
++#endif
+ 
+ #if UseElfFormat
+-#define DlLibrary		-rdynamic -ldl
++# define DlLibrary		-rdynamic -ldl
+ #else
+-#define DlLibrary		/**/
++# define DlLibrary		/**/
+ #endif
+ 
+-#if BuildDynamicLoading
+-#define ServerExtraSysLibs	DlLibrary
+-#else
+ #define ServerExtraSysLibs	/**/
++
++#ifndef PamLibraries
++#define PamLibraries		-lpam DlLibrary
++#endif
++
++#ifndef PamMiscLibraries
++#define PamMiscLibraries	-lpam_misc
++#endif
++
++#if HasDECnet
++# define ConnectionFlags	-DUNIXCONN -DTCPCONN -DDNETCONN
++# define ExtraLibraries		-ldnet
++#else
++# define ConnectionFlags	-DUNIXCONN -DTCPCONN
+ #endif
+-#define ConnectionFlags		-DUNIXCONN -DTCPCONN
+ 
+ /* Some of these man page defaults are overriden in the above OS sections */
+ #ifndef ManSuffix
+@@ -295,13 +821,38 @@
+ #endif
+ 
+ #ifndef StaticLibrary
+-#define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic
++# define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic
++#endif
++
++#ifndef LinkGLToUsrLib
++# define LinkGLToUsrLib		YES
++#endif
++# ifndef LinkGLToUsrInclude
++# define LinkGLToUsrInclude	YES
+ #endif
+ 
+-#define HasGnuMake	YES
++
++#define HasGnuMake		YES
+ 
+ #define MakeNamedTargetSubdir(dir,flags,subname)\
+ 	$(MAKE) -C dir $(MFLAGS) $(PARALLELMFLAGS) flags subname
+ 
++#define ArchitectureDefines	-DLINUX_ARCHITECTURE
++
++#define TtClientLibs $(TTLIB) $(XTOOLLIB) $(XLIB)
++#define TtClientDepLibs $(DEPTTLIB) $(DEPXTOOLLIB) $(DEPXLIB)
++
++#ifdef s390Architecture
++# define HasXServer	NO
++#endif
++
+ #include <lnxLib.rules>
+-#include <xfree86.cf>
++#ifdef KDriveXServer
++# include <kdrive.cf>
++#else
++# include <xfree86.cf>
++#endif
++
++#ifndef XFree86ServerOSDefines
++# define XFree86ServerOSDefines
++#endif
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.5-dynlib.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.5-dynlib.patch
@@ -0,0 +1,45 @@
+--- vnc-3.3.6/rfb/Makefile.in	2002-08-19 13:18:35.000000000 +0200
++++ vnc-3.3.5/rfb/Makefile.in	2002-11-22 08:21:11.000000000 +0100
+@@ -1,4 +1,9 @@
++# Debian
++LOBJS = vncauth.lo d3des.lo
++SHLIBLDFLAGS=-shared
++REV = 0.0
+ 
++# Original
+ SRCS = d3des.c vncauth.c
+ 
+ OBJS = d3des.o vncauth.o
+@@ -7,11 +12,31 @@
+ 
+ library = librfb.a
+ 
+-all:: $(library)
++all:: $(library) libvncauth.so.$(REV) libvncauth.a
+ 
+ $(library): $(OBJS)
+ 	rm -f $(library)
+ 	$(AR) $(library) $(OBJS)
+ 	$(RANLIB) $(library)
+ 
++# Debian, loadable library.
++$(LOBJS): %.lo: %.c
++	$(CC) -c -fPIC $(CFLAGS) $(ALL_CPPFLAGS) -o $@ $<
++
++libvncauth.a: $(OBJS) $(EXTRALIBRARYDEPS)
++	$(RM) $@
++	$(AR) $@ $(OBJS)
++	$(RANLIB) $@
++
++libvncauth.so.$(REV): $(LOBJS) $(EXTRALIBRARYDEPS)
++	$(RM) $@
++	@SONAME=`echo $@ | sed 's/\.[^\.]*$$//'`; set -x; \
++	$(CC) -o $@ $(SHLIBLDFLAGS) -Wl,-soname,$$SONAME $(LOBJS) $(REQUIREDLIBS) -lc; \
++	$(RM) $$SONAME; ln -s $@ $$SONAME 
++	$(RM) libvncauth.so 
++	ln -s $@ libvncauth.so
++
++clean::
++	-rm -f *.so* *.lo *.a
++
+ # followed by boilerplate.mk
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3r2-getline-fix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.3r2-getline-fix.patch
@@ -0,0 +1,42 @@
+--- vnc-3.3.3r2.orig/Xvnc/config/makedepend/def.h
++++ vnc-3.3.3r2/Xvnc/config/makedepend/def.h
+@@ -137,7 +137,7 @@
+ 
+ char			*copy();
+ char			*base_name();
+-char			*getline();
++char			*x_getline();
+ struct symtab		**slookup();
+ struct symtab		**isdefined();
+ struct symtab		**fdefined();
+--- vnc-3.3.3r2.orig/Xvnc/config/makedepend/main.c
++++ vnc-3.3.3r2/Xvnc/config/makedepend/main.c
+@@ -548,7 +548,7 @@
+  * Get the next line.  We only return lines beginning with '#' since that
+  * is all this program is ever interested in.
+  */
+-char *getline(filep)
++char *x_getline(filep)
+ 	register struct filepointer	*filep;
+ {
+ 	register char	*p,	/* walking pointer */
+--- vnc-3.3.3r2.orig/Xvnc/config/makedepend/parse.c
++++ vnc-3.3.3r2/Xvnc/config/makedepend/parse.c
+@@ -40,7 +40,7 @@
+ 	register char	*line;
+ 	register int	type;
+ 
+-	while (line = getline(filep)) {
++	while (line = x_getline(filep)) {
+ 		switch(type = deftype(line, filep, file_red, file, FALSE)) {
+ 		case IF:
+ 		case IFFALSE:
+@@ -529,7 +529,7 @@
+ 	register int	type;
+ 	boolean recfailOK;
+ 
+-	while (line = getline(filep)) {
++	while (line = x_getline(filep)) {
+ 		switch(type = deftype(line, filep, file_red, file, TRUE)) {
+ 		case IF:
+ 		doif:
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-tunnel-via-ssh-from-tightvnc-without-anuthing-else.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-tunnel-via-ssh-from-tightvnc-without-anuthing-else.patch
@@ -0,0 +1,480 @@
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/Makefile.in vnc-3.3.4/vncviewer/Makefile.in
+--- vnc-3.3.4-unixsrc/vncviewer/Makefile.in	2002-09-13 11:10:53.000000000 +0200
++++ vnc-3.3.4/vncviewer/Makefile.in	2002-10-28 15:47:28.000000000 +0100
+@@ -12,6 +12,7 @@
+   selection.c \
+   shm.c \
+   vncviewer.c \
++  tunnel.c \
+   sockets.cxx \
+   zrle.cxx
+ 
+@@ -28,6 +29,7 @@
+   selection.o \
+   shm.o \
+   vncviewer.o \
++  tunnel.o \
+   sockets.o \
+   zrle.o
+ 
+--- vnc-3.3.7.orig/vncviewer/argsresources.c	2003-02-28 19:47:10.000000000 +0100
++++ vnc-3.3.7/vncviewer/argsresources.c	2003-07-18 16:09:25.000000000 +0200
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002-2003 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -261,6 +262,22 @@
+ 
+ 
+ /*
++ * removeArgs() is used to remove some of command line arguments.
++ */
++
++void
++removeArgs(int *argc, char** argv, int idx, int nargs)
++{
++  int i;
++  if ((idx+nargs) > *argc) return;
++  for (i = idx+nargs; i < *argc; i++) {
++    argv[i-nargs] = argv[i];
++  }
++  *argc -= nargs;
++}
++
++
++/*
+  * usage() prints out the usage message.
+  */
+ 
+@@ -272,6 +289,7 @@
+ 	  "       %s [<options>] -listen [<display#>]\n"
+ 	  "\n"
+ 	  "<options> are standard Xt options, or:\n"
++	  "              -via <GATEWAY>\n"
+ 	  "              -shared\n"
+ 	  "              -viewonly\n"
+ 	  "              -fullscreen\n"
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/listen.c vnc-3.3.4/vncviewer/listen.c
+--- vnc-3.3.4-unixsrc/vncviewer/listen.c	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/listen.c	2002-10-28 16:11:50.000000000 +0100
+@@ -41,17 +41,6 @@
+ static void flashDisplay(Display *d, char *user);
+ static Bool AllXEventsPredicate(Display *d, XEvent *ev, char *arg);
+ 
+-static void
+-removeArgs(int *argc, char** argv, int idx, int nargs)
+-{
+-  int i;
+-  if ((idx+nargs) > *argc) return;
+-  for (i = idx+nargs; i < *argc; i++) {
+-    argv[i-nargs] = argv[i];
+-  }
+-  *argc -= nargs;
+-}
+-
+ /*
+  * listenForIncomingConnections() - listen for incoming connections from
+  * servers, and fork a new process to deal with each connection.  We must do
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/sockets.cxx vnc-3.3.4/vncviewer/sockets.cxx
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/tunnel.c vnc-3.3.4/vncviewer/tunnel.c
+--- vnc-3.3.4-unixsrc/vncviewer/tunnel.c	1970-01-01 01:00:00.000000000 +0100
++++ vnc-3.3.4/vncviewer/tunnel.c	2002-10-28 16:22:54.000000000 +0100
+@@ -0,0 +1,254 @@
++/*
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
++ *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
++ *
++ *  This is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License as published by
++ *  the Free Software Foundation; either version 2 of the License, or
++ *  (at your option) any later version.
++ *
++ *  This software is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ *  You should have received a copy of the GNU General Public License
++ *  along with this software; if not, write to the Free Software
++ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
++ *  USA.
++ */
++
++/*
++ * tunnel.c - tunneling support (e.g. for using standalone SSH installation)
++ */
++
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <vncviewer/vncviewer.h>
++
++/* True if there was -tunnel or -via option in the command line. */
++Bool tunnelSpecified = False;
++
++/* True if it was -tunnel, not -via option. */
++static Bool tunnelOption = False;
++
++/* "Hostname:display" pair in the command line will be substituted
++   by this fake argument when tunneling is used. */
++static char lastArgv[32];
++
++
++static void processTunnelArgs(char **remoteHost,
++			      int *remotePort, int localPort,
++			      int *pargc, char **argv, int tunnelArgIndex);
++static void processViaArgs(char **gatewayHost, char **remoteHost,
++			   int *remotePort, int localPort,
++			   int *pargc, char **argv, int tunnelArgIndex);
++static char *getCmdPattern(void);
++static Bool fillCmdPattern(char *result, char *pattern,
++			   char *gatewayHost, char *remoteHost,
++			   char *remotePort, char *localPort);
++static Bool runCommand(char *cmd);
++
++
++Bool
++createTunnel(int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pattern;
++  char cmd[1024];
++  int localPort, remotePort;
++  char localPortStr[8];
++  char remotePortStr[8];
++  char *gatewayHost = "";
++  char *remoteHost = "localhost";
++
++  tunnelSpecified = True;
++  if (strcmp(argv[tunnelArgIndex], "-tunnel") == 0)
++    tunnelOption = True;
++
++  pattern = getCmdPattern();
++  if (!pattern)
++    return False;
++
++  localPort = FindFreeTcpPort();
++  if (localPort == 0)
++    return False;
++
++  if (tunnelOption) {
++    processTunnelArgs(&remoteHost, &remotePort, localPort,
++		      pargc, argv, tunnelArgIndex);
++  } else {
++    processViaArgs(&gatewayHost, &remoteHost, &remotePort, localPort,
++		   pargc, argv, tunnelArgIndex);
++  }
++
++  sprintf(localPortStr, "%d", localPort);
++  sprintf(remotePortStr, "%d", remotePort);
++
++  if (!fillCmdPattern(cmd, pattern, gatewayHost, remoteHost,
++		      remotePortStr, localPortStr))
++    return False;
++
++  if (!runCommand(cmd))
++    return False;
++
++  return True;
++}
++
++static void
++processTunnelArgs(char **remoteHost, int *remotePort, int localPort,
++		  int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pdisplay;
++  //int port;
++
++  if (tunnelArgIndex >= *pargc - 1)
++    usage();
++
++  pdisplay = strchr(argv[*pargc - 1], ':');
++  if (pdisplay == NULL || pdisplay == argv[*pargc - 1])
++    usage();
++
++  *pdisplay++ = '\0';
++  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
++    usage();
++
++  *remotePort = atoi(pdisplay);
++  if (*remotePort < 100)
++    *remotePort += SERVER_PORT_OFFSET;
++
++  sprintf(lastArgv, "localhost:%d", localPort);
++
++  *remoteHost = argv[*pargc - 1];
++  argv[*pargc - 1] = lastArgv;
++
++  removeArgs(pargc, argv, tunnelArgIndex, 1);
++}
++
++static void
++processViaArgs(char **gatewayHost, char **remoteHost,
++	       int *remotePort, int localPort,
++	       int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pdisplay;
++  //int port;
++
++  if (tunnelArgIndex >= *pargc - 2)
++    usage();
++
++  pdisplay = strchr(argv[*pargc - 1], ':');
++  if (pdisplay == NULL)
++    usage();
++
++  *pdisplay++ = '\0';
++  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
++    usage();
++
++  *remotePort = atoi(pdisplay);
++  if (*remotePort < 100)
++    *remotePort += SERVER_PORT_OFFSET;
++
++  sprintf(lastArgv, "localhost:%d", localPort);
++
++  *gatewayHost = argv[tunnelArgIndex + 1];
++
++  if (pdisplay != &argv[*pargc - 1][1])
++    *remoteHost = argv[*pargc - 1];
++
++  argv[*pargc - 1] = lastArgv;
++
++  removeArgs(pargc, argv, tunnelArgIndex, 2);
++}
++
++static char *
++getCmdPattern(void)
++{
++  struct stat st;
++  char *pattern;
++
++  pattern = getenv((tunnelOption) ? "VNC_TUNNEL_CMD" : "VNC_VIA_CMD");
++  if (pattern == NULL) {
++    if ( stat(DEFAULT_SSH_CMD, &st) != 0 ||
++	 !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) ) {
++      fprintf(stderr, "%s: Cannot establish SSH tunnel: missing %s binary.\n",
++	      programName, DEFAULT_SSH_CMD);
++      return NULL;
++    }
++    pattern = (tunnelOption) ? DEFAULT_TUNNEL_CMD : DEFAULT_VIA_CMD;
++  }
++
++  return pattern;
++}
++
++/* Note: in fillCmdPattern() result points to a 1024-byte buffer */
++
++static Bool
++fillCmdPattern(char *result, char *pattern,
++	       char *gatewayHost, char *remoteHost,
++	       char *remotePort, char *localPort)
++{
++  int i, j;
++  Bool H_found = False, G_found = False, R_found = False, L_found = False;
++
++  for (i=0, j=0; pattern[i] && j<1023; i++, j++) {
++    if (pattern[i] == '%') {
++      switch (pattern[++i]) {
++      case 'H':
++	strncpy(&result[j], remoteHost, 1024 - j);
++	j += strlen(remoteHost) - 1;
++	H_found = True;
++	continue;
++      case 'G':
++	strncpy(&result[j], gatewayHost, 1024 - j);
++	j += strlen(gatewayHost) - 1;
++	G_found = True;
++	continue;
++      case 'R':
++	strncpy(&result[j], remotePort, 1024 - j);
++	j += strlen(remotePort) - 1;
++	R_found = True;
++	continue;
++      case 'L':
++	strncpy(&result[j], localPort, 1024 - j);
++	j += strlen(localPort) - 1;
++	L_found = True;
++	continue;
++      case '\0':
++	i--;
++	continue;
++      }
++    }
++    result[j] = pattern[i];
++  }
++
++  if (pattern[i]) {
++    fprintf(stderr, "%s: Tunneling command is too long.\n", programName);
++    return False;
++  }
++
++  if (!H_found || !R_found || !L_found) {
++    fprintf(stderr, "%s: %%H, %%R or %%L absent in tunneling command.\n",
++	    programName);
++    return False;
++  }
++  if (!tunnelOption && !G_found) {
++    fprintf(stderr, "%s: %%G pattern absent in tunneling command.\n",
++	    programName);
++    return False;
++  }
++
++  result[j] = '\0';
++  return True;
++}
++
++static Bool
++runCommand(char *cmd)
++{
++  if (system(cmd) != 0) {
++    fprintf(stderr, "%s: Tunneling command failed: %s.\n",
++	    programName, cmd);
++    return False;
++  }
++  return True;
++}
++
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/vncviewer.h vnc-3.3.4/vncviewer/vncviewer.h
+--- vnc-3.3.4-unixsrc/vncviewer/vncviewer.h	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/vncviewer.h	2002-10-28 16:23:58.000000000 +0100
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002 RealVNC Ltd.
++ *  Copyright (C) 2000, 2001 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -51,8 +52,15 @@
+ 
+ #define FLASH_PORT_OFFSET 5400
+ #define LISTEN_PORT_OFFSET 5500
++#define TUNNEL_PORT_OFFSET 5500
+ #define SERVER_PORT_OFFSET 5900
+ 
++#define DEFAULT_SSH_CMD "/usr/bin/ssh"
++#define DEFAULT_TUNNEL_CMD  \
++  (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20")
++#define DEFAULT_VIA_CMD     \
++  (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20")
++
+ 
+ /* argsresources.c */
+ 
+@@ -103,6 +111,8 @@
+ extern XrmOptionDescRec cmdLineOptions[];
+ extern int numCmdLineOptions;
+ 
++extern void removeArgs(int *argc, char** argv, int idx, int nargs);
++extern void usage();
+ extern void GetArgsAndResources(int argc, char **argv);
+ extern void SetFullScreenState(Widget w, XEvent *event, String *params,
+ 			       Cardinal *num_params);
+@@ -234,11 +244,21 @@
+ extern Bool ReadFromRFBServer(char *out, unsigned int n);
+ extern Bool WriteToRFBServer(char *buf, int n);
+ extern int ConnectToTcpAddr(const char* hostname, int port);
++extern int FindFreeTcpPort(void);
+ extern int ListenAtTcpPort(int port);
+ extern int AcceptTcpConnection(int listenSock);
+ 
+ extern int StringToIPAddr(const char *str, unsigned int *addr);
+ 
++extern Bool SameMachine(int sock);
++
++/* tunnel.c */
++
++extern Bool tunnelSpecified;
++
++extern Bool createTunnel(int *argc, char **argv, int tunnelArgIndex);
++
++
+ /* vncviewer.c */
+ 
+ extern char *programName;
+--- vnc-3.3.4-unixsrc/vncviewer/vncviewer.man~	2002-09-19 19:02:52.000000000 +0200
++++ vnc-3.3.4/vncviewer/vncviewer.man	2002-10-28 16:51:14.000000000 +0100
+@@ -89,6 +89,11 @@
+ on customisation below.
+ 
+ .TP
++.B \-via \fIXgateway\fP
++Makes the connection go though SSH to a gateway host. The gateway should be the
++target host for best connection secrecy.
++
++.TP
+ .B \-listen \fI[display-number]\fP
+ Causes vncviewer to listen on port 5500 +
+ .I display-number
+--- vnc-3.3.7.orig/vncviewer/vncviewer.c	2003-02-07 13:41:05.000000000 +0100
++++ vnc-3.3.7/vncviewer/vncviewer.c	2003-07-18 16:14:10.000000000 +0200
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002-2003 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -57,6 +58,11 @@
+       listenForIncomingConnections(&argc, argv, i);
+       break;
+     }
++    if (strcmp(argv[i], "-tunnel") == 0 || strcmp(argv[i], "-via") == 0) {
++      if (!createTunnel(&argc, argv, i))
++	exit(1);
++      break;
++    }
+   }
+ 
+   /* Call the main Xt initialisation function.  It parses command-line options,
+--- vnc-3.3.7.orig/vncviewer/sockets.cxx	2003-02-28 19:47:10.000000000 +0100
++++ vnc-3.3.7/vncviewer/sockets.cxx	2003-07-18 16:14:00.000000000 +0200
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002-2003 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -205,6 +206,39 @@
+ }
+ 
+ 
++/*
++ * FindFreeTcpPort tries to find unused TCP port in the range
++ * (TUNNEL_PORT_OFFSET, TUNNEL_PORT_OFFSET + 99]. Returns 0 on failure.
++ */
++
++int
++FindFreeTcpPort(void)
++{
++  int sock, port;
++  struct sockaddr_in addr;
++
++  addr.sin_family = AF_INET;
++  addr.sin_addr.s_addr = INADDR_ANY;
++
++  sock = socket(AF_INET, SOCK_STREAM, 0);
++  if (sock < 0) {
++    fprintf(stderr,programName);
++    perror(": FindFreeTcpPort: socket");
++    return 0;
++  }
++
++  for (port = TUNNEL_PORT_OFFSET + 99; port > TUNNEL_PORT_OFFSET; port--) {
++    addr.sin_port = htons((unsigned short)port);
++    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
++      close(sock);
++      return port;
++    }
++  }
++
++  close(sock);
++  return 0;
++}
++
+ 
+ /*
+  * ListenAtTcpPort starts listening at the given TCP port.
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3-x-manpath-lsb.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.3-x-manpath-lsb.patch
@@ -0,0 +1,22 @@
+--- vnc-3.3.3-x/Xvnc/config/cf/svr3.cf~	2002-05-11 12:57:05.000000000 +0200
++++ vnc-3.3.3-x/Xvnc/config/cf/svr3.cf	2002-10-28 11:25:28.000000000 +0100
+@@ -51,7 +51,7 @@
+ #endif
+ 
+ #ifndef XmanSearchPath
+-#define XmanSearchPath		/usr/man
++#define XmanSearchPath		/usr/share/man
+ #endif
+ 
+ /*
+--- vnc-3.3.3-x/Xvnc/config/cf/Imake.tmpl~	2002-05-11 12:57:05.000000000 +0200
++++ vnc-3.3.3-x/Xvnc/config/cf/Imake.tmpl	2002-10-28 11:28:42.000000000 +0100
+@@ -487,7 +487,7 @@
+ #if SystemV4
+ #define SystemManDirectory /usr/share/man
+ #else
+-#define SystemManDirectory /usr/man
++#define SystemManDirectory /usr/share/man
+ #endif
+ #endif
+ #ifndef ManDirectoryRoot
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.6-dixfontsfix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.6-dixfontsfix.patch
@@ -0,0 +1,17 @@
+--- vnc-3.3.6/Xvnc/programs/Xserver/dix/dixfonts.c~	2002-05-11 12:57:06.000000000 +0200
++++ vnc-3.3.6/Xvnc/programs/Xserver/dix/dixfonts.c	2002-12-19 08:46:42.000000000 +0100
+@@ -1759,10 +1759,11 @@
+ 	    if (err != Successful) {
+ 		xfree(fpe->name);
+ 		xfree(fpe);
+-		err = BadValue;
+-		goto bail;
++		err = Successful;
++	    }
++	    else {
++	      fplist[valid_paths++] = fpe;
+ 	    }
+-	    fplist[valid_paths++] = fpe;
+ 	} else {
+ 	    err = BadValue;
+ 	    goto bail;
--- vnc-3.3.7.orig/debian/patches/debian/vnc-3.3.3r2.xapploaddir.patch
+++ vnc-3.3.7/debian/patches/debian/vnc-3.3.3r2.xapploaddir.patch
@@ -0,0 +1,11 @@
+--- vnc-3.3.3r2.orig/Xvnc/config/cf/X11.tmpl
++++ vnc-3.3.3r2/Xvnc/config/cf/X11.tmpl
+@@ -735,7 +735,7 @@
+ #endif
+ #endif
+ #ifndef XAppLoadDir
+-#define XAppLoadDir $(LIBDIR)/app-defaults
++#define XAppLoadDir /etc/app-defaults
+ #endif
+ #ifndef XtErrorPrefix
+ #define XtErrorPrefix /* as empty string */
--- vnc-3.3.7.orig/debian/patches/applied-upstream/patch.1.txt
+++ vnc-3.3.7/debian/patches/applied-upstream/patch.1.txt
@@ -0,0 +1,4 @@
+Reported by: Ian Jackson <iwj@ncipher.com>; dated Wed, 8 Nov 2000 16:48:02 UTC
+
+This patch is applied upstream (3.3.4) but with some changes so it will not
+be a big cludge.
--- vnc-3.3.7.orig/debian/patches/applied-upstream/vnc-3.3.4-vncconnect-spellfix.patch
+++ vnc-3.3.7/debian/patches/applied-upstream/vnc-3.3.4-vncconnect-spellfix.patch
@@ -0,0 +1,11 @@
+--- vnc-3.3.4/vncconnect/vncconnect.c~	2002-10-28 20:34:55.000000000 +0100
++++ vnc-3.3.4/vncconnect/vncconnect.c	2002-10-28 20:35:19.000000000 +0100
+@@ -32,7 +32,7 @@
+ {
+     fprintf(stderr,"\nusage: %s [-display Xvnc-display] host[:port]\n"
+             "       %s [-display Xvnc-display] -away\n\n"
+-	    "Tells Xvnc to connects to a listening VNC viewer on the given"
++	    "Tells Xvnc to connect to a listening VNC viewer on the given"
+             " host and port\n"
+             "or to disconnect from all viewers with the -away flag.\n",
+ 	    programName, programName);
--- vnc-3.3.7.orig/debian/patches/applied-upstream/vnc-3.3.4-vncpasswd-fix-compile-warning.patch
+++ vnc-3.3.7/debian/patches/applied-upstream/vnc-3.3.4-vncpasswd-fix-compile-warning.patch
@@ -0,0 +1,11 @@
+--- vnc-3.3.4/vncpasswd/vncpasswd.c~	2002-11-04 17:01:49.000000000 +0100
++++ vnc-3.3.4/vncpasswd/vncpasswd.c	2002-11-04 17:05:12.000000000 +0100
+@@ -114,7 +114,7 @@
+       }
+       for (i = 0; i < strlen(passwd); i++)
+ 	passwd[i] = passwd1[i] = '\0';
+-      return;
++      return 0;
+     }
+ 
+     fprintf(stderr,"They don't match. Try again.\n\n");
--- vnc-3.3.7.orig/debian/patches/applied-upstream/patch.1.diff
+++ vnc-3.3.7/debian/patches/applied-upstream/patch.1.diff
@@ -0,0 +1,66 @@
+--- vnc-3.3.3r2/vncviewer/colour.c~   Wed Aug 11 16:16:21 1999
++++ vnc-3.3.3r2/vncviewer/colour.c    Wed Nov  8 16:38:59 2000
+@@ -40,6 +40,7 @@
+ 
+ static Bool GetPseudoColorVisualAndCmap(int depth);
+ static Bool GetTrueColorVisualAndCmap(int depth);
++static int GetBPPForDepthMaybe(int depth);
+ static int GetBPPForDepth(int depth);
+ static void SetupBGR233Map();
+ static void AllocateExactBGR233Colours();
+@@ -94,10 +95,10 @@
+ 
+   vis = DefaultVisual(dpy,DefaultScreen(dpy));
+   visdepth = DefaultDepth(dpy,DefaultScreen(dpy));
+-  visbpp = GetBPPForDepth(visdepth);
++  visbpp = GetBPPForDepthMaybe(visdepth);
+   cmap = DefaultColormap(dpy,DefaultScreen(dpy));
+ 
+-  if (!appData.useBGR233 && (vis->class == TrueColor)) {
++  if (!appData.useBGR233 && (vis->class == TrueColor) && visbpp != -1) {
+ 
+     myFormat.bitsPerPixel = visbpp;
+     myFormat.depth = visdepth;
+@@ -245,12 +246,14 @@
+ 
+ 
+ /*
+- * GetBPPForDepth looks through the "pixmap formats" to find the bits-per-pixel
+- * for the given depth.
++ * GetBPPForDepth looks through the "pixmap formats" to find the
++ * bits-per-pixel for the given depth.  GetBPPForDepthMaybe is willing
++ * to return -1 instead of a value which isn't a valid RFB format
++ * depth, while GetBPPForDepth will fail instead.
+  */
+ 
+ static int
+-GetBPPForDepth(int depth)
++GetBPPForDepthMaybe(int depth)
+ {
+   XPixmapFormatValues *format;
+   int nformats;
+@@ -274,14 +277,22 @@
+   XFree(format);
+ 
+   if (bpp != 1 && bpp != 8 && bpp != 16 && bpp != 32) {
+-    fprintf(stderr,"Can't cope with %d bits-per-pixel.  Sorry.\n", bpp);
+-    exit(1);
++    return -1;
+   }
+ 
+   return bpp;
+ }
+ 
++static int GetBPPForDepth(int depth) {
++  int bpp;
+ 
++  bpp= GetBPPForDepthMaybe(depth);
++  if (bpp == -1) {
++    fprintf(stderr,"Can't cope with %d bits-per-pixel.  Sorry.\n", bpp);
++    exit(1);
++  }
++  return bpp;
++}
+ 
+ /*
+  * SetupBGR233Map() sets up the BGR233ToPixel array.
--- vnc-3.3.7.orig/debian/patches/applied-upstream/vnc-3.3.4-vncpasswd-fix-compile-warning.author
+++ vnc-3.3.7/debian/patches/applied-upstream/vnc-3.3.4-vncpasswd-fix-compile-warning.author
@@ -0,0 +1 @@
+opal@debian.org
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.6-passwddialogwhennotty.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.6-passwddialogwhennotty.patch
@@ -0,0 +1,11 @@
+--- vnc-3.3.6/vncviewer/argsresources.c~	2002-12-09 12:39:03.000000000 +0100
++++ vnc-3.3.6/vncviewer/argsresources.c	2002-12-19 08:11:14.000000000 +0100
+@@ -358,6 +358,8 @@
+   } else {
+     vncServerName = argv[1];
+ 
++    if (!isatty(0))
++      appData.passwordDialog = True;
+     if (vncServerName[0] == '-')
+       usage();
+   }
--- vnc-3.3.7.orig/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-xinit.author
+++ vnc-3.3.7/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-xinit.author
@@ -0,0 +1 @@
+Wolfram Gloger <Wolfram.Gloger@dent.med.uni-muenchen.de>
--- vnc-3.3.7.orig/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-xinit.diff
+++ vnc-3.3.7/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-xinit.diff
@@ -0,0 +1,15 @@
+--- vnc-3.3.3r2/debian/vncserver.wrapper~      Thu Mar 30 18:44:17 2000
++++ vnc-3.3.3r2/debian/vncserver.wrapper~      Mon Sep 11 15:31:36 2000
+@@ -51,7 +51,11 @@
+   $vncClasses = "/usr/share/vncserver";
+ }
+ if (!$xauthorityFile) {
+-  $xauthorityFile = "$ENV{HOME}/.Xauthority";
++    if (!$ENV{XAUTHORITY}) {
++        $xauthorityFile = "$ENV{HOME}/.Xauthority";
++    } else {
++       $xauthorityFile = "$ENV{XAUTHORITY}";
++    }
+ }
+ if (!$vncUserDir) {
+   $vncUserDir = "$ENV{HOME}/.vnc";
\ No newline at end of file
--- vnc-3.3.7.orig/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-emptyarg.diff
+++ vnc-3.3.7/debian/patches/debian-native/vnc-3.3.3-x-vncserver.wrapper-emptyarg.diff
@@ -0,0 +1,11 @@
+--- /usr/X11R6/bin/vncserver    Tue Dec  5 02:35:06 2000
++++ vnc-3.3.3-x/debian/vncserver.wrapper      Sat Dec 16 23:06:01 2000
+@@ -564,7 +564,7 @@
+ 
+     @optArgs = ();
+ 
+-    arg: while ($arg = shift(@ARGV)) {
++    arg: while (($arg = shift(@ARGV)) ne "") {
+        foreach $opt (@opts) {
+            if ($arg eq $opt) {
+                push(@optArgs, $arg);
--- vnc-3.3.7.orig/debian/patches/debian-native/vncserver-manpagefix.patch
+++ vnc-3.3.7/debian/patches/debian-native/vncserver-manpagefix.patch
@@ -0,0 +1,130 @@
+From: Martin Pool <mbp@sourcefrog.net>
+
+Package: vncserver
+Version: 3.3.7-1
+Severity: normal
+Tags: patch
+
+roff syntax errors in the vncserver(1) manpage cause some paragraphs
+and words to be run together or hard to read.  Also, there are some
+small grammar errors.  This patch fixes it:
+
+diff -c /home/mbp/work/vncserver/vncserver-orig.1 /home/mbp/work/vncserver/vncserver.1
+*** /home/mbp/work/vncserver/vncserver-orig.1	Fri Sep  5 15:44:16 2003
+--- /home/mbp/work/vncserver/vncserver.1	Fri Sep  5 15:44:16 2003
+***************
+*** 47,72 ****
+  
+  .SH EXAMPLES
+  .TP \w'vncserver\ 'u
+! .BI vncserver
+  Invokes Xvnc on the next available display and with suitable defaults.
+  .TP
+! .BI vncserver\ \| :1
+  Invokes Xvnc on desktop 1.
+  .TP
+! .BI vncserver\ \| \-httpport 8080 :1
+  Invokes Xvnc on desktop 1 and listening on the http port 8080.
+  This is only possible if the vnc-java package is installed.
+  .TP
+! .BI vncserver\ \| \-basehttpport 8080 :1
+  Invokes Xvnc on desktop 1 and listening on the http port 8080+displaynumber.
+  This is only possible if the vnc-java package is installed.
+  .TP
+! .BI vncserver\ \| \-geometry\ 640x480\ \-once\ \-httpd\ /usr/X11R6/lib/vncserver
+  Invoke Xvnc for one session, with a framebuffer size of 640x480. Use the
+  Java classes in /usr/X11R6/lib/vncserver (normaly they are in /usr/share/vnc-java
+  if you have that package installed).
+  .TP
+! .BI vncserver\ \| \-kill\ :1
+  Shuts down server :1 at localhost.
+  
+  .SH OVERVIEW
+--- 47,72 ----
+  
+  .SH EXAMPLES
+  .TP \w'vncserver\ 'u
+! .I vncserver
+  Invokes Xvnc on the next available display and with suitable defaults.
+  .TP
+! .I vncserver :1
+  Invokes Xvnc on desktop 1.
+  .TP
+! .I vncserver\ \-httpport\ 8080\ :1
+  Invokes Xvnc on desktop 1 and listening on the http port 8080.
+  This is only possible if the vnc-java package is installed.
+  .TP
+! .I vncserver\ \-basehttpport 8080 :1
+  Invokes Xvnc on desktop 1 and listening on the http port 8080+displaynumber.
+  This is only possible if the vnc-java package is installed.
+  .TP
+! .I vncserver\ \-geometry\ 640x480\ \-once\ \-httpd\ /usr/X11R6/lib/vncserver
+  Invoke Xvnc for one session, with a framebuffer size of 640x480. Use the
+  Java classes in /usr/X11R6/lib/vncserver (normaly they are in /usr/share/vnc-java
+  if you have that package installed).
+  .TP
+! .I vncserver\ \-kill\ :1
+  Shuts down server :1 at localhost.
+  
+  .SH OVERVIEW
+***************
+*** 147,171 ****
+  .B VNC
+  server with the specified
+  display number and removes the lockfile. This option should be used to
+! cleanly shut down a server started by vncserver. Does only work when the
+! server was started with vncserver.
+  .TP
+! .I \-clean\
+! THis option can be used in conjunction with
+  .I \-kill
+! and will remove also the log file of the server process.
+  .I \-nevershared
+  Never allow shared desktops.
+  .I \-alwaysshared
+  Always allow shared desktops.
+  .I \-basehttpport int
+  The base http port to use for the java client applet (you have to install
+  the vnc-java package to make this work). The real port number will be
+  port = base + display num.
+  .I \-httpport int
+! The http port to use for the java client applet (you have to install
+  the vnc-java package to make this work).
+- 
+  .SH FILES
+  .TP
+  .I /etc/vnc.conf
+--- 147,176 ----
+  .B VNC
+  server with the specified
+  display number and removes the lockfile. This option should be used to
+! cleanly shut down a server started by vncserver.  Only works when the
+! server was started with the 
+! .I vncserver
+! command.
+  .TP
+! .I \-clean
+! This option can be used in conjunction with
+  .I \-kill
+! and will also remove the log file of the server process.
+! .TP
+  .I \-nevershared
+  Never allow shared desktops.
++ .TP
+  .I \-alwaysshared
+  Always allow shared desktops.
++ .TP
+  .I \-basehttpport int
+  The base http port to use for the java client applet (you have to install
+  the vnc-java package to make this work). The real port number will be
+  port = base + display num.
++ .TP
+  .I \-httpport int
+! The HTTP port to use for the Java client applet.  (You have to install
+  the vnc-java package to make this work).
+  .SH FILES
+  .TP
+  .I /etc/vnc.conf
+
+
+
--- vnc-3.3.7.orig/debian/patches/debian-native/vnc-3.3.7-option-once-and-startup.patch
+++ vnc-3.3.7/debian/patches/debian-native/vnc-3.3.7-option-once-and-startup.patch
@@ -0,0 +1,104 @@
+From: Steve Fosdick <dbugs@pelvoux.nildram.co.uk>
+
+Package: vncserver
+Version: 3.3.7-1
+Severity: normal
+Tags: patch
+
+We use the VNC server to be able to run certain X applications
+unattended with the facility for someone to connect to the VNC server
+if and when it becomes necessary to diagnose problems.
+
+For this we need to be able to specify that the VNC server run a
+specific application rather than /etc/X11/Xsession but only for that
+session and not changing either the system wide default or the
+invoking user's default.  We also need to be able to specify that the
+VNC server should quit as soon as this application does, i.e. the
+-once option that is documented in the man page for vncserver, but not
+implemented by realvncserver.
+
+The following patch implements both of these, i.e. a -startup command
+line option and the -once command line option.
+
+--- realvncserver.orig	2003-07-18 15:51:19.000000000 +0100
++++ realvncserver	2003-12-01 13:49:16.000000000 +0000
+@@ -111,7 +111,8 @@
+               "-help",0,"--help",0,"-h",0,
+               "-kill",1,"-clean",0, "-fp",1,
+ 	      "-alwaysshared",0, "-nevershared",0,
+-	      "-httpport",1,"-basehttpport",1);
++	      "-httpport",1,"-basehttpport",1,
++	      "-startup",1,"-once",0);
+ 
+ $useClasses = 0;
+ if (defined $vncClasses) {
+@@ -123,7 +124,12 @@
+ 
+ &Usage() if (($opt{'-help'}) || ($opt{'-h'}) || ($opt{'--help'}));
+ 
+-&Kill() if ($opt{'-kill'});
++if (my $display = $opt{'-kill'}) {
++	if ($display !~ /^:\d+$/) {
++        	&Usage();
++	}
++    	&Kill($display);
++}
+ 
+ &GetXDisplayDefaults();
+ 
+@@ -253,6 +259,7 @@
+ 
+ # Run the X startup script.
+ 
++$vncStartup = $opt{'-startup'} if exists $opt{'-startup'};
+ warn "Starting applications specified in $vncStartup\n";
+ warn "Log file is $desktopLog\n\n";
+ 
+@@ -263,8 +270,12 @@
+ 	$vncStartup = "/bin/sh " . $vncStartup;
+ }
+ 
+-system("$vncStartup >> " . &quotedString($desktopLog) . " 2>&1 &") if ($vncStartup);
+-
++if ($opt{'-once'}) {
++	system("$vncStartup >> " . &quotedString($desktopLog) . " 2>&1");
++	&Kill(":" . $displayNumber);
++} else  {
++	system("$vncStartup >> " . &quotedString($desktopLog) . " 2>&1 &") if ($vncStartup);
++}
+ exit;
+ 
+ #########################################################################
+@@ -552,25 +563,25 @@
+ 
+ sub Kill
+ {
+-    if ($opt{'-kill'} !~ /^:\d+$/) {
+-        &Usage();
+-    }
++    my $display = $_[0];
++    
++
+ 
+-    $pidFile = "$vncUserDir/$host$opt{'-kill'}.pid";
++    $pidFile = "$vncUserDir/$host$display.pid";
+ 
+     if (! -r $pidFile) {
+-        die "\nCan't find file $vncUserDir/$host$opt{'-kill'}.pid\n".
++        die "\nCan't find file $vncUserDir/$host$display.pid\n".
+             "You'll have to kill the Xvnc process manually\n\n";
+     }
+ 
+     $SIG{'HUP'} = 'IGNORE';
+     chop($pid = `cat $pidFile`);
+     warn "Killing Xvnc process ID $pid\n";
+-    system("kill $pid");
++    kill SIGTERM, $pid;
+     unlink $pidFile;
+ 
+     ## If option -clean is given, also remove the logfile
+-    unlink "$vncUserDir/$host$opt{'-kill'}.log" if ($opt{'-clean'});
++    unlink "$vncUserDir/$host$display.log" if ($opt{'-clean'});
+ 
+     exit;
+ }
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.4-vncpasswd-possible-minor-security-fix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.4-vncpasswd-possible-minor-security-fix.patch
@@ -0,0 +1,13 @@
+--- vnc-3.3.4/vncpasswd/vncpasswd.c~	2002-10-28 20:34:19.000000000 +0100
++++ vnc-3.3.4/vncpasswd/vncpasswd.c	2002-11-04 17:01:49.000000000 +0100
+@@ -62,6 +62,10 @@
+     sprintf(passwdFile, "%s/passwd", passwdDir);
+ 
+   } else if (argc == 2) {
++    if (strlen(argv[1]) > 240) {
++      fprintf(stderr,"Error: Passwd file string too long\n");
++      exit(1);
++    }
+     strcpy(passwdFile,argv[1]);
+     strcpy(passwdDir,argv[1]);
+     cp = strrchr(passwdDir, '/');
--- vnc-3.3.7.orig/debian/patches/unknown/color.txt
+++ vnc-3.3.7/debian/patches/unknown/color.txt
@@ -0,0 +1,56 @@
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/cfb/cfbcmap.c
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/cfb/cfbcmap.c
+@@ -343,16 +343,16 @@
+ 
+ extern int defaultColorVisualClass;
+ 
+-#define _RZ(d) ((d + 2) / 3)
+-#define _RS(d) 0
+-#define _RM(d) ((1 << _RZ(d)) - 1)
+-#define _GZ(d) ((d - _RZ(d) + 1) / 2)
+-#define _GS(d) _RZ(d)
++#define _BZ(d) (d / 3)
++#define _BS(d) 0
++#define _BM(d) ((1 << _BZ(d)) - 1)
++#define _GZ(d) ((d - _BZ(d) + 1) / 2)
++#define _GS(d) _BZ(d)
+ #define _GM(d) (((1 << _GZ(d)) - 1) << _GS(d))
+-#define _BZ(d) (d - _RZ(d) - _GZ(d))
+-#define _BS(d) (_RZ(d) + _GZ(d))
+-#define _BM(d) (((1 << _BZ(d)) - 1) << _BS(d))
+-#define _CE(d) (1 << _RZ(d))
++#define _RZ(d) (d - _BZ(d) - _GZ(d))
++#define _RS(d) (_BZ(d) + _GZ(d))
++#define _RM(d) (((1 << _RZ(d)) - 1) << _RS(d))
++#define _CE(d) (1 << _GZ(d))
+ 
+ #define MAX_PSEUDO_DEPTH    10	    /* largest DAC size I know */
+ 
+@@ -524,12 +524,21 @@
+ 		visual->ColormapEntries = _CE(d);
+ 		/* fall through */
+ 	    case StaticColor:
+-		visual->redMask =  _RM(d);
+-		visual->greenMask =  _GM(d);
+-		visual->blueMask =  _BM(d);
+-		visual->offsetRed  =  _RS(d);
+-		visual->offsetGreen = _GS(d);
+-		visual->offsetBlue =  _BS(d);
++		if (d == 8) {
++		    visual->redMask = 0x07;
++		    visual->greenMask = 0x38;
++		    visual->blueMask =  0xC0;
++		    visual->offsetRed  =  0;
++		    visual->offsetGreen = 3;
++		    visual->offsetBlue =  6;
++		} else {
++		    visual->redMask =  _RM(d);
++		    visual->greenMask =  _GM(d);
++		    visual->blueMask =  _BM(d);
++		    visual->offsetRed  =  _RS(d);
++		    visual->offsetGreen = _GS(d);
++		    visual->offsetBlue =  _BS(d);
++		}
+ 	    }
+ 	    vid++;
+ 	    visual++;
--- vnc-3.3.7.orig/debian/patches/unknown/unknown.diff
+++ vnc-3.3.7/debian/patches/unknown/unknown.diff
@@ -0,0 +1,11 @@
+--- vnc-3.3.3r2.orig/vncviewer/listen.c
++++ vnc-3.3.3r2/vncviewer/listen.c
+@@ -233,7 +222,7 @@
+   Window w1, w2, w3, w4;
+   XSetWindowAttributes attr;
+ 
+-  XBell(d, 100);
++  XBell(d, 0);
+ 
+   XForceScreenSaver(d, ScreenSaverReset);
+ 
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3-x-manpath-lsb.ptxt
+++ vnc-3.3.7/debian/patches/vnc-3.3.3-x-manpath-lsb.ptxt
@@ -0,0 +1,13 @@
+From: Chris Tillman <tillman@azstarnet.com>
+--- debian/vnc.conf.5x.orig     Sat Dec 29 22:35:29 2001
++++ debian/vnc.conf.5x  Sat Dec 29 22:35:29 2001
+@@ -37,7 +37,7 @@
+
+ .SH EXAMPLES
+ A sample example file should come with the Debian package, under
+-.IR /usr/doc/vncserver/vncrc.sample. It is pretty self-descriptive, and this
++.IR /usr/share/doc/vncserver/vncrc.sample. It is pretty self-descriptive, and
++this
+ document will mainly repeat the information that already can be found there.
+
+ .SH OVERVIEW
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.3r2-debian-bug-128096-security-fix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.3r2-debian-bug-128096-security-fix.patch
@@ -0,0 +1,39 @@
+diff -ur vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranslcl.c vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranslcl.c
+--- vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranslcl.c	Mon Mar  2 11:56:50 1998
++++ vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranslcl.c	Sun Jan  6 20:19:08 2002
+@@ -1046,8 +1046,8 @@
+      */
+ #define X_UNIX_DIR	"/tmp/.X11-unix"
+     
+-    if (!mkdir(X_UNIX_DIR, 0777))
+-	chmod(X_UNIX_DIR, 0777);
++    if (!mkdir(X_UNIX_DIR, 01777))
++	chmod(X_UNIX_DIR, 01777);
+     
+     unlink(server_unix_path);
+     
+diff -ur vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranssock.c vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranssock.c
+--- vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranssock.c	Mon Mar  2 11:56:50 1998
++++ vnc-3.3.3r2/Xvnc/lib/xtrans/Xtranssock.c	Sun Jan  6 20:20:42 2002
+@@ -940,8 +940,8 @@
+     oldUmask = umask (0);
+ 
+ #ifdef UNIX_DIR
+-    if (!mkdir (UNIX_DIR, 0777))
+-        chmod (UNIX_DIR, 0777);
++    if (!mkdir (UNIX_DIR, 01777))
++        chmod (UNIX_DIR, 01777);
+ #endif
+ 
+     sockname.sun_family = AF_UNIX;
+@@ -1029,8 +1029,8 @@
+ 	int oldUmask = umask (0);
+ 
+ #ifdef UNIX_DIR
+-	if (!mkdir (UNIX_DIR, 0777))
+-	    chmod (UNIX_DIR, 0777);
++	if (!mkdir (UNIX_DIR, 01777))
++	    chmod (UNIX_DIR, 01777);
+ #endif
+ 
+ 	close (ciptr->fd);
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.6-dixfontsfix.author
+++ vnc-3.3.7/debian/patches/vnc-3.3.6-dixfontsfix.author
@@ -0,0 +1 @@
+Martin Koegler <e9925248@stud4.tuwien.ac.at>
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.4-vncpasswd-possible-minor-security-fix.author
+++ vnc-3.3.7/debian/patches/vnc-3.3.4-vncpasswd-possible-minor-security-fix.author
@@ -0,0 +1 @@
+opal@debian.org
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.6-passwddialogwhennotty.author
+++ vnc-3.3.7/debian/patches/vnc-3.3.6-passwddialogwhennotty.author
@@ -0,0 +1 @@
+William Thompson <wt@electro-mechanical.com>
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3-ppc-fix-xserver-0.author
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3-ppc-fix-xserver-0.author
@@ -0,0 +1 @@
+Kevin Puetz <puetzk@iastate.edu>; dated Tue, 3 Oct 2000 04:18:02 UTC
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.4-tunnel-via-ssh-from-tightvnc-without-anuthing-else.patch
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.4-tunnel-via-ssh-from-tightvnc-without-anuthing-else.patch
@@ -0,0 +1,482 @@
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/Makefile.in vnc-3.3.4/vncviewer/Makefile.in
+--- vnc-3.3.4-unixsrc/vncviewer/Makefile.in	2002-09-13 11:10:53.000000000 +0200
++++ vnc-3.3.4/vncviewer/Makefile.in	2002-10-28 15:47:28.000000000 +0100
+@@ -12,6 +12,7 @@
+   selection.c \
+   shm.c \
+   vncviewer.c \
++  tunnel.c \
+   sockets.cxx \
+   zrle.cxx
+ 
+@@ -28,6 +29,7 @@
+   selection.o \
+   shm.o \
+   vncviewer.o \
++  tunnel.o \
+   sockets.o \
+   zrle.o
+ 
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/argsresources.c vnc-3.3.4/vncviewer/argsresources.c
+--- vnc-3.3.4-unixsrc/vncviewer/argsresources.c	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/argsresources.c	2002-10-28 16:15:37.000000000 +0100
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -261,6 +262,22 @@
+ 
+ 
+ /*
++ * removeArgs() is used to remove some of command line arguments.
++ */
++
++void
++removeArgs(int *argc, char** argv, int idx, int nargs)
++{
++  int i;
++  if ((idx+nargs) > *argc) return;
++  for (i = idx+nargs; i < *argc; i++) {
++    argv[i-nargs] = argv[i];
++  }
++  *argc -= nargs;
++}
++
++
++/*
+  * usage() prints out the usage message.
+  */
+ 
+@@ -272,6 +289,7 @@
+ 	  "       %s [<options>] -listen [<display#>]\n"
+ 	  "\n"
+ 	  "<options> are standard Xt options, or:\n"
++	  "              -via <GATEWAY>\n"
+ 	  "              -shared\n"
+ 	  "              -viewonly\n"
+ 	  "              -fullscreen\n"
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/listen.c vnc-3.3.4/vncviewer/listen.c
+--- vnc-3.3.4-unixsrc/vncviewer/listen.c	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/listen.c	2002-10-28 16:11:50.000000000 +0100
+@@ -41,17 +41,6 @@
+ static void flashDisplay(Display *d, char *user);
+ static Bool AllXEventsPredicate(Display *d, XEvent *ev, char *arg);
+ 
+-static void
+-removeArgs(int *argc, char** argv, int idx, int nargs)
+-{
+-  int i;
+-  if ((idx+nargs) > *argc) return;
+-  for (i = idx+nargs; i < *argc; i++) {
+-    argv[i-nargs] = argv[i];
+-  }
+-  *argc -= nargs;
+-}
+-
+ /*
+  * listenForIncomingConnections() - listen for incoming connections from
+  * servers, and fork a new process to deal with each connection.  We must do
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/sockets.cxx vnc-3.3.4/vncviewer/sockets.cxx
+--- vnc-3.3.4-unixsrc/vncviewer/sockets.cxx	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/sockets.cxx	2002-10-28 15:55:13.000000000 +0100
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -203,6 +204,39 @@
+ }
+ 
+ 
++/*
++ * FindFreeTcpPort tries to find unused TCP port in the range
++ * (TUNNEL_PORT_OFFSET, TUNNEL_PORT_OFFSET + 99]. Returns 0 on failure.
++ */
++
++int
++FindFreeTcpPort(void)
++{
++  int sock, port;
++  struct sockaddr_in addr;
++
++  addr.sin_family = AF_INET;
++  addr.sin_addr.s_addr = INADDR_ANY;
++
++  sock = socket(AF_INET, SOCK_STREAM, 0);
++  if (sock < 0) {
++    fprintf(stderr,programName);
++    perror(": FindFreeTcpPort: socket");
++    return 0;
++  }
++
++  for (port = TUNNEL_PORT_OFFSET + 99; port > TUNNEL_PORT_OFFSET; port--) {
++    addr.sin_port = htons((unsigned short)port);
++    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) == 0) {
++      close(sock);
++      return port;
++    }
++  }
++
++  close(sock);
++  return 0;
++}
++
+ 
+ /*
+  * ListenAtTcpPort starts listening at the given TCP port.
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/tunnel.c vnc-3.3.4/vncviewer/tunnel.c
+--- vnc-3.3.4-unixsrc/vncviewer/tunnel.c	1970-01-01 01:00:00.000000000 +0100
++++ vnc-3.3.4/vncviewer/tunnel.c	2002-10-28 16:22:54.000000000 +0100
+@@ -0,0 +1,254 @@
++/*
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
++ *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
++ *
++ *  This is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License as published by
++ *  the Free Software Foundation; either version 2 of the License, or
++ *  (at your option) any later version.
++ *
++ *  This software is distributed in the hope that it will be useful,
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *  GNU General Public License for more details.
++ *
++ *  You should have received a copy of the GNU General Public License
++ *  along with this software; if not, write to the Free Software
++ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
++ *  USA.
++ */
++
++/*
++ * tunnel.c - tunneling support (e.g. for using standalone SSH installation)
++ */
++
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <vncviewer/vncviewer.h>
++
++/* True if there was -tunnel or -via option in the command line. */
++Bool tunnelSpecified = False;
++
++/* True if it was -tunnel, not -via option. */
++static Bool tunnelOption = False;
++
++/* "Hostname:display" pair in the command line will be substituted
++   by this fake argument when tunneling is used. */
++static char lastArgv[32];
++
++
++static void processTunnelArgs(char **remoteHost,
++			      int *remotePort, int localPort,
++			      int *pargc, char **argv, int tunnelArgIndex);
++static void processViaArgs(char **gatewayHost, char **remoteHost,
++			   int *remotePort, int localPort,
++			   int *pargc, char **argv, int tunnelArgIndex);
++static char *getCmdPattern(void);
++static Bool fillCmdPattern(char *result, char *pattern,
++			   char *gatewayHost, char *remoteHost,
++			   char *remotePort, char *localPort);
++static Bool runCommand(char *cmd);
++
++
++Bool
++createTunnel(int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pattern;
++  char cmd[1024];
++  int localPort, remotePort;
++  char localPortStr[8];
++  char remotePortStr[8];
++  char *gatewayHost = "";
++  char *remoteHost = "localhost";
++
++  tunnelSpecified = True;
++  if (strcmp(argv[tunnelArgIndex], "-tunnel") == 0)
++    tunnelOption = True;
++
++  pattern = getCmdPattern();
++  if (!pattern)
++    return False;
++
++  localPort = FindFreeTcpPort();
++  if (localPort == 0)
++    return False;
++
++  if (tunnelOption) {
++    processTunnelArgs(&remoteHost, &remotePort, localPort,
++		      pargc, argv, tunnelArgIndex);
++  } else {
++    processViaArgs(&gatewayHost, &remoteHost, &remotePort, localPort,
++		   pargc, argv, tunnelArgIndex);
++  }
++
++  sprintf(localPortStr, "%d", localPort);
++  sprintf(remotePortStr, "%d", remotePort);
++
++  if (!fillCmdPattern(cmd, pattern, gatewayHost, remoteHost,
++		      remotePortStr, localPortStr))
++    return False;
++
++  if (!runCommand(cmd))
++    return False;
++
++  return True;
++}
++
++static void
++processTunnelArgs(char **remoteHost, int *remotePort, int localPort,
++		  int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pdisplay;
++  //int port;
++
++  if (tunnelArgIndex >= *pargc - 1)
++    usage();
++
++  pdisplay = strchr(argv[*pargc - 1], ':');
++  if (pdisplay == NULL || pdisplay == argv[*pargc - 1])
++    usage();
++
++  *pdisplay++ = '\0';
++  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
++    usage();
++
++  *remotePort = atoi(pdisplay);
++  if (*remotePort < 100)
++    *remotePort += SERVER_PORT_OFFSET;
++
++  sprintf(lastArgv, "localhost:%d", localPort);
++
++  *remoteHost = argv[*pargc - 1];
++  argv[*pargc - 1] = lastArgv;
++
++  removeArgs(pargc, argv, tunnelArgIndex, 1);
++}
++
++static void
++processViaArgs(char **gatewayHost, char **remoteHost,
++	       int *remotePort, int localPort,
++	       int *pargc, char **argv, int tunnelArgIndex)
++{
++  char *pdisplay;
++  //int port;
++
++  if (tunnelArgIndex >= *pargc - 2)
++    usage();
++
++  pdisplay = strchr(argv[*pargc - 1], ':');
++  if (pdisplay == NULL)
++    usage();
++
++  *pdisplay++ = '\0';
++  if (strspn(pdisplay, "-0123456789") != strlen(pdisplay))
++    usage();
++
++  *remotePort = atoi(pdisplay);
++  if (*remotePort < 100)
++    *remotePort += SERVER_PORT_OFFSET;
++
++  sprintf(lastArgv, "localhost:%d", localPort);
++
++  *gatewayHost = argv[tunnelArgIndex + 1];
++
++  if (pdisplay != &argv[*pargc - 1][1])
++    *remoteHost = argv[*pargc - 1];
++
++  argv[*pargc - 1] = lastArgv;
++
++  removeArgs(pargc, argv, tunnelArgIndex, 2);
++}
++
++static char *
++getCmdPattern(void)
++{
++  struct stat st;
++  char *pattern;
++
++  pattern = getenv((tunnelOption) ? "VNC_TUNNEL_CMD" : "VNC_VIA_CMD");
++  if (pattern == NULL) {
++    if ( stat(DEFAULT_SSH_CMD, &st) != 0 ||
++	 !(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)) ) {
++      fprintf(stderr, "%s: Cannot establish SSH tunnel: missing %s binary.\n",
++	      programName, DEFAULT_SSH_CMD);
++      return NULL;
++    }
++    pattern = (tunnelOption) ? DEFAULT_TUNNEL_CMD : DEFAULT_VIA_CMD;
++  }
++
++  return pattern;
++}
++
++/* Note: in fillCmdPattern() result points to a 1024-byte buffer */
++
++static Bool
++fillCmdPattern(char *result, char *pattern,
++	       char *gatewayHost, char *remoteHost,
++	       char *remotePort, char *localPort)
++{
++  int i, j;
++  Bool H_found = False, G_found = False, R_found = False, L_found = False;
++
++  for (i=0, j=0; pattern[i] && j<1023; i++, j++) {
++    if (pattern[i] == '%') {
++      switch (pattern[++i]) {
++      case 'H':
++	strncpy(&result[j], remoteHost, 1024 - j);
++	j += strlen(remoteHost) - 1;
++	H_found = True;
++	continue;
++      case 'G':
++	strncpy(&result[j], gatewayHost, 1024 - j);
++	j += strlen(gatewayHost) - 1;
++	G_found = True;
++	continue;
++      case 'R':
++	strncpy(&result[j], remotePort, 1024 - j);
++	j += strlen(remotePort) - 1;
++	R_found = True;
++	continue;
++      case 'L':
++	strncpy(&result[j], localPort, 1024 - j);
++	j += strlen(localPort) - 1;
++	L_found = True;
++	continue;
++      case '\0':
++	i--;
++	continue;
++      }
++    }
++    result[j] = pattern[i];
++  }
++
++  if (pattern[i]) {
++    fprintf(stderr, "%s: Tunneling command is too long.\n", programName);
++    return False;
++  }
++
++  if (!H_found || !R_found || !L_found) {
++    fprintf(stderr, "%s: %%H, %%R or %%L absent in tunneling command.\n",
++	    programName);
++    return False;
++  }
++  if (!tunnelOption && !G_found) {
++    fprintf(stderr, "%s: %%G pattern absent in tunneling command.\n",
++	    programName);
++    return False;
++  }
++
++  result[j] = '\0';
++  return True;
++}
++
++static Bool
++runCommand(char *cmd)
++{
++  if (system(cmd) != 0) {
++    fprintf(stderr, "%s: Tunneling command failed: %s.\n",
++	    programName, cmd);
++    return False;
++  }
++  return True;
++}
++
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/vncviewer.c vnc-3.3.4/vncviewer/vncviewer.c
+--- vnc-3.3.4-unixsrc/vncviewer/vncviewer.c	2002-09-20 16:29:22.000000000 +0200
++++ vnc-3.3.4/vncviewer/vncviewer.c	2002-10-28 15:54:59.000000000 +0100
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002 RealVNC Ltd.
++ *  Copyright (C) 2000 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -57,6 +58,11 @@
+       listenForIncomingConnections(&argc, argv, i);
+       break;
+     }
++    if (strcmp(argv[i], "-tunnel") == 0 || strcmp(argv[i], "-via") == 0) {
++      if (!createTunnel(&argc, argv, i))
++	exit(1);
++      break;
++    }
+   }
+ 
+   /* Call the main Xt initialisation function.  It parses command-line options,
+diff -uNr vnc-3.3.4-unixsrc/vncviewer/vncviewer.h vnc-3.3.4/vncviewer/vncviewer.h
+--- vnc-3.3.4-unixsrc/vncviewer/vncviewer.h	2002-09-01 17:58:21.000000000 +0200
++++ vnc-3.3.4/vncviewer/vncviewer.h	2002-10-28 16:23:58.000000000 +0100
+@@ -1,5 +1,6 @@
+ /*
+  *  Copyright (C) 2002 RealVNC Ltd.
++ *  Copyright (C) 2000, 2001 Const Kaplinsky.  All Rights Reserved.
+  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
+  *
+  *  This is free software; you can redistribute it and/or modify
+@@ -51,8 +52,15 @@
+ 
+ #define FLASH_PORT_OFFSET 5400
+ #define LISTEN_PORT_OFFSET 5500
++#define TUNNEL_PORT_OFFSET 5500
+ #define SERVER_PORT_OFFSET 5900
+ 
++#define DEFAULT_SSH_CMD "/usr/bin/ssh"
++#define DEFAULT_TUNNEL_CMD  \
++  (DEFAULT_SSH_CMD " -f -L %L:localhost:%R %H sleep 20")
++#define DEFAULT_VIA_CMD     \
++  (DEFAULT_SSH_CMD " -f -L %L:%H:%R %G sleep 20")
++
+ 
+ /* argsresources.c */
+ 
+@@ -103,6 +111,8 @@
+ extern XrmOptionDescRec cmdLineOptions[];
+ extern int numCmdLineOptions;
+ 
++extern void removeArgs(int *argc, char** argv, int idx, int nargs);
++extern void usage();
+ extern void GetArgsAndResources(int argc, char **argv);
+ extern void SetFullScreenState(Widget w, XEvent *event, String *params,
+ 			       Cardinal *num_params);
+@@ -234,11 +244,21 @@
+ extern Bool ReadFromRFBServer(char *out, unsigned int n);
+ extern Bool WriteToRFBServer(char *buf, int n);
+ extern int ConnectToTcpAddr(const char* hostname, int port);
++extern int FindFreeTcpPort(void);
+ extern int ListenAtTcpPort(int port);
+ extern int AcceptTcpConnection(int listenSock);
+ 
+ extern int StringToIPAddr(const char *str, unsigned int *addr);
+ 
++extern Bool SameMachine(int sock);
++
++/* tunnel.c */
++
++extern Bool tunnelSpecified;
++
++extern Bool createTunnel(int *argc, char **argv, int tunnelArgIndex);
++
++
+ /* vncviewer.c */
+ 
+ extern char *programName;
+--- vnc-3.3.4-unixsrc/vncviewer/vncviewer.man~	2002-09-19 19:02:52.000000000 +0200
++++ vnc-3.3.4/vncviewer/vncviewer.man	2002-10-28 16:51:14.000000000 +0100
+@@ -89,6 +89,11 @@
+ on customisation below.
+ 
+ .TP
++.B \-via \fIXgateway\fP
++Makes the connection go though SSH to a gateway host. The gateway should be the
++target host for best connection secrecy.
++
++.TP
+ .B \-listen \fI[display-number]\fP
+ Causes vncviewer to listen on port 5500 +
+ .I display-number
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3r2-vncconnect-spellfix.patch
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3r2-vncconnect-spellfix.patch
@@ -0,0 +1,11 @@
+--- vnc-3.3.3r2.orig/vncconnect/vncconnect.c
++++ vnc-3.3.3r2/vncconnect/vncconnect.c
+@@ -11,7 +11,7 @@
+ static void usage()
+ {
+     fprintf(stderr, "usage: %s [-display Xvnc-display] host[:port]\n"
+-	    "Tells Xvnc to connects to a listening VNC viewer on the given"
++	    "Tells Xvnc to connect to a listening VNC viewer on the given"
+ 							    " host and port\n",
+ 	    programName);
+     exit(1);
--- vnc-3.3.7.orig/debian/patches/superseeded/vncauth-lynamic.patch
+++ vnc-3.3.7/debian/patches/superseeded/vncauth-lynamic.patch
@@ -0,0 +1,24 @@
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/Imakefile
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/Imakefile
+@@ -1712,7 +1712,7 @@
+ XVNC = hw/vnc/libvnc.a $(VNCLIBS)
+ XVNCLIBS = PreFbLibs $(XVNC) $(CFB) PostFbLibs
+ XVNCSYSLIBS = $(SYSLIBS) $(VNCSYSLIBS)
+-ServerTarget(Xvnc,$(XVNCDIRS),$(XVNCOBJS),$(XVNCLIBS),$(XVNCSYSLIBS))
++ServerTarget(Xvnc,$(XVNCDIRS),$(XVNCOBJS),$(XVNCLIBS), -L$(TOP)/../libvncauth -lvncauth $(XVNCSYSLIBS))
+ #endif /* XvncServer */
+ 
+ 
+--- vnc-3.3.3r2.orig/vncpasswd/Imakefile
++++ vnc-3.3.3r2/vncpasswd/Imakefile
+@@ -8,8 +8,9 @@
+ SRCS = vncpasswd.c
+ INCLUDES = -I../include
+ VNCAUTH_LIB = ../libvncauth/libvncauth.a
++EXTRA_LDOPTIONS = -L../libvncauth
+ 
+ all:: vncpasswd
+ 
+-NormalProgramTarget(vncpasswd,vncpasswd.o,$(VNCAUTH_LIB),$(VNCAUTH_LIB),)
++NormalProgramTarget(vncpasswd,vncpasswd.o,$(VNCAUTH_LIB),-lvncauth,)
+ DependTarget()
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3-ppc-fix-xserver-0.diff
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3-ppc-fix-xserver-0.diff
@@ -0,0 +1,29 @@
+--- vnc-3.3.3/Xvnc/programs/Xserver/include/servermd.h  Mon Jul 28 09:17:34 1997
++++ vnc-3.3.3.patched/Xvnc/programs/Xserver/include/servermd.h  Mon Oct  2 12:39:49 2000
+@@ -336,7 +336,7 @@
+ 
+ #endif /* luna */
+ 
+-#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !defined(__mc68000__)) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
++#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !(defined(__mc68000__) || defined(PPC))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
+ 
+ #ifndef IMAGE_BYTE_ORDER
+ #define IMAGE_BYTE_ORDER       LSBFirst
+@@ -380,6 +380,18 @@
+ #define GETLEFTBITS_ALIGNMENT  1
+ 
+ #endif /* linux/m68k */
++
++#if defined (linux) && defined (PPC)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#define LARGE_INSTRUCTION_CACHE
++#define FAST_CONSTANT_OFFSET_MODE
++
++#endif /* linux/PPC */
+ 
+ #ifdef sgi
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3r2-ppcsparc-fix-xserver-1.diff
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3r2-ppcsparc-fix-xserver-1.diff
@@ -0,0 +1,64 @@
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/include/servermd.h	Mon Jul 28 10:17:34 1997
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/include/servermd.h	Tue Dec 12 13:40:57 2000
+@@ -336,7 +336,7 @@
+ 
+ #endif /* luna */
+ 
+-#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !defined(__mc68000__)) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
++#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && !(defined(__mc68000__) || defined(PPC) || defined(__sparc__))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__)))
+ 
+ #ifndef IMAGE_BYTE_ORDER
+ #define IMAGE_BYTE_ORDER	LSBFirst
+@@ -380,6 +380,27 @@
+ #define GETLEFTBITS_ALIGNMENT  1
+ 
+ #endif /* linux/m68k */
++
++#if defined (linux) && defined (PPC)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#define LARGE_INSTRUCTION_CACHE
++#define FAST_CONSTANT_OFFSET_MODE
++
++#endif /* linux/PPC */
++
++#if defined (linux) && defined (__sparc__)
++
++#define IMAGE_BYTE_ORDER       MSBFirst
++#define BITMAP_BIT_ORDER       MSBFirst
++#define GLYPHPADBYTES          4
++#define GETLEFTBITS_ALIGNMENT  1
++
++#endif /* linux/__sparc__ */
+ 
+ #ifdef sgi
+ 
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/cfb/stipsparc.s	Wed Apr 27 03:14:23 1994
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/cfb/stipsparc.s	Tue Dec 12 12:15:51 2000
+@@ -85,7 +85,7 @@
+ #define ForEachBits	LY4
+ #define NextBits	LY5
+ 
+-#ifdef SVR4
++#if defined(SVR4) || (defined(linux) && defined(__sparc__))
+ #ifdef TETEXT
+ #define	_cfbStippleStack	cfbStippleStackTE
+ #else
+
+--- vnc-3.3.3r2.orig/Xvnc/programs/Xserver/cfb/stipsprc32.s	Wed Apr 27 03:14:23 1994
++++ vnc-3.3.3r2/Xvnc/programs/Xserver/cfb/stipsprc32.s	Tue Dec 12 12:16:13 2000
+@@ -81,7 +81,7 @@
+ #define ForEachBits	LY4
+ #define NextBits	LY5
+ 
+-#ifdef SVR4
++#if defined(SVR4) || (defined(linux) && defined(__sparc__))
+ #ifdef TETEXT
+ #define	_cfb32StippleStack	cfb32StippleStackTE
+ #else
+
+
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3r2-vncpasswd-filecreation-fix.patch
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3r2-vncpasswd-filecreation-fix.patch
@@ -0,0 +1,86 @@
+--- vnc-3.3.3r2.orig/vncpasswd/vncpasswd.c
++++ vnc-3.3.3r2/vncpasswd/vncpasswd.c
+@@ -24,9 +24,12 @@
+  *              anyway.
+  */
+ 
++#include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/stat.h>
++#include <sys/types.h>
+ #include <unistd.h>
+ #include "vncauth.h"
+ 
+@@ -36,24 +39,40 @@
+ }
+ 
+ int main(int argc, char *argv[]) {
++  char *home_env;
+   char *passwd;
+   char *passwd1;
++  char *cp;
++  char passwdDir[256];
+   char passwdFile[256];
+   int i;
+ 
+   if (argc == 1) {
+-      if (getenv("HOME") == NULL) {
+-	  fprintf(stderr,"Error: no HOME environment variable\n");
+-	  exit(1);
+-      }
+-      sprintf(passwdFile,"%s/.vnc/passwd",getenv("HOME"));
++    home_env = getenv("HOME");
++    if (home_env == NULL) {
++      fprintf(stderr,"Error: no HOME environment variable\n");
++      exit(1);
++    }
++    if (strlen(home_env) > 240) {
++      fprintf(stderr,"Error: HOME environment variable string too long\n");
++      exit(1);
++    }
++    sprintf(passwdDir, "%s/.vnc", home_env);
++    sprintf(passwdFile, "%s/passwd", passwdDir);
+ 
+   } else if (argc == 2) {
+-
+-      strcpy(passwdFile,argv[1]);
+-
++    strcpy(passwdFile,argv[1]);
++    strcpy(passwdDir,argv[1]);
++    cp = strrchr(passwdDir, '/');
++    if (cp == 0) {
++	/* no directory part */
++	passwdDir[0] = '\0';
++    } else {
++	/* cut filename */
++	*cp = '\0';
++    }
+   } else {
+-      usage(argv);
++    usage(argv);
+   }
+ 
+   while (1) {  
+@@ -78,13 +97,19 @@
+     }
+ 
+     if (strcmp(passwd1, passwd) == 0) {
++      if (mkdir (passwdDir, (S_IRWXU | S_IRGRP | S_IXGRP |
++			     S_IROTH | S_IXOTH)) == -1 &&
++	  errno != EEXIST) {
++	perror (passwdDir);
++	exit (1);
++      }
+       if (vncEncryptAndStorePasswd(passwd, passwdFile) != 0) {
+ 	fprintf(stderr,"Cannot write password file %s\n",passwdFile);
+ 	exit(1);
+       }
+       for (i = 0; i < strlen(passwd); i++)
+ 	passwd[i] = passwd1[i] = '\0';
+-      return;
++      return 0;
+     }
+ 
+     fprintf(stderr,"They don't match. Try again.\n\n");
--- vnc-3.3.7.orig/debian/patches/superseeded/vnc-3.3.3r2-ppcsparc-fix-xserver-1.txt
+++ vnc-3.3.7/debian/patches/superseeded/vnc-3.3.3r2-ppcsparc-fix-xserver-1.txt
@@ -0,0 +1,15 @@
+Rich Sahlender <rsahlen@debian.org>
+
+The patch below to servermd.h is a Sparc version of the PPC endian
+patch from #73022. It fixed the garbled text on sparc64 for me.
+
+The additional patches to stipsparc.s and stipsprc32.s are not endian
+fixes but were required for me to build from source on a sparc64.
+It might have been safer to:
+
+if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
+
+but I was in a hurry <grin>.
+
+Regards,
+Rich
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-amd64support.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-amd64support.patch
@@ -0,0 +1,106 @@
+From: Andreas Jochens <aj@andaco.de>
+
+Package: vnc
+Severity: normal
+Tags: patch
+
+The package does not build on amd64 because support for amd64
+is missing in Xvnc/config/cf/Imake.cf and Xvnc/config/cf/linux.cf.
+
+Regards
+Andreas Jochens
+
+diff -urN ../tmp-orig/vnc-3.3.7/Xvnc/config/cf/Imake.cf ./Xvnc/config/cf/Imake.cf
+--- ../tmp-orig/vnc-3.3.7/Xvnc/config/cf/Imake.cf	2004-06-17 00:05:37.918990788 +0200
++++ ./Xvnc/config/cf/Imake.cf	2004-06-17 00:03:02.728007838 +0200
+@@ -740,6 +740,16 @@
+ #  endif
+ #  undef __sparc__
+ # endif
++# ifdef x86_64 
++#  define x86_64Architecture
++#  undef x86_64 
++# endif
++# ifdef __x86_64__
++#  ifndef x86_64Architecture
++#   define x86_64Architecture
++#  endif
++#  undef __x86_64__
++# endif
+ # ifdef ia64 
+ #  define ia64Architecture
+ #  undef ia64 
+diff -urN ../tmp-orig/vnc-3.3.7/Xvnc/config/cf/linux.cf ./Xvnc/config/cf/linux.cf
+--- ../tmp-orig/vnc-3.3.7/Xvnc/config/cf/linux.cf	2004-06-17 00:05:37.923989821 +0200
++++ ./Xvnc/config/cf/linux.cf	2004-06-17 00:05:10.923212162 +0200
+@@ -281,6 +281,8 @@
+ #    define BuildXF86DRI	NO
+ #  elif defined(HPArchitecture)
+ #    define BuildXF86DRI	NO
++#  elif defined(x86_64Architecture)
++#    define BuildXF86DRI	YES
+ #  elif defined(ia64Architecture)
+ #    define BuildXF86DRI	YES
+ #  elif defined(Mc68020Architecture)
+@@ -315,7 +317,7 @@
+    kernel revisions.  So, we'll only build the module for kernels that are
+    known to be supported by the module. */
+ #ifndef BuildXF86DRM
+-#  if defined(i386Architecture) || defined(ia64Architecture) || defined(SparcArchitecture) || defined(AlphaArchitecture)
++#  if defined(i386Architecture) || defined(x86_64Architecture) || defined(ia64Architecture) || defined(SparcArchitecture) || defined(AlphaArchitecture)
+ #    if OSMajorVersion == 2
+        /* Only tested for Linux 2.2.0 through 2.2.12 */
+ #      if OSMinorVersion == 2 && OSTeenyVersion <= 12
+@@ -339,7 +341,7 @@
+ #endif
+ 
+ #ifndef HasAgpGart
+-#  if defined(i386Architecture) || defined(ia64Architecture)
++#  if defined(i386Architecture) || defined(x86_64Architecture) || defined(ia64Architecture)
+      /* The AGPGART header file is included in os-support/linux, which
+         allows all drivers that depend on AGP to build properly. */
+ #    define HasAgpGart	YES
+@@ -542,6 +544,13 @@
+ #   define LdCmd		ld
+ #   define AsmDefines		-DUSE_GAS -U__ELF__
+ #  endif /* HPArchitecture */
++#  ifdef x86_64Architecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-DUSE_GAS -U__ELF__
++#  endif /* x86_64Architecture */
+ #  ifdef ia64Architecture
+ #   define CcCmd		gcc
+ #   define CplusplusCmd		g++
+@@ -573,6 +582,13 @@
+ #   define AsmDefines		-D__ELF__
+ #   define CplusplusCmd		c++ -b alpha-linux
+ #  endif /* AlphaArchitecture */
++#  ifdef x86_64Architecture
++#   define CcCmd		gcc
++#   define CplusplusCmd		g++
++#   define AsCmd		as
++#   define LdCmd		ld
++#   define AsmDefines		-D__ELF__
++#  endif /* x86_64Architecture */
+ #  ifdef ia64Architecture
+ #   define CcCmd		gcc
+ #   define CplusplusCmd		g++
+@@ -689,6 +705,15 @@
+ # define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+ #endif /* Arm32Achitecture */
+ 
++#ifdef x86_64Architecture
++# ifndef OptimizedCDebugFlags
++#  define OptimizedCDebugFlags	-O2
++# endif
++# define LinuxMachineDefines	-D__x86_64__
++# define ServerOSDefines	XFree86ServerOSDefines -DDDXTIME -DPART_NET
++# define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines -D_XSERVER64
++#endif /* x86_64Architecture */
++
+ #ifdef ia64Architecture
+ # ifndef OptimizedCDebugFlags
+ #  define OptimizedCDebugFlags	-O2
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-passwdfix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-passwdfix.patch
@@ -0,0 +1,23 @@
+From: Roderick Schertler <roderick@argon.org>
+
+Package: vnc-common
+Version: 3.3.7-1
+Severity: normal
+Tags: patch
+
+vncpasswd fails on a file name without a directory part.  Here is a fix.
+
+--- vnc-3.3.7/vncpasswd/vncpasswd.c.~1~	2004-02-05 10:36:28.000000000 -0500
++++ vnc-3.3.7/vncpasswd/vncpasswd.c	2004-02-05 10:37:55.000000000 -0500
+@@ -102,8 +102,9 @@
+     }
+ 
+     if (strcmp(passwd1, passwd) == 0) {
+-      if (mkdir (passwdDir, (S_IRWXU | S_IRGRP | S_IXGRP |
+- 			     S_IROTH | S_IXOTH)) == -1 &&
++      if (passwdDir[0] &&
++	  mkdir (passwdDir, (S_IRWXU | S_IRGRP | S_IXGRP |
++			     S_IROTH | S_IXOTH)) == -1 &&
+  	  errno != EEXIST) {
+  	perror (passwdDir);
+  	exit (1);
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-ipv6support.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-ipv6support.patch
@@ -0,0 +1,140 @@
+Robert Bihlmeyer <robbe@orcus.priv.at>
+
+diff -ruNx configure vnc-3.3.6/Xvnc/programs/Xserver/hw/vnc/sockets.c vnc-3.3.6+/Xvnc/programs/Xserver/hw/vnc/sockets.c
+--- vnc-3.3.6/Xvnc/programs/Xserver/hw/vnc/sockets.c	2002-11-21 15:47:08.000000000 +0100
++++ vnc-3.3.6+/Xvnc/programs/Xserver/hw/vnc/sockets.c	2003-02-22 22:47:20.000000000 +0100
+@@ -409,11 +409,25 @@
+ ListenOnTCPPort(port)
+     int port;
+ {
+-    struct sockaddr_in addr;
+     int sock;
+     int one = 1;
++#ifdef AF_INET6
++    struct sockaddr_in6 addr;
++#else
++    struct sockaddr_in addr;
++#endif
+ 
+     memset(&addr, 0, sizeof(addr));
++#ifdef AF_INET6
++    addr.sin6_family = AF_INET6;
++    addr.sin6_port = htons(port);
++    if (rfbLocalhostOnly)
++	addr.sin6_addr = in6addr_loopback;
++    else
++        addr.sin6_addr = in6addr_any;
++
++    if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
++#else
+     addr.sin_family = AF_INET;
+     addr.sin_port = htons(port);
+     if (rfbLocalhostOnly)
+@@ -422,6 +436,7 @@
+         addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ 
+     if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
++#endif
+ 	return -1;
+     }
+     if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+diff -ruNx configure vnc-3.3.6/configure.in vnc-3.3.6+/configure.in
+--- vnc-3.3.6/configure.in	2002-11-26 17:33:28.000000000 +0100
++++ vnc-3.3.6+/configure.in	2003-02-22 21:45:51.000000000 +0100
+@@ -74,6 +74,8 @@
+ SOCKLEN_T_DEFINE='-Dsocklen_t=int')
+ AC_SUBST(SOCKLEN_T_DEFINE)
+ 
++AC_CHECK_FUNCS(getaddrinfo)
++
+ AC_OUTPUT(Makefile:Makefile.in:boilerplate.mk \
+          rdr/Makefile:rdr/Makefile.in:boilerplate.mk \
+          rfb/Makefile:rfb/Makefile.in:boilerplate.mk \
+diff -ruNx configure vnc-3.3.6/vncviewer/argsresources.c vnc-3.3.6+/vncviewer/argsresources.c
+--- vnc-3.3.6/vncviewer/argsresources.c	2003-02-22 22:43:28.000000000 +0100
++++ vnc-3.3.6+/vncviewer/argsresources.c	2003-02-22 21:18:22.000000000 +0100
+@@ -369,9 +369,16 @@
+     exit(1);
+   }
+ 
+-  for (i = 0; vncServerName[i] != ':' && vncServerName[i] != 0; i++);
++  if (vncServerName[0] == '[') {
++    for (i = 1; vncServerName[i] != ']' && vncServerName[i] != 0; i++);
+ 
+-  strncpy(vncServerHost, vncServerName, i);
++    strncpy(vncServerHost, vncServerName + 1, i - 1);
++    i++;
++  } else {
++    for (i = 0; vncServerName[i] != ':' && vncServerName[i] != 0; i++);
++
++    strncpy(vncServerHost, vncServerName, i);
++  }
+ 
+   if (vncServerName[i] == ':') {
+     vncServerPort = atoi(&vncServerName[i+1]);
+diff -ruNx configure vnc-3.3.6/vncviewer/sockets.cxx vnc-3.3.6+/vncviewer/sockets.cxx
+--- vnc-3.3.6/vncviewer/sockets.cxx	2003-02-22 22:43:28.000000000 +0100
++++ vnc-3.3.6+/vncviewer/sockets.cxx	2003-02-22 21:55:05.000000000 +0100
+@@ -32,6 +32,9 @@
+ #include <netdb.h>
+ #include <fcntl.h>
+ #include <assert.h>
++#ifdef HAVE_GETADDRINFO
++#include <netdb.h>
++#endif
+ extern "C" {
+ #include "vncviewer.h"
+ }
+@@ -166,8 +169,22 @@
+ int ConnectToTcpAddr(const char* hostname, int port)
+ {
+   int sock;
+-  struct sockaddr_in addr;
+   int one = 1;
++#ifdef HAVE_GETADDRINFO
++  struct addrinfo *info, hints = { 0, PF_UNSPEC, SOCK_STREAM, 0 };
++  int error;
++  
++  if ((error = getaddrinfo(hostname, NULL, &hints, &info)) != 0) {
++    fprintf(stderr, "Couldn't convert '%s' to host address: %s\n", hostname,
++	    gai_strerror(error));
++    return -1;
++  }
++
++  ((struct sockaddr_in *)info->ai_addr)->sin_port = htons(port);
++
++  sock = socket(info->ai_family, info->ai_socktype, info->ai_protocol);
++#else
++  struct sockaddr_in addr;
+   unsigned int host;
+ 
+   if (!StringToIPAddr(hostname, &host)) {
+@@ -181,19 +198,28 @@
+   addr.sin_addr.s_addr = host;
+ 
+   sock = socket(AF_INET, SOCK_STREAM, 0);
++#endif
+   if (sock < 0) {
+     fprintf(stderr,programName);
+     perror(": ConnectToTcpAddr: socket");
+     return -1;
+   }
+ 
++#ifdef HAVE_GETADDRINFO
++  if (connect(sock, info->ai_addr, info->ai_addrlen) < 0) {
++#else
+   if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
++#endif
+     fprintf(stderr,programName);
+     perror(": ConnectToTcpAddr: connect");
+     close(sock);
+     return -1;
+   }
+ 
++#ifdef HAVE_GETADDRINFO
++  freeaddrinfo(info);
++#endif
++
+   if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,
+ 		 (char *)&one, sizeof(one)) < 0) {
+     fprintf(stderr,programName);
--- vnc-3.3.7.orig/debian/patches/manual/vnc-3.3.7-xfs-reconnect.patch
+++ vnc-3.3.7/debian/patches/manual/vnc-3.3.7-xfs-reconnect.patch
@@ -0,0 +1,41 @@
+From: Martin Koegler <e9925248@stud4.tuwien.ac.at>
+
+Package: tightvncserver
+Version: 1.2.6-4
+Severity: normal
+Tags: patch
+
+I use xfs in my font-path for Xtightvnc. If i restart xfs (/etc/init.d/xfs reload), the Xtightvnc-process starts using all available cpu-time (Idle 0%)
+
+To reproduce run (each command at a different shell):
+xfs -port 8000 
+Xtightvnc :30 -fp tcp/localhost:8000
+Then send Signal 1 to xfs (kill -1).
+A top will show after a few seconds, that Xtightvnc uses all of the free cpu-time.
+
+
+The problem is, that an reconnect is started, but the reconnect is never done.
+Xvnc tries to reopen the connection, but the reconnect-code is never reached.
+Before the select, it notices that an reconnect is pending and starts immediately the next try.
+
+A simple solution is to insert the reconnect-hook at another position:
+In Xvnc/lib/font/fc/fserve.c needs to be changed:
+--- fserve.c~	Tue Mar 19 11:29:49 2002
++++ fserve.c	Sun Jan 12 14:41:37 2003
+@@ -1232,6 +1232,9 @@
+     int         err;
+     fsGenericReply rep;
+ 
++    if (awaiting_reconnect) {
++	_fs_try_reconnect();
++    }
+     /* see if there's any data to be read */
+ 
+     /* 
+
+Maybe the reconnect-code at the end of the function could be removed, but it causes no problem.
+
+
+Xrealvnc has the same problem and contains the same file. So the patch should also work for it, but i have not tried it there.
+
+mfg Martin Kögler
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-cutbufferworkaround.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-cutbufferworkaround.patch
@@ -0,0 +1,13 @@
+--- vnc-3.3.7/vncviewer/Vncviewer.ad~	2002-08-31 20:01:29.000000000 +0200
++++ vnc-3.3.7/vncviewer/Vncviewer.ad	2004-08-13 10:06:19.000000000 +0200
+@@ -19,8 +19,8 @@
+ !
+ 
+ Vncviewer.translations:\
+-  <Enter>: SelectionToVNC()\n\
+-  <Leave>: SelectionFromVNC()
++  <Enter>: SelectionToVNC(always)\n\
++  <Leave>: SelectionFromVNC(always)
+ 
+ 
+ !
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-ipv6support-ipv4revertfix.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-ipv6support-ipv4revertfix.patch
@@ -0,0 +1,52 @@
+From: "J.H.M. Dassen (Ray)" <fsmla@xinara.org>
+
+The IPv6 patch introduced in 3.3.7-3 is unconditional. It doesn't fall back
+to IPv4 if an IPv6 socket cannot be established.
+
+A straightforward fix would be fall back to trying to establish an IPv4
+socket if an IPv6 one cannot be established. The attached (untested) patch
+probably does that.
+
+A saner solution though would be modify Xvnc so that not just the port, but
+also the address (and thereby address family) on which to bind are
+configurable.
+
+HTH,
+Ray
+
+diff -ruN vnc-3.3.7.old/Xvnc/programs/Xserver/hw/vnc/sockets.c vnc-3.3.7/Xvnc/programs/Xserver/hw/vnc/sockets.c
+--- vnc-3.3.7.old/Xvnc/programs/Xserver/hw/vnc/sockets.c	2004-08-14 17:45:33.000000000 +0200
++++ vnc-3.3.7/Xvnc/programs/Xserver/hw/vnc/sockets.c	2004-08-14 17:45:15.000000000 +0200
+@@ -426,18 +426,21 @@
+     else
+         addr.sin6_addr = in6addr_any;
+ 
+-    if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
+-#else
+-    addr.sin_family = AF_INET;
+-    addr.sin_port = htons(port);
+-    if (rfbLocalhostOnly)
+-        addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+-    else
+-        addr.sin_addr.s_addr = htonl(INADDR_ANY);
+-
+-    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
++    /* Don't fail if an IPv6 socket cannot be established, but fall back to
++       IPv4 */
++    if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
+ #endif
+-	return -1;
++    {
++        addr.sin_family = AF_INET;
++        addr.sin_port = htons(port);
++        if (rfbLocalhostOnly)
++            addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
++        else
++            addr.sin_addr.s_addr = htonl(INADDR_ANY);
++
++        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
++            return -1;
++        }
+     }
+     if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ 		   (char *)&one, sizeof(one)) < 0) {
--- vnc-3.3.7.orig/debian/patches/vnc-3.3.7-ipv6support-ipv4revertfix-modification.patch
+++ vnc-3.3.7/debian/patches/vnc-3.3.7-ipv6support-ipv4revertfix-modification.patch
@@ -0,0 +1,70 @@
+--- vnc-3.3.7/Xvnc/programs/Xserver/hw/vnc/sockets.c~	2004-08-14 19:13:27.000000000 +0200
++++ vnc-3.3.7/Xvnc/programs/Xserver/hw/vnc/sockets.c	2004-08-14 19:33:55.000000000 +0200
+@@ -412,25 +412,27 @@
+     int sock;
+     int one = 1;
+ #ifdef AF_INET6
+-    struct sockaddr_in6 addr;
+-#else
+-    struct sockaddr_in addr;
++    int ipv = 4;
++    struct sockaddr_in6 addr6;
+ #endif
++    struct sockaddr_in addr;
+ 
+     memset(&addr, 0, sizeof(addr));
+ #ifdef AF_INET6
+-    addr.sin6_family = AF_INET6;
+-    addr.sin6_port = htons(port);
++    ipv = 6;
++    addr6.sin6_family = AF_INET6;
++    addr6.sin6_port = htons(port);
+     if (rfbLocalhostOnly)
+-	addr.sin6_addr = in6addr_loopback;
++	addr6.sin6_addr = in6addr_loopback;
+     else
+-        addr.sin6_addr = in6addr_any;
++        addr6.sin6_addr = in6addr_any;
+ 
+     /* Don't fail if an IPv6 socket cannot be established, but fall back to
+        IPv4 */
+     if ((sock = socket(AF_INET6, SOCK_STREAM, 0)) < 0)
+-#endif
+     {
++        ipv = 4;
++#endif
+         addr.sin_family = AF_INET;
+         addr.sin_port = htons(port);
+         if (rfbLocalhostOnly)
+@@ -441,16 +443,30 @@
+         if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+             return -1;
+         }
++#ifdef AF_INET6
+     }
++#endif
+     if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
+ 		   (char *)&one, sizeof(one)) < 0) {
+ 	close(sock);
+ 	return -1;
+     }
+-    if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
++#ifdef AF_INET6
++    if (ipv == 6) {
++      if (bind(sock, (struct sockaddr *)&addr6, sizeof(addr6)) < 0) {
+ 	close(sock);
+ 	return -1;
++      }
+     }
++    else if (ipv == 4) {
++#endif
++      if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
++	close(sock);
++	return -1;
++      }      
++#ifdef AF_INET6
++    }
++#endif
+     if (listen(sock, 5) < 0) {
+ 	close(sock);
+ 	return -1;
--- vnc-3.3.7.orig/debian/copyright
+++ vnc-3.3.7/debian/copyright
@@ -0,0 +1,83 @@
+This package was packaged for Debian by Christoph Lameter <clameter@debian.org>
+on Mon, 23 Feb 1998 15:00:26 -0800.
+
+It was taken over by Marcus Brinkmann <Marcus Brinkmann@ruhr-uni-bochum.de>
+on Sat, 14 Mar 1998 19:27:31 +0100.
+
+It was taken over by Edward Betts <edward@debian.org>
+on Sat, 30 Oct 1999 19:57:42 +0100
+
+It was taken over by Ola Lundqvist <opal@debian.org>
+on Tue, 21 Nov 2000 14:45:10 +0100
+
+It was originally downloaded from:
+	http://www.orl.co.uk/vnc/
+Later this changed to:
+	http://www.uk.research.att.com/vnc/.
+And now:
+	http://www.realvnc.com/
+
+COPYRIGHT:
+==========
+
+Copyright (C) 2002 RealVNC Ltd.
+Copyright (C) 1994-2000 Olivetti Research Ltd/AT&T Laboratories Cambridge.
+All Rights Reserved.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License with
+ your Debian GNU system, in /usr/share/common-licenses/GPL, or with the
+ Debian GNU source package as the file LICENSE.TXT.  If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ Boston, MA 02111-1307, USA.
+
+
+ACKNOWLEDGEMENTS
+================
+
+This distribution contains public domain DES software by Richard
+Outerbridge.
+This is:
+
+    Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge.
+    (GEnie : OUTER; CIS : [71755,204]) Graven Imagery, 1992.
+
+
+This distribution contains software from the X Window System, Version 11,
+Release 6.  This is:
+
+    Copyright (C) 1994 X Consortium
+
+    Permission is hereby granted, free of charge, to any person obtaining a
+    copy of this software and associated documentation files (the
+    "Software"), to deal in the Software without restriction, including
+    without limitation the rights to use, copy, modify, merge, publish,
+    distribute, sublicense, and/or sell copies of the Software, and to
+    permit persons to whom the Software is furnished to do so, subject to
+    the following conditions:
+
+    The above copyright notice and this permission notice shall be included
+    in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+    OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+    IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+    OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+    ARISING FROM, OUT OF OR IN CONNEC- TION WITH THE SOFTWARE OR THE USE OR
+    OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the name of the X Consortium shall
+    not be used in advertising or otherwise to promote the sale, use or
+    other deal- ings in this Software without prior written authorization
+    from the X Consor- tium.
+
+    X Window System is a trademark of X Consortium, Inc.
--- vnc-3.3.7.orig/debian/xvncviewer.dirs
+++ vnc-3.3.7/debian/xvncviewer.dirs
@@ -0,0 +1,3 @@
+etc/X11/app-defaults
+usr/bin
+usr/share/man/man1
--- vnc-3.3.7.orig/debian/xvncviewer.menu
+++ vnc-3.3.7/debian/xvncviewer.menu
@@ -0,0 +1,5 @@
+?package(xvncviewer):needs="x11" \
+  section="Apps/Net" \
+  hints="VNC,remote-control"\
+  title="xvncviewer" \
+  command="/usr/bin/xrealvncviewer"
--- vnc-3.3.7.orig/debian/xvncviewer.prerm
+++ vnc-3.3.7/debian/xvncviewer.prerm
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+if [ "$1" = "remove" ] ; then
+    BIN=/usr/bin
+    update-alternatives --remove \
+	vncviewer $BIN/xrealvncviewer
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/control
+++ vnc-3.3.7/debian/control
@@ -0,0 +1,97 @@
+Source: vnc
+Section: x11
+Priority: optional
+Maintainer: Ola Lundqvist <opal@debian.org>
+Standards-Version: 3.6.1
+Build-Depends: debhelper (>> 3.0.0), lynx, zlib1g-dev, xutils, libxaw7-dev (>> 4.1.0), perl-modules, xfonts-base
+
+Package: vnc-common
+Architecture: any
+Conflicts: vnc, vnc-doc, vncserver (<< 3.3.6-1)
+Pre-Depends: dpkg (>= 1.6.8)
+Depends: ${shlibs:Depends}, ${perl:Depends}
+Suggests: xvncviewer|vncviewer, vncserver
+Description: Virtual network computing server software
+ VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+ .
+ It is implemented in a client/server model. This package provides common
+ utilities for the server and client packages.
+
+Package: vncserver
+Architecture: any
+Provides: xserver, vnc-server
+Conflicts: vnc, vnc-doc
+Replaces: vnc, vnc-doc
+Pre-Depends: dpkg (>= 1.6.8)
+Depends: ${shlibs:Depends}, ${perl:Depends}, xbase-clients, xserver-common, vnc-common (>= 3.3.6-1)
+Recommends: xfonts-base
+Suggests: vnc-java
+Description: Virtual network computing server software
+ VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+ .
+ This package provides a server to which X clients can connect and the
+ server generates a display that can be viewed with a vncviewer.
+ .
+ Note: This server does not support or need a display. You need a vncviewer to
+ see something. However, this viewer may also be on a computer running other
+ operating systems in the local net.
+
+Package: xvncviewer
+Architecture: any
+Provides: vnc-viewer
+Conflicts: vnc, vnc-doc
+Replaces: vnc, vnc-doc
+Pre-Depends: dpkg (>= 1.6.8)
+Depends: ${shlibs:Depends}, vnc-common
+Recommends: xfonts-base
+Suggests: vncserver, ssh
+Description: Virtual network computing client software for X
+ VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+ .
+ It is implemented in a client/server model. This package provides a client
+ for X, with this you can connect to a vncserver somewhere in the network
+ and display its content in a window. There are vncserver available for X
+ and for Win95/NT.
+ .
+ This package is an enhanced version of VNC including the tunneling option from
+ TightVNC.
+
+Package: libvncauth0
+Architecture: any
+Section: libs
+Conflicts: vnc, vnc-doc
+Pre-Depends: dpkg (>= 1.6.8)
+Depends: ${shlibs:Depends} 
+Suggests: vncviewer
+Description: Virtual network computing authentication library
+ VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+ .
+ It is implemented in a client/server model. This package provides the library
+ to handle client authentication.
+
+Package: libvncauth-dev
+Architecture: any
+Section: devel
+Conflicts: vnc, vnc-doc
+Pre-Depends: dpkg (>= 1.6.8)
+Depends: libvncauth0 (= ${Source-Version})
+Description: Virtual network computing authentication headers and static lib
+ VNC stands for Virtual Network Computing. It is, in essence, a remote
+ display system which allows you to view a computing `desktop' environment
+ not only on the machine where it is running, but from anywhere on the
+ Internet and from a wide variety of machine architectures.
+ .
+ It is implemented in a client/server model. This package provides the headers
+ and static library to handle client authenticfication.
--- vnc-3.3.7.orig/debian/vnc-common.prerm
+++ vnc-3.3.7/debian/vnc-common.prerm
@@ -0,0 +1,11 @@
+#!/bin/sh -e
+
+if [ "$1" = "remove" ] ; then
+    BIN=/usr/bin
+    update-alternatives --remove \
+	vncserver $BIN/realvncpasswd
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/vncpasswd.wrapper
+++ vnc-3.3.7/debian/vncpasswd.wrapper
@@ -0,0 +1,166 @@
+#!/usr/bin/perl
+#
+#  Copyright (C) 1998 Marcus Brinkmann. This is derived from vncserver.
+#
+#  This is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This software is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this software; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+#  USA.
+#
+
+#
+# vncpasswd - wrapper script to start vncpasswd.real.
+#
+
+use File::Path;
+use File::Basename;
+
+#
+# Get the program name
+#
+
+$vncPasswdCmd = "/usr/bin/realvncpasswd.real";
+
+($prog) = ($0 =~ m|([^/]+)$|);
+
+if (!defined($ENV{HOME})) {
+    die "$prog: The HOME environment variable is not set.\n";
+}
+
+die "couldn't find executable $vncPasswdCmd" unless (-x "$vncPasswdCmd");
+
+# Source in configuration files, first the site wide one and then the
+# user specific one.
+
+$Config_file = "/etc/vnc.conf";
+&ReadConfigFile();
+$Config_file = "$ENV{HOME}/.vncrc";
+&ReadConfigFile();
+
+if (!$vncUserDir) {
+  $vncUserDir = "$ENV{HOME}/.vnc";
+}
+if (!$vncPasswdFile) {
+  $vncPasswdFile = $vncUserDir . "/passwd";
+}
+
+&ParseOptions("-help",0);
+
+&Usage() if ($opt{'-help'} || @ARGV > 1);
+
+if ($ARGV[0]) {
+    $vncPasswdFile = $ARGV[0];
+}
+
+$vncPasswdDir = dirname($vncPasswdFile);
+#I use this extra variable to keep vncUserDir pure.
+
+if (!(-d $vncPasswdDir)) {
+# Create the password file's parent directories if necessary.
+    if (-e $vncPasswdDir) {
+        die "$prog: Could not create $vncPasswdDir, file exists but is not a directory.\n";
+    }
+    if (!mkpath ($vncPasswdDir, 0, 0755)) {
+       die "$prog: Could not create $vncPasswdDir.\n";
+    }
+}
+
+system("$vncPasswdCmd $vncPasswdFile");
+if (($? >> 8) != 0) {
+    exit 1;
+}
+
+exit;
+
+#########################################################################
+#
+# code submitted from Manoj Srivastava. Thank you, Manoj!
+#
+# ReadConfigFile reads in a config file and sets variables according to it.
+#
+
+sub ReadConfigFile
+{
+  open(CONFIG, "$Config_file") || return;
+  my $lineno = 0;
+  while (<CONFIG>) {
+      chomp;
+      $lineno++;
+      s/\#.*//og;
+      next if /^\s*$/og;
+      $_ .= ";" unless /;\s*$/;
+      if (/^\s*([^=]+)\s*=\s*(\S.*)$/o) {
+          my $ret = eval "$1=$2";
+          if ($@) {
+              print STDERR "Error parsing config file $Config_file!\n";
+              print STDERR "$lineno:$_\n";
+          }
+      }
+  }
+}
+
+#
+# Usage
+#
+
+sub Usage
+{
+    die("usage: $prog [passwdFile]\n");
+}
+
+
+#
+# ParseOptions takes a list of possible options and a boolean indicating
+# whether the option has a value following, and sets up an associative array
+# %opt of the values of the options given on the command line. It removes all
+# the arguments it uses from @ARGV and returns them in @optArgs.
+#
+
+sub ParseOptions
+{
+    local (@optval) = @_;
+    local ($opt, @opts, %valFollows, @newargs);
+
+    while (@optval) {
+	$opt = shift(@optval);
+	push(@opts,$opt);
+	$valFollows{$opt} = shift(@optval);
+    }
+
+    @optArgs = ();
+    %opt = ();
+
+    arg: while ($arg = shift(@ARGV)) {
+	foreach $opt (@opts) {
+	    if ($arg eq $opt) {
+		push(@optArgs, $arg);
+		if ($valFollows{$opt}) {
+		    if (@ARGV == 0) {
+			&Usage();
+		    }
+		    $opt{$opt} = shift(@ARGV);
+		    push(@optArgs, $opt{$opt});
+		} else {
+		    $opt{$opt} = 1;
+		}
+		next arg;
+	    }
+	}
+	push(@newargs,$arg);
+    }
+
+    @ARGV = @newargs;
+}
+
+
+
--- vnc-3.3.7.orig/debian/vnc-common.postinst
+++ vnc-3.3.7/debian/vnc-common.postinst
@@ -0,0 +1,14 @@
+#!/bin/sh -e
+
+if [ "$1" = "configure" ]; then
+    MAN=/usr/share/man/man1
+    BIN=/usr/bin
+    update-alternatives --install \
+	$BIN/vncpasswd      vncpasswd            $BIN/realvncpasswd 70 \
+	--slave \
+	$MAN/vncpasswd.1.gz vncpasswd.1.gz       $MAN/realvncpasswd.1.gz
+fi
+
+#DEBHELPER#
+
+exit 0
--- vnc-3.3.7.orig/debian/vnc-common.links
+++ vnc-3.3.7/debian/vnc-common.links
@@ -0,0 +1 @@
+usr/share/man/man1/realvncpasswd.1.gz usr/share/man/man1/realvncpasswd.real.1.gz
--- vnc-3.3.7.orig/debian/vncserver.1x
+++ vnc-3.3.7/debian/vncserver.1x
@@ -0,0 +1,210 @@
+'\" t
+.\" ** The above line should force tbl to be a preprocessor **
+.\" Man page for Xvnc
+.\"
+.\" Copyright (C), 1998, Marcus.Brinkmann@ruhr-uni-bochum.de
+.\"                2000, opal@debian.org
+.\"
+.\" You may distribute under the terms of the GNU General Public
+.\" License as specified in the file COPYING that comes with the
+.\" Debian GNU/Linux distribution.
+.\"
+.TH vncserver 1x "March 16th, 1998" "3.3.1" "Virtual Network Computing X server"
+.SH NAME
+vncserver \- a X server for Virtual Network Computing
+.SH SYNOPSIS
+.\" The general command line
+.B vncserver 
+.RI [\| :display \|]
+.RI [\| \-name\ string \|]
+.RI [\| \-geometry\ WxH \|]
+.RI [\| \-depth\ int \|]
+.RI [\| \-httpport\ int \|]
+.RI [\| \-basehttpport\ int \|]
+.RI [\| \-alwaysshared \|]
+.RI [\| \-neversshared \|]
+.RI [\| \-pixelformat\ \| [\| bgrnnn | rgbnnn \|]]
+.RI [\| Xvnc\ options \|]
+.RI [\| \-help \|]
+
+.B vncserver
+.RI [\| \-clean \|] \-kill\ :display
+
+.SH DESCRIPTION
+.B vncserver
+is a wrapper script for
+.B Xvnc,
+the free X server for
+.B Virtual Network Computing
+(VNC). It provides all capabilities of a standard X server, but does not connect
+to a display for itself. You need a
+.B vncviewer
+to view and control the applications that run on the server.
+
+There are viewers for a variety of plattforms, e.g. X, svgalib and Windows.
+For Linux and Windows also a server exists. With the built-in Java classes,
+you can even use a Java capable Internet browser to connect to Xvnc.
+
+.SH EXAMPLES
+.TP \w'vncserver\ 'u
+.I vncserver
+Invokes Xvnc on the next available display and with suitable defaults.
+.TP
+.I vncserver :1
+Invokes Xvnc on desktop 1.
+.TP
+.I vncserver\ \-httpport\ 8080\ :1
+Invokes Xvnc on desktop 1 and listening on the http port 8080.
+This is only possible if the vnc-java package is installed.
+.TP
+.I vncserver\ \-basehttpport 8080 :1
+Invokes Xvnc on desktop 1 and listening on the http port 8080+displaynumber.
+This is only possible if the vnc-java package is installed.
+.TP
+.I vncserver\ \-geometry\ 640x480\ \-once\ \-httpd\ /usr/X11R6/lib/vncserver
+Invoke Xvnc for one session, with a framebuffer size of 640x480. Use the
+Java classes in /usr/X11R6/lib/vncserver (normaly they are in /usr/share/vnc-java
+if you have that package installed).
+.TP
+.I vncserver\ \-kill\ :1
+Shuts down server :1 at localhost.
+
+.SH OVERVIEW
+.B vncserver
+parses up to three configuration files and then invokes
+.B Xvnc
+with appropriate defaults. You can add further options to the
+command line, those will be added to the Xvnc command.
+
+Many options are available to 
+.B Xvnc
+in order to give as much flexibility as possible to the user.
+Most of the options are standard options for X server, and Xvnc provides a
+few additional options dsigned for its special purpose. Those options are
+not described here, but in tha man page for
+.BR Xvnc (1x).
+
+.B vncserver
+parses first the site wide configuratione file
+.I /etc/vnc.conf
+and then the user configuration file
+.I ~/.vncrc. This way a user can override or
+delete the values from the site wide
+.IR vnc.conf .
+A user can also trigger the default value when he sets the value to the empty string "".
+
+After that, vncserver will parse
+.I $XFConfigPath
+for "FontPath" and "RgbPath" values, if
+.I $XFConfigPath is specified
+.I $fontPath
+or
+.I $ColorPath
+are not. vncserver will also calculate other default values (for example geometry
+and color depth).
+
+If the specified or default password file does not exist, vncserver will
+invoke
+.BR vncpasswd (1x)
+to create on. A magic cookie will be created and added to the X authority
+file. After invoking Xvnc, a X session script will be started.
+
+.SH DEFAULTS
+.B vncserver
+has suitable defaults for all values, so you can try to run it without a
+configuration file and without command line options.
+
+If you want to know the default values for various options, please look them
+up in the man page of
+.BR vnc.conf .
+
+.SH OPTIONS
+You can add
+.BR Xvnc (1x)
+options at the command line. They will be added to the invocation of Xvnc
+without changes.
+
+.TP
+.I \-help
+Prints a short usage notice to stderr.
+.TP
+.I \-name\ string
+This specifies the name of the desktop.
+.TP
+.I \-geometry\ WxH
+Set framebuffer width & height.
+.TP
+.I \-depth\ num
+Set framebuffer depth. Must be a value between 8 and 32.
+.TP
+.I \-pixelformat\ format
+Set pixel format (BGRnnn or RGBnnn). The viewer can do the conversion to any
+other pixel format, but it is faster if the depth and pixelformat of the
+server is the same as the aequivalent values on the viewer display.
+.TP
+.I \-kill\ :display
+uses kill(1) to send the TERM signal to the
+.B VNC
+server with the specified
+display number and removes the lockfile. This option should be used to
+cleanly shut down a server started by vncserver.  Only works when the
+server was started with the 
+.I vncserver
+command.
+.TP
+.I \-clean
+This option can be used in conjunction with
+.I \-kill
+and will also remove the log file of the server process.
+.TP
+.I \-nevershared
+Never allow shared desktops.
+.TP
+.I \-alwaysshared
+Always allow shared desktops.
+.TP
+.I \-basehttpport int
+The base http port to use for the java client applet (you have to install
+the vnc-java package to make this work). The real port number will be
+port = base + display num.
+.TP
+.I \-httpport int
+The HTTP port to use for the Java client applet.  (You have to install
+the vnc-java package to make this work).
+.SH FILES
+.TP
+.I /etc/vnc.conf
+Site wide configuration file for vncserver. This is the first configuration
+file parsed for options to control Xvnc's behaviour.
+.TP
+.I ~/.vncrc
+Configuration file for one user. This will be parsed after the site wide
+configuration file, and values can be changed here on a per-user base.
+.TP
+.I /usr/bin/Xvnc
+The real server. Will be invoked by vncserver.
+.TP
+.I /usr/bin/vncpasswd
+Command to create and change password files to be used by the RFB protocol
+(can be specified with the
+.I \-rfbauth
+option).
+.TP
+.I /usr/X11R6/lib/vncserver/
+This directory contains the Java classes for incoming Http connections.
+.SH "SEE ALSO"
+.BR Xvnc (1x), 
+.BR vncpasswd (1x),
+.BR vnc.conf (5),
+.BR xvncviewer (1x),
+.BR svncviewer (1x).
+
+.SH AUTHOR
+VNC developed at Olivetti Research Labs, Cambridge (now AT&T
+Laboratories, Cambridge) by Tristan Richardson, Ken Wood,
+James Weatherall, Andy Harter, Charlie McLachlan, Paul Webster,
+Quentin Stafford-Fraser and others.
+.BR
+This manpage written by Marcus Brinkmann for the Debian GNU/Linux
+distribution.
+.BR
