Commit acb541bc authored by Kaleb Keithley Keithley's avatar Kaleb Keithley Keithley
Browse files

merge latest (4.3.99.16) from XFree86 (vendor) branch

parent d93c194c
......@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/xtrans/Xtrans.c,v 3.28 2002/11/20 23:00:36 dawes Exp $ */
/* $XFree86: xc/lib/xtrans/Xtrans.c,v 3.33 2003/08/11 17:41:29 eich Exp $ */
/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
*
......@@ -78,6 +78,7 @@ from The Open Group.
#define TRANS_LOCAL_NAMED_INDEX 11
#define TRANS_LOCAL_ISC_INDEX 12
#define TRANS_LOCAL_SCO_INDEX 13
#define TRANS_SOCKET_INET6_INDEX 14
static
......@@ -89,6 +90,9 @@ Xtransport_table Xtransports[] = {
#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(DNETCONN)
......@@ -100,6 +104,9 @@ Xtransport_table Xtransports[] = {
#endif /* !LOCALCONN */
{ &TRANS(SocketUNIXFuncs), TRANS_SOCKET_UNIX_INDEX },
#endif /* UNIXCONN */
#if defined(OS2PIPECONN)
{ &TRANS(OS2LocalFuncs), TRANS_LOCAL_LOCAL_INDEX },
#endif /* OS2PIPECONN */
#if defined(LOCALCONN)
{ &TRANS(LocalFuncs), TRANS_LOCAL_LOCAL_INDEX },
#ifndef sun
......@@ -134,7 +141,7 @@ void
TRANS(FreeConnInfo) (XtransConnInfo ciptr)
{
PRMSG (3,"FreeConnInfo(%x)\n", ciptr, 0, 0);
PRMSG (3,"FreeConnInfo(%p)\n", ciptr, 0, 0);
if (ciptr->addr)
xfree (ciptr->addr);
......@@ -166,6 +173,7 @@ TRANS(SelectTransport) (char *protocol)
*/
strncpy (protobuf, protocol, PROTOBUFSIZE - 1);
protobuf[PROTOBUFSIZE-1] = '\0';
for (i = 0; i < PROTOBUFSIZE && protobuf[i] != '\0'; i++)
if (isupper (protobuf[i]))
......@@ -198,7 +206,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
* Other than fontlib, the address is a string formatted
* as "protocol/host:port".
*
* If the protocol part is missing, then assume INET.
* 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.
*/
......@@ -206,6 +214,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
char *mybuf, *tmpptr;
char *_protocol, *_host, *_port;
char hostnamebuf[256];
int _host_len;
PRMSG (3,"ParseAddress(%s)\n", address, 0, 0);
......@@ -220,9 +229,11 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
_protocol = mybuf;
if ((mybuf = strpbrk (mybuf,"/:")) == NULL)
{
/* adress is in a bad format */
if ( ((mybuf = strchr (mybuf,'/')) == NULL) &&
((mybuf = strrchr (tmpptr,':')) == NULL) )
{
/* address is in a bad format */
*protocol = NULL;
*host = NULL;
*port = NULL;
......@@ -233,7 +244,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
if (*mybuf == ':')
{
/*
* If there is a hostname, then assume inet, otherwise
* If there is a hostname, then assume tcp, otherwise
* it must be local.
*/
if (mybuf == tmpptr)
......@@ -243,8 +254,8 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
}
else
{
/* Ther is a hostname specified */
_protocol = "inet";
/* There is a hostname specified */
_protocol = "tcp";
mybuf = tmpptr; /* reset to the begining of the host ptr */
}
}
......@@ -257,11 +268,11 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
if (strlen(_protocol) == 0)
{
/*
* If there is a hostname, then assume inet, otherwise
* If there is a hostname, then assume tcp, otherwise
* it must be local.
*/
if (*mybuf != ':')
_protocol = "inet";
_protocol = "tcp";
else
_protocol = "local";
}
......@@ -271,7 +282,7 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
_host = mybuf;
if ((mybuf = strchr (mybuf,':')) == NULL)
if ((mybuf = strrchr (mybuf,':')) == NULL)
{
*protocol = NULL;
*host = NULL;
......@@ -280,21 +291,51 @@ TRANS(ParseAddress) (char *address, char **protocol, char **host, char **port)
return 0;
}
*mybuf ++= '\0';
/* Check for DECnet */
if (strlen(_host) == 0)
if ((mybuf != _host) && (*(mybuf - 1) == ':')
#if defined(IPv6) && defined(AF_INET6)
/* An IPv6 address can end in :: so three : in a row is assumed to be
an IPv6 host and not a DECnet node with a : in it's name, unless
DECnet is specifically requested */
&& ( ((mybuf - 1) == _host) || (*(mybuf - 2) != ':') ||
((_protocol != NULL) && (strcmp(_protocol, "dnet") == 0)) )
#endif
)
{
TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf));
_host = hostnamebuf;
_protocol = "dnet";
*(mybuf - 1) = '\0';
}
/* Check for DECnet */
*mybuf ++= '\0';
if (*mybuf == ':')
_host_len = strlen(_host);
if (_host_len == 0)
{
_protocol = "dnet";
mybuf++;
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 */
......@@ -727,10 +768,10 @@ TRANS(SetOption) (XtransConnInfo ciptr, int option, int arg)
#ifdef TRANS_SERVER
int
TRANS(CreateListener) (XtransConnInfo ciptr, char *port)
TRANS(CreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
{
return ciptr->transptr->CreateListener (ciptr, port);
return ciptr->transptr->CreateListener (ciptr, port, flags);
}
int
......@@ -738,6 +779,7 @@ TRANS(NoListen) (char * protocol)
{
Xtransport *trans;
int i = 0, ret = 0;
if ((trans = TRANS(SelectTransport)(protocol)) == NULL)
{
......@@ -746,9 +788,16 @@ TRANS(NoListen) (char * 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 0;
return ret;
}
int
......@@ -996,8 +1045,11 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_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,%x)\n",
PRMSG (2,"MakeAllCOTSServerListeners(%s,%p)\n",
port ? port : "NULL", ciptrs_ret, 0);
*count_ret = 0;
......@@ -1005,6 +1057,7 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
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;
......@@ -1024,8 +1077,13 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
trans->TransName, 0, 0);
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))) < 0)
if ((status = TRANS(CreateListener (ciptr, port, flags))) < 0)
{
if (status == TRANS_ADDR_IN_USE)
{
......@@ -1057,6 +1115,11 @@ TRANS(MakeAllCOTSServerListeners) (char *port, int *partial, int *count_ret,
}
}
#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, 0);
......@@ -1099,7 +1162,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
XtransConnInfo ciptr, temp_ciptrs[NUMTRANS];
int status, i, j;
PRMSG (2,"MakeAllCLTSServerListeners(%s,%x)\n",
PRMSG (2,"MakeAllCLTSServerListeners(%s,%p)\n",
port ? port : "NULL", ciptrs_ret, 0);
*count_ret = 0;
......@@ -1124,7 +1187,7 @@ TRANS(MakeAllCLTSServerListeners) (char *port, int *partial, int *count_ret,
continue;
}
if ((status = TRANS(CreateListener (ciptr, port))) < 0)
if ((status = TRANS(CreateListener (ciptr, port, 0))) < 0)
{
if (status == TRANS_ADDR_IN_USE)
{
......
......@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/xtrans/Xtrans.h,v 3.18 2001/12/14 19:57:04 dawes Exp $ */
/* $XFree86: xc/lib/xtrans/Xtrans.h,v 3.22 2003/07/24 13:50:19 eich Exp $ */
/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
*
......@@ -57,6 +57,14 @@ from The Open Group.
#include <X11/Xfuncproto.h>
#include <X11/Xos.h>
#ifndef WIN32
#ifndef Lynx
#include <sys/socket.h>
#else
#include <socket.h>
#endif
#endif
/*
* Set the functions names according to where this code is being compiled.
......@@ -83,7 +91,7 @@ static char* __xtransname = "_X11Trans";
static char* __xtransname = "_XSERVTrans";
#endif
#define X11_t
#endif /* X11_t */
#endif /* XSERV_t */
#ifdef XIM_t
#if !defined(UNIXCPP) || defined(ANSICPP)
......@@ -173,12 +181,15 @@ static char* __xtransname = "_XTrans";
* 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;
......@@ -328,7 +339,8 @@ int TRANS(SetOption)(
int TRANS(CreateListener)(
XtransConnInfo, /* ciptr */
char * /* port */
char *, /* port */
unsigned int /* flags */
);
int TRANS(NoListen) (
......
......@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/xtrans/Xtransdnet.c,v 3.7 2002/11/26 01:12:30 dawes Exp $ */
/* $XFree86: xc/lib/xtrans/Xtransdnet.c,v 3.8 2003/08/26 15:38:39 tsi Exp $ */
/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
*
......@@ -340,7 +340,7 @@ TRANS(DNETSetOption) (XtransConnInfo ciptr, int option, int arg)
#ifdef TRANS_SERVER
static int
TRANS(DNETCreateListener) (XtransConnInfo ciptr, char *port)
TRANS(DNETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags)
{
struct sockaddr_dn dnsock;
......
......@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/xtrans/Xtransint.h,v 3.35 2002/11/26 01:12:30 dawes Exp $ */
/* $XFree86: xc/lib/xtrans/Xtransint.h,v 3.41 2003/08/28 00:35:23 tsi Exp $ */
/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
*
......@@ -81,106 +81,107 @@ from The Open Group.
#endif
#ifdef WIN32
#define _WILLWINSOCK_
# define _WILLWINSOCK_
#endif
#include "Xtrans.h"
#ifdef XTRANSDEBUG
#include <stdio.h>
# include <stdio.h>
#endif /* XTRANSDEBUG */
#include <errno.h>
#ifndef WIN32
#ifndef Lynx
#include <sys/socket.h>
#else
#include <socket.h>
#endif
#include <netinet/in.h>
#include <arpa/inet.h>
#ifdef __UNIXOS2__
#include <sys/ioctl.h>
#endif
# ifndef Lynx
# include <sys/socket.h>
# else
# include <socket.h>
# endif
# include <netinet/in.h>
# include <arpa/inet.h>
# ifdef __UNIXOS2__
# include <sys/ioctl.h>
# endif
/*
* 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(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || defined(SCO)
#ifndef NEED_UTSNAME
#define NEED_UTSNAME
#endif
#include <sys/utsname.h>
#endif
# if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(USG) || defined(SVR4) || defined(SCO)
# ifndef NEED_UTSNAME
# define NEED_UTSNAME
# endif
# include <sys/utsname.h>
# endif
/*
* makedepend screws up on #undef OPEN_MAX, so we define a new symbol
*/
#ifndef TRANS_OPEN_MAX
#ifndef X_NOT_POSIX
#ifdef _POSIX_SOURCE
#include <limits.h>
#else
#define _POSIX_SOURCE
#include <limits.h>
#undef _POSIX_SOURCE
#endif
#endif
#ifndef OPEN_MAX
#ifdef __GNU__
#define OPEN_MAX (sysconf(_SC_OPEN_MAX))
#endif
#ifdef SVR4
#define OPEN_MAX 256
#else
#include <sys/param.h>
#ifndef OPEN_MAX
#ifdef __OSF1__
#define OPEN_MAX 256
#else
#ifdef NOFILE
#define OPEN_MAX NOFILE
#else
#if !defined(__UNIXOS2__) && !defined(__QNX__)
#define OPEN_MAX NOFILES_MAX
#else
#define OPEN_MAX 256
#endif
#endif
#endif
#endif
#endif
#endif
#ifdef __GNU__
#define TRANS_OPEN_MAX OPEN_MAX
#else /* !__GNU__ */
#if OPEN_MAX > 256
#define TRANS_OPEN_MAX 256
#else
#define TRANS_OPEN_MAX OPEN_MAX
#endif
#endif /*__GNU__*/
#endif /* TRANS_OPEN_MAX */
#ifdef __UNIXOS2__
#define ESET(val)
#else
#define ESET(val) errno = val
#endif
#define EGET() errno
# ifndef TRANS_OPEN_MAX
# ifndef X_NOT_POSIX
# ifdef _POSIX_SOURCE
# include <limits.h>
# else
# define _POSIX_SOURCE
# include <limits.h>
# undef _POSIX_SOURCE
# endif
# endif
# ifndef OPEN_MAX
# if defined(_SC_OPEN_MAX)
# define OPEN_MAX (sysconf(_SC_OPEN_MAX))
# else
# ifdef SVR4
# define OPEN_MAX 256
# else
# include <sys/param.h>
# ifndef OPEN_MAX
# ifdef __OSF1__
# define OPEN_MAX 256
# else
# ifdef NOFILE
# define OPEN_MAX NOFILE
# else
# if !defined(__UNIXOS2__) && !defined(__QNX__)
# define OPEN_MAX NOFILES_MAX
# else
# define OPEN_MAX 256
# endif
# endif
# endif
# endif
# endif
# endif
# endif
# if defined(_SC_OPEN_MAX)
# define TRANS_OPEN_MAX OPEN_MAX
# else /* !__GNU__ */
# if OPEN_MAX > 256
# define TRANS_OPEN_MAX 256
# else
# define TRANS_OPEN_MAX OPEN_MAX
# endif
# endif /*__GNU__*/
# endif /* TRANS_OPEN_MAX */
# ifdef __UNIXOS2__
# define ESET(val)
# else
# define ESET(val) errno = val
# endif
# define EGET() errno
#else /* WIN32 */
#include <limits.h> /* for USHRT_MAX */
# include <limits.h> /* for USHRT_MAX */
#define ESET(val) WSASetLastError(val)
#define EGET() WSAGetLastError()
# define ESET(val) WSASetLastError(val)
# define EGET() WSAGetLastError()
#endif /* WIN32 */
......@@ -226,7 +227,7 @@ typedef struct _Xtransport {
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
char ** nolisten;
XtransConnInfo (*OpenCOTSServer)(
struct _Xtransport *, /* transport */
char *, /* protocol */
......@@ -283,10 +284,13 @@ typedef struct _Xtransport {
);
#ifdef TRANS_SERVER
/* Flags */
# define ADDR_IN_USE_ALLOWED 1
int (*CreateListener)(
XtransConnInfo, /* connection */
char * /* port */
char *, /* port */
unsigned int /* flags */
);
int (*ResetListener)(
......
......@@ -26,7 +26,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
/* $XFree86: xc/lib/xtrans/Xtranslcl.c,v 3.39 2002/11/26 01:12:30 dawes Exp $ */
/* $XFree86: xc/lib/xtrans/Xtranslcl.c,v 3.41 2003/08/26 15:38:39 tsi Exp $ */
/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
*
......@@ -2325,7 +2325,7 @@ TRANS(LocalSetOption)(XtransConnInfo ciptr, int option, int arg)
#ifdef TRANS_SERVER
static int
TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port)
TRANS(LocalCreateListener)(XtransConnInfo ciptr, char *port, unsigned int flags)
{
PRMSG(2,"LocalCreateListener(%x->%d,%s)\n",ciptr,ciptr->fd,port);
......@@ -2495,6 +2495,21 @@ TRANS(LocalCloseForCloning)(XtransConnInfo ciptr)
* call to SelectTransport() in Xtrans.c.
*/
#ifdef TRANS_SERVER
static char * local_aliases[] = {
# ifndef sun
"pts",
# endif
"named",
# ifndef sun
# ifndef SCO325
"isc",
# endif
"sco",
# endif
NULL };
#endif
Xtransport TRANS(LocalFuncs) = {
/* Local Interface */
"local",
......@@ -2503,6 +2518,7 @@ Xtransport TRANS(LocalFuncs) = {
TRANS(LocalOpenCOTSClient),
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
local_aliases,
TRANS(LocalOpenCOTSServer),
#endif /* TRANS_SERVER */
#ifdef TRANS_CLIENT
......@@ -2544,6 +2560,7 @@ Xtransport TRANS(PTSFuncs) = {
TRANS(LocalOpenCOTSClient),
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
NULL,
TRANS(LocalOpenCOTSServer),
#endif /* TRANS_SERVER */
#ifdef TRANS_CLIENT
......@@ -2585,6 +2602,7 @@ Xtransport TRANS(NAMEDFuncs) = {
TRANS(LocalOpenCOTSClient),
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
NULL,
TRANS(LocalOpenCOTSServer),
#endif /* TRANS_SERVER */
#ifdef TRANS_CLIENT
......@@ -2626,6 +2644,7 @@ Xtransport TRANS(ISCFuncs) = {
TRANS(LocalOpenCOTSClient),
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
NULL,
TRANS(LocalOpenCOTSServer),
#endif /* TRANS_SERVER */
#ifdef TRANS_CLIENT
......@@ -2665,6 +2684,7 @@ Xtransport TRANS(SCOFuncs) = {
TRANS(LocalOpenCOTSClient),
#endif /* TRANS_CLIENT */
#ifdef TRANS_SERVER
NULL,
TRANS(LocalOpenCOTSServer),
#endif /* TRANS_SERVER */
#ifdef TRANS_CLIENT
......
This diff is collapsed.