aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/OpenDis.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-06-11 15:12:35 +0000
committermarha <marha@users.sourceforge.net>2010-06-11 15:12:35 +0000
commitbb9571d3ede4adbb9396fdb25ab8e3e91aba1479 (patch)
tree8e21e43376a5b106a5d9689a4349385101263325 /libX11/src/OpenDis.c
parentd1e4f4b8546c7955c66dd023bfd6ef437db9d21d (diff)
parentf56cfbb54588917d9566277a669fa086a842b2f5 (diff)
downloadvcxsrv-bb9571d3ede4adbb9396fdb25ab8e3e91aba1479.tar.gz
vcxsrv-bb9571d3ede4adbb9396fdb25ab8e3e91aba1479.tar.bz2
vcxsrv-bb9571d3ede4adbb9396fdb25ab8e3e91aba1479.zip
svn merge ^/branches/released .
Diffstat (limited to 'libX11/src/OpenDis.c')
-rw-r--r--libX11/src/OpenDis.c270
1 files changed, 24 insertions, 246 deletions
diff --git a/libX11/src/OpenDis.c b/libX11/src/OpenDis.c
index 16f72b30e..a225bb437 100644
--- a/libX11/src/OpenDis.c
+++ b/libX11/src/OpenDis.c
@@ -30,12 +30,7 @@ in this Software without prior written authorization from The Open Group.
#include <config.h>
#endif
#include "Xlibint.h"
-#if USE_XCB
#include "Xxcbint.h"
-#else /* !USE_XCB */
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/extensions/bigreqstr.h>
-#endif /* USE_XCB */
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <stdio.h>
@@ -46,21 +41,6 @@ in this Software without prior written authorization from The Open Group.
#include "XKBlib.h"
#endif /* XKB */
-#if !USE_XCB
-#ifdef X_NOT_POSIX
-#define Size_t unsigned int
-#else
-#define Size_t size_t
-#endif
-
-#define bignamelen (sizeof(XBigReqExtensionName) - 1)
-
-typedef struct {
- unsigned long seq;
- int opcode;
-} _XBigReqState;
-#endif /* !USE_XCB */
-
#ifdef XTHREADS
#include "locking.h"
int (*_XInitDisplayLock_fn)(Display *dpy) = NULL;
@@ -77,11 +57,7 @@ static xReq _dummy_request = {
0, 0, 0
};
-static void OutOfMemory(Display *dpy, char *setup);
-#if !USE_XCB
-static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len,
- XPointer data);
-#endif /* !USE_XCB */
+static void OutOfMemory(Display *dpy);
/*
* Connects to a server, creates a Display object and returns a pointer to
@@ -95,14 +71,6 @@ XOpenDisplay (
register int i;
int j, k; /* random iterator indexes */
char *display_name; /* pointer to display name */
-#if !USE_XCB
- int endian; /* to determine which endian. */
- xConnClientPrefix client; /* client information */
- int idisplay; /* display number */
- int prefixread = 0; /* setup prefix already read? */
- char *conn_auth_name, *conn_auth_data;
- int conn_auth_namelen, conn_auth_datalen;
-#endif /* !USE_XCB */
char *setup = NULL; /* memory allocated at startup */
char *fullname = NULL; /* expanded name of display */
int iscreen; /* screen number */
@@ -123,11 +91,6 @@ XOpenDisplay (
long int conn_buf_size;
char *xlib_buffer_size;
-#if !USE_XCB
- bzero((char *) &client, sizeof(client));
- bzero((char *) &prefix, sizeof(prefix));
-#endif /* !USE_XCB */
-
/*
* If the display specifier string supplied as an argument to this
* routine is NULL or a pointer to NULL, read the DISPLAY variable.
@@ -163,7 +126,6 @@ XOpenDisplay (
* will set fullname to point to the expanded name.
*/
-#if USE_XCB
if(!_XConnectXCB(dpy, display, &fullname, &iscreen)) {
/* Try falling back on other transports if no transport specified */
const char *slash = strrchr(display_name, '/');
@@ -184,22 +146,10 @@ XOpenDisplay (
}
dpy->display_name = fullname;
- OutOfMemory(dpy, NULL);
+ OutOfMemory(dpy);
return NULL;
}
fallback_success:
-#else /* !USE_XCB */
- if ((dpy->trans_conn = _X11TransConnectDisplay (
- display_name, &fullname, &idisplay,
- &iscreen, &conn_auth_name,
- &conn_auth_namelen, &conn_auth_data,
- &conn_auth_datalen)) == NULL) {
- Xfree ((char *) dpy);
- return(NULL);
- }
-
- dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn);
-#endif /* USE_XCB */
/* Initialize as much of the display structure as we can.
* Initialize pointers to NULL so that XFreeDisplayStructure will
@@ -275,12 +225,12 @@ fallback_success:
/* Initialize the display lock */
if (InitDisplayLock(dpy) != 0) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
if (!_XPollfdCacheInit(dpy)) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -306,14 +256,11 @@ fallback_success:
conn_buf_size = XLIBMINBUFSIZE;
if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
- dpy->bufmax = dpy->buffer + conn_buf_size;
-#if USE_XCB
- dpy->xcb->real_bufmax = dpy->bufmax;
+ dpy->xcb->real_bufmax = dpy->buffer + conn_buf_size;
dpy->bufmax = dpy->buffer;
-#endif
/* Set up the input event queue and input event queue parameters. */
dpy->head = dpy->tail = NULL;
@@ -323,68 +270,10 @@ fallback_success:
if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
sizeof(_XFreeFuncRec)))
== NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
-#if !USE_XCB
-/*
- * The xConnClientPrefix describes the initial connection setup information
- * and is followed by the authorization information. Sites that are interested
- * in security are strongly encouraged to use an authentication and
- * authorization system such as Kerberos.
- */
- endian = 1;
- if (*(char *) &endian)
- client.byteOrder = '\154'; /* 'l' */
- else
- client.byteOrder = '\102'; /* 'B' */
- client.majorVersion = X_PROTOCOL;
- client.minorVersion = X_PROTOCOL_REVISION;
- client.nbytesAuthProto = conn_auth_namelen;
- client.nbytesAuthString = conn_auth_datalen;
- prefixread = _XSendClientPrefix(dpy, &client,
- conn_auth_name, conn_auth_data,
- &prefix);
- if (prefixread < 0)
- {
- _XDisconnectDisplay (dpy->trans_conn);
- Xfree ((char *)dpy);
- return(NULL);
- }
- if (conn_auth_name) Xfree(conn_auth_name);
- if (conn_auth_data) Xfree(conn_auth_data);
-/*
- * Now see if connection was accepted...
- */
- /* these internal functions expect the display to be locked */
- LockDisplay(dpy);
-
- if (prefixread == 0)
- _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix));
-
- /* an Authenticate reply we weren't expecting? */
- if (prefix.success != xTrue && prefix.success != xFalse) {
- fprintf (stderr,
- "Xlib: unexpected connection setup reply from server, type %d.\r\n",
- prefix.success);
- _XDisconnectDisplay (dpy->trans_conn);
- Xfree ((char *)dpy);
- return(NULL);
- }
-
- if (prefix.majorVersion != X_PROTOCOL) {
- /* XXX - printing messages marks a bad programming interface */
- fprintf (stderr,
- "Xlib: client uses different protocol version (%d) than server (%d)!\r\n",
- X_PROTOCOL, prefix.majorVersion);
- _XDisconnectDisplay (dpy->trans_conn);
- Xfree ((char *)dpy);
+ OutOfMemory (dpy);
return(NULL);
}
-#endif /* !USE_XCB */
-#if USE_XCB
{
const struct xcb_setup_t *xcbsetup = xcb_get_setup(dpy->xcb->connection);
memcpy(&prefix, xcbsetup, sizeof(prefix));
@@ -393,38 +282,6 @@ fallback_success:
setup += SIZEOF(xConnSetupPrefix);
u.setup = (xConnSetup *) setup;
}
-#else /* !USE_XCB */
- setuplength = prefix.length << 2;
- if ( (u.setup = (xConnSetup *)
- (setup = Xmalloc ((unsigned) setuplength))) == NULL) {
- _XDisconnectDisplay (dpy->trans_conn);
- Xfree ((char *)dpy);
- return(NULL);
- }
- _XRead (dpy, (char *)u.setup, setuplength);
-
-/*
- * If the connection was not accepted by the server due to problems,
- * give error message to the user....
- */
- if (prefix.success != xTrue) {
- /* XXX - printing messages marks a bad programming interface */
- fprintf (stderr,
- "Xlib: connection to \"%s\" refused by server\r\nXlib: ",
- fullname);
-
- if (prefix.lengthReason > setuplength) {
- fprintf (stderr, "Xlib: Broken initial reply: length of reason > length of packet\r\n");
- }else{
- (void) fwrite (u.failure, (Size_t)sizeof(char),
- (Size_t)prefix.lengthReason, stderr);
- (void) fwrite ("\r\n", sizeof(char), 2, stderr);
- }
-
- OutOfMemory(dpy, setup);
- return (NULL);
- }
-#endif /* USE_XCB */
/*
* Check if the reply was long enough to get any information out of it.
@@ -432,7 +289,7 @@ fallback_success:
usedbytes = sz_xConnSetup;
if (setuplength < usedbytes ) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return (NULL);
}
@@ -461,7 +318,7 @@ fallback_success:
{
fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
fullname);
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return (NULL);
}
@@ -476,13 +333,13 @@ fallback_success:
*/
/* Check for a sane vendor string length */
if (u.setup->nbytesVendor > 256) {
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return (NULL);
}
dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
if (dpy->vendor == NULL) {
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return (NULL);
}
vendorlen = u.setup->nbytesVendor;
@@ -493,7 +350,7 @@ fallback_success:
usedbytes += (vendorlen + 3) & ~3;
if (setuplength < usedbytes) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return (NULL);
}
@@ -510,7 +367,7 @@ fallback_success:
(ScreenFormat *)Xmalloc(
(unsigned) (dpy->nformats *sizeof(ScreenFormat)));
if (dpy->pixmap_format == NULL) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
/*
@@ -520,7 +377,7 @@ fallback_success:
if (setuplength < usedbytes) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -539,7 +396,7 @@ fallback_success:
dpy->screens =
(Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
if (dpy->screens == NULL) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -553,7 +410,7 @@ fallback_success:
usedbytes += sz_xWindowRoot;
if (setuplength < usedbytes) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -582,7 +439,7 @@ fallback_success:
sp->depths = (Depth *)Xmalloc(
(unsigned)sp->ndepths*sizeof(Depth));
if (sp->depths == NULL) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
/*
@@ -594,7 +451,7 @@ fallback_success:
usedbytes += sz_xDepth;
if (setuplength < usedbytes) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -605,7 +462,7 @@ fallback_success:
dp->visuals =
(Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
if (dp->visuals == NULL) {
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
for (k = 0; k < dp->nvisuals; k++) {
@@ -614,7 +471,7 @@ fallback_success:
usedbytes += sz_xVisualType;
if (setuplength < usedbytes) {
fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
+ OutOfMemory (dpy);
return(NULL);
}
@@ -647,7 +504,7 @@ fallback_success:
fprintf(stderr, "Xlib: Did not parse entire setup message: "
"parsed: %ld, message: %ld\n",
usedbytes, setuplength);
- OutOfMemory(dpy, setup);
+ OutOfMemory(dpy);
return(NULL);
}
@@ -655,30 +512,17 @@ fallback_success:
* Now start talking to the server to setup all other information...
*/
-#if !USE_XCB
- Xfree (setup); /* all finished with setup information */
-#endif /* !USE_XCB */
-
/*
* Make sure default screen is legal.
*/
if (iscreen >= dpy->nscreens) {
- OutOfMemory(dpy, (char *) NULL);
+ OutOfMemory(dpy);
return(NULL);
}
-#if !USE_XCB
-/*
- * finished calling internal routines, now unlock for external routines
- */
- UnlockDisplay(dpy);
-#endif /* !USE_XCB */
-
-#if USE_XCB
dpy->bigreq_size = xcb_get_maximum_request_length(dpy->xcb->connection);
if(dpy->bigreq_size <= dpy->max_request_size)
dpy->bigreq_size = 0;
-#endif /* USE_XCB */
/*
* Set up other stuff clients are always going to use.
@@ -691,7 +535,7 @@ fallback_success:
if ((sp->default_gc = XCreateGC (dpy, sp->root,
GCForeground|GCBackground,
&values)) == NULL) {
- OutOfMemory(dpy, (char *) NULL);
+ OutOfMemory(dpy);
return (NULL);
}
}
@@ -709,24 +553,6 @@ fallback_success:
{
xGetPropertyReply reply;
xGetPropertyReq *req;
-#if !USE_XCB
- _XAsyncHandler async;
- _XBigReqState async_state;
- xQueryExtensionReq *qreq;
- xBigReqEnableReq *breq;
- xBigReqEnableReply brep;
-
- GetReq(QueryExtension, qreq);
- async_state.seq = dpy->request;
- async_state.opcode = 0;
- async.next = dpy->async_handlers;
- async.handler = _XBigReqHandler;
- async.data = (XPointer)&async_state;
- dpy->async_handlers = &async;
- qreq->nbytes = bignamelen;
- qreq->length += (bignamelen+3)>>2;
- Data(dpy, XBigReqExtensionName, bignamelen);
-#endif /* !USE_XCB */
GetReq (GetProperty, req);
req->window = RootWindow(dpy, 0);
@@ -747,16 +573,6 @@ fallback_success:
else if (reply.propertyType != None)
_XEatData(dpy, reply.nItems * (reply.format >> 3));
}
-#if !USE_XCB
- DeqAsyncHandler(dpy, &async);
- if (async_state.opcode) {
- GetReq(BigReqEnable, breq);
- breq->reqType = async_state.opcode;
- breq->brReqType = X_BigReqEnable;
- if (_XReply(dpy, (xReply *)&brep, 0, xFalse))
- dpy->bigreq_size = brep.max_request_size;
- }
-#endif /* !USE_XCB */
}
UnlockDisplay(dpy);
@@ -775,35 +591,6 @@ fallback_success:
return(dpy);
}
-#if !USE_XCB
-static Bool
-_XBigReqHandler(
- register Display *dpy,
- register xReply *rep,
- char *buf,
- int len,
- XPointer data)
-{
- _XBigReqState *state;
- xQueryExtensionReply replbuf;
- xQueryExtensionReply *repl;
-
- state = (_XBigReqState *)data;
- if (dpy->last_request_read != state->seq)
- return False;
- if (rep->generic.type == X_Error)
- return True;
- repl = (xQueryExtensionReply *)
- _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
- (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2,
- True);
- if (repl->present)
- state->opcode = repl->major_opcode;
- return True;
-}
-#endif /* !USE_XCB */
-
-
/* XFreeDisplayStructure frees all the storage associated with a
* Display. It is used by XOpenDisplay if it runs out of memory,
* and also by XCloseDisplay. It needs to check whether all pointers
@@ -939,9 +726,7 @@ void _XFreeDisplayStructure(Display *dpy)
if (dpy->filedes)
Xfree (dpy->filedes);
-#if USE_XCB
_XFreeX11XCBStructure(dpy);
-#endif /* USE_XCB */
Xfree ((char *)dpy);
}
@@ -949,16 +734,9 @@ void _XFreeDisplayStructure(Display *dpy)
/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
after this returns. */
-static void OutOfMemory(Display *dpy, char *setup)
+static void OutOfMemory(Display *dpy)
{
-#if USE_XCB
if(dpy->xcb->connection)
xcb_disconnect(dpy->xcb->connection);
-#else /* !USE_XCB */
- _XDisconnectDisplay (dpy->trans_conn);
-#endif /* USE_XCB */
_XFreeDisplayStructure (dpy);
-#if !USE_XCB
- if (setup) Xfree (setup);
-#endif /* !USE_XCB */
}