Initialize Tizen 2.3 tizen_2.3 2.3a_release submit/tizen_2.3/20140531.115625 submit/tizen_2.3/20150202.070128 tizen_2.3_release
authorSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 04:21:36 +0000 (13:21 +0900)
committerSehong Na <sehong.na@samsung.com>
Sat, 31 May 2014 04:21:36 +0000 (13:21 +0900)
21 files changed:
AUTHORS [new file with mode: 0644]
COPYING [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
README [new file with mode: 0644]
Xtrans.c [new file with mode: 0644]
Xtrans.h [new file with mode: 0644]
Xtransint.h [new file with mode: 0644]
Xtranslcl.c [new file with mode: 0644]
Xtranssock.c [new file with mode: 0644]
Xtranstli.c [new file with mode: 0644]
Xtransutil.c [new file with mode: 0644]
configure.ac [new file with mode: 0644]
doc/Makefile.am [new file with mode: 0644]
doc/xtrans.xml [new file with mode: 0644]
docbook.am [new file with mode: 0644]
packaging/xorg-x11-xtrans-devel.spec [new file with mode: 0644]
transport.c [new file with mode: 0644]
xtrans.m4 [new file with mode: 0644]
xtrans.pc.in [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..87f4ec7
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,7 @@
+Contributors to this package include The Open Group (another words, the
+X Consortium), NCR Corporation, Sebastien Marineau and Holger Veit
+(OS/2 support), Sun Microsystems, David Dawes, Egbert Eich, Alan Coopersmith
+Marc La France, J. Kean Johnston, Frank Giessler, Jean-Claude Michot, and
+Matthieu Herrb.
+
+Our apologies if we missed anyone.
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..d2dbc2c
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,121 @@
+Copyright 1993, 1994, 1998, 2002  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+______________________________________________________________________________
+
+Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name NCR not be used in advertising
+or publicity pertaining to distribution of the software without specific,
+written prior permission.  NCR makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+
+NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+______________________________________________________________________________
+
+Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
+
+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 (including the next
+paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+
+______________________________________________________________________________
+
+(c) Copyright 1996 by Sebastien Marineau and Holger Veit
+                     <marineau@genie.uottawa.ca>
+                     <Holger.Veit@gmd.de>
+
+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
+HOLGER VEIT  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Except as contained in this notice, the name of Sebastien Marineau or
+Holger Veit shall not be used in advertising or otherwise to promote
+the sale, use or other dealings in this Software without prior written
+authorization from Holger Veit or Sebastien Marineau.
+
+______________________________________________________________________________
+
+Copyright © 2003 Keith Packard, Noah Levitt
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name of Keith Packard not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission.  Keith Packard makes no
+representations about the suitability of this software for any purpose.  It
+is provided "as is" without express or implied warranty.
+
+KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..66b30c2
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,1803 @@
+commit 8ce5ecd33b05becc054dbd07f87e385165b6c979
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Mar 22 20:04:07 2012 -0700
+
+    xtrans 1.2.7
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit f8eea0bf256de59602790b6a7c7877b31520440f
+Author: Matt Dew <marcoz@osource.org>
+Date:   Wed Jan 11 22:23:32 2012 -0700
+
+    informaltable cleanup
+
+    On certain tables, add top and bottom borders to table
+    header and a bottom border to the table. This matches
+    what those tables in the old pdfs looked like.
+
+    the <?dbfo keep-together='always'> prevents tables from
+    splitting across pages. Useful for tiny tables.
+
+    Converting the colwidth to a floating point,
+    IE, 1* -> 1.0* cleans up these build errors:
+    WARNING: table-layout="fixed" and column-width unspecified
+    => falling back to proportional-column-width(1)
+
+    Signed-off-by: Matt Dew <marcoz@osource.org>
+
+commit 6086f6c1d0e0a1c9e590879acb2319dea0eb6e96
+Author: Robert Bragg <robert@linux.intel.com>
+Date:   Mon Dec 12 00:30:43 2011 +0000
+
+    Xtranssock.c: avoid buffer overrun in SocketReopen
+
+    This function was constructing an address from a port string allocating
+    a buffer according to the size of the string but then later copying
+    the address according to sizeof(struct sockaddr).
+
+    This patch ensures that we allocate a struct sockaddr buffer with enough
+    space for the port string to be copied into sa_data[] and uses that
+    combined length to determine how much should be copied at the end of the
+    function.
+
+    This fixes a crash when using xwayland which uses ListenOnOpenFD() that
+    will call _XSERVTransReopenCOTSServer() with a short port string like
+    ":1".
+
+    Signed-off-by: Robert Bragg <robert@linux.intel.com>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit a04a45cb94f7f569e6dd77df93258fa167d0a4ea
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Nov 30 18:40:46 2011 -0800
+
+    Remove unnecessary casts on malloc, calloc & free calls
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
+
+commit a0bfb4fefd20b396e3d88eff0c60602fc436dad5
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Nov 30 18:11:15 2011 -0800
+
+    Replace malloc(strlen)+strcpy with strdup
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
+
+commit b89e1b45198c48996750b5da3d715c10f974243f
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Wed Nov 30 18:05:05 2011 -0800
+
+    Finish conversion to standard C allocation functions
+
+    Commit 4ac40cd5451 started this, by no longer special casing the
+    xserver to include it's former custom allocation functions, this
+    just takes the remaining #defines and pre-substitutes them into
+    the code.
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ff992be7b05483f9a0586a27ee0edb6d99580b84
+Author: Alan Hourihane <alanh@fairlite.co.uk>
+Date:   Thu Dec 1 12:04:22 2011 +0000
+
+    Fix some resource & memory leaks in libxtrans.
+
+    Signed-off-by: Alan Hourihane <alanh@vmware.com>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 29c9e101f7ad72556aa6b3dbc17d66a1ace9b2b1
+Author: Matt Dew <marcoz@osource.org>
+Date:   Tue Oct 4 21:59:50 2011 -0600
+
+    Cleanup IDs and links in doc
+
+    1 - fix the capitalization of the ID attributes to match either the
+         <title> or <funcdef> string it goes with.
+    2 - fix any <linkend>'s that were affected by 1.
+    3 - any <function> in the docs that has an actual funcdef,
+    will become an olink.
+
+    Signed-off-by: Matt Dew <marcoz@osource.org>
+
+commit 0f942e5f015cb3270e6f2e17c308bee894cb5fe3
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Sep 25 11:39:13 2011 -0700
+
+    Convert a bunch of sprintf calls to snprintf
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit eb9a8904fbef61a57ff01c90627ead57055ed62b
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Sep 25 11:18:26 2011 -0700
+
+    Add const attributes to fix gcc -Wwrite-strings warnings
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit 4e610d4bbcf29cca9dc5dbad29ca820996aaa8c7
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Sep 25 10:59:45 2011 -0700
+
+    Fix warning: unused variable 'tmpport' with various configurations
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit a74c5d915c3095059356f83d1b845192e5c472c2
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sun Sep 25 10:57:00 2011 -0700
+
+    Add _X_UNUSED attributes to silence unused parameter warnings
+
+    Not all the transport variants use all the arguments to every function,
+    but as long as one transport type needs it, they all get the args passed.
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit 64f765de138cb9b757df315469b3136d32222ea2
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Sep 24 00:04:40 2011 -0700
+
+    Mark __xtransname strings for debug messages as const char *
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit ea921932dae7049b231bead7f8f3f088d7beaf9e
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Sep 23 23:03:09 2011 -0700
+
+    Fix unused variable warnings
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit c1968d10f97d62ac05d698822c2688151f70a9eb
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Sep 23 22:59:11 2011 -0700
+
+    Fix warning: ISO C90 forbids mixed declarations and code
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit 225c45b3accab56fab361104a3d14b80f6cec954
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Sep 23 22:57:56 2011 -0700
+
+    Fix printf format string warnings
+
+    Now that prmsg lets arguments types actually be checked, fix
+    the warnings found.
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit b1b69ce8e8e4fe0f190c8bd85b537309e71055c8
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Sep 23 22:35:03 2011 -0700
+
+    Convert PRMSG macro to prmsg inline function
+
+    Allows using varargs to have the correct number of arguments passed to
+    get rid of the many gcc warnings about variable printf format strings,
+    and to reduce the duplication from having 5 implementations of the
+    PRMSG macro depending on the debug options defined & output method used.
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit cbdb434033da1725a69014cc6e4d89c691a6fd95
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Sep 24 07:43:07 2011 -0700
+
+    Fix warnings about static functions declared but never defined
+
+    Add #define XTRANS_TRANSPORT_C to transport.c and check for it
+    before making static function declarations and other bits needed
+    only when compiling the Xtrans code itself, not from other sources
+    that include the Xtransint.h header for the struct definitions.
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit cf39d738086b0a7c668fb3720d64de8d711a1a97
+Author: Arvind Umrao <arvind.umrao@oracle.com>
+Date:   Tue Sep 20 22:56:52 2011 +0530
+
+    Removing SUN specific code, let solaris create .X11-pipe with sticky bit on
+
+    Alan told me, named pipe support was added around Solaris 2.6 when that was a much better performing transport than Unix sockets on the Solaris kernels of the time. By Solaris 10, Unix sockets had been reimplemented in the kernel to be faster, so they became the default again. In Solaris 11, we don't even have named pipe support in the libxcb library that implements X client connection code now, so the named pipes would only be accessed by code with a different libX11 or a statically linked libX11 from Solaris 2.6-9
+
+    Signed-off-by: Arvind Umrao <arvind.umrao@oracle.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit a477713b89686480cf59a9c75c0aaeeba2386d0a
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Sep 20 18:56:47 2011 -0400
+
+    specs: regroup <author> <editor> <othercredit> under authorgroup
+
+    Some elements are not displayed when outside authorgroup
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 1ad48fb9bc18d0c7a8fbec1d2cd232877e945047
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Sep 20 15:47:09 2011 -0400
+
+    specs: refactor copyright legal text for multi licensing
+
+    we can use <copyright> markup for the first holder
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit bd93bf86fd914a9cc54e2bedec5b063e5a38b732
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Sep 19 10:58:40 2011 -0400
+
+    doc: support multi licensed copyright notice and license text
+
+    For documentation having multiple licenses, the copyright and legalnotice
+    elements sequence cannot instantiated multiple times.
+    The copyright notice and license text are therefore coded inside a
+    legalnotice element. The role attribute on the paragraph is used to allow
+    styling of the copyright notice text which should not be italicized.
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit eb9ec458b7fb5332f7ae7b8faf59443a9075ec60
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Sep 16 22:54:41 2011 -0700
+
+    Strip trailing whitespace
+
+    Performed with: find * -type f | xargs perl -i -p -e 's{[ \t]+$}{}'
+    git diff -w & git diff -b show no diffs from this change
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 36174eb06e805fa51c9c2e9e914fdfad4a99f50f
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Sep 14 15:29:19 2011 -0400
+
+    docs: fix authors affiliation
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 9b6c2473be2848ce0a4986ddaa59e5f5ef028bfc
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Sep 12 16:37:24 2011 -0400
+
+    docs: use the &fullrelvers; entity to set X11 release information
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit b5754cdf64f3396a5853413eda1943cf75ff3cbd
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Sep 11 19:49:54 2011 -0400
+
+    docs: remove <productnumber> which is not used by default
+
+    This element is not rendered by default on the title. A template
+    customization is required to display it.
+    X Window System does not have a product number.
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 20f338c548e5fcb16650a4e2c25c2008c1fdac36
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Thu Sep 8 20:00:00 2011 -0400
+
+    docbook.am: embed css styles inside the HTML HEAD element
+
+    Rather than referring to the external xorg.css stylesheet, embed the content
+    of the file in the html output produced. This is accomplished by using
+    version 1.10 of xorg-xhtml.xsl.
+
+    This makes the whole html docs tree much more relocatable.
+    In addition, it eliminates xorg.css as a runtime file which makes
+    xorg-sgml-doctools a build time only package.
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 8eb827af1b57ec52be183cddaf32257968c02878
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Sep 7 10:31:04 2011 -0400
+
+    docbook.am: global maintenance update - entities, images and olinking
+
+    Adding support in libX11 for html chunking caused a reorg of docbook.am
+    as well as the xorg-sgml-doctools masterdb for olinking.
+    The parameter img.src.path is added for pdf images.
+    A searchpath to the root builddir is added for local entities, if present.
+
+    The docbook.am makefile hides all the details and is identical for
+    all 22 modules having DocBook documentation. It is included by a thin
+    Makefile.am which requires no docbook knowledge.
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit b710cdadc92fc212af361bee48f5af6333ec3e6d
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Jun 12 18:39:46 2011 -0400
+
+    Install xml versions of specs even if HAVE_XMLTO is false
+
+    DocBook/XML input source is also a usefull output format that can be viewed
+    with an XML viewer or editor and by some O/S help system.
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 78d1f7d29145567e11b985042e917a435bef95f9
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Jun 5 16:27:37 2011 -0400
+
+    Install target dbs alongside generated documents
+
+    This matches a change in xorg-sgml-docs whereby the masterdb will look for
+    the target dbs into the same location as the generated documents.
+
+    The target dbs are now installed alongside the generated documents.
+    Previously they are installed in $prefix/sgml/X11/dbs alongside masterdb which
+    has the potential of installing outside the package prefix and cause
+    distcheck to fail when user does not have write permission in this package.
+
+    Requires XORG_CHECK_SGML_DOCTOOLS(1.8) which was released 2011-06-11
+
+commit e05d7abbcf880099058b699ac52f65edcac95582
+Author: Jeremy Huddleston <jeremyhu@apple.com>
+Date:   Sun Apr 24 19:39:26 2011 -0700
+
+    Silence warnings when building with clang
+
+    /usr/X11/include/X11/Xtrans/Xtransint.h:349:12: error: unused function 'is_numeric' [-Werror,-Wunused-function]
+    static int is_numeric (
+              ^
+    /usr/X11/include/X11/Xtrans/Xtransint.h:354:12: error: unused function 'trans_mkdir' [-Werror,-Wunused-function]
+    static int trans_mkdir (
+              ^
+
+    In file included from /usr/X11/include/X11/Xtrans/transport.c:67:
+    ...
+    fatal error: too many errors emitted, stopping now [-ferror-limit=]
+
+    Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
+
+commit 27ae0ad1406a33919ea9f76034495bca7cccf051
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Feb 27 15:06:18 2011 -0500
+
+    Documentation: add Docbook external references support
+
+    When writing technical documentation, it is often necessary to cross
+    reference to other information. When that other information is not in the
+    current document, additional support is needed, namely <olink>.
+
+    A new feature with version 1.7 of xorg-sgml-doctools adds references to
+    other documents within or outside this package.
+
+    This patch adds technical support for this feature but does not change
+    the content of the documentation as seen by the end user.
+
+    Each book or article must generate a database containing the href
+    of sections that can be referred to from another document. This database
+    is installed in DATAROOTDIR/sgml/X11/dbs. There is a requirement that
+    the value of DATAROOTDIR for xorg-sgml-doctools and for the package
+    documentation is the same. This forms a virtual document tree.
+
+    This database is consulted by other documents while they are being generated
+    in order to fulfill the missing information for linking.
+    Refer to the xorg-sgml-doctools for further technical information.
+
+    Co-authored-by: Matt Dew <marcoz@osource.org>
+
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit cc199c31465b258032bdb9083879699202db7ee9
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Mon Feb 21 12:44:06 2011 -0500
+
+    Remove a decnet leftover
+
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Reviewed-by: Daniel Stone <daniel@fooishbar.org>
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 91620213d2bd75fe322df06c5b6f55b85a10e55a
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Mar 15 15:47:08 2011 -0400
+
+    Remove K&R token pasting macros
+
+    Reviewed-by: Julien Cristau <jcristau@debian.org>
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 4ac40cd5451983e6f62527700cdf9e2f8a29c013
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Mar 15 15:45:56 2011 -0400
+
+    Don't special-case allocation for the X server
+
+    xserver uses malloc/free directly now, don't route through the Xalloc
+    wrappers.
+
+    Reviewed-by: Julien Cristau <jcristau@debian.org>
+    Signed-off-by: Adam Jackson <ajax@redhat.com>
+
+commit 638caa2053330038c5ba5a5682ff02be6aa0faa6
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Feb 2 11:43:46 2011 -0500
+
+    config: comment, minor upgrade, quote and layout configure.ac
+
+    Group statements per section as per Autoconf standard layout
+    Quote statements where appropriate.
+    Autoconf recommends not using dnl instead of # for comments
+
+    Use AC_CONFIG_FILES to replace the deprecated AC_OUTPUT with parameters.
+    Add AC_CONFIG_SRCDIR([Makefile.am])
+
+    This helps automated maintenance and release activities.
+    Details can be found in http://wiki.x.org/wiki/NewModuleGuidelines
+
+commit a26753b7b20cd5cadc1e7fa007cec063f39a49e8
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Thu Dec 16 23:59:20 2010 -0800
+
+    doc: Correct column count in transport configuration table
+
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 59f57d1a19d4091fef115b9eafa139bf620332cb
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Mon Nov 8 16:33:45 2010 -0800
+
+    xtrans 1.2.6
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 05cd71c899e83022147f27085ee652d26f5462cb
+Author: Jesse Adkins <jesserayadkins@gmail.com>
+Date:   Sat Nov 6 12:53:24 2010 -0700
+
+    Remove ISCFuncs, fix SCOFuncs inclusion (bug 23324)
+    
+    ISCFuncs was removed by commit 339ddc413559d4cb117a72f87b2a70dae6911c32.
+    SCOFuncs should be for SCO only, instead of !sun.
+    
+    Also, remove comments that suggest ISC support.
+    
+    Signed-off-by: Jesse Adkins <jesserayadkins@gmail.com>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 0e5a66c82535dd8e9beee9fc4c42c52f90d05f50
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Nov 6 13:22:59 2010 -0700
+
+    doc: Update for X11R7/modularization
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 1858516e9f0f3e65cc3d1f6cedfe8bfa614c8082
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Nov 6 11:22:15 2010 -0700
+
+    doc: Markup & typo cleanups
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 16bdc50ca85bbae065a32647e2410a5ca47b4924
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Nov 6 09:53:08 2010 -0700
+
+    doc: Correct legal notices
+    
+    Restore both copyright/license notices from troff version
+    Move implementation note out of legalnotice section
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit d01d081538d04ac60b9e14f6e2faa60fe6bed5ff
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Nov 6 09:23:26 2010 -0700
+
+    doc: Use installed css stylesheet instead of making another copy
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit ea6977f4a51612172ba51c3bd35aa150ad9ff158
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Sat Nov 6 12:41:48 2010 -0700
+
+    Xtransint.h: Add missing ' in comment
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit 862d2de24950d2658158ebc4cf8307e73f80bc8d
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri Oct 29 18:22:33 2010 -0700
+
+    Sun's copyrights now belong to Oracle
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit cbb59ebc916d0be18c322eec782b694f4dc2e685
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Jun 27 20:27:39 2010 -0400
+
+    Update README to reflect docs converted from nroff to DocBook XML
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 3441142714b2640d1e143fcb5d089a2a42bd5321
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sun Jun 27 20:21:20 2010 -0400
+
+    doc: remove trailing spaces in xtrans.xml
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 7761846c7fd97f15d7207e1b9fd9d42c9e58a0c4
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Sat Jun 26 13:06:22 2010 -0400
+
+    doc: replace groff input format with docbook xml format
+    
+    Initial version of xtrans docbook xml.
+    Requires util-macros 1.10
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 4f557036253ac5750576c88e5b9a86759a49d247
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Fri Jun 18 21:47:52 2010 -0400
+
+    config: XORG_WITH_GROFF: use HAVE_GROFF_HTML conditional
+    
+    Groff uses grohtml to generate html output format. This program, in turn,
+    uses a number of pnm* commands from the netpbm package, psselect
+    from the psutils package and the ghostscript package.
+    
+    These are independently installed, so they could be missing.
+    Skip the HTML output format if one of the dependencies is missing.
+    The version 1.9 of the util-macros package is required.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 1e9b958a096682b1ec111d400bd25048e3f95ed4
+Author: Alan Coopersmith <alan.coopersmith@oracle.com>
+Date:   Fri May 21 18:54:20 2010 -0700
+
+    Update README to reflect docs moved here from xorg-docs module
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
+
+commit d400e69526c1c331e8e23893e2ba8658979376e8
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Mar 29 14:53:49 2010 -0400
+
+    config: remove the pkgconfig pc.in file from EXTRA_DIST
+    
+    Automake always includes it in the tarball.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 373922e1529b3d55513fbc0ec24527600f7b529c
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Tue Feb 16 18:18:06 2010 -0500
+
+    doc: use HAVE_GROFF_MM to skip doc when 'm.tmac' macros missing
+    
+    This conditional is defined in XORG_WITH_GROFF macro.
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit b531ff3ed2ad841b716ba370fd43bbe8f06f1185
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Fri Jan 29 15:05:37 2010 -0500
+
+    doc: use new macros XORG_WITH_GROFF and PS2PDF
+    
+    These control the usage of doc tools
+    Also use XORG_ENABLE_DOCS to control generation of docs
+    
+    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+
+commit 5922556f408fbcd14e7ad23bbe46db2ae8dcdee6
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Jan 14 21:11:43 2010 -0800
+
+    Update Sun license notices to current X.Org standard form
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit dab2bcdaf60977643ec55d71a81e67c1e3a162a9
+Author: Rémi Cardona <remi@gentoo.org>
+Date:   Thu Dec 17 08:31:20 2009 +0100
+
+    require autoconf 2.60 because of $(docdir) use
+    
+    Signed-off-by: Rémi Cardona <remi@gentoo.org>
+    Reviewed-by: Gaetan Nadon <memsize@videotron.ca>
+    Reviewed-by: Alan Coopersmith <alan.coopersmith@sun.com>
+    Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
+
+commit 197ec0dc83e775e42fce4966142ae3a641f2db69
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Fri Nov 27 20:56:05 2009 -0500
+
+    Makefile.am: add ChangeLog and INSTALL on MAINTAINERCLEANFILES
+    
+    Now that the INSTALL file is generated.
+    Allows running make maintainer-clean.
+
+commit 27a18fb2c9356cc44bdd892f87200c3ea230109b
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Wed Oct 28 14:09:11 2009 -0400
+
+    INSTALL, NEWS, README or AUTHORS files are missing/incorrect #24206
+    
+    Add missing INSTALL file. Use standard GNU file on building tarball
+    README may have been updated
+    Remove AUTHORS file as it is empty and no content available yet.
+    Remove NEWS file as it is empty and no content available yet.
+
+commit 92da89326d26e0924d4c6efe2ebd26ceb527f4f7
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Mon Oct 26 22:08:43 2009 -0400
+
+    Makefile.am: ChangeLog not required: EXTRA_DIST or *CLEANFILES #24432
+    
+    ChangeLog filename is known to Automake and requires no further
+    coding in the makefile.
+
+commit 9aeff40d0722b4fedc4ab9ccc1aaff75368020fe
+Author: Gaetan Nadon <memsize@videotron.ca>
+Date:   Thu Oct 22 12:34:20 2009 -0400
+
+    .gitignore: use common defaults with custom section # 24239
+    
+    Using common defaults will reduce errors and maintenance.
+    Only the very small or inexistent custom section need periodic maintenance
+    when the structure of the component changes. Do not edit defaults.
+
+commit f0f7c47055eecac35786ec616c7632604da204b5
+Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
+Date:   Wed Oct 21 12:47:27 2009 -0700
+
+    This is not a GNU project, so declare it foreign.
+    
+    On Wed, 2009-10-21 at 13:36 +1000, Peter Hutterer wrote:
+    > On Tue, Oct 20, 2009 at 08:23:55PM -0700, Jeremy Huddleston wrote:
+    > > I noticed an INSTALL file in xlsclients and libXvMC today, and it
+    > > was quite annoying to work around since 'autoreconf -fvi' replaces
+    > > it and git wants to commit it.  Should these files even be in git?
+    > > Can I nuke them for the betterment of humanity and since they get
+    > > created by autoreconf anyways?
+    >
+    > See https://bugs.freedesktop.org/show_bug.cgi?id=24206
+    
+    As an interim measure, replace AM_INIT_AUTOMAKE([dist-bzip2]) with
+    AM_INIT_AUTOMAKE([foreign dist-bzip2]). This will prevent the generation
+    of the INSTALL file. It is also part of the 24206 solution.
+    
+    Signed-off-by: Jeremy Huddleston <jeremyhu@freedesktop.org>
+
+commit 7d98b9b03c5fd5a82f9f4d215b10c0926edeab00
+Author: Eric Sesterhenn <eric.sesterhenn@lsexperts.de>
+Date:   Mon Oct 19 09:53:18 2009 -0700
+
+    Bug 24612: Memory & fd leaks in local transports
+    
+    X.Org bug #24612 <http://bugs.freedesktop.org/show_bug.cgi?id=24612>
+    Patch #30548 <http://bugs.freedesktop.org/attachment.cgi?id=30548>
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 1127b8ec766ed8c48cc49b0779647fb697a07ebd
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sat Oct 17 13:14:03 2009 -0700
+
+    xtrans 1.2.5
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 628b125ff9c72ec93090005b06228690f0dd6004
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sat Oct 17 13:06:26 2009 -0700
+
+    Move Xtrans interface docs from xorg-docs module
+    
+    Only built/installed if --enable-docs is requested, since few people should
+    be writing code using xtrans interfaces directly.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 3b0fc7a5a6d4b4b6903a9ad6685e2441f9fe83a7
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Oct 15 17:07:10 2009 -0700
+
+    Migrate to xorg macros 1.3 & XORG_DEFAULT_OPTIONS
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 69334376346a96beb3df120a3eeeb7935923c388
+Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+Date:   Thu Oct 15 15:25:58 2009 -0500
+
+    Silence root ownership warnings on Cygwin
+    
+    XWin need not be run as root, nor do Administrators have uid of 0.
+    
+    Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+
+commit d009d995d85dc499dc3f1add34da551fdf703b60
+Author: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+Date:   Thu Oct 15 15:25:57 2009 -0500
+
+    Don't use -lws2_32 on Cygwin
+    
+    On Cygwin, both the (builtin) *NIX socket API and WinSock (via w32api) are
+    available, but they cannot be mixed.  We use *NIX APIs for everything else,
+    so we do not want to mix in WinSock here.
+    
+    Signed-off-by: Yaakov Selkowitz <yselkowitz@users.sourceforge.net>
+
+commit 773478581913bafa5e98a7bff3260efb0c4f2ab6
+Author: Mikhail Gusarov <dottedmag@dottedmag.net>
+Date:   Sat Sep 26 04:39:20 2009 +0700
+
+    Move xtrans.pc to /usr/share/pkg-config
+    
+    This fixes configuration in cross-compilation mode:
+    pkg-config does not look for .pc in /usr/lib/pkg-config during
+    cross-compilation to avoid picking up wrong libraries.
+    
+    Signed-off-by: Mikhail Gusarov <dottedmag@dottedmag.net>
+    Acked-by: Julien Cristau <jcristau@debian.org>
+
+commit 336d4cfb58c784a81beca74fe03a0af0abb224ba
+Author: Julien Cristau <jcristau@debian.org>
+Date:   Fri Aug 7 16:58:58 2009 +0200
+
+    Xtranssock: assume that we have getaddrinfo if ipv6 is enabled
+    
+    If IPv6 is enabled at build time, assume that the C library will have
+    getaddrinfo at runtime.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 4f82ca502d8ec33b0038700675d54539d85d723c
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Jul 31 17:24:25 2009 -0700
+
+    Version 1.2.4
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit e5f52f206916b7c5264b9371f9bd0113632a4a16
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Jul 30 16:07:39 2009 -0700
+
+    Fix ifdef checks for SVR4 to do the right thing on Solaris
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 6d1ad967b894a37f423fd52247df5fcc3bfab1a8
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon May 18 18:26:36 2009 -0700
+
+    xfs segfaults in _FontTransSocketReopen when cloning itself
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 1e32f79670a6dc0baae2c2622d2b562f41266ea5
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Apr 24 02:10:53 2009 -0700
+
+    Constify path argument to trans_mkdir()
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 732f3366c40c4bea258b11b96c4763f5948a4844
+Author: Benjamin Close <Benjamin.Close@clearchain.com>
+Date:   Mon Feb 9 16:34:00 2009 +1030
+
+    Update is_numeric base on the declaration change in 389e01fb51ba2d708015e27d8fc17c88a0e55802
+    
+    Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com>
+
+commit 300893171ca7ad684472e5961a7b2ba0eb291f6b
+Author: Benjamin Close <Benjamin.Close@clearchain.com>
+Date:   Mon Feb 9 16:33:59 2009 +1030
+
+    Revert "Fix "XXX declared 'static' but not defined""
+    
+    This reverts commit d192bac409fe5ef99fa9fb9b5a0d5f656f0f1412.
+    
+    When transport.c is directly include (as in the case of libICE:icetrans.c:32)
+    Xtranssock.c must be included before Xtransutil.c in order for the socket
+    structures to be included. Including Xtransutil.c after Xtranssock.c requires
+    is_number and trans_mkdir to be defined.
+    
+    This reintroduces the warning until a cleaner solution can be found
+    but fixes the build.
+    
+    Found by: Tinderbox
+    
+    Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com>
+
+commit 389e01fb51ba2d708015e27d8fc17c88a0e55802
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Feb 6 11:31:06 2009 -0800
+
+    Constify string argument to is_numeric
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit cca91ddaae2121f42b2d5c08867bb93df8f9de13
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Feb 6 11:27:02 2009 -0800
+
+    Fix libICE build after code motion in d192bac409...
+    
+    The #ifdef ICE_t case in Xtransutil.c depended on some #includes that
+    are done in files that transport.c previously included before Xtransutil.c
+    but are now after Xtransutil.c is included.
+    
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit d192bac409fe5ef99fa9fb9b5a0d5f656f0f1412
+Author: Tomas Carnecky <tom@dbservice.com>
+Date:   Wed Feb 4 15:26:18 2009 +0100
+
+    Fix "XXX declared 'static' but not defined"
+    
+    The functions are declared static in Xtransint.h but are defined
+    in Xtransutil.c. So when someone (xserver/os/connection.c)
+    incuded Xtransint.h, gcc would throw the warning.
+    I removed the declarations from the header and rearranged includes
+    in transport.c so that Xtransutil.c is included just after
+    Xtransint.h. This way the functions are still defined for the
+    files that need them (Xtranssock.c, Xtranstli.c).
+    
+    Signed-off-by: Tomas Carnecky <tom@dbservice.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit 77784ae71b6af1ec270198cfdd5f2eab1fe4a0c0
+Author: Tomas Carnecky <tom@dbservice.com>
+Date:   Wed Feb 4 15:22:28 2009 +0100
+
+    Fix "warning: format not a string literal and no format arguments"
+    
+    Signed-off-by: Tomas Carnecky <tom@dbservice.com>
+    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
+
+commit c893bc4aa7a674c6888aacc8249b3c4a8f6bf12a
+Author: Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>
+Date:   Fri Jan 30 18:47:32 2009 -0200
+
+    Janitor: Correct make distcheck and compiler warnings.
+    
+      Compiler warnings are spread on other packages, with a
+    warning in the format:
+    /usr/include/X11/Xtrans/Xtranssock.c:548: warning: 'ciptr' may be used uninitialized in this function
+    so the code was slightly changed so that the compiler
+    would not "think" it could be used without initialization.
+
+commit 1cf4a1a6716f2c0adf5ee4d0a194a1013be53105
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sun Jan 11 10:54:52 2009 -0800
+
+    Version 1.2.3
+
+commit d0c5592142369afa93dcd58ca6f390dbd127a28a
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Sun Jan 11 10:51:49 2009 -0800
+
+    Add bugzilla, mailing list & git repo pointers to README
+
+commit 9f12a154437554938a4fa18b7d3948c7dff8d631
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Dec 1 13:58:31 2008 -0800
+
+    Switch ChangeLog generation to use XORG_CHANGELOG from xorg-macros 1.2
+
+commit 8c313881a0c586179c09922a7e00a1f8d669a68a
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Dec 1 08:37:42 2008 -0800
+
+    18748: xtrans.m4 causes configure --help to list --enable-ipv6 in wrong case.
+    
+    X.Org Bug #18748 <http://bugs.freedesktop.org/show_bug.cgi?id=18748>
+
+commit c626a4298e98f4988701dd587bc8355c62542ec4
+Author: Alan Hourihane <alanh@tungstengraphics.com>
+Date:   Wed Oct 15 11:19:41 2008 +0100
+
+    add winsock check for windows builds
+
+commit 005bd80a9eab736aea737869b8a1079c565e1cd6
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Oct 7 09:56:49 2008 -0400
+
+    xtrans 1.2.2
+
+commit 1185dd2966521e1a19474dfd4206306cb383fc89
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Oct 7 09:55:22 2008 -0400
+
+    Finish removing OS/2 support
+
+commit 51b2e85aeb172f4a058d8ceceec91021ffd0b2a5
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Tue Oct 7 09:51:27 2008 -0400
+
+    Remove DECNET support.
+    
+    This hasn't been consumed in the server or libs since 7.0.
+
+commit 892ec928da3a0653ae54c321e4c3b1aa06c4e678
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Thu Aug 7 10:32:11 2008 -0400
+
+    Drastically simplify TRANS_OPEN_MAX.
+    
+    If your OS doesn't have sysconf(3), then life is already hard for you.
+
+commit 339ddc413559d4cb117a72f87b2a70dae6911c32
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Thu Aug 7 10:23:19 2008 -0400
+
+    Massive ifdef cleanup, dropping a ton of unsupported platform code.
+
+commit a78b9819cbbbddccb4a6bf364b88ec4f27d25c1f
+Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
+Date:   Tue Aug 5 17:46:37 2008 -0700
+
+    Added a flag to enable "The OS already took care of securing this, please skip checking xauth" for use with Apple launchd sockets.
+
+commit 3db805979b476d233baa881e83950ef1d2731841
+Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
+Date:   Tue Jul 15 16:56:12 2008 -0700
+
+    Apple: Allow Xquartz to provide an additional fd to xtrans since the dynamic addition code in the server isn't bulletproof yet.
+
+commit 81d8bdced6b45ab2ab3d3a0bc164ddbf1659fea1
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Jul 2 15:24:20 2008 -0400
+
+    xtrans 1.2.1
+
+commit 302af17c4d5f0293a9af4d6c1097ab57a57d3f0f
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Tue Jun 24 15:45:38 2008 -0700
+
+    Clear some pointer type mismatch warnings
+
+commit 4d184e41d30a8fe27380e04beb24f775d4a40782
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Tue Jun 24 15:45:18 2008 -0700
+
+    LocalClose() takes a ConnInfoPtr, not an fd
+
+commit 177c2fd41727bd0110b493933dcbdbf21878fe09
+Author: Jeremy Huddleston <jeremyhu@freedesktop.org>
+Date:   Fri May 23 09:48:59 2008 -0700
+
+    Launchd: This functionality has been moved into xorg-server
+
+commit 02fcb08803dca5bb2df4f8be490a845659bd7ed3
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Mon May 12 17:49:41 2008 -0400
+
+    Connection failure for abstract socket is ECONNREFUSED, not ENOENT.
+    
+    Apropos of bug #15884.
+
+commit 906294025573d07c739894fa3b2eedc82813a379
+Author: Bill Nottingham <notting@redhat.com>
+Date:   Mon May 12 17:43:36 2008 -0400
+
+    Ignore mkdir() errors when creating the abstract socket.
+    
+    Red Hat bug #445303.
+
+commit 08134c2ce72bc43c172b6ae134d8a94a40b45c9b
+Author: James Cloos <cloos@jhcloos.com>
+Date:   Sat May 10 07:02:09 2008 -0400
+
+    Remove extraneous execute bit from .c file
+
+commit e75b9dad0ae4bc0869af81652d8259675a3c5cac
+Author: Julien Cristau <jcristau@debian.org>
+Date:   Thu May 8 16:27:29 2008 +0200
+
+    Bump to 1.2
+
+commit 962ad4d3f8096f5ffa14b32b3ee094f250790c77
+Author: Alan Hourihane <alanh@tungstengraphics.com>
+Date:   Mon Apr 28 23:46:05 2008 +0100
+
+    disable UNIXCONN on MINGW
+
+commit 9e8c0e3356bc6359368b7655d3a717d6c000387e
+Author: Alan Hourihane <alanh@tungstengraphics.com>
+Date:   Sat Apr 26 16:23:19 2008 +0100
+
+    fix build for MAKEWORD
+
+commit 568c5ea02ee1de437833ee0b53a7b3fd7ece084f
+Author: Colin Harrison <colin.harrison-at-virgin.net>
+Date:   Sat Apr 26 08:53:13 2008 +0100
+
+    Update to winsock2
+
+commit 960902584a3ef125946beb5ebe331b54d697e9d9
+Author: James Cloos <cloos@jhcloos.com>
+Date:   Fri Apr 25 15:53:20 2008 -0400
+
+    Fix length calculation for the path for abstract unix domain sockets
+    
+    Since the struct has a fixed-lenght char[] its sizeof() contains
+    trailing NUL octets which results in corrupt abstract sockets.
+    
+    Instead, take the strlen(3) of the path, plus the single NUL octet
+    (which identifies the path as an abstract path rather than a file-
+    system path) plus the offset from the start of the struct to the
+    start of the char array.
+    
+    This fixes:
+    
+    https://bugs.freedesktop.org/show_bug.cgi?id=15677
+
+commit 3a2a5375b8aab85697b4f2644ab99c3ccf79e658
+Author: Colin Harrison <colin.harrison-at-virgin.net>
+Date:   Wed Apr 23 10:39:30 2008 +0100
+
+    Only call WSAGetLastError() if there has been an
+    error condition.
+
+commit ac13a1a34b61247a21da130f0ba9922f35d3dc3b
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Tue Apr 15 12:32:35 2008 -0700
+
+    Sun bug #6688467: _X11TransConvertAddress: Unknown family type on 64-bit SPARC
+    
+    Check for socklen_t definition and if found use it instead of size_t or
+    int for the length argument to getpeername/getsockname/etc.
+    
+    <http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6688467>
+
+commit 556a351de83fc6f401b02213dae95731553c216d
+Author: Loïc Minier <lool@dooz.org>
+Date:   Mon Mar 24 15:38:27 2008 -0400
+
+    Bug #10489: Don't retry unix socket connect()s on ENOENT.
+    
+    If the socket isn't there, it's not gonna magically appear.  Either it's
+    a server socket and you should have just waited for the SIGUSR1 from the
+    server, or it's a stale reference to an ICE socket.
+    
+    However, do retry once, so fallback from abstract to filesystem namespace
+    works.
+    
+    Originally Debian bug #385976.
+
+commit 3de3e666e0653d4e8ae23fc3e6e31864ddad4059
+Author: Julien Cristau <jcristau@debian.org>
+Date:   Sun Mar 23 19:43:32 2008 +0100
+
+    BSD44SOCKETS is the wrong check for SOCK_MAXADDRLEN
+    
+    GNU/kFreeBSD defines BSD44SOCKETS, but doesn't have SOCK_MAXADDRLEN.
+    Check for the latter directly.
+
+commit 662994b9096181117cec4cae88f24bf6da806159
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Mar 5 21:02:28 2008 -0500
+
+    xtrans 1.1
+
+commit 2afe206ec9569e0d62caa6d91c3fb057b0efa23d
+Author: Adam Jackson <ajax@redhat.com>
+Date:   Wed Mar 5 20:48:59 2008 -0500
+
+    Add support for the abstract socket namespace under Linux.
+    
+    Unlike normal unix sockets, the abstract namespace is not bound to the
+    filesystem.  This has some notable advantages; /tmp need not exist, the
+    socket directory need not have magic permissions, etc.  xtrans servers
+    will listen on both the normal and abstract socket endpoints; clients
+    will attempt to connect to the abstract socket before connecting to the
+    corresponding filesystem socket.
+    
+    Based on a patch by Bill Crawford.
+
+commit c8ed67f16f71042ef134a4d2189c20dd200a0648
+Author: Jeremy Huddleston <jeremy@tifa.local>
+Date:   Sun Feb 10 19:04:40 2008 -0800
+
+    Fixed #ifdef checks that were using i386 to use __i386__
+    
+    """
+    
+    It's simply obsolete, sloppy, compiler namespace pollution.  The
+    compiler is not allowed to predefine symbols that might conflict with
+    ordinary identifiers.  For backwards compatibility gcc currently
+    predefines i386 when compiling for x86 32-bit (but not 64-bit), but that
+    will go away.  It is also not defined if you specify -ansi when invoking
+    the compiler, because then it is seriously standards compliant.  Other
+    compilers shouldn't define it either.  Correct code shouldn't rely on it
+    being defined.  However __i386__ is safe and proper.
+    
+    """
+
+commit 9970b5b6f8237685267b7972282319cf266661ea
+Author: Ben Byer <bbyer@bbyer.local>
+Date:   Sun Dec 2 07:36:51 2007 -0800
+
+    make launchd error messages less scary
+
+commit cd1da5cec49fb7fe6238a00d9ba550b3ed78fa08
+Author: Ben Byer <bbyer@bbyer.local>
+Date:   Wed Nov 14 03:57:57 2007 -0800
+
+    Fix for incorrect processing of recycled launchd socket on OS X
+
+commit 3da4d6c1dc05f9e1291b023a97535eb67f0830e2
+Author: Ben Byer <bbyer@bbyer.local>
+Date:   Wed Nov 14 03:55:42 2007 -0800
+
+    removed cvs tags
+
+commit 496cf2c46d2123c3bed3e6878f8f9a62e87ce559
+Author: Dodji Seketeli <dodji@seketeli.org>
+Date:   Tue Sep 11 12:52:44 2007 +0200
+
+    libxtrans: fixed a typo in my last commit
+    
+            * Xtranssock.c: (SocketReopen): oops fix a typo in my last commit.
+
+commit 88e141225113fcc4ebe5e8fe361e75673cdbf9ff
+Author: Dodji Seketeli <dodji@seketeli.org>
+Date:   Tue Sep 11 08:48:03 2007 +0200
+
+    libxtrans: fix linux compilation breakage
+    
+            * Xtranssock.c:
+              (SocketReopen): protect use of BSD4.4 socket with BSD44SOCKETS macro.
+              protect use of strlcnpy with HAVE_STRLCPY macro.
+              That one is defined (or not) by the xserver configure.
+
+commit 6217f34977bfa17b66b89df5d45420774abedcb3
+Author: Ben Byer <bbyer@bbyer.apple.com>
+Date:   Wed Sep 5 18:29:44 2007 -0700
+
+    changes to support launchd on OS X
+
+commit 4d0cfe491046df26027db291530b247b7f24df5b
+Author: Ben Byer <bbyer@bbyer.apple.com>
+Date:   Wed Sep 5 18:04:01 2007 -0700
+
+    suppress warning about socket directory ownership on OS X
+    
+    We don't need to warn the user about the fact that the socket
+    directory is not owned by root under OS X; on that platform,
+    it's never owned by root, as the X server runs as the normal user.
+
+commit de93d67f6d48c7c08f2554cb85515bcf7dfbffb2
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Tue Aug 21 17:54:23 2007 -0700
+
+    Version bump: 1.0.4
+
+commit 5e16b0ebccb233f7aeaf3928a853ee966b7cbb39
+Author: Kean Johnston <kean@armory.com>
+Date:   Wed Jul 18 09:27:06 2007 -0700
+
+    Fix typo in Xtranslcl.c (sprintf with size argument should be snprintf)
+
+commit 1abc981349140260d6fb643d29cf2b851fc06ac9
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Sat Dec 16 01:15:21 2006 +0200
+
+    bump to 1.0.3
+
+commit 8172528bb894856aa5b133f61444294dc5a347e6
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Wed Dec 6 18:51:59 2006 +0200
+
+    Makefile.am: make ChangeLog hook safer
+    Make ChangeLog hook as safe as possible.
+
+commit 5ffb704b1df9ec44a448d53d4c20b9d4c5d825d4
+Author: Adam Jackson <ajax@benzedrine.nwnk.net>
+Date:   Fri Oct 13 17:01:59 2006 -0400
+
+    Bump to 1.0.2
+
+commit ae3b57953f5c1fa875d19fb42a2178d7e594ea44
+Author: Adam Jackson <ajax@benzedrine.nwnk.net>
+Date:   Thu Oct 12 20:36:52 2006 -0400
+
+    Fix the ChangeLog hook to distcheck.
+
+commit 4a2f176da3e2171f4feea2e6c8787e24fdf204f3
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Sep 15 14:59:15 2006 -0700
+
+    Remove GIT_DIR setting from git log command
+
+commit ec3abba0e351278876909bb5250d490b807d904a
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Fri Sep 15 13:54:18 2006 -0700
+
+    Copy additional copyright/license statements from source to COPYING
+
+commit b4c6bd92b3a8bed746da641c59a9f040e1d83768
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Wed Sep 13 14:09:22 2006 -0700
+
+    Bug 728: RUI in _X11TransSocketINETGetAddr in file "Xtranssock.c"
+    
+    Bug #728: <https://bugs.freedesktop.org/show_bug.cgi?id=728>
+    Patch #3527: <https://bugs.freedesktop.org/attachment.cgi?id=3527>
+    bzero sockaddr structures before passing to kernel to convince memory
+    checkers that they are initialized before use
+
+commit 5d006baadf213e91f131ffedc53c88a973fb1cba
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Aug 24 17:40:24 2006 -0700
+
+    Use SUN_LEN if it is defined on non-BSD44SOCKETS systems
+
+commit 2495789d6c290e2037b2836f28b027786ea5b605
+Author: Petr Salinger <petr.salinger@t-systems.cz>
+Date:   Sun Apr 23 01:31:00 2006 -0700
+
+    Bug 4982: use offsetof for manipulating struct sockaddr_un
+    
+    X.Org Bugzilla #4982 <https://bugs.freedesktop.org/show_bug.cgi?id=4982>
+    Patch #5424 <https://bugs.freedesktop.org/attachment.cgi?id=5424>
+
+commit 2633eaf8824828433a0eb9c9f3c4263b50342473
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Aug 24 16:53:08 2006 -0700
+
+    Try to capture the insanity of xtrans in a short README document
+
+commit 02ffb657b023d9b2a2c6c1d2417da8dcb96aa4b2
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Aug 24 14:46:42 2006 -0700
+
+    More sprintf -> snprintf conversions
+
+commit 3d5e7dd18c8836065c4835740211c10747b18abd
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Wed Aug 23 19:14:35 2006 -0700
+
+    Replace static ChangeLog with dist-hook to generate from git-log
+
+commit 92807fe90aad2303cec4b54bec40ce6edf671654
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Wed Aug 23 16:59:33 2006 -0700
+
+    Add ResetListener for named pipe transport
+    
+    (more merging of Xtrans code from Solaris xtrans)
+
+commit e11b861fcf3a295e5cb390cbac3a44d8ce4fad4f
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Tue Aug 22 11:29:46 2006 -0700
+
+    Merge more fixes from Solaris xtrans
+    
+    Convert sprintf -> snprintf
+    Don't use fake readv/writev on Solaris x86.
+
+commit 049932c0171855aa6d55222947f4d47495b6f173
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Aug 21 19:08:19 2006 -0700
+
+    Merge Solaris named pipe transport support into LOCALCONN
+    
+    Also clean up #ifdefs in Xtranslcl for which transport types are supported
+    Add "pipe" alias for named pipe transport on Solaris to match Solaris Xlib.
+
+commit 11391a1ffe4c633507406d2a1ed5abe57c8698db
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Aug 21 19:05:49 2006 -0700
+
+    Add --enable-local-transport and set it on by default on SVR4 OS'es
+
+commit c0ebfcde0dd3f82c0e5712764e4403b2837e09b5
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Mon Aug 21 19:04:54 2006 -0700
+
+    Add *~ to .gitignore to skip emacs droppings
+
+commit fe7054f2f5ce74ce9b8c1704899894bc1c9f32b7
+Author: Alan Coopersmith <alan.coopersmith@sun.com>
+Date:   Thu Jul 13 14:59:21 2006 -0700
+
+    renamed: .cvsignore -> .gitignore
+
+commit 0eea51ea11381ba07d5e6953c7bf6519a3ded829
+Author: Donnie Berkholz <spyderous@gentoo.org>
+Date:   Fri Jun 30 04:05:45 2006 +0000
+
+    Bump to 1.0.1.
+
+commit 8d37f63810fc12f113bfcf37065ac9da09702b46
+Author: Matthieu Herrb <matthieu.herrb@laas.fr>
+Date:   Tue Jun 20 19:11:16 2006 +0000
+
+    Check setuild() return value. Bugzilla #7116.
+
+commit f9a47b508a89c647829266aacb19a0fc2dbb6158
+Author: Jeremy C. Reed <reed@reedmedia.net>
+Date:   Thu May 25 20:20:54 2006 +0000
+
+    No code change. Just fix comment that said SOCKCONN to become TCPCONN.
+        (This dates back to 1994 or before.)
+
+commit 2b7124954f5bedc8625c2f144bbbab4bbba7701c
+Author: Kevin E Martin <kem@kem.org>
+Date:   Thu Dec 15 00:24:36 2005 +0000
+
+    Update package version number for final X11R7 release candidate.
+
+commit 3d3228a24513ea75c73f6d58ba50097f32b297a1
+Author: Kevin E Martin <kem@kem.org>
+Date:   Wed Nov 9 21:19:14 2005 +0000
+
+    Update package version number for X11R7 RC2 release.
+
+commit 2cac02b2fe1ceaec2a2f1cd601d9ab4afcf3cb66
+Author: Kean Johnson <kean@armory.com>
+Date:   Tue Nov 8 06:33:26 2005 +0000
+
+    See ChangeLog entry 2005-11-07 for details.
+
+commit 063a39b0e1e615387fd7baa570265ed71ca87c22
+Author: Kevin E Martin <kem@kem.org>
+Date:   Wed Oct 19 02:48:13 2005 +0000
+
+    Update package version number for RC1 release.
+
+commit 21a498d25f567ada296d0321f65536dfc816482b
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Mon Oct 3 17:45:28 2005 +0000
+
+    Bug #3813 <https://bugs.freedesktop.org/show_bug.cgi?id=3813> GNU/kFreeBSD
+        fix for xtrans (Robert Millan)
+
+commit e41835b4b2fe03d8a1997bd8e8eabab2a94bccd5
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Sun Oct 2 21:01:35 2005 +0000
+
+    //bugs.freedesktop.org/show_bug.cgi?id=4256> Patch #3046
+        <https://bugs.freedesktop.org/attachment.cgi?id=3046> Define
+        MAXHOSTNAMELEN if platform doesn't (Michael Banck)
+
+commit 4683f28f0c9d1a1ee0338a32011219ed1fb3c565
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Fri Aug 19 23:53:22 2005 +0000
+
+    Bugzilla #3957 <https://bugs.freedesktop.org/show_bug.cgi?id=3957> Patch
+        #2924 <https://bugs.freedesktop.org/attachment.cgi?id=2924> xtrans
+        changes for AIX (Dan McNichol, IBM)
+    Bugzilla #3957 <https://bugs.freedesktop.org/show_bug.cgi?id=3957> Patch
+        #2925 <https://bugs.freedesktop.org/attachment.cgi?id=2925> xtrans
+        changes for AIX (Dan McNichol, IBM)
+
+commit 79db37c65905823b66411533152ab54407f04004
+Author: Eric Anholt <anholt@freebsd.org>
+Date:   Wed Aug 17 19:10:49 2005 +0000
+
+    On FreeBSD, some of the symbols necessary for secure RPC support are in
+        librpcsvc, so check for their presence in rpcsvc so that the library
+        will be added.
+
+commit 5165ebdb8144cd5be706e49957f5c8b51b762821
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Tue Aug 16 02:23:41 2005 +0000
+
+    Define BSD44SOCKETS if struct sockaddr_in has a sin_len member
+
+commit 4ce01dc794022e74b01aac7b902acbbfebc74ed1
+Author: Kevin E Martin <kem@kem.org>
+Date:   Fri Jul 29 21:22:54 2005 +0000
+
+    Various changes preparing packages for RC0:
+    - Verify and update package version numbers as needed
+    - Implement versioning scheme
+    - Change bug address to point to bugzilla bug entry form
+    - Disable loadable i18n in libX11 by default (use --enable-loadable-i18n to
+        reenable it)
+    - Fix makedepend to use pkgconfig and pass distcheck
+    - Update build script to build macros first
+    - Update modular Xorg version
+
+commit 4ddee2d488f8bdcee624be96fa52ca03a7e64b83
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Tue Jul 26 18:59:11 2005 +0000
+
+    Use AC_TYPE_SIGNAL to replace Imake's SIGNAL_DEFINES (used in Xtransutil.c)
+
+commit 0a80fbc1eb80343eaff27c48f9531f5ba709b6ef
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Tue Jul 26 18:55:41 2005 +0000
+
+    Add config.h includes for modularization Use RETSIGTYPE if defined by
+        autoconf in addition to Imake's SIGNALRETURNSINT. Use
+        HAVE_WORKING_VFORK if defined by autoconf in addition to Imake's
+        HAS_VFORK
+
+commit 9a44d60cb031f1779c228f13697fb17e17df10d5
+Author: Matthieu Herrb <matthieu.herrb@laas.fr>
+Date:   Sat Jul 23 19:52:56 2005 +0000
+
+    typo
+
+commit 65ca78f15fe7f1640f3610245957eac9bca0bf04
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Sun Jul 17 02:01:55 2005 +0000
+
+    Move AC_MSG_RESULT so it shows up in the right place, not after other tests
+        are executed
+
+commit f1d56df5736087eafa3db255437c918f6b9075a1
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Thu Jul 14 22:44:31 2005 +0000
+
+    Split out TCP library/IPv6 support checks into XTRANS_TCP_FLAGS for sharing
+        with code like xdm that doesn't use Xtrans but accesses TCP sockets
+        directly. Clean up --enable flags and report settings in configure
+        output.
+
+commit 9552877bf0a7be02c781ef8fb2f271573a55e297
+Author: Keith Packard <keithp@keithp.com>
+Date:   Sat Jul 9 21:22:30 2005 +0000
+
+    Add .cvsignore files
+
+commit 586cc58eff6d3c68313e5c8aedb8ec2464069f2f
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Sun Jul 3 23:51:24 2005 +0000
+
+    Change <X11/os.h> to "os.h".
+
+commit 926367f82972bd94a64ef76c8e036f27ca61fb14
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Sun Jul 3 07:01:01 2005 +0000
+
+    Add Xtrans definitions (FONT_t, TRANS_CLIENT) to clean up warnings.
+    Add XSERV_t, TRANS_SERVER, TRANS_REOPEN to quash warnings.
+    Add #include <dix-config.h> or <xorg-config.h>, as appropriate, to all
+        source files in the xserver/xorg tree, predicated on defines of
+        HAVE_{DIX,XORG}_CONFIG_H. Change all Xfont includes to
+        <X11/fonts/foo.h>.
+
+commit 40b7e438e4b441204ff47e1e25755162921d7c3e
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Sat Jul 2 18:00:50 2005 +0000
+
+    Make includedir=@includedir@ in xtrans.pc.in, not with /X11/Xtrans.
+
+commit b413f4c1dddc467014adf16bfe31627e65508c12
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Wed Jun 22 22:46:39 2005 +0000
+
+    Apply these patches from Theo van Klaveren:
+    lib-dmx.patch lib-FS.patch lib-X11.patch lib-XRes.patch
+        lib-XScrnSaver.patch lib-xtrans.patch
+    to make the libraries distcheck.
+
+commit 57aac0006e27624a41f04c5d0c458b9f0108a084
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Wed Jun 22 22:36:51 2005 +0000
+
+    Add the rest of my patch from bugzilla #1605 to define INADDR_NONE on
+        platforms that don't define it in the system headers.
+
+commit f5a6a188407cec6e567070d192aac2db72cacd92
+Author: Kristian Høgsberg <krh@redhat.com>
+Date:   Wed Jun 22 01:21:24 2005 +0000
+
+    Apply patch by Alan Coopersmith from #1605 to fix address resolution of
+        hostnames starting with a digit for 64 bit architechtures.
+
+commit 5bad61831b1c06888d80d92a0bf34acbeecda026
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Sat Jun 18 07:48:43 2005 +0000
+
+    Move Secure RPC flags from X11/configure.ac to xtrans/xtrans.m4 since
+        multiple modules will need them
+
+commit 62438b14130e0f8de6939767a108ef12558653a3
+Author: Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>
+Date:   Thu Jun 9 15:56:48 2005 +0000
+
+    Use $(includedir)/X11/Xtrans for Xtransincludedir
+
+commit 7c8e397ddcbd0ae998cc4f23868726022d1aa47b
+Author: Eric Anholt <anholt@freebsd.org>
+Date:   Wed Jun 8 06:24:53 2005 +0000
+
+    Install the xtrans.m4 to the directory returned by aclocal --print-ac-dir,
+        so that the aclocal calls in other modules will pick it up if this
+        prefix's aclocal dir is not in a default path for system aclocal.
+
+commit 58c7263ca5b64a21dc101bb4b24201ba67a8d068
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Wed May 25 21:47:56 2005 +0000
+
+    - Add FSlib to symlink.sh
+    - Change Xtrans includedir back to be X11/Xtrans, so that users of it can
+        continue to include <X11/*>
+    - Add build system for FSlib
+    - Conditionally include config.h in xc/lib/FS
+    - Remove redundant include of FSproto.h in xc/lib/FS
+    - Add check to proto/X11/configure.ac whether -D_XOPEN_SOURCE is needed.
+
+commit b2e662de63948928e4cbc7e3ba90631f150c5137
+Author: Josh Triplett <josh@speakeasy.net>
+Date:   Mon May 23 01:53:21 2005 +0000
+
+    Change xtransincludedir in pkg-config file to match change in Makefile.am.
+
+commit 83d29f6e0c1587c8ad008672e7ae5631942559eb
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Sat May 21 23:07:48 2005 +0000
+
+    xtrans:
+    Create autoconf macro XTRANS_CONNECTION_FLAGS to provide standard set of
+        --enable flags for which transports to support and common place to
+        update for required libraries for platforms that need certain libs for
+        certain transports
+    ICE:
+    Add ICE_t #define required by Xtrans headers. Replace static defines of
+        LOCALCONN & UNIXCONN with new XTRANS_CONNECTION_FLAGS macro.
+    X11:
+    Moved transport type checks to new macro XTRANS_CONNECTION_FLAGS in
+        xtrans.m4 in xtrans module so they can be shared by all modules using
+        xtrans.
+
+commit bd79d86fb50233e0cd41a57b553f12b6d490ac7e
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Thu May 19 00:22:33 2005 +0000
+
+    revert last change, didn't do right thing at all, sorry for the noise
+
+commit 10776fa562c060d74fdd4434a16408fe4bd34ab9
+Author: Adam Jackson <ajax@nwnk.net>
+Date:   Thu May 19 00:10:08 2005 +0000
+
+    Require automake 1.7 in AM_INIT_AUTOMAKE
+
+commit daa7168e9e0cdff5eb06b0c9a7155f8880681fff
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Fri May 13 22:53:43 2005 +0000
+
+    - For now put xtrans in X11/Xtrans/X11, since libX11 is looking for it in
+        <X11/...>
+    - For Xcomposite and Xdamage, don't link the build system out of the xc
+        tree
+    - Link the public X11 headers into their own directory
+    - Add links to XKeysymDB and XErrorDB
+    - Add links to all the Xlib man pages
+    - Add links to the lcUniConv subdirectory
+    - Conditionally include config.h in Xlib source
+
+commit d11d95fa4faec21655625b7de27d8a71c08ffe2d
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Fri May 13 15:16:43 2005 +0000
+
+    Dummy changes to ChangeLog/configure.ac to see if that fixes group
+        permissions
+
+commit b8a8c31f63a543d1c1c6bb4ae26a4019b4400edc
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Fri May 13 15:04:52 2005 +0000
+
+    Re-adding ChangeLog and configure.ac files
+
+commit 798c08054ce5a8238f35fee3e69218ece74441fa
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Fri May 13 15:02:19 2005 +0000
+
+    Temporarily remove ChangeLog configure.ac
+
+commit b3da86ae588df14dde916674a4f6593edf1964f7
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Fri May 13 14:43:37 2005 +0000
+
+    Dummy commit to see if that fixes the group execute permissions
+
+commit ea04267da780c2c3f08a710d15468565897420c4
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Thu May 12 16:12:34 2005 +0000
+
+    Make xtrans install in $(includedir)/X11/Xtrans. Remove all references to
+        Xtransdef.
+    Add Xdmcp build files
+    Add Wrap.h to lib/dmcp part of symlink script.
+
+commit f25791629f3f443d2552bdb05bea1a960b530342
+Author: Daniel Stone <daniel@fooishbar.org>
+Date:   Thu May 12 02:49:16 2005 +0000
+
+    Add Xtransdef.h.in as an AM_CONFIG_HEADER.
+
+commit d628bf24f2bf0d017394b6961784d7ac5b33f46b
+Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
+Date:   Wed May 11 22:44:52 2005 +0000
+
+    lib/Xau:
+    - Update AUTHORS, COPYING from Keith's tree
+    - Don't use gcc specific "-include config.h"
+    - Add autogen.sh
+    lib/xtrans:
+    - Add AUTHORS, COPYING, ChangeLog, Makefile.am, NEWS, README, autogen.sh,
+        configure.ac, xtrans.pc.in
+    xc/lib/Xau:
+    - Add conditionalized #include <config.h>
+    util/modular/symlink.sh
+    - Add functions symlink_lib_xau() and symlink_lib_xtrans()
+    util/modular/addconfig.h
+    - New script that adds #include <config.h> to files
+
+commit c814f30e9a5dc48a24c20517334cf5f9c37e066a
+Author: Roland Mainz <roland.mainz@nrubsig.org>
+Date:   Wed Mar 2 11:20:29 2005 +0000
+
+    xc/config/cf/DragonFly.cf
+    xc/config/cf/Imake.cf
+    xc/config/cf/Imakefile
+    xc/config/imake/imake.c
+    xc/config/imake/imakemdep.h
+    xc/extras/drm/shared/drm.h
+    xc/include/Xos_r.h
+    xc/lib/xtrans/Xtranssock.c
+    xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
+    xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
+    xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c
+    //bugs.freedesktop.org/show_bug.cgi?id=1712) attachment #2004
+        (https://bugs.freedesktop.org/attachment.cgi?id=2004): Add support for
+        DragonFly/BSD platform. Patch by Jeroen Ruigrok <asmodai@tendra.org>
+        and Mike Verona <firedragonfly@gmail.com>.
+
+commit 92e80a5a67273fc60623b17a5f34c239f1ed6947
+Author: Alexander Gottwald <alexander.gottwald@s1999.tu-chemnitz.de>
+Date:   Mon Nov 15 15:06:56 2004 +0000
+
+    Bufzilla #1802, http://freedesktop.org/bugzilla/show_bug.cgi?id=1802 Added
+        mingw (Win32) port
+
+commit d92a9d31416a8366cd065886d7ff352fefce646d
+Author: Egbert Eich <eich@suse.de>
+Date:   Fri Aug 27 22:47:45 2004 +0000
+
+    Set the define XtransFailSoft to restore the old behavior to fail softly
+        when socket directory cannot chowned/chmod to correct user/group. This
+        should be added on a per OS basis which hasn't been done.
+
+commit 48ffd91cff9a07c68194f6d0b380dd2acd46a8ca
+Author: Egbert Eich <eich@suse.de>
+Date:   Fri Jul 30 21:00:20 2004 +0000
+
+    fail hard if socket directories cannot be chowned to root or chmod'ed to
+        the requested mode if 'sticky' bit is requested for this directory
+        instead of just print a warning that will remain unnoticed most of the
+        times.
+
+commit c3e50fa69ea7a2d08a298866e8a63c0f07c8248d
+Author: Egbert Eich <eich@suse.de>
+Date:   Fri Jul 30 18:40:36 2004 +0000
+
+    Fixed typo in a comment.
+    Deleted bogus comment.
+    Added debugging support.
+
+commit 79d38d618406ecc5228730a57ad406b280a5a189
+Author: Alan Coopersmith <Alan.Coopersmith@sun.com>
+Date:   Sat Jul 17 01:13:31 2004 +0000
+
+    Fix typo in debug message in MakeAllCLTSServerListeners
+    Add $(GETPEER_DEFINES) to DEPEND_DEFINES for makedepend
+    Add "localuser" and "localgroup" access types to server-interpreted
+        authentication scheme.
+
+commit 8d0820e2058545e27f95d9fdc581262822799193
+Author: Egbert Eich <eich@suse.de>
+Date:   Fri Apr 23 18:44:27 2004 +0000
+
+    Merging XORG-CURRENT into trunk
+
+commit c594d3393cd355f52545b05bcc27ee8a2c533caa
+Author: Egbert Eich <eich@suse.de>
+Date:   Sun Mar 14 08:32:40 2004 +0000
+
+    Importing vendor version xf86-4_4_99_1 on Sun Mar 14 00:26:39 PST 2004
+
+commit 2d51220fae172d2b8d28b971a853605b41038533
+Author: Egbert Eich <eich@suse.de>
+Date:   Wed Mar 3 12:11:46 2004 +0000
+
+    Importing vendor version xf86-4_4_0 on Wed Mar 3 04:09:24 PST 2004
+
+commit 6e2cb92d192171961165c8e5a24b00f35f56aaeb
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Feb 26 13:35:36 2004 +0000
+
+    readding XFree86's cvs IDs
+
+commit 93f13d69958cb9c9adfe1244e478521269f9258b
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Feb 26 09:22:54 2004 +0000
+
+    Importing vendor version xf86-4_3_99_903 on Wed Feb 26 01:21:00 PST 2004
+
+commit 7a10db6531003055886e0e994c2ef8e46a010eb2
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Mon Feb 23 20:34:44 2004 +0000
+
+    Import most of XFree86 4.4RC3. This import excludes files which have the
+        new license. If we want to, later we can import 4.4RC3 again and pick
+        up the files that have the new license, but for now the vendor branch
+        is "pure."
+
+commit 871b8c33f2ab8c98b95aa3324bb70055f5207c61
+Author: Egbert Eich <eich@suse.de>
+Date:   Thu Jan 29 08:08:15 2004 +0000
+
+    Importing vendor version xf86-012804-2330 on Thu Jan 29 00:06:33 PST 2004
+
+commit 352e5de72e125d7d474907f354462cc1442e0989
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Fri Dec 19 20:54:45 2003 +0000
+
+    XFree86 4.3.99.902 (RC 2)
+
+commit d223c1bb16c503e58f07dfef14b8e79fe7c358ff
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Thu Dec 4 22:03:05 2003 +0000
+
+    XFree86 4.3.99.901 (RC 1)
+
+commit 6c36ea2d54ea6b6f0cbece06d867d0b884783d0c
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Tue Nov 25 19:28:21 2003 +0000
+
+    XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folks
+
+commit 3b0d3a905e39624abe9ddd1ce20542097601e4c2
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Tue Nov 25 19:28:21 2003 +0000
+
+    Initial revision
+
+commit 3bd236a07c0ebaabb7337dd5d56bc57a028a9c0e
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Fri Nov 14 16:48:50 2003 +0000
+
+    XFree86 4.3.0.1
+
+commit 26781c4f009a4b448dca3ab4912cbf01182e3d92
+Author: Kaleb Keithley <kaleb@freedesktop.org>
+Date:   Fri Nov 14 15:54:40 2003 +0000
+
+    R6.6 is the Xorg base-line
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..c9fd2c0
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,290 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007, 2008 Free Software Foundation, Inc.
+
+   This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+   Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package.  The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+   It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring.  Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+   The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'.  You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.
+
+     Running `configure' might take a while.  While running, it prints
+     some messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+  6. Often, you can also type `make uninstall' to remove the installed
+     files again.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+   You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here
+is an example:
+
+     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+   *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you can use GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory.  After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+   On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor.  Like
+this:
+
+     ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+                 CPP="gcc -E" CXXCPP="g++ -E"
+
+   This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+   By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc.  You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Particular systems
+==================
+
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+     ./configure CC="cc -Ae"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+   On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
+a workaround.  If GNU CC is not installed, it is therefore recommended
+to try
+
+     ./configure CC="cc"
+
+and if that doesn't work, try
+
+     ./configure CC="cc -nodtk"
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on.  Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+     CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+     OS KERNEL-OS
+
+   See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+   If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+   If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+   Variables not defined in a site shell script can be set in the
+environment passed to `configure'.  However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost.  In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'.  For example:
+
+     ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug.  Until the bug is fixed you can use this workaround:
+
+     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+     Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+     Print a summary of the options unique to this package's
+     `configure', and exit.  The `short' variant lists options used
+     only in the top level, while the `recursive' variant lists options
+     also present in any nested packages.
+
+`--version'
+`-V'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`--cache-file=FILE'
+     Enable the cache: use and save the results of the tests in FILE,
+     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     disable caching.
+
+`--config-cache'
+`-C'
+     Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+     Use DIR as the installation prefix.  *Note Installation Names::
+     for more details, including other options available for fine-tuning
+     the installation locations.
+
+`--no-create'
+`-n'
+     Run the configure checks, but stop before creating any output
+     files.
+
+`configure' also accepts some other, not widely useful, options.  Run
+`configure --help' for more details.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..9ff1723
--- /dev/null
@@ -0,0 +1,31 @@
+SUBDIRS=doc
+
+Xtransincludedir = $(includedir)/X11/Xtrans
+Xtransinclude_HEADERS = \
+       Xtrans.h \
+       Xtrans.c \
+       Xtransint.h \
+       Xtranslcl.c \
+       Xtranssock.c \
+       Xtranstli.c \
+       Xtransutil.c \
+       transport.c
+
+aclocaldir = $(datadir)/aclocal
+aclocal_DATA = xtrans.m4
+
+pkgconfigdir = $(datadir)/pkgconfig
+pkgconfig_DATA = xtrans.pc
+
+MAINTAINERCLEANFILES = ChangeLog INSTALL
+EXTRA_DIST = ${aclocal_DATA}
+
+.PHONY: ChangeLog INSTALL
+
+INSTALL:
+       $(INSTALL_CMD)
+
+ChangeLog:
+       $(CHANGELOG_CMD)
+
+dist-hook: ChangeLog INSTALL
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..6b1c468
--- /dev/null
+++ b/README
@@ -0,0 +1,37 @@
+xtrans is a library of code that is shared among various X packages to
+handle network protocol transport in a modular fashion, allowing a
+single place to add new transport types.  It is used by the X server,
+libX11, libICE, the X font server, and related components.
+
+It is however, *NOT* a shared library, but code which each consumer
+includes and builds it's own copy of with various #ifdef flags to make
+each copy slightly different.  To support this in the modular build
+system, this package simply installs the C source files into
+$(prefix)/include/X11/Xtrans and installs a pkg-config file and an
+autoconf m4 macro file with the flags needed to use it.
+
+Documentation of the xtrans API can be found in the included xtrans.xml
+file in DocBook XML format. If 'xmlto' is installed, you can generate text,
+html, postscript or pdf versions of the documentation by configuring
+the build with --enable-docs, which is the default.
+
+Please submit bugs & patches to the Xorg bugzilla:
+
+       https://bugs.freedesktop.org/enter_bug.cgi?product=xorg
+
+under the component "Lib/xtrans".
+
+All questions regarding this software should be directed at the
+Xorg mailing list:
+
+       http://lists.freedesktop.org/mailman/listinfo/xorg
+
+The master development code repository can be found at:
+
+       git://anongit.freedesktop.org/git/xorg/lib/libxtrans
+
+       http://cgit.freedesktop.org/xorg/lib/libxtrans
+
+For more information on the git code manager, see:
+
+       http://wiki.x.org/wiki/GitPage
diff --git a/Xtrans.c b/Xtrans.c
new file mode 100644 (file)
index 0000000..54e3bdc
--- /dev/null
+++ b/Xtrans.c
@@ -0,0 +1,1352 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <ctype.h>
+
+/*
+ * The transport table contains a definition for every transport (protocol)
+ * family. All operations that can be made on the transport go through this
+ * table.
+ *
+ * Each transport is assigned a unique transport id.
+ *
+ * New transports can be added by adding an entry in this table.
+ * For compatiblity, the transport ids should never be renumbered.
+ * Always add to the end of the list.
+ */
+
+#define TRANS_TLI_INET_INDEX           1
+#define TRANS_TLI_TCP_INDEX            2
+#define TRANS_TLI_TLI_INDEX            3
+#define TRANS_SOCKET_UNIX_INDEX                4
+#define TRANS_SOCKET_LOCAL_INDEX       5
+#define TRANS_SOCKET_INET_INDEX                6
+#define TRANS_SOCKET_TCP_INDEX         7
+#define TRANS_DNET_INDEX               8
+#define TRANS_LOCAL_LOCAL_INDEX                9
+#define TRANS_LOCAL_PTS_INDEX          10
+#define TRANS_LOCAL_NAMED_INDEX                11
+/* 12 used to be ISC, but that's gone. */
+#define TRANS_LOCAL_SCO_INDEX          13
+#define TRANS_SOCKET_INET6_INDEX       14
+#define TRANS_LOCAL_PIPE_INDEX         15
+
+
+static
+Xtransport_table Xtransports[] = {
+#if defined(STREAMSCONN)
+    { &TRANS(TLITCPFuncs),     TRANS_TLI_TCP_INDEX },
+    { &TRANS(TLIINETFuncs),    TRANS_TLI_INET_INDEX },
+    { &TRANS(TLITLIFuncs),     TRANS_TLI_TLI_INDEX },
+#endif /* STREAMSCONN */
+#if defined(TCPCONN)
+    { &TRANS(SocketTCPFuncs),  TRANS_SOCKET_TCP_INDEX },
+#if defined(IPv6) && defined(AF_INET6)
+    { &TRANS(SocketINET6Funcs),        TRANS_SOCKET_INET6_INDEX },
+#endif /* IPv6 */
+    { &TRANS(SocketINETFuncs), TRANS_SOCKET_INET_INDEX },
+#endif /* TCPCONN */
+#if defined(UNIXCONN)
+#if !defined(LOCALCONN)
+    { &TRANS(SocketLocalFuncs),        TRANS_SOCKET_LOCAL_INDEX },
+#endif /* !LOCALCONN */
+    { &TRANS(SocketUNIXFuncs), TRANS_SOCKET_UNIX_INDEX },
+#endif /* UNIXCONN */
+#if defined(LOCALCONN)
+    { &TRANS(LocalFuncs),      TRANS_LOCAL_LOCAL_INDEX },
+#ifndef sun
+    { &TRANS(PTSFuncs),                TRANS_LOCAL_PTS_INDEX },
+#endif /* sun */
+#if defined(SVR4) || defined(__SVR4)
+    { &TRANS(NAMEDFuncs),      TRANS_LOCAL_NAMED_INDEX },
+#endif
+#ifdef sun
+    { &TRANS(PIPEFuncs),       TRANS_LOCAL_PIPE_INDEX },
+#endif /* sun */
+#if defined(__SCO__) || defined(__UNIXWARE__)
+    { &TRANS(SCOFuncs),                TRANS_LOCAL_SCO_INDEX },
+#endif /* __SCO__ || __UNIXWARE__ */
+#endif /* LOCALCONN */
+};
+
+#define NUMTRANS       (sizeof(Xtransports)/sizeof(Xtransport_table))
+
+
+#ifdef WIN32
+#define ioctl ioctlsocket
+#endif
+
+
+\f
+/*
+ * These are a few utility function used by the public interface functions.
+ */
+
+void
+TRANS(FreeConnInfo) (XtransConnInfo ciptr)
+
+{
+    prmsg (3,"FreeConnInfo(%p)\n", ciptr);
+
+    if (ciptr->addr)
+       free (ciptr->addr);
+
+    if (ciptr->peeraddr)
+       free (ciptr->peeraddr);
+
+    if (ciptr->port)
+       free (ciptr->port);
+
+    free (ciptr);
+}
+
+
+#define PROTOBUFSIZE   20
+
+static Xtransport *
+TRANS(SelectTransport) (const char *protocol)
+
+{
+    char       protobuf[PROTOBUFSIZE];
+    int                i;
+
+    prmsg (3,"SelectTransport(%s)\n", protocol);
+
+    /*
+     * Force Protocol to be lowercase as a way of doing
+     * a case insensitive match.
+     */
+
+    strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
+    protobuf[PROTOBUFSIZE-1] = '\0';
+
+    for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
+       if (isupper (protobuf[i]))
+           protobuf[i] = tolower (protobuf[i]);
+
+    /* Look at all of the configured protocols */
+
+    for (i = 0; i < NUMTRANS; i++)
+    {
+       if (!strcmp (protobuf, Xtransports[i].transport->TransName))
+           return Xtransports[i].transport;
+    }
+
+    return NULL;
+}
+
+#ifndef TEST_t
+static
+#endif /* TEST_t */
+int
+TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
+
+{
+    /*
+     * For the font library, the address is a string formatted
+     * as "protocol/host:port[/catalogue]".  Note that the catologue
+     * is optional.  At this time, the catologue info is ignored, but
+     * we have to parse it anyways.
+     *
+     * Other than fontlib, the address is a string formatted
+     * as "protocol/host:port".
+     *
+     * If the protocol part is missing, then assume TCP.
+     * If the protocol part and host part are missing, then assume local.
+     * If a "::" is found then assume DNET.
+     */
+
+    char       *mybuf, *tmpptr;
+    const char *_protocol;
+    char       *_host, *_port;
+    char       hostnamebuf[256];
+    int                _host_len;
+
+    prmsg (3,"ParseAddress(%s)\n", address);
+
+    /* Copy the string so it can be changed */
+
+    tmpptr = mybuf = strdup (address);
+
+    /* Parse the string to get each component */
+
+    /* Get the protocol part */
+
+    _protocol = mybuf;
+
+
+   if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&
+      ((mybuf = strrchr (tmpptr,':')) == NULL) )
+   {
+       /* address is in a bad format */
+       *protocol = NULL;
+       *host = NULL;
+       *port = NULL;
+       free (tmpptr);
+       return 0;
+    }
+
+    if (*mybuf == ':')
+    {
+       /*
+        * If there is a hostname, then assume tcp, otherwise
+        * it must be local.
+        */
+       if (mybuf == tmpptr)
+       {
+           /* There is neither a protocol or host specified */
+           _protocol = "local";
+       }
+       else
+       {
+           /* There is a hostname specified */
+           _protocol = "tcp";
+           mybuf = tmpptr;     /* reset to the begining of the host ptr */
+       }
+    }
+    else
+    {
+       /* *mybuf == '/' */
+
+       *mybuf ++= '\0'; /* put a null at the end of the protocol */
+
+       if (strlen(_protocol) == 0)
+       {
+           /*
+            * If there is a hostname, then assume tcp, otherwise
+            * it must be local.
+            */
+           if (*mybuf != ':')
+               _protocol = "tcp";
+           else
+               _protocol = "local";
+       }
+    }
+
+    /* Get the host part */
+
+    _host = mybuf;
+
+    if ((mybuf = strrchr (mybuf,':')) == NULL)
+    {
+       *protocol = NULL;
+       *host = NULL;
+       *port = NULL;
+       free (tmpptr);
+       return 0;
+    }
+
+    *mybuf ++= '\0';
+
+    _host_len = strlen(_host);
+    if (_host_len == 0)
+    {
+       TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+       _host = hostnamebuf;
+    }
+#if defined(IPv6) && defined(AF_INET6)
+    /* hostname in IPv6 [numeric_addr]:0 form? */
+    else if ( (_host_len > 3) &&
+      ((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0))
+      && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) {
+       struct sockaddr_in6 sin6;
+
+       *(_host + _host_len - 1) = '\0';
+
+       /* Verify address is valid IPv6 numeric form */
+       if (inet_pton(AF_INET6, _host + 1, &sin6) == 1) {
+           /* It is. Use it as such. */
+           _host++;
+           _protocol = "inet6";
+       } else {
+           /* It's not, restore it just in case some other code can use it. */
+           *(_host + _host_len - 1) = ']';
+       }
+    }
+#endif
+
+
+    /* Get the port */
+
+    _port = mybuf;
+
+#if defined(FONT_t) || defined(FS_t)
+    /*
+     * Is there an optional catalogue list?
+     */
+
+    if ((mybuf = strchr (mybuf,'/')) != NULL)
+       *mybuf ++= '\0';
+
+    /*
+     * The rest, if any, is the (currently unused) catalogue list.
+     *
+     * _catalogue = mybuf;
+     */
+#endif
+
+#ifdef HAVE_LAUNCHD
+    /* launchd sockets will look like 'local//tmp/launch-XgkNns/:0' */
+    if(address != NULL && strlen(address)>8 && (!strncmp(address,"local//",7))) {
+      _protocol="local";
+      _host="";
+      _port=address+6;
+    }
+#endif
+
+    /*
+     * Now that we have all of the components, allocate new
+     * string space for them.
+     */
+
+    if ((*protocol = strdup (_protocol)) == NULL)
+    {
+       /* Malloc failed */
+       *port = NULL;
+       *host = NULL;
+       *protocol = NULL;
+       free (tmpptr);
+       return 0;
+    }
+
+    if ((*host = strdup (_host)) == NULL)
+    {
+       /* Malloc failed */
+       *port = NULL;
+       *host = NULL;
+       free (*protocol);
+       *protocol = NULL;
+       free (tmpptr);
+       return 0;
+    }
+
+    if ((*port = strdup (_port)) == NULL)
+    {
+       /* Malloc failed */
+       *port = NULL;
+       free (*host);
+       *host = NULL;
+       free (*protocol);
+       *protocol = NULL;
+       free (tmpptr);
+       return 0;
+    }
+
+    free (tmpptr);
+
+    return 1;
+}
+
+
+/*
+ * TRANS(Open) does all of the real work opening a connection. The only
+ * funny part about this is the type parameter which is used to decide which
+ * type of open to perform.
+ */
+
+static XtransConnInfo
+TRANS(Open) (int type, char *address)
+
+{
+    char               *protocol = NULL, *host = NULL, *port = NULL;
+    XtransConnInfo     ciptr = NULL;
+    Xtransport         *thistrans;
+
+    prmsg (2,"Open(%d,%s)\n", type, address);
+
+#if defined(WIN32) && defined(TCPCONN)
+    if (TRANS(WSAStartup)())
+    {
+       prmsg (1,"Open: WSAStartup failed\n");
+       return NULL;
+    }
+#endif
+
+    /* Parse the Address */
+
+    if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)
+    {
+       prmsg (1,"Open: Unable to Parse address %s\n", address);
+       return NULL;
+    }
+
+    /* Determine the transport type */
+
+    if ((thistrans = TRANS(SelectTransport) (protocol)) == NULL)
+    {
+       prmsg (1,"Open: Unable to find transport for %s\n",
+              protocol);
+
+       free (protocol);
+       free (host);
+       free (port);
+       return NULL;
+    }
+
+    /* Open the transport */
+
+    switch (type)
+    {
+    case XTRANS_OPEN_COTS_CLIENT:
+#ifdef TRANS_CLIENT
+       ciptr = thistrans->OpenCOTSClient(thistrans, protocol, host, port);
+#endif /* TRANS_CLIENT */
+       break;
+    case XTRANS_OPEN_COTS_SERVER:
+#ifdef TRANS_SERVER
+       ciptr = thistrans->OpenCOTSServer(thistrans, protocol, host, port);
+#endif /* TRANS_SERVER */
+       break;
+    case XTRANS_OPEN_CLTS_CLIENT:
+#ifdef TRANS_CLIENT
+       ciptr = thistrans->OpenCLTSClient(thistrans, protocol, host, port);
+#endif /* TRANS_CLIENT */
+       break;
+    case XTRANS_OPEN_CLTS_SERVER:
+#ifdef TRANS_SERVER
+       ciptr = thistrans->OpenCLTSServer(thistrans, protocol, host, port);
+#endif /* TRANS_SERVER */
+       break;
+    default:
+       prmsg (1,"Open: Unknown Open type %d\n", type);
+    }
+
+    if (ciptr == NULL)
+    {
+       if (!(thistrans->flags & TRANS_DISABLED))
+       {
+           prmsg (1,"Open: transport open failed for %s/%s:%s\n",
+                  protocol, host, port);
+       }
+       free (protocol);
+       free (host);
+       free (port);
+       return NULL;
+    }
+
+    ciptr->transptr = thistrans;
+    ciptr->port = port;                        /* We need this for TRANS(Reopen) */
+
+    free (protocol);
+    free (host);
+
+    return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+/*
+ * We might want to create an XtransConnInfo object based on a previously
+ * opened connection.  For example, the font server may clone itself and
+ * pass file descriptors to the parent.
+ */
+
+static XtransConnInfo
+TRANS(Reopen) (int type, int trans_id, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr = NULL;
+    Xtransport         *thistrans = NULL;
+    char               *save_port;
+    int                        i;
+
+    prmsg (2,"Reopen(%d,%d,%s)\n", trans_id, fd, port);
+
+    /* Determine the transport type */
+
+    for (i = 0; i < NUMTRANS; i++)
+       if (Xtransports[i].transport_id == trans_id)
+       {
+           thistrans = Xtransports[i].transport;
+           break;
+       }
+
+    if (thistrans == NULL)
+    {
+       prmsg (1,"Reopen: Unable to find transport id %d\n",
+              trans_id);
+
+       return NULL;
+    }
+
+    if ((save_port = strdup (port)) == NULL)
+    {
+       prmsg (1,"Reopen: Unable to malloc port string\n");
+
+       return NULL;
+    }
+
+    /* Get a new XtransConnInfo object */
+
+    switch (type)
+    {
+    case XTRANS_OPEN_COTS_SERVER:
+       ciptr = thistrans->ReopenCOTSServer(thistrans, fd, port);
+       break;
+    case XTRANS_OPEN_CLTS_SERVER:
+       ciptr = thistrans->ReopenCLTSServer(thistrans, fd, port);
+       break;
+    default:
+       prmsg (1,"Reopen: Bad Open type %d\n", type);
+    }
+
+    if (ciptr == NULL)
+    {
+       prmsg (1,"Reopen: transport open failed\n");
+       free (save_port);
+       return NULL;
+    }
+
+    ciptr->transptr = thistrans;
+    ciptr->port = save_port;
+
+    return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+\f
+/*
+ * These are the public interfaces to this Transport interface.
+ * These are the only functions that should have knowledge of the transport
+ * table.
+ */
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo
+TRANS(OpenCOTSClient) (char *address)
+
+{
+    prmsg (2,"OpenCOTSClient(%s)\n", address);
+    return TRANS(Open) (XTRANS_OPEN_COTS_CLIENT, address);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo
+TRANS(OpenCOTSServer) (char *address)
+
+{
+    prmsg (2,"OpenCOTSServer(%s)\n", address);
+    return TRANS(Open) (XTRANS_OPEN_COTS_SERVER, address);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo
+TRANS(OpenCLTSClient) (char *address)
+
+{
+    prmsg (2,"OpenCLTSClient(%s)\n", address);
+    return TRANS(Open) (XTRANS_OPEN_CLTS_CLIENT, address);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo
+TRANS(OpenCLTSServer) (char *address)
+
+{
+    prmsg (2,"OpenCLTSServer(%s)\n", address);
+    return TRANS(Open) (XTRANS_OPEN_CLTS_SERVER, address);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+XtransConnInfo
+TRANS(ReopenCOTSServer) (int trans_id, int fd, char *port)
+
+{
+    prmsg (2,"ReopenCOTSServer(%d, %d, %s)\n", trans_id, fd, port);
+    return TRANS(Reopen) (XTRANS_OPEN_COTS_SERVER, trans_id, fd, port);
+}
+
+XtransConnInfo
+TRANS(ReopenCLTSServer) (int trans_id, int fd, char *port)
+
+{
+    prmsg (2,"ReopenCLTSServer(%d, %d, %s)\n", trans_id, fd, port);
+    return TRANS(Reopen) (XTRANS_OPEN_CLTS_SERVER, trans_id, fd, port);
+}
+
+
+int
+TRANS(GetReopenInfo) (XtransConnInfo ciptr,
+                     int *trans_id, int *fd, char **port)
+
+{
+    int i;
+
+    for (i = 0; i < NUMTRANS; i++)
+       if (Xtransports[i].transport == ciptr->transptr)
+       {
+           *trans_id = Xtransports[i].transport_id;
+           *fd = ciptr->fd;
+
+           if ((*port = strdup (ciptr->port)) == NULL)
+               return 0;
+           else
+               return 1;
+       }
+
+    return 0;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+int
+TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+    int        fd = ciptr->fd;
+    int        ret = 0;
+
+    prmsg (2,"SetOption(%d,%d,%d)\n", fd, option, arg);
+
+    /*
+     * For now, all transport type use the same stuff for setting options.
+     * As long as this is true, we can put the common code here. Once a more
+     * complicated transport such as shared memory or an OSI implementation
+     * that uses the session and application libraries is implemented, this
+     * code may have to move to a transport dependent function.
+     *
+     * ret = ciptr->transptr->SetOption (ciptr, option, arg);
+     */
+
+    switch (option)
+    {
+    case TRANS_NONBLOCKING:
+       switch (arg)
+       {
+       case 0:
+           /* Set to blocking mode */
+           break;
+       case 1: /* Set to non-blocking mode */
+
+#if defined(O_NONBLOCK) && !defined(SCO325)
+           ret = fcntl (fd, F_GETFL, 0);
+           if (ret != -1)
+               ret = fcntl (fd, F_SETFL, ret | O_NONBLOCK);
+#else
+#ifdef FIOSNBIO
+       {
+           int arg;
+           arg = 1;
+           ret = ioctl (fd, FIOSNBIO, &arg);
+       }
+#else
+#if defined(WIN32)
+       {
+#ifdef WIN32
+           u_long arg;
+#else
+           int arg;
+#endif
+           arg = 1;
+/* IBM TCP/IP understands this option too well: it causes TRANS(Read) to fail
+ * eventually with EWOULDBLOCK */
+           ret = ioctl (fd, FIONBIO, &arg);
+       }
+#else
+           ret = fcntl (fd, F_GETFL, 0);
+#ifdef FNDELAY
+           ret = fcntl (fd, F_SETFL, ret | FNDELAY);
+#else
+           ret = fcntl (fd, F_SETFL, ret | O_NDELAY);
+#endif
+#endif /* AIXV3  || uniosu */
+#endif /* FIOSNBIO */
+#endif /* O_NONBLOCK */
+           break;
+       default:
+           /* Unknown option */
+           break;
+       }
+       break;
+    case TRANS_CLOSEONEXEC:
+#ifdef F_SETFD
+#ifdef FD_CLOEXEC
+       ret = fcntl (fd, F_SETFD, FD_CLOEXEC);
+#else
+       ret = fcntl (fd, F_SETFD, 1);
+#endif /* FD_CLOEXEC */
+#endif /* F_SETFD */
+       break;
+    }
+
+    return ret;
+}
+
+#ifdef TRANS_SERVER
+
+int
+TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+    return ciptr->transptr->CreateListener (ciptr, port, flags);
+}
+
+int
+TRANS(NoListen) (const char * protocol)
+
+{
+   Xtransport *trans;
+   int i = 0, ret = 0;
+
+   if ((trans = TRANS(SelectTransport)(protocol)) == NULL)
+   {
+       prmsg (1,"TransNoListen: unable to find transport: %s\n",
+              protocol);
+
+       return -1;
+   }
+   if (trans->flags & TRANS_ALIAS) {
+       if (trans->nolisten)
+          while (trans->nolisten[i]) {
+              ret |= TRANS(NoListen)(trans->nolisten[i]);
+              i++;
+       }
+   }
+
+   trans->flags |= TRANS_NOLISTEN;
+   return ret;
+}
+
+int
+TRANS(ResetListener) (XtransConnInfo ciptr)
+
+{
+    if (ciptr->transptr->ResetListener)
+       return ciptr->transptr->ResetListener (ciptr);
+    else
+       return TRANS_RESET_NOOP;
+}
+
+
+XtransConnInfo
+TRANS(Accept) (XtransConnInfo ciptr, int *status)
+
+{
+    XtransConnInfo     newciptr;
+
+    prmsg (2,"Accept(%d)\n", ciptr->fd);
+
+    newciptr = ciptr->transptr->Accept (ciptr, status);
+
+    if (newciptr)
+       newciptr->transptr = ciptr->transptr;
+
+    return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+int
+TRANS(Connect) (XtransConnInfo ciptr, char *address)
+
+{
+    char       *protocol;
+    char       *host;
+    char       *port;
+    int                ret;
+
+    prmsg (2,"Connect(%d,%s)\n", ciptr->fd, address);
+
+    if (TRANS(ParseAddress) (address, &protocol, &host, &port) == 0)
+    {
+       prmsg (1,"Connect: Unable to Parse address %s\n",
+              address);
+       return -1;
+    }
+
+#ifdef HAVE_LAUNCHD
+    if (!host) host=strdup("");
+#endif
+
+    if (!port || !*port)
+    {
+       prmsg (1,"Connect: Missing port specification in %s\n",
+             address);
+       if (protocol) free (protocol);
+       if (host) free (host);
+       return -1;
+    }
+
+    ret = ciptr->transptr->Connect (ciptr, host, port);
+
+    if (protocol) free (protocol);
+    if (host) free (host);
+    if (port) free (port);
+
+    return ret;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+int
+TRANS(BytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+    return ciptr->transptr->BytesReadable (ciptr, pend);
+}
+
+int
+TRANS(Read) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+    return ciptr->transptr->Read (ciptr, buf, size);
+}
+
+int
+TRANS(Write) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+    return ciptr->transptr->Write (ciptr, buf, size);
+}
+
+int
+TRANS(Readv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    return ciptr->transptr->Readv (ciptr, buf, size);
+}
+
+int
+TRANS(Writev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    return ciptr->transptr->Writev (ciptr, buf, size);
+}
+
+int
+TRANS(Disconnect) (XtransConnInfo ciptr)
+
+{
+    return ciptr->transptr->Disconnect (ciptr);
+}
+
+int
+TRANS(Close) (XtransConnInfo ciptr)
+
+{
+    int ret;
+
+    prmsg (2,"Close(%d)\n", ciptr->fd);
+
+    ret = ciptr->transptr->Close (ciptr);
+
+    TRANS(FreeConnInfo) (ciptr);
+
+    return ret;
+}
+
+int
+TRANS(CloseForCloning) (XtransConnInfo ciptr)
+
+{
+    int ret;
+
+    prmsg (2,"CloseForCloning(%d)\n", ciptr->fd);
+
+    ret = ciptr->transptr->CloseForCloning (ciptr);
+
+    TRANS(FreeConnInfo) (ciptr);
+
+    return ret;
+}
+
+int
+TRANS(IsLocal) (XtransConnInfo ciptr)
+
+{
+    return (ciptr->family == AF_UNIX);
+}
+
+
+int
+TRANS(GetMyAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
+                 Xtransaddr **addrp)
+
+{
+    prmsg (2,"GetMyAddr(%d)\n", ciptr->fd);
+
+    *familyp = ciptr->family;
+    *addrlenp = ciptr->addrlen;
+
+    if ((*addrp = malloc (ciptr->addrlen)) == NULL)
+    {
+       prmsg (1,"GetMyAddr: malloc failed\n");
+       return -1;
+    }
+    memcpy(*addrp, ciptr->addr, ciptr->addrlen);
+
+    return 0;
+}
+
+int
+TRANS(GetPeerAddr) (XtransConnInfo ciptr, int *familyp, int *addrlenp,
+                   Xtransaddr **addrp)
+
+{
+    prmsg (2,"GetPeerAddr(%d)\n", ciptr->fd);
+
+    *familyp = ciptr->family;
+    *addrlenp = ciptr->peeraddrlen;
+
+    if ((*addrp = malloc (ciptr->peeraddrlen)) == NULL)
+    {
+       prmsg (1,"GetPeerAddr: malloc failed\n");
+       return -1;
+    }
+    memcpy(*addrp, ciptr->peeraddr, ciptr->peeraddrlen);
+
+    return 0;
+}
+
+
+int
+TRANS(GetConnectionNumber) (XtransConnInfo ciptr)
+
+{
+    return ciptr->fd;
+}
+
+\f
+/*
+ * These functions are really utility functions, but they require knowledge
+ * of the internal data structures, so they have to be part of the Transport
+ * Independant API.
+ */
+
+#ifdef TRANS_SERVER
+
+static int
+complete_network_count (void)
+
+{
+    int count = 0;
+    int found_local = 0;
+    int i;
+
+    /*
+     * For a complete network, we only need one LOCALCONN transport to work
+     */
+
+    for (i = 0; i < NUMTRANS; i++)
+    {
+       if (Xtransports[i].transport->flags & TRANS_ALIAS
+        || Xtransports[i].transport->flags & TRANS_NOLISTEN)
+           continue;
+
+       if (Xtransports[i].transport->flags & TRANS_LOCAL)
+           found_local = 1;
+       else
+           count++;
+    }
+
+    return (count + found_local);
+}
+
+
+#ifdef XQUARTZ_EXPORTS_LAUNCHD_FD
+extern int xquartz_launchd_fd;
+#endif
+
+int
+TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
+                                  XtransConnInfo **ciptrs_ret)
+
+{
+    char               buffer[256]; /* ??? What size ?? */
+    XtransConnInfo     ciptr, temp_ciptrs[NUMTRANS];
+    int                        status, i, j;
+
+#if defined(IPv6) && defined(AF_INET6)
+    int                ipv6_succ = 0;
+#endif
+    prmsg (2,"MakeAllCOTSServerListeners(%s,%p)\n",
+          port ? port : "NULL", ciptrs_ret);
+
+    *count_ret = 0;
+
+#ifdef XQUARTZ_EXPORTS_LAUNCHD_FD
+    fprintf(stderr, "Launchd socket fd: %d\n", xquartz_launchd_fd);
+    if(xquartz_launchd_fd != -1) {
+        if((ciptr = TRANS(ReopenCOTSServer(TRANS_SOCKET_LOCAL_INDEX,
+                                           xquartz_launchd_fd, getenv("DISPLAY"))))==NULL)
+            fprintf(stderr,"Got NULL while trying to Reopen launchd port\n");
+        else
+            temp_ciptrs[(*count_ret)++] = ciptr;
+    }
+#endif
+
+    for (i = 0; i < NUMTRANS; i++)
+    {
+       Xtransport *trans = Xtransports[i].transport;
+       unsigned int flags = 0;
+
+       if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)
+           continue;
+
+       snprintf(buffer, sizeof(buffer), "%s/:%s",
+                trans->TransName, port ? port : "");
+
+       prmsg (5,"MakeAllCOTSServerListeners: opening %s\n",
+              buffer);
+
+       if ((ciptr = TRANS(OpenCOTSServer(buffer))) == NULL)
+       {
+           if (trans->flags & TRANS_DISABLED)
+               continue;
+
+           prmsg (1,
+         "MakeAllCOTSServerListeners: failed to open listener for %s\n",
+                 trans->TransName);
+           continue;
+       }
+#if defined(IPv6) && defined(AF_INET6)
+               if ((Xtransports[i].transport_id == TRANS_SOCKET_INET_INDEX
+                    && ipv6_succ))
+                   flags |= ADDR_IN_USE_ALLOWED;
+#endif
+
+       if ((status = TRANS(CreateListener (ciptr, port, flags))) < 0)
+       {
+           if (status == TRANS_ADDR_IN_USE)
+           {
+               /*
+                * We failed to bind to the specified address because the
+                * address is in use.  It must be that a server is already
+                * running at this address, and this function should fail.
+                */
+
+               prmsg (1,
+               "MakeAllCOTSServerListeners: server already running\n");
+
+               for (j = 0; j < *count_ret; j++)
+                   TRANS(Close) (temp_ciptrs[j]);
+
+               *count_ret = 0;
+               *ciptrs_ret = NULL;
+               *partial = 0;
+               return -1;
+           }
+           else
+           {
+               prmsg (1,
+       "MakeAllCOTSServerListeners: failed to create listener for %s\n",
+                 trans->TransName);
+
+               continue;
+           }
+       }
+
+#if defined(IPv6) && defined(AF_INET6)
+       if (Xtransports[i].transport_id == TRANS_SOCKET_INET6_INDEX)
+           ipv6_succ = 1;
+#endif
+
+       prmsg (5,
+             "MakeAllCOTSServerListeners: opened listener for %s, %d\n",
+             trans->TransName, ciptr->fd);
+
+       temp_ciptrs[*count_ret] = ciptr;
+       (*count_ret)++;
+    }
+
+    *partial = (*count_ret < complete_network_count());
+
+    prmsg (5,
+     "MakeAllCOTSServerListeners: partial=%d, actual=%d, complete=%d \n",
+       *partial, *count_ret, complete_network_count());
+
+    if (*count_ret > 0)
+    {
+       if ((*ciptrs_ret = malloc (
+           *count_ret * sizeof (XtransConnInfo))) == NULL)
+       {
+           return -1;
+       }
+
+       for (i = 0; i < *count_ret; i++)
+       {
+           (*ciptrs_ret)[i] = temp_ciptrs[i];
+       }
+    }
+    else
+       *ciptrs_ret = NULL;
+
+    return 0;
+}
+
+int
+TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
+                                  XtransConnInfo **ciptrs_ret)
+
+{
+    char               buffer[256]; /* ??? What size ?? */
+    XtransConnInfo     ciptr, temp_ciptrs[NUMTRANS];
+    int                        status, i, j;
+
+    prmsg (2,"MakeAllCLTSServerListeners(%s,%p)\n",
+       port ? port : "NULL", ciptrs_ret);
+
+    *count_ret = 0;
+
+    for (i = 0; i < NUMTRANS; i++)
+    {
+       Xtransport *trans = Xtransports[i].transport;
+
+       if (trans->flags&TRANS_ALIAS || trans->flags&TRANS_NOLISTEN)
+           continue;
+
+       snprintf(buffer, sizeof(buffer), "%s/:%s",
+                trans->TransName, port ? port : "");
+
+       prmsg (5,"MakeAllCLTSServerListeners: opening %s\n",
+           buffer);
+
+       if ((ciptr = TRANS(OpenCLTSServer (buffer))) == NULL)
+       {
+           prmsg (1,
+       "MakeAllCLTSServerListeners: failed to open listener for %s\n",
+                 trans->TransName);
+           continue;
+       }
+
+       if ((status = TRANS(CreateListener (ciptr, port, 0))) < 0)
+       {
+           if (status == TRANS_ADDR_IN_USE)
+           {
+               /*
+                * We failed to bind to the specified address because the
+                * address is in use.  It must be that a server is already
+                * running at this address, and this function should fail.
+                */
+
+               prmsg (1,
+               "MakeAllCLTSServerListeners: server already running\n");
+
+               for (j = 0; j < *count_ret; j++)
+                   TRANS(Close) (temp_ciptrs[j]);
+
+               *count_ret = 0;
+               *ciptrs_ret = NULL;
+               *partial = 0;
+               return -1;
+           }
+           else
+           {
+               prmsg (1,
+       "MakeAllCLTSServerListeners: failed to create listener for %s\n",
+                 trans->TransName);
+
+               continue;
+           }
+       }
+
+       prmsg (5,
+       "MakeAllCLTSServerListeners: opened listener for %s, %d\n",
+             trans->TransName, ciptr->fd);
+       temp_ciptrs[*count_ret] = ciptr;
+       (*count_ret)++;
+    }
+
+    *partial = (*count_ret < complete_network_count());
+
+    prmsg (5,
+     "MakeAllCLTSServerListeners: partial=%d, actual=%d, complete=%d \n",
+       *partial, *count_ret, complete_network_count());
+
+    if (*count_ret > 0)
+    {
+       if ((*ciptrs_ret = malloc (
+           *count_ret * sizeof (XtransConnInfo))) == NULL)
+       {
+           return -1;
+       }
+
+       for (i = 0; i < *count_ret; i++)
+       {
+           (*ciptrs_ret)[i] = temp_ciptrs[i];
+       }
+    }
+    else
+       *ciptrs_ret = NULL;
+
+    return 0;
+}
+
+#endif /* TRANS_SERVER */
+
+
+\f
+/*
+ * These routines are not part of the X Transport Interface, but they
+ * may be used by it.
+ */
+
+
+#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
+
+/*
+ * emulate readv
+ */
+
+static int TRANS(ReadV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+    int i, len, total;
+    char *base;
+
+    ESET(0);
+    for (i = 0, total = 0;  i < iovcnt;  i++, iov++) {
+       len = iov->iov_len;
+       base = iov->iov_base;
+       while (len > 0) {
+           register int nbytes;
+           nbytes = TRANS(Read) (ciptr, base, len);
+           if (nbytes < 0 && total == 0)  return -1;
+           if (nbytes <= 0)  return total;
+           ESET(0);
+           len   -= nbytes;
+           total += nbytes;
+           base  += nbytes;
+       }
+    }
+    return total;
+}
+
+#endif /* SYSV && __i386__ || WIN32 || __sxg__ */
+
+#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
+
+/*
+ * emulate writev
+ */
+
+static int TRANS(WriteV) (XtransConnInfo ciptr, struct iovec *iov, int iovcnt)
+
+{
+    int i, len, total;
+    char *base;
+
+    ESET(0);
+    for (i = 0, total = 0;  i < iovcnt;  i++, iov++) {
+       len = iov->iov_len;
+       base = iov->iov_base;
+       while (len > 0) {
+           register int nbytes;
+           nbytes = TRANS(Write) (ciptr, base, len);
+           if (nbytes < 0 && total == 0)  return -1;
+           if (nbytes <= 0)  return total;
+           ESET(0);
+           len   -= nbytes;
+           total += nbytes;
+           base  += nbytes;
+       }
+    }
+    return total;
+}
+
+#endif /* SYSV && __i386__ || WIN32 || __sxg__ */
+
+
+#if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)
+#ifndef NEED_UTSNAME
+#define NEED_UTSNAME
+#endif
+#include <sys/utsname.h>
+#endif
+
+/*
+ * TRANS(GetHostname) - similar to gethostname but allows special processing.
+ */
+
+int TRANS(GetHostname) (char *buf, int maxlen)
+
+{
+    int len;
+
+#ifdef NEED_UTSNAME
+    struct utsname name;
+
+    uname (&name);
+    len = strlen (name.nodename);
+    if (len >= maxlen) len = maxlen - 1;
+    strncpy (buf, name.nodename, len);
+    buf[len] = '\0';
+#else
+    buf[0] = '\0';
+    (void) gethostname (buf, maxlen);
+    buf [maxlen - 1] = '\0';
+    len = strlen(buf);
+#endif /* NEED_UTSNAME */
+    return len;
+}
diff --git a/Xtrans.h b/Xtrans.h
new file mode 100644 (file)
index 0000000..2945b2a
--- /dev/null
+++ b/Xtrans.h
@@ -0,0 +1,450 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _XTRANS_H_
+#define _XTRANS_H_
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xos.h>
+
+#ifndef WIN32
+#include <sys/socket.h>
+#endif
+
+#ifdef __clang__
+/* Not all clients make use of all provided statics */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
+
+/*
+ * Set the functions names according to where this code is being compiled.
+ */
+
+#ifdef X11_t
+#define TRANS(func) _X11Trans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_X11Trans";
+#endif
+#endif /* X11_t */
+
+#ifdef XSERV_t
+#define TRANS(func) _XSERVTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_XSERVTrans";
+#endif
+#define X11_t
+#endif /* XSERV_t */
+
+#ifdef XIM_t
+#define TRANS(func) _XimXTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_XimTrans";
+#endif
+#endif /* XIM_t */
+
+#ifdef FS_t
+#define TRANS(func) _FSTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_FSTrans";
+#endif
+#endif /* FS_t */
+
+#ifdef FONT_t
+#define TRANS(func) _FontTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_FontTrans";
+#endif
+#endif /* FONT_t */
+
+#ifdef ICE_t
+#define TRANS(func) _IceTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_IceTrans";
+#endif
+#endif /* ICE_t */
+
+#ifdef TEST_t
+#define TRANS(func) _TESTTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_TESTTrans";
+#endif
+#endif /* TEST_t */
+
+#ifdef LBXPROXY_t
+#define TRANS(func) _LBXPROXYTrans##func
+#define X11_t          /* The server defines this - so should the LBX proxy */
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_LBXPROXYTrans";
+#endif
+#endif /* LBXPROXY_t */
+
+#if !defined(TRANS)
+#define TRANS(func) _XTrans##func
+#ifdef XTRANSDEBUG
+static const char *__xtransname = "_XTrans";
+#endif
+#endif /* !TRANS */
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+/*
+ * Create a single address structure that can be used wherever
+ * an address structure is needed. struct sockaddr is not big enough
+ * to hold a sockadd_un, so we create this definition to have a single
+ * structure that is big enough for all the structures we might need.
+ *
+ * This structure needs to be independent of the socket/TLI interface used.
+ */
+
+#if defined(IPv6) && defined(AF_INET6)
+typedef struct sockaddr_storage Xtransaddr;
+#else
+#define XTRANS_MAX_ADDR_LEN    128     /* large enough to hold sun_path */
+
+typedef        struct {
+    unsigned char      addr[XTRANS_MAX_ADDR_LEN];
+} Xtransaddr;
+#endif
+
+#ifdef LONG64
+typedef int BytesReadable_t;
+#else
+typedef long BytesReadable_t;
+#endif
+
+
+#if defined(WIN32) || defined(USG)
+
+/*
+ *      TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
+ *      in Berkeley systems in <sys/uio.h>.  See the readv(2) and writev(2)
+ *      manual pages for details.
+ */
+
+struct iovec {
+    caddr_t iov_base;
+    int iov_len;
+};
+
+#else
+#include <sys/uio.h>
+#endif
+
+typedef struct _XtransConnInfo *XtransConnInfo;
+
+
+/*
+ * Transport Option definitions
+ */
+
+#define TRANS_NONBLOCKING      1
+#define        TRANS_CLOSEONEXEC       2
+
+
+/*
+ * Return values of Connect (0 is success)
+ */
+
+#define TRANS_CONNECT_FAILED   -1
+#define TRANS_TRY_CONNECT_AGAIN -2
+#define TRANS_IN_PROGRESS      -3
+
+
+/*
+ * Return values of CreateListener (0 is success)
+ */
+
+#define TRANS_CREATE_LISTENER_FAILED   -1
+#define TRANS_ADDR_IN_USE              -2
+
+
+/*
+ * Return values of Accept (0 is success)
+ */
+
+#define TRANS_ACCEPT_BAD_MALLOC                        -1
+#define TRANS_ACCEPT_FAILED                    -2
+#define TRANS_ACCEPT_MISC_ERROR                        -3
+
+
+/*
+ * ResetListener return values
+ */
+
+#define TRANS_RESET_NOOP       1
+#define TRANS_RESET_NEW_FD     2
+#define TRANS_RESET_FAILURE    3
+
+
+/*
+ * Function prototypes for the exposed interface
+ */
+
+void TRANS(FreeConnInfo) (
+    XtransConnInfo     /* ciptr */
+);
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo TRANS(OpenCOTSClient)(
+    char *             /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo TRANS(OpenCOTSServer)(
+    char *             /* address */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+XtransConnInfo TRANS(OpenCLTSClient)(
+    char *             /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+XtransConnInfo TRANS(OpenCLTSServer)(
+    char *             /* address */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_REOPEN
+
+XtransConnInfo TRANS(ReopenCOTSServer)(
+    int,               /* trans_id */
+    int,               /* fd */
+    char *             /* port */
+);
+
+XtransConnInfo TRANS(ReopenCLTSServer)(
+    int,               /* trans_id */
+    int,               /* fd */
+    char *             /* port */
+);
+
+int TRANS(GetReopenInfo)(
+    XtransConnInfo,    /* ciptr */
+    int *,             /* trans_id */
+    int *,             /* fd */
+    char **            /* port */
+);
+
+#endif /* TRANS_REOPEN */
+
+
+int TRANS(SetOption)(
+    XtransConnInfo,    /* ciptr */
+    int,               /* option */
+    int                        /* arg */
+);
+
+#ifdef TRANS_SERVER
+
+int TRANS(CreateListener)(
+    XtransConnInfo,    /* ciptr */
+    char *,            /* port */
+    unsigned int       /* flags */
+);
+
+int TRANS(NoListen) (
+    const char*         /* protocol*/
+);
+
+int TRANS(ResetListener)(
+    XtransConnInfo     /* ciptr */
+);
+
+XtransConnInfo TRANS(Accept)(
+    XtransConnInfo,    /* ciptr */
+    int *              /* status */
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+int TRANS(Connect)(
+    XtransConnInfo,    /* ciptr */
+    char *             /* address */
+);
+
+#endif /* TRANS_CLIENT */
+
+int TRANS(BytesReadable)(
+    XtransConnInfo,    /* ciptr */
+    BytesReadable_t *  /* pend */
+);
+
+int TRANS(Read)(
+    XtransConnInfo,    /* ciptr */
+    char *,            /* buf */
+    int                        /* size */
+);
+
+int TRANS(Write)(
+    XtransConnInfo,    /* ciptr */
+    char *,            /* buf */
+    int                        /* size */
+);
+
+int TRANS(Readv)(
+    XtransConnInfo,    /* ciptr */
+    struct iovec *,    /* buf */
+    int                        /* size */
+);
+
+int TRANS(Writev)(
+    XtransConnInfo,    /* ciptr */
+    struct iovec *,    /* buf */
+    int                        /* size */
+);
+
+int TRANS(Disconnect)(
+    XtransConnInfo     /* ciptr */
+);
+
+int TRANS(Close)(
+    XtransConnInfo     /* ciptr */
+);
+
+int TRANS(CloseForCloning)(
+    XtransConnInfo     /* ciptr */
+);
+
+int TRANS(IsLocal)(
+    XtransConnInfo     /* ciptr */
+);
+
+int TRANS(GetMyAddr)(
+    XtransConnInfo,    /* ciptr */
+    int *,             /* familyp */
+    int *,             /* addrlenp */
+    Xtransaddr **      /* addrp */
+);
+
+int TRANS(GetPeerAddr)(
+    XtransConnInfo,    /* ciptr */
+    int *,             /* familyp */
+    int *,             /* addrlenp */
+    Xtransaddr **      /* addrp */
+);
+
+int TRANS(GetConnectionNumber)(
+    XtransConnInfo     /* ciptr */
+);
+
+#ifdef TRANS_SERVER
+
+int TRANS(MakeAllCOTSServerListeners)(
+    char *,            /* port */
+    int *,             /* partial */
+    int *,             /* count_ret */
+    XtransConnInfo **  /* ciptrs_ret */
+);
+
+int TRANS(MakeAllCLTSServerListeners)(
+    char *,            /* port */
+    int *,             /* partial */
+    int *,             /* count_ret */
+    XtransConnInfo **  /* ciptrs_ret */
+);
+
+#endif /* TRANS_SERVER */
+
+
+/*
+ * Function Prototypes for Utility Functions.
+ */
+
+#ifdef X11_t
+
+int TRANS(ConvertAddress)(
+    int *,             /* familyp */
+    int *,             /* addrlenp */
+    Xtransaddr **      /* addrp */
+);
+
+#endif /* X11_t */
+
+#ifdef ICE_t
+
+char *
+TRANS(GetMyNetworkId)(
+    XtransConnInfo     /* ciptr */
+);
+
+char *
+TRANS(GetPeerNetworkId)(
+    XtransConnInfo     /* ciptr */
+);
+
+#endif /* ICE_t */
+
+int
+TRANS(GetHostname) (
+    char *     /* buf */,
+    int        /* maxlen */
+);
+
+#if defined(WIN32) && defined(TCPCONN)
+int TRANS(WSAStartup)();
+#endif
+
+#endif /* _XTRANS_H_ */
diff --git a/Xtransint.h b/Xtransint.h
new file mode 100644 (file)
index 0000000..3bce8dc
--- /dev/null
@@ -0,0 +1,439 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _XTRANSINT_H_
+#define _XTRANSINT_H_
+
+/*
+ * XTRANSDEBUG will enable the PRMSG() macros used in the X Transport
+ * Interface code. Each use of the PRMSG macro has a level associated with
+ * it. XTRANSDEBUG is defined to be a level. If the invocation level is =<
+ * the value of XTRANSDEBUG, then the message will be printed out to stderr.
+ * Recommended levels are:
+ *
+ *     XTRANSDEBUG=1   Error messages
+ *     XTRANSDEBUG=2 API Function Tracing
+ *     XTRANSDEBUG=3 All Function Tracing
+ *     XTRANSDEBUG=4 printing of intermediate values
+ *     XTRANSDEBUG=5 really detailed stuff
+#define XTRANSDEBUG 2
+ *
+ * Defining XTRANSDEBUGTIMESTAMP will cause printing timestamps with each
+ * message.
+ */
+
+#if !defined(XTRANSDEBUG) && defined(XTRANS_TRANSPORT_C)
+#  define XTRANSDEBUG 1
+#endif
+
+#ifdef WIN32
+# define _WILLWINSOCK_
+#endif
+
+#include "Xtrans.h"
+
+#ifndef _X_UNUSED  /* Defined in Xfuncproto.h in xproto >= 7.0.22 */
+# define _X_UNUSED  /* */
+#endif
+
+#ifdef XTRANSDEBUG
+# include <stdio.h>
+#endif /* XTRANSDEBUG */
+
+#include <errno.h>
+
+#ifndef WIN32
+#  include <sys/socket.h>
+# include <netinet/in.h>
+# include <arpa/inet.h>
+
+/*
+ * Moved the setting of NEED_UTSNAME to this header file from Xtrans.c,
+ * to avoid a race condition. JKJ (6/5/97)
+ */
+
+# if defined(_POSIX_SOURCE) || defined(USG) || defined(SVR4) || defined(__SVR4) || defined(__SCO__)
+#  ifndef NEED_UTSNAME
+#   define NEED_UTSNAME
+#  endif
+#  include <sys/utsname.h>
+# endif
+
+#  define ESET(val) errno = val
+# define EGET() errno
+
+#else /* WIN32 */
+
+# include <limits.h>   /* for USHRT_MAX */
+
+# define ESET(val) WSASetLastError(val)
+# define EGET() WSAGetLastError()
+
+#endif /* WIN32 */
+
+#include <stddef.h>
+
+#ifdef X11_t
+#define X_TCP_PORT     6000
+#endif
+
+struct _XtransConnInfo {
+    struct _Xtransport     *transptr;
+    int                index;
+    char       *priv;
+    int                flags;
+    int                fd;
+    char       *port;
+    int                family;
+    char       *addr;
+    int                addrlen;
+    char       *peeraddr;
+    int                peeraddrlen;
+};
+
+#define XTRANS_OPEN_COTS_CLIENT       1
+#define XTRANS_OPEN_COTS_SERVER       2
+#define XTRANS_OPEN_CLTS_CLIENT       3
+#define XTRANS_OPEN_CLTS_SERVER       4
+
+
+typedef struct _Xtransport {
+    const char *TransName;
+    int                flags;
+
+#ifdef TRANS_CLIENT
+
+    XtransConnInfo (*OpenCOTSClient)(
+       struct _Xtransport *,   /* transport */
+       char *,                 /* protocol */
+       char *,                 /* host */
+       char *                  /* port */
+    );
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+    const char **      nolisten;
+    XtransConnInfo (*OpenCOTSServer)(
+       struct _Xtransport *,   /* transport */
+       char *,                 /* protocol */
+       char *,                 /* host */
+       char *                  /* port */
+    );
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+    XtransConnInfo (*OpenCLTSClient)(
+       struct _Xtransport *,   /* transport */
+       char *,                 /* protocol */
+       char *,                 /* host */
+       char *                  /* port */
+    );
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+    XtransConnInfo (*OpenCLTSServer)(
+       struct _Xtransport *,   /* transport */
+       char *,                 /* protocol */
+       char *,                 /* host */
+       char *                  /* port */
+    );
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+    XtransConnInfo (*ReopenCOTSServer)(
+       struct _Xtransport *,   /* transport */
+        int,                   /* fd */
+        char *                 /* port */
+    );
+
+    XtransConnInfo (*ReopenCLTSServer)(
+       struct _Xtransport *,   /* transport */
+        int,                   /* fd */
+        char *                 /* port */
+    );
+
+#endif /* TRANS_REOPEN */
+
+
+    int        (*SetOption)(
+       XtransConnInfo,         /* connection */
+       int,                    /* option */
+       int                     /* arg */
+    );
+
+#ifdef TRANS_SERVER
+/* Flags */
+# define ADDR_IN_USE_ALLOWED   1
+
+    int        (*CreateListener)(
+       XtransConnInfo,         /* connection */
+       char *,                 /* port */
+       unsigned int            /* flags */
+    );
+
+    int        (*ResetListener)(
+       XtransConnInfo          /* connection */
+    );
+
+    XtransConnInfo (*Accept)(
+       XtransConnInfo,         /* connection */
+        int *                  /* status */
+    );
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+    int        (*Connect)(
+       XtransConnInfo,         /* connection */
+       char *,                 /* host */
+       char *                  /* port */
+    );
+
+#endif /* TRANS_CLIENT */
+
+    int        (*BytesReadable)(
+       XtransConnInfo,         /* connection */
+       BytesReadable_t *       /* pend */
+    );
+
+    int        (*Read)(
+       XtransConnInfo,         /* connection */
+       char *,                 /* buf */
+       int                     /* size */
+    );
+
+    int        (*Write)(
+       XtransConnInfo,         /* connection */
+       char *,                 /* buf */
+       int                     /* size */
+    );
+
+    int        (*Readv)(
+       XtransConnInfo,         /* connection */
+       struct iovec *,         /* buf */
+       int                     /* size */
+    );
+
+    int        (*Writev)(
+       XtransConnInfo,         /* connection */
+       struct iovec *,         /* buf */
+       int                     /* size */
+    );
+
+    int        (*Disconnect)(
+       XtransConnInfo          /* connection */
+    );
+
+    int        (*Close)(
+       XtransConnInfo          /* connection */
+    );
+
+    int        (*CloseForCloning)(
+       XtransConnInfo          /* connection */
+    );
+
+} Xtransport;
+
+
+typedef struct _Xtransport_table {
+    Xtransport *transport;
+    int                transport_id;
+} Xtransport_table;
+
+
+/*
+ * Flags for the flags member of Xtransport.
+ */
+
+#define TRANS_ALIAS    (1<<0)  /* record is an alias, don't create server */
+#define TRANS_LOCAL    (1<<1)  /* local transport */
+#define TRANS_DISABLED (1<<2)  /* Don't open this one */
+#define TRANS_NOLISTEN  (1<<3)  /* Don't listen on this one */
+#define TRANS_NOUNLINK (1<<4)  /* Don't unlink transport endpoints */
+#define TRANS_ABSTRACT (1<<5)  /* Use abstract sockets if available */
+#define TRANS_NOXAUTH  (1<<6)  /* Don't verify authentication (because it's secure some other way at the OS layer) */
+
+/* Flags to preserve when setting others */
+#define TRANS_KEEPFLAGS        (TRANS_NOUNLINK|TRANS_ABSTRACT)
+
+#ifdef XTRANS_TRANSPORT_C /* only provide static function prototypes when
+                            building the transport.c file that has them in */
+
+#ifdef __clang__
+/* Not all clients make use of all provided statics */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
+
+/*
+ * readv() and writev() don't exist or don't work correctly on some
+ * systems, so they may be emulated.
+ */
+
+#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
+
+#define READV(ciptr, iov, iovcnt)      TRANS(ReadV)(ciptr, iov, iovcnt)
+
+static int TRANS(ReadV)(
+    XtransConnInfo,    /* ciptr */
+    struct iovec *,    /* iov */
+    int                        /* iovcnt */
+);
+
+#else
+
+#define READV(ciptr, iov, iovcnt)      readv(ciptr->fd, iov, iovcnt)
+
+#endif /* CRAY || (SYSV && __i386__) || WIN32 || __sxg__ || */
+
+
+#if defined(SYSV) && defined(__i386__) && !defined(__SCO__) && !defined(sun) || defined(WIN32)
+
+#define WRITEV(ciptr, iov, iovcnt)     TRANS(WriteV)(ciptr, iov, iovcnt)
+
+static int TRANS(WriteV)(
+    XtransConnInfo,    /* ciptr */
+    struct iovec *,    /* iov */
+    int                /* iovcnt */
+);
+
+#else
+
+#define WRITEV(ciptr, iov, iovcnt)     writev(ciptr->fd, iov, iovcnt)
+
+#endif /* CRAY || WIN32 || __sxg__ */
+
+
+static int is_numeric (
+    const char *       /* str */
+);
+
+#ifdef TRANS_SERVER
+static int trans_mkdir (
+    const char *,      /* path */
+    int                        /* mode */
+);
+#endif
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+/*
+ * Some XTRANSDEBUG stuff
+ */
+
+#ifdef XTRANSDEBUG
+#include <stdarg.h>
+
+/*
+ * The X server provides ErrorF() & VErrorF(), for other software that uses
+ * xtrans, we provide our own simple versions.
+ */
+# if defined(XSERV_t) && defined(TRANS_SERVER)
+#  include "os.h"
+# else
+static inline void _X_ATTRIBUTE_PRINTF(1, 0)
+VErrorF(const char *f, va_list args)
+{
+    vfprintf(stderr, f, args);
+    fflush(stderr);
+}
+
+static inline void  _X_ATTRIBUTE_PRINTF(1, 2)
+ErrorF(const char *f, ...)
+{
+    va_list args;
+
+    va_start(args, f);
+    VErrorF(f, args);
+    va_end(args);
+}
+# endif /* xserver */
+#endif /* XTRANSDEBUG */
+
+static inline void  _X_ATTRIBUTE_PRINTF(2, 3)
+prmsg(int lvl, const char *f, ...)
+{
+#ifdef XTRANSDEBUG
+    va_list args;
+
+    va_start(args, f);
+    if (lvl <= XTRANSDEBUG) {
+       int saveerrno = errno;
+
+       ErrorF("%s", __xtransname);
+       VErrorF(f, args);
+
+# ifdef XTRANSDEBUGTIMESTAMP
+       {
+           struct timeval tp;
+           gettimeofday(&tp, 0);
+           ErrorF("timestamp (ms): %d\n",
+                  tp.tv_sec * 1000 + tp.tv_usec / 1000);
+       }
+# endif
+       errno = saveerrno;
+    }
+    va_end(args);
+#endif /* XTRANSDEBUG */
+}
+
+#endif /* XTRANS_TRANSPORT_C */
+
+#endif /* _XTRANSINT_H_ */
diff --git a/Xtranslcl.c b/Xtranslcl.c
new file mode 100644 (file)
index 0000000..5beef7c
--- /dev/null
@@ -0,0 +1,2546 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ *
+ * The connection code/ideas in lib/X and server/os for SVR4/Intel
+ * environments was contributed by the following companies/groups:
+ *
+ *     MetroLink Inc
+ *     NCR
+ *     Pittsburgh Powercomputing Corporation (PPc)/Quarterdeck Office Systems
+ *     SGCS
+ *     Unix System Laboratories (USL) / Novell
+ *     XFree86
+ *
+ * The goal is to have common connection code among all SVR4/Intel vendors.
+ *
+ * ALL THE ABOVE COMPANIES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL THESE COMPANIES * BE LIABLE FOR ANY SPECIAL, INDIRECT
+ * OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
+ * OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <errno.h>
+#include <ctype.h>
+#include <sys/signal.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#if defined(SVR4) || defined(__SVR4)
+#include <sys/filio.h>
+#endif
+#ifdef sun
+# include <stropts.h>
+#else
+# include <sys/stropts.h>
+#endif
+#include <sys/wait.h>
+#include <sys/types.h>
+
+/*
+ * The local transports should be treated the same as a UNIX domain socket
+ * wrt authentication, etc. Because of this, we will use struct sockaddr_un
+ * for the address format. This will simplify the code in other places like
+ * The X Server.
+ */
+
+#include <sys/socket.h>
+#ifndef X_NO_SYS_UN
+#include <sys/un.h>
+#endif
+
+
+/* Types of local connections supported:
+ *  - PTS
+ *  - named pipes
+ *  - SCO
+ */
+#if !defined(sun)
+# define LOCAL_TRANS_PTS
+#endif
+#if defined(SVR4) || defined(__SVR4)
+# define LOCAL_TRANS_NAMED
+#endif
+#if defined(__SCO__) || defined(__UNIXWARE__)
+# define LOCAL_TRANS_SCO
+#endif
+
+static int TRANS(LocalClose)(XtransConnInfo ciptr);
+
+/*
+ * These functions actually implement the local connection mechanisms.
+ */
+
+/* Type Not Supported */
+
+static int
+TRANS(OpenFail)(XtransConnInfo ciptr _X_UNUSED, char *port _X_UNUSED)
+
+{
+    return -1;
+}
+
+#ifdef TRANS_REOPEN
+
+static int
+TRANS(ReopenFail)(XtransConnInfo ciptr _X_UNUSED, int fd _X_UNUSED, char *port _X_UNUSED)
+
+{
+    return 0;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+\f
+static int
+TRANS(FillAddrInfo)(XtransConnInfo ciptr, char *sun_path, char *peer_sun_path)
+
+{
+    struct sockaddr_un *sunaddr;
+    struct sockaddr_un *p_sunaddr;
+
+    ciptr->family = AF_UNIX;
+    ciptr->addrlen = sizeof (struct sockaddr_un);
+
+    if ((sunaddr = malloc (ciptr->addrlen)) == NULL)
+    {
+       prmsg(1,"FillAddrInfo: failed to allocate memory for addr\n");
+       return 0;
+    }
+
+    sunaddr->sun_family = AF_UNIX;
+
+    if (strlen(sun_path) > sizeof(sunaddr->sun_path) - 1) {
+       prmsg(1, "FillAddrInfo: path too long\n");
+       free((char *) sunaddr);
+       return 0;
+    }
+    strcpy (sunaddr->sun_path, sun_path);
+#if defined(BSD44SOCKETS)
+    sunaddr->sun_len = strlen (sunaddr->sun_path);
+#endif
+
+    ciptr->addr = (char *) sunaddr;
+
+    ciptr->peeraddrlen = sizeof (struct sockaddr_un);
+
+    if ((p_sunaddr = malloc (ciptr->peeraddrlen)) == NULL)
+    {
+       prmsg(1,
+          "FillAddrInfo: failed to allocate memory for peer addr\n");
+       free (sunaddr);
+       ciptr->addr = NULL;
+
+       return 0;
+    }
+
+    p_sunaddr->sun_family = AF_UNIX;
+
+    if (strlen(peer_sun_path) > sizeof(p_sunaddr->sun_path) - 1) {
+       prmsg(1, "FillAddrInfo: peer path too long\n");
+       free((char *) p_sunaddr);
+       return 0;
+    }
+    strcpy (p_sunaddr->sun_path, peer_sun_path);
+#if defined(BSD44SOCKETS)
+    p_sunaddr->sun_len = strlen (p_sunaddr->sun_path);
+#endif
+
+    ciptr->peeraddr = (char *) p_sunaddr;
+
+    return 1;
+}
+
+
+\f
+#ifdef LOCAL_TRANS_PTS
+/* PTS */
+
+#if defined(SYSV) && !defined(__SCO__)
+#define SIGNAL_T int
+#else
+#define SIGNAL_T void
+#endif /* SYSV */
+
+typedef SIGNAL_T (*PFV)();
+
+extern PFV signal();
+
+extern char *ptsname(
+    int
+);
+
+static void _dummy(int sig _X_UNUSED)
+
+{
+}
+#endif /* LOCAL_TRANS_PTS */
+
+#ifndef sun
+#define X_STREAMS_DIR  "/dev/X"
+#define DEV_SPX                "/dev/spx"
+#else
+#ifndef X11_t
+#define X_STREAMS_DIR  "/dev/X"
+#else
+#define X_STREAMS_DIR  "/tmp/.X11-pipe"
+#endif
+#endif
+
+#define DEV_PTMX       "/dev/ptmx"
+
+#if defined(X11_t)
+
+#define PTSNODENAME "/dev/X/server."
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.X11-pipe/X"
+#else
+#define NAMEDNODENAME "/dev/X/Nserver."
+
+#define SCORNODENAME   "/dev/X%1sR"
+#define SCOSNODENAME   "/dev/X%1sS"
+#endif /* !sun */
+#endif
+#if defined(XIM_t)
+#ifdef sun
+#define NAMEDNODENAME "/tmp/.XIM-pipe/XIM"
+#else
+#define PTSNODENAME    "/dev/X/XIM."
+#define NAMEDNODENAME  "/dev/X/NXIM."
+#define SCORNODENAME   "/dev/XIM.%sR"
+#define SCOSNODENAME   "/dev/XIM.%sS"
+#endif
+#endif
+#if defined(FS_t) || defined (FONT_t)
+#ifdef sun
+#define NAMEDNODENAME  "/tmp/.font-pipe/fs"
+#else
+/*
+ * USL has already defined something here. We need to check with them
+ * and see if their choice is usable here.
+ */
+#define PTSNODENAME    "/dev/X/fontserver."
+#define NAMEDNODENAME  "/dev/X/Nfontserver."
+#define SCORNODENAME   "/dev/fontserver.%sR"
+#define SCOSNODENAME   "/dev/fontserver.%sS"
+#endif
+#endif
+#if defined(ICE_t)
+#ifdef sun
+#define NAMEDNODENAME  "/tmp/.ICE-pipe/"
+#else
+#define PTSNODENAME    "/dev/X/ICE."
+#define NAMEDNODENAME  "/dev/X/NICE."
+#define SCORNODENAME   "/dev/ICE.%sR"
+#define SCOSNODENAME   "/dev/ICE.%sS"
+#endif
+#endif
+#if defined(TEST_t)
+#ifdef sun
+#define NAMEDNODENAME  "/tmp/.Test-unix/test"
+#endif
+#define PTSNODENAME    "/dev/X/transtest."
+#define NAMEDNODENAME  "/dev/X/Ntranstest."
+#define SCORNODENAME   "/dev/transtest.%sR"
+#define SCOSNODENAME   "/dev/transtest.%sS"
+#endif
+
+
+\f
+#ifdef LOCAL_TRANS_PTS
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(PTSOpenClient)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef PTSNODENAME
+    int                        fd,server,exitval,alarm_time,ret;
+    char               server_path[64];
+    char               *slave, namelen;
+    char               buf[20]; /* MAX_PATH_LEN?? */
+    PFV                        savef;
+    pid_t              saved_pid;
+#endif
+
+    prmsg(2,"PTSOpenClient(%s)\n", port);
+
+#if !defined(PTSNODENAME)
+    prmsg(1,"PTSOpenClient: Protocol is not supported by a pts connection\n");
+    return -1;
+#else
+    if (port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+           snprintf(server_path, sizeof(server_path), "%s", port);
+       } else {
+           snprintf(server_path, sizeof(server_path), "%s%s",
+                    PTSNODENAME, port);
+       }
+    } else {
+       snprintf(server_path, sizeof(server_path), "%s%d",
+                PTSNODENAME, getpid());
+    }
+
+
+    /*
+     * Open the node the on which the server is listening.
+     */
+
+    if ((server = open (server_path, O_RDWR)) < 0) {
+       prmsg(1,"PTSOpenClient: failed to open %s\n", server_path);
+       return -1;
+    }
+
+
+    /*
+     * Open the streams based pipe that will be this connection.
+     */
+
+    if ((fd = open(DEV_PTMX, O_RDWR)) < 0) {
+       prmsg(1,"PTSOpenClient: failed to open %s\n", DEV_PTMX);
+       close(server);
+       return(-1);
+    }
+
+    (void) grantpt(fd);
+    (void) unlockpt(fd);
+
+    slave = ptsname(fd); /* get name */
+
+    if( slave == NULL ) {
+       prmsg(1,"PTSOpenClient: failed to get ptsname()\n");
+       close(fd);
+       close(server);
+       return -1;
+    }
+
+    /*
+     * This is neccesary for the case where a program is setuid to non-root.
+     * grantpt() calls /usr/lib/pt_chmod which is set-uid root. This program will
+     * set the owner of the pt device incorrectly if the uid is not restored
+     * before it is called. The problem is that once it gets restored, it
+     * cannot be changed back to its original condition, hence the fork().
+     */
+
+    if(!(saved_pid=fork())) {
+       uid_t       saved_euid;
+
+       saved_euid = geteuid();
+       /** sets the euid to the actual/real uid **/
+       if (setuid( getuid() ) == -1) {
+               exit(1);
+       }
+       if( chown( slave, saved_euid, -1 ) < 0 ) {
+               exit( 1 );
+               }
+
+       exit( 0 );
+    }
+
+    waitpid(saved_pid, &exitval, 0);
+    if (WIFEXITED(exitval) && WEXITSTATUS(exitval) != 0) {
+       close(fd);
+       close(server);
+       prmsg(1, "PTSOpenClient: cannot set the owner of %s\n",
+             slave);
+       return(-1);
+    }
+    if (chmod(slave, 0666) < 0) {
+       close(fd);
+       close(server);
+       prmsg(1,"PTSOpenClient: Cannot chmod %s\n", slave);
+       return(-1);
+    }
+
+    /*
+     * write slave name to server
+     */
+
+    namelen = strlen(slave);
+    buf[0] = namelen;
+    (void) sprintf(&buf[1], slave);
+    (void) write(server, buf, namelen+1);
+    (void) close(server);
+
+    /*
+     * wait for server to respond
+     */
+
+    savef = signal(SIGALRM, _dummy);
+    alarm_time = alarm (30); /* CONNECT_TIMEOUT */
+
+    ret = read(fd, buf, 1);
+
+    (void) alarm(alarm_time);
+    (void) signal(SIGALRM, savef);
+
+    if (ret != 1) {
+       prmsg(1,
+       "PTSOpenClient: failed to get acknoledgement from server\n");
+       (void) close(fd);
+       fd = -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if (TRANS(FillAddrInfo) (ciptr, slave, server_path) == 0)
+    {
+       prmsg(1,"PTSOpenClient: failed to fill in addr info\n");
+       close(fd);
+       return -1;
+    }
+
+    return(fd);
+
+#endif /* !PTSNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(PTSOpenServer)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef PTSNODENAME
+    int fd, server;
+    char server_path[64], *slave;
+    int mode;
+#endif
+
+    prmsg(2,"PTSOpenServer(%s)\n", port);
+
+#if !defined(PTSNODENAME)
+    prmsg(1,"PTSOpenServer: Protocol is not supported by a pts connection\n");
+    return -1;
+#else
+    if (port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+               (void) sprintf(server_path, "%s", port);
+           } else {
+               (void) sprintf(server_path, "%s%s", PTSNODENAME, port);
+           }
+    } else {
+       (void) sprintf(server_path, "%s%d", PTSNODENAME, getpid());
+    }
+
+#ifdef HAS_STICKY_DIR_BIT
+    mode = 01777;
+#else
+    mode = 0777;
+#endif
+    if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
+       prmsg (1, "PTSOpenServer: mkdir(%s) failed, errno = %d\n",
+              X_STREAMS_DIR, errno);
+       return(-1);
+    }
+
+#if 0
+    if( (fd=open(server_path, O_RDWR)) >= 0 ) {
+       /*
+        * This doesn't prevent the server from starting up, and doesn't
+        * prevent clients from trying to connect to the in-use PTS (which
+        * is often in use by something other than another server).
+        */
+       prmsg(1, "PTSOpenServer: A server is already running on port %s\n", port);
+       prmsg(1, "PTSOpenServer: Remove %s if this is incorrect.\n", server_path);
+       close(fd);
+       return(-1);
+    }
+#else
+    /* Just remove the old path (which is what happens with UNIXCONN) */
+#endif
+
+    unlink(server_path);
+
+    if( (fd=open(DEV_PTMX, O_RDWR)) < 0) {
+       prmsg(1, "PTSOpenServer: Unable to open %s\n", DEV_PTMX);
+       return(-1);
+    }
+
+    grantpt(fd);
+    unlockpt(fd);
+
+    if( (slave=ptsname(fd)) == NULL) {
+       prmsg(1, "PTSOpenServer: Unable to get slave device name\n");
+       close(fd);
+       return(-1);
+    }
+
+    if( link(slave,server_path) < 0 ) {
+       prmsg(1, "PTSOpenServer: Unable to link %s to %s\n", slave, server_path);
+       close(fd);
+       return(-1);
+    }
+
+    if( chmod(server_path, 0666) < 0 ) {
+       prmsg(1, "PTSOpenServer: Unable to chmod %s to 0666\n", server_path);
+       close(fd);
+       return(-1);
+    }
+
+    if( (server=open(server_path, O_RDWR)) < 0 ) {
+       prmsg(1, "PTSOpenServer: Unable to open server device %s\n", server_path);
+       close(fd);
+       return(-1);
+    }
+
+    close(server);
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"PTSOpenServer: failed to fill in addr info\n");
+       close(fd);
+       return -1;
+    }
+
+    return fd;
+
+#endif /* !PTSNODENAME */
+}
+
+static int
+TRANS(PTSAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+
+{
+    int                        newfd;
+    int                        in;
+    unsigned char      length;
+    char               buf[256];
+    struct sockaddr_un *sunaddr;
+
+    prmsg(2,"PTSAccept(%x->%d)\n",ciptr,ciptr->fd);
+
+    if( (in=read(ciptr->fd,&length,1)) <= 0 ){
+       if( !in ) {
+               prmsg(2,
+               "PTSAccept: Incoming connection closed\n");
+               }
+       else {
+               prmsg(1,
+       "PTSAccept: Error reading incoming connection. errno=%d \n",
+                                                               errno);
+               }
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return -1;
+    }
+
+    if( (in=read(ciptr->fd,buf,length)) <= 0 ){
+       if( !in ) {
+               prmsg(2,
+               "PTSAccept: Incoming connection closed\n");
+               }
+       else {
+               prmsg(1,
+"PTSAccept: Error reading device name for new connection. errno=%d \n",
+                                                               errno);
+               }
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return -1;
+    }
+
+    buf[length] = '\0';
+
+    if( (newfd=open(buf,O_RDWR)) < 0 ) {
+       prmsg(1, "PTSAccept: Failed to open %s\n",buf);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return -1;
+    }
+
+    write(newfd,"1",1);
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    newciptr->addrlen=ciptr->addrlen;
+    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
+       prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
+       close(newfd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+
+    newciptr->peeraddrlen=sizeof(struct sockaddr_un);
+    if( (sunaddr = malloc(newciptr->peeraddrlen)) == NULL ) {
+       prmsg(1,"PTSAccept: failed to allocate memory for peer addr\n");
+       free(newciptr->addr);
+       close(newfd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    sunaddr->sun_family=AF_UNIX;
+    strcpy(sunaddr->sun_path,buf);
+#if defined(BSD44SOCKETS)
+    sunaddr->sun_len=strlen(sunaddr->sun_path);
+#endif
+
+    newciptr->peeraddr=(char *)sunaddr;
+
+    *status = 0;
+
+    return newfd;
+}
+
+#endif /* TRANS_SERVER */
+#endif /* LOCAL_TRANS_PTS */
+
+\f
+#ifdef LOCAL_TRANS_NAMED
+
+/* NAMED */
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(NAMEDOpenClient)(XtransConnInfo ciptr, char *port)
+
+{
+#ifdef NAMEDNODENAME
+    int                        fd;
+    char               server_path[64];
+    struct stat                filestat;
+# ifndef sun
+    extern int         isastream(int);
+# endif
+#endif
+
+    prmsg(2,"NAMEDOpenClient(%s)\n", port);
+
+#if !defined(NAMEDNODENAME)
+    prmsg(1,"NAMEDOpenClient: Protocol is not supported by a NAMED connection\n");
+    return -1;
+#else
+    if ( port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+               (void) snprintf(server_path, sizeof(server_path), "%s", port);
+           } else {
+               (void) snprintf(server_path, sizeof(server_path), "%s%s", NAMEDNODENAME, port);
+           }
+    } else {
+       (void) snprintf(server_path, sizeof(server_path), "%s%ld", NAMEDNODENAME, (long)getpid());
+    }
+
+    if ((fd = open(server_path, O_RDWR)) < 0) {
+       prmsg(1,"NAMEDOpenClient: Cannot open %s for NAMED connection\n", server_path);
+       return -1;
+    }
+
+    if (fstat(fd, &filestat) < 0 ) {
+       prmsg(1,"NAMEDOpenClient: Cannot stat %s for NAMED connection\n", server_path);
+       (void) close(fd);
+       return -1;
+    }
+
+    if ((filestat.st_mode & S_IFMT) != S_IFIFO) {
+       prmsg(1,"NAMEDOpenClient: Device %s is not a FIFO\n", server_path);
+       /* Is this really a failure? */
+       (void) close(fd);
+       return -1;
+    }
+
+
+    if (isastream(fd) <= 0) {
+       prmsg(1,"NAMEDOpenClient: %s is not a streams device\n", server_path);
+       (void) close(fd);
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"NAMEDOpenClient: failed to fill in addr info\n");
+       close(fd);
+       return -1;
+    }
+
+    return(fd);
+
+#endif /* !NAMEDNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+
+#ifdef NAMEDNODENAME
+static int
+TRANS(NAMEDOpenPipe)(const char *server_path)
+{
+    int                        fd, pipefd[2];
+    struct stat                sbuf;
+    int                        mode;
+
+    prmsg(2,"NAMEDOpenPipe(%s)\n", server_path);
+
+#ifdef HAS_STICKY_DIR_BIT
+    mode = 01777;
+#else
+    mode = 0777;
+#endif
+    if (trans_mkdir(X_STREAMS_DIR, mode) == -1) {
+       prmsg (1, "NAMEDOpenPipe: mkdir(%s) failed, errno = %d\n",
+              X_STREAMS_DIR, errno);
+       return(-1);
+    }
+
+    if(stat(server_path, &sbuf) != 0) {
+       if (errno == ENOENT) {
+           if ((fd = creat(server_path, (mode_t)0666)) == -1) {
+               prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path);
+               return(-1);
+           }
+           close(fd);
+           if (chmod(server_path, (mode_t)0666) < 0) {
+               prmsg(1, "NAMEDOpenPipe: Can't open %s\n", server_path);
+               return(-1);
+           }
+       } else {
+           prmsg(1, "NAMEDOpenPipe: stat on %s failed\n", server_path);
+           return(-1);
+       }
+    }
+
+    if( pipe(pipefd) != 0) {
+       prmsg(1, "NAMEDOpenPipe: pipe() failed, errno=%d\n",errno);
+       return(-1);
+    }
+
+    if( ioctl(pipefd[0], I_PUSH, "connld") != 0) {
+       prmsg(1, "NAMEDOpenPipe: ioctl(I_PUSH,\"connld\") failed, errno=%d\n",errno);
+       close(pipefd[0]);
+       close(pipefd[1]);
+       return(-1);
+    }
+
+    if( fattach(pipefd[0], server_path) != 0) {
+       prmsg(1, "NAMEDOpenPipe: fattach(%s) failed, errno=%d\n", server_path,errno);
+       close(pipefd[0]);
+       close(pipefd[1]);
+       return(-1);
+    }
+
+    return(pipefd[1]);
+}
+#endif
+
+static int
+TRANS(NAMEDOpenServer)(XtransConnInfo ciptr, char *port)
+{
+#ifdef NAMEDNODENAME
+    int                        fd;
+    char               server_path[64];
+#endif
+
+    prmsg(2,"NAMEDOpenServer(%s)\n", port);
+
+#if !defined(NAMEDNODENAME)
+    prmsg(1,"NAMEDOpenServer: Protocol is not supported by a NAMED connection\n");
+    return -1;
+#else
+    if ( port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+           (void) snprintf(server_path, sizeof(server_path), "%s", port);
+       } else {
+           (void) snprintf(server_path, sizeof(server_path), "%s%s",
+                           NAMEDNODENAME, port);
+       }
+    } else {
+       (void) snprintf(server_path, sizeof(server_path), "%s%ld",
+                      NAMEDNODENAME, (long)getpid());
+    }
+
+    fd = TRANS(NAMEDOpenPipe)(server_path);
+    if (fd < 0) {
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"NAMEDOpenServer: failed to fill in addr info\n");
+       TRANS(LocalClose)(ciptr);
+       return -1;
+    }
+
+    return fd;
+
+#endif /* !NAMEDNODENAME */
+}
+
+static int
+TRANS(NAMEDResetListener) (XtransConnInfo ciptr)
+
+{
+  struct sockaddr_un      *sockname=(struct sockaddr_un *) ciptr->addr;
+  struct stat     statb;
+
+  prmsg(2,"NAMEDResetListener(%p, %d)\n", ciptr, ciptr->fd);
+
+  if (ciptr->fd != -1) {
+    /*
+     * see if the pipe has disappeared
+     */
+
+    if (stat (sockname->sun_path, &statb) == -1 ||
+       (statb.st_mode & S_IFMT) != S_IFIFO) {
+      prmsg(3, "Pipe %s trashed, recreating\n", sockname->sun_path);
+      TRANS(LocalClose)(ciptr);
+      ciptr->fd = TRANS(NAMEDOpenPipe)(sockname->sun_path);
+      if (ciptr->fd >= 0)
+         return TRANS_RESET_NEW_FD;
+      else
+         return TRANS_CREATE_LISTENER_FAILED;
+    }
+  }
+  return TRANS_RESET_NOOP;
+}
+
+static int
+TRANS(NAMEDAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+
+{
+    struct strrecvfd str;
+
+    prmsg(2,"NAMEDAccept(%p->%d)\n", ciptr, ciptr->fd);
+
+    if( ioctl(ciptr->fd, I_RECVFD, &str ) < 0 ) {
+       prmsg(1, "NAMEDAccept: ioctl(I_RECVFD) failed, errno=%d\n", errno);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return(-1);
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+    newciptr->family=ciptr->family;
+    newciptr->addrlen=ciptr->addrlen;
+    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
+       prmsg(1,
+             "NAMEDAccept: failed to allocate memory for pipe addr\n");
+       close(str.fd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+
+    newciptr->peeraddrlen=newciptr->addrlen;
+    if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
+       prmsg(1,
+       "NAMEDAccept: failed to allocate memory for peer addr\n");
+       free(newciptr->addr);
+       close(str.fd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);
+
+    *status = 0;
+
+    return str.fd;
+}
+
+#endif /* TRANS_SERVER */
+
+#endif /* LOCAL_TRANS_NAMED */
+
+
+\f
+#if defined(LOCAL_TRANS_SCO)
+
+/*
+ * connect_spipe is used by the SCO connection type.
+ */
+static int
+connect_spipe(int fd1, int fd2)
+{
+    long temp;
+    struct strfdinsert sbuf;
+
+    sbuf.databuf.maxlen = -1;
+    sbuf.databuf.len = -1;
+    sbuf.databuf.buf = NULL;
+    sbuf.ctlbuf.maxlen = sizeof(long);
+    sbuf.ctlbuf.len = sizeof(long);
+    sbuf.ctlbuf.buf = (caddr_t)&temp;
+    sbuf.offset = 0;
+    sbuf.fildes = fd2;
+    sbuf.flags = 0;
+
+    if( ioctl(fd1, I_FDINSERT, &sbuf) < 0 )
+       return(-1);
+
+    return(0);
+}
+
+/*
+ * named_spipe is used by the SCO connection type.
+ */
+
+static int
+named_spipe(int fd, char *path)
+
+{
+    int oldUmask, ret;
+    struct stat sbuf;
+
+    oldUmask = umask(0);
+
+    (void) fstat(fd, &sbuf);
+    ret = mknod(path, 0020666, sbuf.st_rdev);
+
+    umask(oldUmask);
+
+    if (ret < 0) {
+       ret = -1;
+    } else {
+       ret = fd;
+    }
+
+    return(ret);
+}
+
+#endif /* defined(LOCAL_TRANS_SCO) */
+
+
+
+\f
+#ifdef LOCAL_TRANS_SCO
+/* SCO */
+
+/*
+ * 2002-11-09 (jkj@sco.com)
+ *
+ * This code has been modified to match what is in the actual SCO X server.
+ * This greatly helps inter-operability between X11R6 and X11R5 (the native
+ * SCO server). Mainly, it relies on streams nodes existing in /dev, not
+ * creating them or unlinking them, which breaks the native X server.
+ *
+ * However, this is only for the X protocol. For all other protocols, we
+ * do in fact create the nodes, as only X11R6 will use them, and this makes
+ * it possible to have both types of clients running, otherwise we get all
+ * kinds of nasty errors on startup for anything that doesnt use the X
+ * protocol (like SM, when KDE starts up).
+ */
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(SCOOpenClient)(XtransConnInfo ciptr, char *port)
+{
+#ifdef SCORNODENAME
+    int                        fd, server, fl, ret;
+    char               server_path[64];
+    struct strbuf      ctlbuf;
+    unsigned long      alarm_time;
+    void               (*savef)();
+    long               temp;
+    extern int getmsg(), putmsg();
+#endif
+
+    prmsg(2,"SCOOpenClient(%s)\n", port);
+    if (!port || !port[0])
+       port = "0";
+
+#if !defined(SCORNODENAME)
+    prmsg(2,"SCOOpenClient: Protocol is not supported by a SCO connection\n");
+    return -1;
+#else
+    (void) sprintf(server_path, SCORNODENAME, port);
+
+    if ((server = open(server_path, O_RDWR)) < 0) {
+       prmsg(1,"SCOOpenClient: failed to open %s\n", server_path);
+       return -1;
+    }
+
+    if ((fd = open(DEV_SPX, O_RDWR)) < 0) {
+       prmsg(1,"SCOOpenClient: failed to open %s\n", DEV_SPX);
+       close(server);
+       return -1;
+    }
+
+    (void) write(server, &server, 1);
+    ctlbuf.len = 0;
+    ctlbuf.maxlen = sizeof(long);
+    ctlbuf.buf = (caddr_t)&temp;
+    fl = 0;
+
+    savef = signal(SIGALRM, _dummy);
+    alarm_time = alarm(10);
+
+    ret = getmsg(server, &ctlbuf, 0, &fl);
+
+    (void) alarm(alarm_time);
+    (void) signal(SIGALRM, savef);
+
+    if (ret < 0) {
+       prmsg(1,"SCOOpenClient: error from getmsg\n");
+       close(fd);
+       close(server);
+       return -1;
+    }
+
+    /* The msg we got via getmsg is the result of an
+     * I_FDINSERT, so if we do a putmsg with whatever
+     * we recieved, we're doing another I_FDINSERT ...
+     */
+    (void) putmsg(fd, &ctlbuf, 0, 0);
+    (void) fcntl(fd,F_SETFL,fcntl(fd,F_GETFL,0)|O_NDELAY);
+
+    (void) close(server);
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+#if defined(X11_t) && defined(__SCO__)
+    ciptr->flags |= TRANS_NOUNLINK;
+#endif
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"SCOOpenClient: failed to fill addr info\n");
+       close(fd);
+       return -1;
+    }
+
+    return(fd);
+
+#endif  /* !SCORNODENAME */
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SCOOpenServer)(XtransConnInfo ciptr, char *port)
+{
+#ifdef SCORNODENAME
+    char               serverR_path[64];
+    char               serverS_path[64];
+    struct flock       mylock;
+    int                        fdr = -1;
+    int                        fds = -1;
+#endif
+
+    prmsg(2,"SCOOpenServer(%s)\n", port);
+    if (!port || !port[0])
+       port = "0";
+
+#if !defined(SCORNODENAME)
+    prmsg(1,"SCOOpenServer: Protocol is not supported by a SCO connection\n");
+    return -1;
+#else
+    (void) sprintf(serverR_path, SCORNODENAME, port);
+    (void) sprintf(serverS_path, SCOSNODENAME, port);
+
+#if !defined(X11_t) || !defined(__SCO__)
+    unlink(serverR_path);
+    unlink(serverS_path);
+
+    if ((fds = open(DEV_SPX, O_RDWR)) < 0 ||
+       (fdr = open(DEV_SPX, O_RDWR)) < 0 ) {
+       prmsg(1,"SCOOpenServer: failed to open %s\n", DEV_SPX);
+       if (fds >= 0)
+               close(fds);
+       if (fdr >= 0)
+               close(fdr);
+       return -1;
+    }
+
+    if (named_spipe (fds, serverS_path) == -1) {
+       prmsg(1,"SCOOpenServer: failed to create %s\n", serverS_path);
+       close (fdr);
+       close (fds);
+       return -1;
+    }
+
+    if (named_spipe (fdr, serverR_path) == -1) {
+       prmsg(1,"SCOOpenServer: failed to create %s\n", serverR_path);
+       close (fdr);
+       close (fds);
+       return -1;
+    }
+#else /* X11_t */
+
+    fds = open (serverS_path, O_RDWR | O_NDELAY);
+    if (fds < 0) {
+       prmsg(1,"SCOOpenServer: failed to open %s\n", serverS_path);
+       return -1;
+    }
+
+    /*
+     * Lock the connection device for the duration of the server.
+     * This resolves multiple server starts especially on SMP machines.
+     */
+    mylock.l_type      = F_WRLCK;
+    mylock.l_whence    = 0;
+    mylock.l_start     = 0;
+    mylock.l_len       = 0;
+    if (fcntl (fds, F_SETLK, &mylock) < 0) {
+       prmsg(1,"SCOOpenServer: failed to lock %s\n", serverS_path);
+       close (fds);
+       return -1;
+    }
+
+    fdr = open (serverR_path, O_RDWR | O_NDELAY);
+    if (fdr < 0) {
+       prmsg(1,"SCOOpenServer: failed to open %s\n", serverR_path);
+       close (fds);
+       return -1;
+    }
+#endif /* X11_t */
+
+    if (connect_spipe(fds, fdr)) {
+       prmsg(1,"SCOOpenServer: ioctl(I_FDINSERT) failed on %s\n",
+             serverS_path);
+       close (fdr);
+       close (fds);
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+#if defined(X11_t) && defined(__SCO__)
+    ciptr->flags |= TRANS_NOUNLINK;
+#endif
+    if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0) {
+       prmsg(1,"SCOOpenServer: failed to fill in addr info\n");
+       close(fds);
+       close(fdr);
+       return -1;
+    }
+
+    return(fds);
+
+#endif /* !SCORNODENAME */
+}
+
+static int
+TRANS(SCOAccept)(XtransConnInfo ciptr, XtransConnInfo newciptr, int *status)
+{
+    char               c;
+    int                        fd;
+
+    prmsg(2,"SCOAccept(%d)\n", ciptr->fd);
+
+    if (read(ciptr->fd, &c, 1) < 0) {
+       prmsg(1,"SCOAccept: can't read from client\n");
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return(-1);
+    }
+
+    if( (fd = open(DEV_SPX, O_RDWR)) < 0 ) {
+       prmsg(1,"SCOAccept: can't open \"%s\"\n",DEV_SPX);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return(-1);
+    }
+
+    if (connect_spipe (ciptr->fd, fd) < 0) {
+       prmsg(1,"SCOAccept: ioctl(I_FDINSERT) failed\n");
+       close (fd);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    newciptr->addrlen=ciptr->addrlen;
+    if( (newciptr->addr = malloc(newciptr->addrlen)) == NULL ) {
+       prmsg(1,
+             "SCOAccept: failed to allocate memory for peer addr\n");
+       close(fd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    memcpy(newciptr->addr,ciptr->addr,newciptr->addrlen);
+#if defined(__SCO__)
+    newciptr->flags |= TRANS_NOUNLINK;
+#endif
+
+    newciptr->peeraddrlen=newciptr->addrlen;
+    if( (newciptr->peeraddr = malloc(newciptr->peeraddrlen)) == NULL ) {
+       prmsg(1,
+             "SCOAccept: failed to allocate memory for peer addr\n");
+       free(newciptr->addr);
+       close(fd);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return -1;
+    }
+
+    memcpy(newciptr->peeraddr,newciptr->addr,newciptr->peeraddrlen);
+
+    *status = 0;
+
+    return(fd);
+}
+
+#endif /* TRANS_SERVER */
+#endif /* LOCAL_TRANS_SCO */
+
+
+\f
+#ifdef TRANS_REOPEN
+#ifdef LOCAL_TRANS_PTS
+
+static int
+TRANS(PTSReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef PTSNODENAME
+    char server_path[64];
+#endif
+
+    prmsg(2,"PTSReopenServer(%d,%s)\n", fd, port);
+
+#if !defined(PTSNODENAME)
+    prmsg(1,"PTSReopenServer: Protocol is not supported by a pts connection\n");
+    return 0;
+#else
+    if (port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+           snprintf(server_path, sizeof(server_path), "%s", port);
+       } else {
+           snprintf(server_path, sizeof(server_path), "%s%s",
+                    PTSNODENAME, port);
+       }
+    } else {
+       snprintf(server_path, sizeof(server_path), "%s%ld",
+               PTSNODENAME, (long)getpid());
+    }
+
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"PTSReopenServer: failed to fill in addr info\n");
+       return 0;
+    }
+
+    return 1;
+
+#endif /* !PTSNODENAME */
+}
+
+#endif /* LOCAL_TRANS_PTS */
+
+#ifdef LOCAL_TRANS_NAMED
+
+static int
+TRANS(NAMEDReopenServer)(XtransConnInfo ciptr, int fd _X_UNUSED, char *port)
+
+{
+#ifdef NAMEDNODENAME
+    char server_path[64];
+#endif
+
+    prmsg(2,"NAMEDReopenServer(%s)\n", port);
+
+#if !defined(NAMEDNODENAME)
+    prmsg(1,"NAMEDReopenServer: Protocol is not supported by a NAMED connection\n");
+    return 0;
+#else
+    if ( port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+           snprintf(server_path, sizeof(server_path),"%s", port);
+       } else {
+           snprintf(server_path, sizeof(server_path), "%s%s",
+                    NAMEDNODENAME, port);
+       }
+    } else {
+       snprintf(server_path, sizeof(server_path), "%s%ld",
+               NAMEDNODENAME, (long)getpid());
+    }
+
+    if (TRANS(FillAddrInfo) (ciptr, server_path, server_path) == 0)
+    {
+       prmsg(1,"NAMEDReopenServer: failed to fill in addr info\n");
+       return 0;
+    }
+
+    return 1;
+
+#endif /* !NAMEDNODENAME */
+}
+
+#endif /* LOCAL_TRANS_NAMED */
+
+
+#ifdef LOCAL_TRANS_SCO
+static int
+TRANS(SCOReopenServer)(XtransConnInfo ciptr, int fd, char *port)
+
+{
+#ifdef SCORNODENAME
+    char serverR_path[64], serverS_path[64];
+#endif
+
+    prmsg(2,"SCOReopenServer(%s)\n", port);
+    if (!port || !port[0])
+      port = "0";
+
+#if !defined(SCORNODENAME)
+    prmsg(2,"SCOReopenServer: Protocol is not supported by a SCO connection\n");
+    return 0;
+#else
+    (void) sprintf(serverR_path, SCORNODENAME, port);
+    (void) sprintf(serverS_path, SCOSNODENAME, port);
+
+#if defined(X11_t) && defined(__SCO__)
+    ciptr->flags |= TRANS_NOUNLINK;
+#endif
+    if (TRANS(FillAddrInfo) (ciptr, serverS_path, serverR_path) == 0)
+    {
+       prmsg(1, "SCOReopenServer: failed to fill in addr info\n");
+       return 0;
+    }
+
+    return 1;
+
+#endif /* SCORNODENAME */
+}
+
+#endif /* LOCAL_TRANS_SCO */
+
+#endif /* TRANS_REOPEN */
+
+
+\f
+/*
+ * This table contains all of the entry points for the different local
+ * connection mechanisms.
+ */
+
+typedef struct _LOCALtrans2dev {
+    const char *transname;
+
+#ifdef TRANS_CLIENT
+
+    int        (*devcotsopenclient)(
+       XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+    int        (*devcotsopenserver)(
+       XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_CLIENT
+
+    int        (*devcltsopenclient)(
+       XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_CLIENT */
+
+#ifdef TRANS_SERVER
+
+    int        (*devcltsopenserver)(
+       XtransConnInfo, char * /*port*/
+);
+
+#endif /* TRANS_SERVER */
+
+#ifdef TRANS_REOPEN
+
+    int        (*devcotsreopenserver)(
+       XtransConnInfo,
+       int,    /* fd */
+       char *  /* port */
+);
+
+    int        (*devcltsreopenserver)(
+       XtransConnInfo,
+       int,    /* fd */
+       char *  /* port */
+);
+
+#endif /* TRANS_REOPEN */
+
+#ifdef TRANS_SERVER
+
+    int (*devreset)(
+       XtransConnInfo /* ciptr */
+);
+
+    int        (*devaccept)(
+       XtransConnInfo, XtransConnInfo, int *
+);
+
+#endif /* TRANS_SERVER */
+
+} LOCALtrans2dev;
+
+static LOCALtrans2dev LOCALtrans2devtab[] = {
+#ifdef LOCAL_TRANS_PTS
+{"",
+#ifdef TRANS_CLIENT
+     TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(PTSReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     NULL,             /* ResetListener */
+     TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"local",
+#ifdef TRANS_CLIENT
+     TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(PTSReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     NULL,             /* ResetListener */
+     TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"pts",
+#ifdef TRANS_CLIENT
+     TRANS(PTSOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(PTSOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(PTSReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     NULL,             /* ResetListener */
+     TRANS(PTSAccept)
+#endif /* TRANS_SERVER */
+},
+#else /* !LOCAL_TRANS_PTS */
+{"",
+#ifdef TRANS_CLIENT
+     TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(NAMEDReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     TRANS(NAMEDResetListener),
+     TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+
+{"local",
+#ifdef TRANS_CLIENT
+     TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(NAMEDReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     TRANS(NAMEDResetListener),
+     TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* !LOCAL_TRANS_PTS */
+
+#ifdef LOCAL_TRANS_NAMED
+{"named",
+#ifdef TRANS_CLIENT
+     TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(NAMEDReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     TRANS(NAMEDResetListener),
+     TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+
+#ifdef sun /* Alias "pipe" to named, since that's what Solaris called it */
+{"pipe",
+#ifdef TRANS_CLIENT
+     TRANS(NAMEDOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(NAMEDOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(NAMEDReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     TRANS(NAMEDResetListener),
+     TRANS(NAMEDAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* sun */
+#endif /* LOCAL_TRANS_NAMED */
+
+
+#ifdef LOCAL_TRANS_SCO
+{"sco",
+#ifdef TRANS_CLIENT
+     TRANS(SCOOpenClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(SCOOpenServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+     TRANS(OpenFail),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+     TRANS(OpenFail),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+     TRANS(SCOReopenServer),
+     TRANS(ReopenFail),
+#endif
+#ifdef TRANS_SERVER
+     NULL,             /* ResetListener */
+     TRANS(SCOAccept)
+#endif /* TRANS_SERVER */
+},
+#endif /* LOCAL_TRANS_SCO */
+};
+
+#define NUMTRANSPORTS  (sizeof(LOCALtrans2devtab)/sizeof(LOCALtrans2dev))
+
+static const char      *XLOCAL=NULL;
+static char    *workingXLOCAL=NULL;
+static char    *freeXLOCAL=NULL;
+
+#if defined(__SCO__)
+#define DEF_XLOCAL "SCO:UNIX:PTS"
+#elif defined(__UNIXWARE__)
+#define DEF_XLOCAL "UNIX:PTS:NAMED:SCO"
+#elif defined(sun)
+#define DEF_XLOCAL "UNIX:NAMED"
+#else
+#define DEF_XLOCAL "UNIX:PTS:NAMED:SCO"
+#endif
+
+static void
+TRANS(LocalInitTransports)(const char *protocol)
+
+{
+    prmsg(3,"LocalInitTransports(%s)\n", protocol);
+
+    if( strcmp(protocol,"local") && strcmp(protocol,"LOCAL") )
+    {
+       workingXLOCAL = freeXLOCAL = strdup (protocol);
+    }
+    else {
+       XLOCAL=(char *)getenv("XLOCAL");
+       if(XLOCAL==NULL)
+           XLOCAL=DEF_XLOCAL;
+       workingXLOCAL = freeXLOCAL = strdup (XLOCAL);
+    }
+}
+
+static void
+TRANS(LocalEndTransports)(void)
+
+{
+    prmsg(3,"LocalEndTransports()\n");
+    free(freeXLOCAL);
+}
+
+#define TYPEBUFSIZE    32
+
+#ifdef TRANS_CLIENT
+
+static LOCALtrans2dev *
+TRANS(LocalGetNextTransport)(void)
+
+{
+    int        i,j;
+    char       *typetocheck;
+    char       typebuf[TYPEBUFSIZE];
+    prmsg(3,"LocalGetNextTransport()\n");
+
+    while(1)
+    {
+       if( workingXLOCAL == NULL || *workingXLOCAL == '\0' )
+           return NULL;
+
+       typetocheck=workingXLOCAL;
+       workingXLOCAL=strchr(workingXLOCAL,':');
+       if(workingXLOCAL && *workingXLOCAL)
+           *workingXLOCAL++='\0';
+
+       for(i=0;i<NUMTRANSPORTS;i++)
+       {
+           /*
+            * This is equivalent to a case insensitive strcmp(),
+            * but should be more portable.
+            */
+           strncpy(typebuf,typetocheck,TYPEBUFSIZE);
+           for(j=0;j<TYPEBUFSIZE;j++)
+               if (isupper(typebuf[j]))
+                   typebuf[j]=tolower(typebuf[j]);
+
+           /* Now, see if they match */
+           if(!strcmp(LOCALtrans2devtab[i].transname,typebuf))
+               return &LOCALtrans2devtab[i];
+       }
+    }
+#if 0
+    /*NOTREACHED*/
+    return NULL;
+#endif
+}
+
+#ifdef NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+HostReallyLocal (char *host)
+
+{
+    /*
+     * The 'host' passed to this function may have been generated
+     * by either uname() or gethostname().  We try both if possible.
+     */
+
+#ifdef NEED_UTSNAME
+    struct utsname name;
+#endif
+    char buf[256];
+
+#ifdef NEED_UTSNAME
+    if (uname (&name) >= 0 && strcmp (host, name.nodename) == 0)
+       return (1);
+#endif
+
+    buf[0] = '\0';
+    (void) gethostname (buf, 256);
+    buf[255] = '\0';
+
+    if (strcmp (host, buf) == 0)
+       return (1);
+
+    return (0);
+}
+
+
+static XtransConnInfo
+TRANS(LocalOpenClient)(int type, char *protocol, char *host, char *port)
+
+{
+    LOCALtrans2dev *transptr;
+    XtransConnInfo ciptr;
+    int index;
+
+    prmsg(3,"LocalOpenClient()\n");
+
+    /*
+     * Make sure 'host' is really local.  If not, we return failure.
+     * The reason we make this check is because a process may advertise
+     * a "local" address for which it can accept connections, but if a
+     * process on a remote machine tries to connect to this address,
+     * we know for sure it will fail.
+     */
+
+    if (strcmp (host, "unix") != 0 && !HostReallyLocal (host))
+    {
+       prmsg (1,
+          "LocalOpenClient: Cannot connect to non-local host %s\n",
+              host);
+       return NULL;
+    }
+
+
+#if defined(X11_t)
+    /*
+     * X has a well known port, that is transport dependant. It is easier
+     * to handle it here, than try and come up with a transport independent
+     * representation that can be passed in and resolved the usual way.
+     *
+     * The port that is passed here is really a string containing the idisplay
+     * from ConnectDisplay(). Since that is what we want for the local transports,
+     * we don't have to do anything special.
+     */
+#endif /* X11_t */
+
+    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+    {
+       prmsg(1,"LocalOpenClient: calloc(1,%lu) failed\n",
+             sizeof(struct _XtransConnInfo));
+       return NULL;
+    }
+
+    ciptr->fd = -1;
+
+    TRANS(LocalInitTransports)(protocol);
+
+    index = 0;
+    for(transptr=TRANS(LocalGetNextTransport)();
+       transptr!=NULL;transptr=TRANS(LocalGetNextTransport)(), index++)
+    {
+       switch( type )
+       {
+       case XTRANS_OPEN_COTS_CLIENT:
+           ciptr->fd=transptr->devcotsopenclient(ciptr,port);
+           break;
+       case XTRANS_OPEN_CLTS_CLIENT:
+           ciptr->fd=transptr->devcltsopenclient(ciptr,port);
+           break;
+       case XTRANS_OPEN_COTS_SERVER:
+       case XTRANS_OPEN_CLTS_SERVER:
+           prmsg(1,
+                 "LocalOpenClient: Should not be opening a server with this function\n");
+           break;
+       default:
+           prmsg(1,
+                 "LocalOpenClient: Unknown Open type %d\n",
+                 type);
+       }
+       if( ciptr->fd >= 0 )
+           break;
+    }
+
+    TRANS(LocalEndTransports)();
+
+    if( ciptr->fd < 0 )
+    {
+       free(ciptr);
+       return NULL;
+    }
+
+    ciptr->priv=(char *)transptr;
+    ciptr->index = index;
+
+    return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenServer)(int type, char *protocol, char *host _X_UNUSED, char *port)
+
+{
+    int        i;
+    XtransConnInfo ciptr;
+
+    prmsg(2,"LocalOpenServer(%d,%s,%s)\n", type, protocol, port);
+
+#if defined(X11_t)
+    /*
+     * For X11, the port will be in the format xserverN where N is the
+     * display number. All of the local connections just need to know
+     * the display number because they don't do any name resolution on
+     * the port. This just truncates port to the display portion.
+     */
+#endif /* X11_t */
+
+    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+    {
+       prmsg(1,"LocalOpenServer: calloc(1,%lu) failed\n",
+             sizeof(struct _XtransConnInfo));
+       return NULL;
+    }
+
+    for(i=1;i<NUMTRANSPORTS;i++)
+    {
+       if( strcmp(protocol,LOCALtrans2devtab[i].transname) != 0 )
+           continue;
+       switch( type )
+       {
+       case XTRANS_OPEN_COTS_CLIENT:
+       case XTRANS_OPEN_CLTS_CLIENT:
+           prmsg(1,
+                 "LocalOpenServer: Should not be opening a client with this function\n");
+           break;
+       case XTRANS_OPEN_COTS_SERVER:
+           ciptr->fd=LOCALtrans2devtab[i].devcotsopenserver(ciptr,port);
+           break;
+       case XTRANS_OPEN_CLTS_SERVER:
+           ciptr->fd=LOCALtrans2devtab[i].devcltsopenserver(ciptr,port);
+           break;
+       default:
+           prmsg(1,"LocalOpenServer: Unknown Open type %d\n",
+                 type );
+       }
+       if( ciptr->fd >= 0 ) {
+           ciptr->priv=(char *)&LOCALtrans2devtab[i];
+           ciptr->index=i;
+           ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+           return ciptr;
+       }
+    }
+
+    free(ciptr);
+    return NULL;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(LocalReopenServer)(int type, int index, int fd, char *port)
+
+{
+    XtransConnInfo ciptr;
+    int stat = 0;
+
+    prmsg(2,"LocalReopenServer(%d,%d,%d)\n", type, index, fd);
+
+    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+    {
+       prmsg(1,"LocalReopenServer: calloc(1,%lu) failed\n",
+             sizeof(struct _XtransConnInfo));
+       return NULL;
+    }
+
+    ciptr->fd = fd;
+
+    switch( type )
+    {
+    case XTRANS_OPEN_COTS_SERVER:
+       stat = LOCALtrans2devtab[index].devcotsreopenserver(ciptr,fd,port);
+       break;
+    case XTRANS_OPEN_CLTS_SERVER:
+       stat = LOCALtrans2devtab[index].devcltsreopenserver(ciptr,fd,port);
+       break;
+    default:
+       prmsg(1,"LocalReopenServer: Unknown Open type %d\n",
+         type );
+    }
+
+    if( stat > 0 ) {
+       ciptr->priv=(char *)&LOCALtrans2devtab[index];
+       ciptr->index=index;
+       ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+       return ciptr;
+    }
+
+    free(ciptr);
+    return NULL;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+\f
+/*
+ * This is the Local implementation of the X Transport service layer
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(LocalOpenCOTSClient)(Xtransport *thistrans _X_UNUSED, char *protocol,
+                          char *host, char *port)
+
+{
+    prmsg(2,"LocalOpenCOTSClient(%s,%s,%s)\n",protocol,host,port);
+
+    return TRANS(LocalOpenClient)(XTRANS_OPEN_COTS_CLIENT, protocol, host, port);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenCOTSServer)(Xtransport *thistrans, char *protocol,
+                          char *host, char *port)
+
+{
+    char *typetocheck = NULL;
+    int found = 0;
+    char typebuf[TYPEBUFSIZE];
+
+    prmsg(2,"LocalOpenCOTSServer(%s,%s,%s)\n",protocol,host,port);
+
+    /* Check if this local type is in the XLOCAL list */
+    TRANS(LocalInitTransports)("local");
+    typetocheck = workingXLOCAL;
+    while (typetocheck && !found) {
+       int j;
+
+       workingXLOCAL = strchr(workingXLOCAL, ':');
+       if (workingXLOCAL && *workingXLOCAL)
+           *workingXLOCAL++ = '\0';
+       strncpy(typebuf, typetocheck, TYPEBUFSIZE);
+       for (j = 0; j < TYPEBUFSIZE; j++)
+           if (isupper(typebuf[j]))
+               typebuf[j] = tolower(typebuf[j]);
+       if (!strcmp(thistrans->TransName, typebuf))
+           found = 1;
+       typetocheck = workingXLOCAL;
+    }
+    TRANS(LocalEndTransports)();
+
+    if (!found) {
+       prmsg(3,"LocalOpenCOTSServer: disabling %s\n",thistrans->TransName);
+       thistrans->flags |= TRANS_DISABLED;
+       return NULL;
+    }
+
+    return TRANS(LocalOpenServer)(XTRANS_OPEN_COTS_SERVER, protocol, host, port);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(LocalOpenCLTSClient)(Xtransport *thistrans _X_UNUSED, char *protocol,
+                          char *host, char *port)
+
+{
+    prmsg(2,"LocalOpenCLTSClient(%s,%s,%s)\n",protocol,host,port);
+
+    return TRANS(LocalOpenClient)(XTRANS_OPEN_CLTS_CLIENT, protocol, host, port);
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(LocalOpenCLTSServer)(Xtransport *thistrans _X_UNUSED, char *protocol,
+                          char *host, char *port)
+
+{
+    prmsg(2,"LocalOpenCLTSServer(%s,%s,%s)\n",protocol,host,port);
+
+    return TRANS(LocalOpenServer)(XTRANS_OPEN_CLTS_SERVER, protocol, host, port);
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(LocalReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+    int index;
+
+    prmsg(2,"LocalReopenCOTSServer(%d,%s)\n", fd, port);
+
+    for(index=1;index<NUMTRANSPORTS;index++)
+    {
+       if( strcmp(thistrans->TransName,
+           LOCALtrans2devtab[index].transname) == 0 )
+           break;
+    }
+
+    if (index >= NUMTRANSPORTS)
+    {
+       return (NULL);
+    }
+
+    return TRANS(LocalReopenServer)(XTRANS_OPEN_COTS_SERVER,
+       index, fd, port);
+}
+
+static XtransConnInfo
+TRANS(LocalReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+    int index;
+
+    prmsg(2,"LocalReopenCLTSServer(%d,%s)\n", fd, port);
+
+    for(index=1;index<NUMTRANSPORTS;index++)
+    {
+       if( strcmp(thistrans->TransName,
+           LOCALtrans2devtab[index].transname) == 0 )
+           break;
+    }
+
+    if (index >= NUMTRANSPORTS)
+    {
+       return (NULL);
+    }
+
+    return TRANS(LocalReopenServer)(XTRANS_OPEN_CLTS_SERVER,
+       index, fd, port);
+}
+
+#endif /* TRANS_REOPEN */
+
+
+
+static int
+TRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg)
+
+{
+    prmsg(2,"LocalSetOption(%d,%d,%d)\n",ciptr->fd,option,arg);
+
+    return -1;
+}
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags _X_UNUSED)
+
+{
+    prmsg(2,"LocalCreateListener(%p->%d,%s)\n",ciptr,ciptr->fd,port);
+
+    return 0;
+}
+
+static int
+TRANS(LocalResetListener)(XtransConnInfo ciptr)
+
+{
+    LOCALtrans2dev     *transptr;
+
+    prmsg(2,"LocalResetListener(%p)\n",ciptr);
+
+    transptr=(LOCALtrans2dev *)ciptr->priv;
+    if (transptr->devreset != NULL) {
+       return transptr->devreset(ciptr);
+    }
+    return TRANS_RESET_NOOP;
+}
+
+
+static XtransConnInfo
+TRANS(LocalAccept)(XtransConnInfo ciptr, int *status)
+
+{
+    XtransConnInfo     newciptr;
+    LOCALtrans2dev     *transptr;
+
+    prmsg(2,"LocalAccept(%p->%d)\n", ciptr, ciptr->fd);
+
+    transptr=(LOCALtrans2dev *)ciptr->priv;
+
+    if( (newciptr = calloc(1,sizeof(struct _XtransConnInfo)))==NULL )
+    {
+       prmsg(1,"LocalAccept: calloc(1,%lu) failed\n",
+             sizeof(struct _XtransConnInfo));
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return NULL;
+    }
+
+    newciptr->fd=transptr->devaccept(ciptr,newciptr,status);
+
+    if( newciptr->fd < 0 )
+    {
+       free(newciptr);
+       return NULL;
+    }
+
+    newciptr->priv=(char *)transptr;
+    newciptr->index = ciptr->index;
+
+    *status = 0;
+
+    return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(LocalConnect)(XtransConnInfo ciptr, char *host _X_UNUSED, char *port)
+
+{
+    prmsg(2,"LocalConnect(%p->%d,%s)\n", ciptr, ciptr->fd, port);
+
+    return 0;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(LocalBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend )
+
+{
+    prmsg(2,"LocalBytesReadable(%p->%d,%p)\n", ciptr, ciptr->fd, pend);
+
+#if defined(SCO325)
+    return ioctl(ciptr->fd, I_NREAD, (char *)pend);
+#else
+    return ioctl(ciptr->fd, FIONREAD, (char *)pend);
+#endif
+}
+
+static int
+TRANS(LocalRead)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg(2,"LocalRead(%d,%p,%d)\n", ciptr->fd, buf, size );
+
+    return read(ciptr->fd,buf,size);
+}
+
+static int
+TRANS(LocalWrite)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg(2,"LocalWrite(%d,%p,%d)\n", ciptr->fd, buf, size );
+
+    return write(ciptr->fd,buf,size);
+}
+
+static int
+TRANS(LocalReadv)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg(2,"LocalReadv(%d,%p,%d)\n", ciptr->fd, buf, size );
+
+    return READV(ciptr,buf,size);
+}
+
+static int
+TRANS(LocalWritev)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg(2,"LocalWritev(%d,%p,%d)\n", ciptr->fd, buf, size );
+
+    return WRITEV(ciptr,buf,size);
+}
+
+static int
+TRANS(LocalDisconnect)(XtransConnInfo ciptr)
+
+{
+    prmsg(2,"LocalDisconnect(%p->%d)\n", ciptr, ciptr->fd);
+
+    return 0;
+}
+
+static int
+TRANS(LocalClose)(XtransConnInfo ciptr)
+
+{
+    struct sockaddr_un      *sockname=(struct sockaddr_un *) ciptr->addr;
+    int        ret;
+
+    prmsg(2,"LocalClose(%p->%d)\n", ciptr, ciptr->fd );
+
+    ret=close(ciptr->fd);
+
+    if(ciptr->flags
+       && sockname
+       && sockname->sun_family == AF_UNIX
+       && sockname->sun_path[0] )
+    {
+       if (!(ciptr->flags & TRANS_NOUNLINK))
+           unlink(sockname->sun_path);
+    }
+
+    return ret;
+}
+
+static int
+TRANS(LocalCloseForCloning)(XtransConnInfo ciptr)
+
+{
+    int ret;
+
+    prmsg(2,"LocalCloseForCloning(%p->%d)\n", ciptr, ciptr->fd );
+
+    /* Don't unlink path */
+
+    ret=close(ciptr->fd);
+
+    return ret;
+}
+
+
+/*
+ * MakeAllCOTSServerListeners() will go through the entire Xtransports[]
+ * array defined in Xtrans.c and try to OpenCOTSServer() for each entry.
+ * We will add duplicate entries to that table so that the OpenCOTSServer()
+ * function will get called once for each type of local transport.
+ *
+ * The TransName is in lowercase, so it will never match during a normal
+ * call to SelectTransport() in Xtrans.c.
+ */
+
+#ifdef TRANS_SERVER
+static const char * local_aliases[] = {
+# ifdef LOCAL_TRANS_PTS
+                                  "pts",
+# endif
+                                 "named",
+# ifdef sun
+                                 "pipe", /* compatibility with Solaris Xlib */
+# endif
+# ifdef LOCAL_TRANS_SCO
+                                 "sco",
+# endif
+                                 NULL };
+#endif
+
+Xtransport     TRANS(LocalFuncs) = {
+       /* Local Interface */
+       "local",
+       TRANS_ALIAS | TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       local_aliases,
+       TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(LocalReopenCOTSServer),
+       TRANS(LocalReopenCLTSServer),
+#endif
+       TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+       TRANS(LocalCreateListener),
+       TRANS(LocalResetListener),
+       TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(LocalBytesReadable),
+       TRANS(LocalRead),
+       TRANS(LocalWrite),
+       TRANS(LocalReadv),
+       TRANS(LocalWritev),
+       TRANS(LocalDisconnect),
+       TRANS(LocalClose),
+       TRANS(LocalCloseForCloning),
+};
+
+#ifdef LOCAL_TRANS_PTS
+
+Xtransport     TRANS(PTSFuncs) = {
+       /* Local Interface */
+       "pts",
+       TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(LocalReopenCOTSServer),
+       TRANS(LocalReopenCLTSServer),
+#endif
+       TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+       TRANS(LocalCreateListener),
+       TRANS(LocalResetListener),
+       TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(LocalBytesReadable),
+       TRANS(LocalRead),
+       TRANS(LocalWrite),
+       TRANS(LocalReadv),
+       TRANS(LocalWritev),
+       TRANS(LocalDisconnect),
+       TRANS(LocalClose),
+       TRANS(LocalCloseForCloning),
+};
+
+#endif /* LOCAL_TRANS_PTS */
+
+#ifdef LOCAL_TRANS_NAMED
+
+Xtransport     TRANS(NAMEDFuncs) = {
+       /* Local Interface */
+       "named",
+       TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(LocalReopenCOTSServer),
+       TRANS(LocalReopenCLTSServer),
+#endif
+       TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+       TRANS(LocalCreateListener),
+       TRANS(LocalResetListener),
+       TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(LocalBytesReadable),
+       TRANS(LocalRead),
+       TRANS(LocalWrite),
+       TRANS(LocalReadv),
+       TRANS(LocalWritev),
+       TRANS(LocalDisconnect),
+       TRANS(LocalClose),
+       TRANS(LocalCloseForCloning),
+};
+
+#ifdef sun
+Xtransport     TRANS(PIPEFuncs) = {
+       /* Local Interface */
+       "pipe",
+       TRANS_ALIAS | TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(LocalReopenCOTSServer),
+       TRANS(LocalReopenCLTSServer),
+#endif
+       TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+       TRANS(LocalCreateListener),
+       TRANS(LocalResetListener),
+       TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(LocalBytesReadable),
+       TRANS(LocalRead),
+       TRANS(LocalWrite),
+       TRANS(LocalReadv),
+       TRANS(LocalWritev),
+       TRANS(LocalDisconnect),
+       TRANS(LocalClose),
+       TRANS(LocalCloseForCloning),
+};
+#endif /* sun */
+#endif /* LOCAL_TRANS_NAMED */
+
+
+#ifdef LOCAL_TRANS_SCO
+Xtransport     TRANS(SCOFuncs) = {
+       /* Local Interface */
+       "sco",
+       TRANS_LOCAL,
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(LocalOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(LocalOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(LocalReopenCOTSServer),
+       TRANS(LocalReopenCLTSServer),
+#endif
+       TRANS(LocalSetOption),
+#ifdef TRANS_SERVER
+       TRANS(LocalCreateListener),
+       TRANS(LocalResetListener),
+       TRANS(LocalAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(LocalConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(LocalBytesReadable),
+       TRANS(LocalRead),
+       TRANS(LocalWrite),
+       TRANS(LocalReadv),
+       TRANS(LocalWritev),
+       TRANS(LocalDisconnect),
+       TRANS(LocalClose),
+       TRANS(LocalCloseForCloning),
+};
+#endif /* LOCAL_TRANS_SCO */
diff --git a/Xtranssock.c b/Xtranssock.c
new file mode 100644 (file)
index 0000000..dfa41cf
--- /dev/null
@@ -0,0 +1,2484 @@
+/*
+ * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ *
+ * 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 (including the next
+ * paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the copyright holders shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from the copyright holders.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <ctype.h>
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+
+#ifndef WIN32
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#endif
+
+#if defined(TCPCONN) || defined(UNIXCONN)
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <X11/Xos_r.h>
+#endif
+
+#ifdef UNIXCONN
+#ifndef X_NO_SYS_UN
+#include <sys/un.h>
+#endif
+#include <sys/stat.h>
+#endif
+
+
+#ifndef NO_TCP_H
+#if defined(linux) || defined(__GLIBC__)
+#include <sys/param.h>
+#endif /* osf */
+#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#include <sys/param.h>
+#include <machine/endian.h>
+#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */
+#include <netinet/tcp.h>
+#endif /* !NO_TCP_H */
+
+#include <sys/ioctl.h>
+#if defined(SVR4) || defined(__SVR4)
+#include <sys/filio.h>
+#endif
+
+#if (defined(__i386__) && defined(SYSV)) && !defined(SCO325) && !defined(sun)
+#include <net/errno.h>
+#endif
+
+#if defined(__i386__) && defined(SYSV)
+#include <sys/stropts.h>
+#endif
+
+#include <unistd.h>
+
+#else /* !WIN32 */
+
+#include <X11/Xwinsock.h>
+#include <X11/Xwindows.h>
+#include <X11/Xw32defs.h>
+#undef close
+#define close closesocket
+#define ECONNREFUSED WSAECONNREFUSED
+#define EADDRINUSE WSAEADDRINUSE
+#define EPROTOTYPE WSAEPROTOTYPE
+#undef EWOULDBLOCK
+#define EWOULDBLOCK WSAEWOULDBLOCK
+#define EINPROGRESS WSAEINPROGRESS
+#undef EINTR
+#define EINTR WSAEINTR
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_MTSAFE_NETDBAPI
+#include <X11/Xos_r.h>
+#endif /* WIN32 */
+
+#if defined(SO_DONTLINGER) && defined(SO_LINGER)
+#undef SO_DONTLINGER
+#endif
+
+/* others don't need this */
+#define SocketInitOnce() /**/
+
+#ifdef linux
+#define HAVE_ABSTRACT_SOCKETS
+#endif
+
+#define MIN_BACKLOG 128
+#ifdef SOMAXCONN
+#if SOMAXCONN > MIN_BACKLOG
+#define BACKLOG SOMAXCONN
+#endif
+#endif
+#ifndef BACKLOG
+#define BACKLOG MIN_BACKLOG
+#endif
+
+/*
+ * This is the Socket implementation of the X Transport service layer
+ *
+ * This file contains the implementation for both the UNIX and INET domains,
+ * and can be built for either one, or both.
+ *
+ */
+
+typedef struct _Sockettrans2dev {
+    const char *transname;
+    int                family;
+    int                devcotsname;
+    int                devcltsname;
+    int                protocol;
+} Sockettrans2dev;
+
+static Sockettrans2dev Sockettrans2devtab[] = {
+#ifdef TCPCONN
+    {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(IPv6) || !defined(AF_INET6)
+    {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0},
+#else /* IPv6 */
+    {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+    {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */
+    {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0},
+#endif
+#endif /* TCPCONN */
+#ifdef UNIXCONN
+    {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#if !defined(LOCALCONN)
+    {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0},
+#endif /* !LOCALCONN */
+#endif /* UNIXCONN */
+};
+
+#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev))
+
+#ifdef TCPCONN
+static int TRANS(SocketINETClose) (XtransConnInfo ciptr);
+#endif
+
+#ifdef UNIXCONN
+
+
+#if defined(X11_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR "/tmp/.X11-unix"
+#endif /* X11_t */
+#if defined(XIM_t)
+#define UNIX_PATH "/tmp/.XIM-unix/XIM"
+#define UNIX_DIR "/tmp/.XIM-unix"
+#endif /* XIM_t */
+#if defined(FS_t) || defined(FONT_t)
+#define UNIX_PATH "/tmp/.font-unix/fs"
+#define UNIX_DIR "/tmp/.font-unix"
+#endif /* FS_t || FONT_t */
+#if defined(ICE_t)
+#define UNIX_PATH "/tmp/.ICE-unix/"
+#define UNIX_DIR "/tmp/.ICE-unix"
+#endif /* ICE_t */
+#if defined(TEST_t)
+#define UNIX_PATH "/tmp/.Test-unix/test"
+#define UNIX_DIR "/tmp/.Test-unix"
+#endif
+#if defined(LBXPROXY_t)
+#define UNIX_PATH "/tmp/.X11-unix/X"
+#define UNIX_DIR  "/tmp/.X11-unix"
+#endif
+
+
+#endif /* UNIXCONN */
+
+#define PORTBUFSIZE    32
+
+#ifndef MAXHOSTNAMELEN
+#define MAXHOSTNAMELEN 255
+#endif
+
+#if defined HAVE_SOCKLEN_T || (defined(IPv6) && defined(AF_INET6))
+# define SOCKLEN_T socklen_t
+#elif defined(SVR4) || defined(__SVR4) || defined(__SCO__)
+# define SOCKLEN_T size_t
+#else
+# define SOCKLEN_T int
+#endif
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(SocketSelectFamily) (int first, const char *family)
+
+{
+    int     i;
+
+    prmsg (3,"SocketSelectFamily(%s)\n", family);
+
+    for (i = first + 1; i < NUMSOCKETFAMILIES;i++)
+    {
+        if (!strcmp (family, Sockettrans2devtab[i].transname))
+           return i;
+    }
+
+    return (first == -1 ? -2 : -1);
+}
+
+
+/*
+ * This function gets the local address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+    struct sockaddr_storage socknamev6;
+#else
+    struct sockaddr_in socknamev4;
+#endif
+    void *socknamePtr;
+    SOCKLEN_T namelen;
+
+    prmsg (3,"SocketINETGetAddr(%p)\n", ciptr);
+
+#if defined(IPv6) && defined(AF_INET6)
+    namelen = sizeof(socknamev6);
+    socknamePtr = &socknamev6;
+#else
+    namelen = sizeof(socknamev4);
+    socknamePtr = &socknamev4;
+#endif
+
+    bzero(socknamePtr, namelen);
+
+    if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr,
+                    (void *)&namelen) < 0)
+    {
+#ifdef WIN32
+       errno = WSAGetLastError();
+#endif
+       prmsg (1,"SocketINETGetAddr: getsockname() failed: %d\n",
+           EGET());
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if ((ciptr->addr = malloc (namelen)) == NULL)
+    {
+        prmsg (1,
+           "SocketINETGetAddr: Can't allocate space for the addr\n");
+        return -1;
+    }
+
+#if defined(IPv6) && defined(AF_INET6)
+    ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family;
+#else
+    ciptr->family = socknamev4.sin_family;
+#endif
+    ciptr->addrlen = namelen;
+    memcpy (ciptr->addr, socknamePtr, ciptr->addrlen);
+
+    return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+    struct sockaddr_storage socknamev6;
+#endif
+    struct sockaddr_in         socknamev4;
+    void *socknamePtr;
+    SOCKLEN_T namelen;
+
+#if defined(IPv6) && defined(AF_INET6)
+    if (ciptr->family == AF_INET6)
+    {
+       namelen = sizeof(socknamev6);
+       socknamePtr = &socknamev6;
+    }
+    else
+#endif
+    {
+       namelen = sizeof(socknamev4);
+       socknamePtr = &socknamev4;
+    }
+
+    bzero(socknamePtr, namelen);
+
+    prmsg (3,"SocketINETGetPeerAddr(%p)\n", ciptr);
+
+    if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr,
+                    (void *)&namelen) < 0)
+    {
+#ifdef WIN32
+       errno = WSAGetLastError();
+#endif
+       prmsg (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n",
+           EGET());
+       return -1;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if ((ciptr->peeraddr = malloc (namelen)) == NULL)
+    {
+        prmsg (1,
+          "SocketINETGetPeerAddr: Can't allocate space for the addr\n");
+        return -1;
+    }
+
+    ciptr->peeraddrlen = namelen;
+    memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen);
+
+    return 0;
+}
+
+
+static XtransConnInfo
+TRANS(SocketOpen) (int i, int type)
+
+{
+    XtransConnInfo     ciptr;
+
+    prmsg (3,"SocketOpen(%d,%d)\n", i, type);
+
+    if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+    {
+       prmsg (1, "SocketOpen: malloc failed\n");
+       return NULL;
+    }
+
+    if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type,
+       Sockettrans2devtab[i].protocol)) < 0
+#ifndef WIN32
+#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t)
+       || ciptr->fd >= sysconf(_SC_OPEN_MAX)
+#endif
+#endif
+      ) {
+#ifdef WIN32
+       errno = WSAGetLastError();
+#endif
+       prmsg (2, "SocketOpen: socket() failed for %s\n",
+           Sockettrans2devtab[i].transname);
+
+       free (ciptr);
+       return NULL;
+    }
+
+#ifdef TCP_NODELAY
+    if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+      || Sockettrans2devtab[i].family == AF_INET6
+#endif
+    )
+    {
+       /*
+        * turn off TCP coalescence for INET sockets
+        */
+
+       int tmp = 1;
+       setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+           (char *) &tmp, sizeof (int));
+    }
+#endif
+
+    return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopen) (int i _X_UNUSED, int type, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int portlen;
+    struct sockaddr *addr;
+    size_t addrlen;
+
+    prmsg (3,"SocketReopen(%d,%d,%s)\n", type, fd, port);
+
+    if (port == NULL) {
+      prmsg (1, "SocketReopen: port was null!\n");
+      return NULL;
+    }
+
+    portlen = strlen(port) + 1; // include space for trailing null
+#ifdef SOCK_MAXADDRLEN
+    if (portlen < 0 || portlen > (SOCK_MAXADDRLEN + 2)) {
+      prmsg (1, "SocketReopen: invalid portlen %d\n", portlen);
+      return NULL;
+    }
+    if (portlen < 14) portlen = 14;
+#else
+    if (portlen < 0 || portlen > 14) {
+      prmsg (1, "SocketReopen: invalid portlen %d\n", portlen);
+      return NULL;
+    }
+#endif /*SOCK_MAXADDRLEN*/
+
+    if ((ciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+    {
+       prmsg (1, "SocketReopen: malloc(ciptr) failed\n");
+       return NULL;
+    }
+
+    ciptr->fd = fd;
+
+    addrlen = portlen + offsetof(struct sockaddr, sa_data);
+    if ((addr = calloc (1, addrlen)) == NULL) {
+       prmsg (1, "SocketReopen: malloc(addr) failed\n");
+       free (ciptr);
+       return NULL;
+    }
+    ciptr->addr = (char *) addr;
+    ciptr->addrlen = addrlen;
+
+    if ((ciptr->peeraddr = calloc (1, addrlen)) == NULL) {
+       prmsg (1, "SocketReopen: malloc(portaddr) failed\n");
+       free (addr);
+       free (ciptr);
+       return NULL;
+    }
+    ciptr->peeraddrlen = addrlen;
+
+    /* Initialize ciptr structure as if it were a normally-opened unix socket */
+    ciptr->flags = TRANS_LOCAL | TRANS_NOUNLINK;
+#ifdef BSD44SOCKETS
+    addr->sa_len = addrlen;
+#endif
+    addr->sa_family = AF_UNIX;
+#ifdef HAS_STRLCPY
+    strlcpy(addr->sa_data, port, portlen);
+#else
+    strncpy(addr->sa_data, port, portlen);
+#endif
+    ciptr->family = AF_UNIX;
+    memcpy(ciptr->peeraddr, ciptr->addr, addrlen);
+    ciptr->port = rindex(addr->sa_data, ':');
+    if (ciptr->port == NULL) {
+       if (is_numeric(addr->sa_data)) {
+           ciptr->port = addr->sa_data;
+       }
+    } else if (ciptr->port[0] == ':') {
+       ciptr->port++;
+    }
+    /* port should now point to portnum or NULL */
+    return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClientBase) (const char *transname, const char *protocol,
+                          const char *host, const char *port, int previndex)
+{
+    XtransConnInfo     ciptr;
+    int                        i = previndex;
+
+    prmsg (2, "SocketOpenCOTSClient(%s,%s,%s)\n",
+       protocol, host, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) {
+       if ((ciptr = TRANS(SocketOpen) (
+               i, Sockettrans2devtab[i].devcotsname)) != NULL) {
+           /* Save the index for later use */
+
+           ciptr->index = i;
+           break;
+       }
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketOpenCOTSClient: Unable to open socket for %s\n",
+                  transname);
+       else
+           prmsg (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n",
+                  transname);
+       return NULL;
+    }
+
+    return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol,
+                            char *host, char *port)
+{
+    return TRANS(SocketOpenCOTSClientBase)(
+                       thistrans->TransName, protocol, host, port, -1);
+}
+
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol,
+                            char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int        i = -1;
+
+    prmsg (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+       if ((ciptr = TRANS(SocketOpen) (
+                i, Sockettrans2devtab[i].devcotsname)) != NULL)
+           break;
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketOpenCOTSServer: Unable to open socket for %s\n",
+                  thistrans->TransName);
+       else
+           prmsg (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n",
+                  thistrans->TransName);
+       return NULL;
+    }
+
+    /*
+     * Using this prevents the bind() check for an existing server listening
+     * on the same port, but it is required for other reasons.
+     */
+#ifdef SO_REUSEADDR
+
+    /*
+     * SO_REUSEADDR only applied to AF_INET && AF_INET6
+     */
+
+    if (Sockettrans2devtab[i].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+      || Sockettrans2devtab[i].family == AF_INET6
+#endif
+    )
+    {
+       int one = 1;
+       setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR,
+                   (char *) &one, sizeof (int));
+    }
+#endif
+#ifdef IPV6_V6ONLY
+    if (Sockettrans2devtab[i].family == AF_INET6)
+    {
+       int one = 1;
+       setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+    }
+#endif
+    /* Save the index for later use */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol,
+                            char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                        i = -1;
+
+    prmsg (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+       if ((ciptr = TRANS(SocketOpen) (
+                i, Sockettrans2devtab[i].devcotsname)) != NULL)
+           break;
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketOpenCLTSClient: Unable to open socket for %s\n",
+                  thistrans->TransName);
+       else
+           prmsg (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n",
+                  thistrans->TransName);
+       return NULL;
+    }
+
+    /* Save the index for later use */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol,
+                            char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int        i = -1;
+
+    prmsg (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+       if ((ciptr = TRANS(SocketOpen) (
+                i, Sockettrans2devtab[i].devcotsname)) != NULL)
+           break;
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketOpenCLTSServer: Unable to open socket for %s\n",
+                  thistrans->TransName);
+       else
+           prmsg (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n",
+                  thistrans->TransName);
+       return NULL;
+    }
+
+#ifdef IPV6_V6ONLY
+    if (Sockettrans2devtab[i].family == AF_INET6)
+    {
+       int one = 1;
+       setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int));
+    }
+#endif
+    /* Save the index for later use */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                        i = -1;
+
+    prmsg (2,
+       "SocketReopenCOTSServer(%d, %s)\n", fd, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+       if ((ciptr = TRANS(SocketReopen) (
+                i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+           break;
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketReopenCOTSServer: Unable to open socket for %s\n",
+                  thistrans->TransName);
+       else
+           prmsg (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n",
+                  thistrans->TransName);
+       return NULL;
+    }
+
+    /* Save the index for later use */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+static XtransConnInfo
+TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                        i = -1;
+
+    prmsg (2,
+       "SocketReopenCLTSServer(%d, %s)\n", fd, port);
+
+    SocketInitOnce();
+
+    while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) {
+       if ((ciptr = TRANS(SocketReopen) (
+                i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL)
+           break;
+    }
+    if (i < 0) {
+       if (i == -1)
+           prmsg (1,"SocketReopenCLTSServer: Unable to open socket for %s\n",
+                  thistrans->TransName);
+       else
+           prmsg (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n",
+                  thistrans->TransName);
+       return NULL;
+    }
+
+    /* Save the index for later use */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg)
+
+{
+    prmsg (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg);
+
+    return -1;
+}
+
+#ifdef UNIXCONN
+static int
+set_sun_path(const char *port, const char *upath, char *path, int abstract)
+{
+    struct sockaddr_un s;
+    int maxlen = sizeof(s.sun_path) - 1;
+    const char *at = "";
+
+    if (!port || !*port || !path)
+       return -1;
+
+#ifdef HAVE_ABSTRACT_SOCKETS
+    if (port[0] == '@')
+       upath = "";
+    else if (abstract)
+       at = "@";
+#endif
+
+    if (*port == '/') /* a full pathname */
+       upath = "";
+
+    if (strlen(port) + strlen(upath) > maxlen)
+       return -1;
+    snprintf(path, sizeof(s.sun_path), "%s%s%s", at, upath, port);
+    return 0;
+}
+#endif
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(SocketCreateListener) (XtransConnInfo ciptr,
+                            struct sockaddr *sockname,
+                            int socknamelen, unsigned int flags)
+
+{
+    SOCKLEN_T namelen = socknamelen;
+    int        fd = ciptr->fd;
+    int        retry;
+
+    prmsg (3, "SocketCreateListener(%p,%d)\n", ciptr, fd);
+
+    if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+      || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+       )
+       retry = 20;
+    else
+       retry = 0;
+
+    while (bind (fd, (struct sockaddr *) sockname, namelen) < 0)
+    {
+       if (errno == EADDRINUSE) {
+           if (flags & ADDR_IN_USE_ALLOWED)
+               break;
+           else
+               return TRANS_ADDR_IN_USE;
+       }
+
+       if (retry-- == 0) {
+           prmsg (1, "SocketCreateListener: failed to bind listener\n");
+           close (fd);
+           return TRANS_CREATE_LISTENER_FAILED;
+       }
+#ifdef SO_REUSEADDR
+       sleep (1);
+#else
+       sleep (10);
+#endif /* SO_REUSEDADDR */
+    }
+
+    if (Sockettrans2devtab[ciptr->index].family == AF_INET
+#if defined(IPv6) && defined(AF_INET6)
+      || Sockettrans2devtab[ciptr->index].family == AF_INET6
+#endif
+       ) {
+#ifdef SO_DONTLINGER
+       setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else
+#ifdef SO_LINGER
+    {
+       static int linger[2] = { 0, 0 };
+       setsockopt (fd, SOL_SOCKET, SO_LINGER,
+               (char *) linger, sizeof (linger));
+    }
+#endif
+#endif
+}
+
+    if (listen (fd, BACKLOG) < 0)
+    {
+       prmsg (1, "SocketCreateListener: listen() failed\n");
+       close (fd);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    /* Set a flag to indicate that this connection is a listener */
+
+    ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS);
+
+    return 0;
+}
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+#if defined(IPv6) && defined(AF_INET6)
+    struct sockaddr_storage sockname;
+#else
+    struct sockaddr_in     sockname;
+#endif
+    unsigned short         sport;
+    SOCKLEN_T  namelen = sizeof(sockname);
+    int                status;
+    long       tmpport;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+    _Xgetservbynameparams sparams;
+#endif
+    struct servent *servp;
+
+#ifdef X11_t
+    char       portbuf[PORTBUFSIZE];
+#endif
+
+    prmsg (2, "SocketINETCreateListener(%s)\n", port);
+
+#ifdef X11_t
+    /*
+     * X has a well known port, that is transport dependent. It is easier
+     * to handle it here, than try and come up with a transport independent
+     * representation that can be passed in and resolved the usual way.
+     *
+     * The port that is passed here is really a string containing the idisplay
+     * from ConnectDisplay().
+     */
+
+    if (is_numeric (port))
+    {
+       /* fixup the server port address */
+       tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+       snprintf (portbuf, sizeof(portbuf), "%lu", tmpport);
+       port = portbuf;
+    }
+#endif
+
+    if (port && *port)
+    {
+       /* Check to see if the port string is just a number (handles X11) */
+
+       if (!is_numeric (port))
+       {
+           if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL)
+           {
+               prmsg (1,
+            "SocketINETCreateListener: Unable to get service for %s\n",
+                     port);
+               return TRANS_CREATE_LISTENER_FAILED;
+           }
+           /* we trust getservbyname to return a valid number */
+           sport = servp->s_port;
+       }
+       else
+       {
+           tmpport = strtol (port, (char**)NULL, 10);
+           /*
+            * check that somehow the port address isn't negative or in
+            * the range of reserved port addresses. This can happen and
+            * be very bad if the server is suid-root and the user does
+            * something (dumb) like `X :60049`.
+            */
+           if (tmpport < 1024 || tmpport > USHRT_MAX)
+               return TRANS_CREATE_LISTENER_FAILED;
+
+           sport = (unsigned short) tmpport;
+       }
+    }
+    else
+       sport = 0;
+
+    bzero(&sockname, sizeof(sockname));
+#if defined(IPv6) && defined(AF_INET6)
+    if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+       namelen = sizeof (struct sockaddr_in);
+#ifdef BSD44SOCKETS
+       ((struct sockaddr_in *)&sockname)->sin_len = namelen;
+#endif
+       ((struct sockaddr_in *)&sockname)->sin_family = AF_INET;
+       ((struct sockaddr_in *)&sockname)->sin_port = htons(sport);
+       ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY);
+    } else {
+       namelen = sizeof (struct sockaddr_in6);
+#ifdef SIN6_LEN
+       ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname);
+#endif
+       ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6;
+       ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport);
+       ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any;
+    }
+#else
+#ifdef BSD44SOCKETS
+    sockname.sin_len = sizeof (sockname);
+#endif
+    sockname.sin_family = AF_INET;
+    sockname.sin_port = htons (sport);
+    sockname.sin_addr.s_addr = htonl (INADDR_ANY);
+#endif
+
+    if ((status = TRANS(SocketCreateListener) (ciptr,
+       (struct sockaddr *) &sockname, namelen, flags)) < 0)
+    {
+       prmsg (1,
+    "SocketINETCreateListener: ...SocketCreateListener() failed\n");
+       return status;
+    }
+
+    if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+    {
+       prmsg (1,
+       "SocketINETCreateListener: ...SocketINETGetAddr() failed\n");
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    return 0;
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+
+static int
+TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port,
+                                unsigned int flags)
+
+{
+    struct sockaddr_un sockname;
+    int                        namelen;
+    int                        oldUmask;
+    int                        status;
+    unsigned int       mode;
+    char               tmpport[108];
+
+    int                        abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
+
+    prmsg (2, "SocketUNIXCreateListener(%s)\n",
+       port ? port : "NULL");
+
+    /* Make sure the directory is created */
+
+    oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+    mode = 01777;
+#else
+    mode = 0777;
+#endif
+    if (!abstract && trans_mkdir(UNIX_DIR, mode) == -1) {
+       prmsg (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n",
+              UNIX_DIR, errno);
+       (void) umask (oldUmask);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+#endif
+
+    memset(&sockname, 0, sizeof(sockname));
+    sockname.sun_family = AF_UNIX;
+
+    if (!(port && *port)) {
+       snprintf (tmpport, sizeof(tmpport), "%s%ld", UNIX_PATH, (long)getpid());
+       port = tmpport;
+    }
+    if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {
+       prmsg (1, "SocketUNIXCreateListener: path too long\n");
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))
+    sockname.sun_len = strlen(sockname.sun_path);
+#endif
+
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+    namelen = SUN_LEN(&sockname);
+#else
+    namelen = strlen(sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);
+#endif
+
+    if (abstract) {
+       sockname.sun_path[0] = '\0';
+       namelen = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&sockname.sun_path[1]);
+    }
+    else
+       unlink (sockname.sun_path);
+
+    if ((status = TRANS(SocketCreateListener) (ciptr,
+       (struct sockaddr *) &sockname, namelen, flags)) < 0)
+    {
+       prmsg (1,
+    "SocketUNIXCreateListener: ...SocketCreateListener() failed\n");
+       (void) umask (oldUmask);
+       return status;
+    }
+
+    /*
+     * Now that the listener is esablished, create the addr info for
+     * this connection. getpeername() doesn't work for UNIX Domain Sockets
+     * on some systems (hpux at least), so we will just do it manually, instead
+     * of calling something like TRANS(SocketUNIXGetAddr).
+     */
+
+    namelen = sizeof (sockname); /* this will always make it the same size */
+
+    if ((ciptr->addr = malloc (namelen)) == NULL)
+    {
+        prmsg (1,
+        "SocketUNIXCreateListener: Can't allocate space for the addr\n");
+       (void) umask (oldUmask);
+        return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    if (abstract)
+       sockname.sun_path[0] = '@';
+
+    ciptr->family = sockname.sun_family;
+    ciptr->addrlen = namelen;
+    memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+
+    (void) umask (oldUmask);
+
+    return 0;
+}
+
+
+static int
+TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr)
+
+{
+    /*
+     * See if the unix domain socket has disappeared.  If it has, recreate it.
+     */
+
+    struct sockaddr_un         *unsock = (struct sockaddr_un *) ciptr->addr;
+    struct stat                statb;
+    int                status = TRANS_RESET_NOOP;
+    unsigned int       mode;
+    int abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
+
+    prmsg (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd);
+
+    if (!abstract && (
+       stat (unsock->sun_path, &statb) == -1 ||
+        ((statb.st_mode & S_IFMT) !=
+#if defined(NCR) || defined(SCO325) || !defined(S_IFSOCK)
+                       S_IFIFO
+#else
+                       S_IFSOCK
+#endif
+                               )))
+    {
+       int oldUmask = umask (0);
+
+#ifdef UNIX_DIR
+#ifdef HAS_STICKY_DIR_BIT
+       mode = 01777;
+#else
+       mode = 0777;
+#endif
+        if (trans_mkdir(UNIX_DIR, mode) == -1) {
+            prmsg (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n",
+           UNIX_DIR, errno);
+           (void) umask (oldUmask);
+           return TRANS_RESET_FAILURE;
+        }
+#endif
+
+       close (ciptr->fd);
+       unlink (unsock->sun_path);
+
+       if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
+       {
+           TRANS(FreeConnInfo) (ciptr);
+           (void) umask (oldUmask);
+           return TRANS_RESET_FAILURE;
+       }
+
+       if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0)
+       {
+           close (ciptr->fd);
+           TRANS(FreeConnInfo) (ciptr);
+           return TRANS_RESET_FAILURE;
+       }
+
+       if (listen (ciptr->fd, BACKLOG) < 0)
+       {
+           close (ciptr->fd);
+           TRANS(FreeConnInfo) (ciptr);
+           (void) umask (oldUmask);
+           return TRANS_RESET_FAILURE;
+       }
+
+       umask (oldUmask);
+
+       status = TRANS_RESET_NEW_FD;
+    }
+
+    return status;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+
+static XtransConnInfo
+TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status)
+
+{
+    XtransConnInfo     newciptr;
+    struct sockaddr_in sockname;
+    SOCKLEN_T          namelen = sizeof(sockname);
+
+    prmsg (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd);
+
+    if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+    {
+       prmsg (1, "SocketINETAccept: malloc failed\n");
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return NULL;
+    }
+
+    if ((newciptr->fd = accept (ciptr->fd,
+       (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+    {
+#ifdef WIN32
+       errno = WSAGetLastError();
+#endif
+       prmsg (1, "SocketINETAccept: accept() failed\n");
+       free (newciptr);
+       *status = TRANS_ACCEPT_FAILED;
+       return NULL;
+    }
+
+#ifdef TCP_NODELAY
+    {
+       /*
+        * turn off TCP coalescence for INET sockets
+        */
+
+       int tmp = 1;
+       setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY,
+           (char *) &tmp, sizeof (int));
+    }
+#endif
+
+    /*
+     * Get this address again because the transport may give a more
+     * specific address now that a connection is established.
+     */
+
+    if (TRANS(SocketINETGetAddr) (newciptr) < 0)
+    {
+       prmsg (1,
+           "SocketINETAccept: ...SocketINETGetAddr() failed:\n");
+       close (newciptr->fd);
+       free (newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+        return NULL;
+    }
+
+    if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0)
+    {
+       prmsg (1,
+         "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n");
+       close (newciptr->fd);
+       if (newciptr->addr) free (newciptr->addr);
+       free (newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+        return NULL;
+    }
+
+    *status = 0;
+
+    return newciptr;
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static XtransConnInfo
+TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status)
+
+{
+    XtransConnInfo     newciptr;
+    struct sockaddr_un sockname;
+    SOCKLEN_T          namelen = sizeof sockname;
+
+    prmsg (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd);
+
+    if ((newciptr = calloc (1, sizeof(struct _XtransConnInfo))) == NULL)
+    {
+       prmsg (1, "SocketUNIXAccept: malloc() failed\n");
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return NULL;
+    }
+
+    if ((newciptr->fd = accept (ciptr->fd,
+       (struct sockaddr *) &sockname, (void *)&namelen)) < 0)
+    {
+       prmsg (1, "SocketUNIXAccept: accept() failed\n");
+       free (newciptr);
+       *status = TRANS_ACCEPT_FAILED;
+       return NULL;
+    }
+
+       ciptr->addrlen = namelen;
+    /*
+     * Get the socket name and the peer name from the listener socket,
+     * since this is unix domain.
+     */
+
+    if ((newciptr->addr = malloc (ciptr->addrlen)) == NULL)
+    {
+        prmsg (1,
+        "SocketUNIXAccept: Can't allocate space for the addr\n");
+       close (newciptr->fd);
+       free (newciptr);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+        return NULL;
+    }
+
+    /*
+     * if the socket is abstract, we already modified the address to have a
+     * @ instead of the initial NUL, so no need to do that again here.
+     */
+
+    newciptr->addrlen = ciptr->addrlen;
+    memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen);
+
+    if ((newciptr->peeraddr = malloc (ciptr->addrlen)) == NULL)
+    {
+        prmsg (1,
+             "SocketUNIXAccept: Can't allocate space for the addr\n");
+       close (newciptr->fd);
+       if (newciptr->addr) free (newciptr->addr);
+       free (newciptr);
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+        return NULL;
+    }
+
+    newciptr->peeraddrlen = ciptr->addrlen;
+    memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen);
+
+    newciptr->family = AF_UNIX;
+
+    *status = 0;
+
+    return newciptr;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+#ifdef TCPCONN
+
+#if defined(IPv6) && defined(AF_INET6)
+struct addrlist {
+    struct addrinfo *  addr;
+    struct addrinfo *  firstaddr;
+    char               port[PORTBUFSIZE];
+    char               host[MAXHOSTNAMELEN];
+};
+static struct addrlist  *addrlist = NULL;
+#endif
+
+
+static int
+TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+    struct sockaddr *  socketaddr = NULL;
+    int                        socketaddrlen = 0;
+    int                        res;
+#if defined(IPv6) && defined(AF_INET6)
+    struct addrinfo    hints;
+    char               ntopbuf[INET6_ADDRSTRLEN];
+    int                        resetonce = 0;
+#else
+    struct sockaddr_in sockname;
+    struct hostent     *hostp;
+    struct servent     *servp;
+    unsigned long      tmpaddr;
+#endif
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+    _Xgethostbynameparams hparams;
+    _Xgetservbynameparams sparams;
+#endif
+#ifdef X11_t
+    char       portbuf[PORTBUFSIZE];
+#endif
+
+    char               hostnamebuf[256];               /* tmp space */
+
+    prmsg (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+    if (!host)
+    {
+       hostnamebuf[0] = '\0';
+       (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+       host = hostnamebuf;
+    }
+
+#ifdef X11_t
+    /*
+     * X has a well known port, that is transport dependent. It is easier
+     * to handle it here, than try and come up with a transport independent
+     * representation that can be passed in and resolved the usual way.
+     *
+     * The port that is passed here is really a string containing the idisplay
+     * from ConnectDisplay().
+     */
+
+    if (is_numeric (port))
+    {
+       long tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+       snprintf (portbuf, sizeof(portbuf), "%lu", tmpport);
+       port = portbuf;
+    }
+#endif
+
+#if defined(IPv6) && defined(AF_INET6)
+    {
+       if (addrlist != NULL) {
+           if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) {
+               if (addrlist->firstaddr)
+                   freeaddrinfo(addrlist->firstaddr);
+               addrlist->firstaddr = NULL;
+           }
+       } else {
+           addrlist = malloc(sizeof(struct addrlist));
+           addrlist->firstaddr = NULL;
+       }
+
+       if (addrlist->firstaddr == NULL) {
+           strncpy(addrlist->port, port, sizeof(addrlist->port));
+           addrlist->port[sizeof(addrlist->port) - 1] = '\0';
+           strncpy(addrlist->host, host, sizeof(addrlist->host));
+           addrlist->host[sizeof(addrlist->host) - 1] = '\0';
+
+           bzero(&hints,sizeof(hints));
+           hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname;
+
+           res = getaddrinfo(host,port,&hints,&addrlist->firstaddr);
+           if (res != 0) {
+               prmsg (1, "SocketINETConnect() can't get address "
+                       "for %s:%s: %s\n", host, port, gai_strerror(res));
+               ESET(EINVAL);
+               return TRANS_CONNECT_FAILED;
+           }
+           for (res = 0, addrlist->addr = addrlist->firstaddr;
+                addrlist->addr ; res++) {
+               addrlist->addr = addrlist->addr->ai_next;
+           }
+           prmsg(4,"Got New Address list with %d addresses\n", res);
+           res = 0;
+           addrlist->addr = NULL;
+       }
+
+       while (socketaddr == NULL) {
+           if (addrlist->addr == NULL) {
+               if (resetonce) {
+                   /* Already checked entire list - no usable addresses */
+                   prmsg (1, "SocketINETConnect() no usable address "
+                          "for %s:%s\n", host, port);
+                   return TRANS_CONNECT_FAILED;
+               } else {
+                   /* Go back to beginning of list */
+                   resetonce = 1;
+                   addrlist->addr = addrlist->firstaddr;
+               }
+           }
+
+           socketaddr = addrlist->addr->ai_addr;
+           socketaddrlen = addrlist->addr->ai_addrlen;
+
+           if (addrlist->addr->ai_family == AF_INET) {
+               struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr;
+
+               prmsg (4,"SocketINETConnect() sockname.sin_addr = %s\n",
+                       inet_ntop(addrlist->addr->ai_family,&sin->sin_addr,
+                       ntopbuf,sizeof(ntopbuf)));
+
+               prmsg (4,"SocketINETConnect() sockname.sin_port = %d\n",
+                       ntohs(sin->sin_port));
+
+               if (Sockettrans2devtab[ciptr->index].family == AF_INET6) {
+                   if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+                               "tcp") == 0) {
+                       XtransConnInfo newciptr;
+
+                       /*
+                        * Our socket is an IPv6 socket, but the address is
+                        * IPv4.  Close it and get an IPv4 socket.  This is
+                        * needed for IPv4 connections to work on platforms
+                        * that don't allow IPv4 over IPv6 sockets.
+                        */
+                       TRANS(SocketINETClose)(ciptr);
+                       newciptr = TRANS(SocketOpenCOTSClientBase)(
+                                       "tcp", "tcp", host, port, ciptr->index);
+                       if (newciptr)
+                           ciptr->fd = newciptr->fd;
+                       if (!newciptr ||
+                           Sockettrans2devtab[newciptr->index].family !=
+                               AF_INET) {
+                           socketaddr = NULL;
+                           prmsg (4,"SocketINETConnect() Cannot get IPv4 "
+                                       " socketfor IPv4 address\n");
+                       }
+                       if (newciptr)
+                           free(newciptr);
+                   } else {
+                       socketaddr = NULL;
+                       prmsg (4,"SocketINETConnect Skipping IPv4 address\n");
+                   }
+               }
+           } else if (addrlist->addr->ai_family == AF_INET6) {
+               struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr;
+
+               prmsg (4,"SocketINETConnect() sockname.sin6_addr = %s\n",
+                       inet_ntop(addrlist->addr->ai_family,
+                                 &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)));
+               prmsg (4,"SocketINETConnect() sockname.sin6_port = %d\n",
+                       ntohs(sin6->sin6_port));
+
+               if (Sockettrans2devtab[ciptr->index].family == AF_INET) {
+                   if (strcmp(Sockettrans2devtab[ciptr->index].transname,
+                               "tcp") == 0) {
+                       XtransConnInfo newciptr;
+
+                       /*
+                        * Close the IPv4 socket and try to open an IPv6 socket.
+                        */
+                       TRANS(SocketINETClose)(ciptr);
+                       newciptr = TRANS(SocketOpenCOTSClientBase)(
+                                       "tcp", "tcp", host, port, -1);
+                       if (newciptr)
+                           ciptr->fd = newciptr->fd;
+                       if (!newciptr ||
+                           Sockettrans2devtab[newciptr->index].family !=
+                                       AF_INET6) {
+                           socketaddr = NULL;
+                           prmsg (4,"SocketINETConnect() Cannot get IPv6 "
+                                  "socket for IPv6 address\n");
+                       }
+                       if (newciptr)
+                           free(newciptr);
+                   }
+                   else
+                   {
+                       socketaddr = NULL;
+                       prmsg (4,"SocketINETConnect() Skipping IPv6 address\n");
+                   }
+               }
+           } else {
+               socketaddr = NULL; /* Unsupported address type */
+           }
+           if (socketaddr == NULL) {
+               addrlist->addr = addrlist->addr->ai_next;
+           }
+       }
+    }
+#else
+    {
+       /*
+        * Build the socket name.
+        */
+
+#ifdef BSD44SOCKETS
+       sockname.sin_len = sizeof (struct sockaddr_in);
+#endif
+       sockname.sin_family = AF_INET;
+
+       /*
+        * fill in sin_addr
+        */
+
+#ifndef INADDR_NONE
+#define INADDR_NONE ((in_addr_t) 0xffffffff)
+#endif
+
+       /* check for ww.xx.yy.zz host string */
+
+       if (isascii (host[0]) && isdigit (host[0])) {
+           tmpaddr = inet_addr (host); /* returns network byte order */
+       } else {
+           tmpaddr = INADDR_NONE;
+       }
+
+       prmsg (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr);
+
+       if (tmpaddr == INADDR_NONE) {
+           if ((hostp = _XGethostbyname(host,hparams)) == NULL) {
+               prmsg (1,"SocketINETConnect: Can't get address for %s\n",
+                       host);
+               ESET(EINVAL);
+               return TRANS_CONNECT_FAILED;
+           }
+           if (hostp->h_addrtype != AF_INET) {  /* is IP host? */
+               prmsg (1,"SocketINETConnect: not INET host%s\n", host);
+               ESET(EPROTOTYPE);
+               return TRANS_CONNECT_FAILED;
+           }
+
+           memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr,
+                   sizeof (sockname.sin_addr));
+
+       } else {
+           sockname.sin_addr.s_addr = tmpaddr;
+        }
+
+       /*
+        * fill in sin_port
+        */
+
+       /* Check for number in the port string */
+
+       if (!is_numeric (port)) {
+           if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) {
+               prmsg (1,"SocketINETConnect: can't get service for %s\n",
+                       port);
+               return TRANS_CONNECT_FAILED;
+           }
+           sockname.sin_port = htons (servp->s_port);
+       } else {
+           long tmpport = strtol (port, (char**)NULL, 10);
+           if (tmpport < 1024 || tmpport > USHRT_MAX)
+               return TRANS_CONNECT_FAILED;
+           sockname.sin_port = htons (((unsigned short) tmpport));
+       }
+
+       prmsg (4,"SocketINETConnect: sockname.sin_port = %d\n",
+               ntohs(sockname.sin_port));
+       socketaddr = (struct sockaddr *) &sockname;
+       socketaddrlen = sizeof(sockname);
+    }
+#endif
+
+    /*
+     * Turn on socket keepalive so the client process will eventually
+     * be notified with a SIGPIPE signal if the display server fails
+     * to respond to a periodic transmission of messages
+     * on the connected socket.
+     * This is useful to avoid hung application processes when the
+     * processes are not spawned from the xdm session and
+     * the display server terminates abnormally.
+     * (Someone turned off the power switch.)
+     */
+
+    {
+       int tmp = 1;
+       setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE,
+               (char *) &tmp, sizeof (int));
+    }
+
+    /*
+     * Do the connect()
+     */
+
+    if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0)
+    {
+#ifdef WIN32
+       int olderrno = WSAGetLastError();
+#else
+       int olderrno = errno;
+#endif
+
+       /*
+        * If the error was ECONNREFUSED, the server may be overloaded
+        * and we should try again.
+        *
+        * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+        * was non-blocking and we should poll using select
+        *
+        * If the error was EINTR, the connect was interrupted and we
+        * should try again.
+        *
+        * If multiple addresses are found for a host then we should
+        * try to connect again with a different address for a larger
+        * number of errors that made us quit before, since those
+        * could be caused by trying to use an IPv6 address to contact
+        * a machine with an IPv4-only server or other reasons that
+        * only affect one of a set of addresses.
+        */
+
+       if (olderrno == ECONNREFUSED || olderrno == EINTR
+#if defined(IPv6) && defined(AF_INET6)
+         || (((addrlist->addr->ai_next != NULL) ||
+               (addrlist->addr != addrlist->firstaddr)) &&
+               (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT ||
+                olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT
+#if defined(EHOSTDOWN)
+                  || olderrno == EHOSTDOWN
+#endif
+              ))
+#endif
+           )
+           res = TRANS_TRY_CONNECT_AGAIN;
+       else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+           res = TRANS_IN_PROGRESS;
+       else
+       {
+           prmsg (2,"SocketINETConnect: Can't connect: errno = %d\n",
+                  olderrno);
+
+           res = TRANS_CONNECT_FAILED;
+       }
+    } else {
+       res = 0;
+
+
+       /*
+        * Sync up the address fields of ciptr.
+        */
+
+       if (TRANS(SocketINETGetAddr) (ciptr) < 0)
+       {
+           prmsg (1,
+            "SocketINETConnect: ...SocketINETGetAddr() failed:\n");
+           res = TRANS_CONNECT_FAILED;
+       }
+
+       else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0)
+       {
+           prmsg (1,
+             "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n");
+           res = TRANS_CONNECT_FAILED;
+       }
+    }
+
+#if defined(IPv6) && defined(AF_INET6)
+   if (res != 0) {
+       addrlist->addr = addrlist->addr->ai_next;
+   }
+#endif
+
+    return res;
+}
+
+#endif /* TCPCONN */
+
+
+\f
+#ifdef UNIXCONN
+
+/*
+ * Make sure 'host' is really local.
+ */
+
+static int
+UnixHostReallyLocal (char *host)
+
+{
+    char hostnamebuf[256];
+
+    TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
+
+    if (strcmp (hostnamebuf, host) == 0)
+    {
+       return (1);
+    } else {
+#if defined(IPv6) && defined(AF_INET6)
+       struct addrinfo *localhostaddr;
+       struct addrinfo *otherhostaddr;
+       struct addrinfo *i, *j;
+       int equiv = 0;
+
+       if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0)
+           return 0;
+       if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) {
+           freeaddrinfo(localhostaddr);
+           return 0;
+       }
+
+       for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) {
+           for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) {
+               if (i->ai_family == j->ai_family) {
+                   if (i->ai_family == AF_INET) {
+                       struct sockaddr_in *sinA
+                         = (struct sockaddr_in *) i->ai_addr;
+                       struct sockaddr_in *sinB
+                         = (struct sockaddr_in *) j->ai_addr;
+                       struct in_addr *A = &sinA->sin_addr;
+                       struct in_addr *B = &sinB->sin_addr;
+
+                       if (memcmp(A,B,sizeof(struct in_addr)) == 0) {
+                           equiv = 1;
+                       }
+                   } else if (i->ai_family == AF_INET6) {
+                       struct sockaddr_in6 *sinA
+                         = (struct sockaddr_in6 *) i->ai_addr;
+                       struct sockaddr_in6 *sinB
+                         = (struct sockaddr_in6 *) j->ai_addr;
+                       struct in6_addr *A = &sinA->sin6_addr;
+                       struct in6_addr *B = &sinB->sin6_addr;
+
+                       if (memcmp(A,B,sizeof(struct in6_addr)) == 0) {
+                           equiv = 1;
+                       }
+                   }
+               }
+           }
+       }
+
+       freeaddrinfo(localhostaddr);
+       freeaddrinfo(otherhostaddr);
+       return equiv;
+#else
+       /*
+        * A host may have more than one network address.  If any of the
+        * network addresses of 'host' (specified to the connect call)
+        * match any of the network addresses of 'hostname' (determined
+        * by TRANS(GetHostname)), then the two hostnames are equivalent,
+        * and we know that 'host' is really a local host.
+        */
+       char specified_local_addr_list[10][4];
+       int scount, equiv, i, j;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+       _Xgethostbynameparams hparams;
+#endif
+       struct hostent *hostp;
+
+       if ((hostp = _XGethostbyname (host,hparams)) == NULL)
+           return (0);
+
+       scount = 0;
+       while (hostp->h_addr_list[scount] && scount <= 8)
+       {
+           /*
+            * The 2nd call to gethostname() overrides the data
+            * from the 1st call, so we must save the address list.
+            */
+
+           specified_local_addr_list[scount][0] =
+                               hostp->h_addr_list[scount][0];
+           specified_local_addr_list[scount][1] =
+                               hostp->h_addr_list[scount][1];
+           specified_local_addr_list[scount][2] =
+                               hostp->h_addr_list[scount][2];
+           specified_local_addr_list[scount][3] =
+                               hostp->h_addr_list[scount][3];
+           scount++;
+       }
+       if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL)
+           return (0);
+
+       equiv = 0;
+       i = 0;
+
+       while (i < scount && !equiv)
+       {
+           j = 0;
+
+           while (hostp->h_addr_list[j])
+           {
+               if ((specified_local_addr_list[i][0] ==
+                                       hostp->h_addr_list[j][0]) &&
+                   (specified_local_addr_list[i][1] ==
+                                       hostp->h_addr_list[j][1]) &&
+                   (specified_local_addr_list[i][2] ==
+                                       hostp->h_addr_list[j][2]) &&
+                   (specified_local_addr_list[i][3] ==
+                                       hostp->h_addr_list[j][3]))
+               {
+                   /* They're equal, so we're done */
+
+                   equiv = 1;
+                   break;
+               }
+
+               j++;
+           }
+
+           i++;
+       }
+       return (equiv);
+#endif
+    }
+}
+
+static int
+TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port)
+
+{
+    struct sockaddr_un sockname;
+    SOCKLEN_T          namelen;
+
+
+    int abstract = 0;
+#ifdef HAVE_ABSTRACT_SOCKETS
+    abstract = ciptr->transptr->flags & TRANS_ABSTRACT;
+#endif
+
+    prmsg (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port);
+
+    /*
+     * Make sure 'host' is really local.  If not, we return failure.
+     * The reason we make this check is because a process may advertise
+     * a "local" network ID for which it can accept connections, but if
+     * a process on a remote machine tries to connect to this network ID,
+     * we know for sure it will fail.
+     */
+
+    if (host && *host && host[0]!='/' && strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host))
+    {
+       prmsg (1,
+          "SocketUNIXConnect: Cannot connect to non-local host %s\n",
+              host);
+       return TRANS_CONNECT_FAILED;
+    }
+
+
+    /*
+     * Check the port.
+     */
+
+    if (!port || !*port)
+    {
+       prmsg (1,"SocketUNIXConnect: Missing port specification\n");
+       return TRANS_CONNECT_FAILED;
+    }
+
+    /*
+     * Build the socket name.
+     */
+
+    sockname.sun_family = AF_UNIX;
+
+    if (set_sun_path(port, UNIX_PATH, sockname.sun_path, abstract) != 0) {
+       prmsg (1, "SocketUNIXConnect: path too long\n");
+       return TRANS_CONNECT_FAILED;
+    }
+
+#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__))
+    sockname.sun_len = strlen (sockname.sun_path);
+#endif
+
+#if defined(BSD44SOCKETS) || defined(SUN_LEN)
+    namelen = SUN_LEN (&sockname);
+#else
+    namelen = strlen (sockname.sun_path) + offsetof(struct sockaddr_un, sun_path);
+#endif
+
+
+
+    /*
+     * Adjust the socket path if using abstract sockets.
+     * Done here because otherwise all the strlen() calls above would fail.
+     */
+
+    if (abstract) {
+       sockname.sun_path[0] = '\0';
+    }
+
+    /*
+     * Do the connect()
+     */
+
+    if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0)
+    {
+       int olderrno = errno;
+       int connected = 0;
+
+       if (!connected)
+       {
+           errno = olderrno;
+
+           /*
+            * If the error was ENOENT, the server may be starting up; we used
+            * to suggest to try again in this case with
+            * TRANS_TRY_CONNECT_AGAIN, but this introduced problems for
+            * processes still referencing stale sockets in their environment.
+            * Hence, we now return a hard error, TRANS_CONNECT_FAILED, and it
+            * is suggested that higher level stacks handle retries on their
+            * level when they face a slow starting server.
+            *
+            * If the error was EWOULDBLOCK or EINPROGRESS then the socket
+            * was non-blocking and we should poll using select
+            *
+            * If the error was EINTR, the connect was interrupted and we
+            * should try again.
+            */
+
+           if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS)
+               return TRANS_IN_PROGRESS;
+           else if (olderrno == EINTR)
+               return TRANS_TRY_CONNECT_AGAIN;
+           else if (olderrno == ENOENT || olderrno == ECONNREFUSED) {
+               /* If opening as abstract socket failed, try again normally */
+               if (abstract) {
+                   ciptr->transptr->flags &= ~(TRANS_ABSTRACT);
+                   return TRANS_TRY_CONNECT_AGAIN;
+               } else {
+                   return TRANS_CONNECT_FAILED;
+               }
+           } else {
+               prmsg (2,"SocketUNIXConnect: Can't connect: errno = %d\n",
+                      EGET());
+
+               return TRANS_CONNECT_FAILED;
+           }
+       }
+    }
+
+    /*
+     * Get the socket name and the peer name from the connect socket,
+     * since this is unix domain.
+     */
+
+    if ((ciptr->addr = malloc(namelen)) == NULL ||
+       (ciptr->peeraddr = malloc(namelen)) == NULL)
+    {
+        prmsg (1,
+       "SocketUNIXCreateListener: Can't allocate space for the addr\n");
+        return TRANS_CONNECT_FAILED;
+    }
+
+    if (abstract)
+       sockname.sun_path[0] = '@';
+
+    ciptr->family = AF_UNIX;
+    ciptr->addrlen = namelen;
+    ciptr->peeraddrlen = namelen;
+    memcpy (ciptr->addr, &sockname, ciptr->addrlen);
+    memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen);
+
+    return 0;
+}
+
+#endif /* UNIXCONN */
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+    prmsg (2,"SocketBytesReadable(%p,%d,%p)\n",
+       ciptr, ciptr->fd, pend);
+#ifdef WIN32
+    {
+       int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend);
+       if (ret == SOCKET_ERROR) errno = WSAGetLastError();
+       return ret;
+    }
+#else
+#if defined(__i386__) && defined(SYSV) && !defined(SCO325)
+    return ioctl (ciptr->fd, I_NREAD, (char *) pend);
+#else
+    return ioctl (ciptr->fd, FIONREAD, (char *) pend);
+#endif /* __i386__ && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(WIN32)
+    {
+       int ret = recv ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+       if (ret == SOCKET_ERROR) errno = WSAGetLastError();
+#endif
+       return ret;
+    }
+#else
+    return read (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+#if defined(WIN32)
+    {
+       int ret = send ((SOCKET)ciptr->fd, buf, size, 0);
+#ifdef WIN32
+       if (ret == SOCKET_ERROR) errno = WSAGetLastError();
+#endif
+       return ret;
+    }
+#else
+    return write (ciptr->fd, buf, size);
+#endif /* WIN32 */
+}
+
+
+static int
+TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+    return READV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size);
+
+    return WRITEV (ciptr, buf, size);
+}
+
+
+static int
+TRANS(SocketDisconnect) (XtransConnInfo ciptr)
+
+{
+    prmsg (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd);
+
+#ifdef WIN32
+    {
+       int ret = shutdown (ciptr->fd, 2);
+       if (ret == SOCKET_ERROR) errno = WSAGetLastError();
+       return ret;
+    }
+#else
+    return shutdown (ciptr->fd, 2); /* disallow further sends and receives */
+#endif
+}
+
+
+#ifdef TCPCONN
+static int
+TRANS(SocketINETClose) (XtransConnInfo ciptr)
+
+{
+    prmsg (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd);
+
+#ifdef WIN32
+    {
+       int ret = close (ciptr->fd);
+       if (ret == SOCKET_ERROR) errno = WSAGetLastError();
+       return ret;
+    }
+#else
+    return close (ciptr->fd);
+#endif
+}
+
+#endif /* TCPCONN */
+
+
+#ifdef UNIXCONN
+static int
+TRANS(SocketUNIXClose) (XtransConnInfo ciptr)
+{
+    /*
+     * If this is the server side, then once the socket is closed,
+     * it must be unlinked to completely close it
+     */
+
+    struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr;
+    int ret;
+
+    prmsg (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd);
+
+    ret = close(ciptr->fd);
+
+    if (ciptr->flags
+       && sockname
+       && sockname->sun_family == AF_UNIX
+       && sockname->sun_path[0])
+    {
+       if (!(ciptr->flags & TRANS_NOUNLINK
+           || ciptr->transptr->flags & TRANS_ABSTRACT))
+               unlink (sockname->sun_path);
+    }
+
+    return ret;
+}
+
+static int
+TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr)
+
+{
+    /*
+     * Don't unlink path.
+     */
+
+    int ret;
+
+    prmsg (2,"SocketUNIXCloseForCloning(%p,%d)\n",
+       ciptr, ciptr->fd);
+
+    ret = close(ciptr->fd);
+
+    return ret;
+}
+
+#endif /* UNIXCONN */
+
+
+#ifdef TCPCONN
+# ifdef TRANS_SERVER
+static const char* tcp_nolisten[] = {
+       "inet",
+#if defined(IPv6) && defined(AF_INET6)
+       "inet6",
+#endif
+       NULL
+};
+# endif
+
+Xtransport     TRANS(SocketTCPFuncs) = {
+       /* Socket Interface */
+       "tcp",
+        TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       tcp_nolisten,
+       TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(SocketReopenCOTSServer),
+       TRANS(SocketReopenCLTSServer),
+#endif
+       TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+       TRANS(SocketINETCreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(SocketBytesReadable),
+       TRANS(SocketRead),
+       TRANS(SocketWrite),
+       TRANS(SocketReadv),
+       TRANS(SocketWritev),
+       TRANS(SocketDisconnect),
+       TRANS(SocketINETClose),
+       TRANS(SocketINETClose),
+       };
+
+Xtransport     TRANS(SocketINETFuncs) = {
+       /* Socket Interface */
+       "inet",
+       0,
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(SocketReopenCOTSServer),
+       TRANS(SocketReopenCLTSServer),
+#endif
+       TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+       TRANS(SocketINETCreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(SocketBytesReadable),
+       TRANS(SocketRead),
+       TRANS(SocketWrite),
+       TRANS(SocketReadv),
+       TRANS(SocketWritev),
+       TRANS(SocketDisconnect),
+       TRANS(SocketINETClose),
+       TRANS(SocketINETClose),
+       };
+
+#if defined(IPv6) && defined(AF_INET6)
+Xtransport     TRANS(SocketINET6Funcs) = {
+       /* Socket Interface */
+       "inet6",
+       0,
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(SocketReopenCOTSServer),
+       TRANS(SocketReopenCLTSServer),
+#endif
+       TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+       TRANS(SocketINETCreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(SocketINETAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketINETConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(SocketBytesReadable),
+       TRANS(SocketRead),
+       TRANS(SocketWrite),
+       TRANS(SocketReadv),
+       TRANS(SocketWritev),
+       TRANS(SocketDisconnect),
+       TRANS(SocketINETClose),
+       TRANS(SocketINETClose),
+       };
+#endif /* IPv6 */
+#endif /* TCPCONN */
+
+#ifdef UNIXCONN
+#if !defined(LOCALCONN)
+Xtransport     TRANS(SocketLocalFuncs) = {
+       /* Socket Interface */
+       "local",
+#ifdef HAVE_ABSTRACT_SOCKETS
+       TRANS_ABSTRACT,
+#else
+       0,
+#endif
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(SocketReopenCOTSServer),
+       TRANS(SocketReopenCLTSServer),
+#endif
+       TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+       TRANS(SocketUNIXCreateListener),
+       TRANS(SocketUNIXResetListener),
+       TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(SocketBytesReadable),
+       TRANS(SocketRead),
+       TRANS(SocketWrite),
+       TRANS(SocketReadv),
+       TRANS(SocketWritev),
+       TRANS(SocketDisconnect),
+       TRANS(SocketUNIXClose),
+       TRANS(SocketUNIXCloseForCloning),
+       };
+#endif /* !LOCALCONN */
+# ifdef TRANS_SERVER
+#  if !defined(LOCALCONN)
+static char* unix_nolisten[] = { "local" , NULL };
+#  endif
+# endif
+
+Xtransport     TRANS(SocketUNIXFuncs) = {
+       /* Socket Interface */
+       "unix",
+#if !defined(LOCALCONN) && !defined(HAVE_ABSTRACT_SOCKETS)
+        TRANS_ALIAS,
+#else
+       0,
+#endif
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+#if !defined(LOCALCONN)
+       unix_nolisten,
+#else
+       NULL,
+#endif
+       TRANS(SocketOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(SocketOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(SocketReopenCOTSServer),
+       TRANS(SocketReopenCLTSServer),
+#endif
+       TRANS(SocketSetOption),
+#ifdef TRANS_SERVER
+       TRANS(SocketUNIXCreateListener),
+       TRANS(SocketUNIXResetListener),
+       TRANS(SocketUNIXAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(SocketUNIXConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(SocketBytesReadable),
+       TRANS(SocketRead),
+       TRANS(SocketWrite),
+       TRANS(SocketReadv),
+       TRANS(SocketWritev),
+       TRANS(SocketDisconnect),
+       TRANS(SocketUNIXClose),
+       TRANS(SocketUNIXCloseForCloning),
+       };
+
+#endif /* UNIXCONN */
diff --git a/Xtranstli.c b/Xtranstli.c
new file mode 100644 (file)
index 0000000..397c946
--- /dev/null
@@ -0,0 +1,1407 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/un.h>
+#include <stropts.h>
+#include <poll.h>
+#include <tiuser.h>
+
+#include <netdir.h>
+#include <netconfig.h>
+
+
+/*
+ * This is the TLI implementation of the X Transport service layer
+ */
+
+typedef struct _TLItrans2dev {
+    char       *transname;
+    char       *protofamily;
+    char       *devcotsname;
+    char       *devcltsname;
+    int        family;
+} TLItrans2dev;
+
+static TLItrans2dev TLItrans2devtab[] = {
+       {"inet","inet","/dev/tcp","/dev/udp",AF_INET},
+       {"tcp","inet","/dev/tcp","/dev/udp",AF_INET},
+       {"tli","loopback","/dev/ticots","/dev/ticlts",AF_UNIX},
+};
+
+#define NUMTLIFAMILIES (sizeof(TLItrans2devtab)/sizeof(TLItrans2dev))
+
+/*
+ * The local TLI connection, is a form of a local connection, so use a
+ * sockaddr_un for the address so that it will be treated just like the other
+ * local transports such as UNIX domain sockets, pts, and named.
+ */
+
+#if defined(X11_t)
+#define TLINODENAME    "TLI:xserver"
+#endif
+
+#if defined(XIM_t)
+#define TLINODENAME    "TLI:xim"
+#endif
+
+#if defined(FS_t) || defined(FONT_t)
+#define TLINODENAME    "TLI:fontserver"
+#endif
+
+#if defined(ICE_t)
+#define TLINODENAME    "TLI:ICE"
+#endif
+
+#if defined(TEST_t)
+#define TLINODENAME    "TLI:test"
+#endif
+
+#ifndef PORTBUFSIZE
+#ifdef TRANS_SERVER
+#define PORTBUFSIZE    64
+#else
+#ifdef TRANS_CLIENT
+#define PORTBUFSIZE    64
+#endif
+#endif
+#endif
+
+
+/*
+ * These are some utility function used by the real interface function below.
+ */
+
+static int
+TRANS(TLISelectFamily)(char *family)
+
+{
+    int     i;
+
+    prmsg(3,"TLISelectFamily(%s)\n", family);
+
+    for(i=0;i<NUMTLIFAMILIES;i++)
+    {
+       if( !strcmp(family,TLItrans2devtab[i].transname) )
+           return i;
+    }
+    return -1;
+}
+
+
+/*
+ * This function gets the local address of the transport and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(TLIGetAddr)(XtransConnInfo ciptr)
+
+{
+    Xtransaddr         sockname;
+    struct netbuf      netbuf;
+
+    prmsg(3,"TLIGetAddr(%x)\n", ciptr);
+
+    netbuf.buf=(char *)&sockname;
+    netbuf.len=sizeof(sockname);
+    netbuf.maxlen=sizeof(sockname);
+
+    if( t_getname(ciptr->fd,&netbuf,LOCALNAME) < 0 )
+    {
+       prmsg(1,"TLIGetAddr: t_getname(LOCALNAME) failed: %d\n",
+             errno);
+       return -1;
+    }
+
+    prmsg(4,"TLIGetAddr: got family %d len %d\n",
+         ((struct sockaddr *) &sockname)->sa_family ,netbuf.len);
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if( ciptr->addr )
+       free(ciptr->addr);
+
+    if( (ciptr->addr = malloc(netbuf.len)) == NULL )
+    {
+       prmsg(1, "TLIGetAddr: Can't allocate space for the addr\n");
+       return -1;
+    }
+
+    ciptr->family=((struct sockaddr *) &sockname)->sa_family;
+    ciptr->addrlen=netbuf.len;
+    memcpy(ciptr->addr,&sockname,ciptr->addrlen);
+
+    return 0;
+}
+
+
+/*
+ * This function gets the remote address of the socket and stores it in the
+ * XtransConnInfo structure for the connection.
+ */
+
+static int
+TRANS(TLIGetPeerAddr)(XtransConnInfo ciptr)
+
+{
+    Xtransaddr         sockname;
+    struct netbuf      netbuf;
+
+    prmsg(3,"TLIGetPeerAddr(%x)\n", ciptr);
+
+    netbuf.buf=(char *)&sockname;
+    netbuf.len=sizeof(sockname);
+    netbuf.maxlen=sizeof(sockname);
+
+    if( t_getname(ciptr->fd,&netbuf,REMOTENAME) < 0 )
+    {
+       prmsg(1,"TLIGetPeerAddr: t_getname(REMOTENAME) failed: %d\n",
+             errno);
+       return -1;
+    }
+
+    prmsg(4,"TLIGetPeerAddr: got family %d len %d\n",
+         ((struct sockaddr *) &sockname)->sa_family ,netbuf.len);
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if( ciptr->peeraddr )
+       free(ciptr->peeraddr);
+
+    if( (ciptr->peeraddr = malloc(netbuf.len)) == NULL )
+    {
+       prmsg(1,
+             "TLIGetPeerAddr: Can't allocate space for the addr\n");
+       return -1;
+    }
+
+    ciptr->peeraddrlen=netbuf.len;
+    memcpy(ciptr->peeraddr,&sockname,ciptr->peeraddrlen);
+
+    return 0;
+}
+
+
+/*
+ * This function will establish a local name for the transport. This function
+ * do extra work for the local tli connection. It must create a sockaddr_un
+ * format address so that it will look like an AF_UNIX connection to the
+ * higher layer.
+ *
+ * This function will only be called by the OPENC?TSClient() functions since
+ * the local address is set up in the CreateListner() for the server ends.
+ */
+
+static int
+TRANS(TLITLIBindLocal)(int fd, int family, char *port)
+
+{
+    struct sockaddr_un *sunaddr=NULL;
+    struct t_bind      *req=NULL;
+
+    prmsg(2, "TLITLIBindLocal(%d,%d,%s)\n", fd, family, port);
+
+    if( family == AF_UNIX )
+    {
+       if( (req=(struct t_bind *)t_alloc(fd,T_BIND,0)) == NULL )
+       {
+           prmsg(1,
+                 "TLITLIBindLocal() failed to allocate a t_bind\n");
+           return -1;
+       }
+
+       if( (sunaddr=(struct sockaddr_un *)
+            malloc(sizeof(struct sockaddr_un))) == NULL )
+       {
+           prmsg(1,
+                 "TLITLIBindLocal: failed to allocate a sockaddr_un\n");
+           t_free((char *)req,T_BIND);
+           return -1;
+       }
+
+       sunaddr->sun_family=AF_UNIX;
+
+#ifdef nuke
+       if( *port == '/' ) { /* A full pathname */
+           (void) strcpy(sunaddr->sun_path, port);
+       } else {
+           (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+       }
+#endif /*NUKE*/
+
+       (void) sprintf(sunaddr->sun_path,"%s%d",
+                      TLINODENAME, getpid()^time(NULL) );
+
+       prmsg(4, "TLITLIBindLocal: binding to %s\n",
+             sunaddr->sun_path);
+
+       req->addr.buf=(char *)sunaddr;
+       req->addr.len=sizeof(*sunaddr);
+       req->addr.maxlen=sizeof(*sunaddr);
+    }
+
+    if( t_bind(fd, req, NULL) < 0 )
+    {
+       prmsg(1,
+             "TLIBindLocal: Unable to bind TLI device to %s\n",
+             port);
+       if (sunaddr)
+           free((char *) sunaddr);
+       if (req)
+           t_free((char *)req,T_BIND);
+       return -1;
+    }
+    return 0;
+}
+
+static XtransConnInfo
+TRANS(TLIOpen)(char *device)
+
+{
+    XtransConnInfo     ciptr;
+
+    prmsg(3,"TLIOpen(%s)\n", device);
+
+    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+    {
+       prmsg(1, "TLIOpen: calloc failed\n");
+       return NULL;
+    }
+
+    if( (ciptr->fd=t_open( device, O_RDWR, NULL )) < 0 )
+    {
+       prmsg(1, "TLIOpen: t_open failed for %s\n", device);
+       free(ciptr);
+       return NULL;
+    }
+
+    return ciptr;
+}
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(TLIReopen)(char *device, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+
+    prmsg(3,"TLIReopen(%s,%d, %s)\n", device, fd, port );
+
+    if (t_sync (fd) < 0)
+    {
+       prmsg(1, "TLIReopen: t_sync failed\n");
+       return NULL;
+    }
+
+    if( (ciptr = calloc(1,sizeof(struct _XtransConnInfo))) == NULL )
+    {
+       prmsg(1, "TLIReopen: calloc failed\n");
+       return NULL;
+    }
+
+    ciptr->fd = fd;
+
+    return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(TLIAddrToNetbuf)(int tlifamily, char *host, char *port,
+                      struct netbuf *netbufp)
+
+{
+    struct netconfig *netconfigp;
+    struct nd_hostserv nd_hostserv;
+    struct nd_addrlist *nd_addrlistp = NULL;
+    void *handlep;
+    long lport;
+
+    prmsg(3,"TLIAddrToNetbuf(%d,%s,%s)\n", tlifamily, host, port );
+
+    if( (handlep=setnetconfig()) == NULL )
+       return -1;
+
+    lport = strtol (port, (char**)NULL, 10);
+    if (lport < 1024 || lport > USHRT_MAX)
+       return -1;
+
+    nd_hostserv.h_host = host;
+    if( port && *port ) {
+       nd_hostserv.h_serv = port;
+    } else {
+       nd_hostserv.h_serv = NULL;
+    }
+
+    while( (netconfigp=getnetconfig(handlep)) != NULL )
+    {
+       if( strcmp(netconfigp->nc_protofmly,
+                  TLItrans2devtab[tlifamily].protofamily) != 0 )
+           continue;
+       prmsg(5,"TLIAddrToNetbuf: Trying to resolve %s.%s for %s\n",
+             host, port, TLItrans2devtab[tlifamily].protofamily );
+       if( netdir_getbyname(netconfigp,&nd_hostserv, &nd_addrlistp) == 0 )
+       {
+           /* we have at least one address to use */
+
+           prmsg(5, "TLIAddrToNetbuf: found address for %s.%s\n", host, port);
+           prmsg(5, "TLIAddrToNetbuf: %s\n",taddr2uaddr(netconfigp,nd_addrlistp->n_addrs));
+
+           memcpy(netbufp->buf,nd_addrlistp->n_addrs->buf,
+                  nd_addrlistp->n_addrs->len);
+           netbufp->len=nd_addrlistp->n_addrs->len;
+           endnetconfig(handlep);
+           return 0;
+       }
+    }
+    endnetconfig(handlep);
+
+    return -1;
+}
+
+/*
+ * These functions are the interface supplied in the Xtransport structure
+ */
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(TLIOpenCOTSClient)(Xtransport *thistrans, char *protocol,
+                        char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                i;
+
+    prmsg(2,"TLIOpenCOTSClient(%s,%s,%s)\n", protocol, host, port );
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,"TLIOpenCOTSClient: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+    {
+       prmsg(1,"TLIOpenCOTSClient: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCOTSClient: ...TLITLIBindLocal() failed: %d\n",
+             errno);
+       t_close(ciptr->fd);
+       free(ciptr);
+       return NULL;
+    }
+
+    if( TRANS(TLIGetAddr)(ciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCOTSClient: ...TLIGetAddr() failed: %d\n",
+             errno);
+       t_close(ciptr->fd);
+       free(ciptr);
+       return NULL;
+    }
+
+    /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(TLIOpenCOTSServer)(Xtransport *thistrans, char *protocol,
+                        char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                i;
+
+    prmsg(2,"TLIOpenCOTSServer(%s,%s,%s)\n", protocol, host, port );
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCOTSServer: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+    {
+       prmsg(1,
+             "TLIOpenCOTSServer: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    /* Set the family type */
+
+    ciptr->family = TLItrans2devtab[i].family;
+
+
+    /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static XtransConnInfo
+TRANS(TLIOpenCLTSClient)(Xtransport *thistrans, char *protocol,
+                        char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                i;
+
+    prmsg(2,"TLIOpenCLTSClient(%s,%s,%s)\n", protocol, host, port );
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCLTSClient: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL )
+    {
+       prmsg(1,
+             "TLIOpenCLTSClient: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( TRANS(TLITLIBindLocal)(ciptr->fd,TLItrans2devtab[i].family,port) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCLTSClient: ...TLITLIBindLocal() failed: %d\n",
+             errno);
+       t_close(ciptr->fd);
+       free(ciptr);
+       return NULL;
+    }
+
+    if( TRANS(TLIGetAddr)(ciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCLTSClient: ...TLIGetPeerAddr() failed: %d\n",
+             errno);
+       t_close(ciptr->fd);
+       free(ciptr);
+       return NULL;
+    }
+
+    return ciptr;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+#ifdef TRANS_SERVER
+
+static XtransConnInfo
+TRANS(TLIOpenCLTSServer)(Xtransport *thistrans, char *protocol,
+                        char *host, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                i;
+
+    prmsg(2,"TLIOpenCLTSServer(%s,%s,%s)\n", protocol, host, port );
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,
+             "TLIOpenCLTSServer: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcltsname)) == NULL )
+    {
+       prmsg(1,
+             "TLIOpenCLTSServer: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    return ciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_REOPEN
+
+static XtransConnInfo
+TRANS(TLIReopenCOTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                        i;
+
+    prmsg(2,"TLIReopenCOTSServer(%d, %s)\n", fd, port);
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,
+             "TLIReopenCOTSServer: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIReopen)(
+       TLItrans2devtab[i].devcotsname, fd, port)) == NULL )
+    {
+       prmsg(1,
+             "TLIReopenCOTSServer: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    /* Save the TLIFamily for later use in TLIAddrToNetbuf() lookups */
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+
+static XtransConnInfo
+TRANS(TLIReopenCLTSServer)(Xtransport *thistrans, int fd, char *port)
+
+{
+    XtransConnInfo     ciptr;
+    int                i;
+
+    prmsg(2,"TLIReopenCLTSServer(%d, %s)\n", fd, port);
+
+    if( (i=TRANS(TLISelectFamily)(thistrans->TransName)) < 0 )
+    {
+       prmsg(1,
+             "TLIReopenCLTSServer: Unable to determine device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    if( (ciptr=TRANS(TLIReopen)(
+       TLItrans2devtab[i].devcltsname, fd, port)) == NULL )
+    {
+       prmsg(1,
+             "TLIReopenCLTSServer: Unable to open device for %s\n",
+             thistrans->TransName);
+       return NULL;
+    }
+
+    ciptr->index = i;
+
+    return ciptr;
+}
+
+#endif /* TRANS_REOPEN */
+
+
+static int
+TRANS(TLISetOption)(XtransConnInfo ciptr, int option, int arg)
+
+{
+    prmsg(2,"TLISetOption(%d,%d,%d)\n", ciptr->fd, option, arg );
+
+    return -1;
+}
+
+
+#ifdef TRANS_SERVER
+
+static int
+TRANS(TLICreateListener)(XtransConnInfo ciptr, struct t_bind *req)
+
+{
+    struct t_bind      *ret;
+
+    prmsg(2,"TLICreateListener(%x->%d,%x)\n", ciptr, ciptr->fd, req );
+
+    if( (ret=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL )
+    {
+       prmsg(1, "TLICreateListener: failed to allocate a t_bind\n");
+       t_free((char *)req,T_BIND);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    if( t_bind(ciptr->fd, req, ret) < 0 )
+    {
+       prmsg(1, "TLICreateListener: t_bind failed\n");
+       t_free((char *)req,T_BIND);
+       t_free((char *)ret,T_BIND);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    if( memcmp(req->addr.buf,ret->addr.buf,req->addr.len) != 0 )
+    {
+       prmsg(1, "TLICreateListener: unable to bind to %x\n",
+             req);
+       t_free((char *)req,T_BIND);
+       t_free((char *)ret,T_BIND);
+       return TRANS_ADDR_IN_USE;
+    }
+
+    /*
+     * Everything looks good: fill in the XtransConnInfo structure.
+     */
+
+    if( (ciptr->addr = malloc(ret->addr.len)) == NULL )
+    {
+       prmsg(1,
+             "TLICreateListener: Unable to allocate space for the address\n");
+       t_free((char *)req,T_BIND);
+       t_free((char *)ret, T_BIND);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    ciptr->addrlen=ret->addr.len;
+    memcpy(ciptr->addr,ret->addr.buf,ret->addr.len);
+
+    t_free((char *)req,T_BIND);
+    t_free((char *)ret, T_BIND);
+
+    return 0;
+}
+
+
+static int
+TRANS(TLIINETCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+    char    portbuf[PORTBUFSIZE];
+    struct t_bind      *req;
+    struct sockaddr_in *sinaddr;
+    long               tmpport;
+
+    prmsg(2,"TLIINETCreateListener(%x->%d,%s)\n", ciptr,
+       ciptr->fd, port ? port : "NULL" );
+
+#ifdef X11_t
+    /*
+     * X has a well known port, that is transport dependent. It is easier
+     * to handle it here, than try and come up with a transport independent
+     * representation that can be passed in and resolved the usual way.
+     *
+     * The port that is passed here is really a string containing the idisplay
+     * from ConnectDisplay().
+     */
+
+    if (is_numeric (port))
+    {
+       tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+       sprintf(portbuf,"%u", tmpport);
+       port = portbuf;
+    }
+#endif
+
+    if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,T_ALL)) == NULL )
+    {
+       prmsg(1,
+           "TLIINETCreateListener: failed to allocate a t_bind\n");
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    if( port && *port ) {
+       if(TRANS(TLIAddrToNetbuf)(ciptr->index,HOST_SELF,port,&(req->addr)) < 0)
+       {
+           prmsg(1,
+                 "TLIINETCreateListener: can't resolve name:HOST_SELF.%s\n",
+                 port);
+           t_free((char *)req,T_BIND);
+           return TRANS_CREATE_LISTENER_FAILED;
+       }
+    } else {
+       sinaddr=(struct sockaddr_in *) req->addr.buf;
+       sinaddr->sin_family=AF_INET;
+       sinaddr->sin_port=htons(0);
+       sinaddr->sin_addr.s_addr=0;
+    }
+
+    /* Set the qlen */
+
+    req->qlen=1;
+
+    return TRANS(TLICreateListener)(ciptr, req);
+}
+
+
+static int
+TRANS(TLITLICreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
+
+{
+    struct t_bind      *req;
+    struct sockaddr_un *sunaddr;
+    int                ret_value;
+
+    prmsg(2,"TLITLICreateListener(%x->%d,%s)\n", ciptr, ciptr->fd,
+       port ? port : "NULL");
+
+    if( (req=(struct t_bind *)t_alloc(ciptr->fd,T_BIND,0)) == NULL )
+    {
+       prmsg(1,
+             "TLITLICreateListener: failed to allocate a t_bind\n");
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    if( (sunaddr=(struct sockaddr_un *)
+        malloc(sizeof(struct sockaddr_un))) == NULL )
+    {
+       prmsg(1,
+             "TLITLICreateListener: failed to allocate a sockaddr_un\n");
+       t_free((char *)req,T_BIND);
+       return TRANS_CREATE_LISTENER_FAILED;
+    }
+
+    sunaddr->sun_family=AF_UNIX;
+    if( port && *port ) {
+       if( *port == '/' ) { /* A full pathname */
+           (void) strcpy(sunaddr->sun_path, port);
+       } else {
+           (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+       }
+    } else {
+       (void) sprintf(sunaddr->sun_path,"%s%d", TLINODENAME, getpid());
+    }
+
+    req->addr.buf=(char *)sunaddr;
+    req->addr.len=sizeof(*sunaddr);
+    req->addr.maxlen=sizeof(*sunaddr);
+
+    /* Set the qlen */
+
+    req->qlen=1;
+
+    ret_value = TRANS(TLICreateListener)(ciptr, req);
+
+    free((char *) sunaddr);
+
+    return ret_value;
+}
+
+
+static XtransConnInfo
+TRANS(TLIAccept)(XtransConnInfo ciptr, int *status)
+
+{
+    struct t_call      *call;
+    XtransConnInfo     newciptr;
+    int        i;
+
+    prmsg(2,"TLIAccept(%x->%d)\n", ciptr, ciptr->fd);
+
+    if( (call=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL )
+    {
+       prmsg(1, "TLIAccept() failed to allocate a t_call\n");
+       *status = TRANS_ACCEPT_BAD_MALLOC;
+       return NULL;
+    }
+
+    if( t_listen(ciptr->fd,call) < 0 )
+    {
+       extern char *t_errlist[];
+       extern int t_errno;
+       prmsg(1, "TLIAccept() t_listen() failed\n");
+       prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]);
+       t_free((char *)call,T_CALL);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    /*
+     * Now we need to set up the new endpoint for the incoming connection.
+     */
+
+    i=ciptr->index; /* Makes the next line more readable */
+
+    if( (newciptr=TRANS(TLIOpen)(TLItrans2devtab[i].devcotsname)) == NULL )
+    {
+       prmsg(1, "TLIAccept() failed to open a new endpoint\n");
+       t_free((char *)call,T_CALL);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    if( TRANS(TLITLIBindLocal)(newciptr->fd,TLItrans2devtab[i].family,"") < 0 )
+    {
+       prmsg(1,
+             "TLIAccept: TRANS(TLITLIBindLocal)() failed: %d\n",
+             errno);
+       t_free((char *)call,T_CALL);
+       t_close(newciptr->fd);
+       free(newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+
+    if( t_accept(ciptr->fd,newciptr->fd,call) < 0 )
+    {
+       extern char *t_errlist[];
+       extern int t_errno;
+       prmsg(1, "TLIAccept() t_accept() failed\n");
+       prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]);
+       if( t_errno == TLOOK )
+       {
+           int evtype = t_look(ciptr->fd);
+           prmsg(1, "TLIAccept() t_look() returned %d\n", evtype);
+           switch( evtype )
+           {
+               case T_DISCONNECT:
+                   if( t_rcvdis(ciptr->fd, NULL) < 0 )
+                   {
+                       prmsg(1, "TLIAccept() t_rcvdis() failed\n");
+                       prmsg(1, "TLIAccept: %s\n", t_errlist[t_errno]);
+                   }
+                   break;
+               default:
+                   break;
+           }
+       }
+       t_free((char *)call,T_CALL);
+       t_close(newciptr->fd);
+       free(newciptr);
+       *status = TRANS_ACCEPT_FAILED;
+       return NULL;
+    }
+
+    t_free((char *)call,T_CALL);
+
+    if( TRANS(TLIGetAddr)(newciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
+             errno);
+       t_close(newciptr->fd);
+       free(newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    if( TRANS(TLIGetPeerAddr)(newciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIAccept: TRANS(TLIGetPeerAddr)() failed: %d\n",
+             errno);
+       t_close(newciptr->fd);
+       free(newciptr->addr);
+       free(newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    if( ioctl(newciptr->fd, I_POP,"timod") < 0 )
+    {
+       prmsg(1, "TLIAccept() ioctl(I_POP, \"timod\") failed %d\n",
+             errno);
+       t_close(newciptr->fd);
+       free(newciptr->addr);
+       free(newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    if( ioctl(newciptr->fd, I_PUSH,"tirdwr") < 0 )
+    {
+       prmsg(1, "TLIAccept() ioctl(I_PUSH,\"tirdwr\") failed %d\n",
+             errno);
+       t_close(newciptr->fd);
+       free(newciptr->addr);
+       free(newciptr);
+       *status = TRANS_ACCEPT_MISC_ERROR;
+       return NULL;
+    }
+
+    *status = 0;
+
+    return newciptr;
+}
+
+#endif /* TRANS_SERVER */
+
+
+#ifdef TRANS_CLIENT
+
+static int
+TRANS(TLIConnect)(XtransConnInfo ciptr, struct t_call *sndcall )
+
+{
+    prmsg(2, "TLIConnect(%x->%d,%x)\n", ciptr, ciptr->fd, sndcall);
+
+    if( t_connect(ciptr->fd,sndcall,NULL) < 0 )
+    {
+       extern char *t_errlist[];
+       extern int t_errno;
+       prmsg(1, "TLIConnect() t_connect() failed\n");
+       prmsg(1, "TLIConnect: %s\n", t_errlist[t_errno]);
+       t_free((char *)sndcall,T_CALL);
+       if (t_errno == TLOOK && t_look(ciptr->fd) == T_DISCONNECT)
+       {
+           t_rcvdis(ciptr->fd,NULL);
+           return TRANS_TRY_CONNECT_AGAIN;
+       }
+       else
+           return TRANS_CONNECT_FAILED;
+    }
+
+    t_free((char *)sndcall,T_CALL);
+
+    /*
+     * Sync up the address fields of ciptr.
+     */
+
+    if( TRANS(TLIGetAddr)(ciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIConnect: ...TLIGetAddr() failed: %d\n",
+             errno);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    if( TRANS(TLIGetPeerAddr)(ciptr) < 0 )
+    {
+       prmsg(1,
+             "TLIConnect: ...TLIGetPeerAddr() failed: %d\n",
+             errno);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    if( ioctl(ciptr->fd, I_POP,"timod") < 0 )
+    {
+       prmsg(1, "TLIConnect() ioctl(I_POP,\"timod\") failed %d\n",
+             errno);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    if( ioctl(ciptr->fd, I_PUSH,"tirdwr") < 0 )
+    {
+       prmsg(1, "TLIConnect() ioctl(I_PUSH,\"tirdwr\") failed %d\n",
+             errno);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    return 0;
+}
+
+
+static int
+TRANS(TLIINETConnect)(XtransConnInfo ciptr, char *host, char *port)
+
+{
+    char       portbuf[PORTBUFSIZE];
+    struct     t_call  *sndcall;
+    long       tmpport;
+
+    prmsg(2, "TLIINETConnect(%s,%s)\n", host, port);
+
+#ifdef X11_t
+    /*
+     * X has a well known port, that is transport dependant. It is easier
+     * to handle it here, than try and come up with a transport independent
+     * representation that can be passed in and resolved the usual way.
+     *
+     * The port that is passed here is really a string containing the idisplay
+     * from ConnectDisplay().
+     */
+
+    if (is_numeric (port))
+    {
+       tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10);
+       sprintf(portbuf,"%u", tmpport );
+       port = portbuf;
+    }
+#endif
+
+    if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_ALL)) == NULL )
+    {
+       prmsg(1, "TLIINETConnect() failed to allocate a t_call\n");
+       return TRANS_CONNECT_FAILED;
+    }
+
+    if( TRANS(TLIAddrToNetbuf)(ciptr->index, host, port, &(sndcall->addr) ) < 0 )
+    {
+       prmsg(1, "TLIINETConnect() unable to resolve name:%s.%s\n",
+             host, port);
+       t_free((char *)sndcall,T_CALL);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    return TRANS(TLIConnect)(ciptr, sndcall );
+}
+
+
+static int
+TRANS(TLITLIConnect)(XtransConnInfo ciptr, char *host, char *port)
+
+{
+    struct t_call      *sndcall;
+    struct sockaddr_un *sunaddr;
+    int                        ret_value;
+
+    prmsg(2, "TLITLIConnect(%s,%s)\n", host, port);
+
+    if( (sndcall=(struct t_call *)t_alloc(ciptr->fd,T_CALL,T_OPT|T_UDATA)) == NULL )
+    {
+       prmsg(1, "TLITLIConnect() failed to allocate a t_call\n");
+       return TRANS_CONNECT_FAILED;
+    }
+
+    if( (sunaddr=(struct sockaddr_un *)
+        malloc(sizeof(struct sockaddr_un))) == NULL )
+    {
+       prmsg(1,
+             "TLITLIConnect: failed to allocate a sockaddr_un\n");
+       t_free((char *)sndcall,T_CALL);
+       return TRANS_CONNECT_FAILED;
+    }
+
+    sunaddr->sun_family=AF_UNIX;
+    if( *port == '/' ||
+       strncmp (port, TLINODENAME, strlen (TLINODENAME)) == 0) {
+       /* Use the port as is */
+       (void) strcpy(sunaddr->sun_path, port);
+    } else {
+       (void) sprintf(sunaddr->sun_path,"%s%s", TLINODENAME, port );
+    }
+
+    sndcall->addr.buf=(char *)sunaddr;
+    sndcall->addr.len=sizeof(*sunaddr);
+    sndcall->addr.maxlen=sizeof(*sunaddr);
+
+    ret_value = TRANS(TLIConnect)(ciptr, sndcall );
+
+    free((char *) sunaddr);
+
+    return ret_value;
+}
+
+#endif /* TRANS_CLIENT */
+
+
+static int
+TRANS(TLIBytesReadable)(XtransConnInfo ciptr, BytesReadable_t *pend)
+
+{
+    int ret;
+    struct pollfd filedes;
+
+    prmsg(2, "TLIByteReadable(%x->%d,%x)\n", ciptr, ciptr->fd, pend );
+
+    /*
+     * This function should detect hangup conditions. Use poll to check
+     * if no data is present. On SVR4, the M_HANGUP message sits on the
+     * streams head, and ioctl(N_READ) keeps returning 0 because there is
+     * no data available. The hangup goes undetected, and the client hangs.
+     */
+
+    ret=ioctl(ciptr->fd, I_NREAD, (char *)pend);
+
+    if( ret != 0 )
+       return ret; /* Data present or error */
+
+
+    /* Zero data, or POLLHUP message */
+
+    filedes.fd=ciptr->fd;
+    filedes.events=POLLIN;
+
+    ret=poll(&filedes, 1, 0);
+
+    if( ret == 0 ) {
+       *pend=0;
+       return 0; /* Really, no data */
+       }
+
+    if( ret < 0 )
+       return -1; /* just pass back the error */
+
+    if( filedes.revents & (POLLHUP|POLLERR) ) /* check for hangup */
+       return -1;
+
+    /* Should only get here if data arrived after the first ioctl() */
+    return ioctl(ciptr->fd, I_NREAD, (char *)pend);
+}
+
+
+static int
+TRANS(TLIRead)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg(2, "TLIRead(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+    return read(ciptr->fd,buf,size);
+}
+
+
+static int
+TRANS(TLIWrite)(XtransConnInfo ciptr, char *buf, int size)
+
+{
+    prmsg(2, "TLIWrite(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+    return write(ciptr->fd,buf,size);
+}
+
+
+static int
+TRANS(TLIReadv)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg(2, "TLIReadv(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+    return READV(ciptr,buf,size);
+}
+
+
+static int
+TRANS(TLIWritev)(XtransConnInfo ciptr, struct iovec *buf, int size)
+
+{
+    prmsg(2, "TLIWritev(%d,%x,%d)\n", ciptr->fd, buf, size );
+
+    return WRITEV(ciptr,buf,size);
+}
+
+
+static int
+TRANS(TLIDisconnect)(XtransConnInfo ciptr)
+
+{
+    prmsg(2, "TLIDisconnect(%x->%d)\n", ciptr, ciptr->fd);
+
+    /*
+     * Restore the TLI modules so that the connection can be properly shutdown.
+     * This avoids the situation where a connection goes into the TIME_WAIT
+     * state, and the address remains unavailable for a while.
+     */
+    ioctl(ciptr->fd, I_POP,"tirdwr");
+    ioctl(ciptr->fd, I_PUSH,"timod");
+
+    t_snddis(ciptr->fd,NULL);
+
+    return 0;
+}
+
+
+static int
+TRANS(TLIClose)(XtransConnInfo ciptr)
+
+{
+    prmsg(2, "TLIClose(%x->%d)\n", ciptr, ciptr->fd);
+
+    t_unbind(ciptr->fd);
+
+    return (t_close(ciptr->fd));
+}
+
+
+static int
+TRANS(TLICloseForCloning)(XtransConnInfo ciptr)
+
+{
+    /*
+     * Don't unbind.
+     */
+
+    prmsg(2, "TLICloseForCloning(%x->%d)\n", ciptr, ciptr->fd);
+
+    return (t_close(ciptr->fd));
+}
+
+
+Xtransport     TRANS(TLITCPFuncs) = {
+       /* TLI Interface */
+       "tcp",
+       0,
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(TLIReopenCOTSServer),
+       TRANS(TLIReopenCLTSServer),
+#endif
+       TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+       TRANS(TLIINETCreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLIINETConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(TLIBytesReadable),
+       TRANS(TLIRead),
+       TRANS(TLIWrite),
+       TRANS(TLIReadv),
+       TRANS(TLIWritev),
+       TRANS(TLIDisconnect),
+       TRANS(TLIClose),
+       TRANS(TLICloseForCloning),
+};
+
+#ifdef TRANS_SERVER
+static char * inet_aliases[] = { "tcp", NULL };
+#endif
+Xtransport     TRANS(TLIINETFuncs) = {
+       /* TLI Interface */
+       "inet",
+       TRANS_ALIAS,
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       inet_aliases,
+       TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(TLIReopenCOTSServer),
+       TRANS(TLIReopenCLTSServer),
+#endif
+       TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+       TRANS(TLIINETCreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLIINETConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(TLIBytesReadable),
+       TRANS(TLIRead),
+       TRANS(TLIWrite),
+       TRANS(TLIReadv),
+       TRANS(TLIWritev),
+       TRANS(TLIDisconnect),
+       TRANS(TLIClose),
+       TRANS(TLICloseForCloning),
+};
+
+Xtransport     TRANS(TLITLIFuncs) = {
+       /* TLI Interface */
+       "tli",
+       0,
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCOTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       NULL,
+       TRANS(TLIOpenCOTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLIOpenCLTSClient),
+#endif /* TRANS_CLIENT */
+#ifdef TRANS_SERVER
+       TRANS(TLIOpenCLTSServer),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_REOPEN
+       TRANS(TLIReopenCOTSServer),
+       TRANS(TLIReopenCLTSServer),
+#endif
+       TRANS(TLISetOption),
+#ifdef TRANS_SERVER
+       TRANS(TLITLICreateListener),
+       NULL,                                   /* ResetListener */
+       TRANS(TLIAccept),
+#endif /* TRANS_SERVER */
+#ifdef TRANS_CLIENT
+       TRANS(TLITLIConnect),
+#endif /* TRANS_CLIENT */
+       TRANS(TLIBytesReadable),
+       TRANS(TLIRead),
+       TRANS(TLIWrite),
+       TRANS(TLIReadv),
+       TRANS(TLIWritev),
+       TRANS(TLIDisconnect),
+       TRANS(TLIClose),
+       TRANS(TLICloseForCloning),
+};
diff --git a/Xtransutil.c b/Xtransutil.c
new file mode 100644 (file)
index 0000000..52c937b
--- /dev/null
@@ -0,0 +1,649 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCRS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * These are some utility functions created for convenience or to provide
+ * an interface that is similar to an existing interface. These are built
+ * only using the Transport Independant API, and have no knowledge of
+ * the internal implementation.
+ */
+
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifdef WIN32
+#include <X11/Xlibint.h>
+#include <X11/Xwinsock.h>
+#endif
+
+#ifdef X11_t
+
+/*
+ * These values come from X.h and Xauth.h, and MUST match them. Some
+ * of these values are also defined by the ChangeHost protocol message.
+ */
+
+#define FamilyInternet         0       /* IPv4 */
+#define FamilyDECnet           1
+#define FamilyChaos            2
+#define FamilyInternet6                6
+#define FamilyAmoeba           33
+#define FamilyLocalHost                252
+#define FamilyKrb5Principal    253
+#define FamilyNetname          254
+#define FamilyLocal            256
+#define FamilyWild             65535
+
+/*
+ * TRANS(ConvertAddress) converts a sockaddr based address to an
+ * X authorization based address. Some of this is defined as part of
+ * the ChangeHost protocol. The rest is just done in a consistent manner.
+ */
+
+int
+TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr **addrp)
+
+{
+
+    prmsg(2,"ConvertAddress(%d,%d,%p)\n",*familyp,*addrlenp,*addrp);
+
+    switch( *familyp )
+    {
+#if defined(TCPCONN) || defined(STREAMSCONN)
+    case AF_INET:
+    {
+       /*
+        * Check for the BSD hack localhost address 127.0.0.1.
+        * In this case, we are really FamilyLocal.
+        */
+
+       struct sockaddr_in saddr;
+       int len = sizeof(saddr.sin_addr.s_addr);
+       char *cp = (char *) &saddr.sin_addr.s_addr;
+
+       memcpy (&saddr, *addrp, sizeof (struct sockaddr_in));
+
+       if ((len == 4) && (cp[0] == 127) && (cp[1] == 0) &&
+           (cp[2] == 0) && (cp[3] == 1))
+       {
+           *familyp=FamilyLocal;
+       }
+       else
+       {
+           *familyp=FamilyInternet;
+           *addrlenp=len;
+           memcpy(*addrp,&saddr.sin_addr,len);
+       }
+       break;
+    }
+
+#if defined(IPv6) && defined(AF_INET6)
+    case AF_INET6:
+    {
+       struct sockaddr_in6 saddr6;
+
+       memcpy (&saddr6, *addrp, sizeof (struct sockaddr_in6));
+
+       if (IN6_IS_ADDR_LOOPBACK(&saddr6.sin6_addr))
+       {
+           *familyp=FamilyLocal;
+       }
+       else if (IN6_IS_ADDR_V4MAPPED(&(saddr6.sin6_addr))) {
+           char *cp = (char *) &saddr6.sin6_addr.s6_addr[12];
+
+           if ((cp[0] == 127) && (cp[1] == 0) &&
+             (cp[2] == 0) && (cp[3] == 1))
+           {
+               *familyp=FamilyLocal;
+           }
+           else
+           {
+               *familyp=FamilyInternet;
+               *addrlenp = sizeof (struct in_addr);
+               memcpy(*addrp,cp,*addrlenp);
+           }
+       }
+       else
+       {
+           *familyp=FamilyInternet6;
+           *addrlenp=sizeof(saddr6.sin6_addr);
+           memcpy(*addrp,&saddr6.sin6_addr,sizeof(saddr6.sin6_addr));
+       }
+       break;
+    }
+#endif /* IPv6 */
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+
+#if defined(UNIXCONN) || defined(LOCALCONN)
+    case AF_UNIX:
+    {
+       *familyp=FamilyLocal;
+       break;
+    }
+#endif /* defined(UNIXCONN) || defined(LOCALCONN) */
+
+#if (defined(__SCO__) || defined(__UNIXWARE__)) && defined(LOCALCONN)
+    case 0:
+    {
+       *familyp=FamilyLocal;
+       break;
+    }
+#endif
+
+    default:
+       prmsg(1,"ConvertAddress: Unknown family type %d\n",
+             *familyp);
+       return -1;
+    }
+
+
+    if (*familyp == FamilyLocal)
+    {
+       /*
+        * In the case of a local connection, we need to get the
+        * host name for authentication.
+        */
+
+       char hostnamebuf[256];
+       int len = TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf);
+
+       if (len > 0) {
+           if (*addrp && *addrlenp < (len + 1))
+           {
+               free (*addrp);
+               *addrp = NULL;
+           }
+           if (!*addrp)
+               *addrp = malloc (len + 1);
+           if (*addrp) {
+               strcpy ((char *) *addrp, hostnamebuf);
+               *addrlenp = len;
+           } else {
+               *addrlenp = 0;
+           }
+       }
+       else
+       {
+           if (*addrp)
+               free (*addrp);
+           *addrp = NULL;
+           *addrlenp = 0;
+       }
+    }
+
+    return 0;
+}
+
+#endif /* X11_t */
+
+#ifdef ICE_t
+
+/* Needed for _XGethostbyaddr usage in TRANS(GetPeerNetworkId) */
+# if defined(TCPCONN) || defined(UNIXCONN)
+#  define X_INCLUDE_NETDB_H
+#  define XOS_USE_NO_LOCKING
+#  include <X11/Xos_r.h>
+# endif
+
+#include <signal.h>
+
+char *
+TRANS(GetMyNetworkId) (XtransConnInfo ciptr)
+
+{
+    int                family = ciptr->family;
+    char       *addr = ciptr->addr;
+    char       hostnamebuf[256];
+    char       *networkId = NULL;
+    const char *transName = ciptr->transptr->TransName;
+
+    if (gethostname (hostnamebuf, sizeof (hostnamebuf)) < 0)
+    {
+       return (NULL);
+    }
+
+    switch (family)
+    {
+#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN)
+    case AF_UNIX:
+    {
+       struct sockaddr_un *saddr = (struct sockaddr_un *) addr;
+       networkId = malloc (3 + strlen (transName) +
+           strlen (hostnamebuf) + strlen (saddr->sun_path));
+       sprintf (networkId, "%s/%s:%s", transName,
+           hostnamebuf, saddr->sun_path);
+       break;
+    }
+#endif /* defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+    case AF_INET:
+#if defined(IPv6) && defined(AF_INET6)
+    case AF_INET6:
+#endif
+    {
+       struct sockaddr_in *saddr = (struct sockaddr_in *) addr;
+#if defined(IPv6) && defined(AF_INET6)
+       struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) addr;
+#endif
+       int portnum;
+       char portnumbuf[10];
+
+
+#if defined(IPv6) && defined(AF_INET6)
+       if (family == AF_INET6)
+           portnum = ntohs (saddr6->sin6_port);
+       else
+#endif
+           portnum = ntohs (saddr->sin_port);
+
+       snprintf (portnumbuf, sizeof(portnumbuf), "%d", portnum);
+       networkId = malloc (3 + strlen (transName) +
+           strlen (hostnamebuf) + strlen (portnumbuf));
+       sprintf (networkId, "%s/%s:%s", transName, hostnamebuf, portnumbuf);
+       break;
+    }
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+
+    default:
+       break;
+    }
+
+    return (networkId);
+}
+
+#include <setjmp.h>
+static jmp_buf env;
+
+#ifdef SIGALRM
+static volatile int nameserver_timedout = 0;
+
+static
+#ifdef RETSIGTYPE /* set by autoconf AC_TYPE_SIGNAL */
+RETSIGTYPE
+#else /* Imake */
+#ifdef SIGNALRETURNSINT
+int
+#else
+void
+#endif
+#endif
+nameserver_lost(int sig _X_UNUSED)
+{
+  nameserver_timedout = 1;
+  longjmp (env, -1);
+  /* NOTREACHED */
+#ifdef SIGNALRETURNSINT
+  return -1;                           /* for picky compilers */
+#endif
+}
+#endif /* SIGALARM */
+
+
+char *
+TRANS(GetPeerNetworkId) (XtransConnInfo ciptr)
+
+{
+    int                family = ciptr->family;
+    char       *peer_addr = ciptr->peeraddr;
+    char       *hostname;
+    char       addrbuf[256];
+    const char *addr = NULL;
+
+    switch (family)
+    {
+    case AF_UNSPEC:
+#if defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN)
+    case AF_UNIX:
+    {
+       if (gethostname (addrbuf, sizeof (addrbuf)) == 0)
+           addr = addrbuf;
+       break;
+    }
+#endif /* defined(UNIXCONN) || defined(STREAMSCONN) || defined(LOCALCONN) */
+
+#if defined(TCPCONN) || defined(STREAMSCONN)
+    case AF_INET:
+#if defined(IPv6) && defined(AF_INET6)
+    case AF_INET6:
+#endif
+    {
+       struct sockaddr_in *saddr = (struct sockaddr_in *) peer_addr;
+#if defined(IPv6) && defined(AF_INET6)
+       struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) peer_addr;
+#endif
+       char *address;
+       int addresslen;
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+       _Xgethostbynameparams hparams;
+#endif
+       struct hostent * volatile hostp = NULL;
+
+#if defined(IPv6) && defined(AF_INET6)
+       if (family == AF_INET6)
+       {
+           address = (char *) &saddr6->sin6_addr;
+           addresslen = sizeof (saddr6->sin6_addr);
+       }
+       else
+#endif
+       {
+           address = (char *) &saddr->sin_addr;
+           addresslen = sizeof (saddr->sin_addr);
+       }
+
+#ifdef SIGALRM
+       /*
+        * gethostbyaddr can take a LONG time if the host does not exist.
+        * Assume that if it does not respond in NAMESERVER_TIMEOUT seconds
+        * that something is wrong and do not make the user wait.
+        * gethostbyaddr will continue after a signal, so we have to
+        * jump out of it.
+        */
+
+       nameserver_timedout = 0;
+       signal (SIGALRM, nameserver_lost);
+       alarm (4);
+       if (setjmp(env) == 0) {
+#endif
+           hostp = _XGethostbyaddr (address, addresslen, family, hparams);
+#ifdef SIGALRM
+       }
+       alarm (0);
+#endif
+       if (hostp != NULL)
+         addr = hostp->h_name;
+       else
+#if defined(IPv6) && defined(AF_INET6)
+         addr = inet_ntop (family, address, addrbuf, sizeof (addrbuf));
+#else
+         addr = inet_ntoa (saddr->sin_addr);
+#endif
+       break;
+    }
+
+#endif /* defined(TCPCONN) || defined(STREAMSCONN) */
+
+
+    default:
+       return (NULL);
+    }
+
+
+    hostname = malloc (strlen (ciptr->transptr->TransName) + strlen (addr) + 2);
+    strcpy (hostname, ciptr->transptr->TransName);
+    strcat (hostname, "/");
+    if (addr)
+       strcat (hostname, addr);
+
+    return (hostname);
+}
+
+#endif /* ICE_t */
+
+
+#if defined(WIN32) && defined(TCPCONN)
+int
+TRANS(WSAStartup) (void)
+{
+    static WSADATA wsadata;
+
+    prmsg (2,"WSAStartup()\n");
+
+    if (!wsadata.wVersion && WSAStartup(MAKEWORD(2,2), &wsadata))
+        return 1;
+    return 0;
+}
+#endif
+
+#include <ctype.h>
+
+static int
+is_numeric (const char *str)
+{
+    int i;
+
+    for (i = 0; i < (int) strlen (str); i++)
+       if (!isdigit (str[i]))
+           return (0);
+
+    return (1);
+}
+
+#ifdef TRANS_SERVER
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#if !defined(S_IFLNK) && !defined(S_ISLNK)
+#undef lstat
+#define lstat(a,b) stat(a,b)
+#endif
+
+#define FAIL_IF_NOMODE  1
+#define FAIL_IF_NOT_ROOT 2
+#define WARN_NO_ACCESS 4
+
+/*
+ * We make the assumption that when the 'sticky' (t) bit is requested
+ * it's not save if the directory has non-root ownership or the sticky
+ * bit cannot be set and fail.
+ */
+static int
+trans_mkdir(const char *path, int mode)
+{
+    struct stat buf;
+
+    if (lstat(path, &buf) != 0) {
+       if (errno != ENOENT) {
+           prmsg(1, "mkdir: ERROR: (l)stat failed for %s (%d)\n",
+                 path, errno);
+           return -1;
+       }
+       /* Dir doesn't exist. Try to create it */
+
+#if !defined(WIN32) && !defined(__CYGWIN__)
+       /*
+        * 'sticky' bit requested: assume application makes
+        * certain security implications. If effective user ID
+        * is != 0: fail as we may not be able to meet them.
+        */
+       if (geteuid() != 0) {
+           if (mode & 01000) {
+               prmsg(1, "mkdir: ERROR: euid != 0,"
+                     "directory %s will not be created.\n",
+                     path);
+#ifdef FAIL_HARD
+               return -1;
+#endif
+           } else {
+               prmsg(1, "mkdir: Cannot create %s with root ownership\n",
+                     path);
+           }
+       }
+#endif
+
+#ifndef WIN32
+       if (mkdir(path, mode) == 0) {
+           if (chmod(path, mode)) {
+               prmsg(1, "mkdir: ERROR: Mode of %s should be set to %04o\n",
+                     path, mode);
+#ifdef FAIL_HARD
+               return -1;
+#endif
+           }
+#else
+       if (mkdir(path) == 0) {
+#endif
+       } else {
+           prmsg(1, "mkdir: ERROR: Cannot create %s\n",
+                 path);
+           return -1;
+       }
+
+       return 0;
+
+    } else {
+       if (S_ISDIR(buf.st_mode)) {
+           int updateOwner = 0;
+           int updateMode = 0;
+           int updatedOwner = 0;
+           int updatedMode = 0;
+           int status = 0;
+           /* Check if the directory's ownership is OK. */
+           if (buf.st_uid != 0)
+               updateOwner = 1;
+
+           /*
+            * Check if the directory's mode is OK.  An exact match isn't
+            * required, just a mode that isn't more permissive than the
+            * one requested.
+            */
+           if ((~mode) & 0077 & buf.st_mode)
+               updateMode = 1;
+
+           /*
+            * If the directory is not writeable not everybody may
+            * be able to create sockets. Therefore warn if mode
+            * cannot be fixed.
+            */
+           if ((~buf.st_mode) & 0022 & mode) {
+               updateMode = 1;
+               status |= WARN_NO_ACCESS;
+           }
+
+           /*
+            * If 'sticky' bit is requested fail if owner isn't root
+            * as we assume the caller makes certain security implications
+            */
+           if (mode & 01000) {
+               status |= FAIL_IF_NOT_ROOT;
+               if (!(buf.st_mode & 01000)) {
+                   status |= FAIL_IF_NOMODE;
+                   updateMode = 1;
+               }
+           }
+
+#ifdef HAS_FCHOWN
+           /*
+            * If fchown(2) and fchmod(2) are available, try to correct the
+            * directory's owner and mode.  Otherwise it isn't safe to attempt
+            * to do this.
+            */
+           if (updateMode || updateOwner) {
+               int fd = -1;
+               struct stat fbuf;
+               if ((fd = open(path, O_RDONLY)) != -1) {
+                   if (fstat(fd, &fbuf) == -1) {
+                       prmsg(1, "mkdir: ERROR: fstat failed for %s (%d)\n",
+                             path, errno);
+                       close(fd);
+                       return -1;
+                   }
+                   /*
+                    * Verify that we've opened the same directory as was
+                    * checked above.
+                    */
+                   if (!S_ISDIR(fbuf.st_mode) ||
+                       buf.st_dev != fbuf.st_dev ||
+                       buf.st_ino != fbuf.st_ino) {
+                       prmsg(1, "mkdir: ERROR: inode for %s changed\n",
+                             path);
+                       close(fd);
+                       return -1;
+                   }
+                   if (updateOwner && fchown(fd, 0, 0) == 0)
+                       updatedOwner = 1;
+                   if (updateMode && fchmod(fd, mode) == 0)
+                       updatedMode = 1;
+                   close(fd);
+               }
+           }
+#endif
+
+           if (updateOwner && !updatedOwner) {
+#ifdef FAIL_HARD
+               if (status & FAIL_IF_NOT_ROOT) {
+                   prmsg(1, "mkdir: ERROR: Owner of %s must be set to root\n",
+                         path);
+                   return -1;
+               }
+#endif
+#if !defined(__APPLE_CC__) && !defined(__CYGWIN__)
+               prmsg(1, "mkdir: Owner of %s should be set to root\n",
+                     path);
+#endif
+           }
+
+           if (updateMode && !updatedMode) {
+#ifdef FAIL_HARD
+               if (status & FAIL_IF_NOMODE) {
+                   prmsg(1, "mkdir: ERROR: Mode of %s must be set to %04o\n",
+                         path, mode);
+                   return -1;
+               }
+#endif
+               prmsg(1, "mkdir: Mode of %s should be set to %04o\n",
+                     path, mode);
+               if (status & WARN_NO_ACCESS) {
+                   prmsg(1, "mkdir: this may cause subsequent errors\n");
+               }
+           }
+           return 0;
+       }
+       return -1;
+    }
+
+    /* In all other cases, fail */
+    return -1;
+}
+
+#endif /* TRANS_SERVER */
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..3d11c34
--- /dev/null
@@ -0,0 +1,64 @@
+#  Copyright © 2003 Keith Packard, Noah Levitt
+#
+#  Permission to use, copy, modify, distribute, and sell this software and its
+#  documentation for any purpose is hereby granted without fee, provided that
+#  the above copyright notice appear in all copies and that both that
+#  copyright notice and this permission notice appear in supporting
+#  documentation, and that the name of Keith Packard not be used in
+#  advertising or publicity pertaining to distribution of the software without
+#  specific, written prior permission.  Keith Packard makes no
+#  representations about the suitability of this software for any purpose.  It
+#  is provided "as is" without express or implied warranty.
+#
+#  KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+#  EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+#  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+#  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+#  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+#  PERFORMANCE OF THIS SOFTWARE.
+#
+
+# Initialize Autoconf
+AC_PREREQ([2.60])
+AC_INIT([xtrans], [1.2.7],
+        [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xtrans])
+AC_CONFIG_SRCDIR([Makefile.am])
+
+# Initialize Automake
+AM_INIT_AUTOMAKE([foreign dist-bzip2])
+AM_MAINTAINER_MODE
+
+# Require xorg-macros minimum of 1.12 for DocBook external references
+m4_ifndef([XORG_MACROS_VERSION],
+          [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.12)
+XORG_DEFAULT_OPTIONS
+XORG_ENABLE_DOCS
+XORG_WITH_XMLTO(0.0.22)
+XORG_WITH_FOP
+XORG_WITH_XSLTPROC
+XORG_CHECK_SGML_DOCTOOLS(1.8)
+
+# Because xtrans is included into other modules rather than being linked
+# with, these defines have to be added to the cflags line
+
+# fchown()
+
+AC_CHECK_FUNC(fchown, [fchown_define="-DHAS_FCHOWN"], [fchown_define=""])
+
+AC_SUBST(fchown_define)
+
+# sticky bit
+#
+# if any system exists without sticky dir bits this
+# needs to be redone with a real autoconf test
+
+sticky_bit_define="-DHAS_STICKY_DIR_BIT"
+
+AC_SUBST(sticky_bit_define)
+
+AC_CONFIG_FILES([Makefile
+               doc/Makefile
+               xtrans.pc])
+AC_OUTPUT
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644 (file)
index 0000000..014c956
--- /dev/null
@@ -0,0 +1,13 @@
+
+if ENABLE_DOCS
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = xtrans.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif ENABLE_DOCS
diff --git a/doc/xtrans.xml b/doc/xtrans.xml
new file mode 100644 (file)
index 0000000..12dbe3c
--- /dev/null
@@ -0,0 +1,1201 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+                      "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
+[
+<!ENTITY % defs SYSTEM "defs.ent"> %defs;
+]>
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="xtrans">
+
+<bookinfo>
+   <title>X Transport Interface</title>
+   <subtitle>X Consortium Standard</subtitle>
+   <authorgroup>
+     <author>
+       <firstname>Stuart</firstname><surname>Anderson</surname>
+       <affiliation><orgname>NCR Corporation</orgname></affiliation>
+     </author>
+     <othercredit><firstname>Ralph</firstname><surname>Mor</surname>
+       <affiliation><orgname>X Consortium</orgname></affiliation>
+     </othercredit>
+     <othercredit><firstname>Alan</firstname><surname>Coopersmith</surname>
+       <affiliation><orgname>Oracle Corp.</orgname></affiliation>
+     </othercredit>
+   </authorgroup>
+   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
+   <releaseinfo>Version 0.7</releaseinfo>
+   <copyright><year>1993</year><year>1994</year>
+     <holder>NCR Corporation - Dayton, Ohio, USA</holder>
+   </copyright>
+
+<legalnotice>
+<para>
+All Rights Reserved
+</para>
+<para>
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation, and that the name NCR not be used in advertising
+or publicity pertaining to distribution of the software without specific,
+written prior permission.  NCR makes no representations about the
+suitability of this software for any purpose.  It is provided "as is"
+without express or implied warranty.
+</para>
+<para>
+NCR DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+</para>
+</legalnotice>
+
+<legalnotice>
+<para role="multiLicensing">
+Copyright &copy; 1993, 1994, 2002 The Open Group
+</para>
+<para>
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the &ldquo;Software&rdquo;), 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:
+</para>
+<para>
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+</para>
+<para>
+THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, 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
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+</para>
+<para>
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+</para>
+<para>
+X Window System is a trademark of The Open Group, Inc.
+</para>
+</legalnotice>
+</bookinfo>
+
+<preface><title>The X Transport Interface</title>
+<para>
+Designed by Stuart Anderson (NCR) with help from Ralph Mor (X Consortium)
+</para>
+
+<note><para>
+This documentation does not completely match the implementation in R6
+(as a result of some late changes made in the code). Specifically, support
+was added for font server cloning, and conditional compliation was introduced
+for client vs. server code.
+</para></note>
+</preface>
+
+<chapter id='Purposes_and_Goals'>
+<title>Purposes and Goals</title>
+
+<para>The X Transport Interface is intended to combine all system and
+transport specific code into a single place in the source tree. This API
+should be used by all libraries, clients and servers of the X Window System.
+Use of this API should allow the addition of new types of transports and
+support for new platforms without making any changes to the source except
+in the X Transport Interface code.</para>
+<para>This interface should solve the problem of multiple
+<code>#ifdef TRANSPORT</code> and <code>#ifdef PLATFORM</code>
+statements scattered throughout the source tree.</para>
+<para>This interface should provide enough functionality to support all
+types of protocols, including connection oriented protocols such as X11 and
+FS, and connection-less oriented protocols such as XDMCP.</para>
+
+</chapter>
+
+<chapter id='Overview_of_the_Interface'>
+<title>Overview of the Interface</title>
+
+<para>
+The interface provides an API for use by applications. The functions in
+this API perform work that is common to all transports and systems, such
+as parsing an address into a host and port number. The functions in this
+API call transport specific functions that are contained in a table whose
+contents are defined at compile time. This table contains an entry for each
+type of transport. Each entry is a record containing mostly pointers to
+function that implements the interface for the given transport.
+</para>
+<para>
+This API does not provide an abstraction for <function>select()</function>
+or <function>poll()</function>.
+These functions are themselves transport independent, so an additional
+interface is not needed for these functions. It is also unclear how such
+an interface would affect performance.
+</para>
+</chapter>
+
+<chapter id='Definition_of_Address_Specification_Format'>
+<title>Definition of Address Specification Format</title>
+
+<para>
+Addresses are specified in the following syntax,
+
+<synopsis>
+<replaceable>protocol</replaceable>/<replaceable>host</replaceable>:<replaceable>port</replaceable>
+</synopsis>
+
+where <replaceable>protocol</replaceable> specifies a protocol family
+or an alias for a protocol family. A definition of common protocol
+families is given in a later section.
+</para>
+<para>
+The <replaceable>host</replaceable> part specifies the name of a host or other
+transport dependent entity that could be interpreted as a Network Service Access Point
+(NSAP).
+</para>
+<para>
+The <replaceable>port</replaceable> part specifies the name of a Transport Service
+Access Point (TSAP). The format of the TSAP is defined by the underlying transport
+implementation, but it is represented using a string format when it is
+part of an address.
+</para>
+</chapter>
+
+<chapter id='Internal_Data_Structures'>
+<title>Internal Data Structures</title>
+<para>
+There are two major data structures associated with the transport
+independent portion of this interface.  Additional data structures
+may be used internally by each transport.
+</para>
+<sect1 id='Xtransport'>
+<title>Xtransport</title>
+<para>
+Each transport supported has an entry in the transport table. The transport
+table is an array of Xtransport records. Each record contains all the entry
+points for a single transport. This record is defined as:
+</para>
+
+<synopsis>
+typedef struct _Xtransport {
+
+    char *TransName;
+    int  flags;
+
+    XtransConnInfo (*OpenCOTSClient)(
+    struct _Xtransport *,     /* transport */
+    char     *,     /* protocol */
+    char     *,     /* host */
+    char     *      /* port */
+    );
+
+    XtransConnInfo (*OpenCOTSServer)(
+    struct _Xtransport *,     /* transport */
+    char *,     /* protocol */
+    char *,     /* host */
+    char *      /* port */
+    );
+
+    XtransConnInfo (*OpenCLTSClient)(
+    struct _Xtransport *,     /* transport */
+    char *,               /* protocol */
+    char *,               /* host */
+    char *               /* port */
+    );
+
+    XtransConnInfo (*OpenCLTSServer)(
+     struct _Xtransport *,   /* transport */
+     char *,     /* protocol */
+     char *,     /* host */
+     char *     /* port */
+    );
+
+    int     (*SetOption)(
+     XtransConnInfo,          /* connection */
+     int,               /* option */
+     int               /* arg */
+    );
+
+    int     (*CreateListener)(
+     XtransConnInfo,          /* connection */
+     char *,               /* port */
+     int               /* flags */
+    );
+
+    int     (*ResetListener)(
+     XtransConnInfo          /* connection */
+    );
+
+    XtransConnInfo (*Accept)(
+     XtransConnInfo          /* connection */
+    );
+
+    int     (*Connect)(
+     XtransConnInfo,          /* connection */
+     char *,               /* host */
+     char *               /* port */
+    );
+
+    int     (*BytesReadable)(
+     XtransConnInfo,          /* connection */
+     BytesReadable_t *     /* pend */
+    );
+
+    int     (*Read)(
+     XtransConnInfo,          /* connection */
+     char *,               /* buf */
+     int               /* size */
+    );
+
+    int     (*Write)(
+     XtransConnInfo,          /* connection */
+     char *,               /* buf */
+     int               /* size */
+    );
+
+    int     (*Readv)(
+     XtransConnInfo,          /* connection */
+     struct iovec *,          /* buf */
+     int               /* size */
+    );
+
+    int     (*Writev)(
+     XtransConnInfo,          /* connection */
+     struct iovec *,          /* buf */
+     int               /* size */
+    );
+
+    int     (*Disconnect)(
+     XtransConnInfo          /* connection */
+    );
+
+    int     (*Close)(
+     XtransConnInfo          /* connection */
+    );
+
+} Xtransport;
+</synopsis>
+
+<para>
+The <structfield>flags</structfield> field can contain an OR of
+the following masks:
+<variablelist>
+  <varlistentry>
+    <term><symbol>TRANS_ALIAS</symbol></term>
+    <listitem><para>
+indicates that this record is providing an alias, and should
+not be used to create a listener.
+      </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><symbol>TRANS_LOCAL</symbol></term>
+    <listitem><para>
+indicates that this is a <symbol>LOCALCONN</symbol> transport.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><symbol>TRANS_ABSTRACT</symbol></term>
+    <listitem><para>
+indicates that a local connection transport uses the abstract socket namespace.
+    </para></listitem>
+  </varlistentry>
+</variablelist>
+</para>
+
+<para>
+Some additional flags may be set in the <structfield>flags</structfield>
+field by the library while it is running:
+<variablelist>
+  <varlistentry>
+    <term><symbol>TRANS_DISABLED</symbol></term>
+    <listitem><para>
+indicates that this transport has been disabled.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><symbol>TRANS_NOLISTEN</symbol></term>
+    <listitem><para>
+indicates that servers should not open new listeners using this transport.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><symbol>TRANS_NOUNLINK</symbol></term>
+    <listitem><para>
+set by a transport backend to indicate that the endpoints for its connection
+should not be unlinked.
+    </para></listitem>
+  </varlistentry>
+</variablelist>
+</para>
+</sect1>
+
+<sect1 id='XtransConnInfo'>
+<title>XtransConnInfo</title>
+<para>
+Each connection will have an opaque <structname>XtransConnInfo</structname>
+transport connection
+object allocated for it. This record contains information specific to the
+connection. The record is defined as:
+
+<synopsis>
+typedef struct _XtransConnInfo *XtransConnInfo;
+
+struct _XtransConnInfo {
+    struct _Xtransport     *transptr;
+    char     *priv;
+    int          flags;
+    int          fd;
+    int          family;
+    char     *addr;
+    int          addrlen;
+    char     *peeraddr;
+    int          peeraddrlen;
+};
+</synopsis>
+</para>
+</sect1>
+</chapter>
+
+<chapter id='Exposed_Transport_Independent_API'>
+<title>Exposed Transport Independent API</title>
+
+<para>
+This API is included in each library and server that uses it. The API may
+be used by the library, but it is not added to the public API for that
+library. This interface is simply an implementation facilitator. This API
+contains a low level set of core primitives, and a few utility functions
+that are built on top of the primitives.  The utility functions exist to
+provide a more familiar interface that can be used to port existing code.
+</para>
+<para>
+A macro is defined in Xtrans.h for TRANS(func) that creates a unique function
+name depending on where the code is compiled. For example, when built for
+Xlib, TRANS(OpenCOTSClient) becomes <function>_X11TransOpenCOTSClient</function>.
+</para>
+<para>
+All failures are considered fatal, and the connection should be closed
+and re-established if desired. In most cases, however, the value of
+errno will be available for debugging purposes.
+</para>
+<sect1 id='Core_Interface_API'>
+<title>Core Interface API</title>
+<itemizedlist mark='bullet'>
+  <listitem>
+    <para>
+XtransConnInfo TRANS(OpenCOTSClient)(char *address)
+    </para>
+    <para>
+This function creates a Connection-Oriented Transport that is
+suitable for use by a client. The parameter <parameter>address</parameter>
+contains the full address of the server to which this endpoint will be connected.  This
+functions returns an opaque transport connection object on success, or
+NULL on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo TRANS(OpenCOTSServer)(char *address)
+    </para>
+    <para>
+This function creates a Connection-Oriented Transport that is suitable
+for use by a server. The parameter <parameter>address</parameter> contains the
+full address to which this server will be bound. This functions returns an opaque
+transport connection object on success, or NULL on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo TRANS(OpenCLTSClient)(char *address)
+    </para>
+    <para>
+This function creates a Connection-Less Transport that is suitable for
+use by a client. The parameter <parameter>address</parameter> contains the
+full address of the server to which this endpoint will be connected. This functions
+returns an opaque transport connection object on success, or NULL on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo TRANS(OpenCLTSServer)(char *address)
+    </para>
+    <para>
+This function creates a Connection-Less Transport that is suitable for
+use by a server. The parameter <parameter>address</parameter> contains the
+full address to which this server will be bound. This functions returns an opaque
+transport connection object on success, or NULL on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(SetOption)(XtransConnInfo connection, int option, int arg)
+    </para>
+    <para>
+This function sets transport options, similar to the way
+<function>setsockopt()</function> and <function>ioctl()</function> work.
+The parameter <parameter>connection</parameter> is an endpoint
+that was obtained from _XTransOpen*() functions. The parameter
+<parameter>option</parameter> contains the option that will be set. The actual
+values for option are defined in a later section. The parameter
+<parameter>arg</parameter> can be used to pass in an additional value that may
+be required by some options. This function return 0 on
+success and -1 on failure.
+    </para>
+    <note><para>
+Based on current usage, the complimentary function
+<function>TRANS(GetOption)</function> is not necessary.
+    </para></note>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(CreateListener)(XtransConnInfo connection, char *port, int flags)
+    </para>
+    <para>
+This function sets up the server endpoint for listening. The parameter
+<parameter>connection</parameter> is an endpoint that was obtained from
+<function>TRANS(OpenCOTSServer)()</function> or
+<function>TRANS(OpenCLTSServer)()</function>. The parameter
+<parameter>port</parameter> specifies the
+port to which this endpoint should be bound for listening. If port is NULL,
+then the transport may attempt to allocate any available TSAP for this
+connection. If the transport cannot support this, then this function will
+return a failure. The <parameter>flags</parameter> parameter can be set
+to <symbol>ADDR_IN_USE_ALLOWED</symbol> to allow the call to the underlying
+binding function to fail with a <errorname>EADDRINUSE</errorname> error
+without causing the <function>TRANS(CreateListener)</function>
+function itself to fail. This function return 0 on success and -1 on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(ResetListener)(XtransConnInfo connection)
+    </para>
+    <para>
+When a server is restarted, certain listen ports may need to be reset.
+For example, unix domain needs to check that the file used for
+communication has not been deleted. If it has, it must be recreated.
+The parameter <parameter>connection</parameter> is an opened and bound
+endpoint that was obtained from <function>TRANS(OpenCOTSServer)()</function>
+and passed to <function>TRANS(CreateListener)()</function>.
+This function will return one of the following values:
+<symbol>TRANS_RESET_NOOP</symbol>,
+<symbol>TRANS_RESET_NEW_FD</symbol>, or
+<symbol>TRANS_RESET_FAILURE</symbol>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo TRANS(Accept)(XtransConnInfo connection)
+    </para>
+    <para>
+Once a connection indication is received, this function can be called to
+accept the connection. The parameter <parameter>connection</parameter> is
+an opened and bound endpoint that was obtained from
+<function>TRANS(OpenCOTSServer)()</function> and passed to
+<function>TRANS(CreateListener)()</function>. This function will return a
+new opaque transport connection object upon success, NULL otherwise.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Connect)(XtransConnInfo connection, char *address)
+    </para>
+    <para>
+This function creates a connection to a server. The parameter
+<parameter>connection</parameter> is an endpoint that was obtained
+from <function>TRANS(OpenCOTSClient)()</function>. The parameter
+<parameter>address</parameter> specifies the TSAP to which this endpoint
+should connect. If the
+protocol is included in the address, it will be ignored. This function
+return 0 on success and -1 on failure.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(BytesReadable)(XtransConnInfo connection, BytesReadable_t *pend);
+    </para>
+    <para>
+This function provides the same functionality as the BytesReadable macro.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Read)(XtransConnInfo connection, char *buf, int size)
+    </para>
+    <para>
+This function will return the number of bytes requested on a COTS
+connection, and will return the minimum of the number bytes requested or
+the size of the incoming packet on a CLTS connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Write)(XtransConnInfo connection, char *buf, int size)
+    </para>
+    <para>
+This function will write the requested number of bytes on a COTS
+connection, and will send a packet of the requested size on a CLTS connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Readv)(XtransConnInfo connection, struct iovec *buf, int size)
+    </para>
+    <para>
+Similar to <function>TRANS(Read)()</function>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+  int TRANS(Writev)(XtransConnInfo connection, struct iovec *buf, int size)
+    </para>
+    <para>
+Similar to <function>TRANS(Write)()</function>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Disconnect)(XtransConnInfo connection)
+    </para>
+    <para>
+This function is used when an orderly disconnect is desired. This function
+breaks the connection on the transport. It is similar to the socket function
+<function>shutdown()</function>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(Close)(XtransConnInfo connection)
+    </para>
+    <para>
+This function closes the transport, unbinds it, and frees all resources that
+was associated with the transport. If a <function>TRANS(Disconnect)</function>
+call was not made on the connection, a disorderly disconnect may occur.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(IsLocal)(XtransConnInfo connection)
+    </para>
+    <para>
+Returns TRUE if it is a local transport.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(GetMyAddr)(XtransConnInfo connection, int *familyp, int *addrlenp,
+Xtransaddr **addrp)
+    </para>
+    <para>
+This function is similar to
+<function>getsockname()</function>.
+This function will allocate space for the address, so it must be freed by
+the caller. Not all transports will have a valid address until a connection
+is established.  This function should not be used until the connection is
+established with
+<function>Connect()</function> or
+<function>Accept()</function>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(GetPeerAddr)(XtransConnInfo connection, int *familyp, int *addrlenp,
+Xtransaddr **addrp)
+    </para>
+    <para>
+This function is similar to
+<function>getpeername()</function>.
+This function will allocate space for the address, so it must be freed by
+the caller. Not all transports will have a valid address until a connection
+is established.  This function should not be used until the connection is
+established with
+<function>Connect()</function> or
+<function>Accept()</function>.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(GetConnectionNumber)(XtransConnInfo connection)
+    </para>
+    <para>
+Returns the file descriptor associated with this transport.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(MakeAllCOTSServerListeners)(char *port, int *partial_ret,
+int *count_ret, XtransConnInfo **connections_ret)
+    </para>
+    <para>
+This function should be used by most servers. It will try to establish
+a COTS server endpoint for each transport listed in the transport table.
+<parameter>partial_ret</parameter> will be set to <symbol>True</symbol> if
+only a partial network could be created. <parameter>count_ret</parameter> is
+the number of transports returned, and <parameter>connections_ret</parameter>
+is the list of transports.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int TRANS(MakeAllCLTSServerListeners)( char *port, int *partial_ret,
+int *count_ret, XtransConnInfo **connections_ret)
+    </para>
+    <para>
+This function should be used by most servers. It will try to establish a
+CLTS server endpoint for each transport listed in the transport table.
+<parameter>partial_ret</parameter> will be set to <symbol>True</symbol> if
+only a partial network could be created. <parameter>count_ret</parameter> is
+the number of transports returned, and <parameter>connections_ret</parameter>
+is the list of transports.
+    </para>
+  </listitem>
+</itemizedlist>
+</sect1>
+
+<sect1 id='Utility_API'>
+<title>Utility API</title>
+<para>
+This section describes a few useful functions that have been implemented on
+top of the Core Interface API.  These functions are being provided as a
+convenience.
+</para>
+<itemizedlist mark='bullet'>
+  <listitem>
+    <para>
+int TRANS(ConvertAddress)(int *familyp, int *addrlenp, Xtransaddr *addrp)
+    </para>
+    <para>
+This function converts a sockaddr based address to an X authorization based
+address (ie AF_INET, AF_UNIX to the X protocol definition (ie FamilyInternet,
+FamilyLocal)).
+    </para>
+  </listitem>
+</itemizedlist>
+</sect1>
+</chapter>
+
+<chapter id='Transport_Option_Definition'>
+<title>Transport Option Definition</title>
+<para>
+The following options are defined for the
+<function>TRANS(SetOption)()</function>
+ function. If an OS or transport does not support any of these options,
+then it will silently ignore the option.
+</para>
+
+<itemizedlist mark='bullet'>
+  <listitem>
+    <para>
+<symbol>TRANS_NONBLOCKING</symbol>
+    </para>
+    <para>
+This option controls the blocking mode of the connection. If the argument
+is set to 1, then the connection will be set to blocking. If the argument
+is set to 0, then the connection will be set to non- blocking.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+<symbol>TRANS_CLOSEONEXEC</symbol>
+    </para>
+    <para>
+This option determines what will happen to the connection when an exec is
+encountered. If the argument is set to 1, then the connection will be
+closed when an exec occurs. If the argument is set to 0, then the
+connection will not be closed when an exec occurs.
+    </para>
+  </listitem>
+</itemizedlist>
+</chapter>
+
+<chapter id='Hidden_Transport_Dependent_API'>
+<title>Hidden Transport Dependent API</title>
+<para>
+The hidden transport dependent functions are placed in the Xtransport record.
+These function are similar to the Exposed Transport Independent API, but
+some of the parameters and return values are slightly different.  Stuff like
+the <code>#ifdef SUNSYSV</code> should be handled inside these functions.
+</para>
+
+<itemizedlist mark='bullet'>
+  <listitem>
+    <para>
+XtransConnInfo *OpenCOTSClient (
+struct _Xtransport *thistrans, char *protocol, char *host, char *port)
+    </para>
+    <para>
+This function creates a Connection-Oriented Transport. The parameter
+<parameter>thistrans</parameter>
+points to an Xtransport entry in the transport table. The parameters
+<parameter>protocol</parameter>,
+<parameter>host</parameter>,  and
+<parameter>port</parameter>, point to strings containing the corresponding
+parts of the address that was passed into <function>TRANS(OpenCOTSClient)()</function>.
+This function must allocate and initialize the contents of the XtransConnInfo
+structure that is returned by this function. This function will open the
+transport, and bind it into the transport namespace if applicable. The local
+address portion of the XtransConnInfo structure will also be filled in by
+this function.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo *OpenCOTSServer (
+struct _Xtransport *thistrans, char *protocol, char *host, char *port)
+    </para>
+    <para>
+This function creates a Connection-Oriented Transport. The parameter
+<parameter>thistrans</parameter>
+points to an Xtransport entry in the transport table. The
+parameters
+<parameter>protocol</parameter>,
+<parameter>host</parameter>, and
+<parameter>port</parameter> point to strings containing the
+corresponding parts of the address that was passed into
+<function>TRANS(OpenCOTSClient)()</function>.
+This function must allocate and initialize the contents of the
+XtransConnInfo structure that is returned by this function. This function
+will open the transport.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo *OpenCLTSClient (
+struct _Xtransport *thistrans, char *protocol, char *host, char *port)
+    </para>
+    <para>
+This function creates a Connection-Less Transport. The parameter
+<parameter>thistrans</parameter>
+points to an Xtransport entry in the transport table. The parameters
+<parameter>protocol</parameter>,
+<parameter>host</parameter>, and
+<parameter>port</parameter> point to strings containing the
+corresponding parts of the address that was passed into
+<function>TRANS(OpenCOTSClient)()</function>.
+This function must allocate and initialize the contents of the XtransConnInfo
+structure that is returned by this function. This function will open the
+transport, and bind it into the transport namespace if applicable. The
+local address portion of the XtransConnInfo structure will also be filled
+in by this function.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+XtransConnInfo *OpenCLTSServer (
+struct _Xtransport *thistrans, char *protocol, char *host, char *port)
+    </para>
+    <para>
+This function creates a Connection-Less Transport. The parameter
+<parameter>thistrans</parameter>
+points to an Xtransport entry in the transport table. The  parameters
+<parameter>protocol</parameter>,
+<parameter>host</parameter>, and
+<parameter>port</parameter> point to strings containing the
+corresponding parts of the address that was passed into
+<function>TRANS(OpenCOTSClient)()</function>.
+This function must allocate and initialize the contents of the
+XtransConnInfo structure that is returned by this function. This
+function will open the transport.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int SetOption (struct _Xtransport *thistrans, int option, int arg)
+    </para>
+    <para>
+This function provides a transport dependent way of implementing the
+options defined by the X Transport Interface. In the current prototype,
+this function is not being used, because all of the options defined so far
+are transport independent. This function will have to be used if a radically
+different transport type is added, or a transport dependent option is defined.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int CreateListener (struct _Xtransport *thistrans, char *port, int flags )
+    </para>
+    <para>
+This function takes a transport endpoint opened for a server, and sets it
+up to listen for incoming connection requests. The parameter
+<parameter>port</parameter>
+contains the port portion of the address that was passed to the Open function.
+The parameter <parameter>flags</parameter> should be set to
+<symbol>ADDR_IN_USE_ALLOWED</symbol> if the underlying transport endpoint
+may be already bound and this should not be considered
+as an error. Otherwise flags should be set to 0. This is used by IPv6 code,
+where the same socket can be bound to both an IPv6 address and then to a
+IPv4 address.  This function will bind the transport into the transport
+name space if applicable, and fill in the local address portion of the
+XtransConnInfo structure. The transport endpoint will then be set to
+listen for incoming connection requests.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int ResetListener (struct _Xtransport *thistrans)
+    </para>
+    <para>
+This function resets the transport for listening.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+ XtransConnInfo Accept(struct _Xtransport *thistrans)
+    </para>
+    <para>
+This function creates a new transport endpoint as a result of an
+incoming connection request. The parameter
+<parameter>thistrans</parameter> is the endpoint
+that was opened for listening by the server. The new endpoint is
+opened and bound into the transport’s namespace. A XtransConnInfo
+structure describing the new endpoint is returned from this function
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Connect(struct _Xtransport *thistrans, char *host, char *port )
+    </para>
+    <para>
+This function establishes a connection to a server. The parameters
+<parameter>host</parameter>  and
+<parameter>port</parameter>
+describe the server to which the connection should be
+established. The connection will be established so that
+<function>Read()</function> and
+<function>Write()</function> call can be made.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int BytesReadable(struct _Xtransport *thistrans, BytesReadable_t *pend )
+    </para>
+    <para>
+This function replaces the
+<function>BytesReadable()</function>
+macro. This allows each transport to have it’s own mechanism for determining
+how much data is ready to be read.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Read(struct _Xtransport *thistrans, char *buf, int size )
+    </para>
+    <para>
+This function reads size bytes into buf from the connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Write(struct _Xtransport *thistrans, char *buf, int size )
+    </para>
+    <para>
+This function writes size bytes from buf to the connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Readv(struct _Xtransport *thistrans, struct iovec *buf, int size )
+    </para>
+    <para>
+This function performs a <function>readv()</function> on the connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Writev(struct _Xtransport *thistrans, struct iovec *buf, int size )
+    </para>
+    <para>
+This function performs a <function>writev()</function> on the connection.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Disconnect(struct _Xtransport *thistrans)
+    </para>
+    <para>
+This function initiates an orderly shutdown of a connection. If a
+transport does not distinguish between orderly and disorderly
+disconnects, then a call to this function will have no affect.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+int Close(struct _Xtransport *thistrans)
+    </para>
+    <para>
+This function will break the connection, and close the endpoint.
+    </para>
+  </listitem>
+</itemizedlist>
+</chapter>
+<chapter id='Configuration'>
+<title>Configuration</title>
+
+<para>
+The implementation of each transport can be platform specific. It is expected
+that existing connection types such as <symbol>TCPCONN</symbol>,
+<symbol>UNIXCONN</symbol>, <symbol>LOCALCONN</symbol>, and
+<symbol>STREAMSCONN</symbol> will be replaced with flags for each
+possible transport type.
+</para>
+<para>
+In X11R6, the below flags to enable transport types were set in
+<symbol>ConnectionFlags</symbol> in the <filename>vendor.cf</filename> or
+<filename>site.def</filename> config files.
+</para>
+<para>
+In X11R7 modular releases, these flags are set when running
+<filename>configure</filename> scripts which include the
+<function>XTRANS_CONNECTION_FLAGS</function> macro from
+<filename>xtrans.m4</filename>.
+</para>
+
+<informaltable frame='topbot'>
+  <tgroup cols='3' align='left' colsep='0' rowsep='0'>
+    <colspec colname='define' colwidth='1.0*' />
+    <colspec colname='enable' colwidth='2.0*' />
+    <colspec colname='desc'   colwidth='2.0*'/>
+    <thead>
+      <row rowsep='1'>
+       <entry><code>#define</code></entry>
+       <entry>configure flag</entry>
+       <entry>Description</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+       <entry><symbol>TCPCONN</symbol></entry>
+       <entry><option>--enable-tcp-transport</option></entry>
+       <entry>
+       Enables the INET (IPv4) Domain Socket based transport
+       </entry>
+      </row>
+      <row>
+       <entry><symbol>IPv6</symbol></entry>
+       <entry><option>--enable-ipv6</option></entry>
+       <entry>
+       Extends <symbol>TCPCONN</symbol> to enable IPv6 Socket based transport
+       </entry>
+      </row>
+      <row>
+       <entry><symbol>UNIXCONN</symbol></entry>
+       <entry><option>--enable-unix-transport</option></entry>
+       <entry>
+       Enables the UNIX Domain Socket based transport
+       </entry>
+      </row>
+      <row>
+       <entry><symbol>STREAMSCONN</symbol></entry>
+       <entry><emphasis>Not available in X11R7</emphasis></entry>
+       <entry>
+       Enables the TLI based transports
+       </entry>
+      </row>
+      <row>
+       <entry><symbol>LOCALCONN</symbol></entry>
+       <entry><option>--enable-local-transport</option></entry>
+       <entry>
+       Enables the SYSV Local connection transports
+       </entry>
+      </row>
+      <row>
+       <entry><symbol>DNETCONN</symbol></entry>
+       <entry><emphasis>Not available in X11R7</emphasis></entry>
+       <entry>
+       Enables the DECnet transports
+       </entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+
+</chapter>
+
+<chapter id='Transport_Specific_Definitions'>
+<title>Transport Specific Definitions</title>
+
+<informaltable frame='all' colsep='1' rowsep='1'>
+  <tgroup cols='4' align='center'>
+    <colspec colname='c1' colwidth='1.0*'/>
+    <colspec colname='c2' colwidth='1.0*'/>
+    <colspec colname='c3' colwidth='3.0*'/>
+    <colspec colname='c4' colwidth='2.0*'/>
+    <thead>
+      <row>
+        <entry morerows="1">Protocol Family</entry>
+        <entry namest="c2" nameend="c4"  align='center'>Address Component</entry>
+      </row>
+      <row>
+        <entry align='center'>protocol</entry>
+        <entry align='center'>host</entry>
+        <entry align='center'>port</entry>
+      </row>
+    </thead>
+    <tbody>
+      <row>
+        <entry>Internet</entry>
+        <entry>inet inet6 tcp udp</entry>
+        <entry>name of an internet addressable host</entry>
+        <entry>string containing the name of a service or a valid port number.  Example: "xserver0", "7100"</entry>
+      </row>
+      <row>
+        <entry>DECnet</entry>
+        <entry>decnet</entry>
+        <entry>name of a DECnet addressable host</entry>
+        <entry>string containing the complete name of the object.  Example: "X$X0"</entry>
+      </row>
+      <row>
+        <entry>NETware</entry>
+        <entry>ipx</entry>
+        <entry>name of a NETware addressable host</entry>
+        <entry>Not sure of the specifics yet.</entry>
+      </row>
+      <row>
+        <entry>OSI</entry>
+        <entry>osi</entry>
+        <entry>name of an OSI adressable host.</entry>
+        <entry>Not sure of the specifics yet.</entry>
+      </row>
+      <row>
+        <entry>Local</entry>
+        <entry>local pts named sco isc</entry>
+        <entry>(ignored)</entry>
+        <entry>String containing the port name, ie "xserver0", "fontserver0".</entry>
+      </row>
+    </tbody>
+  </tgroup>
+</informaltable>
+
+</chapter>
+
+<chapter id='Implementation_Notes'>
+<title>Implementation Notes</title>
+<para>
+This section refers to the prototype implementation that is being developed
+concurrently with this document. This prototype has been able to flush out many
+details and problems as the specification was being developed.
+</para>
+<para>
+In X11R6, all of the source code for this interface was located in
+<filename>xc/lib/xtrans</filename>.
+</para>
+<para>
+In X11R7, all of the source code for this interface is delivered via
+the <systemitem>lib/libxtrans</systemitem> modular package from X.Org,
+and is installed under
+<filename><replaceable>${prefix}</replaceable>/X11/Xtrans</filename>
+so that other modules may find it when they build.
+</para>
+<para>
+All functions names in the source are of the format
+<function>TRANS(func)()</function>. The
+<function>TRANS()</function>
+macro is defined as
+<programlisting language="C">
+#if (__STDC__ &amp;&amp; !defined(UNIXCPP)) || defined(ANSICPP)
+#define TRANS(func) _PROTOCOLTrans##func
+#else
+#define TRANS(func) _PROTOCOLTrans/**/func
+#endif
+</programlisting>
+</para>
+
+<para>
+<symbol>PROTOCOL</symbol> will be uniquely defined in each directory
+where this code is compiled.
+<symbol>PROTOCOL</symbol> will be defined to be the name of the protocol
+that is implemented by the library or server, such as X11, FS, and ICE.
+</para>
+
+<para>
+All libraries and servers that use the X Transport Interface should have a new
+file called <filename><replaceable>TRANSPORT</replaceable>trans.c</filename>.
+This file will include the transports based on the configuration flags
+provided by the <filename>configure</filename> script. Below is an
+example <filename>xfstrans.c</filename> for the font server.
+</para>
+
+<programlisting language="C">
+#include "config.h"
+
+#define FONT_t 1
+#define TRANS_REOPEN 1
+#define TRANS_SERVER 1
+
+#include &lt;X11/Xtrans/transport.c&gt;
+</programlisting>
+<para>
+The source files for this interface are listed below.
+</para>
+
+<variablelist>
+  <varlistentry>
+    <term><filename>Xtrans.h</filename></term>
+    <listitem><para>
+Function prototypes and defines for the Transport Independent API.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtransint.h</filename></term>
+    <listitem><para>
+Used by the interface implementation only.
+Contains the internal data structures.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtranssock.c</filename></term>
+    <listitem><para>
+Socket implementation of the Transport Dependent API.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtranstli.c</filename></term>
+    <listitem><para>
+TLI implementation of the Transport Dependent API.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtransdnet.c</filename></term>
+    <listitem><para>
+DECnet implementation of the Transport Dependent API.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtranslocal.c</filename></term>
+    <listitem><para>
+Implementation of the Transport Dependent API for SYSV Local connections.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtrans.c</filename></term>
+    <listitem><para>
+Exposed Transport Independent API Functions.
+    </para></listitem>
+  </varlistentry>
+  <varlistentry>
+    <term><filename>Xtransutil.c</filename></term>
+    <listitem><para>
+Collection of Utility functions that use the X Transport Interface.
+    </para></listitem>
+  </varlistentry>
+</variablelist>
+
+
+<para>
+The file <filename>Xtransint.h</filename> contains much of the transport
+related code that was previously in <filename>Xlibint.h</filename> and
+<filename>Xlibnet.h</filename>.
+This will make the definitions available for all transport users. This
+should also obsolete the equivalent code in other libraries.
+</para>
+
+</chapter>
+</book>
diff --git a/docbook.am b/docbook.am
new file mode 100644 (file)
index 0000000..bba4d54
--- /dev/null
@@ -0,0 +1,105 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook:  the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+if HAVE_XMLTO
+if HAVE_STYLESHEETS
+
+XMLTO_SEARCHPATH_FLAGS =                               \
+       --searchpath "$(XORG_SGML_PATH)/X11"            \
+       --searchpath "$(abs_top_builddir)"
+XMLTO_HTML_OLINK_FLAGS = \
+       --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.html.xml \
+       --stringparam current.docid="$(<:.xml=)"
+XMLTO_HTML_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl
+XMLTO_HTML_FLAGS =                                     \
+       $(XMLTO_SEARCHPATH_FLAGS)                       \
+       $(XMLTO_HTML_STYLESHEET_FLAGS)                  \
+       $(XMLTO_HTML_OLINK_FLAGS)
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml $(chapters)
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_XMLTO_TEXT
+
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_HTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+if HAVE_FOP
+XMLTO_FO_IMAGEPATH_FLAGS = --stringparam img.src.path=$(abs_builddir)/
+XMLTO_PDF_OLINK_FLAGS = \
+       --stringparam target.database.document=$(XORG_SGML_PATH)/X11/dbs/masterdb.pdf.xml \
+       --stringparam current.docid="$(<:.xml=)"
+XMLTO_FO_STYLESHEET_FLAGS = -x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+
+XMLTO_FO_FLAGS =                                       \
+       $(XMLTO_SEARCHPATH_FLAGS)                       \
+       $(XMLTO_FO_STYLESHEET_FLAGS)                    \
+       $(XMLTO_FO_IMAGEPATH_FLAGS)                     \
+       $(XMLTO_PDF_OLINK_FLAGS)
+
+shelf_DATA += $(docbook:.xml=.pdf)
+%.pdf: %.xml $(chapters)
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+
+shelf_DATA += $(docbook:.xml=.ps)
+%.ps: %.xml $(chapters)
+       $(AM_V_GEN)$(XMLTO) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+# Generate documents cross-reference target databases
+if HAVE_XSLTPROC
+
+XSLT_SEARCHPATH_FLAGS =                                \
+       --path "$(XORG_SGML_PATH)/X11"                  \
+       --path "$(abs_top_builddir)"
+XSLT_OLINK_FLAGS =                                     \
+       --stringparam targets.filename "$@"             \
+       --stringparam collect.xref.targets "only"       \
+       --stringparam olink.base.uri "$(@:.db=)"
+
+XSLT_HTML_FLAGS =                                      \
+       $(XSLT_SEARCHPATH_FLAGS)                        \
+       $(XSLT_OLINK_FLAGS)                             \
+       --nonet --xinclude                              \
+       $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl
+XSLT_PDF_FLAGS =                                       \
+       $(XSLT_SEARCHPATH_FLAGS)                        \
+       $(XSLT_OLINK_FLAGS)                             \
+       --nonet --xinclude                              \
+       $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+
+shelf_DATA += $(docbook:.xml=.html.db)
+%.html.db: %.xml  $(chapters)
+       $(AM_V_GEN)$(XSLTPROC) $(XSLT_HTML_FLAGS) $<
+
+shelf_DATA += $(docbook:.xml=.pdf.db)
+%.pdf.db: %.xml $(chapters)
+       $(AM_V_GEN)$(XSLTPROC) $(XSLT_PDF_FLAGS) $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+endif HAVE_XMLTO
+
+CLEANFILES = $(shelf_DATA)
diff --git a/packaging/xorg-x11-xtrans-devel.spec b/packaging/xorg-x11-xtrans-devel.spec
new file mode 100644 (file)
index 0000000..bcd1a2e
--- /dev/null
@@ -0,0 +1,55 @@
+# NOTE: This package contains only C source and header files and pkg-config
+# *.pc files, and does not contain any ELF binaries or DSOs, so we disable
+# debuginfo generation.
+%define debug_package %{nil}
+
+Summary: X.Org X11 developmental X transport library
+Name: xorg-x11-xtrans-devel
+Version: 1.2.7
+Release: 2
+License: MIT
+Group: System Environment/Libraries
+URL: http://www.x.org
+BuildArch: noarch
+
+Source0: %{name}-%{version}.tar.gz
+
+BuildRequires: pkgconfig
+BuildRequires:  pkgconfig(xorg-macros)
+BuildRequires: xorg-x11-xutils-dev
+
+%description
+X.Org X11 developmental X transport library
+
+%prep
+%setup -q
+
+%build
+
+# yes, this looks horrible, but it's to get the .pc file in datadir
+%reconfigure --libdir=%{_datadir} \
+          --docdir=%{_docdir}/%{name}-%{version}-%{release}
+# Running 'make' not needed.
+
+%install
+make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p"
+
+%remove_docs
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS ChangeLog COPYING README
+%dir %{_includedir}/X11
+%dir %{_includedir}/X11/Xtrans
+%{_includedir}/X11/Xtrans/Xtrans.c
+%{_includedir}/X11/Xtrans/Xtrans.h
+%{_includedir}/X11/Xtrans/Xtransint.h
+%{_includedir}/X11/Xtrans/Xtranslcl.c
+%{_includedir}/X11/Xtrans/Xtranssock.c
+%{_includedir}/X11/Xtrans/Xtranstli.c
+%{_includedir}/X11/Xtrans/Xtransutil.c
+%{_includedir}/X11/Xtrans/transport.c
+%{_datadir}/aclocal/xtrans.m4
+%{_datadir}/pkgconfig/xtrans.pc
+#%dir %{_docdir}/%{name}-%{version}-%{release}
+#%{_docdir}/%{name}-%{version}-%{release}/xtrans.xml
diff --git a/transport.c b/transport.c
new file mode 100644 (file)
index 0000000..2cb8882
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+
+Copyright 1993, 1994, 1998  The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+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 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+ * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, provided
+ * that the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name NCR not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.  NCR makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+
+#define XTRANS_TRANSPORT_C  /* used to flag Xtransint.h that it's being used
+                              here, not just #included in another file */
+
+#include "Xtransint.h"
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+#ifdef LOCALCONN
+#include "Xtranslcl.c"
+#endif
+#if defined(TCPCONN) || defined(UNIXCONN)
+#include "Xtranssock.c"
+#endif
+#ifdef STREAMSCONN
+#include "Xtranstli.c"
+#endif
+#include "Xtrans.c"
+#include "Xtransutil.c"
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
diff --git a/xtrans.m4 b/xtrans.m4
new file mode 100644 (file)
index 0000000..91c6f9d
--- /dev/null
+++ b/xtrans.m4
@@ -0,0 +1,137 @@
+dnl
+dnl Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+dnl
+dnl Permission is hereby granted, free of charge, to any person obtaining a
+dnl copy of this software and associated documentation files (the "Software"),
+dnl to deal in the Software without restriction, including without limitation
+dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
+dnl and/or sell copies of the Software, and to permit persons to whom the
+dnl Software is furnished to do so, subject to the following conditions:
+dnl
+dnl The above copyright notice and this permission notice (including the next
+dnl paragraph) shall be included in all copies or substantial portions of the
+dnl Software.
+dnl
+dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+dnl DEALINGS IN THE SOFTWARE.
+dnl
+
+# XTRANS_TCP_FLAGS()
+# ------------------
+# Find needed libraries for TCP sockets, and check for IPv6 support
+AC_DEFUN([XTRANS_TCP_FLAGS],[
+ # SVR4 hides these in libraries other than libc
+ AC_SEARCH_LIBS(socket, [socket])
+ AC_SEARCH_LIBS(gethostbyname, [nsl])
+ if test "$ac_cv_search_socket$ac_cv_search_gethostbyname" = "nono"; then
+   AC_HAVE_LIBRARY([ws2_32])
+ fi
+
+ # Needs to come after above checks for libsocket & libnsl for SVR4 systems
+ AC_ARG_ENABLE(ipv6,
+       AC_HELP_STRING([--enable-ipv6],[Enable IPv6 support]),
+       [IPV6CONN=$enableval],
+       [AC_CHECK_FUNC(getaddrinfo,[IPV6CONN=yes],[IPV6CONN=no])])
+ AC_MSG_CHECKING([if IPv6 support should be built])
+ if test "$IPV6CONN" = "yes"; then
+       AC_DEFINE(IPv6,1,[Support IPv6 for TCP connections])
+ fi
+ AC_MSG_RESULT($IPV6CONN)
+
+ # 4.3BSD-Reno added a new member to struct sockaddr_in
+ AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
+       AC_DEFINE([BSD44SOCKETS],1,
+           [Define to 1 if `struct sockaddr_in' has a `sin_len' member]), [], [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+ ])
+
+ # POSIX.1g changed the type of pointer passed to getsockname/getpeername/etc.
+ AC_CHECK_TYPES([socklen_t], [], [], [
+AC_INCLUDES_DEFAULT
+#include <sys/socket.h>])
+
+]) # XTRANS_TCP_FLAGS
+
+# XTRANS_CONNECTION_FLAGS()
+# -------------------------
+# Standard checks for which Xtrans transports to use by the Xorg packages
+# that use Xtrans functions
+AC_DEFUN([XTRANS_CONNECTION_FLAGS],[
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([AC_TYPE_SIGNAL])
+ [case $host_os in
+       mingw*) unixdef="no"   ;;
+       *)      unixdef="yes"  ;;
+ esac]
+ AC_ARG_ENABLE(unix-transport,
+       AC_HELP_STRING([--enable-unix-transport],[Enable UNIX domain socket transport]),
+       [UNIXCONN=$enableval], [UNIXCONN=$unixdef])
+ AC_MSG_CHECKING([if Xtrans should support UNIX socket connections])
+ if test "$UNIXCONN" = "yes"; then
+       AC_DEFINE(UNIXCONN,1,[Support UNIX socket connections])
+ fi
+ AC_MSG_RESULT($UNIXCONN)
+ AC_ARG_ENABLE(tcp-transport,
+       AC_HELP_STRING([--enable-tcp-transport],[Enable TCP socket transport]),
+       [TCPCONN=$enableval], [TCPCONN=yes])
+ AC_MSG_CHECKING([if Xtrans should support TCP socket connections])
+ AC_MSG_RESULT($TCPCONN)
+ if test "$TCPCONN" = "yes"; then
+       AC_DEFINE(TCPCONN,1,[Support TCP socket connections])
+       XTRANS_TCP_FLAGS
+ fi
+ [case $host_os in
+       solaris*|sco*|sysv4*)   localdef="yes" ;;
+       *)                      localdef="no"  ;;
+ esac]
+ AC_ARG_ENABLE(local-transport,
+       AC_HELP_STRING([--enable-local-transport],[Enable os-specific local transport]),
+       [LOCALCONN=$enableval], [LOCALCONN=$localdef])
+ AC_MSG_CHECKING([if Xtrans should support os-specific local connections])
+ AC_MSG_RESULT($LOCALCONN)
+ if test "$LOCALCONN" = "yes"; then
+       AC_DEFINE(LOCALCONN,1,[Support os-specific local connections])
+ fi
+
+]) # XTRANS_CONNECTION_FLAGS
+
+
+# XTRANS_SECURE_RPC_FLAGS()
+# -------------------------
+# Check for Secure RPC functions - must come after XTRANS_TCP_FLAGS
+# so that any necessary networking libraries are already found
+AC_DEFUN([XTRANS_SECURE_RPC_FLAGS],
+[AC_REQUIRE([XTRANS_TCP_FLAGS])
+ AC_ARG_ENABLE(secure-rpc,
+       AC_HELP_STRING([--enable-secure-rpc],[Enable Secure RPC]),
+        [SECURE_RPC=$enableval], [SECURE_RPC="try"])
+
+ if test "x$SECURE_RPC" = "xyes" -o "x$SECURE_RPC" = "xtry" ; then
+       FOUND_SECURE_RPC="no"
+       AC_CHECK_FUNCS([authdes_seccreate authdes_create],
+                       [FOUND_SECURE_RPC="yes"])
+       if test "x$FOUND_SECURE_RPC" = "xno" ; then
+               if test "x$SECURE_RPC" = "xyes" ; then
+       AC_MSG_ERROR([Secure RPC requested, but required functions not found])
+               fi
+               SECURE_RPC="no"
+       else
+               dnl FreeBSD keeps getsecretkey in librpcsvc
+               AC_SEARCH_LIBS(getsecretkey, [rpcsvc])
+               SECURE_RPC="yes"
+       fi
+ fi
+ AC_MSG_CHECKING([if Secure RPC authentication ("SUN-DES-1") should be supported])
+ if test "x$SECURE_RPC" = "xyes" ; then
+       AC_DEFINE(SECURE_RPC, 1, [Support Secure RPC ("SUN-DES-1") authentication for X11 clients])
+ fi
+ AC_MSG_RESULT($SECURE_RPC)
+]) # XTRANS_SECURE_RPC_FLAGS
+
diff --git a/xtrans.pc.in b/xtrans.pc.in
new file mode 100644 (file)
index 0000000..90d19b1
--- /dev/null
@@ -0,0 +1,9 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: XTrans
+Description: Abstract network code for X
+Version: @PACKAGE_VERSION@
+Cflags: -I${includedir} -D_BSD_SOURCE @fchown_define@ @sticky_bit_define@