aboutsummaryrefslogtreecommitdiff
path: root/libX11/src
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-05-19 10:32:31 +0000
committermarha <marha@users.sourceforge.net>2010-05-19 10:32:31 +0000
commitb16c0295c9f95426980d567e93ae00c52545b3fa (patch)
treed25e3271be998e47e0ff07048d8297001409ea5f /libX11/src
parentc1b8f2475ebdeb148f4a27b78ed3cb24c68a92c4 (diff)
parent153f5cafa19da4e4c0cf21e9c909958359ed8ebd (diff)
downloadvcxsrv-b16c0295c9f95426980d567e93ae00c52545b3fa.tar.gz
vcxsrv-b16c0295c9f95426980d567e93ae00c52545b3fa.tar.bz2
vcxsrv-b16c0295c9f95426980d567e93ae00c52545b3fa.zip
svn merge "^/branches/released" .
Diffstat (limited to 'libX11/src')
-rw-r--r--libX11/src/ConnDis.c2505
-rw-r--r--libX11/src/Makefile.am873
-rw-r--r--libX11/src/Makefile.in1372
-rw-r--r--libX11/src/OpenDis.c1908
-rw-r--r--libX11/src/SetPntMap.c159
-rw-r--r--libX11/src/XErrorDB2012
-rw-r--r--libX11/src/XlibInt.c7364
-rw-r--r--libX11/src/Xprivate.h43
-rw-r--r--libX11/src/Xxcbint.h92
-rw-r--r--libX11/src/locking.c1243
-rw-r--r--libX11/src/util/Makefile.am40
-rw-r--r--libX11/src/util/Makefile.in565
-rw-r--r--libX11/src/xcb_disp.c242
-rw-r--r--libX11/src/xcb_io.c1261
-rw-r--r--libX11/src/xcms/Makefile.am201
-rw-r--r--libX11/src/xcms/Makefile.in750
-rw-r--r--libX11/src/xkb/Makefile.am105
-rw-r--r--libX11/src/xkb/Makefile.in607
-rw-r--r--libX11/src/xlibi18n/Makefile.am303
-rw-r--r--libX11/src/xlibi18n/Makefile.in741
-rw-r--r--libX11/src/xlibi18n/lcUTF8.c4780
21 files changed, 11646 insertions, 15520 deletions
diff --git a/libX11/src/ConnDis.c b/libX11/src/ConnDis.c
index 7fa7998e8..4eb94f34d 100644
--- a/libX11/src/ConnDis.c
+++ b/libX11/src/ConnDis.c
@@ -1,1254 +1,1251 @@
-/*
-
-Copyright 1989, 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.
-
-*/
-
-/*
- * This file contains operating system dependencies.
- */
-
-#define NEED_EVENTS
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <X11/Xlibint.h>
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/Xauth.h>
-#ifdef HASXDMAUTH
-#include <X11/Xdmcp.h>
-#endif
-#include <stdio.h>
-#include <ctype.h>
-#include <unistd.h>
-
-#if !defined(WIN32)
-#ifndef Lynx
-#include <sys/socket.h>
-#else
-#include <socket.h>
-#endif
-#else
-#include <X11/Xwindows.h>
-#endif
-
-#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
-#define X_CONNECTION_RETRIES 5
-#endif
-
-#include "Xintconn.h"
-
-/* prototypes */
-static void GetAuthorization(
- XtransConnInfo trans_conn,
- int family,
- char *saddr,
- int saddrlen,
- int idisplay,
- char **auth_namep,
- int *auth_namelenp,
- char **auth_datap,
- int *auth_datalenp);
-
-/* functions */
-static char *copystring (const char *src, int len)
-{
- char *dst = Xmalloc (len + 1);
-
- if (dst) {
- strncpy (dst, src, len);
- dst[len] = '\0';
- }
-
- return dst;
-}
-
-#define Xstrdup(s) copystring(s, strlen(s))
-
-#ifdef TCPCONN
-# define TCP_TRANS "tcp"
-#endif
-#ifdef UNIXCONN
-# define UNIX_TRANS "unix"
-#endif
-#if defined(LOCALCONN) || defined(OS2PIPECONN)
-# define LOCAL_TRANS "local"
-#endif
-
-/*
- * Attempts to connect to server, given display name. Returns file descriptor
- * (network socket) or -1 if connection fails. Display names may be of the
- * following format:
- *
- * [protocol/] [hostname] : [:] displaynumber [.screennumber]
- *
- * A string with exactly two colons seperating hostname from the display
- * indicates a DECnet style name. Colons in the hostname may occur if an
- * IPv6 numeric address is used as the hostname. An IPv6 numeric address
- * may also end in a double colon, so three colons in a row indicates an
- * IPv6 address ending in :: followed by :display. To make it easier for
- * people to read, an IPv6 numeric address hostname may be surrounded by
- * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined
- * by IETF RFC 2732.
- *
- * If no hostname and no protocol is specified, the string is interpreted
- * as the most efficient local connection to a server on the same machine.
- * This is usually:
- *
- * o shared memory
- * o local stream
- * o UNIX domain socket
- * o TCP to local host
- *
- * This function will eventually call the X Transport Interface functions
- * which expects the hostname in the format:
- *
- * [protocol/] [hostname] : [:] displaynumber
- *
- */
-XtransConnInfo
-_X11TransConnectDisplay (
- char *display_name,
- char **fullnamep, /* RETURN */
- int *dpynump, /* RETURN */
- int *screenp, /* RETURN */
- char **auth_namep, /* RETURN */
- int *auth_namelenp, /* RETURN */
- char **auth_datap, /* RETURN */
- int *auth_datalenp) /* RETURN */
-{
- int family;
- int saddrlen;
- Xtransaddr *saddr;
- char *lastp, *lastc, *p; /* char pointers */
- char *pprotocol = NULL; /* start of protocol name */
- char *phostname = NULL; /* start of host of display */
- char *pdpynum = NULL; /* start of dpynum of display */
- char *pscrnum = NULL; /* start of screen of display */
- Bool dnet = False; /* if true, then DECnet format */
- int idisplay = 0; /* required display number */
- int iscreen = 0; /* optional screen number */
- /* int (*connfunc)(); */ /* method to create connection */
- int len, hostlen; /* length tmp variable */
- int retry; /* retry counter */
- char addrbuf[128]; /* final address passed to
- X Transport Interface */
- char* address = addrbuf;
- XtransConnInfo trans_conn = NULL; /* transport connection object */
- int connect_stat;
-#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
- Bool reset_hostname = False; /* Reset hostname? */
- char *original_hostname = NULL;
- int local_transport_index = -1;
- const char *local_transport[] = { LOCAL_TRANSPORT_LIST, NULL };
-#endif
-
- p = display_name;
-
- saddrlen = 0; /* set so that we can clear later */
- saddr = NULL;
-
- /*
- * Step 0, find the protocol. This is delimited by the optional
- * slash ('/').
- */
- for (lastp = p; *p && *p != ':' && *p != '/'; p++) ;
- if (!*p) return NULL; /* must have a colon */
-
- if (p != lastp && *p != ':') { /* protocol given? */
- pprotocol = copystring (lastp, p - lastp);
- if (!pprotocol) goto bad; /* no memory */
- p++; /* skip the '/' */
- } else
- p = display_name; /* reset the pointer in
- case no protocol was given */
-
- /*
- * Step 1, find the hostname. This is delimited by either one colon,
- * or two colons in the case of DECnet (DECnet Phase V allows a single
- * colon in the hostname). (See note above regarding IPv6 numeric
- * addresses with triple colons or [] brackets.)
- */
-
- lastp = p;
- lastc = NULL;
- for (; *p; p++)
- if (*p == ':')
- lastc = p;
-
- if (!lastc) return NULL; /* must have a colon */
-
- if ((lastp != lastc) && (*(lastc - 1) == ':')
-#if defined(IPv6) && defined(AF_INET6)
- && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':'))
-#endif
- ) {
- /* DECnet display specified */
-
-#ifndef DNETCONN
- goto bad;
-#else
- dnet = True;
- /* override the protocol specified */
- if (pprotocol)
- Xfree (pprotocol);
- pprotocol = copystring ("dnet", 4);
- hostlen = lastc - 1 - lastp;
-#endif
- }
- else
- hostlen = lastc - lastp;
-
- if (hostlen > 0) { /* hostname given? */
- phostname = copystring (lastp, hostlen);
- if (!phostname) goto bad; /* no memory */
- }
-
- p = lastc;
-
-#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
- /* check if phostname == localnodename AND protocol not specified */
- if (!pprotocol && phostname) {
- char localhostname[256];
-
- if ((_XGetHostname (localhostname, sizeof localhostname) > 0)
- && (strcmp(phostname, localhostname) == 0)) {
- original_hostname = phostname;
- phostname = NULL;
- reset_hostname = True;
- }
- }
-#endif
-
-
- /*
- * Step 2, find the display number. This field is required and is
- * delimited either by a nul or a period, depending on whether or not
- * a screen number is present.
- */
-
- for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ;
- if ((p == lastp) || /* required field */
- (*p != '\0' && *p != '.') || /* invalid non-digit terminator */
- !(pdpynum = copystring (lastp, p - lastp))) /* no memory */
- goto bad;
- idisplay = atoi (pdpynum);
-
-
- /*
- * Step 3, find the screen number. This field is optional. It is
- * present only if the display number was followed by a period (which
- * we've already verified is the only non-nul character).
- */
-
- if (*p) {
- for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ;
- if (p != lastp) {
- if (*p || /* non-digits */
- !(pscrnum = copystring (lastp, p - lastp))) /* no memory */
- goto bad;
- iscreen = atoi (lastp);
- }
- }
-
- /*
- * At this point, we know the following information:
- *
- * pprotocol protocol string or NULL
- * phostname hostname string or NULL
- * idisplay display number
- * iscreen screen number
- * dnet DECnet boolean
- *
- * We can now decide which transport to use based on the defined
- * connection types and the hostname string.
- * If phostname & pprotocol are NULL, then choose the best transport.
- * If phostname is "unix" & pprotocol is NULL, then choose UNIX domain
- * sockets (if configured).
- */
-
-#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN)
- if (!pprotocol) {
-#if defined(UNIXCONN)
- if (phostname && (strcmp (phostname, "unix") == 0)) {
- Xfree(pprotocol);
- pprotocol = copystring ("unix", 4);
- } else
-#endif
-#ifdef HAVE_LAUNCHD
- if (phostname && phostname[0]=='/') {
- pprotocol = copystring ("local", 5);
- }
-#endif
- if (!phostname)
- {
- if (local_transport[0] != NULL) {
- pprotocol = Xstrdup(local_transport[0]);
- local_transport_index = 0;
- }
- }
-
- if (!pprotocol) { /* if still not found one, tcp is our last resort */
- pprotocol = copystring ("tcp", 3);
- }
- }
-#endif
-
-
- connect:
- /*
- * This seems kind of backwards, but we need to put the protocol,
- * host, and port back together to pass to _X11TransOpenCOTSClient().
- */
-
- {
- int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) +
- (phostname ? strlen(phostname) : 0) +
- (pdpynum ? strlen(pdpynum) : 0);
- if (olen > sizeof addrbuf) address = Xmalloc (olen);
- }
- if (!address) goto bad;
-
- sprintf(address,"%s/%s:%d",
- pprotocol ? pprotocol : "",
- phostname ? phostname : "",
- idisplay );
-
- /*
- * Make the connection, also need to get the auth address info for
- * the connection. Do retries in case server host has hit its
- * backlog (which, unfortunately, isn't distinguishable from there not
- * being a server listening at all, which is why we have to not retry
- * too many times).
- */
- for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
- {
- if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
- {
- break;
- }
- if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
- {
- _X11TransClose(trans_conn);
- trans_conn = NULL;
-
- if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
- continue;
- else
- break;
- }
-
- _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
-
- /*
- * The family is given in a socket format (ie AF_INET). This
- * will convert it to the format used by the authorization and
- * X protocol (ie FamilyInternet).
- */
-
- if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
- {
- _X11TransClose(trans_conn);
- trans_conn = NULL;
- if (saddr)
- {
- free ((char *) saddr);
- saddr = NULL;
- }
- continue;
- }
-
- break;
- }
-
- if (address != addrbuf) Xfree (address);
- address = addrbuf;
-
- if( trans_conn == NULL )
- goto bad;
-
- /*
- * Set close-on-exec so that programs that fork() doesn't get confused.
- */
-
- _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1);
-
- /*
- * Build the expanded display name:
- *
- * [host] : [:] dpy . scr \0
- */
-#if defined(LOCALCONN) || defined(TCPCONN) || defined(UNIXCONN)
- /*
- * If we computed the host name, get rid of it so that
- * XDisplayString() and XDisplayName() agree.
- */
- if (reset_hostname && (phostname != original_hostname)) {
- Xfree (phostname);
- phostname = original_hostname;
- original_hostname = NULL;
- }
-#endif
- len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) +
- strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1);
- *fullnamep = (char *) Xmalloc (len);
- if (!*fullnamep) goto bad;
-
-#ifdef HAVE_LAUNCHD
- if (phostname && strlen(phostname) > 11 && !strncmp(phostname, "/tmp/launch", 11))
- sprintf (*fullnamep, "%s%s%d",
- (phostname ? phostname : ""),
- (dnet ? "::" : ":"),
- idisplay);
- else
-#endif
- sprintf (*fullnamep, "%s%s%d.%d",
- (phostname ? phostname : ""),
- (dnet ? "::" : ":"),
- idisplay, iscreen);
-
- *dpynump = idisplay;
- *screenp = iscreen;
- if (pprotocol) Xfree (pprotocol);
- if (phostname) Xfree (phostname);
- if (pdpynum) Xfree (pdpynum);
- if (pscrnum) Xfree (pscrnum);
-#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
- if (original_hostname) Xfree (original_hostname);
-#endif
-
- GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay,
- auth_namep, auth_namelenp, auth_datap, auth_datalenp);
- return trans_conn;
-
-
- /*
- * error return; make sure everything is cleaned up.
- */
- bad:
- if (trans_conn) (void)_X11TransClose(trans_conn);
- if (saddr) free ((char *) saddr);
- if (pprotocol) Xfree (pprotocol);
- if (phostname) Xfree (phostname);
- if (address && address != addrbuf) { Xfree(address); address = addrbuf; }
-
-#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
- /* If connecting to the local machine, and we failed, try again with
- * the next transport type available, if there is one.
- */
- if (local_transport_index >= 0) {
- if (local_transport[++local_transport_index] != NULL) {
- pprotocol = Xstrdup(local_transport[local_transport_index]);
-#ifdef TCPCONN
- if (strcmp(pprotocol, "tcp") == 0) {
- if (original_hostname != NULL) {
- phostname = original_hostname;
- original_hostname = NULL;
- } else {
- phostname = copystring("localhost", 9);
- }
- } else
-#endif /* TCPCONN */
- {
- if ((phostname != NULL) && (original_hostname == NULL)) {
- original_hostname = phostname;
- }
- phostname = NULL;
- }
- goto connect;
- }
- }
-
- /* No more to try, we've failed all available local transports */
- if (original_hostname) Xfree(original_hostname);
-#endif /* LOCALCONN || UNIXCONN || TCPCONN */
-
- if (pdpynum) Xfree (pdpynum);
- if (pscrnum) Xfree (pscrnum);
- return NULL;
-
-}
-
-/*
- * This is gross, but we need it for compatiblity.
- * The test suite relies on the following interface.
- *
- */
-
-int _XConnectDisplay (
- char *display_name,
- char **fullnamep, /* RETURN */
- int *dpynump, /* RETURN */
- int *screenp, /* RETURN */
- char **auth_namep, /* RETURN */
- int *auth_namelenp, /* RETURN */
- char **auth_datap, /* RETURN */
- int *auth_datalenp) /* RETURN */
-{
- XtransConnInfo trans_conn;
-
- trans_conn = _X11TransConnectDisplay (
- display_name, fullnamep, dpynump, screenp,
- auth_namep, auth_namelenp, auth_datap, auth_datalenp);
-
- if (trans_conn)
- {
- int fd = _X11TransGetConnectionNumber (trans_conn);
- _X11TransFreeConnInfo (trans_conn);
- return (fd);
- }
- else
- return (-1);
-}
-
-
-/*****************************************************************************
- * *
- * Connection Utility Routines *
- * *
- *****************************************************************************/
-
-/*
- * Disconnect from server.
- */
-
-int _XDisconnectDisplay (trans_conn)
-
-XtransConnInfo trans_conn;
-
-{
- _X11TransDisconnect(trans_conn);
- _X11TransClose(trans_conn);
- return 0;
-}
-
-
-
-Bool
-_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix)
- Display *dpy;
- xConnClientPrefix *client; /* contains count for auth_* */
- char *auth_proto, *auth_string; /* NOT null-terminated */
- xConnSetupPrefix *prefix; /* prefix information */
-{
- int auth_length = client->nbytesAuthProto;
- int auth_strlen = client->nbytesAuthString;
- static char padbuf[3]; /* for padding to 4x bytes */
- int pad;
- struct iovec iovarray[5], *iov = iovarray;
- int niov = 0;
- int len = 0;
-
-#define add_to_iov(b,l) \
- { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); }
-
- add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix));
-
- /*
- * write authorization protocol name and data
- */
- if (auth_length > 0) {
- add_to_iov (auth_proto, auth_length);
- pad = -auth_length & 3; /* pad auth_length to a multiple of 4 */
- if (pad) add_to_iov (padbuf, pad);
- }
- if (auth_strlen > 0) {
- add_to_iov (auth_string, auth_strlen);
- pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */
- if (pad) add_to_iov (padbuf, pad);
- }
-
-#undef add_to_iov
-
- len -= _X11TransWritev (dpy->trans_conn, iovarray, niov);
-
- /*
- * Set the connection non-blocking since we use select() to block.
- */
-
- _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1);
-
- if (len != 0)
- return -1;
-
-#ifdef K5AUTH
- if (auth_length == 14 &&
- !strncmp(auth_proto, "MIT-KERBEROS-5", 14))
- {
- return k5_clientauth(dpy, prefix);
- } else
-#endif
- return 0;
-}
-
-
-#ifdef STREAMSCONN
-#ifdef SVR4
-#include <tiuser.h>
-#else
-#undef HASXDMAUTH
-#endif
-#endif
-
-#ifdef SECURE_RPC
-#include <rpc/rpc.h>
-#ifdef ultrix
-#include <time.h>
-#include <rpc/auth_des.h>
-#endif
-#endif
-
-#ifdef HASXDMAUTH
-#include <time.h>
-#define Time_t time_t
-#endif
-
-/*
- * First, a routine for setting authorization data
- */
-static int xauth_namelen = 0;
-static char *xauth_name = NULL; /* NULL means use default mechanism */
-static int xauth_datalen = 0;
-static char *xauth_data = NULL; /* NULL means get default data */
-
-/*
- * This is a list of the authorization names which Xlib currently supports.
- * Xau will choose the file entry which matches the earliest entry in this
- * array, allowing us to prioritize these in terms of the most secure first
- */
-
-static char *default_xauth_names[] = {
-#ifdef K5AUTH
- "MIT-KERBEROS-5",
-#endif
-#ifdef SECURE_RPC
- "SUN-DES-1",
-#endif
-#ifdef HASXDMAUTH
- "XDM-AUTHORIZATION-1",
-#endif
- "MIT-MAGIC-COOKIE-1"
-};
-
-static _Xconst int default_xauth_lengths[] = {
-#ifdef K5AUTH
- 14, /* strlen ("MIT-KERBEROS-5") */
-#endif
-#ifdef SECURE_RPC
- 9, /* strlen ("SUN-DES-1") */
-#endif
-#ifdef HASXDMAUTH
- 19, /* strlen ("XDM-AUTHORIZATION-1") */
-#endif
- 18 /* strlen ("MIT-MAGIC-COOKIE-1") */
-};
-
-#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0]))
-
-static char **xauth_names = default_xauth_names;
-static _Xconst int *xauth_lengths = default_xauth_lengths;
-
-static int xauth_names_length = NUM_DEFAULT_AUTH;
-
-void XSetAuthorization (name, namelen, data, datalen)
- int namelen, datalen; /* lengths of name and data */
- char *name, *data; /* NULL or arbitrary array of bytes */
-{
- char *tmpname, *tmpdata;
-
- _XLockMutex(_Xglobal_lock);
- if (xauth_name) Xfree (xauth_name); /* free any existing data */
- if (xauth_data) Xfree (xauth_data);
-
- xauth_name = xauth_data = NULL; /* mark it no longer valid */
- xauth_namelen = xauth_datalen = 0;
- _XUnlockMutex(_Xglobal_lock);
-
- if (namelen < 0) namelen = 0; /* check for bogus inputs */
- if (datalen < 0) datalen = 0; /* maybe should return? */
-
- if (namelen > 0) { /* try to allocate space */
- tmpname = Xmalloc ((unsigned) namelen);
- if (!tmpname) return;
- memcpy (tmpname, name, namelen);
- } else {
- tmpname = NULL;
- }
-
- if (datalen > 0) {
- tmpdata = Xmalloc ((unsigned) datalen);
- if (!tmpdata) {
- if (tmpname) (void) Xfree (tmpname);
- return;
- }
- memcpy (tmpdata, data, datalen);
- } else {
- tmpdata = NULL;
- }
-
- _XLockMutex(_Xglobal_lock);
- xauth_name = tmpname; /* and store the suckers */
- xauth_namelen = namelen;
- if (tmpname)
- {
- xauth_names = &xauth_name;
- xauth_lengths = &xauth_namelen;
- xauth_names_length = 1;
- }
- else
- {
- xauth_names = default_xauth_names;
- xauth_lengths = default_xauth_lengths;
- xauth_names_length = NUM_DEFAULT_AUTH;
- }
- xauth_data = tmpdata;
- xauth_datalen = datalen;
- _XUnlockMutex(_Xglobal_lock);
- return;
-}
-
-#ifdef SECURE_RPC
-/*
- * Create a credential that we can send to the X server.
- */
-static int
-auth_ezencode(
- char *servername,
- int window,
- char *cred_out,
- int *len)
-{
- AUTH *a;
- XDR xdr;
-
-#if defined(SVR4) && defined(sun)
- a = authdes_seccreate(servername, window, NULL, NULL);
-#else
- a = (AUTH *)authdes_create(servername, window, NULL, NULL);
-#endif
- if (a == (AUTH *)NULL) {
- perror("auth_create");
- return 0;
- }
- xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE);
- if (AUTH_MARSHALL(a, &xdr) == FALSE) {
- perror("auth_marshall");
- AUTH_DESTROY(a);
- return 0;
- }
- *len = xdr_getpos(&xdr);
- AUTH_DESTROY(a);
- return 1;
-}
-#endif
-
-#ifdef K5AUTH
-#include <com_err.h>
-
-extern krb5_flags krb5_kdc_default_options;
-
-/*
- * k5_clientauth
- *
- * Returns non-zero if the setup prefix has been read,
- * so we can tell XOpenDisplay to not bother looking for it by
- * itself.
- */
-static int k5_clientauth(dpy, sprefix)
- Display *dpy;
- xConnSetupPrefix *sprefix;
-{
- krb5_error_code retval;
- xReq prefix;
- char *buf;
- CARD16 plen, tlen;
- krb5_data kbuf;
- krb5_ccache cc;
- krb5_creds creds;
- krb5_principal cprinc, sprinc;
- krb5_ap_rep_enc_part *repl;
-
- krb5_init_ets();
- /*
- * stage 0: get encoded principal and tgt from server
- */
- _XRead(dpy, (char *)&prefix, sz_xReq);
- if (prefix.reqType != 2 && prefix.reqType != 3)
- /* not an auth packet... so deal */
- if (prefix.reqType == 0 || prefix.reqType == 1)
- {
- memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
- _XRead(dpy, (char *)sprefix + sz_xReq,
- sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */
- return 1;
- }
- else
- {
- fprintf(stderr,
- "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n",
- prefix.reqType);
- return -1;
- }
- if (prefix.data != 0)
- {
- fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n",
- prefix.data);
- return -1;
- }
- buf = (char *)malloc((prefix.length << 2) - sz_xReq);
- if (buf == NULL) /* malloc failed. Run away! */
- {
- fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
- return -1;
- }
- tlen = (prefix.length << 2) - sz_xReq;
- _XRead(dpy, buf, tlen);
- if (prefix.reqType == 2 && tlen < 6)
- {
- fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n");
- free(buf);
- return -1;
- }
- if (prefix.reqType == 2)
- {
- plen = *(CARD16 *)buf;
- kbuf.data = buf + 2;
- kbuf.length = (plen > tlen) ? tlen : plen;
- }
- else
- {
- kbuf.data = buf;
- kbuf.length = tlen;
- }
- if (XauKrb5Decode(kbuf, &sprinc))
- {
- free(buf);
- fprintf(stderr, "Xlib: XauKrb5Decode bombed\n");
- return -1;
- }
- if (prefix.reqType == 3) /* do some special stuff here */
- {
- char *sname, *hostname = NULL;
-
- sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1);
- if (sname == NULL)
- {
- free(buf);
- krb5_free_principal(sprinc);
- fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
- return -1;
- }
- memcpy(sname, krb5_princ_component(sprinc, 0)->data,
- krb5_princ_component(sprinc, 0)->length);
- sname[krb5_princ_component(sprinc, 0)->length] = '\0';
- krb5_free_principal(sprinc);
- if (dpy->display_name[0] != ':') /* hunt for a hostname */
- {
- char *t;
-
- if ((hostname = (char *)malloc(strlen(dpy->display_name)))
- == NULL)
- {
- free(buf);
- free(sname);
- fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
- return -1;
- }
- strcpy(hostname, dpy->display_name);
- t = strchr(hostname, ':');
- if (t == NULL)
- {
- free(buf);
- free(sname);
- free(hostname);
- fprintf(stderr,
- "Xlib: shouldn't get here! malformed display name.");
- return -1;
- }
- if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':')
- t++;
- *t = '\0'; /* truncate the dpy number out */
- }
- retval = krb5_sname_to_principal(hostname, sname,
- KRB5_NT_SRV_HST, &sprinc);
- free(sname);
- if (hostname)
- free(hostname);
- if (retval)
- {
- free(buf);
- fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n",
- error_message(retval));
- return -1;
- }
- }
- if (retval = krb5_cc_default(&cc))
- {
- free(buf);
- krb5_free_principal(sprinc);
- fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n",
- error_message(retval));
- return -1;
- }
- if (retval = krb5_cc_get_principal(cc, &cprinc))
- {
- free(buf);
- krb5_free_principal(sprinc);
- fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n",
- krb5_cc_default_name(), error_message(retval));
- return -1;
- }
- bzero((char *)&creds, sizeof(creds));
- creds.server = sprinc;
- creds.client = cprinc;
- if (prefix.reqType == 2)
- {
- creds.second_ticket.length = tlen - plen - 2;
- creds.second_ticket.data = buf + 2 + plen;
- retval = krb5_get_credentials(KRB5_GC_USER_USER |
- krb5_kdc_default_options,
- cc, &creds);
- }
- else
- retval = krb5_get_credentials(krb5_kdc_default_options,
- cc, &creds);
- if (retval)
- {
- free(buf);
- krb5_free_cred_contents(&creds);
- fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n",
- error_message(retval));
- return -1;
- }
- /*
- * now format the ap_req to send to the server
- */
- if (prefix.reqType == 2)
- retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY |
- AP_OPTS_MUTUAL_REQUIRED, NULL,
- 0, 0, NULL, cc,
- &creds, NULL, &kbuf);
- else
- retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL,
- 0, 0, NULL, cc, &creds, NULL,
- &kbuf);
- free(buf);
- if (retval) /* Some manner of Kerberos lossage */
- {
- krb5_free_cred_contents(&creds);
- fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n",
- error_message(retval));
- return -1;
- }
- prefix.reqType = 1;
- prefix.data = 0;
- prefix.length = (kbuf.length + sz_xReq + 3) >> 2;
- /*
- * stage 1: send ap_req to server
- */
- _XSend(dpy, (char *)&prefix, sz_xReq);
- _XSend(dpy, (char *)kbuf.data, kbuf.length);
- free(kbuf.data);
- /*
- * stage 2: get ap_rep from server to mutually authenticate
- */
- _XRead(dpy, (char *)&prefix, sz_xReq);
- if (prefix.reqType != 2)
- if (prefix.reqType == 0 || prefix.reqType == 1)
- {
- memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
- _XRead(dpy, (char *)sprefix + sz_xReq,
- sz_xConnSetupPrefix - sz_xReq);
- return 1;
- }
- else
- {
- fprintf(stderr,
- "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n",
- prefix.reqType);
- return -1;
- }
- if (prefix.data != 2)
- return -1;
- kbuf.length = (prefix.length << 2) - sz_xReq;
- kbuf.data = (char *)malloc(kbuf.length);
- if (kbuf.data == NULL)
- {
- fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
- return -1;
- }
- _XRead(dpy, (char *)kbuf.data, kbuf.length);
- retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl);
- if (retval)
- {
- free(kbuf.data);
- fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n",
- error_message(retval));
- return -1;
- }
- free(kbuf.data);
- /*
- * stage 3: send a short ack to the server and return
- */
- prefix.reqType = 3;
- prefix.data = 0;
- prefix.length = sz_xReq >> 2;
- _XSend(dpy, (char *)&prefix, sz_xReq);
- return 0;
-}
-#endif /* K5AUTH */
-
-static void
-GetAuthorization(
- XtransConnInfo trans_conn,
- int family,
- char *saddr,
- int saddrlen,
- int idisplay,
- char **auth_namep, /* RETURN */
- int *auth_namelenp, /* RETURN */
- char **auth_datap, /* RETURN */
- int *auth_datalenp) /* RETURN */
-{
-#ifdef SECURE_RPC
- char rpc_cred[MAX_AUTH_BYTES];
-#endif
-#ifdef HASXDMAUTH
- unsigned char xdmcp_data[192/8];
-#endif
- char *auth_name;
- int auth_namelen;
- unsigned char *auth_data;
- int auth_datalen;
- Xauth *authptr = NULL;
-
-/*
- * Look up the authorization protocol name and data if necessary.
- */
- if (xauth_name && xauth_data) {
- auth_namelen = xauth_namelen;
- auth_name = xauth_name;
- auth_datalen = xauth_datalen;
- auth_data = (unsigned char *) xauth_data;
- } else {
- char dpynumbuf[40]; /* big enough to hold 2^64 and more */
- (void) sprintf (dpynumbuf, "%d", idisplay);
-
- authptr = XauGetBestAuthByAddr ((unsigned short) family,
- (unsigned short) saddrlen,
- saddr,
- (unsigned short) strlen (dpynumbuf),
- dpynumbuf,
- xauth_names_length,
- xauth_names,
- xauth_lengths);
- if (authptr) {
- auth_namelen = authptr->name_length;
- auth_name = (char *)authptr->name;
- auth_datalen = authptr->data_length;
- auth_data = (unsigned char *) authptr->data;
- } else {
- auth_namelen = 0;
- auth_name = NULL;
- auth_datalen = 0;
- auth_data = NULL;
- }
- }
-#ifdef HASXDMAUTH
- /*
- * build XDM-AUTHORIZATION-1 data
- */
- if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19))
- {
- int i, j;
- Time_t now;
- int family, addrlen;
- Xtransaddr *addr = NULL;
-
- for (j = 0; j < 8; j++)
- xdmcp_data[j] = auth_data[j];
-
- _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr);
-
- switch( family )
- {
-#ifdef AF_INET
- case AF_INET:
- {
- /*
- * addr will contain a sockaddr_in with all
- * of the members already in network byte order.
- */
-
- for(i=4; i<8; i++) /* do sin_addr */
- xdmcp_data[j++] = ((char *)addr)[i];
- for(i=2; i<4; i++) /* do sin_port */
- xdmcp_data[j++] = ((char *)addr)[i];
- break;
- }
-#endif /* AF_INET */
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- /* XXX This should probably never happen */
- {
- unsigned char ipv4mappedprefix[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
-
- /* In the case of v4 mapped addresses send the v4
- part of the address - addr is already in network byte order */
- if (memcmp((char*)addr+8, ipv4mappedprefix, 12) == 0) {
- for (i = 20 ; i < 24; i++)
- xdmcp_data[j++] = ((char *)addr)[i];
-
- /* Port number */
- for (i=2; i<4; i++)
- xdmcp_data[j++] = ((char *)addr)[i];
- } else {
- /* Fake data to keep the data aligned. Otherwise the
- the server will bail about incorrect timing data */
- for (i = 0; i < 6; i++) {
- xdmcp_data[j++] = 0;
- }
- }
- break;
- }
-#endif /* AF_INET6 */
-#ifdef AF_UNIX
- case AF_UNIX:
- {
- /*
- * We don't use the sockaddr_un for this encoding.
- * Instead, we create a sockaddr_in filled with
- * a decreasing counter for the address, and the
- * pid for the port.
- */
-
- static unsigned long unix_addr = 0xFFFFFFFF;
- unsigned long the_addr;
- unsigned short the_port;
- unsigned long the_utime;
- struct timeval tp;
-
- X_GETTIMEOFDAY(&tp);
- _XLockMutex(_Xglobal_lock);
- the_addr = unix_addr--;
- _XUnlockMutex(_Xglobal_lock);
- the_utime = (unsigned long) tp.tv_usec;
- the_port = getpid ();
-
- xdmcp_data[j++] = (the_utime >> 24) & 0xFF;
- xdmcp_data[j++] = (the_utime >> 16) & 0xFF;
- xdmcp_data[j++] = ((the_utime >> 8) & 0xF0)
- | ((the_addr >> 8) & 0x0F);
- xdmcp_data[j++] = (the_addr >> 0) & 0xFF;
- xdmcp_data[j++] = (the_port >> 8) & 0xFF;
- xdmcp_data[j++] = (the_port >> 0) & 0xFF;
- break;
- }
-#endif /* AF_UNIX */
-#ifdef AF_DECnet
- case AF_DECnet:
- /*
- * What is the defined encoding for this?
- */
- break;
-#endif /* AF_DECnet */
- default:
- /*
- * Need to return some kind of errro status here.
- * maybe a NULL auth??
- */
- break;
- } /* switch */
-
- if (addr)
- free ((char *) addr);
-
- time (&now);
- xdmcp_data[j++] = (now >> 24) & 0xFF;
- xdmcp_data[j++] = (now >> 16) & 0xFF;
- xdmcp_data[j++] = (now >> 8) & 0xFF;
- xdmcp_data[j++] = (now >> 0) & 0xFF;
- while (j < 192 / 8)
- xdmcp_data[j++] = 0;
- _XLockMutex(_Xglobal_lock);
- /* this function might use static data, hence the lock around it */
- XdmcpWrap (xdmcp_data, auth_data + 8,
- xdmcp_data, j);
- _XUnlockMutex(_Xglobal_lock);
- auth_data = xdmcp_data;
- auth_datalen = j;
- }
-#endif /* HASXDMAUTH */
-#ifdef SECURE_RPC
- /*
- * The SUN-DES-1 authorization protocol uses the
- * "secure RPC" mechanism in SunOS 4.0+.
- */
- if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) {
- char servernetname[MAXNETNAMELEN + 1];
-
- /*
- * Copy over the server's netname from the authorization
- * data field filled in by XauGetAuthByAddr().
- */
- if (auth_datalen > MAXNETNAMELEN) {
- auth_datalen = 0;
- auth_data = NULL;
- } else {
- memcpy(servernetname, auth_data, auth_datalen);
- servernetname[auth_datalen] = '\0';
-
- auth_datalen = sizeof (rpc_cred);
- if (auth_ezencode(servernetname, 100, rpc_cred,
- &auth_datalen))
- auth_data = (unsigned char *) rpc_cred;
- else {
- auth_datalen = 0;
- auth_data = NULL;
- }
- }
- }
-#endif
- if (saddr) free ((char *) saddr);
- if ((*auth_namelenp = auth_namelen))
- {
- if ((*auth_namep = Xmalloc(auth_namelen)))
- memcpy(*auth_namep, auth_name, auth_namelen);
- else
- *auth_namelenp = 0;
- }
- else
- *auth_namep = NULL;
- if ((*auth_datalenp = auth_datalen))
- {
- if ((*auth_datap = Xmalloc(auth_datalen)))
- memcpy(*auth_datap, auth_data, auth_datalen);
- else
- *auth_datalenp = 0;
- }
- else
- *auth_datap = NULL;
- if (authptr) XauDisposeAuth (authptr);
-}
+/*
+
+Copyright 1989, 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.
+
+*/
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <X11/Xlibint.h>
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/Xauth.h>
+#ifdef HASXDMAUTH
+#include <X11/Xdmcp.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+#include <unistd.h>
+
+#if !defined(WIN32)
+#ifndef Lynx
+#include <sys/socket.h>
+#else
+#include <socket.h>
+#endif
+#else
+#include <X11/Xwindows.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#include "Xintconn.h"
+
+/* prototypes */
+static void GetAuthorization(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ char **auth_namep,
+ int *auth_namelenp,
+ char **auth_datap,
+ int *auth_datalenp);
+
+/* functions */
+static char *copystring (const char *src, int len)
+{
+ char *dst = Xmalloc (len + 1);
+
+ if (dst) {
+ strncpy (dst, src, len);
+ dst[len] = '\0';
+ }
+
+ return dst;
+}
+
+#define Xstrdup(s) copystring(s, strlen(s))
+
+#ifdef TCPCONN
+# define TCP_TRANS "tcp"
+#endif
+#ifdef UNIXCONN
+# define UNIX_TRANS "unix"
+#endif
+#if defined(LOCALCONN) || defined(OS2PIPECONN)
+# define LOCAL_TRANS "local"
+#endif
+
+/*
+ * Attempts to connect to server, given display name. Returns file descriptor
+ * (network socket) or -1 if connection fails. Display names may be of the
+ * following format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber [.screennumber]
+ *
+ * A string with exactly two colons seperating hostname from the display
+ * indicates a DECnet style name. Colons in the hostname may occur if an
+ * IPv6 numeric address is used as the hostname. An IPv6 numeric address
+ * may also end in a double colon, so three colons in a row indicates an
+ * IPv6 address ending in :: followed by :display. To make it easier for
+ * people to read, an IPv6 numeric address hostname may be surrounded by
+ * [ ] in a similar fashion to the IPv6 numeric address URL syntax defined
+ * by IETF RFC 2732.
+ *
+ * If no hostname and no protocol is specified, the string is interpreted
+ * as the most efficient local connection to a server on the same machine.
+ * This is usually:
+ *
+ * o shared memory
+ * o local stream
+ * o UNIX domain socket
+ * o TCP to local host
+ *
+ * This function will eventually call the X Transport Interface functions
+ * which expects the hostname in the format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber
+ *
+ */
+XtransConnInfo
+_X11TransConnectDisplay (
+ char *display_name,
+ char **fullnamep, /* RETURN */
+ int *dpynump, /* RETURN */
+ int *screenp, /* RETURN */
+ char **auth_namep, /* RETURN */
+ int *auth_namelenp, /* RETURN */
+ char **auth_datap, /* RETURN */
+ int *auth_datalenp) /* RETURN */
+{
+ int family;
+ int saddrlen;
+ Xtransaddr *saddr;
+ char *lastp, *lastc, *p; /* char pointers */
+ char *pprotocol = NULL; /* start of protocol name */
+ char *phostname = NULL; /* start of host of display */
+ char *pdpynum = NULL; /* start of dpynum of display */
+ char *pscrnum = NULL; /* start of screen of display */
+ Bool dnet = False; /* if true, then DECnet format */
+ int idisplay = 0; /* required display number */
+ int iscreen = 0; /* optional screen number */
+ /* int (*connfunc)(); */ /* method to create connection */
+ int len, hostlen; /* length tmp variable */
+ int retry; /* retry counter */
+ char addrbuf[128]; /* final address passed to
+ X Transport Interface */
+ char* address = addrbuf;
+ XtransConnInfo trans_conn = NULL; /* transport connection object */
+ int connect_stat;
+#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
+ Bool reset_hostname = False; /* Reset hostname? */
+ char *original_hostname = NULL;
+ int local_transport_index = -1;
+ const char *local_transport[] = { LOCAL_TRANSPORT_LIST, NULL };
+#endif
+
+ p = display_name;
+
+ saddrlen = 0; /* set so that we can clear later */
+ saddr = NULL;
+
+ /*
+ * Step 0, find the protocol. This is delimited by the optional
+ * slash ('/').
+ */
+ for (lastp = p; *p && *p != ':' && *p != '/'; p++) ;
+ if (!*p) return NULL; /* must have a colon */
+
+ if (p != lastp && *p != ':') { /* protocol given? */
+ pprotocol = copystring (lastp, p - lastp);
+ if (!pprotocol) goto bad; /* no memory */
+ p++; /* skip the '/' */
+ } else
+ p = display_name; /* reset the pointer in
+ case no protocol was given */
+
+ /*
+ * Step 1, find the hostname. This is delimited by either one colon,
+ * or two colons in the case of DECnet (DECnet Phase V allows a single
+ * colon in the hostname). (See note above regarding IPv6 numeric
+ * addresses with triple colons or [] brackets.)
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')
+#if defined(IPv6) && defined(AF_INET6)
+ && ( ((lastc - 1) == lastp) || (*(lastc - 2) != ':'))
+#endif
+ ) {
+ /* DECnet display specified */
+
+#ifndef DNETCONN
+ goto bad;
+#else
+ dnet = True;
+ /* override the protocol specified */
+ if (pprotocol)
+ Xfree (pprotocol);
+ pprotocol = copystring ("dnet", 4);
+ hostlen = lastc - 1 - lastp;
+#endif
+ }
+ else
+ hostlen = lastc - lastp;
+
+ if (hostlen > 0) { /* hostname given? */
+ phostname = copystring (lastp, hostlen);
+ if (!phostname) goto bad; /* no memory */
+ }
+
+ p = lastc;
+
+#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
+ /* check if phostname == localnodename AND protocol not specified */
+ if (!pprotocol && phostname) {
+ char localhostname[256];
+
+ if ((_XGetHostname (localhostname, sizeof localhostname) > 0)
+ && (strcmp(phostname, localhostname) == 0)) {
+ original_hostname = phostname;
+ phostname = NULL;
+ reset_hostname = True;
+ }
+ }
+#endif
+
+
+ /*
+ * Step 2, find the display number. This field is required and is
+ * delimited either by a nul or a period, depending on whether or not
+ * a screen number is present.
+ */
+
+ for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ;
+ if ((p == lastp) || /* required field */
+ (*p != '\0' && *p != '.') || /* invalid non-digit terminator */
+ !(pdpynum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ idisplay = atoi (pdpynum);
+
+
+ /*
+ * Step 3, find the screen number. This field is optional. It is
+ * present only if the display number was followed by a period (which
+ * we've already verified is the only non-nul character).
+ */
+
+ if (*p) {
+ for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ;
+ if (p != lastp) {
+ if (*p || /* non-digits */
+ !(pscrnum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ iscreen = atoi (lastp);
+ }
+ }
+
+ /*
+ * At this point, we know the following information:
+ *
+ * pprotocol protocol string or NULL
+ * phostname hostname string or NULL
+ * idisplay display number
+ * iscreen screen number
+ * dnet DECnet boolean
+ *
+ * We can now decide which transport to use based on the defined
+ * connection types and the hostname string.
+ * If phostname & pprotocol are NULL, then choose the best transport.
+ * If phostname is "unix" & pprotocol is NULL, then choose UNIX domain
+ * sockets (if configured).
+ */
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN)
+ if (!pprotocol) {
+#if defined(UNIXCONN)
+ if (phostname && (strcmp (phostname, "unix") == 0)) {
+ Xfree(pprotocol);
+ pprotocol = copystring ("unix", 4);
+ } else
+#endif
+#ifdef HAVE_LAUNCHD
+ if (phostname && phostname[0]=='/') {
+ pprotocol = copystring ("local", 5);
+ }
+#endif
+ if (!phostname)
+ {
+ if (local_transport[0] != NULL) {
+ pprotocol = Xstrdup(local_transport[0]);
+ local_transport_index = 0;
+ }
+ }
+
+ if (!pprotocol) { /* if still not found one, tcp is our last resort */
+ pprotocol = copystring ("tcp", 3);
+ }
+ }
+#endif
+
+
+ connect:
+ /*
+ * This seems kind of backwards, but we need to put the protocol,
+ * host, and port back together to pass to _X11TransOpenCOTSClient().
+ */
+
+ {
+ int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) +
+ (phostname ? strlen(phostname) : 0) +
+ (pdpynum ? strlen(pdpynum) : 0);
+ if (olen > sizeof addrbuf) address = Xmalloc (olen);
+ }
+ if (!address) goto bad;
+
+ sprintf(address,"%s/%s:%d",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ idisplay );
+
+ /*
+ * Make the connection, also need to get the auth address info for
+ * the connection. Do retries in case server host has hit its
+ * backlog (which, unfortunately, isn't distinguishable from there not
+ * being a server listening at all, which is why we have to not retry
+ * too many times).
+ */
+ for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
+ {
+ if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
+ {
+ break;
+ }
+ if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ continue;
+ else
+ break;
+ }
+
+ _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
+
+ /*
+ * The family is given in a socket format (ie AF_INET). This
+ * will convert it to the format used by the authorization and
+ * X protocol (ie FamilyInternet).
+ */
+
+ if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+ if (saddr)
+ {
+ free ((char *) saddr);
+ saddr = NULL;
+ }
+ continue;
+ }
+
+ break;
+ }
+
+ if (address != addrbuf) Xfree (address);
+ address = addrbuf;
+
+ if( trans_conn == NULL )
+ goto bad;
+
+ /*
+ * Set close-on-exec so that programs that fork() doesn't get confused.
+ */
+
+ _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1);
+
+ /*
+ * Build the expanded display name:
+ *
+ * [host] : [:] dpy . scr \0
+ */
+#if defined(LOCALCONN) || defined(TCPCONN) || defined(UNIXCONN)
+ /*
+ * If we computed the host name, get rid of it so that
+ * XDisplayString() and XDisplayName() agree.
+ */
+ if (reset_hostname && (phostname != original_hostname)) {
+ Xfree (phostname);
+ phostname = original_hostname;
+ original_hostname = NULL;
+ }
+#endif
+ len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) +
+ strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1);
+ *fullnamep = (char *) Xmalloc (len);
+ if (!*fullnamep) goto bad;
+
+#ifdef HAVE_LAUNCHD
+ if (phostname && strlen(phostname) > 11 && !strncmp(phostname, "/tmp/launch", 11))
+ sprintf (*fullnamep, "%s%s%d",
+ (phostname ? phostname : ""),
+ (dnet ? "::" : ":"),
+ idisplay);
+ else
+#endif
+ sprintf (*fullnamep, "%s%s%d.%d",
+ (phostname ? phostname : ""),
+ (dnet ? "::" : ":"),
+ idisplay, iscreen);
+
+ *dpynump = idisplay;
+ *screenp = iscreen;
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
+ if (original_hostname) Xfree (original_hostname);
+#endif
+
+ GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+ return trans_conn;
+
+
+ /*
+ * error return; make sure everything is cleaned up.
+ */
+ bad:
+ if (trans_conn) (void)_X11TransClose(trans_conn);
+ if (saddr) free ((char *) saddr);
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+ if (address && address != addrbuf) { Xfree(address); address = addrbuf; }
+
+#if defined(LOCALCONN) || defined(UNIXCONN) || defined(TCPCONN)
+ /* If connecting to the local machine, and we failed, try again with
+ * the next transport type available, if there is one.
+ */
+ if (local_transport_index >= 0) {
+ if (local_transport[++local_transport_index] != NULL) {
+ pprotocol = Xstrdup(local_transport[local_transport_index]);
+#ifdef TCPCONN
+ if (strcmp(pprotocol, "tcp") == 0) {
+ if (original_hostname != NULL) {
+ phostname = original_hostname;
+ original_hostname = NULL;
+ } else {
+ phostname = copystring("localhost", 9);
+ }
+ } else
+#endif /* TCPCONN */
+ {
+ if ((phostname != NULL) && (original_hostname == NULL)) {
+ original_hostname = phostname;
+ }
+ phostname = NULL;
+ }
+ goto connect;
+ }
+ }
+
+ /* No more to try, we've failed all available local transports */
+ if (original_hostname) Xfree(original_hostname);
+#endif /* LOCALCONN || UNIXCONN || TCPCONN */
+
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+ return NULL;
+
+}
+
+/*
+ * This is gross, but we need it for compatiblity.
+ * The test suite relies on the following interface.
+ *
+ */
+
+int _XConnectDisplay (
+ char *display_name,
+ char **fullnamep, /* RETURN */
+ int *dpynump, /* RETURN */
+ int *screenp, /* RETURN */
+ char **auth_namep, /* RETURN */
+ int *auth_namelenp, /* RETURN */
+ char **auth_datap, /* RETURN */
+ int *auth_datalenp) /* RETURN */
+{
+ XtransConnInfo trans_conn;
+
+ trans_conn = _X11TransConnectDisplay (
+ display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+
+ if (trans_conn)
+ {
+ int fd = _X11TransGetConnectionNumber (trans_conn);
+ _X11TransFreeConnInfo (trans_conn);
+ return (fd);
+ }
+ else
+ return (-1);
+}
+
+
+/*****************************************************************************
+ * *
+ * Connection Utility Routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * Disconnect from server.
+ */
+
+int _XDisconnectDisplay (XtransConnInfo trans_conn)
+{
+ _X11TransDisconnect(trans_conn);
+ _X11TransClose(trans_conn);
+ return 0;
+}
+
+
+
+Bool
+_XSendClientPrefix(
+ Display *dpy,
+ xConnClientPrefix *client, /* contains count for auth_* */
+ char *auth_proto, char *auth_string, /* NOT null-terminated */
+ xConnSetupPrefix *prefix) /* prefix information */
+{
+ int auth_length = client->nbytesAuthProto;
+ int auth_strlen = client->nbytesAuthString;
+ static char padbuf[3]; /* for padding to 4x bytes */
+ int pad;
+ struct iovec iovarray[5], *iov = iovarray;
+ int niov = 0;
+ int len = 0;
+
+#define add_to_iov(b,l) \
+ { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); }
+
+ add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix));
+
+ /*
+ * write authorization protocol name and data
+ */
+ if (auth_length > 0) {
+ add_to_iov (auth_proto, auth_length);
+ pad = -auth_length & 3; /* pad auth_length to a multiple of 4 */
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = -auth_strlen & 3; /* pad auth_strlen to a multiple of 4 */
+ if (pad) add_to_iov (padbuf, pad);
+ }
+
+#undef add_to_iov
+
+ len -= _X11TransWritev (dpy->trans_conn, iovarray, niov);
+
+ /*
+ * Set the connection non-blocking since we use select() to block.
+ */
+
+ _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (len != 0)
+ return -1;
+
+#ifdef K5AUTH
+ if (auth_length == 14 &&
+ !strncmp(auth_proto, "MIT-KERBEROS-5", 14))
+ {
+ return k5_clientauth(dpy, prefix);
+ } else
+#endif
+ return 0;
+}
+
+
+#ifdef STREAMSCONN
+#ifdef SVR4
+#include <tiuser.h>
+#else
+#undef HASXDMAUTH
+#endif
+#endif
+
+#ifdef SECURE_RPC
+#include <rpc/rpc.h>
+#ifdef ultrix
+#include <time.h>
+#include <rpc/auth_des.h>
+#endif
+#endif
+
+#ifdef HASXDMAUTH
+#include <time.h>
+#define Time_t time_t
+#endif
+
+/*
+ * First, a routine for setting authorization data
+ */
+static int xauth_namelen = 0;
+static char *xauth_name = NULL; /* NULL means use default mechanism */
+static int xauth_datalen = 0;
+static char *xauth_data = NULL; /* NULL means get default data */
+
+/*
+ * This is a list of the authorization names which Xlib currently supports.
+ * Xau will choose the file entry which matches the earliest entry in this
+ * array, allowing us to prioritize these in terms of the most secure first
+ */
+
+static char *default_xauth_names[] = {
+#ifdef K5AUTH
+ "MIT-KERBEROS-5",
+#endif
+#ifdef SECURE_RPC
+ "SUN-DES-1",
+#endif
+#ifdef HASXDMAUTH
+ "XDM-AUTHORIZATION-1",
+#endif
+ "MIT-MAGIC-COOKIE-1"
+};
+
+static _Xconst int default_xauth_lengths[] = {
+#ifdef K5AUTH
+ 14, /* strlen ("MIT-KERBEROS-5") */
+#endif
+#ifdef SECURE_RPC
+ 9, /* strlen ("SUN-DES-1") */
+#endif
+#ifdef HASXDMAUTH
+ 19, /* strlen ("XDM-AUTHORIZATION-1") */
+#endif
+ 18 /* strlen ("MIT-MAGIC-COOKIE-1") */
+};
+
+#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0]))
+
+static char **xauth_names = default_xauth_names;
+static _Xconst int *xauth_lengths = default_xauth_lengths;
+
+static int xauth_names_length = NUM_DEFAULT_AUTH;
+
+void XSetAuthorization (
+ char *name, int namelen, /* *len are lengths of name and data */
+ char *data, int datalen) /* name/data are NULL or arbitrary array of bytes */
+{
+ char *tmpname, *tmpdata;
+
+ _XLockMutex(_Xglobal_lock);
+ if (xauth_name) Xfree (xauth_name); /* free any existing data */
+ if (xauth_data) Xfree (xauth_data);
+
+ xauth_name = xauth_data = NULL; /* mark it no longer valid */
+ xauth_namelen = xauth_datalen = 0;
+ _XUnlockMutex(_Xglobal_lock);
+
+ if (namelen < 0) namelen = 0; /* check for bogus inputs */
+ if (datalen < 0) datalen = 0; /* maybe should return? */
+
+ if (namelen > 0) { /* try to allocate space */
+ tmpname = Xmalloc ((unsigned) namelen);
+ if (!tmpname) return;
+ memcpy (tmpname, name, namelen);
+ } else {
+ tmpname = NULL;
+ }
+
+ if (datalen > 0) {
+ tmpdata = Xmalloc ((unsigned) datalen);
+ if (!tmpdata) {
+ if (tmpname) (void) Xfree (tmpname);
+ return;
+ }
+ memcpy (tmpdata, data, datalen);
+ } else {
+ tmpdata = NULL;
+ }
+
+ _XLockMutex(_Xglobal_lock);
+ xauth_name = tmpname; /* and store the suckers */
+ xauth_namelen = namelen;
+ if (tmpname)
+ {
+ xauth_names = &xauth_name;
+ xauth_lengths = &xauth_namelen;
+ xauth_names_length = 1;
+ }
+ else
+ {
+ xauth_names = default_xauth_names;
+ xauth_lengths = default_xauth_lengths;
+ xauth_names_length = NUM_DEFAULT_AUTH;
+ }
+ xauth_data = tmpdata;
+ xauth_datalen = datalen;
+ _XUnlockMutex(_Xglobal_lock);
+ return;
+}
+
+#ifdef SECURE_RPC
+/*
+ * Create a credential that we can send to the X server.
+ */
+static int
+auth_ezencode(
+ char *servername,
+ int window,
+ char *cred_out,
+ int *len)
+{
+ AUTH *a;
+ XDR xdr;
+
+#if defined(SVR4) && defined(sun)
+ a = authdes_seccreate(servername, window, NULL, NULL);
+#else
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+#endif
+ if (a == (AUTH *)NULL) {
+ perror("auth_create");
+ return 0;
+ }
+ xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE);
+ if (AUTH_MARSHALL(a, &xdr) == FALSE) {
+ perror("auth_marshall");
+ AUTH_DESTROY(a);
+ return 0;
+ }
+ *len = xdr_getpos(&xdr);
+ AUTH_DESTROY(a);
+ return 1;
+}
+#endif
+
+#ifdef K5AUTH
+#include <com_err.h>
+
+extern krb5_flags krb5_kdc_default_options;
+
+/*
+ * k5_clientauth
+ *
+ * Returns non-zero if the setup prefix has been read,
+ * so we can tell XOpenDisplay to not bother looking for it by
+ * itself.
+ */
+static int k5_clientauth(dpy, sprefix)
+ Display *dpy;
+ xConnSetupPrefix *sprefix;
+{
+ krb5_error_code retval;
+ xReq prefix;
+ char *buf;
+ CARD16 plen, tlen;
+ krb5_data kbuf;
+ krb5_ccache cc;
+ krb5_creds creds;
+ krb5_principal cprinc, sprinc;
+ krb5_ap_rep_enc_part *repl;
+
+ krb5_init_ets();
+ /*
+ * stage 0: get encoded principal and tgt from server
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2 && prefix.reqType != 3)
+ /* not an auth packet... so deal */
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 0)
+ {
+ fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n",
+ prefix.data);
+ return -1;
+ }
+ buf = (char *)malloc((prefix.length << 2) - sz_xReq);
+ if (buf == NULL) /* malloc failed. Run away! */
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ tlen = (prefix.length << 2) - sz_xReq;
+ _XRead(dpy, buf, tlen);
+ if (prefix.reqType == 2 && tlen < 6)
+ {
+ fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n");
+ free(buf);
+ return -1;
+ }
+ if (prefix.reqType == 2)
+ {
+ plen = *(CARD16 *)buf;
+ kbuf.data = buf + 2;
+ kbuf.length = (plen > tlen) ? tlen : plen;
+ }
+ else
+ {
+ kbuf.data = buf;
+ kbuf.length = tlen;
+ }
+ if (XauKrb5Decode(kbuf, &sprinc))
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: XauKrb5Decode bombed\n");
+ return -1;
+ }
+ if (prefix.reqType == 3) /* do some special stuff here */
+ {
+ char *sname, *hostname = NULL;
+
+ sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1);
+ if (sname == NULL)
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ memcpy(sname, krb5_princ_component(sprinc, 0)->data,
+ krb5_princ_component(sprinc, 0)->length);
+ sname[krb5_princ_component(sprinc, 0)->length] = '\0';
+ krb5_free_principal(sprinc);
+ if (dpy->display_name[0] != ':') /* hunt for a hostname */
+ {
+ char *t;
+
+ if ((hostname = (char *)malloc(strlen(dpy->display_name)))
+ == NULL)
+ {
+ free(buf);
+ free(sname);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ strcpy(hostname, dpy->display_name);
+ t = strchr(hostname, ':');
+ if (t == NULL)
+ {
+ free(buf);
+ free(sname);
+ free(hostname);
+ fprintf(stderr,
+ "Xlib: shouldn't get here! malformed display name.");
+ return -1;
+ }
+ if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':')
+ t++;
+ *t = '\0'; /* truncate the dpy number out */
+ }
+ retval = krb5_sname_to_principal(hostname, sname,
+ KRB5_NT_SRV_HST, &sprinc);
+ free(sname);
+ if (hostname)
+ free(hostname);
+ if (retval)
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ }
+ if (retval = krb5_cc_default(&cc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ if (retval = krb5_cc_get_principal(cc, &cprinc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n",
+ krb5_cc_default_name(), error_message(retval));
+ return -1;
+ }
+ bzero((char *)&creds, sizeof(creds));
+ creds.server = sprinc;
+ creds.client = cprinc;
+ if (prefix.reqType == 2)
+ {
+ creds.second_ticket.length = tlen - plen - 2;
+ creds.second_ticket.data = buf + 2 + plen;
+ retval = krb5_get_credentials(KRB5_GC_USER_USER |
+ krb5_kdc_default_options,
+ cc, &creds);
+ }
+ else
+ retval = krb5_get_credentials(krb5_kdc_default_options,
+ cc, &creds);
+ if (retval)
+ {
+ free(buf);
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ /*
+ * now format the ap_req to send to the server
+ */
+ if (prefix.reqType == 2)
+ retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY |
+ AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc,
+ &creds, NULL, &kbuf);
+ else
+ retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc, &creds, NULL,
+ &kbuf);
+ free(buf);
+ if (retval) /* Some manner of Kerberos lossage */
+ {
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ prefix.reqType = 1;
+ prefix.data = 0;
+ prefix.length = (kbuf.length + sz_xReq + 3) >> 2;
+ /*
+ * stage 1: send ap_req to server
+ */
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ _XSend(dpy, (char *)kbuf.data, kbuf.length);
+ free(kbuf.data);
+ /*
+ * stage 2: get ap_rep from server to mutually authenticate
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2)
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq);
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 2)
+ return -1;
+ kbuf.length = (prefix.length << 2) - sz_xReq;
+ kbuf.data = (char *)malloc(kbuf.length);
+ if (kbuf.data == NULL)
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ _XRead(dpy, (char *)kbuf.data, kbuf.length);
+ retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl);
+ if (retval)
+ {
+ free(kbuf.data);
+ fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ free(kbuf.data);
+ /*
+ * stage 3: send a short ack to the server and return
+ */
+ prefix.reqType = 3;
+ prefix.data = 0;
+ prefix.length = sz_xReq >> 2;
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ return 0;
+}
+#endif /* K5AUTH */
+
+static void
+GetAuthorization(
+ XtransConnInfo trans_conn,
+ int family,
+ char *saddr,
+ int saddrlen,
+ int idisplay,
+ char **auth_namep, /* RETURN */
+ int *auth_namelenp, /* RETURN */
+ char **auth_datap, /* RETURN */
+ int *auth_datalenp) /* RETURN */
+{
+#ifdef SECURE_RPC
+ char rpc_cred[MAX_AUTH_BYTES];
+#endif
+#ifdef HASXDMAUTH
+ unsigned char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ unsigned char *auth_data;
+ int auth_datalen;
+ Xauth *authptr = NULL;
+
+/*
+ * Look up the authorization protocol name and data if necessary.
+ */
+ if (xauth_name && xauth_data) {
+ auth_namelen = xauth_namelen;
+ auth_name = xauth_name;
+ auth_datalen = xauth_datalen;
+ auth_data = (unsigned char *) xauth_data;
+ } else {
+ char dpynumbuf[40]; /* big enough to hold 2^64 and more */
+ (void) sprintf (dpynumbuf, "%d", idisplay);
+
+ authptr = XauGetBestAuthByAddr ((unsigned short) family,
+ (unsigned short) saddrlen,
+ saddr,
+ (unsigned short) strlen (dpynumbuf),
+ dpynumbuf,
+ xauth_names_length,
+ xauth_names,
+ xauth_lengths);
+ if (authptr) {
+ auth_namelen = authptr->name_length;
+ auth_name = (char *)authptr->name;
+ auth_datalen = authptr->data_length;
+ auth_data = (unsigned char *) authptr->data;
+ } else {
+ auth_namelen = 0;
+ auth_name = NULL;
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+#ifdef HASXDMAUTH
+ /*
+ * build XDM-AUTHORIZATION-1 data
+ */
+ if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19))
+ {
+ int i, j;
+ Time_t now;
+ int family, addrlen;
+ Xtransaddr *addr = NULL;
+
+ for (j = 0; j < 8; j++)
+ xdmcp_data[j] = auth_data[j];
+
+ _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr);
+
+ switch( family )
+ {
+#ifdef AF_INET
+ case AF_INET:
+ {
+ /*
+ * addr will contain a sockaddr_in with all
+ * of the members already in network byte order.
+ */
+
+ for(i=4; i<8; i++) /* do sin_addr */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ for(i=2; i<4; i++) /* do sin_port */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ break;
+ }
+#endif /* AF_INET */
+#if defined(IPv6) && defined(AF_INET6)
+ case AF_INET6:
+ /* XXX This should probably never happen */
+ {
+ unsigned char ipv4mappedprefix[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+
+ /* In the case of v4 mapped addresses send the v4
+ part of the address - addr is already in network byte order */
+ if (memcmp((char*)addr+8, ipv4mappedprefix, 12) == 0) {
+ for (i = 20 ; i < 24; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+
+ /* Port number */
+ for (i=2; i<4; i++)
+ xdmcp_data[j++] = ((char *)addr)[i];
+ } else {
+ /* Fake data to keep the data aligned. Otherwise the
+ the server will bail about incorrect timing data */
+ for (i = 0; i < 6; i++) {
+ xdmcp_data[j++] = 0;
+ }
+ }
+ break;
+ }
+#endif /* AF_INET6 */
+#ifdef AF_UNIX
+ case AF_UNIX:
+ {
+ /*
+ * We don't use the sockaddr_un for this encoding.
+ * Instead, we create a sockaddr_in filled with
+ * a decreasing counter for the address, and the
+ * pid for the port.
+ */
+
+ static unsigned long unix_addr = 0xFFFFFFFF;
+ unsigned long the_addr;
+ unsigned short the_port;
+ unsigned long the_utime;
+ struct timeval tp;
+
+ X_GETTIMEOFDAY(&tp);
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_utime = (unsigned long) tp.tv_usec;
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_utime >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_utime >> 16) & 0xFF;
+ xdmcp_data[j++] = ((the_utime >> 8) & 0xF0)
+ | ((the_addr >> 8) & 0x0F);
+ xdmcp_data[j++] = (the_addr >> 0) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 8) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 0) & 0xFF;
+ break;
+ }
+#endif /* AF_UNIX */
+#ifdef AF_DECnet
+ case AF_DECnet:
+ /*
+ * What is the defined encoding for this?
+ */
+ break;
+#endif /* AF_DECnet */
+ default:
+ /*
+ * Need to return some kind of errro status here.
+ * maybe a NULL auth??
+ */
+ break;
+ } /* switch */
+
+ if (addr)
+ free ((char *) addr);
+
+ time (&now);
+ xdmcp_data[j++] = (now >> 24) & 0xFF;
+ xdmcp_data[j++] = (now >> 16) & 0xFF;
+ xdmcp_data[j++] = (now >> 8) & 0xFF;
+ xdmcp_data[j++] = (now >> 0) & 0xFF;
+ while (j < 192 / 8)
+ xdmcp_data[j++] = 0;
+ _XLockMutex(_Xglobal_lock);
+ /* this function might use static data, hence the lock around it */
+ XdmcpWrap (xdmcp_data, auth_data + 8,
+ xdmcp_data, j);
+ _XUnlockMutex(_Xglobal_lock);
+ auth_data = xdmcp_data;
+ auth_datalen = j;
+ }
+#endif /* HASXDMAUTH */
+#ifdef SECURE_RPC
+ /*
+ * The SUN-DES-1 authorization protocol uses the
+ * "secure RPC" mechanism in SunOS 4.0+.
+ */
+ if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) {
+ char servernetname[MAXNETNAMELEN + 1];
+
+ /*
+ * Copy over the server's netname from the authorization
+ * data field filled in by XauGetAuthByAddr().
+ */
+ if (auth_datalen > MAXNETNAMELEN) {
+ auth_datalen = 0;
+ auth_data = NULL;
+ } else {
+ memcpy(servernetname, auth_data, auth_datalen);
+ servernetname[auth_datalen] = '\0';
+
+ auth_datalen = sizeof (rpc_cred);
+ if (auth_ezencode(servernetname, 100, rpc_cred,
+ &auth_datalen))
+ auth_data = (unsigned char *) rpc_cred;
+ else {
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+ }
+#endif
+ if (saddr) free ((char *) saddr);
+ if ((*auth_namelenp = auth_namelen))
+ {
+ if ((*auth_namep = Xmalloc(auth_namelen)))
+ memcpy(*auth_namep, auth_name, auth_namelen);
+ else
+ *auth_namelenp = 0;
+ }
+ else
+ *auth_namep = NULL;
+ if ((*auth_datalenp = auth_datalen))
+ {
+ if ((*auth_datap = Xmalloc(auth_datalen)))
+ memcpy(*auth_datap, auth_data, auth_datalen);
+ else
+ *auth_datalenp = 0;
+ }
+ else
+ *auth_datap = NULL;
+ if (authptr) XauDisposeAuth (authptr);
+}
diff --git a/libX11/src/Makefile.am b/libX11/src/Makefile.am
index c2aa8bb16..a433fa78a 100644
--- a/libX11/src/Makefile.am
+++ b/libX11/src/Makefile.am
@@ -1,436 +1,437 @@
-if XKB
-XKB_SUBDIRS = xkb
-endif
-SUBDIRS = util xcms xlibi18n $(XKB_SUBDIRS)
-
-lib_LTLIBRARIES=libX11.la
-
-BUILT_SOURCES=ks_tables.h
-CLEANFILES=ks_tables.h ks_tables_h
-
-AM_CPPFLAGS= \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -D_BSD_SOURCE -DX11_t -DTRANS_CLIENT
-
-AM_CFLAGS= \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-#
-# =============================== I18N =============================
-#
-
-I18N_LIBS = \
- xlibi18n/libi18n.la
-
-#
-# =============================== XCMS =============================
-#
-
-XCMS_LIBS = \
- xcms/libxcms.la
-
-#
-# =============================== XKB ==============================
-#
-
-XKB_LIBS = \
- xkb/libxkb.la
-
-#
-# =============================== XLIB =============================
-#
-
-libX11_la_SOURCES = \
- AllCells.c \
- AllowEv.c \
- AllPlanes.c \
- AutoRep.c \
- Backgnd.c \
- BdrWidth.c \
- Bell.c \
- Border.c \
- ChAccCon.c \
- ChActPGb.c \
- ChClMode.c \
- ChCmap.c \
- ChGC.c \
- ChKeyCon.c \
- ChkIfEv.c \
- ChkMaskEv.c \
- ChkTypEv.c \
- ChkTypWEv.c \
- ChkWinEv.c \
- ChPntCon.c \
- ChProp.c \
- ChSaveSet.c \
- ChWAttrs.c \
- ChWindow.c \
- CirWin.c \
- CirWinDn.c \
- CirWinUp.c \
- ClDisplay.c \
- ClearArea.c \
- Clear.c \
- Cmap.h \
- ConfWind.c \
- Context.c \
- ConvSel.c \
- CopyArea.c \
- CopyCmap.c \
- CopyGC.c \
- CopyPlane.c \
- CrBFData.c \
- CrCmap.c \
- CrCursor.c \
- CrGC.c \
- CrGlCur.c \
- Cr.h \
- CrPFBData.c \
- CrPixmap.c \
- CrWindow.c \
- Cursor.c \
- DefCursor.c \
- DelProp.c \
- Depths.c \
- DestSubs.c \
- DestWind.c \
- DisName.c \
- DrArc.c \
- DrArcs.c \
- DrLine.c \
- DrLines.c \
- DrPoint.c \
- DrPoints.c \
- DrRect.c \
- DrRects.c \
- DrSegs.c \
- ErrDes.c \
- ErrHndlr.c \
- evtomask.c \
- EvToWire.c \
- FetchName.c \
- FillArc.c \
- FillArcs.c \
- FillPoly.c \
- FillRct.c \
- FillRcts.c \
- FilterEv.c \
- Flush.c \
- Font.c \
- FontInfo.c \
- FontNames.c \
- FreeCmap.c \
- FreeCols.c \
- FreeCurs.c \
- FreeEData.c \
- FreeEventData.c \
- FreeGC.c \
- FreePix.c \
- FSSaver.c \
- FSWrap.c \
- GCMisc.c \
- Geom.c \
- GetAtomNm.c \
- GetColor.c \
- GetDflt.c \
- GetEventData.c \
- GetFPath.c \
- GetFProp.c \
- GetGCVals.c \
- GetGeom.c \
- GetHColor.c \
- GetHints.c \
- GetIFocus.c \
- GetImage.c \
- GetKCnt.c \
- GetMoEv.c \
- GetNrmHint.c \
- GetPCnt.c \
- GetPntMap.c \
- GetProp.c \
- GetRGBCMap.c \
- GetSOwner.c \
- GetSSaver.c \
- GetStCmap.c \
- GetTxtProp.c \
- GetWAttrs.c \
- GetWMCMapW.c \
- GetWMProto.c \
- globals.c \
- GrButton.c \
- GrKeybd.c \
- GrKey.c \
- GrPointer.c \
- GrServer.c \
- Host.c \
- Iconify.c \
- IfEvent.c \
- imConv.c \
- ImText16.c \
- ImText.c \
- ImUtil.c \
- InitExt.c \
- InsCmap.c \
- IntAtom.c \
- KeyBind.c \
- Key.h \
- KeysymStr.c \
- KillCl.c \
- LiHosts.c \
- LiICmaps.c \
- LiProps.c \
- ListExt.c \
- LoadFont.c \
- LockDis.c \
- locking.c \
- locking.h \
- LookupCol.c \
- LowerWin.c \
- Macros.c \
- MapRaised.c \
- MapSubs.c \
- MapWindow.c \
- MaskEvent.c \
- Misc.c \
- ModMap.c \
- MoveWin.c \
- NextEvent.c \
- OCWrap.c \
- OMWrap.c \
- OpenDis.c \
- ParseCmd.c \
- ParseCol.c \
- ParseGeom.c \
- PeekEvent.c \
- PeekIfEv.c \
- Pending.c \
- PixFormats.c \
- PmapBgnd.c \
- PmapBord.c \
- poly.h \
- PolyReg.c \
- PolyTxt16.c \
- PolyTxt.c \
- PropAlloc.c \
- PutBEvent.c \
- PutImage.c \
- Quarks.c \
- QuBest.c \
- QuColor.c \
- QuColors.c \
- QuCurShp.c \
- QuExt.c \
- QuKeybd.c \
- QuPntr.c \
- QuStipShp.c \
- QuTextE16.c \
- QuTextExt.c \
- QuTileShp.c \
- QuTree.c \
- RaiseWin.c \
- RdBitF.c \
- RecolorC.c \
- ReconfWin.c \
- ReconfWM.c \
- Region.c \
- RegstFlt.c \
- RepWindow.c \
- RestackWs.c \
- RotProp.c \
- ScrResStr.c \
- SelInput.c \
- SendEvent.c \
- SetBack.c \
- SetClMask.c \
- SetClOrig.c \
- SetCRects.c \
- SetDashes.c \
- SetFont.c \
- SetFore.c \
- SetFPath.c \
- SetFunc.c \
- SetHints.c \
- SetIFocus.c \
- SetLocale.c \
- SetLStyle.c \
- SetNrmHint.c \
- SetPMask.c \
- SetPntMap.c \
- SetRGBCMap.c \
- SetSOwner.c \
- SetSSaver.c \
- SetState.c \
- SetStCmap.c \
- SetStip.c \
- SetTile.c \
- SetTSOrig.c \
- SetTxtProp.c \
- SetWMCMapW.c \
- SetWMProto.c \
- StBytes.c \
- StColor.c \
- StColors.c \
- StName.c \
- StNColor.c \
- StrKeysym.c \
- StrToText.c \
- Sync.c \
- Synchro.c \
- Text16.c \
- Text.c \
- TextExt16.c \
- TextExt.c \
- TextToStr.c \
- TrCoords.c \
- UndefCurs.c \
- UngrabBut.c \
- UngrabKbd.c \
- UngrabKey.c \
- UngrabPtr.c \
- UngrabSvr.c \
- UninsCmap.c \
- UnldFont.c \
- UnmapSubs.c \
- UnmapWin.c \
- utlist.h \
- VisUtil.c \
- WarpPtr.c \
- Window.c \
- WinEvent.c \
- Withdraw.c \
- WMGeom.c \
- WMProps.c \
- WrBitF.c \
- Xatomtype.h \
- Xintatom.h \
- Xintconn.h \
- XlibAsync.c \
- XlibInt.c \
- Xprivate.h \
- XomGeneric.h \
- Xresinternal.h \
- Xrm.c \
- XrmI.h
-
-#
-# ========================= Extra stuff ============================
-#
-
-if OS2
-libX11_la_SOURCES+=os2Stubs.c
-endif OS2
-
-if UDC
-libX11_la_SOURCES+=udcInf.c
-endif
-
-if THRSTUBS
-libX11_la_SOURCES+=UIThrStubs.c
-endif
-
-x11datadir = @X11_DATADIR@
-x11data_DATA = XKeysymDB XErrorDB
-
-EXTRA_DIST = \
- $(x11data_DATA) \
- os2Stubs.c \
- udcInf.c \
- UIThrStubs.c
-
-if XCB
-libX11_la_SOURCES += \
- xcb_disp.c \
- xcb_io.c \
- Xxcbint.h
-
-lib_LTLIBRARIES += libX11-xcb.la
-libX11_xcb_la_SOURCES = x11_xcb.c Xxcbint.h
-libX11_xcb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
-libX11_xcb_la_LIBADD = libX11.la
-else
-libX11_la_SOURCES += \
- ConnDis.c \
- x11_trans.c
-endif
-
-#
-# Figure out which sub-libraries to link into Xlib
-#
-
-if XLOCALE
-USE_I18N_LIBS = $(I18N_LIBS)
-endif
-
-if XCMS
-USE_XCMS_LIBS = $(XCMS_LIBS)
-endif
-
-if XKB
-USE_XKB_LIBS = $(XKB_LIBS)
-endif
-
-libX11_la_LDFLAGS = -version-number 6:3:0 -no-undefined
-
-libX11_la_LIBADD = \
- $(USE_I18N_LIBS) \
- $(USE_XCMS_LIBS) \
- $(USE_XKB_LIBS) \
- $(X11_LIBS) \
- $(XDMCP_LIBS)
-
-preprocess: $(patsubst %.c,%.ii,$(libX11_la_SOURCES))
-.c.ii:
- $(COMPILE) -E -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
-
-if LINT
-# Check source code with tools like lint & sparse
-
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-lint: $(BUILT_SOURCES)
- for f in $(libX11_la_SOURCES) ; do \
- $(LINT) $(ALL_LINT_FLAGS) $$f ; \
- done
- @for subdir in $(SUBDIRS) ; do \
- echo "Making $@ in src/$$subdir"; \
- (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) lint) ; \
- done
-endif LINT
-
-if MAKE_LINT_LIB
-lintlibdir = $(libdir)
-
-lintlib_DATA = $(LINTLIB)
-
-lintlib_src = $(libX11_la_SOURCES) xcms/*.c xkb/*.c
-
-CLEANFILES += $(lintlib_DATA)
-
-$(LINTLIB): $(libX11_la_SOURCES)
- $(AM_V_GEN)$(LINT) -y -oX11 -x $(ALL_LINT_FLAGS) $(lintlib_src)
-endif MAKE_LINT_LIB
-
-#
-# Building ks_tables.h requires the makekeys utility
-#
-
-KEYSYMDEF=@KEYSYMDEF@
-
-ks_tables.h: $(KEYSYMDEF) $(top_builddir)/src/util/makekeys$(EXEEXT)
- $(top_builddir)/src/util/makekeys < $(KEYSYMDEF) > ks_tables_h
- mv ks_tables_h $@
-
-$(top_builddir)/src/util/makekeys$(EXEEXT): force
- cd util && $(MAKE)
-
-force:
+if XKB
+XKB_SUBDIRS = xkb
+endif
+SUBDIRS = util xcms xlibi18n $(XKB_SUBDIRS)
+
+lib_LTLIBRARIES=libX11.la
+
+BUILT_SOURCES=ks_tables.h
+CLEANFILES=ks_tables.h ks_tables_h
+
+AM_CPPFLAGS= \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/X11 \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/include/X11 \
+ -I$(top_srcdir)/src/xcms \
+ -I$(top_srcdir)/src/xkb \
+ -I$(top_srcdir)/src/xlibi18n \
+ -D_BSD_SOURCE -DX11_t -DTRANS_CLIENT
+
+AM_CFLAGS= \
+ $(X11_CFLAGS) \
+ $(BIGFONT_CFLAGS) \
+ $(XDMCP_CFLAGS) \
+ $(XMALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+#
+# =============================== I18N =============================
+#
+
+I18N_LIBS = \
+ xlibi18n/libi18n.la
+
+#
+# =============================== XCMS =============================
+#
+
+XCMS_LIBS = \
+ xcms/libxcms.la
+
+#
+# =============================== XKB ==============================
+#
+
+XKB_LIBS = \
+ xkb/libxkb.la
+
+#
+# =============================== XLIB =============================
+#
+
+libX11_la_SOURCES = \
+ AllCells.c \
+ AllowEv.c \
+ AllPlanes.c \
+ AutoRep.c \
+ Backgnd.c \
+ BdrWidth.c \
+ Bell.c \
+ Border.c \
+ ChAccCon.c \
+ ChActPGb.c \
+ ChClMode.c \
+ ChCmap.c \
+ ChGC.c \
+ ChKeyCon.c \
+ ChkIfEv.c \
+ ChkMaskEv.c \
+ ChkTypEv.c \
+ ChkTypWEv.c \
+ ChkWinEv.c \
+ ChPntCon.c \
+ ChProp.c \
+ ChSaveSet.c \
+ ChWAttrs.c \
+ ChWindow.c \
+ CirWin.c \
+ CirWinDn.c \
+ CirWinUp.c \
+ ClDisplay.c \
+ ClearArea.c \
+ Clear.c \
+ Cmap.h \
+ ConfWind.c \
+ Context.c \
+ ConvSel.c \
+ CopyArea.c \
+ CopyCmap.c \
+ CopyGC.c \
+ CopyPlane.c \
+ CrBFData.c \
+ CrCmap.c \
+ CrCursor.c \
+ CrGC.c \
+ CrGlCur.c \
+ Cr.h \
+ CrPFBData.c \
+ CrPixmap.c \
+ CrWindow.c \
+ Cursor.c \
+ DefCursor.c \
+ DelProp.c \
+ Depths.c \
+ DestSubs.c \
+ DestWind.c \
+ DisName.c \
+ DrArc.c \
+ DrArcs.c \
+ DrLine.c \
+ DrLines.c \
+ DrPoint.c \
+ DrPoints.c \
+ DrRect.c \
+ DrRects.c \
+ DrSegs.c \
+ ErrDes.c \
+ ErrHndlr.c \
+ evtomask.c \
+ EvToWire.c \
+ FetchName.c \
+ FillArc.c \
+ FillArcs.c \
+ FillPoly.c \
+ FillRct.c \
+ FillRcts.c \
+ FilterEv.c \
+ Flush.c \
+ Font.c \
+ FontInfo.c \
+ FontNames.c \
+ FreeCmap.c \
+ FreeCols.c \
+ FreeCurs.c \
+ FreeEData.c \
+ FreeEventData.c \
+ FreeGC.c \
+ FreePix.c \
+ FSSaver.c \
+ FSWrap.c \
+ GCMisc.c \
+ Geom.c \
+ GetAtomNm.c \
+ GetColor.c \
+ GetDflt.c \
+ GetEventData.c \
+ GetFPath.c \
+ GetFProp.c \
+ GetGCVals.c \
+ GetGeom.c \
+ GetHColor.c \
+ GetHints.c \
+ GetIFocus.c \
+ GetImage.c \
+ GetKCnt.c \
+ GetMoEv.c \
+ GetNrmHint.c \
+ GetPCnt.c \
+ GetPntMap.c \
+ GetProp.c \
+ GetRGBCMap.c \
+ GetSOwner.c \
+ GetSSaver.c \
+ GetStCmap.c \
+ GetTxtProp.c \
+ GetWAttrs.c \
+ GetWMCMapW.c \
+ GetWMProto.c \
+ globals.c \
+ GrButton.c \
+ GrKeybd.c \
+ GrKey.c \
+ GrPointer.c \
+ GrServer.c \
+ Host.c \
+ Iconify.c \
+ IfEvent.c \
+ imConv.c \
+ ImText16.c \
+ ImText.c \
+ ImUtil.c \
+ InitExt.c \
+ InsCmap.c \
+ IntAtom.c \
+ KeyBind.c \
+ Key.h \
+ KeysymStr.c \
+ KillCl.c \
+ LiHosts.c \
+ LiICmaps.c \
+ LiProps.c \
+ ListExt.c \
+ LoadFont.c \
+ LockDis.c \
+ locking.c \
+ locking.h \
+ LookupCol.c \
+ LowerWin.c \
+ Macros.c \
+ MapRaised.c \
+ MapSubs.c \
+ MapWindow.c \
+ MaskEvent.c \
+ Misc.c \
+ ModMap.c \
+ MoveWin.c \
+ NextEvent.c \
+ OCWrap.c \
+ OMWrap.c \
+ OpenDis.c \
+ ParseCmd.c \
+ ParseCol.c \
+ ParseGeom.c \
+ PeekEvent.c \
+ PeekIfEv.c \
+ Pending.c \
+ PixFormats.c \
+ PmapBgnd.c \
+ PmapBord.c \
+ poly.h \
+ PolyReg.c \
+ PolyTxt16.c \
+ PolyTxt.c \
+ PropAlloc.c \
+ PutBEvent.c \
+ PutImage.c \
+ Quarks.c \
+ QuBest.c \
+ QuColor.c \
+ QuColors.c \
+ QuCurShp.c \
+ QuExt.c \
+ QuKeybd.c \
+ QuPntr.c \
+ QuStipShp.c \
+ QuTextE16.c \
+ QuTextExt.c \
+ QuTileShp.c \
+ QuTree.c \
+ RaiseWin.c \
+ RdBitF.c \
+ RecolorC.c \
+ ReconfWin.c \
+ ReconfWM.c \
+ Region.c \
+ RegstFlt.c \
+ RepWindow.c \
+ RestackWs.c \
+ RotProp.c \
+ ScrResStr.c \
+ SelInput.c \
+ SendEvent.c \
+ SetBack.c \
+ SetClMask.c \
+ SetClOrig.c \
+ SetCRects.c \
+ SetDashes.c \
+ SetFont.c \
+ SetFore.c \
+ SetFPath.c \
+ SetFunc.c \
+ SetHints.c \
+ SetIFocus.c \
+ SetLocale.c \
+ SetLStyle.c \
+ SetNrmHint.c \
+ SetPMask.c \
+ SetPntMap.c \
+ SetRGBCMap.c \
+ SetSOwner.c \
+ SetSSaver.c \
+ SetState.c \
+ SetStCmap.c \
+ SetStip.c \
+ SetTile.c \
+ SetTSOrig.c \
+ SetTxtProp.c \
+ SetWMCMapW.c \
+ SetWMProto.c \
+ StBytes.c \
+ StColor.c \
+ StColors.c \
+ StName.c \
+ StNColor.c \
+ StrKeysym.c \
+ StrToText.c \
+ Sync.c \
+ Synchro.c \
+ Text16.c \
+ Text.c \
+ TextExt16.c \
+ TextExt.c \
+ TextToStr.c \
+ TrCoords.c \
+ UndefCurs.c \
+ UngrabBut.c \
+ UngrabKbd.c \
+ UngrabKey.c \
+ UngrabPtr.c \
+ UngrabSvr.c \
+ UninsCmap.c \
+ UnldFont.c \
+ UnmapSubs.c \
+ UnmapWin.c \
+ utlist.h \
+ VisUtil.c \
+ WarpPtr.c \
+ Window.c \
+ WinEvent.c \
+ Withdraw.c \
+ WMGeom.c \
+ WMProps.c \
+ WrBitF.c \
+ Xatomtype.h \
+ Xintatom.h \
+ Xintconn.h \
+ XlibAsync.c \
+ XlibInt.c \
+ Xprivate.h \
+ XomGeneric.h \
+ Xresinternal.h \
+ Xrm.c \
+ XrmI.h
+
+#
+# ========================= Extra stuff ============================
+#
+
+if OS2
+libX11_la_SOURCES+=os2Stubs.c
+endif OS2
+
+if UDC
+libX11_la_SOURCES+=udcInf.c
+endif
+
+if THRSTUBS
+libX11_la_SOURCES+=UIThrStubs.c
+endif
+
+x11datadir = @X11_DATADIR@
+x11data_DATA = XKeysymDB XErrorDB
+
+EXTRA_DIST = \
+ $(x11data_DATA) \
+ os2Stubs.c \
+ udcInf.c \
+ UIThrStubs.c
+
+if XCB
+libX11_la_SOURCES += \
+ xcb_disp.c \
+ xcb_io.c \
+ Xxcbint.h
+
+lib_LTLIBRARIES += libX11-xcb.la
+libX11_xcb_la_SOURCES = x11_xcb.c Xxcbint.h
+libX11_xcb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
+libX11_xcb_la_LIBADD = libX11.la
+else
+libX11_la_SOURCES += \
+ ConnDis.c \
+ x11_trans.c
+endif
+
+#
+# Figure out which sub-libraries to link into Xlib
+#
+
+if XLOCALE
+USE_I18N_LIBS = $(I18N_LIBS)
+endif
+
+if XCMS
+USE_XCMS_LIBS = $(XCMS_LIBS)
+endif
+
+if XKB
+USE_XKB_LIBS = $(XKB_LIBS)
+endif
+
+libX11_la_LDFLAGS = -version-number 6:3:0 -no-undefined
+
+libX11_la_LIBADD = \
+ $(USE_I18N_LIBS) \
+ $(USE_XCMS_LIBS) \
+ $(USE_XKB_LIBS) \
+ $(X11_LIBS) \
+ $(XDMCP_LIBS)
+
+preprocess: $(patsubst %.c,%.ii,$(libX11_la_SOURCES))
+.c.ii:
+ $(COMPILE) -E -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
+
+if LINT
+# Check source code with tools like lint & sparse
+
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
+
+lint: $(BUILT_SOURCES)
+ for f in $(libX11_la_SOURCES) ; do \
+ $(LINT) $(ALL_LINT_FLAGS) $$f ; \
+ done
+ @for subdir in $(SUBDIRS) ; do \
+ echo "Making $@ in src/$$subdir"; \
+ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) lint) ; \
+ done
+endif LINT
+
+if MAKE_LINT_LIB
+lintlibdir = $(libdir)
+
+lintlib_DATA = $(LINTLIB)
+
+lintlib_src = $(libX11_la_SOURCES) xcms/*.c xkb/*.c
+
+CLEANFILES += $(lintlib_DATA)
+
+$(LINTLIB): $(libX11_la_SOURCES)
+ $(AM_V_GEN)$(LINT) -y -oX11 -x $(ALL_LINT_FLAGS) $(lintlib_src)
+endif MAKE_LINT_LIB
+
+#
+# Building ks_tables.h requires the makekeys utility
+#
+
+KEYSYMDEF=@KEYSYMDEF@
+
+ks_tables.h: $(KEYSYMDEF) $(top_builddir)/src/util/makekeys$(EXEEXT)
+ $(top_builddir)/src/util/makekeys < $(KEYSYMDEF) > ks_tables_h
+ mv ks_tables_h $@
+
+$(top_builddir)/src/util/makekeys$(EXEEXT): force
+ cd util && $(MAKE)
+
+force:
diff --git a/libX11/src/Makefile.in b/libX11/src/Makefile.in
deleted file mode 100644
index 0c153e1c5..000000000
--- a/libX11/src/Makefile.in
+++ /dev/null
@@ -1,1372 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-
-#
-# ========================= Extra stuff ============================
-#
-@OS2_TRUE@am__append_1 = os2Stubs.c
-@UDC_TRUE@am__append_2 = udcInf.c
-@THRSTUBS_TRUE@am__append_3 = UIThrStubs.c
-@XCB_TRUE@am__append_4 = \
-@XCB_TRUE@ xcb_disp.c \
-@XCB_TRUE@ xcb_io.c \
-@XCB_TRUE@ Xxcbint.h
-
-@XCB_TRUE@am__append_5 = libX11-xcb.la
-@XCB_FALSE@am__append_6 = \
-@XCB_FALSE@ ConnDis.c \
-@XCB_FALSE@ x11_trans.c
-
-@MAKE_LINT_LIB_TRUE@am__append_7 = $(lintlib_DATA)
-subdir = src
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h $(top_builddir)/include/X11/XlibConf.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(lintlibdir)" \
- "$(DESTDIR)$(x11datadir)"
-LTLIBRARIES = $(lib_LTLIBRARIES)
-@XCB_TRUE@libX11_xcb_la_DEPENDENCIES = libX11.la
-am__libX11_xcb_la_SOURCES_DIST = x11_xcb.c Xxcbint.h
-@XCB_TRUE@am_libX11_xcb_la_OBJECTS = x11_xcb.lo
-libX11_xcb_la_OBJECTS = $(am_libX11_xcb_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-libX11_xcb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(libX11_xcb_la_LDFLAGS) $(LDFLAGS) -o $@
-@XCB_TRUE@am_libX11_xcb_la_rpath = -rpath $(libdir)
-am__DEPENDENCIES_1 =
-libX11_la_DEPENDENCIES = $(USE_I18N_LIBS) $(USE_XCMS_LIBS) \
- $(USE_XKB_LIBS) $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-am__libX11_la_SOURCES_DIST = AllCells.c AllowEv.c AllPlanes.c \
- AutoRep.c Backgnd.c BdrWidth.c Bell.c Border.c ChAccCon.c \
- ChActPGb.c ChClMode.c ChCmap.c ChGC.c ChKeyCon.c ChkIfEv.c \
- ChkMaskEv.c ChkTypEv.c ChkTypWEv.c ChkWinEv.c ChPntCon.c \
- ChProp.c ChSaveSet.c ChWAttrs.c ChWindow.c CirWin.c CirWinDn.c \
- CirWinUp.c ClDisplay.c ClearArea.c Clear.c Cmap.h ConfWind.c \
- Context.c ConvSel.c CopyArea.c CopyCmap.c CopyGC.c CopyPlane.c \
- CrBFData.c CrCmap.c CrCursor.c CrGC.c CrGlCur.c Cr.h \
- CrPFBData.c CrPixmap.c CrWindow.c Cursor.c DefCursor.c \
- DelProp.c Depths.c DestSubs.c DestWind.c DisName.c DrArc.c \
- DrArcs.c DrLine.c DrLines.c DrPoint.c DrPoints.c DrRect.c \
- DrRects.c DrSegs.c ErrDes.c ErrHndlr.c evtomask.c EvToWire.c \
- FetchName.c FillArc.c FillArcs.c FillPoly.c FillRct.c \
- FillRcts.c FilterEv.c Flush.c Font.c FontInfo.c FontNames.c \
- FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeEventData.c \
- FreeGC.c FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c \
- GetAtomNm.c GetColor.c GetDflt.c GetEventData.c GetFPath.c \
- GetFProp.c GetGCVals.c GetGeom.c GetHColor.c GetHints.c \
- GetIFocus.c GetImage.c GetKCnt.c GetMoEv.c GetNrmHint.c \
- GetPCnt.c GetPntMap.c GetProp.c GetRGBCMap.c GetSOwner.c \
- GetSSaver.c GetStCmap.c GetTxtProp.c GetWAttrs.c GetWMCMapW.c \
- GetWMProto.c globals.c GrButton.c GrKeybd.c GrKey.c \
- GrPointer.c GrServer.c Host.c Iconify.c IfEvent.c imConv.c \
- ImText16.c ImText.c ImUtil.c InitExt.c InsCmap.c IntAtom.c \
- KeyBind.c Key.h KeysymStr.c KillCl.c LiHosts.c LiICmaps.c \
- LiProps.c ListExt.c LoadFont.c LockDis.c locking.c locking.h \
- LookupCol.c LowerWin.c Macros.c MapRaised.c MapSubs.c \
- MapWindow.c MaskEvent.c Misc.c ModMap.c MoveWin.c NextEvent.c \
- OCWrap.c OMWrap.c OpenDis.c ParseCmd.c ParseCol.c ParseGeom.c \
- PeekEvent.c PeekIfEv.c Pending.c PixFormats.c PmapBgnd.c \
- PmapBord.c poly.h PolyReg.c PolyTxt16.c PolyTxt.c PropAlloc.c \
- PutBEvent.c PutImage.c Quarks.c QuBest.c QuColor.c QuColors.c \
- QuCurShp.c QuExt.c QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c \
- QuTextExt.c QuTileShp.c QuTree.c RaiseWin.c RdBitF.c \
- RecolorC.c ReconfWin.c ReconfWM.c Region.c RegstFlt.c \
- RepWindow.c RestackWs.c RotProp.c ScrResStr.c SelInput.c \
- SendEvent.c SetBack.c SetClMask.c SetClOrig.c SetCRects.c \
- SetDashes.c SetFont.c SetFore.c SetFPath.c SetFunc.c \
- SetHints.c SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c \
- SetPMask.c SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c \
- SetState.c SetStCmap.c SetStip.c SetTile.c SetTSOrig.c \
- SetTxtProp.c SetWMCMapW.c SetWMProto.c StBytes.c StColor.c \
- StColors.c StName.c StNColor.c StrKeysym.c StrToText.c Sync.c \
- Synchro.c Text16.c Text.c TextExt16.c TextExt.c TextToStr.c \
- TrCoords.c UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c \
- UngrabPtr.c UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c \
- UnmapWin.c utlist.h VisUtil.c WarpPtr.c Window.c WinEvent.c \
- Withdraw.c WMGeom.c WMProps.c WrBitF.c Xatomtype.h Xintatom.h \
- Xintconn.h XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h \
- Xresinternal.h Xrm.c XrmI.h os2Stubs.c udcInf.c UIThrStubs.c \
- xcb_disp.c xcb_io.c Xxcbint.h ConnDis.c x11_trans.c
-@OS2_TRUE@am__objects_1 = os2Stubs.lo
-@UDC_TRUE@am__objects_2 = udcInf.lo
-@THRSTUBS_TRUE@am__objects_3 = UIThrStubs.lo
-@XCB_TRUE@am__objects_4 = xcb_disp.lo xcb_io.lo
-@XCB_FALSE@am__objects_5 = ConnDis.lo x11_trans.lo
-am_libX11_la_OBJECTS = AllCells.lo AllowEv.lo AllPlanes.lo AutoRep.lo \
- Backgnd.lo BdrWidth.lo Bell.lo Border.lo ChAccCon.lo \
- ChActPGb.lo ChClMode.lo ChCmap.lo ChGC.lo ChKeyCon.lo \
- ChkIfEv.lo ChkMaskEv.lo ChkTypEv.lo ChkTypWEv.lo ChkWinEv.lo \
- ChPntCon.lo ChProp.lo ChSaveSet.lo ChWAttrs.lo ChWindow.lo \
- CirWin.lo CirWinDn.lo CirWinUp.lo ClDisplay.lo ClearArea.lo \
- Clear.lo ConfWind.lo Context.lo ConvSel.lo CopyArea.lo \
- CopyCmap.lo CopyGC.lo CopyPlane.lo CrBFData.lo CrCmap.lo \
- CrCursor.lo CrGC.lo CrGlCur.lo CrPFBData.lo CrPixmap.lo \
- CrWindow.lo Cursor.lo DefCursor.lo DelProp.lo Depths.lo \
- DestSubs.lo DestWind.lo DisName.lo DrArc.lo DrArcs.lo \
- DrLine.lo DrLines.lo DrPoint.lo DrPoints.lo DrRect.lo \
- DrRects.lo DrSegs.lo ErrDes.lo ErrHndlr.lo evtomask.lo \
- EvToWire.lo FetchName.lo FillArc.lo FillArcs.lo FillPoly.lo \
- FillRct.lo FillRcts.lo FilterEv.lo Flush.lo Font.lo \
- FontInfo.lo FontNames.lo FreeCmap.lo FreeCols.lo FreeCurs.lo \
- FreeEData.lo FreeEventData.lo FreeGC.lo FreePix.lo FSSaver.lo \
- FSWrap.lo GCMisc.lo Geom.lo GetAtomNm.lo GetColor.lo \
- GetDflt.lo GetEventData.lo GetFPath.lo GetFProp.lo \
- GetGCVals.lo GetGeom.lo GetHColor.lo GetHints.lo GetIFocus.lo \
- GetImage.lo GetKCnt.lo GetMoEv.lo GetNrmHint.lo GetPCnt.lo \
- GetPntMap.lo GetProp.lo GetRGBCMap.lo GetSOwner.lo \
- GetSSaver.lo GetStCmap.lo GetTxtProp.lo GetWAttrs.lo \
- GetWMCMapW.lo GetWMProto.lo globals.lo GrButton.lo GrKeybd.lo \
- GrKey.lo GrPointer.lo GrServer.lo Host.lo Iconify.lo \
- IfEvent.lo imConv.lo ImText16.lo ImText.lo ImUtil.lo \
- InitExt.lo InsCmap.lo IntAtom.lo KeyBind.lo KeysymStr.lo \
- KillCl.lo LiHosts.lo LiICmaps.lo LiProps.lo ListExt.lo \
- LoadFont.lo LockDis.lo locking.lo LookupCol.lo LowerWin.lo \
- Macros.lo MapRaised.lo MapSubs.lo MapWindow.lo MaskEvent.lo \
- Misc.lo ModMap.lo MoveWin.lo NextEvent.lo OCWrap.lo OMWrap.lo \
- OpenDis.lo ParseCmd.lo ParseCol.lo ParseGeom.lo PeekEvent.lo \
- PeekIfEv.lo Pending.lo PixFormats.lo PmapBgnd.lo PmapBord.lo \
- PolyReg.lo PolyTxt16.lo PolyTxt.lo PropAlloc.lo PutBEvent.lo \
- PutImage.lo Quarks.lo QuBest.lo QuColor.lo QuColors.lo \
- QuCurShp.lo QuExt.lo QuKeybd.lo QuPntr.lo QuStipShp.lo \
- QuTextE16.lo QuTextExt.lo QuTileShp.lo QuTree.lo RaiseWin.lo \
- RdBitF.lo RecolorC.lo ReconfWin.lo ReconfWM.lo Region.lo \
- RegstFlt.lo RepWindow.lo RestackWs.lo RotProp.lo ScrResStr.lo \
- SelInput.lo SendEvent.lo SetBack.lo SetClMask.lo SetClOrig.lo \
- SetCRects.lo SetDashes.lo SetFont.lo SetFore.lo SetFPath.lo \
- SetFunc.lo SetHints.lo SetIFocus.lo SetLocale.lo SetLStyle.lo \
- SetNrmHint.lo SetPMask.lo SetPntMap.lo SetRGBCMap.lo \
- SetSOwner.lo SetSSaver.lo SetState.lo SetStCmap.lo SetStip.lo \
- SetTile.lo SetTSOrig.lo SetTxtProp.lo SetWMCMapW.lo \
- SetWMProto.lo StBytes.lo StColor.lo StColors.lo StName.lo \
- StNColor.lo StrKeysym.lo StrToText.lo Sync.lo Synchro.lo \
- Text16.lo Text.lo TextExt16.lo TextExt.lo TextToStr.lo \
- TrCoords.lo UndefCurs.lo UngrabBut.lo UngrabKbd.lo \
- UngrabKey.lo UngrabPtr.lo UngrabSvr.lo UninsCmap.lo \
- UnldFont.lo UnmapSubs.lo UnmapWin.lo VisUtil.lo WarpPtr.lo \
- Window.lo WinEvent.lo Withdraw.lo WMGeom.lo WMProps.lo \
- WrBitF.lo XlibAsync.lo XlibInt.lo Xrm.lo $(am__objects_1) \
- $(am__objects_2) $(am__objects_3) $(am__objects_4) \
- $(am__objects_5)
-libX11_la_OBJECTS = $(am_libX11_la_OBJECTS)
-libX11_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(libX11_la_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/X11
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libX11_xcb_la_SOURCES) $(libX11_la_SOURCES)
-DIST_SOURCES = $(am__libX11_xcb_la_SOURCES_DIST) \
- $(am__libX11_la_SOURCES_DIST)
-RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
- html-recursive info-recursive install-data-recursive \
- install-dvi-recursive install-exec-recursive \
- install-html-recursive install-info-recursive \
- install-pdf-recursive install-ps-recursive install-recursive \
- installcheck-recursive installdirs-recursive pdf-recursive \
- ps-recursive uninstall-recursive
-DATA = $(lintlib_DATA) $(x11data_DATA)
-RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
- distclean-recursive maintainer-clean-recursive
-AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
- $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
- distdir
-ETAGS = etags
-CTAGS = ctags
-DIST_SUBDIRS = util xcms xlibi18n xkb
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-am__relativize = \
- dir0=`pwd`; \
- sed_first='s,^\([^/]*\)/.*$$,\1,'; \
- sed_rest='s,^[^/]*/*,,'; \
- sed_last='s,^.*/\([^/]*\)$$,\1,'; \
- sed_butlast='s,/*[^/]*$$,,'; \
- while test -n "$$dir1"; do \
- first=`echo "$$dir1" | sed -e "$$sed_first"`; \
- if test "$$first" != "."; then \
- if test "$$first" = ".."; then \
- dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
- dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
- else \
- first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
- if test "$$first2" = "$$first"; then \
- dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
- else \
- dir2="../$$dir2"; \
- fi; \
- dir0="$$dir0"/"$$first"; \
- fi; \
- fi; \
- dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
- done; \
- reldir="$$dir2"
-ACLOCAL = @ACLOCAL@
-ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
-ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APP_MAN_DIR = @APP_MAN_DIR@
-APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BIGFONT_CFLAGS = @BIGFONT_CFLAGS@
-BIGFONT_LIBS = @BIGFONT_LIBS@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CHANGELOG_CMD = @CHANGELOG_CMD@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CWARNFLAGS = @CWARNFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DOLT_BASH = @DOLT_BASH@
-DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
-DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FILE_MAN_DIR = @FILE_MAN_DIR@
-FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
-GREP = @GREP@
-GROFF = @GROFF@
-I18N_MODULE_LIBS = @I18N_MODULE_LIBS@
-INSTALL = @INSTALL@
-INSTALL_CMD = @INSTALL_CMD@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-
-#
-# Building ks_tables.h requires the makekeys utility
-#
-KEYSYMDEF = @KEYSYMDEF@
-LAUNCHD = @LAUNCHD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIB_MAN_DIR = @LIB_MAN_DIR@
-LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINT = @LINT@
-LINTLIB = @LINTLIB@
-LINT_FLAGS = @LINT_FLAGS@
-LN_S = @LN_S@
-LTCOMPILE = @LTCOMPILE@
-LTCXXCOMPILE = @LTCXXCOMPILE@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@
-MISC_MAN_DIR = @MISC_MAN_DIR@
-MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
-MKDIR_P = @MKDIR_P@
-NMEDIT = @NMEDIT@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PKG_CONFIG = @PKG_CONFIG@
-PS2PDF = @PS2PDF@
-RANLIB = @RANLIB@
-RAWCPP = @RAWCPP@
-RAWCPPFLAGS = @RAWCPPFLAGS@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WCHAR32 = @WCHAR32@
-X11_CFLAGS = @X11_CFLAGS@
-X11_DATADIR = @X11_DATADIR@
-X11_EXTRA_DEPS = @X11_EXTRA_DEPS@
-X11_LIBDIR = @X11_LIBDIR@
-X11_LIBS = @X11_LIBS@
-X11_LOCALEDATADIR = @X11_LOCALEDATADIR@
-X11_LOCALEDIR = @X11_LOCALEDIR@
-X11_LOCALELIBDIR = @X11_LOCALELIBDIR@
-XDMCP_CFLAGS = @XDMCP_CFLAGS@
-XDMCP_LIBS = @XDMCP_LIBS@
-XERRORDB = @XERRORDB@
-XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@
-XKEYSYMDB = @XKEYSYMDB@
-XLOCALEDATADIR = @XLOCALEDATADIR@
-XLOCALEDIR = @XLOCALEDIR@
-XLOCALELIBDIR = @XLOCALELIBDIR@
-XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@
-XTHREADLIB = @XTHREADLIB@
-XTHREAD_CFLAGS = @XTHREAD_CFLAGS@
-XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-@XKB_TRUE@XKB_SUBDIRS = xkb
-SUBDIRS = util xcms xlibi18n $(XKB_SUBDIRS)
-lib_LTLIBRARIES = libX11.la $(am__append_5)
-BUILT_SOURCES = ks_tables.h
-CLEANFILES = ks_tables.h ks_tables_h $(am__append_7)
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -D_BSD_SOURCE -DX11_t -DTRANS_CLIENT
-
-AM_CFLAGS = \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-
-#
-# =============================== I18N =============================
-#
-I18N_LIBS = \
- xlibi18n/libi18n.la
-
-
-#
-# =============================== XCMS =============================
-#
-XCMS_LIBS = \
- xcms/libxcms.la
-
-
-#
-# =============================== XKB ==============================
-#
-XKB_LIBS = \
- xkb/libxkb.la
-
-
-#
-# =============================== XLIB =============================
-#
-libX11_la_SOURCES = AllCells.c AllowEv.c AllPlanes.c AutoRep.c \
- Backgnd.c BdrWidth.c Bell.c Border.c ChAccCon.c ChActPGb.c \
- ChClMode.c ChCmap.c ChGC.c ChKeyCon.c ChkIfEv.c ChkMaskEv.c \
- ChkTypEv.c ChkTypWEv.c ChkWinEv.c ChPntCon.c ChProp.c \
- ChSaveSet.c ChWAttrs.c ChWindow.c CirWin.c CirWinDn.c \
- CirWinUp.c ClDisplay.c ClearArea.c Clear.c Cmap.h ConfWind.c \
- Context.c ConvSel.c CopyArea.c CopyCmap.c CopyGC.c CopyPlane.c \
- CrBFData.c CrCmap.c CrCursor.c CrGC.c CrGlCur.c Cr.h \
- CrPFBData.c CrPixmap.c CrWindow.c Cursor.c DefCursor.c \
- DelProp.c Depths.c DestSubs.c DestWind.c DisName.c DrArc.c \
- DrArcs.c DrLine.c DrLines.c DrPoint.c DrPoints.c DrRect.c \
- DrRects.c DrSegs.c ErrDes.c ErrHndlr.c evtomask.c EvToWire.c \
- FetchName.c FillArc.c FillArcs.c FillPoly.c FillRct.c \
- FillRcts.c FilterEv.c Flush.c Font.c FontInfo.c FontNames.c \
- FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeEventData.c \
- FreeGC.c FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c \
- GetAtomNm.c GetColor.c GetDflt.c GetEventData.c GetFPath.c \
- GetFProp.c GetGCVals.c GetGeom.c GetHColor.c GetHints.c \
- GetIFocus.c GetImage.c GetKCnt.c GetMoEv.c GetNrmHint.c \
- GetPCnt.c GetPntMap.c GetProp.c GetRGBCMap.c GetSOwner.c \
- GetSSaver.c GetStCmap.c GetTxtProp.c GetWAttrs.c GetWMCMapW.c \
- GetWMProto.c globals.c GrButton.c GrKeybd.c GrKey.c \
- GrPointer.c GrServer.c Host.c Iconify.c IfEvent.c imConv.c \
- ImText16.c ImText.c ImUtil.c InitExt.c InsCmap.c IntAtom.c \
- KeyBind.c Key.h KeysymStr.c KillCl.c LiHosts.c LiICmaps.c \
- LiProps.c ListExt.c LoadFont.c LockDis.c locking.c locking.h \
- LookupCol.c LowerWin.c Macros.c MapRaised.c MapSubs.c \
- MapWindow.c MaskEvent.c Misc.c ModMap.c MoveWin.c NextEvent.c \
- OCWrap.c OMWrap.c OpenDis.c ParseCmd.c ParseCol.c ParseGeom.c \
- PeekEvent.c PeekIfEv.c Pending.c PixFormats.c PmapBgnd.c \
- PmapBord.c poly.h PolyReg.c PolyTxt16.c PolyTxt.c PropAlloc.c \
- PutBEvent.c PutImage.c Quarks.c QuBest.c QuColor.c QuColors.c \
- QuCurShp.c QuExt.c QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c \
- QuTextExt.c QuTileShp.c QuTree.c RaiseWin.c RdBitF.c \
- RecolorC.c ReconfWin.c ReconfWM.c Region.c RegstFlt.c \
- RepWindow.c RestackWs.c RotProp.c ScrResStr.c SelInput.c \
- SendEvent.c SetBack.c SetClMask.c SetClOrig.c SetCRects.c \
- SetDashes.c SetFont.c SetFore.c SetFPath.c SetFunc.c \
- SetHints.c SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c \
- SetPMask.c SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c \
- SetState.c SetStCmap.c SetStip.c SetTile.c SetTSOrig.c \
- SetTxtProp.c SetWMCMapW.c SetWMProto.c StBytes.c StColor.c \
- StColors.c StName.c StNColor.c StrKeysym.c StrToText.c Sync.c \
- Synchro.c Text16.c Text.c TextExt16.c TextExt.c TextToStr.c \
- TrCoords.c UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c \
- UngrabPtr.c UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c \
- UnmapWin.c utlist.h VisUtil.c WarpPtr.c Window.c WinEvent.c \
- Withdraw.c WMGeom.c WMProps.c WrBitF.c Xatomtype.h Xintatom.h \
- Xintconn.h XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h \
- Xresinternal.h Xrm.c XrmI.h $(am__append_1) $(am__append_2) \
- $(am__append_3) $(am__append_4) $(am__append_6)
-x11datadir = @X11_DATADIR@
-x11data_DATA = XKeysymDB XErrorDB
-EXTRA_DIST = \
- $(x11data_DATA) \
- os2Stubs.c \
- udcInf.c \
- UIThrStubs.c
-
-@XCB_TRUE@libX11_xcb_la_SOURCES = x11_xcb.c Xxcbint.h
-@XCB_TRUE@libX11_xcb_la_LDFLAGS = -version-info 1:0:0 -no-undefined
-@XCB_TRUE@libX11_xcb_la_LIBADD = libX11.la
-
-#
-# Figure out which sub-libraries to link into Xlib
-#
-@XLOCALE_TRUE@USE_I18N_LIBS = $(I18N_LIBS)
-@XCMS_TRUE@USE_XCMS_LIBS = $(XCMS_LIBS)
-@XKB_TRUE@USE_XKB_LIBS = $(XKB_LIBS)
-libX11_la_LDFLAGS = -version-number 6:3:0 -no-undefined
-libX11_la_LIBADD = \
- $(USE_I18N_LIBS) \
- $(USE_XCMS_LIBS) \
- $(USE_XKB_LIBS) \
- $(X11_LIBS) \
- $(XDMCP_LIBS)
-
-
-# Check source code with tools like lint & sparse
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-@MAKE_LINT_LIB_TRUE@lintlibdir = $(libdir)
-@MAKE_LINT_LIB_TRUE@lintlib_DATA = $(LINTLIB)
-@MAKE_LINT_LIB_TRUE@lintlib_src = $(libX11_la_SOURCES) xcms/*.c xkb/*.c
-all: $(BUILT_SOURCES) config.h
- $(MAKE) $(AM_MAKEFLAGS) all-recursive
-
-.SUFFIXES:
-.SUFFIXES: .c .ii .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-config.h: stamp-h1
- @if test ! -f $@; then \
- rm -f stamp-h1; \
- $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
- else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
- @rm -f stamp-h1
- cd $(top_builddir) && $(SHELL) ./config.status src/config.h
-$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
- rm -f stamp-h1
- touch $@
-
-distclean-hdr:
- -rm -f config.h stamp-h1
-install-libLTLIBRARIES: $(lib_LTLIBRARIES)
- @$(NORMAL_INSTALL)
- test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
- list2=; for p in $$list; do \
- if test -f $$p; then \
- list2="$$list2 $$p"; \
- else :; fi; \
- done; \
- test -z "$$list2" || { \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
- }
-
-uninstall-libLTLIBRARIES:
- @$(NORMAL_UNINSTALL)
- @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
- for p in $$list; do \
- $(am__strip_dir) \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
- done
-
-clean-libLTLIBRARIES:
- -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
- @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-libX11-xcb.la: $(libX11_xcb_la_OBJECTS) $(libX11_xcb_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libX11_xcb_la_LINK) $(am_libX11_xcb_la_rpath) $(libX11_xcb_la_OBJECTS) $(libX11_xcb_la_LIBADD) $(LIBS)
-libX11.la: $(libX11_la_OBJECTS) $(libX11_la_DEPENDENCIES)
- $(AM_V_CCLD)$(libX11_la_LINK) -rpath $(libdir) $(libX11_la_OBJECTS) $(libX11_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllCells.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllPlanes.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AllowEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AutoRep.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Backgnd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BdrWidth.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bell.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Border.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChAccCon.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChActPGb.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChClMode.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChGC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChKeyCon.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChPntCon.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChSaveSet.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChWAttrs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChWindow.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChkIfEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChkMaskEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChkTypEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChkTypWEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChkWinEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CirWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CirWinDn.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CirWinUp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClDisplay.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Clear.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClearArea.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfWind.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConnDis.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Context.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConvSel.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyArea.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyGC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CopyPlane.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrBFData.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrCursor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrGC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrGlCur.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrPFBData.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrPixmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CrWindow.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cursor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DefCursor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DelProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Depths.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DestSubs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DestWind.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisName.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrArc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrArcs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrLine.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrLines.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrPoint.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrPoints.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrRect.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrRects.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DrSegs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ErrDes.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ErrHndlr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EvToWire.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSSaver.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FSWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FetchName.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillArc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillArcs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillPoly.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillRct.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FillRcts.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Flush.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Font.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FontInfo.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FontNames.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeCols.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeCurs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeEData.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeEventData.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeGC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreePix.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GCMisc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Geom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetAtomNm.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetColor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetDflt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetEventData.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetFPath.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetFProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetGCVals.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetGeom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetHColor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetHints.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetIFocus.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetImage.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetKCnt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetMoEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetNrmHint.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetPCnt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetPntMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetRGBCMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetSOwner.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetSSaver.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetStCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetTxtProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetWAttrs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetWMCMapW.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetWMProto.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrButton.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrKey.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrKeybd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrPointer.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GrServer.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Host.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Iconify.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IfEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ImText.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ImText16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ImUtil.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InitExt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InsCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IntAtom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KeyBind.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KeysymStr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KillCl.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LiHosts.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LiICmaps.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LiProps.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ListExt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LoadFont.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LockDis.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LookupCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LowerWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Macros.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MapRaised.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MapSubs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MapWindow.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MaskEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Misc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ModMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MoveWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NextEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OCWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OMWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OpenDis.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ParseCmd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ParseCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ParseGeom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeekEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PeekIfEv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pending.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PixFormats.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PmapBgnd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PmapBord.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PolyReg.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PolyTxt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PolyTxt16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PropAlloc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PutBEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PutImage.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuBest.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuColor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuColors.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuCurShp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuExt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuKeybd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuPntr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuStipShp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuTextE16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuTextExt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuTileShp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuTree.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Quarks.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RaiseWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RdBitF.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RecolorC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReconfWM.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ReconfWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Region.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RegstFlt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RepWindow.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RestackWs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RotProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScrResStr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelInput.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SendEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetBack.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetCRects.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetClMask.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetClOrig.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetDashes.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetFPath.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetFont.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetFore.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetFunc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetHints.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetIFocus.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetLStyle.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetLocale.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetNrmHint.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetPMask.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetPntMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetRGBCMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetSOwner.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetSSaver.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetStCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetState.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetStip.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetTSOrig.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetTile.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetTxtProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetWMCMapW.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetWMProto.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StBytes.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StColor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StColors.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StNColor.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StName.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StrKeysym.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StrToText.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sync.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Synchro.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Text.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Text16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextExt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextExt16.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextToStr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrCoords.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UIThrStubs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UndefCurs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UngrabBut.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UngrabKbd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UngrabKey.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UngrabPtr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UngrabSvr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UninsCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnldFont.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnmapSubs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UnmapWin.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VisUtil.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WMGeom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WMProps.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WarpPtr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WinEvent.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Window.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Withdraw.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WrBitF.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XlibAsync.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XlibInt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Xrm.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evtomask.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/globals.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imConv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locking.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os2Stubs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udcInf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11_trans.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x11_xcb.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcb_disp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xcb_io.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-install-lintlibDATA: $(lintlib_DATA)
- @$(NORMAL_INSTALL)
- test -z "$(lintlibdir)" || $(MKDIR_P) "$(DESTDIR)$(lintlibdir)"
- @list='$(lintlib_DATA)'; test -n "$(lintlibdir)" || list=; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(lintlibdir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(lintlibdir)" || exit $$?; \
- done
-
-uninstall-lintlibDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(lintlib_DATA)'; test -n "$(lintlibdir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(lintlibdir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(lintlibdir)" && rm -f $$files
-install-x11dataDATA: $(x11data_DATA)
- @$(NORMAL_INSTALL)
- test -z "$(x11datadir)" || $(MKDIR_P) "$(DESTDIR)$(x11datadir)"
- @list='$(x11data_DATA)'; test -n "$(x11datadir)" || list=; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(x11datadir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(x11datadir)" || exit $$?; \
- done
-
-uninstall-x11dataDATA:
- @$(NORMAL_UNINSTALL)
- @list='$(x11data_DATA)'; test -n "$(x11datadir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(x11datadir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(x11datadir)" && rm -f $$files
-
-# This directory's subdirectories are mostly independent; you can cd
-# into them and run `make' without going through this Makefile.
-# To change the values of `make' variables: instead of editing Makefiles,
-# (1) if the variable is set in `config.status', edit `config.status'
-# (which will cause the Makefiles to be regenerated when you run `make');
-# (2) otherwise, pass the desired values on the `make' command line.
-$(RECURSIVE_TARGETS):
- @fail= failcom='exit 1'; \
- for f in x $$MAKEFLAGS; do \
- case $$f in \
- *=* | --[!k]*);; \
- *k*) failcom='fail=yes';; \
- esac; \
- done; \
- dot_seen=no; \
- target=`echo $@ | sed s/-recursive//`; \
- list='$(SUBDIRS)'; for subdir in $$list; do \
- echo "Making $$target in $$subdir"; \
- if test "$$subdir" = "."; then \
- dot_seen=yes; \
- local_target="$$target-am"; \
- else \
- local_target="$$target"; \
- fi; \
- ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
- || eval $$failcom; \
- done; \
- if test "$$dot_seen" = "no"; then \
- $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
- fi; test -z "$$fail"
-
-$(RECURSIVE_CLEAN_TARGETS):
- @fail= failcom='exit 1'; \
- for f in x $$MAKEFLAGS; do \
- case $$f in \
- *=* | --[!k]*);; \
- *k*) failcom='fail=yes';; \
- esac; \
- done; \
- dot_seen=no; \
- case "$@" in \
- distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
- *) list='$(SUBDIRS)' ;; \
- esac; \
- rev=''; for subdir in $$list; do \
- if test "$$subdir" = "."; then :; else \
- rev="$$subdir $$rev"; \
- fi; \
- done; \
- rev="$$rev ."; \
- target=`echo $@ | sed s/-recursive//`; \
- for subdir in $$rev; do \
- echo "Making $$target in $$subdir"; \
- if test "$$subdir" = "."; then \
- local_target="$$target-am"; \
- else \
- local_target="$$target"; \
- fi; \
- ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
- || eval $$failcom; \
- done && test -z "$$fail"
-tags-recursive:
- list='$(SUBDIRS)'; for subdir in $$list; do \
- test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
- done
-ctags-recursive:
- list='$(SUBDIRS)'; for subdir in $$list; do \
- test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
- done
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
- include_option=--etags-include; \
- empty_fix=.; \
- else \
- include_option=--include; \
- empty_fix=; \
- fi; \
- list='$(SUBDIRS)'; for subdir in $$list; do \
- if test "$$subdir" = .; then :; else \
- test ! -f $$subdir/TAGS || \
- set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
- fi; \
- done; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
- @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
- if test "$$subdir" = .; then :; else \
- test -d "$(distdir)/$$subdir" \
- || $(MKDIR_P) "$(distdir)/$$subdir" \
- || exit 1; \
- fi; \
- done
- @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
- if test "$$subdir" = .; then :; else \
- dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
- $(am__relativize); \
- new_distdir=$$reldir; \
- dir1=$$subdir; dir2="$(top_distdir)"; \
- $(am__relativize); \
- new_top_distdir=$$reldir; \
- echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
- echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
- ($(am__cd) $$subdir && \
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$$new_top_distdir" \
- distdir="$$new_distdir" \
- am__remove_distdir=: \
- am__skip_length_check=: \
- am__skip_mode_fix=: \
- distdir) \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: $(BUILT_SOURCES)
- $(MAKE) $(AM_MAKEFLAGS) check-recursive
-all-am: Makefile $(LTLIBRARIES) $(DATA) config.h
-installdirs: installdirs-recursive
-installdirs-am:
- for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(lintlibdir)" "$(DESTDIR)$(x11datadir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
- done
-install: $(BUILT_SOURCES)
- $(MAKE) $(AM_MAKEFLAGS) install-recursive
-install-exec: install-exec-recursive
-install-data: install-data-recursive
-uninstall: uninstall-recursive
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-recursive
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
- -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
- -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
-clean: clean-recursive
-
-clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
- mostlyclean-am
-
-distclean: distclean-recursive
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-hdr distclean-tags
-
-dvi: dvi-recursive
-
-dvi-am:
-
-html: html-recursive
-
-html-am:
-
-info: info-recursive
-
-info-am:
-
-install-data-am: install-lintlibDATA install-x11dataDATA
-
-install-dvi: install-dvi-recursive
-
-install-dvi-am:
-
-install-exec-am: install-libLTLIBRARIES
-
-install-html: install-html-recursive
-
-install-html-am:
-
-install-info: install-info-recursive
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-recursive
-
-install-pdf-am:
-
-install-ps: install-ps-recursive
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-recursive
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-recursive
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-recursive
-
-pdf-am:
-
-ps: ps-recursive
-
-ps-am:
-
-uninstall-am: uninstall-libLTLIBRARIES uninstall-lintlibDATA \
- uninstall-x11dataDATA
-
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
- ctags-recursive install install-am install-strip \
- tags-recursive
-
-.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
- all all-am check check-am clean clean-generic \
- clean-libLTLIBRARIES clean-libtool ctags ctags-recursive \
- distclean distclean-compile distclean-generic distclean-hdr \
- distclean-libtool distclean-tags distdir dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-libLTLIBRARIES install-lintlibDATA \
- install-man install-pdf install-pdf-am install-ps \
- install-ps-am install-strip install-x11dataDATA installcheck \
- installcheck-am installdirs installdirs-am maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags tags-recursive uninstall uninstall-am \
- uninstall-libLTLIBRARIES uninstall-lintlibDATA \
- uninstall-x11dataDATA
-
-
-preprocess: $(patsubst %.c,%.ii,$(libX11_la_SOURCES))
-.c.ii:
- $(COMPILE) -E -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
-
-@LINT_TRUE@lint: $(BUILT_SOURCES)
-@LINT_TRUE@ for f in $(libX11_la_SOURCES) ; do \
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $$f ; \
-@LINT_TRUE@ done
-@LINT_TRUE@ @for subdir in $(SUBDIRS) ; do \
-@LINT_TRUE@ echo "Making $@ in src/$$subdir"; \
-@LINT_TRUE@ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) lint) ; \
-@LINT_TRUE@ done
-
-@MAKE_LINT_LIB_TRUE@$(LINTLIB): $(libX11_la_SOURCES)
-@MAKE_LINT_LIB_TRUE@ $(AM_V_GEN)$(LINT) -y -oX11 -x $(ALL_LINT_FLAGS) $(lintlib_src)
-
-ks_tables.h: $(KEYSYMDEF) $(top_builddir)/src/util/makekeys$(EXEEXT)
- $(top_builddir)/src/util/makekeys < $(KEYSYMDEF) > ks_tables_h
- mv ks_tables_h $@
-
-$(top_builddir)/src/util/makekeys$(EXEEXT): force
- cd util && $(MAKE)
-
-force:
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/libX11/src/OpenDis.c b/libX11/src/OpenDis.c
index 46e102685..16f72b30e 100644
--- a/libX11/src/OpenDis.c
+++ b/libX11/src/OpenDis.c
@@ -1,944 +1,964 @@
-/*
-
-Copyright 1985, 1986, 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.
-
-*/
-
-#define NEED_REPLIES
-#define NEED_EVENTS
-#ifdef HAVE_CONFIG_H
-#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>
-#include "Xintconn.h"
-
-#ifdef XKB
-#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;
-void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
-
-#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
-#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
-#else
-#define InitDisplayLock(dis) Success
-#define FreeDisplayLock(dis)
-#endif /* XTHREADS */
-
-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 */
-
-/*
- * Connects to a server, creates a Display object and returns a pointer to
- * the newly created Display back to the caller.
- */
-Display *
-XOpenDisplay (
- register _Xconst char *display)
-{
- register Display *dpy; /* New Display object being created. */
- register int i;
- int j, k; /* random iterator indexes */
-#if !USE_XCB
- char *display_name; /* pointer to display name */
- 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 */
- xConnSetupPrefix prefix; /* prefix information */
- int vendorlen; /* length of vendor string */
- union {
- xConnSetup *setup;
- char *failure;
- char *vendor;
- xPixmapFormat *sf;
- xWindowRoot *rp;
- xDepth *dp;
- xVisualType *vp;
- } u; /* proto data returned from server */
- long setuplength; /* number of bytes in setup message */
- long usedbytes = 0; /* number of bytes we have processed */
- unsigned long mask;
- long int conn_buf_size;
- char *xlib_buffer_size;
-
-#if !USE_XCB
- bzero((char *) &client, sizeof(client));
- bzero((char *) &prefix, sizeof(prefix));
-
- /*
- * If the display specifier string supplied as an argument to this
- * routine is NULL or a pointer to NULL, read the DISPLAY variable.
- */
- if (display == NULL || *display == '\0') {
- if ((display_name = getenv("DISPLAY")) == NULL) {
- /* Oops! No DISPLAY environment variable - error. */
- return(NULL);
- }
- }
- else {
- /* Display is non-NULL, copy the pointer */
- display_name = (char *)display;
- }
-#endif /* !USE_XCB */
-
-/*
- * Set the default error handlers. This allows the global variables to
- * default to NULL for use with shared libraries.
- */
- if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
- if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
-
-/*
- * Attempt to allocate a display structure. Return NULL if allocation fails.
- */
- if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
- return(NULL);
- }
-
-/*
- * Call the Connect routine to get the transport connection object.
- * If NULL is returned, the connection failed. The connect routine
- * will set fullname to point to the expanded name.
- */
-
-#if USE_XCB
- if(!_XConnectXCB(dpy, display, &fullname, &iscreen)) {
- dpy->display_name = fullname;
- OutOfMemory(dpy, NULL);
- return NULL;
- }
-#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
- * work if we run out of memory before we finish initializing.
- */
- dpy->display_name = fullname;
- dpy->keysyms = (KeySym *) NULL;
- dpy->modifiermap = NULL;
- dpy->lock_meaning = NoSymbol;
- dpy->keysyms_per_keycode = 0;
- dpy->xdefaults = (char *)NULL;
- dpy->scratch_length = 0L;
- dpy->scratch_buffer = NULL;
- dpy->key_bindings = NULL;
- dpy->ext_procs = (_XExtension *)NULL;
- dpy->ext_data = (XExtData *)NULL;
- dpy->ext_number = 0;
- dpy->event_vec[X_Error] = _XUnknownWireEvent;
- dpy->event_vec[X_Reply] = _XUnknownWireEvent;
- dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
- dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
- for (i = KeyPress; i < LASTEvent; i++) {
- dpy->event_vec[i] = _XWireToEvent;
- dpy->wire_vec[i] = NULL;
- }
- for (i = LASTEvent; i < 128; i++) {
- dpy->event_vec[i] = _XUnknownWireEvent;
- dpy->wire_vec[i] = _XUnknownNativeEvent;
- }
- dpy->resource_id = 0;
- dpy->db = (struct _XrmHashBucketRec *)NULL;
- dpy->cursor_font = None;
- dpy->flags = 0;
- dpy->async_handlers = NULL;
- dpy->screens = NULL;
- dpy->vendor = NULL;
- dpy->buffer = NULL;
- dpy->atoms = NULL;
- dpy->error_vec = NULL;
- dpy->context_db = NULL;
- dpy->free_funcs = NULL;
- dpy->pixmap_format = NULL;
- dpy->cms.clientCmaps = NULL;
- dpy->cms.defaultCCCs = NULL;
- dpy->cms.perVisualIntensityMaps = NULL;
- dpy->im_filters = NULL;
- dpy->bigreq_size = 0;
- dpy->lock = NULL;
- dpy->lock_fns = NULL;
- dpy->qfree = NULL;
- dpy->next_event_serial_num = 1;
- dpy->im_fd_info = NULL;
- dpy->im_fd_length = 0;
- dpy->conn_watchers = NULL;
- dpy->watcher_count = 0;
- dpy->filedes = NULL;
- dpy->flushes = NULL;
- dpy->xcmisc_opcode = 0;
- dpy->xkb_info = NULL;
-
-/*
- * Setup other information in this display structure.
- */
- dpy->vnumber = X_PROTOCOL;
- dpy->resource_alloc = _XAllocID;
- dpy->idlist_alloc = _XAllocIDs;
- dpy->synchandler = NULL;
- dpy->savedsynchandler = NULL;
- dpy->request = 0;
- dpy->last_request_read = 0;
- dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
- dpy->last_req = (char *)&_dummy_request;
-
- /* Initialize the display lock */
- if (InitDisplayLock(dpy) != 0) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- if (!_XPollfdCacheInit(dpy)) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- /* Set up the output buffers. */
-#ifndef XLIBDEFAULTBUFSIZE
-#define XLIBDEFAULTBUFSIZE 16384 /* 16k */
-#endif
-#ifndef XLIBMINBUFSIZE
-#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */
-#endif
- xlib_buffer_size = getenv("XLIBBUFFERSIZE");
-
-#ifdef __sun /* Backwards compatibility for old Solaris libX11 name */
- if (xlib_buffer_size == NULL)
- xlib_buffer_size = getenv("XSUNBUFFERSIZE");
-#endif
-
- if (xlib_buffer_size == NULL)
- conn_buf_size = XLIBDEFAULTBUFSIZE;
- else
- conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10);
- if (conn_buf_size < XLIBMINBUFSIZE)
- conn_buf_size = XLIBMINBUFSIZE;
-
- if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
- dpy->bufmax = dpy->buffer + conn_buf_size;
-#if USE_XCB
- dpy->xcb->real_bufmax = dpy->bufmax;
- dpy->bufmax = dpy->buffer;
-#endif
-
- /* Set up the input event queue and input event queue parameters. */
- dpy->head = dpy->tail = NULL;
- dpy->qlen = 0;
-
- /* Set up free-function record */
- 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);
- 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));
- setuplength = prefix.length << 2;
- setup = (char *) xcbsetup;
- 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.
- */
- usedbytes = sz_xConnSetup;
- if (setuplength < usedbytes ) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory(dpy, setup);
- return (NULL);
- }
-
-/*
- * We succeeded at authorization, so let us move the data into
- * the display structure.
- */
- dpy->proto_major_version= prefix.majorVersion;
- dpy->proto_minor_version= prefix.minorVersion;
- dpy->release = u.setup->release;
- dpy->resource_base = u.setup->ridBase;
- dpy->resource_mask = u.setup->ridMask;
- dpy->min_keycode = u.setup->minKeyCode;
- dpy->max_keycode = u.setup->maxKeyCode;
- dpy->motion_buffer = u.setup->motionBufferSize;
- dpy->nformats = u.setup->numFormats;
- dpy->nscreens = u.setup->numRoots;
- dpy->byte_order = u.setup->imageByteOrder;
- dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
- dpy->bitmap_pad = u.setup->bitmapScanlinePad;
- dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
- dpy->max_request_size = u.setup->maxRequestSize;
- mask = dpy->resource_mask;
- dpy->resource_shift = 0;
- if (!mask)
- {
- fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
- fullname);
- OutOfMemory(dpy, setup);
- return (NULL);
- }
-
- while (!(mask & 1)) {
- dpy->resource_shift++;
- mask = mask >> 1;
- }
- dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
-/*
- * now extract the vendor string... String must be null terminated,
- * padded to multiple of 4 bytes.
- */
- /* Check for a sane vendor string length */
- if (u.setup->nbytesVendor > 256) {
- OutOfMemory(dpy, setup);
- return (NULL);
- }
-
- dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
- if (dpy->vendor == NULL) {
- OutOfMemory(dpy, setup);
- return (NULL);
- }
- vendorlen = u.setup->nbytesVendor;
-
-/*
- * validate setup length
- */
- usedbytes += (vendorlen + 3) & ~3;
- if (setuplength < usedbytes) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory(dpy, setup);
- return (NULL);
- }
-
- u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
- (void) strncpy(dpy->vendor, u.vendor, vendorlen);
- dpy->vendor[vendorlen] = '\0';
- vendorlen = (vendorlen + 3) & ~3; /* round up */
- u.vendor += vendorlen;
-
-/*
- * Now iterate down setup information.....
- */
- dpy->pixmap_format =
- (ScreenFormat *)Xmalloc(
- (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
- if (dpy->pixmap_format == NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-/*
- * First decode the Z axis Screen format information.
- */
- usedbytes += dpy->nformats * sz_xPixmapFormat;
-
- if (setuplength < usedbytes) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- for (i = 0; i < dpy->nformats; i++) {
- register ScreenFormat *fmt = &dpy->pixmap_format[i];
- fmt->depth = u.sf->depth;
- fmt->bits_per_pixel = u.sf->bitsPerPixel;
- fmt->scanline_pad = u.sf->scanLinePad;
- fmt->ext_data = NULL;
- u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
- }
-
-/*
- * next the Screen structures.
- */
- dpy->screens =
- (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
- if (dpy->screens == NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
-/*
- * Now go deal with each screen structure.
- */
- for (i = 0; i < dpy->nscreens; i++) {
- register Screen *sp = &dpy->screens[i];
- VisualID root_visualID;
-
- usedbytes += sz_xWindowRoot;
- if (setuplength < usedbytes) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- root_visualID = u.rp->rootVisualID;
- sp->display = dpy;
- sp->root = u.rp->windowId;
- sp->cmap = u.rp->defaultColormap;
- sp->white_pixel = u.rp->whitePixel;
- sp->black_pixel = u.rp->blackPixel;
- sp->root_input_mask = u.rp->currentInputMask;
- sp->width = u.rp->pixWidth;
- sp->height = u.rp->pixHeight;
- sp->mwidth = u.rp->mmWidth;
- sp->mheight = u.rp->mmHeight;
- sp->min_maps = u.rp->minInstalledMaps;
- sp->max_maps = u.rp->maxInstalledMaps;
- sp->backing_store= u.rp->backingStore;
- sp->save_unders = u.rp->saveUnders;
- sp->root_depth = u.rp->rootDepth;
- sp->ndepths = u.rp->nDepths;
- sp->ext_data = NULL;
- u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
-/*
- * lets set up the depth structures.
- */
- sp->depths = (Depth *)Xmalloc(
- (unsigned)sp->ndepths*sizeof(Depth));
- if (sp->depths == NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
- /*
- * for all depths on this screen.
- */
- for (j = 0; j < sp->ndepths; j++) {
- Depth *dp = &sp->depths[j];
-
- usedbytes += sz_xDepth;
- if (setuplength < usedbytes) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- dp->depth = u.dp->depth;
- dp->nvisuals = u.dp->nVisuals;
- u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
- if (dp->nvisuals > 0) {
- dp->visuals =
- (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
- if (dp->visuals == NULL) {
- OutOfMemory (dpy, setup);
- return(NULL);
- }
- for (k = 0; k < dp->nvisuals; k++) {
- register Visual *vp = &dp->visuals[k];
-
- usedbytes += sz_xVisualType;
- if (setuplength < usedbytes) {
- fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
- OutOfMemory (dpy, setup);
- return(NULL);
- }
-
- vp->visualid = u.vp->visualID;
- vp->class = u.vp->class;
- vp->bits_per_rgb= u.vp->bitsPerRGB;
- vp->map_entries = u.vp->colormapEntries;
- vp->red_mask = u.vp->redMask;
- vp->green_mask = u.vp->greenMask;
- vp->blue_mask = u.vp->blueMask;
- vp->ext_data = NULL;
- u.vp = (xVisualType *) (((char *) u.vp) +
- sz_xVisualType);
- }
- if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS"))
- {
- Xfree (dp->visuals);
- dp->visuals = NULL;
- dp->nvisuals = 0;
- }
- } else {
- dp->visuals = (Visual *) NULL;
- }
- }
- sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
- }
-
- if(usedbytes != setuplength){
- /* Sanity check, shouldn't happen. */
- fprintf(stderr, "Xlib: Did not parse entire setup message: "
- "parsed: %ld, message: %ld\n",
- usedbytes, setuplength);
- OutOfMemory(dpy, setup);
- return(NULL);
- }
-
-/*
- * 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);
- 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.
- */
- for (i = 0; i < dpy->nscreens; i++) {
- register Screen *sp = &dpy->screens[i];
- XGCValues values;
- values.foreground = sp->black_pixel;
- values.background = sp->white_pixel;
- if ((sp->default_gc = XCreateGC (dpy, sp->root,
- GCForeground|GCBackground,
- &values)) == NULL) {
- OutOfMemory(dpy, (char *) NULL);
- return (NULL);
- }
- }
-/*
- * call into synchronization routine so that all programs can be
- * forced synchronous
- */
- (void) XSynchronize(dpy, _Xdebug);
-
-/*
- * get availability of large requests, and
- * get the resource manager database off the root window.
- */
- LockDisplay(dpy);
- {
- 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);
- req->property = XA_RESOURCE_MANAGER;
- req->type = XA_STRING;
- req->delete = False;
- req->longOffset = 0;
- req->longLength = 100000000L;
-
- if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
- if (reply.format == 8 && reply.propertyType == XA_STRING &&
- (reply.nItems + 1 > 0) &&
- (reply.nItems <= req->longLength * 4) &&
- (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
- _XReadPad (dpy, dpy->xdefaults, reply.nItems);
- dpy->xdefaults[reply.nItems] = '\0';
- }
- 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);
-
-#ifdef MOTIFBC
- {
- extern Display *_XHeadOfDisplayList;
- _XHeadOfDisplayList = dpy;
- }
-#endif
-#ifdef XKB
- XkbUseExtension(dpy,NULL,NULL);
-#endif
-/*
- * and return successfully
- */
- 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
- * are non-NULL before dereferencing them, since it may be called
- * by XOpenDisplay before the Display structure is fully formed.
- * XOpenDisplay must be sure to initialize all the pointers to NULL
- * before the first possible call on this.
- */
-
-void _XFreeDisplayStructure(Display *dpy)
-{
- /* move all cookies in the EQ to the jar, then free them. */
- if (dpy->qfree) {
- _XQEvent *qelt = dpy->qfree;
- while (qelt) {
- if (_XIsEventCookie(dpy, &qelt->event))
- _XStoreEventCookie(dpy, &qelt->event);
- qelt = qelt->next;
- }
- }
- if (dpy->cookiejar)
- _XFreeEventCookies(dpy);
- while (dpy->ext_procs) {
- _XExtension *ext = dpy->ext_procs;
- dpy->ext_procs = ext->next;
- if (ext->name)
- Xfree (ext->name);
- Xfree ((char *)ext);
- }
- if (dpy->im_filters)
- (*dpy->free_funcs->im_filters)(dpy);
- if (dpy->cms.clientCmaps)
- (*dpy->free_funcs->clientCmaps)(dpy);
- if (dpy->cms.defaultCCCs)
- (*dpy->free_funcs->defaultCCCs)(dpy);
- if (dpy->cms.perVisualIntensityMaps)
- (*dpy->free_funcs->intensityMaps)(dpy);
- if (dpy->atoms)
- (*dpy->free_funcs->atoms)(dpy);
- if (dpy->modifiermap)
- (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
- if (dpy->key_bindings)
- (*dpy->free_funcs->key_bindings)(dpy);
- if (dpy->context_db)
- (*dpy->free_funcs->context_db)(dpy);
- if (dpy->xkb_info)
- (*dpy->free_funcs->xkb)(dpy);
-
- /* if RM database was allocated by XGetDefault() free it */
- if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB))
- XrmDestroyDatabase(dpy->db);
-
- if (dpy->screens) {
- register int i;
-
- for (i = 0; i < dpy->nscreens; i++) {
- Screen *sp = &dpy->screens[i];
-
- if (sp->depths) {
- register int j;
-
- for (j = 0; j < sp->ndepths; j++) {
- Depth *dp = &sp->depths[j];
-
- if (dp->visuals) {
- register int k;
-
- for (k = 0; k < dp->nvisuals; k++)
- _XFreeExtData (dp->visuals[k].ext_data);
- Xfree ((char *) dp->visuals);
- }
- }
-
- Xfree ((char *) sp->depths);
- }
-
- _XFreeExtData (sp->ext_data);
- }
-
- Xfree ((char *)dpy->screens);
- }
-
- if (dpy->pixmap_format) {
- register int i;
-
- for (i = 0; i < dpy->nformats; i++)
- _XFreeExtData (dpy->pixmap_format[i].ext_data);
- Xfree ((char *)dpy->pixmap_format);
- }
-
- if (dpy->display_name)
- Xfree (dpy->display_name);
- if (dpy->vendor)
- Xfree (dpy->vendor);
-
- if (dpy->buffer)
- Xfree (dpy->buffer);
- if (dpy->keysyms)
- Xfree ((char *) dpy->keysyms);
- if (dpy->xdefaults)
- Xfree (dpy->xdefaults);
- if (dpy->error_vec)
- Xfree ((char *)dpy->error_vec);
-
- _XFreeExtData (dpy->ext_data);
- if (dpy->free_funcs)
- Xfree ((char *)dpy->free_funcs);
- if (dpy->scratch_buffer)
- Xfree (dpy->scratch_buffer);
- FreeDisplayLock(dpy);
-
- if (dpy->qfree) {
- register _XQEvent *qelt = dpy->qfree;
-
- while (qelt) {
- register _XQEvent *qnxt = qelt->next;
- Xfree ((char *) qelt);
- qelt = qnxt;
- }
- }
- while (dpy->im_fd_info) {
- struct _XConnectionInfo *conni = dpy->im_fd_info;
- dpy->im_fd_info = conni->next;
- if (conni->watch_data)
- Xfree (conni->watch_data);
- Xfree (conni);
- }
- if (dpy->conn_watchers) {
- struct _XConnWatchInfo *watcher = dpy->conn_watchers;
- dpy->conn_watchers = watcher->next;
- Xfree (watcher);
- }
- if (dpy->filedes)
- Xfree (dpy->filedes);
-
-#if USE_XCB
- _XFreeX11XCBStructure(dpy);
-#endif /* USE_XCB */
-
- Xfree ((char *)dpy);
-}
-
-/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
- after this returns. */
-
-static void OutOfMemory(Display *dpy, char *setup)
-{
-#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 */
-}
+/*
+
+Copyright 1985, 1986, 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.
+
+*/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#ifdef HAVE_CONFIG_H
+#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>
+#include <unistd.h>
+#include "Xintconn.h"
+
+#ifdef XKB
+#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;
+void (*_XFreeDisplayLock_fn)(Display *dpy) = NULL;
+
+#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif /* XTHREADS */
+
+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 */
+
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+Display *
+XOpenDisplay (
+ register _Xconst char *display)
+{
+ register Display *dpy; /* New Display object being created. */
+ 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 */
+ xConnSetupPrefix prefix; /* prefix information */
+ int vendorlen; /* length of vendor string */
+ union {
+ xConnSetup *setup;
+ char *failure;
+ char *vendor;
+ xPixmapFormat *sf;
+ xWindowRoot *rp;
+ xDepth *dp;
+ xVisualType *vp;
+ } u; /* proto data returned from server */
+ long setuplength; /* number of bytes in setup message */
+ long usedbytes = 0; /* number of bytes we have processed */
+ unsigned long mask;
+ 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.
+ */
+ if (display == NULL || *display == '\0') {
+ if ((display_name = getenv("DISPLAY")) == NULL) {
+ /* Oops! No DISPLAY environment variable - error. */
+ return(NULL);
+ }
+ }
+ else {
+ /* Display is non-NULL, copy the pointer */
+ display_name = (char *)display;
+ }
+
+/*
+ * Set the default error handlers. This allows the global variables to
+ * default to NULL for use with shared libraries.
+ */
+ if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+ if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the transport connection object.
+ * If NULL is returned, the connection failed. The connect routine
+ * 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, '/');
+ if(slash == NULL) {
+ const char *protocols[] = {"local", "unix", "tcp", "inet6", "inet", NULL};
+ const char **s;
+ size_t buf_size = strlen(display_name) + 7; // max strlen + 2 (null + /)
+ char *buf = Xmalloc(buf_size * sizeof(char));
+
+ if(buf) {
+ for(s = protocols; buf && *s; s++) {
+ snprintf(buf, buf_size, "%s/%s", *s, display_name);
+ if(_XConnectXCB(dpy, buf, &fullname, &iscreen))
+ goto fallback_success;
+ }
+ Xfree(buf);
+ }
+ }
+
+ dpy->display_name = fullname;
+ OutOfMemory(dpy, NULL);
+ 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
+ * work if we run out of memory before we finish initializing.
+ */
+ dpy->display_name = fullname;
+ dpy->keysyms = (KeySym *) NULL;
+ dpy->modifiermap = NULL;
+ dpy->lock_meaning = NoSymbol;
+ dpy->keysyms_per_keycode = 0;
+ dpy->xdefaults = (char *)NULL;
+ dpy->scratch_length = 0L;
+ dpy->scratch_buffer = NULL;
+ dpy->key_bindings = NULL;
+ dpy->ext_procs = (_XExtension *)NULL;
+ dpy->ext_data = (XExtData *)NULL;
+ dpy->ext_number = 0;
+ dpy->event_vec[X_Error] = _XUnknownWireEvent;
+ dpy->event_vec[X_Reply] = _XUnknownWireEvent;
+ dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
+ dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
+ for (i = KeyPress; i < LASTEvent; i++) {
+ dpy->event_vec[i] = _XWireToEvent;
+ dpy->wire_vec[i] = NULL;
+ }
+ for (i = LASTEvent; i < 128; i++) {
+ dpy->event_vec[i] = _XUnknownWireEvent;
+ dpy->wire_vec[i] = _XUnknownNativeEvent;
+ }
+ dpy->resource_id = 0;
+ dpy->db = (struct _XrmHashBucketRec *)NULL;
+ dpy->cursor_font = None;
+ dpy->flags = 0;
+ dpy->async_handlers = NULL;
+ dpy->screens = NULL;
+ dpy->vendor = NULL;
+ dpy->buffer = NULL;
+ dpy->atoms = NULL;
+ dpy->error_vec = NULL;
+ dpy->context_db = NULL;
+ dpy->free_funcs = NULL;
+ dpy->pixmap_format = NULL;
+ dpy->cms.clientCmaps = NULL;
+ dpy->cms.defaultCCCs = NULL;
+ dpy->cms.perVisualIntensityMaps = NULL;
+ dpy->im_filters = NULL;
+ dpy->bigreq_size = 0;
+ dpy->lock = NULL;
+ dpy->lock_fns = NULL;
+ dpy->qfree = NULL;
+ dpy->next_event_serial_num = 1;
+ dpy->im_fd_info = NULL;
+ dpy->im_fd_length = 0;
+ dpy->conn_watchers = NULL;
+ dpy->watcher_count = 0;
+ dpy->filedes = NULL;
+ dpy->flushes = NULL;
+ dpy->xcmisc_opcode = 0;
+ dpy->xkb_info = NULL;
+
+/*
+ * Setup other information in this display structure.
+ */
+ dpy->vnumber = X_PROTOCOL;
+ dpy->resource_alloc = _XAllocID;
+ dpy->idlist_alloc = _XAllocIDs;
+ dpy->synchandler = NULL;
+ dpy->savedsynchandler = NULL;
+ dpy->request = 0;
+ dpy->last_request_read = 0;
+ dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
+ dpy->last_req = (char *)&_dummy_request;
+
+ /* Initialize the display lock */
+ if (InitDisplayLock(dpy) != 0) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ if (!_XPollfdCacheInit(dpy)) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ /* Set up the output buffers. */
+#ifndef XLIBDEFAULTBUFSIZE
+#define XLIBDEFAULTBUFSIZE 16384 /* 16k */
+#endif
+#ifndef XLIBMINBUFSIZE
+#define XLIBMINBUFSIZE BUFSIZE /* old default buffer size */
+#endif
+ xlib_buffer_size = getenv("XLIBBUFFERSIZE");
+
+#ifdef __sun /* Backwards compatibility for old Solaris libX11 name */
+ if (xlib_buffer_size == NULL)
+ xlib_buffer_size = getenv("XSUNBUFFERSIZE");
+#endif
+
+ if (xlib_buffer_size == NULL)
+ conn_buf_size = XLIBDEFAULTBUFSIZE;
+ else
+ conn_buf_size = 1024 * strtol(xlib_buffer_size, NULL, 10);
+ if (conn_buf_size < XLIBMINBUFSIZE)
+ conn_buf_size = XLIBMINBUFSIZE;
+
+ if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ dpy->bufmax = dpy->buffer + conn_buf_size;
+#if USE_XCB
+ dpy->xcb->real_bufmax = dpy->bufmax;
+ dpy->bufmax = dpy->buffer;
+#endif
+
+ /* Set up the input event queue and input event queue parameters. */
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+
+ /* Set up free-function record */
+ 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);
+ 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));
+ setuplength = prefix.length << 2;
+ setup = (char *) xcbsetup;
+ 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.
+ */
+ usedbytes = sz_xConnSetup;
+ if (setuplength < usedbytes ) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ dpy->proto_major_version= prefix.majorVersion;
+ dpy->proto_minor_version= prefix.minorVersion;
+ dpy->release = u.setup->release;
+ dpy->resource_base = u.setup->ridBase;
+ dpy->resource_mask = u.setup->ridMask;
+ dpy->min_keycode = u.setup->minKeyCode;
+ dpy->max_keycode = u.setup->maxKeyCode;
+ dpy->motion_buffer = u.setup->motionBufferSize;
+ dpy->nformats = u.setup->numFormats;
+ dpy->nscreens = u.setup->numRoots;
+ dpy->byte_order = u.setup->imageByteOrder;
+ dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
+ dpy->bitmap_pad = u.setup->bitmapScanlinePad;
+ dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
+ dpy->max_request_size = u.setup->maxRequestSize;
+ mask = dpy->resource_mask;
+ dpy->resource_shift = 0;
+ if (!mask)
+ {
+ fprintf (stderr, "Xlib: connection to \"%s\" invalid setup\n",
+ fullname);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ while (!(mask & 1)) {
+ dpy->resource_shift++;
+ mask = mask >> 1;
+ }
+ dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
+/*
+ * now extract the vendor string... String must be null terminated,
+ * padded to multiple of 4 bytes.
+ */
+ /* Check for a sane vendor string length */
+ if (u.setup->nbytesVendor > 256) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ if (dpy->vendor == NULL) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+ vendorlen = u.setup->nbytesVendor;
+
+/*
+ * validate setup length
+ */
+ usedbytes += (vendorlen + 3) & ~3;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+ u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
+ (void) strncpy(dpy->vendor, u.vendor, vendorlen);
+ dpy->vendor[vendorlen] = '\0';
+ vendorlen = (vendorlen + 3) & ~3; /* round up */
+ u.vendor += vendorlen;
+
+/*
+ * Now iterate down setup information.....
+ */
+ dpy->pixmap_format =
+ (ScreenFormat *)Xmalloc(
+ (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
+ if (dpy->pixmap_format == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * First decode the Z axis Screen format information.
+ */
+ usedbytes += dpy->nformats * sz_xPixmapFormat;
+
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ for (i = 0; i < dpy->nformats; i++) {
+ register ScreenFormat *fmt = &dpy->pixmap_format[i];
+ fmt->depth = u.sf->depth;
+ fmt->bits_per_pixel = u.sf->bitsPerPixel;
+ fmt->scanline_pad = u.sf->scanLinePad;
+ fmt->ext_data = NULL;
+ u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
+ }
+
+/*
+ * next the Screen structures.
+ */
+ dpy->screens =
+ (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
+ if (dpy->screens == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * Now go deal with each screen structure.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ VisualID root_visualID;
+
+ usedbytes += sz_xWindowRoot;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ root_visualID = u.rp->rootVisualID;
+ sp->display = dpy;
+ sp->root = u.rp->windowId;
+ sp->cmap = u.rp->defaultColormap;
+ sp->white_pixel = u.rp->whitePixel;
+ sp->black_pixel = u.rp->blackPixel;
+ sp->root_input_mask = u.rp->currentInputMask;
+ sp->width = u.rp->pixWidth;
+ sp->height = u.rp->pixHeight;
+ sp->mwidth = u.rp->mmWidth;
+ sp->mheight = u.rp->mmHeight;
+ sp->min_maps = u.rp->minInstalledMaps;
+ sp->max_maps = u.rp->maxInstalledMaps;
+ sp->backing_store= u.rp->backingStore;
+ sp->save_unders = u.rp->saveUnders;
+ sp->root_depth = u.rp->rootDepth;
+ sp->ndepths = u.rp->nDepths;
+ sp->ext_data = NULL;
+ u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
+/*
+ * lets set up the depth structures.
+ */
+ sp->depths = (Depth *)Xmalloc(
+ (unsigned)sp->ndepths*sizeof(Depth));
+ if (sp->depths == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ /*
+ * for all depths on this screen.
+ */
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ usedbytes += sz_xDepth;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ dp->depth = u.dp->depth;
+ dp->nvisuals = u.dp->nVisuals;
+ u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
+ if (dp->nvisuals > 0) {
+ dp->visuals =
+ (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
+ if (dp->visuals == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ for (k = 0; k < dp->nvisuals; k++) {
+ register Visual *vp = &dp->visuals[k];
+
+ usedbytes += sz_xVisualType;
+ if (setuplength < usedbytes) {
+ fprintf (stderr, "Xlib: Broken initial reply: Too short (%ld)\n", setuplength);
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ vp->visualid = u.vp->visualID;
+ vp->class = u.vp->class;
+ vp->bits_per_rgb= u.vp->bitsPerRGB;
+ vp->map_entries = u.vp->colormapEntries;
+ vp->red_mask = u.vp->redMask;
+ vp->green_mask = u.vp->greenMask;
+ vp->blue_mask = u.vp->blueMask;
+ vp->ext_data = NULL;
+ u.vp = (xVisualType *) (((char *) u.vp) +
+ sz_xVisualType);
+ }
+ if (dp->depth == 32 && getenv ("XLIB_SKIP_ARGB_VISUALS"))
+ {
+ Xfree (dp->visuals);
+ dp->visuals = NULL;
+ dp->nvisuals = 0;
+ }
+ } else {
+ dp->visuals = (Visual *) NULL;
+ }
+ }
+ sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
+ }
+
+ if(usedbytes != setuplength){
+ /* Sanity check, shouldn't happen. */
+ fprintf(stderr, "Xlib: Did not parse entire setup message: "
+ "parsed: %ld, message: %ld\n",
+ usedbytes, setuplength);
+ OutOfMemory(dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * 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);
+ 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.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XGCValues values;
+ values.foreground = sp->black_pixel;
+ values.background = sp->white_pixel;
+ if ((sp->default_gc = XCreateGC (dpy, sp->root,
+ GCForeground|GCBackground,
+ &values)) == NULL) {
+ OutOfMemory(dpy, (char *) NULL);
+ return (NULL);
+ }
+ }
+/*
+ * call into synchronization routine so that all programs can be
+ * forced synchronous
+ */
+ (void) XSynchronize(dpy, _Xdebug);
+
+/*
+ * get availability of large requests, and
+ * get the resource manager database off the root window.
+ */
+ LockDisplay(dpy);
+ {
+ 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);
+ req->property = XA_RESOURCE_MANAGER;
+ req->type = XA_STRING;
+ req->delete = False;
+ req->longOffset = 0;
+ req->longLength = 100000000L;
+
+ if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ if (reply.format == 8 && reply.propertyType == XA_STRING &&
+ (reply.nItems + 1 > 0) &&
+ (reply.nItems <= req->longLength * 4) &&
+ (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
+ _XReadPad (dpy, dpy->xdefaults, reply.nItems);
+ dpy->xdefaults[reply.nItems] = '\0';
+ }
+ 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);
+
+#ifdef MOTIFBC
+ {
+ extern Display *_XHeadOfDisplayList;
+ _XHeadOfDisplayList = dpy;
+ }
+#endif
+#ifdef XKB
+ XkbUseExtension(dpy,NULL,NULL);
+#endif
+/*
+ * and return successfully
+ */
+ 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
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+void _XFreeDisplayStructure(Display *dpy)
+{
+ /* move all cookies in the EQ to the jar, then free them. */
+ if (dpy->qfree) {
+ _XQEvent *qelt = dpy->qfree;
+ while (qelt) {
+ if (_XIsEventCookie(dpy, &qelt->event))
+ _XStoreEventCookie(dpy, &qelt->event);
+ qelt = qelt->next;
+ }
+ }
+ if (dpy->cookiejar)
+ _XFreeEventCookies(dpy);
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+ if (dpy->im_filters)
+ (*dpy->free_funcs->im_filters)(dpy);
+ if (dpy->cms.clientCmaps)
+ (*dpy->free_funcs->clientCmaps)(dpy);
+ if (dpy->cms.defaultCCCs)
+ (*dpy->free_funcs->defaultCCCs)(dpy);
+ if (dpy->cms.perVisualIntensityMaps)
+ (*dpy->free_funcs->intensityMaps)(dpy);
+ if (dpy->atoms)
+ (*dpy->free_funcs->atoms)(dpy);
+ if (dpy->modifiermap)
+ (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
+ if (dpy->key_bindings)
+ (*dpy->free_funcs->key_bindings)(dpy);
+ if (dpy->context_db)
+ (*dpy->free_funcs->context_db)(dpy);
+ if (dpy->xkb_info)
+ (*dpy->free_funcs->xkb)(dpy);
+
+ /* if RM database was allocated by XGetDefault() free it */
+ if (dpy->db && (dpy->flags & XlibDisplayDfltRMDB))
+ XrmDestroyDatabase(dpy->db);
+
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->error_vec)
+ Xfree ((char *)dpy->error_vec);
+
+ _XFreeExtData (dpy->ext_data);
+ if (dpy->free_funcs)
+ Xfree ((char *)dpy->free_funcs);
+ if (dpy->scratch_buffer)
+ Xfree (dpy->scratch_buffer);
+ FreeDisplayLock(dpy);
+
+ if (dpy->qfree) {
+ register _XQEvent *qelt = dpy->qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ }
+ while (dpy->im_fd_info) {
+ struct _XConnectionInfo *conni = dpy->im_fd_info;
+ dpy->im_fd_info = conni->next;
+ if (conni->watch_data)
+ Xfree (conni->watch_data);
+ Xfree (conni);
+ }
+ if (dpy->conn_watchers) {
+ struct _XConnWatchInfo *watcher = dpy->conn_watchers;
+ dpy->conn_watchers = watcher->next;
+ Xfree (watcher);
+ }
+ if (dpy->filedes)
+ Xfree (dpy->filedes);
+
+#if USE_XCB
+ _XFreeX11XCBStructure(dpy);
+#endif /* USE_XCB */
+
+ Xfree ((char *)dpy);
+}
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory(Display *dpy, char *setup)
+{
+#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 */
+}
diff --git a/libX11/src/SetPntMap.c b/libX11/src/SetPntMap.c
index eaa642d65..78f965e32 100644
--- a/libX11/src/SetPntMap.c
+++ b/libX11/src/SetPntMap.c
@@ -1,80 +1,79 @@
-/*
-
-Copyright 1986, 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.
-
-*/
-
-#define NEED_REPLIES
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-/* returns either DeviceMappingSuccess or DeviceMappingBusy */
-
-int
-XSetPointerMapping (
- register Display *dpy,
- _Xconst unsigned char *map,
- int nmaps)
- {
- register xSetPointerMappingReq *req;
- xSetPointerMappingReply rep;
-
- LockDisplay(dpy);
- GetReq (SetPointerMapping, req);
- req->nElts = nmaps;
- req->length += (nmaps + 3)>>2;
- Data (dpy, (char *)map, (long) nmaps);
- if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
- rep.success = MappingSuccess;
- UnlockDisplay(dpy);
- SyncHandle();
- return ((int) rep.success);
- }
-
-int
-XChangeKeyboardMapping (
- register Display *dpy,
- int first_keycode,
- int keysyms_per_keycode,
- KeySym *keysyms,
- int nkeycodes)
-{
- register long nbytes;
- register xChangeKeyboardMappingReq *req;
-
- LockDisplay(dpy);
- GetReq (ChangeKeyboardMapping, req);
- req->firstKeyCode = first_keycode;
- req->keyCodes = nkeycodes;
- req->keySymsPerKeyCode = keysyms_per_keycode;
- req->firstKeyCode = first_keycode;
- req->length += nkeycodes * keysyms_per_keycode;
- nbytes = keysyms_per_keycode * nkeycodes * 4;
- Data32 (dpy, (long *)keysyms, nbytes);
- UnlockDisplay(dpy);
- SyncHandle();
- return 0;
- }
-
+/*
+
+Copyright 1986, 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.
+
+*/
+
+#define NEED_REPLIES
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+/* returns either DeviceMappingSuccess or DeviceMappingBusy */
+
+int
+XSetPointerMapping (
+ register Display *dpy,
+ _Xconst unsigned char *map,
+ int nmaps)
+ {
+ register xSetPointerMappingReq *req;
+ xSetPointerMappingReply rep;
+
+ LockDisplay(dpy);
+ GetReq (SetPointerMapping, req);
+ req->nElts = nmaps;
+ req->length += (nmaps + 3)>>2;
+ Data (dpy, (char *)map, (long) nmaps);
+ if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
+ rep.success = MappingSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.success);
+ }
+
+int
+XChangeKeyboardMapping (
+ register Display *dpy,
+ int first_keycode,
+ int keysyms_per_keycode,
+ KeySym *keysyms,
+ int nkeycodes)
+{
+ register long nbytes;
+ register xChangeKeyboardMappingReq *req;
+
+ LockDisplay(dpy);
+ GetReq (ChangeKeyboardMapping, req);
+ req->firstKeyCode = first_keycode;
+ req->keyCodes = nkeycodes;
+ req->keySymsPerKeyCode = keysyms_per_keycode;
+ req->length += nkeycodes * keysyms_per_keycode;
+ nbytes = keysyms_per_keycode * nkeycodes * 4;
+ Data32 (dpy, (long *)keysyms, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
diff --git a/libX11/src/XErrorDB b/libX11/src/XErrorDB
index 25b79a026..5d1846605 100644
--- a/libX11/src/XErrorDB
+++ b/libX11/src/XErrorDB
@@ -1,1003 +1,1009 @@
-!
-! Copyright 1993, 1995, 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.
-!
-!
-! these are used in XGetErrorMessage.
-XlibMessage.XError: X Error of failed request
-XlibMessage.MajorCode: Major opcode of failed request: %d
-XlibMessage.MinorCode: Minor opcode of failed request: %d
-XlibMessage.ResourceID: Resource id in failed request: 0x%lx
-XlibMessage.Value: Value in failed request: 0x%lx
-XlibMessage.AtomID: Atom id in failed request: 0x%lx
-XlibMessage.ErrorSerial: Serial number of failed request: %lu
-XlibMessage.CurrentSerial: Current serial number in output stream: %lu
-! X request codes.
-XRequest.1:X_CreateWindow
-XRequest.2:X_ChangeWindowAttributes
-XRequest.3:X_GetWindowAttributes
-XRequest.4:X_DestroyWindow
-XRequest.5:X_DestroySubwindows
-XRequest.6:X_ChangeSaveSet
-XRequest.7:X_ReparentWindow
-XRequest.8:X_MapWindow
-XRequest.9:X_MapSubwindows
-XRequest.10:X_UnmapWindow
-XRequest.11:X_UnmapSubwindows
-XRequest.12:X_ConfigureWindow
-XRequest.13:X_CirculateWindow
-XRequest.14:X_GetGeometry
-XRequest.15:X_QueryTree
-XRequest.16:X_InternAtom
-XRequest.17:X_GetAtomName
-XRequest.18:X_ChangeProperty
-XRequest.19:X_DeleteProperty
-XRequest.20:X_GetProperty
-XRequest.21:X_ListProperties
-XRequest.22:X_SetSelectionOwner
-XRequest.23:X_GetSelectionOwner
-XRequest.24:X_ConvertSelection
-XRequest.25:X_SendEvent
-XRequest.26:X_GrabPointer
-XRequest.27:X_UngrabPointer
-XRequest.28:X_GrabButton
-XRequest.29:X_UngrabButton
-XRequest.30:X_ChangeActivePointerGrab
-XRequest.31:X_GrabKeyboard
-XRequest.32:X_UngrabKeyboard
-XRequest.33:X_GrabKey
-XRequest.34:X_UngrabKey
-XRequest.35:X_AllowEvents
-XRequest.36:X_GrabServer
-XRequest.37:X_UngrabServer
-XRequest.38:X_QueryPointer
-XRequest.39:X_GetMotionEvents
-XRequest.40:X_TranslateCoords
-XRequest.41:X_WarpPointer
-XRequest.42:X_SetInputFocus
-XRequest.43:X_GetInputFocus
-XRequest.44:X_QueryKeymap
-XRequest.45:X_OpenFont
-XRequest.46:X_CloseFont
-XRequest.47:X_QueryFont
-XRequest.48:X_QueryTextExtents
-XRequest.49:X_ListFonts
-XRequest.50:X_ListFontsWithInfo
-XRequest.51:X_SetFontPath
-XRequest.52:X_GetFontPath
-XRequest.53:X_CreatePixmap
-XRequest.54:X_FreePixmap
-XRequest.55:X_CreateGC
-XRequest.56:X_ChangeGC
-XRequest.57:X_CopyGC
-XRequest.58:X_SetDashes
-XRequest.59:X_SetClipRectangles
-XRequest.60:X_FreeGC
-XRequest.61:X_ClearArea
-XRequest.62:X_CopyArea
-XRequest.63:X_CopyPlane
-XRequest.64:X_PolyPoint
-XRequest.65:X_PolyLine
-XRequest.66:X_PolySegment
-XRequest.67:X_PolyRectangle
-XRequest.68:X_PolyArc
-XRequest.69:X_FillPoly
-XRequest.70:X_PolyFillRectangle
-XRequest.71:X_PolyFillArc
-XRequest.72:X_PutImage
-XRequest.73:X_GetImage
-XRequest.74:X_PolyText8
-XRequest.75:X_PolyText16
-XRequest.76:X_ImageText8
-XRequest.77:X_ImageText16
-XRequest.78:X_CreateColormap
-XRequest.79:X_FreeColormap
-XRequest.80:X_CopyColormapAndFree
-XRequest.81:X_InstallColormap
-XRequest.82:X_UninstallColormap
-XRequest.83:X_ListInstalledColormaps
-XRequest.84:X_AllocColor
-XRequest.85:X_AllocNamedColor
-XRequest.86:X_AllocColorCells
-XRequest.87:X_AllocColorPlanes
-XRequest.88:X_FreeColors
-XRequest.89:X_StoreColors
-XRequest.90:X_StoreNamedColor
-XRequest.91:X_QueryColors
-XRequest.92:X_LookupColor
-XRequest.93:X_CreateCursor
-XRequest.94:X_CreateGlyphCursor
-XRequest.95:X_FreeCursor
-XRequest.96:X_RecolorCursor
-XRequest.97:X_QueryBestSize
-XRequest.98:X_QueryExtension
-XRequest.99:X_ListExtensions
-XRequest.100:X_ChangeKeyboardMapping
-XRequest.101:X_GetKeyboardMapping
-XRequest.102:X_ChangeKeyboardControl
-XRequest.103:X_GetKeyboardControl
-XRequest.104:X_Bell
-XRequest.105:X_ChangePointerControl
-XRequest.106:X_GetPointerControl
-XRequest.107:X_SetScreenSaver
-XRequest.108:X_GetScreenSaver
-XRequest.109:X_ChangeHosts
-XRequest.110:X_ListHosts
-XRequest.111:X_SetAccessControl
-XRequest.112:X_SetCloseDownMode
-XRequest.113:X_KillClient
-XRequest.114:X_RotateProperties
-XRequest.115:X_ForceScreenSaver
-XRequest.116:X_SetPointerMapping
-XRequest.117:X_GetPointerMapping
-XRequest.118:X_SetModifierMapping
-XRequest.119:X_GetModifierMapping
-XRequest.127:X_NoOperation
-! X Error Codes
-XProtoError.0: unknown error code 0
-XProtoError.1: BadRequest (invalid request code or no such operation)
-XProtoError.2: BadValue (integer parameter out of range for operation)
-XProtoError.3: BadWindow (invalid Window parameter)
-XProtoError.4: BadPixmap (invalid Pixmap parameter)
-XProtoError.5: BadAtom (invalid Atom parameter)
-XProtoError.6: BadCursor (invalid Cursor parameter)
-XProtoError.7: BadFont (invalid Font parameter)
-XProtoError.8: BadMatch (invalid parameter attributes)
-XProtoError.9: BadDrawable (invalid Pixmap or Window parameter)
-XProtoError.10: BadAccess (attempt to access private resource denied)
-XProtoError.11: BadAlloc (insufficient resources for operation)
-XProtoError.12: BadColor (invalid Colormap parameter)
-XProtoError.13: BadGC (invalid GC parameter)
-XProtoError.14: BadIDChoice (invalid resource ID chosen for this connection)
-XProtoError.15: BadName (named color or font does not exist)
-XProtoError.16: BadLength (poly request too large or internal Xlib length error)
-XProtoError.17: BadImplementation (server does not implement operation)
-! Multi-Buffering extension, not an X Consortium standard
-XRequest.Multi-Buffering.0: X_MbufGetBufferVersion
-XRequest.Multi-Buffering.1: X_MbufCreateImageBuffers
-XRequest.Multi-Buffering.2: X_MbufDestroyImageBuffers
-XRequest.Multi-Buffering.3: X_MbufDisplayImageBuffers
-XRequest.Multi-Buffering.4: X_MbufSetMultiBufferAttributes
-XRequest.Multi-Buffering.5: X_MbufGetMultiBufferAttributes
-XRequest.Multi-Buffering.6: X_MbufSetBufferAttributes
-XRequest.Multi-Buffering.7: X_MbufGetBufferAttributes
-XRequest.Multi-Buffering.8: X_MbufGetBufferInfo
-XRequest.Multi-Buffering.9: X_MbufCreateStereoWindow
-XProtoError.Multi-Buffering.0: BadBuffer (invalid Buffer parameter)
-XlibMessage.Multi-Buffering.0: Buffer id in failed request: 0x%lx
-! SHAPE extension, an X Consortium standard
-XRequest.SHAPE.0: X_ShapeQueryVersion
-XRequest.SHAPE.1: X_ShapeRectangles
-XRequest.SHAPE.2: X_ShapeMask
-XRequest.SHAPE.3: X_ShapeCombine
-XRequest.SHAPE.4: X_ShapeOffset
-XRequest.SHAPE.5: X_ShapeQueryExtents
-XRequest.SHAPE.6: X_ShapeSelectInput
-XRequest.SHAPE.7: X_ShapeInputSelected
-XRequest.SHAPE.8: X_ShapeGetRectangles
-! Input extension, an X Consortium standard
-XRequest.XInputExtension.1:X_GetExtensionVersion
-XRequest.XInputExtension.2:X_ListInputDevices
-XRequest.XInputExtension.3:X_OpenDevice
-XRequest.XInputExtension.4:X_CloseDevice
-XRequest.XInputExtension.5:X_SetDeviceMode
-XRequest.XInputExtension.6:X_SelectExtensionEvent
-XRequest.XInputExtension.7:X_GetSelectedExtensionEvents
-XRequest.XInputExtension.8:X_ChangeDeviceDontPropagateList
-XRequest.XInputExtension.9:X_GetDeviceDontPropagateList
-XRequest.XInputExtension.10:X_GetDeviceMotionEvents
-XRequest.XInputExtension.11:X_ChangeKeyboardDevice
-XRequest.XInputExtension.12:X_ChangePointerDevice
-XRequest.XInputExtension.13:X_GrabDevice
-XRequest.XInputExtension.14:X_UngrabDevice
-XRequest.XInputExtension.15:X_GrabDeviceKey
-XRequest.XInputExtension.16:X_UngrabDeviceKey
-XRequest.XInputExtension.17:X_GrabDeviceButton
-XRequest.XInputExtension.18:X_UngrabDeviceButton
-XRequest.XInputExtension.19:X_AllowDeviceEvents
-XRequest.XInputExtension.20:X_GetDeviceFocus
-XRequest.XInputExtension.21:X_SetDeviceFocus
-XRequest.XInputExtension.22:X_GetFeedbackControl
-XRequest.XInputExtension.23:X_ChangeFeedbackControl
-XRequest.XInputExtension.24:X_GetDeviceKeyMapping
-XRequest.XInputExtension.25:X_ChangeDeviceKeyMapping
-XRequest.XInputExtension.26:X_GetDeviceModifierMapping
-XRequest.XInputExtension.27:X_SetDeviceModifierMapping
-XRequest.XInputExtension.28:X_GetDeviceButtonMapping
-XRequest.XInputExtension.29:X_SetDeviceButtonMapping
-XRequest.XInputExtension.30:X_QueryDeviceState
-XRequest.XInputExtension.31:X_SendExtensionEvent
-XRequest.XInputExtension.32:X_DeviceBell
-XRequest.XInputExtension.33:X_SetDeviceValuators
-XRequest.XInputExtension.34:X_GetDeviceControl
-XRequest.XInputExtension.35:X_ChangeDeviceControl
-XRequest.XInputExtension.36: X_ListDeviceProperties
-XRequest.XInputExtension.37: X_ChangeDeviceProperty
-XRequest.XInputExtension.38: X_DeleteDeviceProperty
-XRequest.XInputExtension.39: X_GetDeviceProperty
-XProtoError.XInputExtension.0: XI_BadDevice (invalid Device parameter)
-XlibMessage.XInputExtension.0: Device id in failed request: 0x%lx
-XProtoError.XInputExtension.1: XI_BadEvent (invalid Event parameter)
-XlibMessage.XInputExtension.1: Event id in failed request: 0x%lx
-XProtoError.XInputExtension.2: XI_BadMode (invalid Mode parameter)
-XlibMessage.XInputExtension.2: Mode id in failed request: 0x%lx
-XProtoError.XInputExtension.3: XI_DeviceBusy
-XlibMessage.XInputExtension.3: Device id in failed request: 0x%lx
-XProtoError.XInputExtension.4: XI_BadClass (invalid Class parameter)
-XlibMessage.XInputExtension.4: Class id in failed request: 0x%lx
-! MIT-SHM extension, experimental, not an X Consortium standard
-XRequest.MIT-SHM.0: X_ShmQueryVersion
-XRequest.MIT-SHM.1: X_ShmAttach
-XRequest.MIT-SHM.2: X_ShmDetach
-XRequest.MIT-SHM.3: X_ShmPutImage
-XRequest.MIT-SHM.4: X_ShmGetImage
-XRequest.MIT-SHM.5: X_ShmCreatePixmap
-XProtoError.MIT-SHM.0: BadShmSeg (invalid shared segment parameter)
-XlibMessage.MIT-SHM.0: Segment id in failed request: 0x%lx
-! MIT-SUNDRY-NONSTANDARD extension, definitely not an X Consortium standard
-XRequest.MIT-SUNDRY-NONSTANDARD.0: X_MITSetBugMode
-XRequest.MIT-SUNDRY-NONSTANDARD.1: X_MITGetBugMode
-! X3D-PEX extension
-XRequest.X3D-PEX.1: PEX_GetExtensionInfo
-XRequest.X3D-PEX.2: PEX_GetEnumeratedTypeInfo
-XRequest.X3D-PEX.3: PEX_GetImpDepConstants
-XRequest.X3D-PEX.4: PEX_CreateLookupTable
-XRequest.X3D-PEX.5: PEX_CopyLookupTable
-XRequest.X3D-PEX.6: PEX_FreeLookupTable
-XRequest.X3D-PEX.7: PEX_GetTableInfo
-XRequest.X3D-PEX.8: PEX_GetPredefinedEntries
-XRequest.X3D-PEX.9: PEX_GetDefinedIndices
-XRequest.X3D-PEX.10: PEX_GetTableEntry
-XRequest.X3D-PEX.11: PEX_GetTableEntries
-XRequest.X3D-PEX.12: PEX_SetTableEntries
-XRequest.X3D-PEX.13: PEX_DeleteTableEntries
-XRequest.X3D-PEX.14: PEX_CreatePipelineContext
-XRequest.X3D-PEX.15: PEX_CopyPipelineContext
-XRequest.X3D-PEX.16: PEX_FreePipelineContext
-XRequest.X3D-PEX.17: PEX_GetPipelineContext
-XRequest.X3D-PEX.18: PEX_ChangePipelineContext
-XRequest.X3D-PEX.19: PEX_CreateRenderer
-XRequest.X3D-PEX.20: PEX_FreeRenderer
-XRequest.X3D-PEX.21: PEX_ChangeRenderer
-XRequest.X3D-PEX.22: PEX_GetRendererAttributes
-XRequest.X3D-PEX.23: PEX_GetRendererDynamics
-XRequest.X3D-PEX.24: PEX_BeginRendering
-XRequest.X3D-PEX.25: PEX_EndRendering
-XRequest.X3D-PEX.26: PEX_BeginStructure
-XRequest.X3D-PEX.27: PEX_EndStructure
-XRequest.X3D-PEX.28: PEX_RenderOutputCommands
-XRequest.X3D-PEX.29: PEX_RenderNetwork
-XRequest.X3D-PEX.30: PEX_CreateStructure
-XRequest.X3D-PEX.31: PEX_CopyStructure
-XRequest.X3D-PEX.32: PEX_DestroyStructures
-XRequest.X3D-PEX.33: PEX_GetStructureInfo
-XRequest.X3D-PEX.34: PEX_GetElementInfo
-XRequest.X3D-PEX.35: PEX_GetStructuresInNetwork
-XRequest.X3D-PEX.36: PEX_GetAncestors
-XRequest.X3D-PEX.37: PEX_GetDescendants
-XRequest.X3D-PEX.38: PEX_FetchElements
-XRequest.X3D-PEX.39: PEX_SetEditingMode
-XRequest.X3D-PEX.40: PEX_SetElementPointer
-XRequest.X3D-PEX.41: PEX_SetElementPointerAtLabel
-XRequest.X3D-PEX.42: PEX_ElementSearch
-XRequest.X3D-PEX.43: PEX_StoreElements
-XRequest.X3D-PEX.44: PEX_DeleteElements
-XRequest.X3D-PEX.45: PEX_DeleteElementsToLabel
-XRequest.X3D-PEX.46: PEX_DeleteBetweenLabels
-XRequest.X3D-PEX.47: PEX_CopyElements
-XRequest.X3D-PEX.48: PEX_ChangeStructureRefs
-XRequest.X3D-PEX.49: PEX_CreateNameSet
-XRequest.X3D-PEX.50: PEX_CopyNameSet
-XRequest.X3D-PEX.51: PEX_FreeNameSet
-XRequest.X3D-PEX.52: PEX_GetNameSet
-XRequest.X3D-PEX.53: PEX_ChangeNameSet
-XRequest.X3D-PEX.54: PEX_CreateSearchContext
-XRequest.X3D-PEX.55: PEX_CopySearchContext
-XRequest.X3D-PEX.56: PEX_FreeSearchContext
-XRequest.X3D-PEX.57: PEX_GetSearchContext
-XRequest.X3D-PEX.58: PEX_ChangeSearchContext
-XRequest.X3D-PEX.59: PEX_SearchNetwork
-XRequest.X3D-PEX.60: PEX_CreatePhigsWks
-XRequest.X3D-PEX.61: PEX_FreePhigsWks
-XRequest.X3D-PEX.62: PEX_GetWksInfo
-XRequest.X3D-PEX.63: PEX_GetDynamics
-XRequest.X3D-PEX.64: PEX_GetViewRep
-XRequest.X3D-PEX.65: PEX_RedrawAllStructures
-XRequest.X3D-PEX.66: PEX_UpdateWorkstation
-XRequest.X3D-PEX.67: PEX_RedrawClipRegion
-XRequest.X3D-PEX.68: PEX_ExecuteDeferredActions
-XRequest.X3D-PEX.69: PEX_SetViewPriority
-XRequest.X3D-PEX.70: PEX_SetDisplayUpdateMode
-XRequest.X3D-PEX.71: PEX_MapDCtoWC
-XRequest.X3D-PEX.72: PEX_MapWCtoDC
-XRequest.X3D-PEX.73: PEX_SetViewRep
-XRequest.X3D-PEX.74: PEX_SetWksWindow
-XRequest.X3D-PEX.75: PEX_SetWksViewport
-XRequest.X3D-PEX.76: PEX_SetHlhsrMode
-XRequest.X3D-PEX.77: PEX_SetWksBufferMode
-XRequest.X3D-PEX.78: PEX_PostStructure
-XRequest.X3D-PEX.79: PEX_UnpostStructure
-XRequest.X3D-PEX.80: PEX_UnpostAllStructures
-XRequest.X3D-PEX.81: PEX_GetWksPostings
-XRequest.X3D-PEX.82: PEX_GetPickDevice
-XRequest.X3D-PEX.83: PEX_ChangePickDevice
-XRequest.X3D-PEX.84: PEX_CreatePickMeasure
-XRequest.X3D-PEX.85: PEX_FreePickMeasure
-XRequest.X3D-PEX.86: PEX_GetPickMeasure
-XRequest.X3D-PEX.87: PEX_UpdatePickMeasure
-XRequest.X3D-PEX.88: PEX_OpenFont
-XRequest.X3D-PEX.89: PEX_CloseFont
-XRequest.X3D-PEX.90: PEX_QueryFont
-XRequest.X3D-PEX.91: PEX_ListFonts
-XRequest.X3D-PEX.92: PEX_ListFontsWithInfo
-XRequest.X3D-PEX.93: PEX_QueryTextExtents
-XRequest.X3D-PEX.94: PEX_MatchRenderingTargets
-XRequest.X3D-PEX.95: PEX_Escape
-XRequest.X3D-PEX.96: PEX_EscapeWithReply
-XRequest.X3D-PEX.97: PEX_RenderElements
-XRequest.X3D-PEX.98: PEX_AccumulateState
-XRequest.X3D-PEX.99: PEX_BeginPickOne
-XRequest.X3D-PEX.100: PEX_EndPickOne
-XRequest.X3D-PEX.101: PEX_PickOne
-XRequest.X3D-PEX.102: PEX_BeginPickAll
-XRequest.X3D-PEX.103: PEX_EndPickAll
-XRequest.X3D-PEX.104: PEX_PickAll
-XProtoError.X3D-PEX.0: PEXColorTypeError
-XlibMessage.X3D-PEX.0: Color type in failed request: 0x%lx
-XProtoError.X3D-PEX.1: PEXRendererStateError
-XlibMessage.X3D-PEX.1: Renderer id in failed request: 0x%lx
-XProtoError.X3D-PEX.2: PEXFloatingPointFormatError
-XlibMessage.X3D-PEX.2: Format in failed request: 0x%lx
-XProtoError.X3D-PEX.3: PEXLabelError
-XlibMessage.X3D-PEX.3: Label in failed request: 0x%lx
-XProtoError.X3D-PEX.4: PEXLookupTableError
-XlibMessage.X3D-PEX.4: Table id in failed request: 0x%lx
-XProtoError.X3D-PEX.5: PEXNameSetError
-XlibMessage.X3D-PEX.5: Nameset in failed request: 0x%lx
-XProtoError.X3D-PEX.6: PEXPathError
-XlibMessage.X3D-PEX.6: Path id in failed request: 0x%lx
-XProtoError.X3D-PEX.7: PEXFontError
-XlibMessage.X3D-PEX.7: Font id in failed request: 0x%lx
-XProtoError.X3D-PEX.8: PEXPhigsWksError
-XlibMessage.X3D-PEX.8: Workstation id in failed request: 0x%lx
-XProtoError.X3D-PEX.9: PEXPickMeasureError
-XlibMessage.X3D-PEX.9: Device id in failed request: 0x%lx
-XProtoError.X3D-PEX.10: PEXPipelineContextError
-XlibMessage.X3D-PEX.10: Context id in failed request: 0x%lx
-XProtoError.X3D-PEX.11: PEXRendererError
-XlibMessage.X3D-PEX.11: Renderer id in failed request: 0x%lx
-XProtoError.X3D-PEX.12: PEXSearchContextError
-XlibMessage.X3D-PEX.12: Context id in failed request: 0x%lx
-XProtoError.X3D-PEX.13: PEXStructureError
-XlibMessage.X3D-PEX.13: Structure id in failed request: 0x%lx
-XProtoError.X3D-PEX.14: PEXOutputCommandError
-XlibMessage.X3D-PEX.14: Resource id in failed request: 0x%lx
-! XTEST extension, an X Consortium standard
-XRequest.XTEST.0: X_XTestGetVersion
-XRequest.XTEST.1: X_XTestCompareCursor
-XRequest.XTEST.2: X_XTestFakeInput
-XRequest.XTEST.3: X_XTestGrabControl
-! BIG-REQUESTS extension, an X Consortium standard
-XRequest.BIG-REQUESTS.0: X_BigReqEnable
-! XIE extension, an X Consortium standard
-XRequest.XIE.1: XIE_QueryImageExtension
-XRequest.XIE.2: XIE_QueryTechniques
-XRequest.XIE.3: XIE_CreateColorList
-XRequest.XIE.4: XIE_DestroyColorList
-XRequest.XIE.5: XIE_PurgeColorList
-XRequest.XIE.6: XIE_QueryColorList
-XRequest.XIE.7: XIE_CreateLUT
-XRequest.XIE.8: XIE_DestroyLUT
-XRequest.XIE.9: XIE_CreatePhotomap
-XRequest.XIE.10: XIE_DestroyPhotomap
-XRequest.XIE.11: XIE_QueryPhotomap
-XRequest.XIE.12: XIE_CreateROI
-XRequest.XIE.13: XIE_DestroyROI
-XRequest.XIE.14: XIE_CreatePhotospace
-XRequest.XIE.15: XIE_DestroyPhotospace
-XRequest.XIE.16: XIE_ExecuteImmediate
-XRequest.XIE.17: XIE_CreatePhotoflo
-XRequest.XIE.18: XIE_DestroyPhotoflo
-XRequest.XIE.19: XIE_ExecutePhotoflo
-XRequest.XIE.20: XIE_ModifyPhotoflo
-XRequest.XIE.21: XIE_RedefinePhotoflo
-XRequest.XIE.22: XIE_PutClientData
-XRequest.XIE.23: XIE_GetClientData
-XRequest.XIE.24: XIE_QueryPhotoflo
-XRequest.XIE.25: XIE_Await
-XRequest.XIE.26: XIE_Abort
-XProtoError.XIE.0: XIE_ColorListError
-XlibMessage.XIE.0: ColorList in failed request: 0x%lx
-XProtoError.XIE.1: XIE_LUTError
-XlibMessage.XIE.1: LUT in failed request: 0x%lx
-XProtoError.XIE.2: XIE_PhotofloError
-XlibMessage.XIE.2: Photoflo in failed request: 0x%lx
-XProtoError.XIE.3: XIE_PhotomapError
-XlibMessage.XIE.3: Photomap in failed request: 0x%lx
-XProtoError.XIE.4: XIE_PhotospaceError
-XlibMessage.XIE.4: Photospace in failed request: 0x%lx
-XProtoError.XIE.5: XIE_ROIError
-XlibMessage.XIE.5: ROI in failed request: 0x%lx
-XProtoError.XIE.6: XIE_FloError
-XlibMessage.XIE.6: Photoflo in failed request: 0x%lx
-! SYNC extension, an X Consortium standard
-XRequest.SYNC.0: X_SyncInitialize
-XRequest.SYNC.1: X_SyncListSystemCounters
-XRequest.SYNC.2: X_SyncCreateCounter
-XRequest.SYNC.3: X_SyncSetCounter
-XRequest.SYNC.4: X_SyncChangeCounter
-XRequest.SYNC.5: X_SyncQueryCounter
-XRequest.SYNC.6: X_SyncDestroyCounter
-XRequest.SYNC.7: X_SyncAwait
-XRequest.SYNC.8: X_SyncCreateAlarm
-XRequest.SYNC.9: X_SyncChangeAlarm
-XRequest.SYNC.10: X_SyncQueryAlarm
-XRequest.SYNC.11: X_SyncDestroyAlarm
-XRequest.SYNC.12: X_SyncSetPriority
-XRequest.SYNC.13: X_SyncGetPriority
-XProtoError.SYNC.0: XSyncBadCounter
-XlibMessage.SYNC.0: Counter in failed request: 0x%lx
-XProtoError.SYNC.1: XSyncBadAlarm
-XlibMessage.SYNC.1: Alarm in failed request: 0x%lx
-! XKB extension
-XRequest.XKEYBOARD.0: XkbUseExtension
-XRequest.XKEYBOARD.1: XkbSelectEvents
-XRequest.XKEYBOARD.2: OBSOLETE
-XRequest.XKEYBOARD.3: XkbBell
-XRequest.XKEYBOARD.4: XkbGetState
-XRequest.XKEYBOARD.5: XkbLatchLockState
-XRequest.XKEYBOARD.6: XkbGetControls
-XRequest.XKEYBOARD.7: XkbSetControls
-XRequest.XKEYBOARD.8: XkbGetMap
-XRequest.XKEYBOARD.9: XkbSetMap
-XRequest.XKEYBOARD.10: XkbGetCompatMap
-XRequest.XKEYBOARD.11: XkbSetCompatMap
-XRequest.XKEYBOARD.12: XkbGetIndicatorState
-XRequest.XKEYBOARD.13: XkbGetIndicatorMap
-XRequest.XKEYBOARD.14: XkbSetIndicatorMap
-XRequest.XKEYBOARD.15: XkbGetNamedIndicator
-XRequest.XKEYBOARD.16: XkbSetNamedIndicator
-XRequest.XKEYBOARD.17: XkbGetNames
-XRequest.XKEYBOARD.18: XkbSetNames
-XRequest.XKEYBOARD.19: XkbGetGeometry
-XRequest.XKEYBOARD.20: XkbSetGeometry
-XRequest.XKEYBOARD.21: XkbPerClientFlags
-XRequest.XKEYBOARD.22: XkbListComponents
-XRequest.XKEYBOARD.23: XkbGetKbdByName
-XRequest.XKEYBOARD.24: XkbGetDeviceInfo
-XRequest.XKEYBOARD.25: XkbSetDeviceInfo
-XRequest.XKEYBOARD.101: XkbSetDebuggingFlags
-XProtoError.XKEYBOARD.0: XkbBadKeyboard
-XlibMessage.XKEYBOARD.0: Device id in failed request: 0x%lx
-! GLX extension for OpenGL, an OpenGL Architectural Review Board standard
-! GLX Commands
-XRequest.GLX.7: X_GLXQueryVersion
-XRequest.GLX.3: X_GLXCreateContext
-XRequest.GLX.4: X_GLXDestroyContext
-XRequest.GLX.5: X_GLXMakeCurrent
-XRequest.GLX.6: X_GLXIsDirect
-XRequest.GLX.10: X_GLXCopyContext
-XRequest.GLX.8: X_GLXWaitGL
-XRequest.GLX.9: X_GLXWaitX
-XRequest.GLX.11: X_GLXSwapBuffers
-XRequest.GLX.12: X_GLXUseXFont
-XRequest.GLX.13: X_GLXCreateGLXPixmap
-XRequest.GLX.15: X_GLXDestroyGLXPixmap
-XRequest.GLX.14: X_GLXGetVisualConfigs
-XRequest.GLX.16: X_GLXVendorPrivate
-XRequest.GLX.17: X_GLXVendorPrivateWithReply
-XRequest.GLX.18: X_GLXQueryExtensionsString
-XRequest.GLX.19: X_GLXQueryServerString
-XRequest.GLX.20: X_GLXClientInfo
-XRequest.GLX.21: X_GLXGetFBConfigs
-XRequest.GLX.22: X_GLXCreatePixmap
-XRequest.GLX.23: X_GLXDestroyPixmap
-XRequest.GLX.24: X_GLXCreateNewContext
-XRequest.GLX.25: X_GLXQueryContext
-XRequest.GLX.26: X_GLXMakeContextCurrent
-XRequest.GLX.27: X_GLXCreatePbuffer
-XRequest.GLX.28: X_GLXDestroyPbuffer
-XRequest.GLX.29: X_GLXGetDrawableAttributes
-XRequest.GLX.30: X_GLXChangeDrawableAttributes
-XRequest.GLX.31: X_GLXCreateWindow
-XRequest.GLX.32: X_GLXDestroyWindow
-! GL Non-rendering Commands
-XRequest.GLX.103: X_GLXDeleteLists
-XRequest.GLX.102: X_GLXEndList
-XRequest.GLX.105: X_GLXFeedbackBuffer
-XRequest.GLX.108: X_GLXFinish
-XRequest.GLX.142: X_GLXFlush
-XRequest.GLX.104: X_GLXGenLists
-XRequest.GLX.112: X_GLXGetBooleanv
-XRequest.GLX.113: X_GLXGetClipPlane
-XRequest.GLX.114: X_GLXGetDoublev
-XRequest.GLX.115: X_GLXGetError
-XRequest.GLX.116: X_GLXGetFloatv
-XRequest.GLX.117: X_GLXGetIntegerv
-XRequest.GLX.118: X_GLXGetLightfv
-XRequest.GLX.119: X_GLXGetLightiv
-XRequest.GLX.120: X_GLXGetMapdv
-XRequest.GLX.121: X_GLXGetMapfv
-XRequest.GLX.122: X_GLXGetMapiv
-XRequest.GLX.123: X_GLXGetMaterialfv
-XRequest.GLX.124: X_GLXGetMaterialiv
-XRequest.GLX.125: X_GLXGetPixelfv
-XRequest.GLX.126: X_GLXGetPixelMapuiv
-XRequest.GLX.127: X_GLXGetPixelMapusv
-XRequest.GLX.129: X_GLXGetString
-XRequest.GLX.130: X_GLXGetTexEnvfv
-XRequest.GLX.131: X_GLXGetTexEnviv
-XRequest.GLX.132: X_GLXGetTexGendv
-XRequest.GLX.133: X_GLXGetTexGenfv
-XRequest.GLX.134: X_GLXGetTexGeniv
-XRequest.GLX.138: X_GLXGetTexLevelParameterfv
-XRequest.GLX.139: X_GLXGetTexLevelParameteriv
-XRequest.GLX.136: X_GLXGetTexParameterfv
-XRequest.GLX.137: X_GLXGetTexParameteriv
-XRequest.GLX.140: X_GLXIsEnabled
-XRequest.GLX.141: X_GLXIsList
-XRequest.GLX.101: X_GLXNewList
-XRequest.GLX.109: X_GLXPixelStoref
-XRequest.GLX.110: X_GLXPixelStorei
-XRequest.GLX.107: X_GLXRenderMode
-XRequest.GLX.106: X_GLXSelectBuffer
-! GL Non-rendering Commands That Return Pixel Data
-XRequest.GLX.128: X_GLXGetPolygonStipple
-XRequest.GLX.135: X_GLXGetTexImage
-XRequest.GLX.111: X_GLXReadPixels
-! GL Rendering Commands
-XRequest.GLX.1: X_GLXRender
-XRequest.GLX.2: X_GLXRenderLarge
-! GLX Errors
-XProtoError.GLX.0: GLXBadContext
-XProtoError.GLX.1: GLXBadContextState
-XProtoError.GLX.2: GLXBadDrawable
-XProtoError.GLX.3: GLXBadPixmap
-XProtoError.GLX.4: GLXBadContextTag
-XProtoError.GLX.5: GLXBadCurrentWindow
-XProtoError.GLX.6: GLXBadRenderRequest
-XProtoError.GLX.7: GLXBadLargeRequest
-XProtoError.GLX.8: GLXUnsupportedPrivateRequest
-XProtoError.GLX.9: GLXBadFBConfig
-XProtoError.GLX.10: GLXBadPbuffer
-XProtoError.GLX.11: GLXBadCurrentDrawable
-XProtoError.GLX.12: GLXBadWindow
-! XC-MISC extension, an X Consortium standard
-XRequest.XC-MISC.0: XCMiscGetVersion
-XRequest.XC-MISC.1: XCMiscGetXIDRange
-! RECORD extension
-XRequest.RECORD.0: XRecordQueryVersion
-XRequest.RECORD.1: XRecordCreateContext
-XRequest.RECORD.2: XRecordRegisterClients
-XRequest.RECORD.3: XRecordUnregisterClients
-XRequest.RECORD.4: XRecordGetContext
-XRequest.RECORD.5: XRecordEnableContext
-XRequest.RECORD.6: XRecordDisableContext
-XRequest.RECORD.7: XRecordFreeContext
-XProtoError.RECORD.0: XRecordBadContext
-XlibMessage.RECORD.0: Context in failed request: 0x%lx
-! XFree86-VidModeExtension -- not an X Consortium standard
-XRequest.XFree86-VidModeExtension.0: XF86VidModeQueryVersion
-XRequest.XFree86-VidModeExtension.1: XF86VidModeGetModeLine
-XRequest.XFree86-VidModeExtension.2: XF86VidModeModModeLine
-XRequest.XFree86-VidModeExtension.3: XF86VidModeSwitchMode
-XRequest.XFree86-VidModeExtension.4: XF86VidModeGetMonitor
-XRequest.XFree86-VidModeExtension.5: XF86VidModeLockModeSwitch
-XRequest.XFree86-VidModeExtension.6: XF86VidModeGetAllModeLines
-XRequest.XFree86-VidModeExtension.7: XF86VidModeAddModeLine
-XRequest.XFree86-VidModeExtension.8: XF86VidModeDeleteModeLine
-XRequest.XFree86-VidModeExtension.9: XF86VidModeValidateModeLine
-XRequest.XFree86-VidModeExtension.10: XF86VidModeSwitchToMode
-XRequest.XFree86-VidModeExtension.11: XF86VidModeGetViewPort
-XRequest.XFree86-VidModeExtension.12: XF86VidModeSetViewPort
-XRequest.XFree86-VidModeExtension.13: XF86VidModeGetDotClocks
-XRequest.XFree86-VidModeExtension.14: XF86VidModeSetClientVersion
-XRequest.XFree86-VidModeExtension.15: XF86VidModeSetGamma
-XRequest.XFree86-VidModeExtension.16: XF86VidModeGetGamma
-XRequest.XFree86-VidModeExtension.17: XF86VidModeGetGammaRamp
-XRequest.XFree86-VidModeExtension.18: XF86VidModeSetGammaRamp
-XRequest.XFree86-VidModeExtension.19: XF86VidModeGetGammaRampSize
-XRequest.XFree86-VidModeExtension.20: XF86VidModeGetPermissions
-XProtoError.XFree86-VidModeExtension.0: XF86VidModeBadClock
-XProtoError.XFree86-VidModeExtension.1: XF86VidModeBadHTimings
-XProtoError.XFree86-VidModeExtension.2: XF86VidModeBadVTimings
-XProtoError.XFree86-VidModeExtension.3: XF86VidModeModeUnsuitable
-XProtoError.XFree86-VidModeExtension.4: XF86VidModeExtensionDisabled
-XProtoError.XFree86-VidModeExtension.5: XF86VidModeClientNotLocal
-XProtoError.XFree86-VidModeExtension.6: XF86VidModeZoomLocked
-! XFree86-Misc -- not an X Consortium standard
-XRequest.XFree86-Misc.0: XF86MiscQueryVersion
-XRequest.XFree86-Misc.1: XF86MiscGetSaver
-XRequest.XFree86-Misc.2: XF86MiscSetSaver
-XRequest.XFree86-Misc.3: XF86MiscGetMouseSettings
-XRequest.XFree86-Misc.4: XF86MiscGetKbdSettings
-XRequest.XFree86-Misc.5: XF86MiscSetMouseSettings
-XRequest.XFree86-Misc.6: XF86MiscSetKbdSettings
-XRequest.XFree86-Misc.7: XF86MiscSetGrabKeysState
-XRequest.XFree86-Misc.8: XF86MiscSetClientVersion
-XRequest.XFree86-Misc.9: XF86MiscGetFilePaths
-XProtoError.XFree86-Misc.0: XF86MiscBadMouseProtocol
-XProtoError.XFree86-Misc.1: XF86MiscBadMouseBaudRate
-XProtoError.XFree86-Misc.2: XF86MiscBadMouseFlags
-XProtoError.XFree86-Misc.3: XF86MiscBadMouseCombo
-XProtoError.XFree86-Misc.4: XF86MiscBadKbdType
-XProtoError.XFree86-Misc.5: XF86MiscModInDevDisabled
-XProtoError.XFree86-Misc.6: XF86MiscModInDevClientNotLocal
-XProtoError.XFree86-Misc.7: XF86MiscNoModule
-! XFree86-DGA -- not an X Consortium standard
-XRequest.XFree86-DGA.0: XF86DGAQueryVersion
-XRequest.XFree86-DGA.1: XF86DGAGetVideoLL
-XRequest.XFree86-DGA.2: XF86DGADirectVideo
-XRequest.XFree86-DGA.3: XF86DGAGetViewPortSize
-XRequest.XFree86-DGA.4: XF86DGASetViewPort
-XRequest.XFree86-DGA.5: XF86DGAGetVidPage
-XRequest.XFree86-DGA.6: XF86DGASetVidPage
-XRequest.XFree86-DGA.7: XF86DGAInstallColormap
-XRequest.XFree86-DGA.8: XF86DGAQueryDirectVideo
-XRequest.XFree86-DGA.9: XF86DGAViewPortChanged
-XRequest.XFree86-DGA.10: XF86DGAObsolete1
-XRequest.XFree86-DGA.11: XF86DGAObsolete2
-XRequest.XFree86-DGA.12: XDGAQueryModes
-XRequest.XFree86-DGA.13: XDGASetMode
-XRequest.XFree86-DGA.14: XDGASetViewport
-XRequest.XFree86-DGA.15: XDGAInstallColormap
-XRequest.XFree86-DGA.16: XDGASelectInput
-XRequest.XFree86-DGA.17: XDGAFillRectangle
-XRequest.XFree86-DGA.18: XDGACopyArea
-XRequest.XFree86-DGA.19: XDGACopyTransparentArea
-XRequest.XFree86-DGA.20: XDGAGetViewportStatus
-XRequest.XFree86-DGA.21: XDGASync
-XRequest.XFree86-DGA.22: XDGAOpenFramebuffer
-XRequest.XFree86-DGA.23: XDGACloseFramebuffer
-XRequest.XFree86-DGA.24: XDGASetClientVersion
-XRequest.XFree86-DGA.25: XDGAChangePixmapMode
-XRequest.XFree86-DGA.26: XDGACreateColormap
-XProtoError.XFree86-DGA.0: XF86DGAClientNotLocal
-XProtoError.XFree86-DGA.1: XF86DGANoDirectVideoMode
-XProtoError.XFree86-DGA.2: XF86DGAScreenNotActive
-XProtoError.XFree86-DGA.3: XF86DGADirectNotActivated
-XProtoError.XFree86-DGA.4: XF86DGAOperationNotSupported
-! DOUBLE-BUFFER (DBE), an X Consortium standard
-XRequest.DOUBLE-BUFFER.0: DBEGetVersion
-XRequest.DOUBLE-BUFFER.1: DBEAllocateBackBufferName
-XRequest.DOUBLE-BUFFER.2: DBEDeallocateBackBufferName
-XRequest.DOUBLE-BUFFER.3: DBESwapBuffers
-XRequest.DOUBLE-BUFFER.4: DBEBeginIdiom
-XRequest.DOUBLE-BUFFER.5: DBEEndIdiom
-XRequest.DOUBLE-BUFFER.6: DBEGetVisualInfo
-XRequest.DOUBLE-BUFFER.7: DBEGetBackBufferAttributes
-XProtoError.DOUBLE-BUFFER.0: DBEBadBuffer (invalid BackBuffer parameter)
-XlibMessage.DOUBLE-BUFFER.0: BackBuffer in failed request: 0x%lx
-! SECURITY
-XRequest.SECURITY.0: SecurityQueryVersion
-XRequest.SECURITY.1: SecurityGenerateAuthorization
-XProtoError.SECURITY.0: SecurityBadAuthorization (invalid authorization id)
-XProtoError.SECURITY.1: SecurityBadAuthorizationProtocol (invalid authorization name or data)
-XlibMessage.SECURITY.1: authorization id in failed request: 0x%lx
-! AppGroup
-XRequest.APPGROUP.0: XagQueryVersion
-XRequest.APPGROUP.1: XagCreate
-XRequest.APPGROUP.2: XagDestroy
-XRequest.APPGROUP.3: XagGetAttr
-XRequest.APPGROUP.4: XagQuery
-XRequest.APPGROUP.5: XagCreateAssoc
-XRequest.APPGROUP.6: XagDestroyAssoc
-XProtoError.APPGROUP.0: XagBadAppGroup (invalid AppGroup parameter)
-! LBX
-XRequest.LBX.0: LbxQueryVersion
-XRequest.LBX.1: LbxStartProxy
-XRequest.LBX.2: LbxStopProxy
-XRequest.LBX.3: LbxSwitch
-XRequest.LBX.4: LbxNewClient
-XRequest.LBX.5: LbxCloseClient
-XRequest.LBX.6: LbxModifySequence
-XRequest.LBX.7: LbxAllowMotion
-XRequest.LBX.8: LbxIncrementPixel
-XRequest.LBX.9: LbxDelta
-XRequest.LBX.10: LbxGetModifierMapping
-XRequest.LBX.11: LbxQueryTag
-XRequest.LBX.12: LbxInvalidateTag
-XRequest.LBX.13: LbxPolyPoint
-XRequest.LBX.14: LbxPolyLine
-XRequest.LBX.15: LbxPolySegment
-XRequest.LBX.16: LbxPolyRectangle
-XRequest.LBX.17: LbxPolyArc
-XRequest.LBX.18: LbxFillPoly
-XRequest.LBX.19: LbxPolyFillRectangle
-XRequest.LBX.20: LbxPolyFillArc
-XRequest.LBX.21: LbxGetKeyboardMapping
-XRequest.LBX.22: LbxQueryFont
-XRequest.LBX.23: LbxChangeProperty
-XRequest.LBX.24: LbxGetProperty
-XRequest.LBX.25: LbxTagData
-XRequest.LBX.26: LbxCopyArea
-XRequest.LBX.27: LbxCopyPlane
-XRequest.LBX.28: LbxPolyText8
-XRequest.LBX.29: LbxPolyText16
-XRequest.LBX.30: LbxImageText8
-XRequest.LBX.31: LbxImageText16
-XRequest.LBX.32: LbxQueryExtension
-XRequest.LBX.33: LbxPutImage
-XRequest.LBX.34: LbxGetImage
-XRequest.LBX.35: LbxBeginLargeRequest
-XRequest.LBX.36: LbxLargeRequestData
-XRequest.LBX.37: LbxEndLargeRequest
-XRequest.LBX.38: LbxInternAtoms
-XRequest.LBX.39: LbxGetWinAttrAndGeom
-XRequest.LBX.40: LbxGrabCmap
-XRequest.LBX.41: LbxReleaseCmap
-XRequest.LBX.42: LbxAllocColor
-XRequest.LBX.43: LbxSync
-XProtoError.LBX.0: BadLbxClient
-! XpExtension
-XRequest.XpExtension.0: PrintQueryVersion
-XRequest.XpExtension.1: PrintGetPrinterList
-XRequest.XpExtension.2: PrintCreateContext
-XRequest.XpExtension.3: PrintSetContext
-XRequest.XpExtension.4: PrintGetContext
-XRequest.XpExtension.5: PrintDestroyContext
-XRequest.XpExtension.6: PrintGetContextScreen
-XRequest.XpExtension.7: PrintStartJob
-XRequest.XpExtension.8: PrintEndJob
-XRequest.XpExtension.9: PrintStartDoc
-XRequest.XpExtension.10: PrintEndDoc
-XRequest.XpExtension.11: PrintPutDocumentData
-XRequest.XpExtension.12: PrintGetDocumentData
-XRequest.XpExtension.13: PrintStartPage
-XRequest.XpExtension.14: PrintEndPage
-XRequest.XpExtension.15: PrintSelectInput
-XRequest.XpExtension.16: PrintInputSelected
-XRequest.XpExtension.17: PrintGetAttributes
-XRequest.XpExtension.18: PrintSetAttributes
-XRequest.XpExtension.19: PrintGetOneAttribute
-XRequest.XpExtension.20: PrintRehashPrinterList
-XRequest.XpExtension.21: PrintGetPageDimensions
-XRequest.XpExtension.22: PrintQueryScreens
-XRequest.XpExtension.23: PrintSetImageResolution
-XRequest.XpExtension.24: PrintGetImageResolution
-XProtoError.XpExtension.0: XPBadContext (Print Context invalid or missing)
-XlibMessage.XpExtension.0: Context in failed request: 0x%lx
-XProtoError.XpExtension.1: XPBadSequence (Illegal sequence of XP operations)
-XProtoError.XpExtension.2: XPBadResourceID (X resource not valid)
-! TOG-CUP, an X Project Team specification
-XRequest.TOG-CUP.0: CUPQueryVersion
-XRequest.TOG-CUP.1: CUPGetReservedColormapEntries
-XRequest.TOG-CUP.2: CUPStoreColors
-! Extended-Visual-Information, an X Project Team specification
-XRequest.Extended-Visual-Information.0: EVIQueryVersion
-XRequest.Extended-Visual-Information.1: EVIGetVisualInfo
-! DPMS (Display Power Management Signaling), an X Project Team specification
-XRequest.DPMS.0: DPMSGetVersion
-XRequest.DPMS.1: DPMSCapable
-XRequest.DPMS.2: DPMSGetTimeouts
-XRequest.DPMS.3: DPMSSetTimeouts
-XRequest.DPMS.4: DPMSEnable
-XRequest.DPMS.5: DPMSDisable
-XRequest.DPMS.6: DPMSForceLevel
-XRequest.DPMS.7: DPMSInfo
-! XINERAMA, not an X Project Team specification
-XRequest.XINERAMA.0: XINERAMAQueryVersion
-XRequest.XINERAMA.1: XINERAMAGetState
-XRequest.XINERAMA.2: XINERAMAGetScreenCount
-XRequest.XINERAMA.3: XINERAMAGetScreenSize
-XRequest.XINERAMA.4: XINERAMAIsActive
-XRequest.XINERAMA.5: XINERAMAQueryScreens
-! XF86Rush extension, not a standard spec
-Xrequest.XFree86-Rush.0: XF86RushQueryVersion
-Xrequest.XFree86-Rush.1: XF86RushLockPixmap
-Xrequest.XFree86-Rush.2: XF86RushUnlockPixmap
-Xrequest.XFree86-Rush.3: XF86RushUnlockAllPixmaps
-Xrequest.XFree86-Rush.4: XF86RushGetCopyMode
-Xrequest.XFree86-Rush.5: XF86RushSetCopyMode
-Xrequest.XFree86-Rush.6: XF86RushGetPixelStride
-Xrequest.XFree86-Rush.7: XF86RushSetPixelStride
-Xrequest.XFree86-Rush.8: XF86RushOverlayPixmap
-Xrequest.XFree86-Rush.9: XF86RushStatusRegOffset
-Xrequest.XFree86-Rush.10: XF86RushAT3DEnableRegs
-Xrequest.XFree86-Rush.11: XF86RushAT3DDisableRegs
-! XVideo
-Xrequest.XVideo.0: XvQueryExtension
-Xrequest.XVideo.1: XvQueryAdaptors
-Xrequest.XVideo.2: XvQueryEncodings
-Xrequest.XVideo.3: XvGrabPort
-Xrequest.XVideo.4: XvUngrabPort
-Xrequest.XVideo.5: XvPutVideo
-Xrequest.XVideo.6: XvPutStill
-Xrequest.XVideo.7: XvGetVideo
-Xrequest.XVideo.8: XvGetStill
-Xrequest.XVideo.9: XvStopVideo
-Xrequest.XVideo.10: XvSelectVideoNotify
-Xrequest.XVideo.11: XvSelectPortNotify
-Xrequest.XVideo.12: XvQueryBestSize
-Xrequest.XVideo.13: XvSetPortAttribute
-Xrequest.XVideo.14: XvGetPortAttribute
-Xrequest.XVideo.15: XvQueryPortAttributes
-Xrequest.XVideo.16: XvListImageFormats
-Xrequest.XVideo.17: XvQueryImageAttributes
-Xrequest.XVideo.18: XvPutImage
-Xrequest.XVideo.19: XvShmPutImage
-XProtoError.XVideo.0: XvBadPort
-XProtoError.XVideo.1: XvBadEncoding
-XProtoError.XVideo.2: XvBadControl
-! XFree86-Bigfont
-Xrequest.XFree86-Bigfont.0: XF86BigfontQueryVersion
-Xrequest.XFree86-Bigfont.1: XF86BigfontQueryFont
-! Adobe-DPS-Extension, not a standard
-XRequest.Adobe-DPS-Extension.1: PSInit
-XRequest.Adobe-DPS-Extension.2: PSCreateContext
-XRequest.Adobe-DPS-Extension.3: PSCreateSpace
-XRequest.Adobe-DPS-Extension.4: PSGiveInput
-XRequest.Adobe-DPS-Extension.5: PSGetStatus
-XRequest.Adobe-DPS-Extension.6: PSDestroySpace
-XRequest.Adobe-DPS-Extension.7: PSReset
-XRequest.Adobe-DPS-Extension.8: PSNotifyContext
-XRequest.Adobe-DPS-Extension.9: PSCreateContextFromID
-XRequest.Adobe-DPS-Extension.10: PSXIDFromContext
-XRequest.Adobe-DPS-Extension.11: PSContextFromXID
-XRequest.Adobe-DPS-Extension.12: PSSetStatusMask
-XRequest.Adobe-DPS-Extension.13: PSCreateSecureContext
-XRequest.Adobe-DPS-Extension.14: PSNotifyWhenReady
-XProtoError.Adobe-DPS-Extension.0: PSErrorBadContext (invalid Context parameter)
-XlibMessage.Adobe-DPS-Extension.0: Context id in failed request: 0x%lx
-XProtoError.Adobe-DPS-Extension.1: PSErrorBadSpace (invalid Space parameter)
-XlibMessage.Adobe-DPS-Extension.1: Space id in failed request: 0x%lx
-XProtoError.Adobe-DPS-Extension.2: PSErrorAbort (interpreter aborted)
-XlibMessage.Adobe-DPS-Extension.2: Value in failed request: 0x%lx
-! RANDR
-XRequest.RANDR.0: RRQueryVersion
-XRequest.RANDR.1: RROldGetScreenInfo
-XRequest.RANDR.2: RRSetScreenConfig
-XRequest.RANDR.3: RROldScreenChangeSelectInput
-XRequest.RANDR.4: RRSelectInput
-XRequest.RANDR.5: RRGetScreenInfo
-XRequest.RANDR.6: RRGetScreenSizeRange
-XRequest.RANDR.7: RRSetScreenSize
-XRequest.RANDR.8: RRGetScreenResources
-XRequest.RANDR.9: RRGetOutputInfo
-XRequest.RANDR.10: RRListOutputProperties
-XRequest.RANDR.11: RRQueryOutputProperty
-XRequest.RANDR.12: RRConfigureOutputProperty
-XRequest.RANDR.13: RRChangeOutputProperty
-XRequest.RANDR.14: RRDeleteOutputProperty
-XRequest.RANDR.15: RRGetOutputProperty
-XRequest.RANDR.16: RRCreateMode
-XRequest.RANDR.17: RRDestroyMode
-XRequest.RANDR.18: RRAddOutputMode
-XRequest.RANDR.19: RRDeleteOutputMode
-XRequest.RANDR.20: RRGetCrtcInfo
-XRequest.RANDR.21: RRSetCrtcConfig
-XRequest.RANDR.22: RRGetCrtcGammaSize
-XRequest.RANDR.23: RRGetCrtcGamma
-XRequest.RANDR.24: RRSetCrtcGamma
-XRequest.RANDR.25: RRGetScreenResourcesCurrent
-XRequest.RANDR.26: RRSetCrtcTransform
-XRequest.RANDR.27: RRGetCrtcTransform
-XRequest.RANDR.28: RRGetPanning
-XRequest.RANDR.29: RRSetPanning
-XRequest.RANDR.30: RRSetOutputPrimary
-XRequest.RANDR.31: RRGetOutputPrimary
-XProtoError.RANDR.0: BadRROutput (invalid Output parameter)
-XlibMessage.RANDR.0: Output id in failed request: 0x%lx
-XProtoError.RANDR.1: BadRRCrtc (invalid Crtc parameter)
-XlibMessage.RANDR.1: Crtc id in failed request: 0x%lx
-XProtoError.RANDR.2: BadRRMode (invalid Mode parameter)
-XlibMessage.RANDR.2: Mode id in failed request: 0x%lx
-! RENDER
-XRequest.RENDER.0: RenderQueryVersion
-XRequest.RENDER.1: RenderQueryPictFormats
-XRequest.RENDER.2: RenderQueryPictIndexValues
-XRequest.RENDER.3: RenderQueryDithers
-XRequest.RENDER.4: RenderCreatePicture
-XRequest.RENDER.5: RenderChangePicture
-XRequest.RENDER.6: RenderSetPictureClipRectangles
-XRequest.RENDER.7: RenderFreePicture
-XRequest.RENDER.8: RenderComposite
-XRequest.RENDER.9: RenderScale
-XRequest.RENDER.10: RenderTrapezoids
-XRequest.RENDER.11: RenderTriangles
-XRequest.RENDER.12: RenderTriStrip
-XRequest.RENDER.13: RenderTriFan
-XRequest.RENDER.14: RenderColorTrapezoids
-XRequest.RENDER.15: RenderColorTriangles
-XRequest.RENDER.16: RenderTransform
-XRequest.RENDER.17: RenderCreateGlyphSet
-XRequest.RENDER.18: RenderReferenceGlyphSet
-XRequest.RENDER.19: RenderFreeGlyphSet
-XRequest.RENDER.20: RenderAddGlyphs
-XRequest.RENDER.21: RenderAddGlyphsFromPicture
-XRequest.RENDER.22: RenderFreeGlyphs
-XRequest.RENDER.23: RenderCompositeGlyphs8
-XRequest.RENDER.24: RenderCompositeGlyphs16
-XRequest.RENDER.25: RenderCompositeGlyphs32
-XRequest.RENDER.26: RenderFillRectangles
-XRequest.RENDER.27: RenderCreateCursor
-XRequest.RENDER.28: RenderSetPictureTransform
-XRequest.RENDER.29: RenderQueryFilters
-XRequest.RENDER.30: RenderSetPictureFilter
-XRequest.RENDER.31: RenderCreateAnimCursor
-XRequest.RENDER.32: RenderAddTraps
-XRequest.RENDER.33: RenderCreateSolidFill
-XRequest.RENDER.34: RenderCreateLinearGradient
-XRequest.RENDER.35: RenderCreateRadialGradient
-XRequest.RENDER.36: RenderCreateConicalGradient
-XProtoError.RENDER.0: RenderBadFormat (invalid PictFormat parameter)
-XlibMessage.RENDER.0: PictFormat id in failed request: 0x%lx
-XProtoError.RENDER.1: RenderBadPicture (invalid Picture parameter)
-XlibMessage.RENDER.1: Picture id in failed request: 0x%lx
-XProtoError.RENDER.2: RenderBadPictOp (invalid PictOp parameter)
-XlibMessage.RENDER.2: PictOp in failed request: 0x%lx
-XProtoError.RENDER.3: RenderBadGlyphSet (invalid GlyphSet parameter)
-XlibMessage.RENDER.3: GlyphSet id in failed request: 0x%lx
-XProtoError.RENDER.4: RenderBadGlyph (invalid Glyph parameter)
-XlibMessage.RENDER.4: Glyph in failed request: 0x%lx
-! XFixes
-XRequest.XFIXES.0: XFixesQueryVersion
-XRequest.XFIXES.1: XFixesChangeSaveSet
-XRequest.XFIXES.2: XFixesSelectSelectionInput
-XRequest.XFIXES.3: XFixesSelectCursorInput
-XRequest.XFIXES.4: XFixesGetCursorImage
-XRequest.XFIXES.5: XFixesCreateRegion
-XRequest.XFIXES.6: XFixesCreateRegionFromBitmap
-XRequest.XFIXES.7: XFixesCreateRegionFromWindow
-XRequest.XFIXES.8: XFixesCreateRegionFromGC
-XRequest.XFIXES.9: XFixesCreateRegionFromPicture
-XRequest.XFIXES.10: XFixesDestroyRegion
-XRequest.XFIXES.11: XFixesSetRegion
-XRequest.XFIXES.12: XFixesCopyRegion
-XRequest.XFIXES.13: XFixesUnionRegion
-XRequest.XFIXES.14: XFixesIntersectRegion
-XRequest.XFIXES.15: XFixesSubtractRegion
-XRequest.XFIXES.16: XFixesInvertRegion
-XRequest.XFIXES.17: XFixesTranslateRegion
-XRequest.XFIXES.18: XFixesRegionExtents
-XRequest.XFIXES.19: XFixesFetchRegion
-XRequest.XFIXES.20: XFixesSetGCClipRegion
-XRequest.XFIXES.21: XFixesSetWindowShapeRegion
-XRequest.XFIXES.22: XFixesSetPictureClipRegion
-XRequest.XFIXES.23: XFixesSetCursorName
-XRequest.XFIXES.24: XFixesGetCursorName
-XRequest.XFIXES.25: XFixesGetCursorImageAndName
-XRequest.XFIXES.26: XFixesChangeCursor
-XRequest.XFIXES.27: XFixesChangeCursorByName
-XRequest.XFIXES.28: XFixesExpandRegion
-XRequest.XFIXES.29: XFixesHideCursor
-XRequest.XFIXES.30: XFixesShowCursor
-XProtoError.XFIXES.0: BadRegion (invalid Region parameter)
-XlibMessage.XFIXES.0: Region id in failed request: 0x%lx
-! DAMAGE extension
-XRequest.DAMAGE.0: XDamageQueryVersion
-XRequest.DAMAGE.1: XDamageCreate
-XRequest.DAMAGE.2: XDamageDestroy
-XRequest.DAMAGE.3: XDamageSubtract
-XRequest.DAMAGE.4: XDamageAdd
-XProtoError.DAMAGE.0: BadDamage (invalid Damage parameter)
-XlibMessage.DAMAGE.0: Damage id in failed request: 0x%lx
-! DRI2 extension
-XRequest.DRI2.0: DRI2QueryVersion
-XRequest.DRI2.1: DRI2Connect
-XRequest.DRI2.2: DRI2Authenticate
-XRequest.DRI2.3: DRI2CreateDrawable
-XRequest.DRI2.4: DRI2DestroyDrawable
-XRequest.DRI2.5: DRI2GetBuffers
-XRequest.DRI2.6: DRI2CopyRegion
+!
+! Copyright 1993, 1995, 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.
+!
+!
+! these are used in XGetErrorMessage.
+XlibMessage.XError: X Error of failed request
+XlibMessage.MajorCode: Major opcode of failed request: %d
+XlibMessage.MinorCode: Minor opcode of failed request: %d
+XlibMessage.ResourceID: Resource id in failed request: 0x%lx
+XlibMessage.Value: Value in failed request: 0x%lx
+XlibMessage.AtomID: Atom id in failed request: 0x%lx
+XlibMessage.ErrorSerial: Serial number of failed request: %lu
+XlibMessage.CurrentSerial: Current serial number in output stream: %lu
+! X request codes.
+XRequest.1:X_CreateWindow
+XRequest.2:X_ChangeWindowAttributes
+XRequest.3:X_GetWindowAttributes
+XRequest.4:X_DestroyWindow
+XRequest.5:X_DestroySubwindows
+XRequest.6:X_ChangeSaveSet
+XRequest.7:X_ReparentWindow
+XRequest.8:X_MapWindow
+XRequest.9:X_MapSubwindows
+XRequest.10:X_UnmapWindow
+XRequest.11:X_UnmapSubwindows
+XRequest.12:X_ConfigureWindow
+XRequest.13:X_CirculateWindow
+XRequest.14:X_GetGeometry
+XRequest.15:X_QueryTree
+XRequest.16:X_InternAtom
+XRequest.17:X_GetAtomName
+XRequest.18:X_ChangeProperty
+XRequest.19:X_DeleteProperty
+XRequest.20:X_GetProperty
+XRequest.21:X_ListProperties
+XRequest.22:X_SetSelectionOwner
+XRequest.23:X_GetSelectionOwner
+XRequest.24:X_ConvertSelection
+XRequest.25:X_SendEvent
+XRequest.26:X_GrabPointer
+XRequest.27:X_UngrabPointer
+XRequest.28:X_GrabButton
+XRequest.29:X_UngrabButton
+XRequest.30:X_ChangeActivePointerGrab
+XRequest.31:X_GrabKeyboard
+XRequest.32:X_UngrabKeyboard
+XRequest.33:X_GrabKey
+XRequest.34:X_UngrabKey
+XRequest.35:X_AllowEvents
+XRequest.36:X_GrabServer
+XRequest.37:X_UngrabServer
+XRequest.38:X_QueryPointer
+XRequest.39:X_GetMotionEvents
+XRequest.40:X_TranslateCoords
+XRequest.41:X_WarpPointer
+XRequest.42:X_SetInputFocus
+XRequest.43:X_GetInputFocus
+XRequest.44:X_QueryKeymap
+XRequest.45:X_OpenFont
+XRequest.46:X_CloseFont
+XRequest.47:X_QueryFont
+XRequest.48:X_QueryTextExtents
+XRequest.49:X_ListFonts
+XRequest.50:X_ListFontsWithInfo
+XRequest.51:X_SetFontPath
+XRequest.52:X_GetFontPath
+XRequest.53:X_CreatePixmap
+XRequest.54:X_FreePixmap
+XRequest.55:X_CreateGC
+XRequest.56:X_ChangeGC
+XRequest.57:X_CopyGC
+XRequest.58:X_SetDashes
+XRequest.59:X_SetClipRectangles
+XRequest.60:X_FreeGC
+XRequest.61:X_ClearArea
+XRequest.62:X_CopyArea
+XRequest.63:X_CopyPlane
+XRequest.64:X_PolyPoint
+XRequest.65:X_PolyLine
+XRequest.66:X_PolySegment
+XRequest.67:X_PolyRectangle
+XRequest.68:X_PolyArc
+XRequest.69:X_FillPoly
+XRequest.70:X_PolyFillRectangle
+XRequest.71:X_PolyFillArc
+XRequest.72:X_PutImage
+XRequest.73:X_GetImage
+XRequest.74:X_PolyText8
+XRequest.75:X_PolyText16
+XRequest.76:X_ImageText8
+XRequest.77:X_ImageText16
+XRequest.78:X_CreateColormap
+XRequest.79:X_FreeColormap
+XRequest.80:X_CopyColormapAndFree
+XRequest.81:X_InstallColormap
+XRequest.82:X_UninstallColormap
+XRequest.83:X_ListInstalledColormaps
+XRequest.84:X_AllocColor
+XRequest.85:X_AllocNamedColor
+XRequest.86:X_AllocColorCells
+XRequest.87:X_AllocColorPlanes
+XRequest.88:X_FreeColors
+XRequest.89:X_StoreColors
+XRequest.90:X_StoreNamedColor
+XRequest.91:X_QueryColors
+XRequest.92:X_LookupColor
+XRequest.93:X_CreateCursor
+XRequest.94:X_CreateGlyphCursor
+XRequest.95:X_FreeCursor
+XRequest.96:X_RecolorCursor
+XRequest.97:X_QueryBestSize
+XRequest.98:X_QueryExtension
+XRequest.99:X_ListExtensions
+XRequest.100:X_ChangeKeyboardMapping
+XRequest.101:X_GetKeyboardMapping
+XRequest.102:X_ChangeKeyboardControl
+XRequest.103:X_GetKeyboardControl
+XRequest.104:X_Bell
+XRequest.105:X_ChangePointerControl
+XRequest.106:X_GetPointerControl
+XRequest.107:X_SetScreenSaver
+XRequest.108:X_GetScreenSaver
+XRequest.109:X_ChangeHosts
+XRequest.110:X_ListHosts
+XRequest.111:X_SetAccessControl
+XRequest.112:X_SetCloseDownMode
+XRequest.113:X_KillClient
+XRequest.114:X_RotateProperties
+XRequest.115:X_ForceScreenSaver
+XRequest.116:X_SetPointerMapping
+XRequest.117:X_GetPointerMapping
+XRequest.118:X_SetModifierMapping
+XRequest.119:X_GetModifierMapping
+XRequest.127:X_NoOperation
+! X Error Codes
+XProtoError.0: unknown error code 0
+XProtoError.1: BadRequest (invalid request code or no such operation)
+XProtoError.2: BadValue (integer parameter out of range for operation)
+XProtoError.3: BadWindow (invalid Window parameter)
+XProtoError.4: BadPixmap (invalid Pixmap parameter)
+XProtoError.5: BadAtom (invalid Atom parameter)
+XProtoError.6: BadCursor (invalid Cursor parameter)
+XProtoError.7: BadFont (invalid Font parameter)
+XProtoError.8: BadMatch (invalid parameter attributes)
+XProtoError.9: BadDrawable (invalid Pixmap or Window parameter)
+XProtoError.10: BadAccess (attempt to access private resource denied)
+XProtoError.11: BadAlloc (insufficient resources for operation)
+XProtoError.12: BadColor (invalid Colormap parameter)
+XProtoError.13: BadGC (invalid GC parameter)
+XProtoError.14: BadIDChoice (invalid resource ID chosen for this connection)
+XProtoError.15: BadName (named color or font does not exist)
+XProtoError.16: BadLength (poly request too large or internal Xlib length error)
+XProtoError.17: BadImplementation (server does not implement operation)
+! Multi-Buffering extension, not an X Consortium standard
+XRequest.Multi-Buffering.0: X_MbufGetBufferVersion
+XRequest.Multi-Buffering.1: X_MbufCreateImageBuffers
+XRequest.Multi-Buffering.2: X_MbufDestroyImageBuffers
+XRequest.Multi-Buffering.3: X_MbufDisplayImageBuffers
+XRequest.Multi-Buffering.4: X_MbufSetMultiBufferAttributes
+XRequest.Multi-Buffering.5: X_MbufGetMultiBufferAttributes
+XRequest.Multi-Buffering.6: X_MbufSetBufferAttributes
+XRequest.Multi-Buffering.7: X_MbufGetBufferAttributes
+XRequest.Multi-Buffering.8: X_MbufGetBufferInfo
+XRequest.Multi-Buffering.9: X_MbufCreateStereoWindow
+XProtoError.Multi-Buffering.0: BadBuffer (invalid Buffer parameter)
+XlibMessage.Multi-Buffering.0: Buffer id in failed request: 0x%lx
+! SHAPE extension, an X Consortium standard
+XRequest.SHAPE.0: X_ShapeQueryVersion
+XRequest.SHAPE.1: X_ShapeRectangles
+XRequest.SHAPE.2: X_ShapeMask
+XRequest.SHAPE.3: X_ShapeCombine
+XRequest.SHAPE.4: X_ShapeOffset
+XRequest.SHAPE.5: X_ShapeQueryExtents
+XRequest.SHAPE.6: X_ShapeSelectInput
+XRequest.SHAPE.7: X_ShapeInputSelected
+XRequest.SHAPE.8: X_ShapeGetRectangles
+! Input extension, an X Consortium standard
+XRequest.XInputExtension.1:X_GetExtensionVersion
+XRequest.XInputExtension.2:X_ListInputDevices
+XRequest.XInputExtension.3:X_OpenDevice
+XRequest.XInputExtension.4:X_CloseDevice
+XRequest.XInputExtension.5:X_SetDeviceMode
+XRequest.XInputExtension.6:X_SelectExtensionEvent
+XRequest.XInputExtension.7:X_GetSelectedExtensionEvents
+XRequest.XInputExtension.8:X_ChangeDeviceDontPropagateList
+XRequest.XInputExtension.9:X_GetDeviceDontPropagateList
+XRequest.XInputExtension.10:X_GetDeviceMotionEvents
+XRequest.XInputExtension.11:X_ChangeKeyboardDevice
+XRequest.XInputExtension.12:X_ChangePointerDevice
+XRequest.XInputExtension.13:X_GrabDevice
+XRequest.XInputExtension.14:X_UngrabDevice
+XRequest.XInputExtension.15:X_GrabDeviceKey
+XRequest.XInputExtension.16:X_UngrabDeviceKey
+XRequest.XInputExtension.17:X_GrabDeviceButton
+XRequest.XInputExtension.18:X_UngrabDeviceButton
+XRequest.XInputExtension.19:X_AllowDeviceEvents
+XRequest.XInputExtension.20:X_GetDeviceFocus
+XRequest.XInputExtension.21:X_SetDeviceFocus
+XRequest.XInputExtension.22:X_GetFeedbackControl
+XRequest.XInputExtension.23:X_ChangeFeedbackControl
+XRequest.XInputExtension.24:X_GetDeviceKeyMapping
+XRequest.XInputExtension.25:X_ChangeDeviceKeyMapping
+XRequest.XInputExtension.26:X_GetDeviceModifierMapping
+XRequest.XInputExtension.27:X_SetDeviceModifierMapping
+XRequest.XInputExtension.28:X_GetDeviceButtonMapping
+XRequest.XInputExtension.29:X_SetDeviceButtonMapping
+XRequest.XInputExtension.30:X_QueryDeviceState
+XRequest.XInputExtension.31:X_SendExtensionEvent
+XRequest.XInputExtension.32:X_DeviceBell
+XRequest.XInputExtension.33:X_SetDeviceValuators
+XRequest.XInputExtension.34:X_GetDeviceControl
+XRequest.XInputExtension.35:X_ChangeDeviceControl
+XRequest.XInputExtension.36: X_ListDeviceProperties
+XRequest.XInputExtension.37: X_ChangeDeviceProperty
+XRequest.XInputExtension.38: X_DeleteDeviceProperty
+XRequest.XInputExtension.39: X_GetDeviceProperty
+XProtoError.XInputExtension.0: XI_BadDevice (invalid Device parameter)
+XlibMessage.XInputExtension.0: Device id in failed request: 0x%lx
+XProtoError.XInputExtension.1: XI_BadEvent (invalid Event parameter)
+XlibMessage.XInputExtension.1: Event id in failed request: 0x%lx
+XProtoError.XInputExtension.2: XI_BadMode (invalid Mode parameter)
+XlibMessage.XInputExtension.2: Mode id in failed request: 0x%lx
+XProtoError.XInputExtension.3: XI_DeviceBusy
+XlibMessage.XInputExtension.3: Device id in failed request: 0x%lx
+XProtoError.XInputExtension.4: XI_BadClass (invalid Class parameter)
+XlibMessage.XInputExtension.4: Class id in failed request: 0x%lx
+! MIT-SHM extension, experimental, not an X Consortium standard
+XRequest.MIT-SHM.0: X_ShmQueryVersion
+XRequest.MIT-SHM.1: X_ShmAttach
+XRequest.MIT-SHM.2: X_ShmDetach
+XRequest.MIT-SHM.3: X_ShmPutImage
+XRequest.MIT-SHM.4: X_ShmGetImage
+XRequest.MIT-SHM.5: X_ShmCreatePixmap
+XProtoError.MIT-SHM.0: BadShmSeg (invalid shared segment parameter)
+XlibMessage.MIT-SHM.0: Segment id in failed request: 0x%lx
+! MIT-SUNDRY-NONSTANDARD extension, definitely not an X Consortium standard
+XRequest.MIT-SUNDRY-NONSTANDARD.0: X_MITSetBugMode
+XRequest.MIT-SUNDRY-NONSTANDARD.1: X_MITGetBugMode
+! X3D-PEX extension
+XRequest.X3D-PEX.1: PEX_GetExtensionInfo
+XRequest.X3D-PEX.2: PEX_GetEnumeratedTypeInfo
+XRequest.X3D-PEX.3: PEX_GetImpDepConstants
+XRequest.X3D-PEX.4: PEX_CreateLookupTable
+XRequest.X3D-PEX.5: PEX_CopyLookupTable
+XRequest.X3D-PEX.6: PEX_FreeLookupTable
+XRequest.X3D-PEX.7: PEX_GetTableInfo
+XRequest.X3D-PEX.8: PEX_GetPredefinedEntries
+XRequest.X3D-PEX.9: PEX_GetDefinedIndices
+XRequest.X3D-PEX.10: PEX_GetTableEntry
+XRequest.X3D-PEX.11: PEX_GetTableEntries
+XRequest.X3D-PEX.12: PEX_SetTableEntries
+XRequest.X3D-PEX.13: PEX_DeleteTableEntries
+XRequest.X3D-PEX.14: PEX_CreatePipelineContext
+XRequest.X3D-PEX.15: PEX_CopyPipelineContext
+XRequest.X3D-PEX.16: PEX_FreePipelineContext
+XRequest.X3D-PEX.17: PEX_GetPipelineContext
+XRequest.X3D-PEX.18: PEX_ChangePipelineContext
+XRequest.X3D-PEX.19: PEX_CreateRenderer
+XRequest.X3D-PEX.20: PEX_FreeRenderer
+XRequest.X3D-PEX.21: PEX_ChangeRenderer
+XRequest.X3D-PEX.22: PEX_GetRendererAttributes
+XRequest.X3D-PEX.23: PEX_GetRendererDynamics
+XRequest.X3D-PEX.24: PEX_BeginRendering
+XRequest.X3D-PEX.25: PEX_EndRendering
+XRequest.X3D-PEX.26: PEX_BeginStructure
+XRequest.X3D-PEX.27: PEX_EndStructure
+XRequest.X3D-PEX.28: PEX_RenderOutputCommands
+XRequest.X3D-PEX.29: PEX_RenderNetwork
+XRequest.X3D-PEX.30: PEX_CreateStructure
+XRequest.X3D-PEX.31: PEX_CopyStructure
+XRequest.X3D-PEX.32: PEX_DestroyStructures
+XRequest.X3D-PEX.33: PEX_GetStructureInfo
+XRequest.X3D-PEX.34: PEX_GetElementInfo
+XRequest.X3D-PEX.35: PEX_GetStructuresInNetwork
+XRequest.X3D-PEX.36: PEX_GetAncestors
+XRequest.X3D-PEX.37: PEX_GetDescendants
+XRequest.X3D-PEX.38: PEX_FetchElements
+XRequest.X3D-PEX.39: PEX_SetEditingMode
+XRequest.X3D-PEX.40: PEX_SetElementPointer
+XRequest.X3D-PEX.41: PEX_SetElementPointerAtLabel
+XRequest.X3D-PEX.42: PEX_ElementSearch
+XRequest.X3D-PEX.43: PEX_StoreElements
+XRequest.X3D-PEX.44: PEX_DeleteElements
+XRequest.X3D-PEX.45: PEX_DeleteElementsToLabel
+XRequest.X3D-PEX.46: PEX_DeleteBetweenLabels
+XRequest.X3D-PEX.47: PEX_CopyElements
+XRequest.X3D-PEX.48: PEX_ChangeStructureRefs
+XRequest.X3D-PEX.49: PEX_CreateNameSet
+XRequest.X3D-PEX.50: PEX_CopyNameSet
+XRequest.X3D-PEX.51: PEX_FreeNameSet
+XRequest.X3D-PEX.52: PEX_GetNameSet
+XRequest.X3D-PEX.53: PEX_ChangeNameSet
+XRequest.X3D-PEX.54: PEX_CreateSearchContext
+XRequest.X3D-PEX.55: PEX_CopySearchContext
+XRequest.X3D-PEX.56: PEX_FreeSearchContext
+XRequest.X3D-PEX.57: PEX_GetSearchContext
+XRequest.X3D-PEX.58: PEX_ChangeSearchContext
+XRequest.X3D-PEX.59: PEX_SearchNetwork
+XRequest.X3D-PEX.60: PEX_CreatePhigsWks
+XRequest.X3D-PEX.61: PEX_FreePhigsWks
+XRequest.X3D-PEX.62: PEX_GetWksInfo
+XRequest.X3D-PEX.63: PEX_GetDynamics
+XRequest.X3D-PEX.64: PEX_GetViewRep
+XRequest.X3D-PEX.65: PEX_RedrawAllStructures
+XRequest.X3D-PEX.66: PEX_UpdateWorkstation
+XRequest.X3D-PEX.67: PEX_RedrawClipRegion
+XRequest.X3D-PEX.68: PEX_ExecuteDeferredActions
+XRequest.X3D-PEX.69: PEX_SetViewPriority
+XRequest.X3D-PEX.70: PEX_SetDisplayUpdateMode
+XRequest.X3D-PEX.71: PEX_MapDCtoWC
+XRequest.X3D-PEX.72: PEX_MapWCtoDC
+XRequest.X3D-PEX.73: PEX_SetViewRep
+XRequest.X3D-PEX.74: PEX_SetWksWindow
+XRequest.X3D-PEX.75: PEX_SetWksViewport
+XRequest.X3D-PEX.76: PEX_SetHlhsrMode
+XRequest.X3D-PEX.77: PEX_SetWksBufferMode
+XRequest.X3D-PEX.78: PEX_PostStructure
+XRequest.X3D-PEX.79: PEX_UnpostStructure
+XRequest.X3D-PEX.80: PEX_UnpostAllStructures
+XRequest.X3D-PEX.81: PEX_GetWksPostings
+XRequest.X3D-PEX.82: PEX_GetPickDevice
+XRequest.X3D-PEX.83: PEX_ChangePickDevice
+XRequest.X3D-PEX.84: PEX_CreatePickMeasure
+XRequest.X3D-PEX.85: PEX_FreePickMeasure
+XRequest.X3D-PEX.86: PEX_GetPickMeasure
+XRequest.X3D-PEX.87: PEX_UpdatePickMeasure
+XRequest.X3D-PEX.88: PEX_OpenFont
+XRequest.X3D-PEX.89: PEX_CloseFont
+XRequest.X3D-PEX.90: PEX_QueryFont
+XRequest.X3D-PEX.91: PEX_ListFonts
+XRequest.X3D-PEX.92: PEX_ListFontsWithInfo
+XRequest.X3D-PEX.93: PEX_QueryTextExtents
+XRequest.X3D-PEX.94: PEX_MatchRenderingTargets
+XRequest.X3D-PEX.95: PEX_Escape
+XRequest.X3D-PEX.96: PEX_EscapeWithReply
+XRequest.X3D-PEX.97: PEX_RenderElements
+XRequest.X3D-PEX.98: PEX_AccumulateState
+XRequest.X3D-PEX.99: PEX_BeginPickOne
+XRequest.X3D-PEX.100: PEX_EndPickOne
+XRequest.X3D-PEX.101: PEX_PickOne
+XRequest.X3D-PEX.102: PEX_BeginPickAll
+XRequest.X3D-PEX.103: PEX_EndPickAll
+XRequest.X3D-PEX.104: PEX_PickAll
+XProtoError.X3D-PEX.0: PEXColorTypeError
+XlibMessage.X3D-PEX.0: Color type in failed request: 0x%lx
+XProtoError.X3D-PEX.1: PEXRendererStateError
+XlibMessage.X3D-PEX.1: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.2: PEXFloatingPointFormatError
+XlibMessage.X3D-PEX.2: Format in failed request: 0x%lx
+XProtoError.X3D-PEX.3: PEXLabelError
+XlibMessage.X3D-PEX.3: Label in failed request: 0x%lx
+XProtoError.X3D-PEX.4: PEXLookupTableError
+XlibMessage.X3D-PEX.4: Table id in failed request: 0x%lx
+XProtoError.X3D-PEX.5: PEXNameSetError
+XlibMessage.X3D-PEX.5: Nameset in failed request: 0x%lx
+XProtoError.X3D-PEX.6: PEXPathError
+XlibMessage.X3D-PEX.6: Path id in failed request: 0x%lx
+XProtoError.X3D-PEX.7: PEXFontError
+XlibMessage.X3D-PEX.7: Font id in failed request: 0x%lx
+XProtoError.X3D-PEX.8: PEXPhigsWksError
+XlibMessage.X3D-PEX.8: Workstation id in failed request: 0x%lx
+XProtoError.X3D-PEX.9: PEXPickMeasureError
+XlibMessage.X3D-PEX.9: Device id in failed request: 0x%lx
+XProtoError.X3D-PEX.10: PEXPipelineContextError
+XlibMessage.X3D-PEX.10: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.11: PEXRendererError
+XlibMessage.X3D-PEX.11: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.12: PEXSearchContextError
+XlibMessage.X3D-PEX.12: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.13: PEXStructureError
+XlibMessage.X3D-PEX.13: Structure id in failed request: 0x%lx
+XProtoError.X3D-PEX.14: PEXOutputCommandError
+XlibMessage.X3D-PEX.14: Resource id in failed request: 0x%lx
+! XTEST extension, an X Consortium standard
+XRequest.XTEST.0: X_XTestGetVersion
+XRequest.XTEST.1: X_XTestCompareCursor
+XRequest.XTEST.2: X_XTestFakeInput
+XRequest.XTEST.3: X_XTestGrabControl
+! BIG-REQUESTS extension, an X Consortium standard
+XRequest.BIG-REQUESTS.0: X_BigReqEnable
+! XIE extension, an X Consortium standard
+XRequest.XIE.1: XIE_QueryImageExtension
+XRequest.XIE.2: XIE_QueryTechniques
+XRequest.XIE.3: XIE_CreateColorList
+XRequest.XIE.4: XIE_DestroyColorList
+XRequest.XIE.5: XIE_PurgeColorList
+XRequest.XIE.6: XIE_QueryColorList
+XRequest.XIE.7: XIE_CreateLUT
+XRequest.XIE.8: XIE_DestroyLUT
+XRequest.XIE.9: XIE_CreatePhotomap
+XRequest.XIE.10: XIE_DestroyPhotomap
+XRequest.XIE.11: XIE_QueryPhotomap
+XRequest.XIE.12: XIE_CreateROI
+XRequest.XIE.13: XIE_DestroyROI
+XRequest.XIE.14: XIE_CreatePhotospace
+XRequest.XIE.15: XIE_DestroyPhotospace
+XRequest.XIE.16: XIE_ExecuteImmediate
+XRequest.XIE.17: XIE_CreatePhotoflo
+XRequest.XIE.18: XIE_DestroyPhotoflo
+XRequest.XIE.19: XIE_ExecutePhotoflo
+XRequest.XIE.20: XIE_ModifyPhotoflo
+XRequest.XIE.21: XIE_RedefinePhotoflo
+XRequest.XIE.22: XIE_PutClientData
+XRequest.XIE.23: XIE_GetClientData
+XRequest.XIE.24: XIE_QueryPhotoflo
+XRequest.XIE.25: XIE_Await
+XRequest.XIE.26: XIE_Abort
+XProtoError.XIE.0: XIE_ColorListError
+XlibMessage.XIE.0: ColorList in failed request: 0x%lx
+XProtoError.XIE.1: XIE_LUTError
+XlibMessage.XIE.1: LUT in failed request: 0x%lx
+XProtoError.XIE.2: XIE_PhotofloError
+XlibMessage.XIE.2: Photoflo in failed request: 0x%lx
+XProtoError.XIE.3: XIE_PhotomapError
+XlibMessage.XIE.3: Photomap in failed request: 0x%lx
+XProtoError.XIE.4: XIE_PhotospaceError
+XlibMessage.XIE.4: Photospace in failed request: 0x%lx
+XProtoError.XIE.5: XIE_ROIError
+XlibMessage.XIE.5: ROI in failed request: 0x%lx
+XProtoError.XIE.6: XIE_FloError
+XlibMessage.XIE.6: Photoflo in failed request: 0x%lx
+! SYNC extension, an X Consortium standard
+XRequest.SYNC.0: X_SyncInitialize
+XRequest.SYNC.1: X_SyncListSystemCounters
+XRequest.SYNC.2: X_SyncCreateCounter
+XRequest.SYNC.3: X_SyncSetCounter
+XRequest.SYNC.4: X_SyncChangeCounter
+XRequest.SYNC.5: X_SyncQueryCounter
+XRequest.SYNC.6: X_SyncDestroyCounter
+XRequest.SYNC.7: X_SyncAwait
+XRequest.SYNC.8: X_SyncCreateAlarm
+XRequest.SYNC.9: X_SyncChangeAlarm
+XRequest.SYNC.10: X_SyncQueryAlarm
+XRequest.SYNC.11: X_SyncDestroyAlarm
+XRequest.SYNC.12: X_SyncSetPriority
+XRequest.SYNC.13: X_SyncGetPriority
+XProtoError.SYNC.0: XSyncBadCounter
+XlibMessage.SYNC.0: Counter in failed request: 0x%lx
+XProtoError.SYNC.1: XSyncBadAlarm
+XlibMessage.SYNC.1: Alarm in failed request: 0x%lx
+! XKB extension
+XRequest.XKEYBOARD.0: XkbUseExtension
+XRequest.XKEYBOARD.1: XkbSelectEvents
+XRequest.XKEYBOARD.2: OBSOLETE
+XRequest.XKEYBOARD.3: XkbBell
+XRequest.XKEYBOARD.4: XkbGetState
+XRequest.XKEYBOARD.5: XkbLatchLockState
+XRequest.XKEYBOARD.6: XkbGetControls
+XRequest.XKEYBOARD.7: XkbSetControls
+XRequest.XKEYBOARD.8: XkbGetMap
+XRequest.XKEYBOARD.9: XkbSetMap
+XRequest.XKEYBOARD.10: XkbGetCompatMap
+XRequest.XKEYBOARD.11: XkbSetCompatMap
+XRequest.XKEYBOARD.12: XkbGetIndicatorState
+XRequest.XKEYBOARD.13: XkbGetIndicatorMap
+XRequest.XKEYBOARD.14: XkbSetIndicatorMap
+XRequest.XKEYBOARD.15: XkbGetNamedIndicator
+XRequest.XKEYBOARD.16: XkbSetNamedIndicator
+XRequest.XKEYBOARD.17: XkbGetNames
+XRequest.XKEYBOARD.18: XkbSetNames
+XRequest.XKEYBOARD.19: XkbGetGeometry
+XRequest.XKEYBOARD.20: XkbSetGeometry
+XRequest.XKEYBOARD.21: XkbPerClientFlags
+XRequest.XKEYBOARD.22: XkbListComponents
+XRequest.XKEYBOARD.23: XkbGetKbdByName
+XRequest.XKEYBOARD.24: XkbGetDeviceInfo
+XRequest.XKEYBOARD.25: XkbSetDeviceInfo
+XRequest.XKEYBOARD.101: XkbSetDebuggingFlags
+XProtoError.XKEYBOARD.0: XkbBadKeyboard
+XlibMessage.XKEYBOARD.0: Device id in failed request: 0x%lx
+! GLX extension for OpenGL, an OpenGL Architectural Review Board standard
+! GLX Commands
+XRequest.GLX.7: X_GLXQueryVersion
+XRequest.GLX.3: X_GLXCreateContext
+XRequest.GLX.4: X_GLXDestroyContext
+XRequest.GLX.5: X_GLXMakeCurrent
+XRequest.GLX.6: X_GLXIsDirect
+XRequest.GLX.10: X_GLXCopyContext
+XRequest.GLX.8: X_GLXWaitGL
+XRequest.GLX.9: X_GLXWaitX
+XRequest.GLX.11: X_GLXSwapBuffers
+XRequest.GLX.12: X_GLXUseXFont
+XRequest.GLX.13: X_GLXCreateGLXPixmap
+XRequest.GLX.15: X_GLXDestroyGLXPixmap
+XRequest.GLX.14: X_GLXGetVisualConfigs
+XRequest.GLX.16: X_GLXVendorPrivate
+XRequest.GLX.17: X_GLXVendorPrivateWithReply
+XRequest.GLX.18: X_GLXQueryExtensionsString
+XRequest.GLX.19: X_GLXQueryServerString
+XRequest.GLX.20: X_GLXClientInfo
+XRequest.GLX.21: X_GLXGetFBConfigs
+XRequest.GLX.22: X_GLXCreatePixmap
+XRequest.GLX.23: X_GLXDestroyPixmap
+XRequest.GLX.24: X_GLXCreateNewContext
+XRequest.GLX.25: X_GLXQueryContext
+XRequest.GLX.26: X_GLXMakeContextCurrent
+XRequest.GLX.27: X_GLXCreatePbuffer
+XRequest.GLX.28: X_GLXDestroyPbuffer
+XRequest.GLX.29: X_GLXGetDrawableAttributes
+XRequest.GLX.30: X_GLXChangeDrawableAttributes
+XRequest.GLX.31: X_GLXCreateWindow
+XRequest.GLX.32: X_GLXDestroyWindow
+! GL Non-rendering Commands
+XRequest.GLX.103: X_GLXDeleteLists
+XRequest.GLX.102: X_GLXEndList
+XRequest.GLX.105: X_GLXFeedbackBuffer
+XRequest.GLX.108: X_GLXFinish
+XRequest.GLX.142: X_GLXFlush
+XRequest.GLX.104: X_GLXGenLists
+XRequest.GLX.112: X_GLXGetBooleanv
+XRequest.GLX.113: X_GLXGetClipPlane
+XRequest.GLX.114: X_GLXGetDoublev
+XRequest.GLX.115: X_GLXGetError
+XRequest.GLX.116: X_GLXGetFloatv
+XRequest.GLX.117: X_GLXGetIntegerv
+XRequest.GLX.118: X_GLXGetLightfv
+XRequest.GLX.119: X_GLXGetLightiv
+XRequest.GLX.120: X_GLXGetMapdv
+XRequest.GLX.121: X_GLXGetMapfv
+XRequest.GLX.122: X_GLXGetMapiv
+XRequest.GLX.123: X_GLXGetMaterialfv
+XRequest.GLX.124: X_GLXGetMaterialiv
+XRequest.GLX.125: X_GLXGetPixelfv
+XRequest.GLX.126: X_GLXGetPixelMapuiv
+XRequest.GLX.127: X_GLXGetPixelMapusv
+XRequest.GLX.129: X_GLXGetString
+XRequest.GLX.130: X_GLXGetTexEnvfv
+XRequest.GLX.131: X_GLXGetTexEnviv
+XRequest.GLX.132: X_GLXGetTexGendv
+XRequest.GLX.133: X_GLXGetTexGenfv
+XRequest.GLX.134: X_GLXGetTexGeniv
+XRequest.GLX.138: X_GLXGetTexLevelParameterfv
+XRequest.GLX.139: X_GLXGetTexLevelParameteriv
+XRequest.GLX.136: X_GLXGetTexParameterfv
+XRequest.GLX.137: X_GLXGetTexParameteriv
+XRequest.GLX.140: X_GLXIsEnabled
+XRequest.GLX.141: X_GLXIsList
+XRequest.GLX.101: X_GLXNewList
+XRequest.GLX.109: X_GLXPixelStoref
+XRequest.GLX.110: X_GLXPixelStorei
+XRequest.GLX.107: X_GLXRenderMode
+XRequest.GLX.106: X_GLXSelectBuffer
+! GL Non-rendering Commands That Return Pixel Data
+XRequest.GLX.128: X_GLXGetPolygonStipple
+XRequest.GLX.135: X_GLXGetTexImage
+XRequest.GLX.111: X_GLXReadPixels
+! GL Rendering Commands
+XRequest.GLX.1: X_GLXRender
+XRequest.GLX.2: X_GLXRenderLarge
+! GLX Errors
+XProtoError.GLX.0: GLXBadContext
+XProtoError.GLX.1: GLXBadContextState
+XProtoError.GLX.2: GLXBadDrawable
+XProtoError.GLX.3: GLXBadPixmap
+XProtoError.GLX.4: GLXBadContextTag
+XProtoError.GLX.5: GLXBadCurrentWindow
+XProtoError.GLX.6: GLXBadRenderRequest
+XProtoError.GLX.7: GLXBadLargeRequest
+XProtoError.GLX.8: GLXUnsupportedPrivateRequest
+XProtoError.GLX.9: GLXBadFBConfig
+XProtoError.GLX.10: GLXBadPbuffer
+XProtoError.GLX.11: GLXBadCurrentDrawable
+XProtoError.GLX.12: GLXBadWindow
+! XC-MISC extension, an X Consortium standard
+XRequest.XC-MISC.0: XCMiscGetVersion
+XRequest.XC-MISC.1: XCMiscGetXIDRange
+! RECORD extension
+XRequest.RECORD.0: XRecordQueryVersion
+XRequest.RECORD.1: XRecordCreateContext
+XRequest.RECORD.2: XRecordRegisterClients
+XRequest.RECORD.3: XRecordUnregisterClients
+XRequest.RECORD.4: XRecordGetContext
+XRequest.RECORD.5: XRecordEnableContext
+XRequest.RECORD.6: XRecordDisableContext
+XRequest.RECORD.7: XRecordFreeContext
+XProtoError.RECORD.0: XRecordBadContext
+XlibMessage.RECORD.0: Context in failed request: 0x%lx
+! XFree86-VidModeExtension -- not an X Consortium standard
+XRequest.XFree86-VidModeExtension.0: XF86VidModeQueryVersion
+XRequest.XFree86-VidModeExtension.1: XF86VidModeGetModeLine
+XRequest.XFree86-VidModeExtension.2: XF86VidModeModModeLine
+XRequest.XFree86-VidModeExtension.3: XF86VidModeSwitchMode
+XRequest.XFree86-VidModeExtension.4: XF86VidModeGetMonitor
+XRequest.XFree86-VidModeExtension.5: XF86VidModeLockModeSwitch
+XRequest.XFree86-VidModeExtension.6: XF86VidModeGetAllModeLines
+XRequest.XFree86-VidModeExtension.7: XF86VidModeAddModeLine
+XRequest.XFree86-VidModeExtension.8: XF86VidModeDeleteModeLine
+XRequest.XFree86-VidModeExtension.9: XF86VidModeValidateModeLine
+XRequest.XFree86-VidModeExtension.10: XF86VidModeSwitchToMode
+XRequest.XFree86-VidModeExtension.11: XF86VidModeGetViewPort
+XRequest.XFree86-VidModeExtension.12: XF86VidModeSetViewPort
+XRequest.XFree86-VidModeExtension.13: XF86VidModeGetDotClocks
+XRequest.XFree86-VidModeExtension.14: XF86VidModeSetClientVersion
+XRequest.XFree86-VidModeExtension.15: XF86VidModeSetGamma
+XRequest.XFree86-VidModeExtension.16: XF86VidModeGetGamma
+XRequest.XFree86-VidModeExtension.17: XF86VidModeGetGammaRamp
+XRequest.XFree86-VidModeExtension.18: XF86VidModeSetGammaRamp
+XRequest.XFree86-VidModeExtension.19: XF86VidModeGetGammaRampSize
+XRequest.XFree86-VidModeExtension.20: XF86VidModeGetPermissions
+XProtoError.XFree86-VidModeExtension.0: XF86VidModeBadClock
+XProtoError.XFree86-VidModeExtension.1: XF86VidModeBadHTimings
+XProtoError.XFree86-VidModeExtension.2: XF86VidModeBadVTimings
+XProtoError.XFree86-VidModeExtension.3: XF86VidModeModeUnsuitable
+XProtoError.XFree86-VidModeExtension.4: XF86VidModeExtensionDisabled
+XProtoError.XFree86-VidModeExtension.5: XF86VidModeClientNotLocal
+XProtoError.XFree86-VidModeExtension.6: XF86VidModeZoomLocked
+! XFree86-Misc -- not an X Consortium standard
+XRequest.XFree86-Misc.0: XF86MiscQueryVersion
+XRequest.XFree86-Misc.1: XF86MiscGetSaver
+XRequest.XFree86-Misc.2: XF86MiscSetSaver
+XRequest.XFree86-Misc.3: XF86MiscGetMouseSettings
+XRequest.XFree86-Misc.4: XF86MiscGetKbdSettings
+XRequest.XFree86-Misc.5: XF86MiscSetMouseSettings
+XRequest.XFree86-Misc.6: XF86MiscSetKbdSettings
+XRequest.XFree86-Misc.7: XF86MiscSetGrabKeysState
+XRequest.XFree86-Misc.8: XF86MiscSetClientVersion
+XRequest.XFree86-Misc.9: XF86MiscGetFilePaths
+XProtoError.XFree86-Misc.0: XF86MiscBadMouseProtocol
+XProtoError.XFree86-Misc.1: XF86MiscBadMouseBaudRate
+XProtoError.XFree86-Misc.2: XF86MiscBadMouseFlags
+XProtoError.XFree86-Misc.3: XF86MiscBadMouseCombo
+XProtoError.XFree86-Misc.4: XF86MiscBadKbdType
+XProtoError.XFree86-Misc.5: XF86MiscModInDevDisabled
+XProtoError.XFree86-Misc.6: XF86MiscModInDevClientNotLocal
+XProtoError.XFree86-Misc.7: XF86MiscNoModule
+! XFree86-DGA -- not an X Consortium standard
+XRequest.XFree86-DGA.0: XF86DGAQueryVersion
+XRequest.XFree86-DGA.1: XF86DGAGetVideoLL
+XRequest.XFree86-DGA.2: XF86DGADirectVideo
+XRequest.XFree86-DGA.3: XF86DGAGetViewPortSize
+XRequest.XFree86-DGA.4: XF86DGASetViewPort
+XRequest.XFree86-DGA.5: XF86DGAGetVidPage
+XRequest.XFree86-DGA.6: XF86DGASetVidPage
+XRequest.XFree86-DGA.7: XF86DGAInstallColormap
+XRequest.XFree86-DGA.8: XF86DGAQueryDirectVideo
+XRequest.XFree86-DGA.9: XF86DGAViewPortChanged
+XRequest.XFree86-DGA.10: XF86DGAObsolete1
+XRequest.XFree86-DGA.11: XF86DGAObsolete2
+XRequest.XFree86-DGA.12: XDGAQueryModes
+XRequest.XFree86-DGA.13: XDGASetMode
+XRequest.XFree86-DGA.14: XDGASetViewport
+XRequest.XFree86-DGA.15: XDGAInstallColormap
+XRequest.XFree86-DGA.16: XDGASelectInput
+XRequest.XFree86-DGA.17: XDGAFillRectangle
+XRequest.XFree86-DGA.18: XDGACopyArea
+XRequest.XFree86-DGA.19: XDGACopyTransparentArea
+XRequest.XFree86-DGA.20: XDGAGetViewportStatus
+XRequest.XFree86-DGA.21: XDGASync
+XRequest.XFree86-DGA.22: XDGAOpenFramebuffer
+XRequest.XFree86-DGA.23: XDGACloseFramebuffer
+XRequest.XFree86-DGA.24: XDGASetClientVersion
+XRequest.XFree86-DGA.25: XDGAChangePixmapMode
+XRequest.XFree86-DGA.26: XDGACreateColormap
+XProtoError.XFree86-DGA.0: XF86DGAClientNotLocal
+XProtoError.XFree86-DGA.1: XF86DGANoDirectVideoMode
+XProtoError.XFree86-DGA.2: XF86DGAScreenNotActive
+XProtoError.XFree86-DGA.3: XF86DGADirectNotActivated
+XProtoError.XFree86-DGA.4: XF86DGAOperationNotSupported
+! DOUBLE-BUFFER (DBE), an X Consortium standard
+XRequest.DOUBLE-BUFFER.0: DBEGetVersion
+XRequest.DOUBLE-BUFFER.1: DBEAllocateBackBufferName
+XRequest.DOUBLE-BUFFER.2: DBEDeallocateBackBufferName
+XRequest.DOUBLE-BUFFER.3: DBESwapBuffers
+XRequest.DOUBLE-BUFFER.4: DBEBeginIdiom
+XRequest.DOUBLE-BUFFER.5: DBEEndIdiom
+XRequest.DOUBLE-BUFFER.6: DBEGetVisualInfo
+XRequest.DOUBLE-BUFFER.7: DBEGetBackBufferAttributes
+XProtoError.DOUBLE-BUFFER.0: DBEBadBuffer (invalid BackBuffer parameter)
+XlibMessage.DOUBLE-BUFFER.0: BackBuffer in failed request: 0x%lx
+! SECURITY
+XRequest.SECURITY.0: SecurityQueryVersion
+XRequest.SECURITY.1: SecurityGenerateAuthorization
+XProtoError.SECURITY.0: SecurityBadAuthorization (invalid authorization id)
+XProtoError.SECURITY.1: SecurityBadAuthorizationProtocol (invalid authorization name or data)
+XlibMessage.SECURITY.1: authorization id in failed request: 0x%lx
+! AppGroup
+XRequest.APPGROUP.0: XagQueryVersion
+XRequest.APPGROUP.1: XagCreate
+XRequest.APPGROUP.2: XagDestroy
+XRequest.APPGROUP.3: XagGetAttr
+XRequest.APPGROUP.4: XagQuery
+XRequest.APPGROUP.5: XagCreateAssoc
+XRequest.APPGROUP.6: XagDestroyAssoc
+XProtoError.APPGROUP.0: XagBadAppGroup (invalid AppGroup parameter)
+! LBX
+XRequest.LBX.0: LbxQueryVersion
+XRequest.LBX.1: LbxStartProxy
+XRequest.LBX.2: LbxStopProxy
+XRequest.LBX.3: LbxSwitch
+XRequest.LBX.4: LbxNewClient
+XRequest.LBX.5: LbxCloseClient
+XRequest.LBX.6: LbxModifySequence
+XRequest.LBX.7: LbxAllowMotion
+XRequest.LBX.8: LbxIncrementPixel
+XRequest.LBX.9: LbxDelta
+XRequest.LBX.10: LbxGetModifierMapping
+XRequest.LBX.11: LbxQueryTag
+XRequest.LBX.12: LbxInvalidateTag
+XRequest.LBX.13: LbxPolyPoint
+XRequest.LBX.14: LbxPolyLine
+XRequest.LBX.15: LbxPolySegment
+XRequest.LBX.16: LbxPolyRectangle
+XRequest.LBX.17: LbxPolyArc
+XRequest.LBX.18: LbxFillPoly
+XRequest.LBX.19: LbxPolyFillRectangle
+XRequest.LBX.20: LbxPolyFillArc
+XRequest.LBX.21: LbxGetKeyboardMapping
+XRequest.LBX.22: LbxQueryFont
+XRequest.LBX.23: LbxChangeProperty
+XRequest.LBX.24: LbxGetProperty
+XRequest.LBX.25: LbxTagData
+XRequest.LBX.26: LbxCopyArea
+XRequest.LBX.27: LbxCopyPlane
+XRequest.LBX.28: LbxPolyText8
+XRequest.LBX.29: LbxPolyText16
+XRequest.LBX.30: LbxImageText8
+XRequest.LBX.31: LbxImageText16
+XRequest.LBX.32: LbxQueryExtension
+XRequest.LBX.33: LbxPutImage
+XRequest.LBX.34: LbxGetImage
+XRequest.LBX.35: LbxBeginLargeRequest
+XRequest.LBX.36: LbxLargeRequestData
+XRequest.LBX.37: LbxEndLargeRequest
+XRequest.LBX.38: LbxInternAtoms
+XRequest.LBX.39: LbxGetWinAttrAndGeom
+XRequest.LBX.40: LbxGrabCmap
+XRequest.LBX.41: LbxReleaseCmap
+XRequest.LBX.42: LbxAllocColor
+XRequest.LBX.43: LbxSync
+XProtoError.LBX.0: BadLbxClient
+! XpExtension
+XRequest.XpExtension.0: PrintQueryVersion
+XRequest.XpExtension.1: PrintGetPrinterList
+XRequest.XpExtension.2: PrintCreateContext
+XRequest.XpExtension.3: PrintSetContext
+XRequest.XpExtension.4: PrintGetContext
+XRequest.XpExtension.5: PrintDestroyContext
+XRequest.XpExtension.6: PrintGetContextScreen
+XRequest.XpExtension.7: PrintStartJob
+XRequest.XpExtension.8: PrintEndJob
+XRequest.XpExtension.9: PrintStartDoc
+XRequest.XpExtension.10: PrintEndDoc
+XRequest.XpExtension.11: PrintPutDocumentData
+XRequest.XpExtension.12: PrintGetDocumentData
+XRequest.XpExtension.13: PrintStartPage
+XRequest.XpExtension.14: PrintEndPage
+XRequest.XpExtension.15: PrintSelectInput
+XRequest.XpExtension.16: PrintInputSelected
+XRequest.XpExtension.17: PrintGetAttributes
+XRequest.XpExtension.18: PrintSetAttributes
+XRequest.XpExtension.19: PrintGetOneAttribute
+XRequest.XpExtension.20: PrintRehashPrinterList
+XRequest.XpExtension.21: PrintGetPageDimensions
+XRequest.XpExtension.22: PrintQueryScreens
+XRequest.XpExtension.23: PrintSetImageResolution
+XRequest.XpExtension.24: PrintGetImageResolution
+XProtoError.XpExtension.0: XPBadContext (Print Context invalid or missing)
+XlibMessage.XpExtension.0: Context in failed request: 0x%lx
+XProtoError.XpExtension.1: XPBadSequence (Illegal sequence of XP operations)
+XProtoError.XpExtension.2: XPBadResourceID (X resource not valid)
+! TOG-CUP, an X Project Team specification
+XRequest.TOG-CUP.0: CUPQueryVersion
+XRequest.TOG-CUP.1: CUPGetReservedColormapEntries
+XRequest.TOG-CUP.2: CUPStoreColors
+! Extended-Visual-Information, an X Project Team specification
+XRequest.Extended-Visual-Information.0: EVIQueryVersion
+XRequest.Extended-Visual-Information.1: EVIGetVisualInfo
+! DPMS (Display Power Management Signaling), an X Project Team specification
+XRequest.DPMS.0: DPMSGetVersion
+XRequest.DPMS.1: DPMSCapable
+XRequest.DPMS.2: DPMSGetTimeouts
+XRequest.DPMS.3: DPMSSetTimeouts
+XRequest.DPMS.4: DPMSEnable
+XRequest.DPMS.5: DPMSDisable
+XRequest.DPMS.6: DPMSForceLevel
+XRequest.DPMS.7: DPMSInfo
+! XINERAMA, not an X Project Team specification
+XRequest.XINERAMA.0: XINERAMAQueryVersion
+XRequest.XINERAMA.1: XINERAMAGetState
+XRequest.XINERAMA.2: XINERAMAGetScreenCount
+XRequest.XINERAMA.3: XINERAMAGetScreenSize
+XRequest.XINERAMA.4: XINERAMAIsActive
+XRequest.XINERAMA.5: XINERAMAQueryScreens
+! XF86Rush extension, not a standard spec
+Xrequest.XFree86-Rush.0: XF86RushQueryVersion
+Xrequest.XFree86-Rush.1: XF86RushLockPixmap
+Xrequest.XFree86-Rush.2: XF86RushUnlockPixmap
+Xrequest.XFree86-Rush.3: XF86RushUnlockAllPixmaps
+Xrequest.XFree86-Rush.4: XF86RushGetCopyMode
+Xrequest.XFree86-Rush.5: XF86RushSetCopyMode
+Xrequest.XFree86-Rush.6: XF86RushGetPixelStride
+Xrequest.XFree86-Rush.7: XF86RushSetPixelStride
+Xrequest.XFree86-Rush.8: XF86RushOverlayPixmap
+Xrequest.XFree86-Rush.9: XF86RushStatusRegOffset
+Xrequest.XFree86-Rush.10: XF86RushAT3DEnableRegs
+Xrequest.XFree86-Rush.11: XF86RushAT3DDisableRegs
+! XVideo
+Xrequest.XVideo.0: XvQueryExtension
+Xrequest.XVideo.1: XvQueryAdaptors
+Xrequest.XVideo.2: XvQueryEncodings
+Xrequest.XVideo.3: XvGrabPort
+Xrequest.XVideo.4: XvUngrabPort
+Xrequest.XVideo.5: XvPutVideo
+Xrequest.XVideo.6: XvPutStill
+Xrequest.XVideo.7: XvGetVideo
+Xrequest.XVideo.8: XvGetStill
+Xrequest.XVideo.9: XvStopVideo
+Xrequest.XVideo.10: XvSelectVideoNotify
+Xrequest.XVideo.11: XvSelectPortNotify
+Xrequest.XVideo.12: XvQueryBestSize
+Xrequest.XVideo.13: XvSetPortAttribute
+Xrequest.XVideo.14: XvGetPortAttribute
+Xrequest.XVideo.15: XvQueryPortAttributes
+Xrequest.XVideo.16: XvListImageFormats
+Xrequest.XVideo.17: XvQueryImageAttributes
+Xrequest.XVideo.18: XvPutImage
+Xrequest.XVideo.19: XvShmPutImage
+XProtoError.XVideo.0: XvBadPort
+XProtoError.XVideo.1: XvBadEncoding
+XProtoError.XVideo.2: XvBadControl
+! XFree86-Bigfont
+Xrequest.XFree86-Bigfont.0: XF86BigfontQueryVersion
+Xrequest.XFree86-Bigfont.1: XF86BigfontQueryFont
+! Adobe-DPS-Extension, not a standard
+XRequest.Adobe-DPS-Extension.1: PSInit
+XRequest.Adobe-DPS-Extension.2: PSCreateContext
+XRequest.Adobe-DPS-Extension.3: PSCreateSpace
+XRequest.Adobe-DPS-Extension.4: PSGiveInput
+XRequest.Adobe-DPS-Extension.5: PSGetStatus
+XRequest.Adobe-DPS-Extension.6: PSDestroySpace
+XRequest.Adobe-DPS-Extension.7: PSReset
+XRequest.Adobe-DPS-Extension.8: PSNotifyContext
+XRequest.Adobe-DPS-Extension.9: PSCreateContextFromID
+XRequest.Adobe-DPS-Extension.10: PSXIDFromContext
+XRequest.Adobe-DPS-Extension.11: PSContextFromXID
+XRequest.Adobe-DPS-Extension.12: PSSetStatusMask
+XRequest.Adobe-DPS-Extension.13: PSCreateSecureContext
+XRequest.Adobe-DPS-Extension.14: PSNotifyWhenReady
+XProtoError.Adobe-DPS-Extension.0: PSErrorBadContext (invalid Context parameter)
+XlibMessage.Adobe-DPS-Extension.0: Context id in failed request: 0x%lx
+XProtoError.Adobe-DPS-Extension.1: PSErrorBadSpace (invalid Space parameter)
+XlibMessage.Adobe-DPS-Extension.1: Space id in failed request: 0x%lx
+XProtoError.Adobe-DPS-Extension.2: PSErrorAbort (interpreter aborted)
+XlibMessage.Adobe-DPS-Extension.2: Value in failed request: 0x%lx
+! RANDR
+XRequest.RANDR.0: RRQueryVersion
+XRequest.RANDR.1: RROldGetScreenInfo
+XRequest.RANDR.2: RRSetScreenConfig
+XRequest.RANDR.3: RROldScreenChangeSelectInput
+XRequest.RANDR.4: RRSelectInput
+XRequest.RANDR.5: RRGetScreenInfo
+XRequest.RANDR.6: RRGetScreenSizeRange
+XRequest.RANDR.7: RRSetScreenSize
+XRequest.RANDR.8: RRGetScreenResources
+XRequest.RANDR.9: RRGetOutputInfo
+XRequest.RANDR.10: RRListOutputProperties
+XRequest.RANDR.11: RRQueryOutputProperty
+XRequest.RANDR.12: RRConfigureOutputProperty
+XRequest.RANDR.13: RRChangeOutputProperty
+XRequest.RANDR.14: RRDeleteOutputProperty
+XRequest.RANDR.15: RRGetOutputProperty
+XRequest.RANDR.16: RRCreateMode
+XRequest.RANDR.17: RRDestroyMode
+XRequest.RANDR.18: RRAddOutputMode
+XRequest.RANDR.19: RRDeleteOutputMode
+XRequest.RANDR.20: RRGetCrtcInfo
+XRequest.RANDR.21: RRSetCrtcConfig
+XRequest.RANDR.22: RRGetCrtcGammaSize
+XRequest.RANDR.23: RRGetCrtcGamma
+XRequest.RANDR.24: RRSetCrtcGamma
+XRequest.RANDR.25: RRGetScreenResourcesCurrent
+XRequest.RANDR.26: RRSetCrtcTransform
+XRequest.RANDR.27: RRGetCrtcTransform
+XRequest.RANDR.28: RRGetPanning
+XRequest.RANDR.29: RRSetPanning
+XRequest.RANDR.30: RRSetOutputPrimary
+XRequest.RANDR.31: RRGetOutputPrimary
+XProtoError.RANDR.0: BadRROutput (invalid Output parameter)
+XlibMessage.RANDR.0: Output id in failed request: 0x%lx
+XProtoError.RANDR.1: BadRRCrtc (invalid Crtc parameter)
+XlibMessage.RANDR.1: Crtc id in failed request: 0x%lx
+XProtoError.RANDR.2: BadRRMode (invalid Mode parameter)
+XlibMessage.RANDR.2: Mode id in failed request: 0x%lx
+! RENDER
+XRequest.RENDER.0: RenderQueryVersion
+XRequest.RENDER.1: RenderQueryPictFormats
+XRequest.RENDER.2: RenderQueryPictIndexValues
+XRequest.RENDER.3: RenderQueryDithers
+XRequest.RENDER.4: RenderCreatePicture
+XRequest.RENDER.5: RenderChangePicture
+XRequest.RENDER.6: RenderSetPictureClipRectangles
+XRequest.RENDER.7: RenderFreePicture
+XRequest.RENDER.8: RenderComposite
+XRequest.RENDER.9: RenderScale
+XRequest.RENDER.10: RenderTrapezoids
+XRequest.RENDER.11: RenderTriangles
+XRequest.RENDER.12: RenderTriStrip
+XRequest.RENDER.13: RenderTriFan
+XRequest.RENDER.14: RenderColorTrapezoids
+XRequest.RENDER.15: RenderColorTriangles
+XRequest.RENDER.16: RenderTransform
+XRequest.RENDER.17: RenderCreateGlyphSet
+XRequest.RENDER.18: RenderReferenceGlyphSet
+XRequest.RENDER.19: RenderFreeGlyphSet
+XRequest.RENDER.20: RenderAddGlyphs
+XRequest.RENDER.21: RenderAddGlyphsFromPicture
+XRequest.RENDER.22: RenderFreeGlyphs
+XRequest.RENDER.23: RenderCompositeGlyphs8
+XRequest.RENDER.24: RenderCompositeGlyphs16
+XRequest.RENDER.25: RenderCompositeGlyphs32
+XRequest.RENDER.26: RenderFillRectangles
+XRequest.RENDER.27: RenderCreateCursor
+XRequest.RENDER.28: RenderSetPictureTransform
+XRequest.RENDER.29: RenderQueryFilters
+XRequest.RENDER.30: RenderSetPictureFilter
+XRequest.RENDER.31: RenderCreateAnimCursor
+XRequest.RENDER.32: RenderAddTraps
+XRequest.RENDER.33: RenderCreateSolidFill
+XRequest.RENDER.34: RenderCreateLinearGradient
+XRequest.RENDER.35: RenderCreateRadialGradient
+XRequest.RENDER.36: RenderCreateConicalGradient
+XProtoError.RENDER.0: RenderBadFormat (invalid PictFormat parameter)
+XlibMessage.RENDER.0: PictFormat id in failed request: 0x%lx
+XProtoError.RENDER.1: RenderBadPicture (invalid Picture parameter)
+XlibMessage.RENDER.1: Picture id in failed request: 0x%lx
+XProtoError.RENDER.2: RenderBadPictOp (invalid PictOp parameter)
+XlibMessage.RENDER.2: PictOp in failed request: 0x%lx
+XProtoError.RENDER.3: RenderBadGlyphSet (invalid GlyphSet parameter)
+XlibMessage.RENDER.3: GlyphSet id in failed request: 0x%lx
+XProtoError.RENDER.4: RenderBadGlyph (invalid Glyph parameter)
+XlibMessage.RENDER.4: Glyph in failed request: 0x%lx
+! XFixes
+XRequest.XFIXES.0: XFixesQueryVersion
+XRequest.XFIXES.1: XFixesChangeSaveSet
+XRequest.XFIXES.2: XFixesSelectSelectionInput
+XRequest.XFIXES.3: XFixesSelectCursorInput
+XRequest.XFIXES.4: XFixesGetCursorImage
+XRequest.XFIXES.5: XFixesCreateRegion
+XRequest.XFIXES.6: XFixesCreateRegionFromBitmap
+XRequest.XFIXES.7: XFixesCreateRegionFromWindow
+XRequest.XFIXES.8: XFixesCreateRegionFromGC
+XRequest.XFIXES.9: XFixesCreateRegionFromPicture
+XRequest.XFIXES.10: XFixesDestroyRegion
+XRequest.XFIXES.11: XFixesSetRegion
+XRequest.XFIXES.12: XFixesCopyRegion
+XRequest.XFIXES.13: XFixesUnionRegion
+XRequest.XFIXES.14: XFixesIntersectRegion
+XRequest.XFIXES.15: XFixesSubtractRegion
+XRequest.XFIXES.16: XFixesInvertRegion
+XRequest.XFIXES.17: XFixesTranslateRegion
+XRequest.XFIXES.18: XFixesRegionExtents
+XRequest.XFIXES.19: XFixesFetchRegion
+XRequest.XFIXES.20: XFixesSetGCClipRegion
+XRequest.XFIXES.21: XFixesSetWindowShapeRegion
+XRequest.XFIXES.22: XFixesSetPictureClipRegion
+XRequest.XFIXES.23: XFixesSetCursorName
+XRequest.XFIXES.24: XFixesGetCursorName
+XRequest.XFIXES.25: XFixesGetCursorImageAndName
+XRequest.XFIXES.26: XFixesChangeCursor
+XRequest.XFIXES.27: XFixesChangeCursorByName
+XRequest.XFIXES.28: XFixesExpandRegion
+XRequest.XFIXES.29: XFixesHideCursor
+XRequest.XFIXES.30: XFixesShowCursor
+XProtoError.XFIXES.0: BadRegion (invalid Region parameter)
+XlibMessage.XFIXES.0: Region id in failed request: 0x%lx
+! DAMAGE extension
+XRequest.DAMAGE.0: XDamageQueryVersion
+XRequest.DAMAGE.1: XDamageCreate
+XRequest.DAMAGE.2: XDamageDestroy
+XRequest.DAMAGE.3: XDamageSubtract
+XRequest.DAMAGE.4: XDamageAdd
+XProtoError.DAMAGE.0: BadDamage (invalid Damage parameter)
+XlibMessage.DAMAGE.0: Damage id in failed request: 0x%lx
+! DRI2 extension
+XRequest.DRI2.0: DRI2QueryVersion
+XRequest.DRI2.1: DRI2Connect
+XRequest.DRI2.2: DRI2Authenticate
+XRequest.DRI2.3: DRI2CreateDrawable
+XRequest.DRI2.4: DRI2DestroyDrawable
+XRequest.DRI2.5: DRI2GetBuffers
+XRequest.DRI2.6: DRI2CopyRegion
+XRequest.DRI2.7: DRI2GetBuffersWithFormat
+XRequest.DRI2.8: DRI2SwapBuffers
+XRequest.DRI2.9: DRI2GetMSC
+XRequest.DRI2.10: DRI2WaitMSC
+XRequest.DRI2.11: DRI2WaitSBC
+XRequest.DRI2.12: DRI2SwapInterval
diff --git a/libX11/src/XlibInt.c b/libX11/src/XlibInt.c
index 5047e48a8..13f8702aa 100644
--- a/libX11/src/XlibInt.c
+++ b/libX11/src/XlibInt.c
@@ -1,3678 +1,3686 @@
-/*
-
-Copyright 1985, 1986, 1987, 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.
-
-*/
-
-/*
- * XlibInt.c - Internal support routines for the C subroutine
- * interface library (Xlib) to the X Window System Protocol V11.0.
- */
-#define NEED_EVENTS
-#define NEED_REPLIES
-
-#ifdef WIN32
-#define _XLIBINT_
-#include <X11\Xw32defs.h>
-#endif
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "Xprivate.h"
-#include <X11/Xpoll.h>
-#if !USE_XCB
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/extensions/xcmiscstr.h>
-#endif /* !USE_XCB */
-#include <assert.h>
-#include <stdio.h>
-#ifdef WIN32
-#include <direct.h>
-#endif
-
-#ifdef XTHREADS
-#include "locking.h"
-
-/* these pointers get initialized by XInitThreads */
-LockInfoPtr _Xglobal_lock = NULL;
-void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
-/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */
-void (*_XFreeMutex_fn)(LockInfoPtr) = NULL;
-void (*_XLockMutex_fn)(
- LockInfoPtr /* lock */
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
- , char * /* file */
- , int /* line */
-#endif
- ) = NULL;
-void (*_XUnlockMutex_fn)(
- LockInfoPtr /* lock */
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
- , char * /* file */
- , int /* line */
-#endif
- ) = NULL;
-xthread_t (*_Xthread_self_fn)(void) = NULL;
-
-#define XThread_Self() ((*_Xthread_self_fn)())
-
-#if !USE_XCB
-#define UnlockNextReplyReader(d) if ((d)->lock) \
- (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
-
-#define QueueReplyReaderLock(d) ((d)->lock ? \
- (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
-#define QueueEventReaderLock(d) ((d)->lock ? \
- (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
-
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
-#define InternalLockDisplay(d,wskip) if ((d)->lock) \
- (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
-#else
-#define InternalLockDisplay(d,wskip) if ((d)->lock) \
- (*(d)->lock->internal_lock_display)(d,wskip)
-#endif
-#endif /* !USE_XCB */
-
-#else /* XTHREADS else */
-
-#if !USE_XCB
-#define UnlockNextReplyReader(d)
-#define UnlockNextEventReader(d)
-#define InternalLockDisplay(d,wskip)
-#endif /* !USE_XCB */
-
-#endif /* XTHREADS else */
-
-/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
- * systems are broken and return EWOULDBLOCK when they should return EAGAIN
- */
-#ifdef WIN32
-#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
-#else
-#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */
-#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
-#else
-#if defined(EAGAIN) && defined(EWOULDBLOCK)
-#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
-#else
-#ifdef EAGAIN
-#define ETEST() (errno == EAGAIN)
-#else
-#define ETEST() (errno == EWOULDBLOCK)
-#endif /* EAGAIN */
-#endif /* EAGAIN && EWOULDBLOCK */
-#endif /* __CYGWIN__ */
-#endif /* WIN32 */
-
-#ifdef WIN32
-#define ECHECK(err) (WSAGetLastError() == err)
-#define ESET(val) WSASetLastError(val)
-#else
-#ifdef __UNIXOS2__
-#define ECHECK(err) (errno == err)
-#define ESET(val)
-#else
-#define ECHECK(err) (errno == err)
-#define ESET(val) errno = val
-#endif
-#endif
-
-#if defined(LOCALCONN) || defined(LACHMAN)
-#ifdef EMSGSIZE
-#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
-#else
-#define ESZTEST() ECHECK(ERANGE)
-#endif
-#else
-#ifdef EMSGSIZE
-#define ESZTEST() ECHECK(EMSGSIZE)
-#endif
-#endif
-
-#ifdef __UNIXOS2__
-#if !USE_XCB
-#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
-#endif /* !USE_XCB */
-#include <limits.h>
-#define MAX_PATH _POSIX_PATH_MAX
-#endif
-
-#if !USE_XCB
-#ifdef MUSTCOPY
-
-#define STARTITERATE(tpvar,type,start,endcond) \
- { register char *cpvar; \
- for (cpvar = (char *) (start); endcond; ) { \
- type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
- tpvar = &dummy;
-#define ITERPTR(tpvar) cpvar
-#define RESETITERPTR(tpvar,type,start) cpvar = start
-#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
-#define ENDITERATE }}
-
-#else
-
-#define STARTITERATE(tpvar,type,start,endcond) \
- for (tpvar = (type *) (start); endcond; )
-#define ITERPTR(tpvar) (char *)tpvar
-#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
-#define INCITERPTR(tpvar,type) tpvar++
-#define ENDITERATE
-
-#endif /* MUSTCOPY */
-
-typedef union {
- xReply rep;
- char buf[BUFSIZE];
-} _XAlignedBuffer;
-
-static char *_XAsyncReply(
- Display *dpy,
- register xReply *rep,
- char *buf,
- register int *lenp,
- Bool discard);
-#endif /* !USE_XCB */
-
-/*
- * The following routines are internal routines used by Xlib for protocol
- * packet transmission and reception.
- *
- * _XIOError(Display *) will be called if any sort of system call error occurs.
- * This is assumed to be a fatal condition, i.e., XIOError should not return.
- *
- * _XError(Display *, xError *) will be called whenever an X_Error event is
- * received. This is not assumed to be a fatal condition, i.e., it is
- * acceptable for this procedure to return. However, XError should NOT
- * perform any operations (directly or indirectly) on the DISPLAY.
- *
- * Routines declared with a return type of 'Status' return 0 on failure,
- * and non 0 on success. Routines with no declared return type don't
- * return anything. Whenever possible routines that create objects return
- * the object they have created.
- */
-
-#if !USE_XCB
-static xReq _dummy_request = {
- 0, 0, 0
-};
-
-/*
- * This is an OS dependent routine which:
- * 1) returns as soon as the connection can be written on....
- * 2) if the connection can be read, must enqueue events and handle errors,
- * until the connection is writable.
- */
-static void
-_XWaitForWritable(
- Display *dpy
-#ifdef XTHREADS
- ,
- xcondition_t cv /* our reading condition variable */
-#endif
- )
-{
-#ifdef USE_POLL
- struct pollfd filedes;
-#else
- fd_set r_mask;
- fd_set w_mask;
-#endif
- int nfound;
-
-#ifdef USE_POLL
- filedes.fd = dpy->fd;
- filedes.events = 0;
-#else
- FD_ZERO(&r_mask);
- FD_ZERO(&w_mask);
-#endif
-
- for (;;) {
-#ifdef XTHREADS
- /* We allow only one thread at a time to read, to minimize
- passing of read data between threads.
- Now, who is it? If there is a non-NULL reply_awaiters and
- we (i.e., our cv) are not at the head of it, then whoever
- is at the head is the reader, and we don't read.
- Otherwise there is no reply_awaiters or we are at the
- head, having just appended ourselves.
- In this case, if there is a event_awaiters, then whoever
- is at the head of it got there before we did, and they are the
- reader.
-
- Last cases: no event_awaiters and we are at the head of
- reply_awaiters or reply_awaiters is NULL: we are the reader,
- since there is obviously no one else involved.
-
- XXX - what if cv is NULL and someone else comes along after
- us while we are waiting?
- */
-
- if (!dpy->lock ||
- (!dpy->lock->event_awaiters &&
- (!dpy->lock->reply_awaiters ||
- dpy->lock->reply_awaiters->cv == cv)))
-#endif
-#ifdef USE_POLL
- filedes.events = POLLIN;
- filedes.events |= POLLOUT;
-#else
- FD_SET(dpy->fd, &r_mask);
- FD_SET(dpy->fd, &w_mask);
-#endif
-
- do {
- UnlockDisplay(dpy);
-#ifdef USE_POLL
- nfound = poll (&filedes, 1, -1);
-#else
- nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
-#endif
- InternalLockDisplay(dpy, cv != NULL);
- if (nfound < 0 && !(ECHECK(EINTR) || ETEST()))
- _XIOError(dpy);
- } while (nfound <= 0);
-
- if (
-#ifdef USE_POLL
- filedes.revents & POLLIN
-#else
- FD_ISSET(dpy->fd, &r_mask)
-#endif
- )
- {
- _XAlignedBuffer buf;
- BytesReadable_t pend;
- register int len;
- register xReply *rep;
-
- /* find out how much data can be read */
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- len = pend;
-
- /* must read at least one xEvent; if none is pending, then
- we'll just block waiting for it */
- if (len < SIZEOF(xReply)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- )
- len = SIZEOF(xReply);
-
- /* but we won't read more than the max buffer size */
- if (len > BUFSIZE) len = BUFSIZE;
-
- /* round down to an integral number of XReps */
- len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
-
- (void) _XRead (dpy, buf.buf, (long) len);
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- int tmp = len;
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &tmp, True));
- len = tmp;
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *)rep);
- else /* must be an event packet */
- _XEnq (dpy, (xEvent *)rep);
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->event_awaiters)
- ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
-#endif
- }
-#ifdef USE_POLL
- if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
-#else
- if (FD_ISSET(dpy->fd, &w_mask))
-#endif
- {
-#ifdef XTHREADS
- if (dpy->lock) {
- ConditionBroadcast(dpy, dpy->lock->writers);
- }
-#endif
- return;
- }
- }
-}
-#endif /* !USE_XCB */
-
-
-#define POLLFD_CACHE_SIZE 5
-
-/* initialize the struct array passed to poll() below */
-Bool _XPollfdCacheInit(
- Display *dpy)
-{
-#ifdef USE_POLL
- struct pollfd *pfp;
-
- pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
- if (!pfp)
- return False;
- pfp[0].fd = dpy->fd;
- pfp[0].events = POLLIN;
-
- dpy->filedes = (XPointer)pfp;
-#endif
- return True;
-}
-
-void _XPollfdCacheAdd(
- Display *dpy,
- int fd)
-{
-#ifdef USE_POLL
- struct pollfd *pfp = (struct pollfd *)dpy->filedes;
-
- if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
- pfp[dpy->im_fd_length].fd = fd;
- pfp[dpy->im_fd_length].events = POLLIN;
- }
-#endif
-}
-
-/* ARGSUSED */
-void _XPollfdCacheDel(
- Display *dpy,
- int fd) /* not used */
-{
-#ifdef USE_POLL
- struct pollfd *pfp = (struct pollfd *)dpy->filedes;
- struct _XConnectionInfo *conni;
-
- /* just recalculate whole list */
- if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
- int loc = 1;
- for (conni = dpy->im_fd_info; conni; conni=conni->next) {
- pfp[loc].fd = conni->fd;
- pfp[loc].events = POLLIN;
- loc++;
- }
- }
-#endif
-}
-
-#if !USE_XCB
-/* returns True iff there is an event in the queue newer than serial_num */
-
-static Bool
-_XNewerQueuedEvent(
- Display *dpy,
- int serial_num)
-{
- _XQEvent *qev;
-
- if (dpy->next_event_serial_num == serial_num)
- return False;
-
- qev = dpy->head;
- while (qev) {
- if (qev->qserial_num >= serial_num) {
- return True;
- }
- qev = qev->next;
- }
- return False;
-}
-
-static int
-_XWaitForReadable(
- Display *dpy)
-{
- int result;
- int fd = dpy->fd;
- struct _XConnectionInfo *ilist;
- register int saved_event_serial = 0;
- int in_read_events = 0;
- register Bool did_proc_conni = False;
-#ifdef USE_POLL
- struct pollfd *filedes;
-#else
- fd_set r_mask;
- int highest_fd = fd;
-#endif
-
-#ifdef USE_POLL
- if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
- && !(dpy->flags & XlibDisplayProcConni)) {
- /* XXX - this fallback is gross */
- int i;
-
- filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
- filedes[0].fd = fd;
- filedes[0].events = POLLIN;
- for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
- filedes[i].fd = ilist->fd;
- filedes[i].events = POLLIN;
- }
- } else {
- filedes = (struct pollfd *)dpy->filedes;
- }
-#else
- FD_ZERO(&r_mask);
-#endif
- for (;;) {
-#ifndef USE_POLL
- FD_SET(fd, &r_mask);
- if (!(dpy->flags & XlibDisplayProcConni))
- for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
- FD_SET(ilist->fd, &r_mask);
- if (ilist->fd > highest_fd)
- highest_fd = ilist->fd;
- }
-#endif
- UnlockDisplay(dpy);
-#ifdef USE_POLL
- result = poll(filedes,
- (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
- -1);
-#else
- result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
-#endif
- InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
- if (result == -1 && !(ECHECK(EINTR) || ETEST())) _XIOError(dpy);
- if (result <= 0)
- continue;
-#ifdef USE_POLL
- if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
-#else
- if (FD_ISSET(fd, &r_mask))
-#endif
- break;
- if (!(dpy->flags & XlibDisplayProcConni)) {
- int i;
-
- saved_event_serial = dpy->next_event_serial_num;
- /* dpy flags can be clobbered by internal connection callback */
- in_read_events = dpy->flags & XlibDisplayReadEvents;
- for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
-#ifdef USE_POLL
- if (filedes[i].revents & POLLIN)
-#else
- if (FD_ISSET(ilist->fd, &r_mask))
-#endif
- {
- _XProcessInternalConnection(dpy, ilist);
- did_proc_conni = True;
- }
- }
-#ifdef USE_POLL
- if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
- Xfree(filedes);
-#endif
- }
- if (did_proc_conni) {
- /* some internal connection callback might have done an
- XPutBackEvent. We notice it here and if we needed an event,
- we can return all the way. */
- if (_XNewerQueuedEvent(dpy, saved_event_serial)
- && (in_read_events
-#ifdef XTHREADS
- || (dpy->lock && dpy->lock->event_awaiters)
-#endif
- ))
- return -2;
- did_proc_conni = False;
- }
- }
-#ifdef XTHREADS
-#ifdef XTHREADS_DEBUG
- printf("thread %x _XWaitForReadable returning\n", XThread_Self());
-#endif
-#endif
- return 0;
-}
-#endif /* !USE_XCB */
-
-#ifdef _MSC_VER
-#undef min
-#define min __min
-#endif
-
-static int sync_hazard(Display *dpy)
-{
- unsigned long span = dpy->request - dpy->last_request_read;
- unsigned long hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
- return span >= 65535 - hazard - 10;
-}
-
-static
-int _XSeqSyncFunction(
- register Display *dpy)
-{
- xGetInputFocusReply rep;
- register xReq *req;
- int sent_sync = 0;
-
- LockDisplay(dpy);
- if ((dpy->request - dpy->last_request_read) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
- GetEmptyReq(GetInputFocus, req);
- (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
- sent_sync = 1;
- } else if (sync_hazard(dpy))
- _XSetPrivSyncFunction(dpy);
- UnlockDisplay(dpy);
- if (sent_sync)
- SyncHandle();
- return 0;
-}
-
-static int
-_XPrivSyncFunction (Display *dpy)
-{
- assert(dpy->synchandler == _XPrivSyncFunction);
- assert((dpy->flags & XlibDisplayPrivSync) != 0);
- dpy->synchandler = dpy->savedsynchandler;
- dpy->savedsynchandler = NULL;
- dpy->flags &= ~XlibDisplayPrivSync;
- _XIDHandler(dpy);
- _XSeqSyncFunction(dpy);
- return 0;
-}
-
-void _XSetPrivSyncFunction(Display *dpy)
-{
- if (!(dpy->flags & XlibDisplayPrivSync)) {
- dpy->savedsynchandler = dpy->synchandler;
- dpy->synchandler = _XPrivSyncFunction;
- dpy->flags |= XlibDisplayPrivSync;
- }
-}
-
-void _XSetSeqSyncFunction(Display *dpy)
-{
- if (sync_hazard(dpy))
- _XSetPrivSyncFunction (dpy);
-}
-
-#if !USE_XCB
-#ifdef XTHREADS
-static void _XFlushInt(
- register Display *dpy,
- register xcondition_t cv);
-#endif
-
-/*
- * _XFlush - Flush the X request buffer. If the buffer is empty, no
- * action is taken. This routine correctly handles incremental writes.
- * This routine may have to be reworked if int < long.
- */
-void _XFlush(
- register Display *dpy)
-{
-#ifdef XTHREADS
- /* With multi-threading we introduce an internal routine to which
- we can pass a condition variable to do locking correctly. */
-
- _XFlushInt(dpy, NULL);
-}
-
-/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
- * locking correctly.
- */
-
-static void _XFlushInt(
- register Display *dpy,
- register xcondition_t cv)
-{
-#endif /* XTHREADS*/
- register long size, todo;
- register int write_stat;
- register char *bufindex;
- _XExtension *ext;
-
- /* This fix resets the bufptr to the front of the buffer so
- * additional appends to the bufptr will not corrupt memory. Since
- * the server is down, these appends are no-op's anyway but
- * callers of _XFlush() are not verifying this before they call it.
- */
- if (dpy->flags & XlibDisplayIOError)
- {
- dpy->bufptr = dpy->buffer;
- dpy->last_req = (char *)&_dummy_request;
- return;
- }
-
-#ifdef XTHREADS
- while (dpy->flags & XlibDisplayWriting) {
- if (dpy->lock) {
- ConditionWait(dpy, dpy->lock->writers);
- } else {
- _XWaitForWritable (dpy, cv);
- }
- }
-#endif
- size = todo = dpy->bufptr - dpy->buffer;
- if (!size) return;
-#ifdef XTHREADS
- dpy->flags |= XlibDisplayWriting;
- /* make sure no one else can put in data */
- dpy->bufptr = dpy->bufmax;
-#endif
- for (ext = dpy->flushes; ext; ext = ext->next_flush)
- (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
- bufindex = dpy->buffer;
- /*
- * While write has not written the entire buffer, keep looping
- * until the entire buffer is written. bufindex will be
- * incremented and size decremented as buffer is written out.
- */
- while (size) {
- ESET(0);
- write_stat = _X11TransWrite(dpy->trans_conn,
- bufindex, (int) todo);
- if (write_stat >= 0) {
- size -= write_stat;
- todo = size;
- bufindex += write_stat;
- } else if (ETEST()) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
-#ifdef SUNSYSV
- } else if (ECHECK(0)) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
-#endif
-#ifdef ESZTEST
- } else if (ESZTEST()) {
- if (todo > 1)
- todo >>= 1;
- else {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
- }
-#endif
- } else if (!ECHECK(EINTR)) {
- /* Write failed! */
- /* errno set by write system call. */
- _XIOError(dpy);
- }
- }
- dpy->last_req = (char *)&_dummy_request;
- _XSetSeqSyncFunction(dpy);
- dpy->bufptr = dpy->buffer;
-#ifdef XTHREADS
- dpy->flags &= ~XlibDisplayWriting;
-#endif
-}
-
-int
-_XEventsQueued(
- register Display *dpy,
- int mode)
-{
- register int len;
- BytesReadable_t pend;
- _XAlignedBuffer buf;
- register xReply *rep;
- char *read_buf;
-#ifdef XTHREADS
- int entry_event_serial_num;
- struct _XCVList *cvl = NULL;
- xthread_t self;
-
-#ifdef XTHREADS_DEBUG
- printf("_XEventsQueued called in thread %x\n", XThread_Self());
-#endif
-#endif /* XTHREADS*/
-
- if (mode == QueuedAfterFlush)
- {
- _XFlush(dpy);
- if (dpy->qlen)
- return(dpy->qlen);
- }
- if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
-
-#ifdef XTHREADS
- /* create our condition variable and append to list,
- * unless we were called from within XProcessInternalConnection
- * or XLockDisplay
- */
- xthread_clear_id(self);
- if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
- || xthread_have_id (dpy->lock->locking_thread)))
- /* some thread is in XProcessInternalConnection or XLockDisplay
- so we have to see if we are it */
- self = XThread_Self();
- if (!xthread_have_id(self)
- || (!xthread_equal(self, dpy->lock->conni_thread)
- && !xthread_equal(self, dpy->lock->locking_thread))) {
- /* In the multi-threaded case, if there is someone else
- reading events, then there aren't any available, so
- we just return. If we waited we would block.
- */
- if (dpy->lock && dpy->lock->event_awaiters)
- return dpy->qlen;
- /* nobody here but us, so lock out any newcomers */
- cvl = QueueEventReaderLock(dpy);
- }
-
- while (dpy->lock && cvl && dpy->lock->reply_first) {
- /* note which events we have already seen so we'll know
- if _XReply (in another thread) reads one */
- entry_event_serial_num = dpy->next_event_serial_num;
- ConditionWait(dpy, cvl->cv);
- /* did _XReply read an event we can return? */
- if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
- {
- UnlockNextEventReader(dpy);
- return 0;
- }
- }
-#endif /* XTHREADS*/
-
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
-#ifdef XCONN_CHECK_FREQ
- /* This is a crock, required because FIONREAD or equivalent is
- * not guaranteed to detect a broken connection.
- */
- if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
- {
- int result;
-#ifdef USE_POLL
- struct pollfd filedes;
-#else
- fd_set r_mask;
- static struct timeval zero_time;
-#endif
-
- dpy->conn_checker = 0;
-#ifdef USE_POLL
- filedes.fd = dpy->fd;
- filedes.events = POLLIN;
- if ((result = poll(&filedes, 1, 0)))
-#else
- FD_ZERO(&r_mask);
- FD_SET(dpy->fd, &r_mask);
- if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
-#endif
- {
- if (result > 0)
- {
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- /* we should not get zero, if we do, force a read */
- if (!pend)
- pend = SIZEOF(xReply);
- }
- else if (result < 0 && !(ECHECK(EINTR) || ETEST()))
- _XIOError(dpy);
- }
- }
-#endif /* XCONN_CHECK_FREQ */
- if (!(len = pend)) {
- /* _XFlush can enqueue events */
-#ifdef XTHREADS
- if (cvl)
-#endif
- {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen);
- }
- /* Force a read if there is not enough data. Otherwise,
- * a select() loop at a higher-level will spin undesirably,
- * and we've seen at least one OS that appears to not update
- * the result from FIONREAD once it has returned nonzero.
- */
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_awaiters) {
- read_buf = (char *)dpy->lock->reply_awaiters->buf;
- len = SIZEOF(xReply);
- } else
-#endif /* XTHREADS*/
- {
- read_buf = buf.buf;
-
- if (len < SIZEOF(xReply)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- )
- len = SIZEOF(xReply);
- else if (len > BUFSIZE)
- len = BUFSIZE;
- len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
- }
-#ifdef XCONN_CHECK_FREQ
- dpy->conn_checker = 0;
-#endif
-
- (void) _XRead (dpy, read_buf, (long) len);
-
-#ifdef XTHREADS
- /* what did we actually read: reply or event? */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- if (((xReply *)read_buf)->generic.type == X_Reply ||
- ((xReply *)read_buf)->generic.type == X_Error)
- {
- dpy->lock->reply_was_read = True;
- dpy->lock->reply_first = True;
- if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
- memcpy(dpy->lock->reply_awaiters->buf, read_buf,
- len);
- if (cvl) {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen); /* we read, so we can return */
- } else if (read_buf != buf.buf)
- memcpy(buf.buf, read_buf, len);
- }
-#endif /* XTHREADS*/
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- int tmp = len;
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &tmp, True));
- len = tmp;
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *)rep);
- else /* must be an event packet */
- _XEnq (dpy, (xEvent *)rep);
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE
-
-#ifdef XTHREADS
- if (cvl)
-#endif
- {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen);
-}
-
-/* _XReadEvents - Flush the output queue,
- * then read as many events as possible (but at least 1) and enqueue them
- */
-void _XReadEvents(
- register Display *dpy)
-{
- _XAlignedBuffer buf;
- BytesReadable_t pend;
- int len;
- register xReply *rep;
- Bool not_yet_flushed = True;
- char *read_buf;
- int i;
- int entry_event_serial_num = dpy->next_event_serial_num;
-#ifdef XTHREADS
- struct _XCVList *cvl = NULL;
- xthread_t self;
-
-#ifdef XTHREADS_DEBUG
- printf("_XReadEvents called in thread %x\n",
- XThread_Self());
-#endif
- /* create our condition variable and append to list,
- * unless we were called from within XProcessInternalConnection
- * or XLockDisplay
- */
- xthread_clear_id(self);
- if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
- || xthread_have_id (dpy->lock->locking_thread)))
- /* some thread is in XProcessInternalConnection or XLockDisplay
- so we have to see if we are it */
- self = XThread_Self();
- if (!xthread_have_id(self)
- || (!xthread_equal(self, dpy->lock->conni_thread)
- && !xthread_equal(self, dpy->lock->locking_thread)))
- cvl = QueueEventReaderLock(dpy);
-#endif /* XTHREADS */
-
- do {
-#ifdef XTHREADS
- /* if it is not our turn to read an event off the wire,
- wait til we're at head of list */
- if (dpy->lock && cvl &&
- (dpy->lock->event_awaiters != cvl ||
- dpy->lock->reply_first)) {
- ConditionWait(dpy, cvl->cv);
- continue;
- }
-#endif /* XTHREADS */
- /* find out how much data can be read */
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- len = pend;
-
- /* must read at least one xEvent; if none is pending, then
- we'll just flush and block waiting for it */
- if (len < SIZEOF(xEvent)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- ) {
- len = SIZEOF(xEvent);
- /* don't flush until the first time we would block */
- if (not_yet_flushed) {
- _XFlush (dpy);
- if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
- /* _XReply has read an event for us */
- goto got_event;
- }
- not_yet_flushed = False;
- }
- }
-
-#ifdef XTHREADS
- /* If someone is waiting for a reply, gamble that
- the reply will be the next thing on the wire
- and read it into their buffer. */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- read_buf = (char *)dpy->lock->reply_awaiters->buf;
- len = SIZEOF(xReply);
- } else
-#endif /* XTHREADS*/
- {
- read_buf = buf.buf;
-
- /* but we won't read more than the max buffer size */
- if (len > BUFSIZE)
- len = BUFSIZE;
-
- /* round down to an integral number of XReps */
- len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
- }
-
-#ifdef XTHREADS
- if (xthread_have_id(self))
- /* save value we may have to stick in conni_thread */
- dpy->lock->reading_thread = self;
-#endif /* XTHREADS */
- dpy->flags |= XlibDisplayReadEvents;
- i = _XRead (dpy, read_buf, (long) len);
- dpy->flags &= ~XlibDisplayReadEvents;
- if (i == -2) {
- /* special flag from _XRead to say that internal connection has
- done XPutBackEvent. Which we can use so we're done. */
- got_event:
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->lock_wait) {
- if (dpy->lock->event_awaiters != cvl)
- /* since it is not us, must be user lock thread */
- ConditionSignal(dpy,
- dpy->lock->event_awaiters->cv);
- (*dpy->lock->lock_wait)(dpy);
- continue;
- }
-#endif
- break;
- }
-#ifdef XTHREADS
- if (xthread_have_id(self))
- xthread_clear_id(dpy->lock->reading_thread);
-
- /* what did we actually read: reply or event? */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- if (((xReply *)read_buf)->generic.type == X_Reply ||
- ((xReply *)read_buf)->generic.type == X_Error)
- {
- dpy->lock->reply_was_read = True;
- dpy->lock->reply_first = True;
- if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
- memcpy(dpy->lock->reply_awaiters->buf,
- read_buf, len);
- ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
- continue;
- } else if (read_buf != buf.buf)
- memcpy(buf.buf, read_buf, len);
- }
-#endif /* XTHREADS */
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &len, True));
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *) rep);
- else /* must be an event packet */
- {
- if (rep->generic.type == GenericEvent)
- {
- int evlen;
- evlen = (rep->generic.length << 2);
- if (_XRead(dpy, &read_buf[len], evlen) == -2)
- goto got_event; /* XXX: aargh! */
- }
-
- _XEnq (dpy, (xEvent *)rep);
- }
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE;
- } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
-
- UnlockNextEventReader(dpy);
-}
-
-/*
- * _XRead - Read bytes from the socket taking into account incomplete
- * reads. This routine may have to be reworked if int < long.
- */
-int _XRead(
- register Display *dpy,
- register char *data,
- register long size)
-{
- register long bytes_read;
-#ifdef XTHREADS
- int original_size = size;
-#endif
-
- if ((dpy->flags & XlibDisplayIOError) || size == 0)
- return 0;
- ESET(0);
- while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
- != size) {
-
- if (bytes_read > 0) {
- size -= bytes_read;
- data += bytes_read;
- }
- else if (ETEST()) {
- if (_XWaitForReadable(dpy) == -2)
- return -2; /* internal connection did XPutBackEvent */
- ESET(0);
- }
-#ifdef SUNSYSV
- else if (ECHECK(0)) {
- if (_XWaitForReadable(dpy) == -2)
- return -2; /* internal connection did XPutBackEvent */
- }
-#endif
- else if (bytes_read == 0) {
- /* Read failed because of end of file! */
- ESET(EPIPE);
- _XIOError(dpy);
- }
-
- else /* bytes_read is less than 0; presumably -1 */ {
- /* If it's a system call interrupt, it's not an error. */
- if (!ECHECK(EINTR))
- _XIOError(dpy);
- }
- }
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_bytes_left > 0)
- {
- dpy->lock->reply_bytes_left -= original_size;
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- }
-#endif /* XTHREADS*/
- return 0;
-}
-#endif /* !USE_XCB */
-
-#ifdef LONG64
-void _XRead32(
- Display *dpy,
- register long *data,
- long len)
-{
- register int *buf;
- register long i;
-
- if (len) {
- (void) _XRead(dpy, (char *)data, len);
- i = len >> 2;
- buf = (int *)data + i;
- data += i;
- while (--i >= 0)
- *--data = *--buf;
- }
-}
-#endif /* LONG64 */
-
-#ifdef WORD64
-
-/*
- * XXX This is a *really* stupid way of doing this....
- * PACKBUFFERSIZE must be a multiple of 4.
- */
-
-#define PACKBUFFERSIZE 4096
-
-
-/*
- * _XRead32 - Read bytes from the socket unpacking each 32 bits
- * into a long (64 bits on a CRAY computer).
- *
- */
-static void _doXRead32(
- register Display *dpy,
- register long *data
- register long size,
- register char *packbuffer)
-{
- long *lpack,*lp;
- long mask32 = 0x00000000ffffffff;
- long maskw, nwords, i, bits;
-
- _XReadPad (dpy, packbuffer, size);
-
- lp = data;
- lpack = (long *) packbuffer;
- nwords = size >> 2;
- bits = 32;
-
- for(i=0;i<nwords;i++){
- maskw = mask32 << bits;
- *lp++ = ( *lpack & maskw ) >> bits;
- bits = bits ^32;
- if(bits){
- lpack++;
- }
- }
-}
-
-void _XRead32(
- Display *dpy,
- long *data,
- long len)
-{
- char packbuffer[PACKBUFFERSIZE];
- unsigned nunits = PACKBUFFERSIZE >> 2;
-
- for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
- _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
- }
- if (len) _doXRead32 (dpy, data, len, packbuffer);
-}
-
-
-
-/*
- * _XRead16 - Read bytes from the socket unpacking each 16 bits
- * into a long (64 bits on a CRAY computer).
- *
- */
-static _doXRead16(
- register Display *dpy,
- register short *data,
- register long size,
- char *packbuffer)
-{
- long *lpack,*lp;
- long mask16 = 0x000000000000ffff;
- long maskw, nwords, i, bits;
-
- (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
-
- lp = (long *) data;
- lpack = (long *) packbuffer;
- nwords = size >> 1; /* number of 16 bit words to be unpacked */
- bits = 48;
- for(i=0;i<nwords;i++){
- maskw = mask16 << bits;
- *lp++ = ( *lpack & maskw ) >> bits;
- bits -= 16;
- if(bits < 0){
- lpack++;
- bits = 48;
- }
- }
-}
-
-void _XRead16(
- Display *dpy,
- short *data,
- long len)
-{
- char packbuffer[PACKBUFFERSIZE];
- unsigned nunits = PACKBUFFERSIZE >> 1;
-
- for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
- _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
- }
- if (len) _doXRead16 (dpy, data, len, packbuffer);
-}
-
-void _XRead16Pad(
- Display *dpy,
- short *data,
- long size)
-{
- int slop = (size & 3);
- short slopbuf[3];
-
- _XRead16 (dpy, data, size);
- if (slop > 0) {
- _XRead16 (dpy, slopbuf, 4 - slop);
- }
-}
-#endif /* WORD64 */
-
-
-#if !USE_XCB
-/*
- * _XReadPad - Read bytes from the socket taking into account incomplete
- * reads. If the number of bytes is not 0 mod 4, read additional pad
- * bytes. This routine may have to be reworked if int < long.
- */
-void _XReadPad(
- register Display *dpy,
- register char *data,
- register long size)
-{
- register long bytes_read;
- struct iovec iov[2];
- char pad[3];
-#ifdef XTHREADS
- int original_size;
-#endif
-
- if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
- iov[0].iov_len = (int)size;
- iov[0].iov_base = data;
- /*
- * The following hack is used to provide 32 bit long-word
- * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
- * whatever is needed.
- */
-
- iov[1].iov_len = -size & 3;
- iov[1].iov_base = pad;
- size += iov[1].iov_len;
-#ifdef XTHREADS
- original_size = size;
-#endif
- ESET(0);
- while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
-
- if (bytes_read > 0) {
- size -= bytes_read;
- if (iov[0].iov_len < bytes_read) {
- int pad_bytes_read = bytes_read - iov[0].iov_len;
- iov[1].iov_len -= pad_bytes_read;
- iov[1].iov_base =
- (char *)iov[1].iov_base + pad_bytes_read;
- iov[0].iov_len = 0;
- }
- else {
- iov[0].iov_len -= bytes_read;
- iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
- }
- }
- else if (ETEST()) {
- _XWaitForReadable(dpy);
- ESET(0);
- }
-#ifdef SUNSYSV
- else if (ECHECK(0)) {
- _XWaitForReadable(dpy);
- }
-#endif
- else if (bytes_read == 0) {
- /* Read failed because of end of file! */
- ESET(EPIPE);
- _XIOError(dpy);
- }
-
- else /* bytes_read is less than 0; presumably -1 */ {
- /* If it's a system call interrupt, it's not an error. */
- if (!ECHECK(EINTR))
- _XIOError(dpy);
- }
- }
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_bytes_left > 0)
- {
- dpy->lock->reply_bytes_left -= original_size;
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- }
-#endif /* XTHREADS*/
-}
-
-/*
- * _XSend - Flush the buffer and send the client data. 32 bit word aligned
- * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
- * This routine may have to be reworked if int < long;
- */
-void
-_XSend (
- register Display *dpy,
- _Xconst char *data,
- register long size)
-{
- struct iovec iov[3];
- static char const pad[3] = {0, 0, 0};
- /* XText8 and XText16 require that the padding bytes be zero! */
-
- long skip, dbufsize, padsize, total, todo;
- _XExtension *ext;
-
- if (!size || (dpy->flags & XlibDisplayIOError)) return;
- dbufsize = dpy->bufptr - dpy->buffer;
-#ifdef XTHREADS
- dpy->flags |= XlibDisplayWriting;
- /* make sure no one else can put in data */
- dpy->bufptr = dpy->bufmax;
-#endif
- padsize = -size & 3;
- for (ext = dpy->flushes; ext; ext = ext->next_flush) {
- (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
- (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
- if (padsize)
- (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
- }
- skip = 0;
- todo = total = dbufsize + size + padsize;
-
- /*
- * There are 3 pieces that may need to be written out:
- *
- * o whatever is in the display buffer
- * o the data passed in by the user
- * o any padding needed to 32bit align the whole mess
- *
- * This loop looks at all 3 pieces each time through. It uses skip
- * to figure out whether or not a given piece is needed.
- */
- while (total) {
- long before = skip; /* amount of whole thing written */
- long remain = todo; /* amount to try this time, <= total */
- int i = 0;
- long len;
-
- /* You could be very general here and have "in" and "out" iovecs
- * and write a loop without using a macro, but what the heck. This
- * translates to:
- *
- * how much of this piece is new?
- * if more new then we are trying this time, clamp
- * if nothing new
- * then bump down amount already written, for next piece
- * else put new stuff in iovec, will need all of next piece
- *
- * Note that todo had better be at least 1 or else we'll end up
- * writing 0 iovecs.
- */
-#define InsertIOV(pointer, length) \
- len = (length) - before; \
- if (len > remain) \
- len = remain; \
- if (len <= 0) { \
- before = (-len); \
- } else { \
- iov[i].iov_len = len; \
- iov[i].iov_base = (pointer) + before; \
- i++; \
- remain -= len; \
- before = 0; \
- }
-
- InsertIOV (dpy->buffer, dbufsize)
- InsertIOV ((char *)data, size)
- InsertIOV ((char *)pad, padsize)
-
- ESET(0);
- if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
- skip += len;
- total -= len;
- todo = total;
- } else if (ETEST()) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
-#ifdef SUNSYSV
- } else if (ECHECK(0)) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
-#endif
-#ifdef ESZTEST
- } else if (ESZTEST()) {
- if (todo > 1)
- todo >>= 1;
- else {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
- }
-#endif
- } else if (!ECHECK(EINTR)) {
- _XIOError(dpy);
- }
- }
- dpy->last_req = (char *) & _dummy_request;
- _XSetSeqSyncFunction(dpy);
- dpy->bufptr = dpy->buffer;
-#ifdef XTHREADS
- dpy->flags &= ~XlibDisplayWriting;
-#endif
- return;
-}
-
-static void
-_XGetMiscCode(
- register Display *dpy)
-{
- xQueryExtensionReply qrep;
- register xQueryExtensionReq *qreq;
- xXCMiscGetVersionReply vrep;
- register xXCMiscGetVersionReq *vreq;
-
- if (dpy->xcmisc_opcode)
- return;
- GetReq(QueryExtension, qreq);
- qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
- qreq->length += (qreq->nbytes+(unsigned)3)>>2;
- _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
- if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
- dpy->xcmisc_opcode = -1;
- else {
- GetReq(XCMiscGetVersion, vreq);
- vreq->reqType = qrep.major_opcode;
- vreq->miscReqType = X_XCMiscGetVersion;
- vreq->majorVersion = XCMiscMajorVersion;
- vreq->minorVersion = XCMiscMinorVersion;
- if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
- dpy->xcmisc_opcode = -1;
- else
- dpy->xcmisc_opcode = qrep.major_opcode;
- }
-}
-
-int
-_XIDHandler(
- register Display *dpy)
-{
- xXCMiscGetXIDRangeReply grep;
- register xXCMiscGetXIDRangeReq *greq;
- int sent_req = 0;
-
- LockDisplay(dpy);
- if (dpy->resource_max == dpy->resource_mask + 1) {
- _XGetMiscCode(dpy);
- if (dpy->xcmisc_opcode > 0) {
- GetReq(XCMiscGetXIDRange, greq);
- greq->reqType = dpy->xcmisc_opcode;
- greq->miscReqType = X_XCMiscGetXIDRange;
- if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
- dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
- dpy->resource_shift);
- dpy->resource_max = dpy->resource_id;
- if (grep.count > 5)
- dpy->resource_max += grep.count - 6;
- dpy->resource_max <<= dpy->resource_shift;
- }
- sent_req = 1;
- }
- }
- UnlockDisplay(dpy);
- if (sent_req)
- SyncHandle();
- return 0;
-}
-
-/*
- * _XAllocID - resource ID allocation routine.
- */
-XID _XAllocID(
- register Display *dpy)
-{
- XID id;
-
- id = dpy->resource_id << dpy->resource_shift;
- if (id >= dpy->resource_max) {
- _XSetPrivSyncFunction(dpy);
- dpy->resource_max = dpy->resource_mask + 1;
- }
- if (id <= dpy->resource_mask) {
- dpy->resource_id++;
- return (dpy->resource_base + id);
- }
- if (id != 0x10000000) {
- (void) fprintf(stderr,
- "Xlib: resource ID allocation space exhausted!\n");
- id = 0x10000000;
- dpy->resource_id = id >> dpy->resource_shift;
- }
- return id;
-}
-
-/*
- * _XAllocIDs - multiple resource ID allocation routine.
- */
-void _XAllocIDs(
- register Display *dpy,
- XID *ids,
- int count)
-{
- XID id;
- int i;
- xXCMiscGetXIDListReply grep;
- register xXCMiscGetXIDListReq *greq;
-
- id = dpy->resource_id << dpy->resource_shift;
- if (dpy->resource_max <= dpy->resource_mask &&
- id <= dpy->resource_mask &&
- (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
- id += dpy->resource_base;
- for (i = 0; i < count; i++) {
- ids[i] = id;
- id += (1 << dpy->resource_shift);
- dpy->resource_id++;
- }
- return;
- }
- grep.count = 0;
- _XGetMiscCode(dpy);
- if (dpy->xcmisc_opcode > 0) {
- GetReq(XCMiscGetXIDList, greq);
- greq->reqType = dpy->xcmisc_opcode;
- greq->miscReqType = X_XCMiscGetXIDList;
- greq->count = count;
- if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
- _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
- for (i = 0; i < grep.count; i++) {
- id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
- if (id >= dpy->resource_id)
- dpy->resource_id = id;
- }
- if (id >= dpy->resource_max) {
- _XSetPrivSyncFunction(dpy);
- dpy->resource_max = dpy->resource_mask + 1;
- }
- }
- }
- for (i = grep.count; i < count; i++)
- ids[i] = XAllocID(dpy);
-}
-#endif /* !USE_XCB */
-
-/*
- * The hard part about this is that we only get 16 bits from a reply.
- * We have three values that will march along, with the following invariant:
- * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
- * We have to keep
- * dpy->request - dpy->last_request_read < 2^16
- * or else we won't know for sure what value to use in events. We do this
- * by forcing syncs when we get close.
- */
-
-unsigned long
-_XSetLastRequestRead(
- register Display *dpy,
- register xGenericReply *rep)
-{
- register unsigned long newseq, lastseq;
-
- lastseq = dpy->last_request_read;
- /*
- * KeymapNotify has no sequence number, but is always guaranteed
- * to immediately follow another event, except when generated via
- * SendEvent (hmmm).
- */
- if ((rep->type & 0x7f) == KeymapNotify)
- return(lastseq);
-
- newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
-
- if (newseq < lastseq) {
- newseq += 0x10000;
- if (newseq > dpy->request) {
- (void) fprintf (stderr,
- "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
- newseq, dpy->request,
- (unsigned int) rep->type);
- newseq -= 0x10000;
- }
- }
-
- dpy->last_request_read = newseq;
- return(newseq);
-}
-
-#if !USE_XCB
-/*
- * _XReply - Wait for a reply packet and copy its contents into the
- * specified rep. Meanwhile we must handle error and event packets that
- * we may encounter.
- */
-Status
-_XReply (
- register Display *dpy,
- register xReply *rep,
- int extra, /* number of 32-bit words expected after the reply */
- Bool discard) /* should I discard data following "extra" words? */
-{
- /* Pull out the serial number now, so that (currently illegal) requests
- * generated by an error handler don't confuse us.
- */
- unsigned long cur_request = dpy->request;
-#ifdef XTHREADS
- struct _XCVList *cvl;
-#endif
-
- if (dpy->flags & XlibDisplayIOError)
- return 0;
-
-#ifdef XTHREADS
- /* create our condition variable and append to list */
- cvl = QueueReplyReaderLock(dpy);
- if (cvl) {
- cvl->buf = rep;
- if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
- dpy->lock->reply_first = True;
- }
-
-#ifdef XTHREADS_DEBUG
- printf("_XReply called in thread %x, adding %x to cvl\n",
- XThread_Self(), cvl);
-#endif
-
- _XFlushInt(dpy, cvl ? cvl->cv : NULL);
- /* if it is not our turn to read a reply off the wire,
- * wait til we're at head of list. if there is an event waiter,
- * and our reply hasn't been read, they'll be in select and will
- * hand control back to us next.
- */
- if(dpy->lock &&
- (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
- ConditionWait(dpy, cvl->cv);
- }
- dpy->flags |= XlibDisplayReply;
-#else /* XTHREADS else */
- _XFlush(dpy);
-#endif
-
- for (;;) {
-#ifdef XTHREADS
- /* Did another thread's _XReadEvents get our reply by accident? */
- if (!dpy->lock || !dpy->lock->reply_was_read)
-#endif
- (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
-#ifdef XTHREADS
- if (dpy->lock)
- dpy->lock->reply_was_read = False;
-#endif
-
- switch ((int)rep->generic.type) {
-
- case X_Reply:
- /* Reply received. Fast update for synchronous replies,
- * but deal with multiple outstanding replies.
- */
- if (rep->generic.sequenceNumber == (cur_request & 0xffff))
- dpy->last_request_read = cur_request;
- else {
- int pend = SIZEOF(xReply);
- if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
- != (char *)rep)
- continue;
- }
- if (extra <= rep->generic.length) {
- if (extra > 0)
- /*
- * Read the extra data into storage immediately
- * following the GenericReply structure.
- */
- (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
- ((long)extra) << 2);
- if (discard) {
- if (extra < rep->generic.length)
- _XEatData(dpy, (rep->generic.length - extra) << 2);
- }
-#ifdef XTHREADS
- if (dpy->lock) {
- if (discard) {
- dpy->lock->reply_bytes_left = 0;
- } else {
- dpy->lock->reply_bytes_left =
- (rep->generic.length - extra) << 2;
- }
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- } else
- dpy->flags &= ~XlibDisplayReply;
-#endif
- return 1;
- }
- /*
- *if we get here, then extra > rep->generic.length--meaning we
- * read a reply that's shorter than we expected. This is an
- * error, but we still need to figure out how to handle it...
- */
- (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
- ((long) rep->generic.length) << 2);
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- _XIOError (dpy);
- return (0);
-
- case X_Error:
- {
- register _XExtension *ext;
- register Bool ret = False;
- int ret_code;
- xError *err = (xError *) rep;
- unsigned long serial;
-
- dpy->flags &= ~XlibDisplayReply;
- serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
- if (serial == cur_request)
- /* do not die on "no such font", "can't allocate",
- "can't grab" failures */
- switch ((int)err->errorCode) {
- case BadName:
- switch (err->majorCode) {
- case X_LookupColor:
- case X_AllocNamedColor:
- UnlockNextReplyReader(dpy);
- return(0);
- }
- break;
- case BadFont:
- if (err->majorCode == X_QueryFont) {
- UnlockNextReplyReader(dpy);
- return (0);
- }
- break;
- case BadAlloc:
- case BadAccess:
- UnlockNextReplyReader(dpy);
- return (0);
- }
- /*
- * we better see if there is an extension who may
- * want to suppress the error.
- */
- for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
- if (ext->error)
- ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
- }
- if (!ret) {
- _XError(dpy, err);
- ret_code = 0;
- }
- if (serial == cur_request) {
- UnlockNextReplyReader(dpy);
- return(ret_code);
- }
-
- } /* case X_Error */
- break;
- default:
- _XEnq(dpy, (xEvent *) rep);
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->event_awaiters)
- ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
-#endif
- break;
- }
- }
-}
-
-static char *
-_XAsyncReply(
- Display *dpy,
- register xReply *rep,
- char *buf,
- register int *lenp,
- Bool discard)
-{
- register _XAsyncHandler *async, *next;
- register int len;
- register Bool consumed = False;
- char *nbuf;
-
- (void) _XSetLastRequestRead(dpy, &rep->generic);
- len = SIZEOF(xReply) + (rep->generic.length << 2);
- if (len < SIZEOF(xReply)) {
- _XIOError (dpy);
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
-
- for (async = dpy->async_handlers; async; async = next) {
- next = async->next;
- if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
- break;
- }
- if (!consumed) {
- if (!discard)
- return buf;
- (void) fprintf(stderr,
- "Xlib: unexpected async reply (sequence 0x%lx)!\n",
- dpy->last_request_read);
-#ifdef XTHREADS
-#ifdef XTHREADS_DEBUG
- printf("thread %x, unexpected async reply\n", XThread_Self());
-#endif
-#endif
- if (len > *lenp)
- _XEatData(dpy, len - *lenp);
- }
- if (len < SIZEOF(xReply))
- {
- _XIOError (dpy);
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
- if (len >= *lenp) {
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
- *lenp -= len;
- buf += len;
- len = *lenp;
- nbuf = buf;
- while (len > SIZEOF(xReply)) {
- if (*buf == X_Reply)
- return nbuf;
- buf += SIZEOF(xReply);
- len -= SIZEOF(xReply);
- }
- if (len > 0 && len < SIZEOF(xReply)) {
- buf = nbuf;
- len = SIZEOF(xReply) - len;
- nbuf -= len;
- memmove(nbuf, buf, *lenp);
- (void) _XRead(dpy, nbuf + *lenp, (long)len);
- *lenp += len;
- }
- return nbuf;
-}
-#endif /* !USE_XCB */
-
-/*
- * Support for internal connections, such as an IM might use.
- * By Stephen Gildea, X Consortium, September 1993
- */
-
-/* _XRegisterInternalConnection
- * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
- * include in its select/poll mask must call this function to register the
- * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
- * will also be called.
- *
- * Whenever Xlib detects input available on fd, it will call callback
- * with call_data to process it. If non-Xlib code calls select/poll
- * and detects input available, it must call XProcessInternalConnection,
- * which will call the associated callback.
- *
- * Non-Xlib code can learn about these additional fds by calling
- * XInternalConnectionNumbers or, more typically, by registering
- * a XConnectionWatchProc with XAddConnectionWatch
- * to be called when fds are registered or unregistered.
- *
- * Returns True if registration succeeded, False if not, typically
- * because could not allocate memory.
- * Assumes Display locked when called.
- */
-Status
-_XRegisterInternalConnection(
- Display* dpy,
- int fd,
- _XInternalConnectionProc callback,
- XPointer call_data
-)
-{
- struct _XConnectionInfo *new_conni, **iptr;
- struct _XConnWatchInfo *watchers;
- XPointer *wd;
-
- new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
- if (!new_conni)
- return 0;
- new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
- if (!new_conni->watch_data) {
- Xfree(new_conni);
- return 0;
- }
- new_conni->fd = fd;
- new_conni->read_callback = callback;
- new_conni->call_data = call_data;
- new_conni->next = NULL;
- /* link new structure onto end of list */
- for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
- ;
- *iptr = new_conni;
- dpy->im_fd_length++;
- _XPollfdCacheAdd(dpy, fd);
-
- for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
- watchers;
- watchers=watchers->next, wd++) {
- *wd = NULL; /* for cleanliness */
- (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
- }
-
- return 1;
-}
-
-/* _XUnregisterInternalConnection
- * Each IM (or Xlib extension) that closes a file descriptor previously
- * registered with _XRegisterInternalConnection must call this function.
- * Any XConnectionWatchProc registered by XAddConnectionWatch
- * will also be called.
- *
- * Assumes Display locked when called.
- */
-void
-_XUnregisterInternalConnection(
- Display* dpy,
- int fd
-)
-{
- struct _XConnectionInfo *info_list, **prev;
- struct _XConnWatchInfo *watch;
- XPointer *wd;
-
- for (prev = &dpy->im_fd_info; (info_list = *prev);
- prev = &info_list->next) {
- if (info_list->fd == fd) {
- *prev = info_list->next;
- dpy->im_fd_length--;
- for (watch=dpy->conn_watchers, wd=info_list->watch_data;
- watch;
- watch=watch->next, wd++) {
- (*watch->fn) (dpy, watch->client_data, fd, False, wd);
- }
- if (info_list->watch_data)
- Xfree (info_list->watch_data);
- Xfree (info_list);
- break;
- }
- }
- _XPollfdCacheDel(dpy, fd);
-}
-
-/* XInternalConnectionNumbers
- * Returns an array of fds and an array of corresponding call data.
- * Typically a XConnectionWatchProc registered with XAddConnectionWatch
- * will be used instead of this function to discover
- * additional fds to include in the select/poll mask.
- *
- * The list is allocated with Xmalloc and should be freed by the caller
- * with Xfree;
- */
-Status
-XInternalConnectionNumbers(
- Display *dpy,
- int **fd_return,
- int *count_return
-)
-{
- int count;
- struct _XConnectionInfo *info_list;
- int *fd_list;
-
- LockDisplay(dpy);
- count = 0;
- for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
- count++;
- fd_list = (int*) Xmalloc (count * sizeof(int));
- if (!fd_list) {
- UnlockDisplay(dpy);
- return 0;
- }
- count = 0;
- for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
- fd_list[count] = info_list->fd;
- count++;
- }
- UnlockDisplay(dpy);
-
- *fd_return = fd_list;
- *count_return = count;
- return 1;
-}
-
-void _XProcessInternalConnection(
- Display *dpy,
- struct _XConnectionInfo *conn_info)
-{
- dpy->flags |= XlibDisplayProcConni;
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock) {
- /* check cache to avoid call to thread_self */
- if (xthread_have_id(dpy->lock->reading_thread))
- dpy->lock->conni_thread = dpy->lock->reading_thread;
- else
- dpy->lock->conni_thread = XThread_Self();
- }
-#endif /* XTHREADS && !USE_XCB */
- UnlockDisplay(dpy);
- (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
- LockDisplay(dpy);
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock)
- xthread_clear_id(dpy->lock->conni_thread);
-#endif /* XTHREADS && !USE_XCB */
- dpy->flags &= ~XlibDisplayProcConni;
-}
-
-/* XProcessInternalConnection
- * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
- * for this fd.
- * The Display is NOT locked during the call.
- */
-void
-XProcessInternalConnection(
- Display* dpy,
- int fd
-)
-{
- struct _XConnectionInfo *info_list;
-
- LockDisplay(dpy);
- for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
- if (info_list->fd == fd) {
- _XProcessInternalConnection(dpy, info_list);
- break;
- }
- }
- UnlockDisplay(dpy);
-}
-
-/* XAddConnectionWatch
- * Register a callback to be called whenever _XRegisterInternalConnection
- * or _XUnregisterInternalConnection is called.
- * Callbacks are called with the Display locked.
- * If any connections are already registered, the callback is immediately
- * called for each of them.
- */
-Status
-XAddConnectionWatch(
- Display* dpy,
- XConnectionWatchProc callback,
- XPointer client_data
-)
-{
- struct _XConnWatchInfo *new_watcher, **wptr;
- struct _XConnectionInfo *info_list;
- XPointer *wd_array;
-
- LockDisplay(dpy);
-
- /* allocate new watch data */
- for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
- wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
- (dpy->watcher_count + 1) *
- sizeof(XPointer));
- if (!wd_array) {
- UnlockDisplay(dpy);
- return 0;
- }
- wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
- }
-
- new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
- if (!new_watcher) {
- UnlockDisplay(dpy);
- return 0;
- }
- new_watcher->fn = callback;
- new_watcher->client_data = client_data;
- new_watcher->next = NULL;
-
- /* link new structure onto end of list */
- for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
- ;
- *wptr = new_watcher;
- dpy->watcher_count++;
-
- /* call new watcher on all currently registered fds */
- for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
- (*callback) (dpy, client_data, info_list->fd, True,
- info_list->watch_data + dpy->watcher_count - 1);
- }
-
- UnlockDisplay(dpy);
- return 1;
-}
-
-/* XRemoveConnectionWatch
- * Unregister a callback registered by XAddConnectionWatch.
- * Both callback and client_data must match what was passed to
- * XAddConnectionWatch.
- */
-void
-XRemoveConnectionWatch(
- Display* dpy,
- XConnectionWatchProc callback,
- XPointer client_data
-)
-{
- struct _XConnWatchInfo *watch;
- struct _XConnWatchInfo *previous = NULL;
- struct _XConnectionInfo *conni;
- int counter = 0;
-
- LockDisplay(dpy);
- for (watch=dpy->conn_watchers; watch; watch=watch->next) {
- if (watch->fn == callback && watch->client_data == client_data) {
- if (previous)
- previous->next = watch->next;
- else
- dpy->conn_watchers = watch->next;
- Xfree (watch);
- dpy->watcher_count--;
- /* remove our watch_data for each connection */
- for (conni=dpy->im_fd_info; conni; conni=conni->next) {
- /* don't bother realloc'ing; these arrays are small anyway */
- /* overlapping */
- memmove(conni->watch_data+counter,
- conni->watch_data+counter+1,
- dpy->watcher_count - counter);
- }
- break;
- }
- previous = watch;
- counter++;
- }
- UnlockDisplay(dpy);
-}
-
-/* end of internal connections support */
-
-
-#if !USE_XCB
-/* Read and discard "n" 8-bit bytes of data */
-
-void _XEatData(
- Display *dpy,
- register unsigned long n)
-{
-#define SCRATCHSIZE 2048
- char buf[SCRATCHSIZE];
-
- while (n > 0) {
- register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
- (void) _XRead (dpy, buf, bytes_read);
- n -= bytes_read;
- }
-#undef SCRATCHSIZE
-}
-#endif /* !USE_XCB */
-
-/* Cookie jar implementation
- dpy->cookiejar is a linked list. _XEnq receives the events but leaves
- them in the normal EQ. _XStoreEvent returns the cookie event (minus
- data pointer) and adds it to the cookiejar. _XDeq just removes
- the entry like any other event but resets the data pointer for
- cookie events (to avoid double-free, the memory is re-used by Xlib).
-
- _XFetchEventCookie (called from XGetEventData) removes a cookie from the
- jar. _XFreeEventCookies removes all unclaimed cookies from the jar
- (called by XNextEvent).
-
- _XFreeDisplayStructure calls _XFreeEventCookies for each cookie in the
- normal EQ.
- */
-
-#include "utlist.h"
-struct stored_event {
- XGenericEventCookie ev;
- struct stored_event *prev;
- struct stored_event *next;
-};
-
-Bool
-_XIsEventCookie(Display *dpy, XEvent *ev)
-{
- return (ev->xcookie.type == GenericEvent &&
- dpy->generic_event_vec[ev->xcookie.extension & 0x7F] != NULL);
-}
-
-/**
- * Free all events in the event list.
- */
-void
-_XFreeEventCookies(Display *dpy)
-{
- struct stored_event **head, *e, *tmp;
-
- if (!dpy->cookiejar)
- return;
-
- head = (struct stored_event**)&dpy->cookiejar;
-
- DL_FOREACH_SAFE(*head, e, tmp) {
- XFree(e->ev.data);
- XFree(e);
- if (dpy->cookiejar == e)
- dpy->cookiejar = NULL;
- }
-}
-
-/**
- * Add an event to the display's event list. This event must be freed on the
- * next call to XNextEvent().
- */
-void
-_XStoreEventCookie(Display *dpy, XEvent *event)
-{
- XGenericEventCookie* cookie = &event->xcookie;
- struct stored_event **head, *add;
-
- if (!_XIsEventCookie(dpy, event))
- return;
-
- head = (struct stored_event**)(&dpy->cookiejar);
-
- add = Xmalloc(sizeof(struct stored_event));
- if (!add) {
- ESET(ENOMEM);
- _XIOError(dpy);
- }
- add->ev = *cookie;
- DL_APPEND(*head, add);
- cookie->data = NULL; /* don't return data yet, must be claimed */
-}
-
-/**
- * Return the event with the given cookie and remove it from the list.
- */
-Bool
-_XFetchEventCookie(Display *dpy, XGenericEventCookie* ev)
-{
- Bool ret = False;
- struct stored_event **head, *event;
- head = (struct stored_event**)&dpy->cookiejar;
-
- if (!_XIsEventCookie(dpy, (XEvent*)ev))
- return ret;
-
- DL_FOREACH(*head, event) {
- if (event->ev.cookie == ev->cookie &&
- event->ev.extension == ev->extension &&
- event->ev.evtype == ev->evtype) {
- *ev = event->ev;
- DL_DELETE(*head, event);
- Xfree(event);
- ret = True;
- break;
- }
- }
-
- return ret;
-}
-
-Bool
-_XCopyEventCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
-{
- Bool ret = False;
- int extension;
-
- if (!_XIsEventCookie(dpy, (XEvent*)in) || !out)
- return ret;
-
- extension = in->extension & 0x7F;
-
- if (!dpy->generic_event_copy_vec[extension])
- return ret;
-
- ret = ((*dpy->generic_event_copy_vec[extension])(dpy, in, out));
- out->cookie = ret ? ++dpy->next_cookie : 0;
- return ret;
-}
-
-
-/*
- * _XEnq - Place event packets on the display's queue.
- * note that no squishing of move events in V11, since there
- * is pointer motion hints....
- */
-void _XEnq(
- register Display *dpy,
- register xEvent *event)
-{
- register _XQEvent *qelt;
- int type, extension;
-
- if ((qelt = dpy->qfree)) {
- /* If dpy->qfree is non-NULL do this, else malloc a new one. */
- dpy->qfree = qelt->next;
- }
- else if ((qelt =
- (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
- /* Malloc call failed! */
- ESET(ENOMEM);
- _XIOError(dpy);
- }
- qelt->next = NULL;
-
- type = event->u.u.type & 0177;
- extension = ((xGenericEvent*)event)->extension;
- /* If an extension has registerd a generic_event_vec handler, then
- * it can handle event cookies. Otherwise, proceed with the normal
- * event handlers.
- *
- * If the generic_event_vec is called, qelt->event is a event cookie
- * with the data pointer and the "free" pointer set. Data pointer is
- * some memory allocated by the extension.
- */
- if (type == GenericEvent && dpy->generic_event_vec[extension & 0x7F]) {
- XGenericEventCookie *cookie = &qelt->event.xcookie;
- (*dpy->generic_event_vec[extension & 0x7F])(dpy, cookie, event);
- cookie->cookie = ++dpy->next_cookie;
-
- qelt->qserial_num = dpy->next_event_serial_num++;
- if (dpy->tail) dpy->tail->next = qelt;
- else dpy->head = qelt;
-
- dpy->tail = qelt;
- dpy->qlen++;
- } else if ((*dpy->event_vec[type])(dpy, &qelt->event, event)) {
- qelt->qserial_num = dpy->next_event_serial_num++;
- if (dpy->tail) dpy->tail->next = qelt;
- else dpy->head = qelt;
-
- dpy->tail = qelt;
- dpy->qlen++;
- } else {
- /* ignored, or stashed away for many-to-one compression */
- qelt->next = dpy->qfree;
- dpy->qfree = qelt;
- }
-}
-
-/*
- * _XDeq - Remove event packet from the display's queue.
- */
-void _XDeq(
- register Display *dpy,
- register _XQEvent *prev, /* element before qelt */
- register _XQEvent *qelt) /* element to be unlinked */
-{
- if (prev) {
- if ((prev->next = qelt->next) == NULL)
- dpy->tail = prev;
- } else {
- /* no prev, so removing first elt */
- if ((dpy->head = qelt->next) == NULL)
- dpy->tail = NULL;
- }
- qelt->qserial_num = 0;
- qelt->next = dpy->qfree;
- dpy->qfree = qelt;
- dpy->qlen--;
-
- if (_XIsEventCookie(dpy, &qelt->event)) {
- XGenericEventCookie* cookie = &qelt->event.xcookie;
- /* dpy->qfree is re-used, reset memory to avoid double free on
- * _XFreeDisplayStructure */
- cookie->data = NULL;
- }
-}
-
-/*
- * EventToWire in separate file in that often not needed.
- */
-
-/*ARGSUSED*/
-Bool
-_XUnknownWireEvent(
- register Display *dpy, /* pointer to display structure */
- register XEvent *re, /* pointer to where event should be reformatted */
- register xEvent *event) /* wire protocol event */
-{
-#ifdef notdef
- (void) fprintf(stderr,
- "Xlib: unhandled wire event! event number = %d, display = %x\n.",
- event->u.u.type, dpy);
-#endif
- return(False);
-}
-
-Bool
-_XUnknownWireEventCookie(
- Display *dpy, /* pointer to display structure */
- XGenericEventCookie *re, /* pointer to where event should be reformatted */
- xEvent *event) /* wire protocol event */
-{
-#ifdef notdef
- fprintf(stderr,
- "Xlib: unhandled wire cookie event! extension number = %d, display = %x\n.",
- ((xGenericEvent*)event)->extension, dpy);
-#endif
- return(False);
-}
-
-Bool
-_XUnknownCopyEventCookie(
- Display *dpy, /* pointer to display structure */
- XGenericEventCookie *in, /* source */
- XGenericEventCookie *out) /* destination */
-{
-#ifdef notdef
- fprintf(stderr,
- "Xlib: unhandled cookie event copy! extension number = %d, display = %x\n.",
- in->extension, dpy);
-#endif
- return(False);
-}
-
-/*ARGSUSED*/
-Status
-_XUnknownNativeEvent(
- register Display *dpy, /* pointer to display structure */
- register XEvent *re, /* pointer to where event should be reformatted */
- register xEvent *event) /* wire protocol event */
-{
-#ifdef notdef
- (void) fprintf(stderr,
- "Xlib: unhandled native event! event number = %d, display = %x\n.",
- re->type, dpy);
-#endif
- return(0);
-}
-/*
- * reformat a wire event into an XEvent structure of the right type.
- */
-Bool
-_XWireToEvent(
- register Display *dpy, /* pointer to display structure */
- register XEvent *re, /* pointer to where event should be reformatted */
- register xEvent *event) /* wire protocol event */
-{
-
- re->type = event->u.u.type & 0x7f;
- ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
- (xGenericReply *)event);
- ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
- ((XAnyEvent *)re)->display = dpy;
-
- /* Ignore the leading bit of the event type since it is set when a
- client sends an event rather than the server. */
-
- switch (event-> u.u.type & 0177) {
- case KeyPress:
- case KeyRelease:
- {
- register XKeyEvent *ev = (XKeyEvent*) re;
- ev->root = event->u.keyButtonPointer.root;
- ev->window = event->u.keyButtonPointer.event;
- ev->subwindow = event->u.keyButtonPointer.child;
- ev->time = event->u.keyButtonPointer.time;
- ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
- ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
- ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
- ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
- ev->state = event->u.keyButtonPointer.state;
- ev->same_screen = event->u.keyButtonPointer.sameScreen;
- ev->keycode = event->u.u.detail;
- }
- break;
- case ButtonPress:
- case ButtonRelease:
- {
- register XButtonEvent *ev = (XButtonEvent *) re;
- ev->root = event->u.keyButtonPointer.root;
- ev->window = event->u.keyButtonPointer.event;
- ev->subwindow = event->u.keyButtonPointer.child;
- ev->time = event->u.keyButtonPointer.time;
- ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
- ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
- ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
- ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
- ev->state = event->u.keyButtonPointer.state;
- ev->same_screen = event->u.keyButtonPointer.sameScreen;
- ev->button = event->u.u.detail;
- }
- break;
- case MotionNotify:
- {
- register XMotionEvent *ev = (XMotionEvent *)re;
- ev->root = event->u.keyButtonPointer.root;
- ev->window = event->u.keyButtonPointer.event;
- ev->subwindow = event->u.keyButtonPointer.child;
- ev->time = event->u.keyButtonPointer.time;
- ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
- ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
- ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
- ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
- ev->state = event->u.keyButtonPointer.state;
- ev->same_screen = event->u.keyButtonPointer.sameScreen;
- ev->is_hint = event->u.u.detail;
- }
- break;
- case EnterNotify:
- case LeaveNotify:
- {
- register XCrossingEvent *ev = (XCrossingEvent *) re;
- ev->root = event->u.enterLeave.root;
- ev->window = event->u.enterLeave.event;
- ev->subwindow = event->u.enterLeave.child;
- ev->time = event->u.enterLeave.time;
- ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
- ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
- ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
- ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
- ev->state = event->u.enterLeave.state;
- ev->mode = event->u.enterLeave.mode;
- ev->same_screen = (event->u.enterLeave.flags &
- ELFlagSameScreen) && True;
- ev->focus = (event->u.enterLeave.flags &
- ELFlagFocus) && True;
- ev->detail = event->u.u.detail;
- }
- break;
- case FocusIn:
- case FocusOut:
- {
- register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
- ev->window = event->u.focus.window;
- ev->mode = event->u.focus.mode;
- ev->detail = event->u.u.detail;
- }
- break;
- case KeymapNotify:
- {
- register XKeymapEvent *ev = (XKeymapEvent *) re;
- ev->window = None;
- memcpy(&ev->key_vector[1],
- (char *)((xKeymapEvent *) event)->map,
- sizeof (((xKeymapEvent *) event)->map));
- }
- break;
- case Expose:
- {
- register XExposeEvent *ev = (XExposeEvent *) re;
- ev->window = event->u.expose.window;
- ev->x = event->u.expose.x;
- ev->y = event->u.expose.y;
- ev->width = event->u.expose.width;
- ev->height = event->u.expose.height;
- ev->count = event->u.expose.count;
- }
- break;
- case GraphicsExpose:
- {
- register XGraphicsExposeEvent *ev =
- (XGraphicsExposeEvent *) re;
- ev->drawable = event->u.graphicsExposure.drawable;
- ev->x = event->u.graphicsExposure.x;
- ev->y = event->u.graphicsExposure.y;
- ev->width = event->u.graphicsExposure.width;
- ev->height = event->u.graphicsExposure.height;
- ev->count = event->u.graphicsExposure.count;
- ev->major_code = event->u.graphicsExposure.majorEvent;
- ev->minor_code = event->u.graphicsExposure.minorEvent;
- }
- break;
- case NoExpose:
- {
- register XNoExposeEvent *ev = (XNoExposeEvent *) re;
- ev->drawable = event->u.noExposure.drawable;
- ev->major_code = event->u.noExposure.majorEvent;
- ev->minor_code = event->u.noExposure.minorEvent;
- }
- break;
- case VisibilityNotify:
- {
- register XVisibilityEvent *ev = (XVisibilityEvent *) re;
- ev->window = event->u.visibility.window;
- ev->state = event->u.visibility.state;
- }
- break;
- case CreateNotify:
- {
- register XCreateWindowEvent *ev =
- (XCreateWindowEvent *) re;
- ev->window = event->u.createNotify.window;
- ev->parent = event->u.createNotify.parent;
- ev->x = cvtINT16toInt(event->u.createNotify.x);
- ev->y = cvtINT16toInt(event->u.createNotify.y);
- ev->width = event->u.createNotify.width;
- ev->height = event->u.createNotify.height;
- ev->border_width = event->u.createNotify.borderWidth;
- ev->override_redirect = event->u.createNotify.override;
- }
- break;
- case DestroyNotify:
- {
- register XDestroyWindowEvent *ev =
- (XDestroyWindowEvent *) re;
- ev->window = event->u.destroyNotify.window;
- ev->event = event->u.destroyNotify.event;
- }
- break;
- case UnmapNotify:
- {
- register XUnmapEvent *ev = (XUnmapEvent *) re;
- ev->window = event->u.unmapNotify.window;
- ev->event = event->u.unmapNotify.event;
- ev->from_configure = event->u.unmapNotify.fromConfigure;
- }
- break;
- case MapNotify:
- {
- register XMapEvent *ev = (XMapEvent *) re;
- ev->window = event->u.mapNotify.window;
- ev->event = event->u.mapNotify.event;
- ev->override_redirect = event->u.mapNotify.override;
- }
- break;
- case MapRequest:
- {
- register XMapRequestEvent *ev = (XMapRequestEvent *) re;
- ev->window = event->u.mapRequest.window;
- ev->parent = event->u.mapRequest.parent;
- }
- break;
- case ReparentNotify:
- {
- register XReparentEvent *ev = (XReparentEvent *) re;
- ev->event = event->u.reparent.event;
- ev->window = event->u.reparent.window;
- ev->parent = event->u.reparent.parent;
- ev->x = cvtINT16toInt(event->u.reparent.x);
- ev->y = cvtINT16toInt(event->u.reparent.y);
- ev->override_redirect = event->u.reparent.override;
- }
- break;
- case ConfigureNotify:
- {
- register XConfigureEvent *ev = (XConfigureEvent *) re;
- ev->event = event->u.configureNotify.event;
- ev->window = event->u.configureNotify.window;
- ev->above = event->u.configureNotify.aboveSibling;
- ev->x = cvtINT16toInt(event->u.configureNotify.x);
- ev->y = cvtINT16toInt(event->u.configureNotify.y);
- ev->width = event->u.configureNotify.width;
- ev->height = event->u.configureNotify.height;
- ev->border_width = event->u.configureNotify.borderWidth;
- ev->override_redirect = event->u.configureNotify.override;
- }
- break;
- case ConfigureRequest:
- {
- register XConfigureRequestEvent *ev =
- (XConfigureRequestEvent *) re;
- ev->window = event->u.configureRequest.window;
- ev->parent = event->u.configureRequest.parent;
- ev->above = event->u.configureRequest.sibling;
- ev->x = cvtINT16toInt(event->u.configureRequest.x);
- ev->y = cvtINT16toInt(event->u.configureRequest.y);
- ev->width = event->u.configureRequest.width;
- ev->height = event->u.configureRequest.height;
- ev->border_width = event->u.configureRequest.borderWidth;
- ev->value_mask = event->u.configureRequest.valueMask;
- ev->detail = event->u.u.detail;
- }
- break;
- case GravityNotify:
- {
- register XGravityEvent *ev = (XGravityEvent *) re;
- ev->window = event->u.gravity.window;
- ev->event = event->u.gravity.event;
- ev->x = cvtINT16toInt(event->u.gravity.x);
- ev->y = cvtINT16toInt(event->u.gravity.y);
- }
- break;
- case ResizeRequest:
- {
- register XResizeRequestEvent *ev =
- (XResizeRequestEvent *) re;
- ev->window = event->u.resizeRequest.window;
- ev->width = event->u.resizeRequest.width;
- ev->height = event->u.resizeRequest.height;
- }
- break;
- case CirculateNotify:
- {
- register XCirculateEvent *ev = (XCirculateEvent *) re;
- ev->window = event->u.circulate.window;
- ev->event = event->u.circulate.event;
- ev->place = event->u.circulate.place;
- }
- break;
- case CirculateRequest:
- {
- register XCirculateRequestEvent *ev =
- (XCirculateRequestEvent *) re;
- ev->window = event->u.circulate.window;
- ev->parent = event->u.circulate.event;
- ev->place = event->u.circulate.place;
- }
- break;
- case PropertyNotify:
- {
- register XPropertyEvent *ev = (XPropertyEvent *) re;
- ev->window = event->u.property.window;
- ev->atom = event->u.property.atom;
- ev->time = event->u.property.time;
- ev->state = event->u.property.state;
- }
- break;
- case SelectionClear:
- {
- register XSelectionClearEvent *ev =
- (XSelectionClearEvent *) re;
- ev->window = event->u.selectionClear.window;
- ev->selection = event->u.selectionClear.atom;
- ev->time = event->u.selectionClear.time;
- }
- break;
- case SelectionRequest:
- {
- register XSelectionRequestEvent *ev =
- (XSelectionRequestEvent *) re;
- ev->owner = event->u.selectionRequest.owner;
- ev->requestor = event->u.selectionRequest.requestor;
- ev->selection = event->u.selectionRequest.selection;
- ev->target = event->u.selectionRequest.target;
- ev->property = event->u.selectionRequest.property;
- ev->time = event->u.selectionRequest.time;
- }
- break;
- case SelectionNotify:
- {
- register XSelectionEvent *ev = (XSelectionEvent *) re;
- ev->requestor = event->u.selectionNotify.requestor;
- ev->selection = event->u.selectionNotify.selection;
- ev->target = event->u.selectionNotify.target;
- ev->property = event->u.selectionNotify.property;
- ev->time = event->u.selectionNotify.time;
- }
- break;
- case ColormapNotify:
- {
- register XColormapEvent *ev = (XColormapEvent *) re;
- ev->window = event->u.colormap.window;
- ev->colormap = event->u.colormap.colormap;
- ev->new = event->u.colormap.new;
- ev->state = event->u.colormap.state;
- }
- break;
- case ClientMessage:
- {
- register int i;
- register XClientMessageEvent *ev
- = (XClientMessageEvent *) re;
- ev->window = event->u.clientMessage.window;
- ev->format = event->u.u.detail;
- switch (ev->format) {
- case 8:
- ev->message_type = event->u.clientMessage.u.b.type;
- for (i = 0; i < 20; i++)
- ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
- break;
- case 16:
- ev->message_type = event->u.clientMessage.u.s.type;
- ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
- ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
- ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
- ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
- ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
- ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
- ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
- ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
- ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
- ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
- break;
- case 32:
- ev->message_type = event->u.clientMessage.u.l.type;
- ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
- ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
- ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
- ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
- ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
- break;
- default: /* XXX should never occur */
- break;
- }
- }
- break;
- case MappingNotify:
- {
- register XMappingEvent *ev = (XMappingEvent *)re;
- ev->window = 0;
- ev->first_keycode = event->u.mappingNotify.firstKeyCode;
- ev->request = event->u.mappingNotify.request;
- ev->count = event->u.mappingNotify.count;
- }
- break;
- default:
- return(_XUnknownWireEvent(dpy, re, event));
- }
- return(True);
-}
-
-
-/*
- * _XDefaultIOError - Default fatal system error reporting routine. Called
- * when an X internal system error is encountered.
- */
-int _XDefaultIOError(
- Display *dpy)
-{
- if (ECHECK(EPIPE)) {
- (void) fprintf (stderr,
- "X connection to %s broken (explicit kill or server shutdown).\r\n",
- DisplayString (dpy));
- } else {
- (void) fprintf (stderr,
- "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
-#ifdef WIN32
- WSAGetLastError(), strerror(WSAGetLastError()),
-#else
- errno, strerror (errno),
-#endif
- DisplayString (dpy));
- (void) fprintf (stderr,
- " after %lu requests (%lu known processed) with %d events remaining.\r\n",
- NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
- QLength(dpy));
-
- }
- exit(1);
- return(0); /* dummy - function should never return */
-}
-
-
-static int _XPrintDefaultError(
- Display *dpy,
- XErrorEvent *event,
- FILE *fp)
-{
- char buffer[BUFSIZ];
- char mesg[BUFSIZ];
- char number[32];
- const char *mtype = "XlibMessage";
- register _XExtension *ext = (_XExtension *)NULL;
- _XExtension *bext = (_XExtension *)NULL;
- XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
- XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
- (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
- XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
- mesg, BUFSIZ);
- (void) fprintf(fp, mesg, event->request_code);
- if (event->request_code < 128) {
- sprintf(number, "%d", event->request_code);
- XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
- } else {
- for (ext = dpy->ext_procs;
- ext && (ext->codes.major_opcode != event->request_code);
- ext = ext->next)
- ;
- if (ext)
- strcpy(buffer, ext->name);
- else
- buffer[0] = '\0';
- }
- (void) fprintf(fp, " (%s)\n", buffer);
- if (event->request_code >= 128) {
- XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
- mesg, BUFSIZ);
- fputs(" ", fp);
- (void) fprintf(fp, mesg, event->minor_code);
- if (ext) {
- sprintf(mesg, "%s.%d", ext->name, event->minor_code);
- XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
- (void) fprintf(fp, " (%s)", buffer);
- }
- fputs("\n", fp);
- }
- if (event->error_code >= 128) {
- /* kludge, try to find the extension that caused it */
- buffer[0] = '\0';
- for (ext = dpy->ext_procs; ext; ext = ext->next) {
- if (ext->error_string)
- (*ext->error_string)(dpy, event->error_code, &ext->codes,
- buffer, BUFSIZ);
- if (buffer[0]) {
- bext = ext;
- break;
- }
- if (ext->codes.first_error &&
- ext->codes.first_error < (int)event->error_code &&
- (!bext || ext->codes.first_error > bext->codes.first_error))
- bext = ext;
- }
- if (bext)
- sprintf(buffer, "%s.%d", bext->name,
- event->error_code - bext->codes.first_error);
- else
- strcpy(buffer, "Value");
- XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
- if (mesg[0]) {
- fputs(" ", fp);
- (void) fprintf(fp, mesg, event->resourceid);
- fputs("\n", fp);
- }
- /* let extensions try to print the values */
- for (ext = dpy->ext_procs; ext; ext = ext->next) {
- if (ext->error_values)
- (*ext->error_values)(dpy, event, fp);
- }
- } else if ((event->error_code == BadWindow) ||
- (event->error_code == BadPixmap) ||
- (event->error_code == BadCursor) ||
- (event->error_code == BadFont) ||
- (event->error_code == BadDrawable) ||
- (event->error_code == BadColor) ||
- (event->error_code == BadGC) ||
- (event->error_code == BadIDChoice) ||
- (event->error_code == BadValue) ||
- (event->error_code == BadAtom)) {
- if (event->error_code == BadValue)
- XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
- mesg, BUFSIZ);
- else if (event->error_code == BadAtom)
- XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
- mesg, BUFSIZ);
- else
- XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
- mesg, BUFSIZ);
- fputs(" ", fp);
- (void) fprintf(fp, mesg, event->resourceid);
- fputs("\n", fp);
- }
- XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
- mesg, BUFSIZ);
- fputs(" ", fp);
- (void) fprintf(fp, mesg, event->serial);
- XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
- mesg, BUFSIZ);
- fputs("\n ", fp);
- (void) fprintf(fp, mesg, dpy->request);
- fputs("\n", fp);
- if (event->error_code == BadImplementation) return 0;
- return 1;
-}
-
-int _XDefaultError(
- Display *dpy,
- XErrorEvent *event)
-{
- if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
- exit(1);
- /*NOTREACHED*/
-}
-
-/*ARGSUSED*/
-Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we)
-{
- return True;
-}
-
-/*
- * _XError - upcall internal or user protocol error handler
- */
-int _XError (
- Display *dpy,
- register xError *rep)
-{
- /*
- * X_Error packet encountered! We need to unpack the error before
- * giving it to the user.
- */
- XEvent event; /* make it a large event */
- register _XAsyncHandler *async, *next;
-
- event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
-
- for (async = dpy->async_handlers; async; async = next) {
- next = async->next;
- if ((*async->handler)(dpy, (xReply *)rep,
- (char *)rep, SIZEOF(xError), async->data))
- return 0;
- }
-
- event.xerror.display = dpy;
- event.xerror.type = X_Error;
- event.xerror.resourceid = rep->resourceID;
- event.xerror.error_code = rep->errorCode;
- event.xerror.request_code = rep->majorCode;
- event.xerror.minor_code = rep->minorCode;
- if (dpy->error_vec &&
- !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
- return 0;
- if (_XErrorFunction != NULL) {
- int rtn_val;
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock)
- (*dpy->lock->user_lock_display)(dpy);
- UnlockDisplay(dpy);
-#endif /* XTHREADS && !USE_XCB */
- rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
-#if defined(XTHREADS) && !USE_XCB
- LockDisplay(dpy);
- if (dpy->lock)
- (*dpy->lock->user_unlock_display)(dpy);
-#endif /* XTHREADS && !USE_XCB */
- return rtn_val;
- } else {
- return _XDefaultError(dpy, (XErrorEvent *)&event);
- }
-}
-
-/*
- * _XIOError - call user connection error handler and exit
- */
-int
-_XIOError (
- Display *dpy)
-{
- dpy->flags |= XlibDisplayIOError;
-#ifdef WIN32
- errno = WSAGetLastError();
-#endif
-
- /* This assumes that the thread calling exit will call any atexit handlers.
- * If this does not hold, then an alternate solution would involve
- * registering an atexit handler to take over the lock, which would only
- * assume that the same thread calls all the atexit handlers. */
-#ifdef XTHREADS
- if (dpy->lock)
- (*dpy->lock->user_lock_display)(dpy);
-#endif
- UnlockDisplay(dpy);
-
- if (_XIOErrorFunction != NULL)
- (*_XIOErrorFunction)(dpy);
- else
- _XDefaultIOError(dpy);
- exit (1);
- return 0;
-}
-
-
-/*
- * This routine can be used to (cheaply) get some memory within a single
- * Xlib routine for scratch space. A single buffer is reused each time
- * if possible. To be MT safe, you can only call this between a call to
- * GetReq* and a call to Data* or _XSend*, or in a context when the thread
- * is guaranteed to not unlock the display.
- */
-char *_XAllocScratch(
- register Display *dpy,
- unsigned long nbytes)
-{
- if (nbytes > dpy->scratch_length) {
- if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
- if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
- dpy->scratch_length = nbytes;
- else dpy->scratch_length = 0;
- }
- return (dpy->scratch_buffer);
-}
-
-/*
- * Scratch space allocator you can call any time, multiple times, and be
- * MT safe, but you must hand the buffer back with _XFreeTemp.
- */
-char *_XAllocTemp(
- register Display *dpy,
- unsigned long nbytes)
-{
- char *buf;
-
- buf = _XAllocScratch(dpy, nbytes);
- dpy->scratch_buffer = NULL;
- dpy->scratch_length = 0;
- return buf;
-}
-
-void _XFreeTemp(
- register Display *dpy,
- char *buf,
- unsigned long nbytes)
-{
- if (dpy->scratch_buffer)
- Xfree(dpy->scratch_buffer);
- dpy->scratch_buffer = buf;
- dpy->scratch_length = nbytes;
-}
-
-/*
- * Given a visual id, find the visual structure for this id on this display.
- */
-Visual *_XVIDtoVisual(
- Display *dpy,
- VisualID id)
-{
- register int i, j, k;
- register Screen *sp;
- register Depth *dp;
- register Visual *vp;
- for (i = 0; i < dpy->nscreens; i++) {
- sp = &dpy->screens[i];
- for (j = 0; j < sp->ndepths; j++) {
- dp = &sp->depths[j];
- /* if nvisuals == 0 then visuals will be NULL */
- for (k = 0; k < dp->nvisuals; k++) {
- vp = &dp->visuals[k];
- if (vp->visualid == id) return (vp);
- }
- }
- }
- return (NULL);
-}
-
-int
-XFree (void *data)
-{
- Xfree (data);
- return 1;
-}
-
-#ifdef _XNEEDBCOPYFUNC
-void _Xbcopy(b1, b2, length)
- register char *b1, *b2;
- register length;
-{
- if (b1 < b2) {
- b2 += length;
- b1 += length;
- while (length--)
- *--b2 = *--b1;
- } else {
- while (length--)
- *b2++ = *b1++;
- }
-}
-#endif
-
-#ifdef DataRoutineIsProcedure
-void Data(
- Display *dpy,
- char *data,
- long len)
-{
- if (dpy->bufptr + (len) <= dpy->bufmax) {
- memcpy(dpy->bufptr, data, (int)len);
- dpy->bufptr += ((len) + 3) & ~3;
- } else {
- _XSend(dpy, data, len);
- }
-}
-#endif /* DataRoutineIsProcedure */
-
-
-#ifdef LONG64
-int
-_XData32(
- Display *dpy,
- register long *data,
- unsigned len)
-{
- register int *buf;
- register long i;
-
- while (len) {
- buf = (int *)dpy->bufptr;
- i = dpy->bufmax - (char *)buf;
- if (!i) {
- _XFlush(dpy);
- continue;
- }
- if (len < i)
- i = len;
- dpy->bufptr = (char *)buf + i;
- len -= i;
- i >>= 2;
- while (--i >= 0)
- *buf++ = *data++;
- }
- return 0;
-}
-#endif /* LONG64 */
-
-#ifdef WORD64
-
-/*
- * XXX This is a *really* stupid way of doing this. It should just use
- * dpy->bufptr directly, taking into account where in the word it is.
- */
-
-/*
- * Data16 - Place 16 bit data in the buffer.
- *
- * "dpy" is a pointer to a Display.
- * "data" is a pointer to the data.
- * "len" is the length in bytes of the data.
- */
-
-static doData16(
- register Display *dpy,
- short *data,
- unsigned len,
- char *packbuffer)
-{
- long *lp,*lpack;
- long i, nwords,bits;
- long mask16 = 0x000000000000ffff;
-
- lp = (long *)data;
- lpack = (long *)packbuffer;
-
-/* nwords is the number of 16 bit values to be packed,
- * the low order 16 bits of each word will be packed
- * into 64 bit words
- */
- nwords = len >> 1;
- bits = 48;
-
- for(i=0;i<nwords;i++){
- if (bits == 48) *lpack = 0;
- *lpack ^= (*lp & mask16) << bits;
- bits -= 16 ;
- lp++;
- if(bits < 0){
- lpack++;
- bits = 48;
- }
- }
- Data(dpy, packbuffer, len);
-}
-
-_XData16 (
- Display *dpy,
- short *data,
- unsigned len)
-{
- char packbuffer[PACKBUFFERSIZE];
- unsigned nunits = PACKBUFFERSIZE >> 1;
-
- for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
- doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
- }
- if (len) doData16 (dpy, data, len, packbuffer);
-}
-
-/*
- * Data32 - Place 32 bit data in the buffer.
- *
- * "dpy" is a pointer to a Display.
- * "data" is a pointer to the data.
- * "len" is the length in bytes of the data.
- */
-
-static doData32(
- register Display *dpy
- long *data,
- unsigned len,
- char *packbuffer)
-{
- long *lp,*lpack;
- long i,bits,nwords;
- long mask32 = 0x00000000ffffffff;
-
- lpack = (long *) packbuffer;
- lp = data;
-
-/* nwords is the number of 32 bit values to be packed
- * the low order 32 bits of each word will be packed
- * into 64 bit words
- */
- nwords = len >> 2;
- bits = 32;
-
- for(i=0;i<nwords;i++){
- if (bits == 32) *lpack = 0;
- *lpack ^= (*lp & mask32) << bits;
- bits = bits ^32;
- lp++;
- if(bits)
- lpack++;
- }
- Data(dpy, packbuffer, len);
-}
-
-void _XData32(
- Display *dpy,
- long *data,
- unsigned len)
-{
- char packbuffer[PACKBUFFERSIZE];
- unsigned nunits = PACKBUFFERSIZE >> 2;
-
- for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
- doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
- }
- if (len) doData32 (dpy, data, len, packbuffer);
-}
-
-#endif /* WORD64 */
-
-
-/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
- * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
- *
- * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
- * to have sufficient information for interfacing to the network,
- * and so, you may be better off using gethostname (if it exists).
- */
-
-#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(SVR4)
-#define NEED_UTSNAME
-#include <sys/utsname.h>
-#endif
-
-/*
- * _XGetHostname - similar to gethostname but allows special processing.
- */
-int _XGetHostname (
- char *buf,
- int maxlen)
-{
- int len;
-
-#ifdef NEED_UTSNAME
- struct utsname name;
-
- if (maxlen <= 0 || buf == NULL)
- return 0;
-
- uname (&name);
- len = strlen (name.nodename);
- if (len >= maxlen) len = maxlen - 1;
- strncpy (buf, name.nodename, len);
- buf[len] = '\0';
-#else
- if (maxlen <= 0 || buf == NULL)
- return 0;
-
- buf[0] = '\0';
- (void) gethostname (buf, maxlen);
- buf [maxlen - 1] = '\0';
- len = strlen(buf);
-#endif /* NEED_UTSNAME */
- return len;
-}
-
-
-/*
- * _XScreenOfWindow - get the Screen of a given window
- */
-
-Screen *_XScreenOfWindow(Display *dpy, Window w)
-{
- register int i;
- Window root;
- int x, y; /* dummy variables */
- unsigned int width, height, bw, depth; /* dummy variables */
-
- if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
- &bw, &depth) == False) {
- return NULL;
- }
- for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
- if (root == RootWindow (dpy, i)) {
- return ScreenOfDisplay (dpy, i);
- }
- }
- return NULL;
-}
-
-
-#if defined(WIN32)
-
-/*
- * These functions are intended to be used internally to Xlib only.
- * These functions will always prefix the path with a DOS drive in the
- * form "<drive-letter>:". As such, these functions are only suitable
- * for use by Xlib function that supply a root-based path to some
- * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
- * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
- */
-
-static int access_file (path, pathbuf, len_pathbuf, pathret)
- char* path;
- char* pathbuf;
- int len_pathbuf;
- char** pathret;
-{
- if (access (path, F_OK) == 0) {
- if (strlen (path) < len_pathbuf)
- *pathret = pathbuf;
- else
- *pathret = Xmalloc (strlen (path) + 1);
- if (*pathret) {
- strcpy (*pathret, path);
- return 1;
- }
- }
- return 0;
-}
-
-static int AccessFile (path, pathbuf, len_pathbuf, pathret)
- char* path;
- char* pathbuf;
- int len_pathbuf;
- char** pathret;
-{
- unsigned long drives;
- int i, len;
- char* drive;
- char buf[MAX_PATH];
- char* bufp;
-
- /* just try the "raw" name first and see if it works */
- if (access_file (path, pathbuf, len_pathbuf, pathret))
- return 1;
-
- /* try the places set in the environment */
- drive = getenv ("_XBASEDRIVE");
-#ifdef __UNIXOS2__
- if (!drive)
- drive = getenv ("X11ROOT");
-#endif
- if (!drive)
- drive = "C:";
- len = strlen (drive) + strlen (path);
- if (len < MAX_PATH) bufp = buf;
- else bufp = Xmalloc (len + 1);
- strcpy (bufp, drive);
- strcat (bufp, path);
- if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
- if (bufp != buf) Xfree (bufp);
- return 1;
- }
-
-#ifndef __UNIXOS2__
- /* one last place to look */
- drive = getenv ("HOMEDRIVE");
- if (drive) {
- len = strlen (drive) + strlen (path);
- if (len < MAX_PATH) bufp = buf;
- else bufp = Xmalloc (len + 1);
- strcpy (bufp, drive);
- strcat (bufp, path);
- if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
- if (bufp != buf) Xfree (bufp);
- return 1;
- }
- }
-
- /* tried everywhere else, go fishing */
-#define C_DRIVE ('C' - 'A')
-#define Z_DRIVE ('Z' - 'A')
- /* does OS/2 (with or with gcc-emx) have getdrives? */
- drives = _getdrives ();
- for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
- if ((1 << i) & drives) {
- len = 2 + strlen (path);
- if (len < MAX_PATH) bufp = buf;
- else bufp = Xmalloc (len + 1);
- *bufp = 'A' + i;
- *(bufp + 1) = ':';
- *(bufp + 2) = '\0';
- strcat (bufp, path);
- if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
- if (bufp != buf) Xfree (bufp);
- return 1;
- }
- }
- }
-#endif
- return 0;
-}
-
-int _XOpenFile(path, flags)
- _Xconst char* path;
- int flags;
-{
- char buf[MAX_PATH];
- char* bufp = NULL;
- int ret = -1;
- UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
-
- if (AccessFile (path, buf, MAX_PATH, &bufp))
- ret = open (bufp, flags);
-
- (void) SetErrorMode (olderror);
-
- if (bufp != buf) Xfree (bufp);
-
- return ret;
-}
-
-int _XOpenFileMode(path, flags, mode)
- _Xconst char* path;
- int flags;
- mode_t mode;
-{
- char buf[MAX_PATH];
- char* bufp = NULL;
- int ret = -1;
- UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
-
- if (AccessFile (path, buf, MAX_PATH, &bufp))
- ret = open (bufp, flags, mode);
-
- (void) SetErrorMode (olderror);
-
- if (bufp != buf) Xfree (bufp);
-
- return ret;
-}
-
-void* _XFopenFile(path, mode)
- _Xconst char* path;
- _Xconst char* mode;
-{
- char buf[MAX_PATH];
- char* bufp = NULL;
- void* ret = NULL;
- UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
-
- if (AccessFile (path, buf, MAX_PATH, &bufp))
- ret = fopen (bufp, mode);
-
- (void) SetErrorMode (olderror);
-
- if (bufp != buf) Xfree (bufp);
-
- return ret;
-}
-
-int _XAccessFile(path)
- _Xconst char* path;
-{
- char buf[MAX_PATH];
- char* bufp;
- int ret = -1;
- UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
-
- ret = AccessFile (path, buf, MAX_PATH, &bufp);
-
- (void) SetErrorMode (olderror);
-
- if (bufp != buf) Xfree (bufp);
-
- return ret;
-}
-
-#endif
-
-#ifdef WIN32
-#undef _Xdebug
-int _Xdebug = 0;
-int *_Xdebug_p = &_Xdebug;
-void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn;
-void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn;
-void (**_XLockMutex_fn_p)(LockInfoPtr
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
- , char * /* file */
- , int /* line */
-#endif
- ) = &_XLockMutex_fn;
-void (**_XUnlockMutex_fn_p)(LockInfoPtr
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
- , char * /* file */
- , int /* line */
-#endif
- ) = &_XUnlockMutex_fn;
-LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock;
-#endif
+/*
+
+Copyright 1985, 1986, 1987, 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.
+
+*/
+
+/*
+ * XlibInt.c - Internal support routines for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol V11.0.
+ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifdef WIN32
+#define _XLIBINT_
+#include <X11\Xw32defs.h>
+#endif
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#include "Xprivate.h"
+#include <X11/Xpoll.h>
+#if !USE_XCB
+#include <X11/Xtrans/Xtrans.h>
+#include <X11/extensions/xcmiscstr.h>
+#endif /* !USE_XCB */
+#include <assert.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <direct.h>
+#endif
+
+#ifdef XTHREADS
+#include "locking.h"
+
+/* these pointers get initialized by XInitThreads */
+LockInfoPtr _Xglobal_lock = NULL;
+void (*_XCreateMutex_fn)(LockInfoPtr) = NULL;
+/* struct _XCVList *(*_XCreateCVL_fn)() = NULL; */
+void (*_XFreeMutex_fn)(LockInfoPtr) = NULL;
+void (*_XLockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+void (*_XUnlockMutex_fn)(
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = NULL;
+xthread_t (*_Xthread_self_fn)(void) = NULL;
+
+#define XThread_Self() ((*_Xthread_self_fn)())
+
+#if !USE_XCB
+#define UnlockNextReplyReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
+
+#define QueueReplyReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
+#define QueueEventReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
+#endif /* !USE_XCB */
+
+#else /* XTHREADS else */
+
+#if !USE_XCB
+#define UnlockNextReplyReader(d)
+#define UnlockNextEventReader(d)
+#endif /* !USE_XCB */
+
+#endif /* XTHREADS else */
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#ifdef __CYGWIN__ /* Cygwin uses ENOBUFS to signal socket is full */
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK || errno == ENOBUFS)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif /* EAGAIN */
+#endif /* EAGAIN && EWOULDBLOCK */
+#endif /* __CYGWIN__ */
+#endif /* WIN32 */
+
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#ifdef __UNIXOS2__
+#define ECHECK(err) (errno == err)
+#define ESET(val)
+#else
+#define ECHECK(err) (errno == err)
+#define ESET(val) errno = val
+#endif
+#endif
+
+#if defined(LOCALCONN) || defined(LACHMAN)
+#ifdef EMSGSIZE
+#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
+#else
+#define ESZTEST() ECHECK(ERANGE)
+#endif
+#else
+#ifdef EMSGSIZE
+#define ESZTEST() ECHECK(EMSGSIZE)
+#endif
+#endif
+
+#ifdef __UNIXOS2__
+#if !USE_XCB
+#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
+#endif /* !USE_XCB */
+#include <limits.h>
+#define MAX_PATH _POSIX_PATH_MAX
+#endif
+
+#if !USE_XCB
+#ifdef MUSTCOPY
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ { register char *cpvar; \
+ for (cpvar = (char *) (start); endcond; ) { \
+ type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
+ tpvar = &dummy;
+#define ITERPTR(tpvar) cpvar
+#define RESETITERPTR(tpvar,type,start) cpvar = start
+#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
+#define ENDITERATE }}
+
+#else
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ for (tpvar = (type *) (start); endcond; )
+#define ITERPTR(tpvar) (char *)tpvar
+#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
+#define INCITERPTR(tpvar,type) tpvar++
+#define ENDITERATE
+
+#endif /* MUSTCOPY */
+
+typedef union {
+ xReply rep;
+ char buf[BUFSIZE];
+} _XAlignedBuffer;
+
+static char *_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard);
+#endif /* !USE_XCB */
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * _XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * _XError(Display *, xError *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+#if !USE_XCB
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+static void
+_XWaitForWritable(
+ Display *dpy
+#ifdef XTHREADS
+ ,
+ xcondition_t cv /* our reading condition variable */
+#endif
+ )
+{
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ fd_set w_mask;
+#endif
+ int nfound;
+
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = 0;
+#else
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* We allow only one thread at a time to read, to minimize
+ passing of read data between threads.
+ Now, who is it? If there is a non-NULL reply_awaiters and
+ we (i.e., our cv) are not at the head of it, then whoever
+ is at the head is the reader, and we don't read.
+ Otherwise there is no reply_awaiters or we are at the
+ head, having just appended ourselves.
+ In this case, if there is a event_awaiters, then whoever
+ is at the head of it got there before we did, and they are the
+ reader.
+
+ Last cases: no event_awaiters and we are at the head of
+ reply_awaiters or reply_awaiters is NULL: we are the reader,
+ since there is obviously no one else involved.
+
+ XXX - what if cv is NULL and someone else comes along after
+ us while we are waiting?
+ */
+
+ if (!dpy->lock ||
+ (!dpy->lock->event_awaiters &&
+ (!dpy->lock->reply_awaiters ||
+ dpy->lock->reply_awaiters->cv == cv)))
+#endif
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+
+ do {
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ nfound = poll (&filedes, 1, -1);
+#else
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, cv != NULL);
+ if (nfound < 0 && !(ECHECK(EINTR) || ETEST()))
+ _XIOError(dpy);
+ } while (nfound <= 0);
+
+ if (
+#ifdef USE_POLL
+ filedes.revents & POLLIN
+#else
+ FD_ISSET(dpy->fd, &r_mask)
+#endif
+ )
+ {
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register int len;
+ register xReply *rep;
+
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE) len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+
+ (void) _XRead (dpy, buf.buf, (long) len);
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ }
+#ifdef USE_POLL
+ if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(dpy->fd, &w_mask))
+#endif
+ {
+#ifdef XTHREADS
+ if (dpy->lock) {
+ ConditionBroadcast(dpy, dpy->lock->writers);
+ }
+#endif
+ return;
+ }
+ }
+}
+#endif /* !USE_XCB */
+
+
+#define POLLFD_CACHE_SIZE 5
+
+/* initialize the struct array passed to poll() below */
+Bool _XPollfdCacheInit(
+ Display *dpy)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp;
+
+ pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ if (!pfp)
+ return False;
+ pfp[0].fd = dpy->fd;
+ pfp[0].events = POLLIN;
+
+ dpy->filedes = (XPointer)pfp;
+#endif
+ return True;
+}
+
+void _XPollfdCacheAdd(
+ Display *dpy,
+ int fd)
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ pfp[dpy->im_fd_length].fd = fd;
+ pfp[dpy->im_fd_length].events = POLLIN;
+ }
+#endif
+}
+
+/* ARGSUSED */
+void _XPollfdCacheDel(
+ Display *dpy,
+ int fd) /* not used */
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+ struct _XConnectionInfo *conni;
+
+ /* just recalculate whole list */
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ int loc = 1;
+ for (conni = dpy->im_fd_info; conni; conni=conni->next) {
+ pfp[loc].fd = conni->fd;
+ pfp[loc].events = POLLIN;
+ loc++;
+ }
+ }
+#endif
+}
+
+#if !USE_XCB
+/* returns True iff there is an event in the queue newer than serial_num */
+
+static Bool
+_XNewerQueuedEvent(
+ Display *dpy,
+ int serial_num)
+{
+ _XQEvent *qev;
+
+ if (dpy->next_event_serial_num == serial_num)
+ return False;
+
+ qev = dpy->head;
+ while (qev) {
+ if (qev->qserial_num >= serial_num) {
+ return True;
+ }
+ qev = qev->next;
+ }
+ return False;
+}
+
+static int
+_XWaitForReadable(
+ Display *dpy)
+{
+ int result;
+ int fd = dpy->fd;
+ struct _XConnectionInfo *ilist;
+ register int saved_event_serial = 0;
+ int in_read_events = 0;
+ register Bool did_proc_conni = False;
+#ifdef USE_POLL
+ struct pollfd *filedes;
+#else
+ fd_set r_mask;
+ int highest_fd = fd;
+#endif
+
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
+ && !(dpy->flags & XlibDisplayProcConni)) {
+ /* XXX - this fallback is gross */
+ int i;
+
+ filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
+ filedes[0].fd = fd;
+ filedes[0].events = POLLIN;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+ filedes[i].fd = ilist->fd;
+ filedes[i].events = POLLIN;
+ }
+ } else {
+ filedes = (struct pollfd *)dpy->filedes;
+ }
+#else
+ FD_ZERO(&r_mask);
+#endif
+ for (;;) {
+#ifndef USE_POLL
+ FD_SET(fd, &r_mask);
+ if (!(dpy->flags & XlibDisplayProcConni))
+ for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
+ FD_SET(ilist->fd, &r_mask);
+ if (ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+#endif
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ result = poll(filedes,
+ (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
+ -1);
+#else
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
+ if (result == -1 && !(ECHECK(EINTR) || ETEST())) _XIOError(dpy);
+ if (result <= 0)
+ continue;
+#ifdef USE_POLL
+ if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(fd, &r_mask))
+#endif
+ break;
+ if (!(dpy->flags & XlibDisplayProcConni)) {
+ int i;
+
+ saved_event_serial = dpy->next_event_serial_num;
+ /* dpy flags can be clobbered by internal connection callback */
+ in_read_events = dpy->flags & XlibDisplayReadEvents;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+#ifdef USE_POLL
+ if (filedes[i].revents & POLLIN)
+#else
+ if (FD_ISSET(ilist->fd, &r_mask))
+#endif
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ did_proc_conni = True;
+ }
+ }
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
+ Xfree(filedes);
+#endif
+ }
+ if (did_proc_conni) {
+ /* some internal connection callback might have done an
+ XPutBackEvent. We notice it here and if we needed an event,
+ we can return all the way. */
+ if (_XNewerQueuedEvent(dpy, saved_event_serial)
+ && (in_read_events
+#ifdef XTHREADS
+ || (dpy->lock && dpy->lock->event_awaiters)
+#endif
+ ))
+ return -2;
+ did_proc_conni = False;
+ }
+ }
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x _XWaitForReadable returning\n", XThread_Self());
+#endif
+#endif
+ return 0;
+}
+#endif /* !USE_XCB */
+
+#ifdef _MSC_VER
+#undef min
+#define min __min
+#endif
+
+static int sync_hazard(Display *dpy)
+{
+ unsigned long span = dpy->request - dpy->last_request_read;
+ unsigned long hazard = min((dpy->bufmax - dpy->buffer) / SIZEOF(xReq), 65535 - 10);
+ return span >= 65535 - hazard - 10;
+}
+
+static
+void sync_while_locked(Display *dpy)
+{
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+#endif
+ UnlockDisplay(dpy);
+ SyncHandle();
+ InternalLockDisplay(dpy, /* don't skip user locks */ 0);
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif
+}
+
+void _XSeqSyncFunction(
+ register Display *dpy)
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ if ((dpy->request - dpy->last_request_read) >= (65535 - BUFSIZE/SIZEOF(xReq))) {
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ sync_while_locked(dpy);
+ } else if (sync_hazard(dpy))
+ _XSetPrivSyncFunction(dpy);
+}
+
+/* NOTE: only called if !XTHREADS, or when XInitThreads wasn't called. */
+static int
+_XPrivSyncFunction (Display *dpy)
+{
+#ifdef XTHREADS
+ assert(!dpy->lock_fns);
+#endif
+ assert(dpy->synchandler == _XPrivSyncFunction);
+ assert((dpy->flags & XlibDisplayPrivSync) != 0);
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->savedsynchandler = NULL;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ if(dpy->synchandler)
+ dpy->synchandler(dpy);
+ _XIDHandler(dpy);
+ _XSeqSyncFunction(dpy);
+ return 0;
+}
+
+void _XSetPrivSyncFunction(Display *dpy)
+{
+#ifdef XTHREADS
+ if (dpy->lock_fns)
+ return;
+#endif
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XPrivSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+}
+
+void _XSetSeqSyncFunction(Display *dpy)
+{
+ if (sync_hazard(dpy))
+ _XSetPrivSyncFunction (dpy);
+}
+
+#if !USE_XCB
+#ifdef XTHREADS
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv);
+#endif
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void _XFlush(
+ register Display *dpy)
+{
+#ifdef XTHREADS
+ /* With multi-threading we introduce an internal routine to which
+ we can pass a condition variable to do locking correctly. */
+
+ _XFlushInt(dpy, NULL);
+}
+
+/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
+ * locking correctly.
+ */
+
+static void _XFlushInt(
+ register Display *dpy,
+ register xcondition_t cv)
+{
+#endif /* XTHREADS*/
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+ _XExtension *ext;
+
+ /* This fix resets the bufptr to the front of the buffer so
+ * additional appends to the bufptr will not corrupt memory. Since
+ * the server is down, these appends are no-op's anyway but
+ * callers of _XFlush() are not verifying this before they call it.
+ */
+ if (dpy->flags & XlibDisplayIOError)
+ {
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ return;
+ }
+
+#ifdef XTHREADS
+ while (dpy->flags & XlibDisplayWriting) {
+ if (dpy->lock) {
+ ConditionWait(dpy, dpy->lock->writers);
+ } else {
+ _XWaitForWritable (dpy, cv);
+ }
+ }
+#endif
+ size = todo = dpy->bufptr - dpy->buffer;
+ if (!size) return;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ for (ext = dpy->flushes; ext; ext = ext->next_flush)
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
+ bufindex = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be
+ * incremented and size decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _X11TransWrite(dpy->trans_conn,
+ bufindex, (int) todo);
+ if (write_stat >= 0) {
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *)&_dummy_request;
+ _XSetSeqSyncFunction(dpy);
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+}
+
+int
+_XEventsQueued(
+ register Display *dpy,
+ int mode)
+{
+ register int len;
+ BytesReadable_t pend;
+ _XAlignedBuffer buf;
+ register xReply *rep;
+ char *read_buf;
+#ifdef XTHREADS
+ int entry_event_serial_num;
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XEventsQueued called in thread %x\n", XThread_Self());
+#endif
+#endif /* XTHREADS*/
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread))) {
+ /* In the multi-threaded case, if there is someone else
+ reading events, then there aren't any available, so
+ we just return. If we waited we would block.
+ */
+ if (dpy->lock && dpy->lock->event_awaiters)
+ return dpy->qlen;
+ /* nobody here but us, so lock out any newcomers */
+ cvl = QueueEventReaderLock(dpy);
+ }
+
+ while (dpy->lock && cvl && dpy->lock->reply_first) {
+ /* note which events we have already seen so we'll know
+ if _XReply (in another thread) reads one */
+ entry_event_serial_num = dpy->next_event_serial_num;
+ ConditionWait(dpy, cvl->cv);
+ /* did _XReply read an event we can return? */
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
+ {
+ UnlockNextEventReader(dpy);
+ return 0;
+ }
+ }
+#endif /* XTHREADS*/
+
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+ int result;
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ static struct timeval zero_time;
+#endif
+
+ dpy->conn_checker = 0;
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = POLLIN;
+ if ((result = poll(&filedes, 1, 0)))
+#else
+ FD_ZERO(&r_mask);
+ FD_SET(dpy->fd, &r_mask);
+ if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
+#endif
+ {
+ if (result > 0)
+ {
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+ else if (result < 0 && !(ECHECK(EINTR) || ETEST()))
+ _XIOError(dpy);
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend)) {
+ /* _XFlush can enqueue events */
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+ }
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+ }
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+
+ (void) _XRead (dpy, read_buf, (long) len);
+
+#ifdef XTHREADS
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf, read_buf,
+ len);
+ if (cvl) {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen); /* we read, so we can return */
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS*/
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ int tmp = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &tmp, True));
+ len = tmp;
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+
+#ifdef XTHREADS
+ if (cvl)
+#endif
+ {
+ UnlockNextEventReader(dpy);
+ }
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(
+ register Display *dpy)
+{
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ int len;
+ register xReply *rep;
+ Bool not_yet_flushed = True;
+ char *read_buf;
+ int i;
+ int entry_event_serial_num = dpy->next_event_serial_num;
+#ifdef XTHREADS
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReadEvents called in thread %x\n",
+ XThread_Self());
+#endif
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread)))
+ cvl = QueueEventReaderLock(dpy);
+#endif /* XTHREADS */
+
+ do {
+#ifdef XTHREADS
+ /* if it is not our turn to read an event off the wire,
+ wait til we're at head of list */
+ if (dpy->lock && cvl &&
+ (dpy->lock->event_awaiters != cvl ||
+ dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ continue;
+ }
+#endif /* XTHREADS */
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (len < SIZEOF(xEvent)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ ) {
+ len = SIZEOF(xEvent);
+ /* don't flush until the first time we would block */
+ if (not_yet_flushed) {
+ _XFlush (dpy);
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
+ /* _XReply has read an event for us */
+ goto got_event;
+ }
+ not_yet_flushed = False;
+ }
+ }
+
+#ifdef XTHREADS
+ /* If someone is waiting for a reply, gamble that
+ the reply will be the next thing on the wire
+ and read it into their buffer. */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE)
+ len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
+ }
+
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ /* save value we may have to stick in conni_thread */
+ dpy->lock->reading_thread = self;
+#endif /* XTHREADS */
+ dpy->flags |= XlibDisplayReadEvents;
+ i = _XRead (dpy, read_buf, (long) len);
+ dpy->flags &= ~XlibDisplayReadEvents;
+ if (i == -2) {
+ /* special flag from _XRead to say that internal connection has
+ done XPutBackEvent. Which we can use so we're done. */
+ got_event:
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->lock_wait) {
+ if (dpy->lock->event_awaiters != cvl)
+ /* since it is not us, must be user lock thread */
+ ConditionSignal(dpy,
+ dpy->lock->event_awaiters->cv);
+ (*dpy->lock->lock_wait)(dpy);
+ continue;
+ }
+#endif
+ break;
+ }
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ xthread_clear_id(dpy->lock->reading_thread);
+
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf,
+ read_buf, len);
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ continue;
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS */
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &len, True));
+ pend = len;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *) rep);
+ else /* must be an event packet */
+ {
+ if (rep->generic.type == GenericEvent)
+ {
+ int evlen;
+ evlen = (rep->generic.length << 2);
+ if (_XRead(dpy, &read_buf[len], evlen) == -2)
+ goto got_event; /* XXX: aargh! */
+ }
+
+ _XEnq (dpy, (xEvent *)rep);
+ }
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE;
+ } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
+
+ UnlockNextEventReader(dpy);
+}
+
+/*
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int _XRead(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+#ifdef XTHREADS
+ int original_size = size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0)
+ return 0;
+ ESET(0);
+ while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
+ != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST()) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+ return 0;
+}
+#endif /* !USE_XCB */
+
+#ifdef LONG64
+void _XRead32(
+ Display *dpy,
+ register long *data,
+ long len)
+{
+ register int *buf;
+ register long i;
+
+ if (len) {
+ (void) _XRead(dpy, (char *)data, len);
+ i = len >> 2;
+ buf = (int *)data + i;
+ data += i;
+ while (--i >= 0)
+ *--data = *--buf;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32(
+ register Display *dpy,
+ register long *data
+ register long size,
+ register char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32(
+ Display *dpy,
+ long *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static _doXRead16(
+ register Display *dpy,
+ register short *data,
+ register long size,
+ char *packbuffer)
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16(
+ Display *dpy,
+ short *data,
+ long len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad(
+ Display *dpy,
+ short *data,
+ long size)
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+#if !USE_XCB
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void _XReadPad(
+ register Display *dpy,
+ register char *data,
+ register long size)
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+#ifdef XTHREADS
+ int original_size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = -size & 3;
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+#ifdef XTHREADS
+ original_size = size;
+#endif
+ ESET(0);
+ while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if (iov[0].iov_len < bytes_read) {
+ int pad_bytes_read = bytes_read - iov[0].iov_len;
+ iov[1].iov_len -= pad_bytes_read;
+ iov[1].iov_base =
+ (char *)iov[1].iov_base + pad_bytes_read;
+ iov[0].iov_len = 0;
+ }
+ else {
+ iov[0].iov_len -= bytes_read;
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ }
+ else if (ETEST()) {
+ _XWaitForReadable(dpy);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+_XSend (
+ register Display *dpy,
+ _Xconst char *data,
+ register long size)
+{
+ struct iovec iov[3];
+ static char const pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip, dbufsize, padsize, total, todo;
+ _XExtension *ext;
+
+ if (!size || (dpy->flags & XlibDisplayIOError)) return;
+ dbufsize = dpy->bufptr - dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ padsize = -size & 3;
+ for (ext = dpy->flushes; ext; ext = ext->next_flush) {
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
+ (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
+ if (padsize)
+ (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
+ }
+ skip = 0;
+ todo = total = dbufsize + size + padsize;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dbufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV ((char *)pad, padsize)
+
+ ESET(0);
+ if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *) & _dummy_request;
+ _XSetSeqSyncFunction(dpy);
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+ return;
+}
+
+static void
+_XGetMiscCode(
+ register Display *dpy)
+{
+ xQueryExtensionReply qrep;
+ register xQueryExtensionReq *qreq;
+ xXCMiscGetVersionReply vrep;
+ register xXCMiscGetVersionReq *vreq;
+
+ if (dpy->xcmisc_opcode)
+ return;
+ GetReq(QueryExtension, qreq);
+ qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
+ qreq->length += (qreq->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
+ if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else {
+ GetReq(XCMiscGetVersion, vreq);
+ vreq->reqType = qrep.major_opcode;
+ vreq->miscReqType = X_XCMiscGetVersion;
+ vreq->majorVersion = XCMiscMajorVersion;
+ vreq->minorVersion = XCMiscMinorVersion;
+ if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else
+ dpy->xcmisc_opcode = qrep.major_opcode;
+ }
+}
+
+void
+_XIDHandler(
+ register Display *dpy)
+{
+ xXCMiscGetXIDRangeReply grep;
+ register xXCMiscGetXIDRangeReq *greq;
+
+ if (dpy->resource_max == dpy->resource_mask + 1) {
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDRange, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDRange;
+ if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
+ dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
+ dpy->resource_shift);
+ dpy->resource_max = dpy->resource_id;
+ if (grep.count > 5)
+ dpy->resource_max += grep.count - 6;
+ dpy->resource_max <<= dpy->resource_shift;
+ }
+ sync_while_locked(dpy);
+ }
+ }
+}
+
+/*
+ * _XAllocID - resource ID allocation routine.
+ */
+XID _XAllocID(
+ register Display *dpy)
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id >= dpy->resource_max) {
+ _XSetPrivSyncFunction(dpy);
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * _XAllocIDs - multiple resource ID allocation routine.
+ */
+void _XAllocIDs(
+ register Display *dpy,
+ XID *ids,
+ int count)
+{
+ XID id;
+ int i;
+ xXCMiscGetXIDListReply grep;
+ register xXCMiscGetXIDListReq *greq;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (dpy->resource_max <= dpy->resource_mask &&
+ id <= dpy->resource_mask &&
+ (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
+ id += dpy->resource_base;
+ for (i = 0; i < count; i++) {
+ ids[i] = id;
+ id += (1 << dpy->resource_shift);
+ dpy->resource_id++;
+ }
+ return;
+ }
+ grep.count = 0;
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDList, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDList;
+ greq->count = count;
+ if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
+ _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
+ for (i = 0; i < grep.count; i++) {
+ id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
+ if (id >= dpy->resource_id)
+ dpy->resource_id = id;
+ }
+ if (id >= dpy->resource_max) {
+ _XSetPrivSyncFunction(dpy);
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ }
+ }
+ for (i = grep.count; i < count; i++)
+ ids[i] = XAllocID(dpy);
+}
+#endif /* !USE_XCB */
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply.
+ * We have three values that will march along, with the following invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * We have to keep
+ * dpy->request - dpy->last_request_read < 2^16
+ * or else we won't know for sure what value to use in events. We do this
+ * by forcing syncs when we get close.
+ */
+
+unsigned long
+_XSetLastRequestRead(
+ register Display *dpy,
+ register xGenericReply *rep)
+{
+ register unsigned long newseq, lastseq;
+
+ lastseq = dpy->last_request_read;
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(lastseq);
+
+ newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+
+ if (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+#if !USE_XCB
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Meanwhile we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_XReply (
+ register Display *dpy,
+ register xReply *rep,
+ int extra, /* number of 32-bit words expected after the reply */
+ Bool discard) /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+#ifdef XTHREADS
+ struct _XCVList *cvl;
+#endif
+
+ if (dpy->flags & XlibDisplayIOError)
+ return 0;
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list */
+ cvl = QueueReplyReaderLock(dpy);
+ if (cvl) {
+ cvl->buf = rep;
+ if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
+ dpy->lock->reply_first = True;
+ }
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReply called in thread %x, adding %x to cvl\n",
+ XThread_Self(), cvl);
+#endif
+
+ _XFlushInt(dpy, cvl ? cvl->cv : NULL);
+ /* if it is not our turn to read a reply off the wire,
+ * wait til we're at head of list. if there is an event waiter,
+ * and our reply hasn't been read, they'll be in select and will
+ * hand control back to us next.
+ */
+ if(dpy->lock &&
+ (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ }
+ dpy->flags |= XlibDisplayReply;
+#else /* XTHREADS else */
+ _XFlush(dpy);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* Did another thread's _XReadEvents get our reply by accident? */
+ if (!dpy->lock || !dpy->lock->reply_was_read)
+#endif
+ (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+#ifdef XTHREADS
+ if (dpy->lock)
+ dpy->lock->reply_was_read = False;
+#endif
+
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else {
+ int pend = SIZEOF(xReply);
+ if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
+ != (char *)rep)
+ continue;
+ }
+ if (extra <= rep->generic.length) {
+ if (extra > 0)
+ /*
+ * Read the extra data into storage immediately
+ * following the GenericReply structure.
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard) {
+ if (extra < rep->generic.length)
+ _XEatData(dpy, (rep->generic.length - extra) << 2);
+ }
+#ifdef XTHREADS
+ if (dpy->lock) {
+ if (discard) {
+ dpy->lock->reply_bytes_left = 0;
+ } else {
+ dpy->lock->reply_bytes_left =
+ (rep->generic.length - extra) << 2;
+ }
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ } else
+ dpy->flags &= ~XlibDisplayReply;
+#endif
+ return 1;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ dpy->flags &= ~XlibDisplayReply;
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ if (serial == cur_request)
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch ((int)err->errorCode) {
+ case BadName:
+ switch (err->majorCode) {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ UnlockNextReplyReader(dpy);
+ return(0);
+ }
+ break;
+ case BadFont:
+ if (err->majorCode == X_QueryFont) {
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request) {
+ UnlockNextReplyReader(dpy);
+ return(ret_code);
+ }
+
+ } /* case X_Error */
+ break;
+ default:
+ _XEnq(dpy, (xEvent *) rep);
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ break;
+ }
+ }
+}
+
+static char *
+_XAsyncReply(
+ Display *dpy,
+ register xReply *rep,
+ char *buf,
+ register int *lenp,
+ Bool discard)
+{
+ register _XAsyncHandler *async, *next;
+ register int len;
+ register Bool consumed = False;
+ char *nbuf;
+
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ len = SIZEOF(xReply) + (rep->generic.length << 2);
+ if (len < SIZEOF(xReply)) {
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
+ break;
+ }
+ if (!consumed) {
+ if (!discard)
+ return buf;
+ (void) fprintf(stderr,
+ "Xlib: unexpected async reply (sequence 0x%lx)!\n",
+ dpy->last_request_read);
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x, unexpected async reply\n", XThread_Self());
+#endif
+#endif
+ if (len > *lenp)
+ _XEatData(dpy, len - *lenp);
+ }
+ if (len < SIZEOF(xReply))
+ {
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ if (len >= *lenp) {
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ *lenp -= len;
+ buf += len;
+ len = *lenp;
+ nbuf = buf;
+ while (len > SIZEOF(xReply)) {
+ if (*buf == X_Reply)
+ return nbuf;
+ buf += SIZEOF(xReply);
+ len -= SIZEOF(xReply);
+ }
+ if (len > 0 && len < SIZEOF(xReply)) {
+ buf = nbuf;
+ len = SIZEOF(xReply) - len;
+ nbuf -= len;
+ memmove(nbuf, buf, *lenp);
+ (void) _XRead(dpy, nbuf + *lenp, (long)len);
+ *lenp += len;
+ }
+ return nbuf;
+}
+#endif /* !USE_XCB */
+
+/*
+ * Support for internal connections, such as an IM might use.
+ * By Stephen Gildea, X Consortium, September 1993
+ */
+
+/* _XRegisterInternalConnection
+ * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
+ * include in its select/poll mask must call this function to register the
+ * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Whenever Xlib detects input available on fd, it will call callback
+ * with call_data to process it. If non-Xlib code calls select/poll
+ * and detects input available, it must call XProcessInternalConnection,
+ * which will call the associated callback.
+ *
+ * Non-Xlib code can learn about these additional fds by calling
+ * XInternalConnectionNumbers or, more typically, by registering
+ * a XConnectionWatchProc with XAddConnectionWatch
+ * to be called when fds are registered or unregistered.
+ *
+ * Returns True if registration succeeded, False if not, typically
+ * because could not allocate memory.
+ * Assumes Display locked when called.
+ */
+Status
+_XRegisterInternalConnection(
+ Display* dpy,
+ int fd,
+ _XInternalConnectionProc callback,
+ XPointer call_data
+)
+{
+ struct _XConnectionInfo *new_conni, **iptr;
+ struct _XConnWatchInfo *watchers;
+ XPointer *wd;
+
+ new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ if (!new_conni)
+ return 0;
+ new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ if (!new_conni->watch_data) {
+ Xfree(new_conni);
+ return 0;
+ }
+ new_conni->fd = fd;
+ new_conni->read_callback = callback;
+ new_conni->call_data = call_data;
+ new_conni->next = NULL;
+ /* link new structure onto end of list */
+ for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
+ ;
+ *iptr = new_conni;
+ dpy->im_fd_length++;
+ _XPollfdCacheAdd(dpy, fd);
+
+ for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
+ watchers;
+ watchers=watchers->next, wd++) {
+ *wd = NULL; /* for cleanliness */
+ (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
+ }
+
+ return 1;
+}
+
+/* _XUnregisterInternalConnection
+ * Each IM (or Xlib extension) that closes a file descriptor previously
+ * registered with _XRegisterInternalConnection must call this function.
+ * Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Assumes Display locked when called.
+ */
+void
+_XUnregisterInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list, **prev;
+ struct _XConnWatchInfo *watch;
+ XPointer *wd;
+
+ for (prev = &dpy->im_fd_info; (info_list = *prev);
+ prev = &info_list->next) {
+ if (info_list->fd == fd) {
+ *prev = info_list->next;
+ dpy->im_fd_length--;
+ for (watch=dpy->conn_watchers, wd=info_list->watch_data;
+ watch;
+ watch=watch->next, wd++) {
+ (*watch->fn) (dpy, watch->client_data, fd, False, wd);
+ }
+ if (info_list->watch_data)
+ Xfree (info_list->watch_data);
+ Xfree (info_list);
+ break;
+ }
+ }
+ _XPollfdCacheDel(dpy, fd);
+}
+
+/* XInternalConnectionNumbers
+ * Returns an array of fds and an array of corresponding call data.
+ * Typically a XConnectionWatchProc registered with XAddConnectionWatch
+ * will be used instead of this function to discover
+ * additional fds to include in the select/poll mask.
+ *
+ * The list is allocated with Xmalloc and should be freed by the caller
+ * with Xfree;
+ */
+Status
+XInternalConnectionNumbers(
+ Display *dpy,
+ int **fd_return,
+ int *count_return
+)
+{
+ int count;
+ struct _XConnectionInfo *info_list;
+ int *fd_list;
+
+ LockDisplay(dpy);
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
+ count++;
+ fd_list = (int*) Xmalloc (count * sizeof(int));
+ if (!fd_list) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ fd_list[count] = info_list->fd;
+ count++;
+ }
+ UnlockDisplay(dpy);
+
+ *fd_return = fd_list;
+ *count_return = count;
+ return 1;
+}
+
+void _XProcessInternalConnection(
+ Display *dpy,
+ struct _XConnectionInfo *conn_info)
+{
+ dpy->flags |= XlibDisplayProcConni;
+#if defined(XTHREADS) && !USE_XCB
+ if (dpy->lock) {
+ /* check cache to avoid call to thread_self */
+ if (xthread_have_id(dpy->lock->reading_thread))
+ dpy->lock->conni_thread = dpy->lock->reading_thread;
+ else
+ dpy->lock->conni_thread = XThread_Self();
+ }
+#endif /* XTHREADS && !USE_XCB */
+ UnlockDisplay(dpy);
+ (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
+ LockDisplay(dpy);
+#if defined(XTHREADS) && !USE_XCB
+ if (dpy->lock)
+ xthread_clear_id(dpy->lock->conni_thread);
+#endif /* XTHREADS && !USE_XCB */
+ dpy->flags &= ~XlibDisplayProcConni;
+}
+
+/* XProcessInternalConnection
+ * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
+ * for this fd.
+ * The Display is NOT locked during the call.
+ */
+void
+XProcessInternalConnection(
+ Display* dpy,
+ int fd
+)
+{
+ struct _XConnectionInfo *info_list;
+
+ LockDisplay(dpy);
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ if (info_list->fd == fd) {
+ _XProcessInternalConnection(dpy, info_list);
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+}
+
+/* XAddConnectionWatch
+ * Register a callback to be called whenever _XRegisterInternalConnection
+ * or _XUnregisterInternalConnection is called.
+ * Callbacks are called with the Display locked.
+ * If any connections are already registered, the callback is immediately
+ * called for each of them.
+ */
+Status
+XAddConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *new_watcher, **wptr;
+ struct _XConnectionInfo *info_list;
+ XPointer *wd_array;
+
+ LockDisplay(dpy);
+
+ /* allocate new watch data */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
+ (dpy->watcher_count + 1) *
+ sizeof(XPointer));
+ if (!wd_array) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
+ }
+
+ new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ if (!new_watcher) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ new_watcher->fn = callback;
+ new_watcher->client_data = client_data;
+ new_watcher->next = NULL;
+
+ /* link new structure onto end of list */
+ for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
+ ;
+ *wptr = new_watcher;
+ dpy->watcher_count++;
+
+ /* call new watcher on all currently registered fds */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ (*callback) (dpy, client_data, info_list->fd, True,
+ info_list->watch_data + dpy->watcher_count - 1);
+ }
+
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+/* XRemoveConnectionWatch
+ * Unregister a callback registered by XAddConnectionWatch.
+ * Both callback and client_data must match what was passed to
+ * XAddConnectionWatch.
+ */
+void
+XRemoveConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+{
+ struct _XConnWatchInfo *watch;
+ struct _XConnWatchInfo *previous = NULL;
+ struct _XConnectionInfo *conni;
+ int counter = 0;
+
+ LockDisplay(dpy);
+ for (watch=dpy->conn_watchers; watch; watch=watch->next) {
+ if (watch->fn == callback && watch->client_data == client_data) {
+ if (previous)
+ previous->next = watch->next;
+ else
+ dpy->conn_watchers = watch->next;
+ Xfree (watch);
+ dpy->watcher_count--;
+ /* remove our watch_data for each connection */
+ for (conni=dpy->im_fd_info; conni; conni=conni->next) {
+ /* don't bother realloc'ing; these arrays are small anyway */
+ /* overlapping */
+ memmove(conni->watch_data+counter,
+ conni->watch_data+counter+1,
+ dpy->watcher_count - counter);
+ }
+ break;
+ }
+ previous = watch;
+ counter++;
+ }
+ UnlockDisplay(dpy);
+}
+
+/* end of internal connections support */
+
+
+#if !USE_XCB
+/* Read and discard "n" 8-bit bytes of data */
+
+void _XEatData(
+ Display *dpy,
+ register unsigned long n)
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ (void) _XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+#endif /* !USE_XCB */
+
+/* Cookie jar implementation
+ dpy->cookiejar is a linked list. _XEnq receives the events but leaves
+ them in the normal EQ. _XStoreEvent returns the cookie event (minus
+ data pointer) and adds it to the cookiejar. _XDeq just removes
+ the entry like any other event but resets the data pointer for
+ cookie events (to avoid double-free, the memory is re-used by Xlib).
+
+ _XFetchEventCookie (called from XGetEventData) removes a cookie from the
+ jar. _XFreeEventCookies removes all unclaimed cookies from the jar
+ (called by XNextEvent).
+
+ _XFreeDisplayStructure calls _XFreeEventCookies for each cookie in the
+ normal EQ.
+ */
+
+#include "utlist.h"
+struct stored_event {
+ XGenericEventCookie ev;
+ struct stored_event *prev;
+ struct stored_event *next;
+};
+
+Bool
+_XIsEventCookie(Display *dpy, XEvent *ev)
+{
+ return (ev->xcookie.type == GenericEvent &&
+ dpy->generic_event_vec[ev->xcookie.extension & 0x7F] != NULL);
+}
+
+/**
+ * Free all events in the event list.
+ */
+void
+_XFreeEventCookies(Display *dpy)
+{
+ struct stored_event **head, *e, *tmp;
+
+ if (!dpy->cookiejar)
+ return;
+
+ head = (struct stored_event**)&dpy->cookiejar;
+
+ DL_FOREACH_SAFE(*head, e, tmp) {
+ XFree(e->ev.data);
+ XFree(e);
+ if (dpy->cookiejar == e)
+ dpy->cookiejar = NULL;
+ }
+}
+
+/**
+ * Add an event to the display's event list. This event must be freed on the
+ * next call to XNextEvent().
+ */
+void
+_XStoreEventCookie(Display *dpy, XEvent *event)
+{
+ XGenericEventCookie* cookie = &event->xcookie;
+ struct stored_event **head, *add;
+
+ if (!_XIsEventCookie(dpy, event))
+ return;
+
+ head = (struct stored_event**)(&dpy->cookiejar);
+
+ add = Xmalloc(sizeof(struct stored_event));
+ if (!add) {
+ ESET(ENOMEM);
+ _XIOError(dpy);
+ }
+ add->ev = *cookie;
+ DL_APPEND(*head, add);
+ cookie->data = NULL; /* don't return data yet, must be claimed */
+}
+
+/**
+ * Return the event with the given cookie and remove it from the list.
+ */
+Bool
+_XFetchEventCookie(Display *dpy, XGenericEventCookie* ev)
+{
+ Bool ret = False;
+ struct stored_event **head, *event;
+ head = (struct stored_event**)&dpy->cookiejar;
+
+ if (!_XIsEventCookie(dpy, (XEvent*)ev))
+ return ret;
+
+ DL_FOREACH(*head, event) {
+ if (event->ev.cookie == ev->cookie &&
+ event->ev.extension == ev->extension &&
+ event->ev.evtype == ev->evtype) {
+ *ev = event->ev;
+ DL_DELETE(*head, event);
+ Xfree(event);
+ ret = True;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+Bool
+_XCopyEventCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
+{
+ Bool ret = False;
+ int extension;
+
+ if (!_XIsEventCookie(dpy, (XEvent*)in) || !out)
+ return ret;
+
+ extension = in->extension & 0x7F;
+
+ if (!dpy->generic_event_copy_vec[extension])
+ return ret;
+
+ ret = ((*dpy->generic_event_copy_vec[extension])(dpy, in, out));
+ out->cookie = ret ? ++dpy->next_cookie : 0;
+ return ret;
+}
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq(
+ register Display *dpy,
+ register xEvent *event)
+{
+ register _XQEvent *qelt;
+ int type, extension;
+
+ if ((qelt = dpy->qfree)) {
+ /* If dpy->qfree is non-NULL do this, else malloc a new one. */
+ dpy->qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+ _XIOError(dpy);
+ }
+ qelt->next = NULL;
+
+ type = event->u.u.type & 0177;
+ extension = ((xGenericEvent*)event)->extension;
+ /* If an extension has registerd a generic_event_vec handler, then
+ * it can handle event cookies. Otherwise, proceed with the normal
+ * event handlers.
+ *
+ * If the generic_event_vec is called, qelt->event is a event cookie
+ * with the data pointer and the "free" pointer set. Data pointer is
+ * some memory allocated by the extension.
+ */
+ if (type == GenericEvent && dpy->generic_event_vec[extension & 0x7F]) {
+ XGenericEventCookie *cookie = &qelt->event.xcookie;
+ (*dpy->generic_event_vec[extension & 0x7F])(dpy, cookie, event);
+ cookie->cookie = ++dpy->next_cookie;
+
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else if ((*dpy->event_vec[type])(dpy, &qelt->event, event)) {
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ }
+}
+
+/*
+ * _XDeq - Remove event packet from the display's queue.
+ */
+void _XDeq(
+ register Display *dpy,
+ register _XQEvent *prev, /* element before qelt */
+ register _XQEvent *qelt) /* element to be unlinked */
+{
+ if (prev) {
+ if ((prev->next = qelt->next) == NULL)
+ dpy->tail = prev;
+ } else {
+ /* no prev, so removing first elt */
+ if ((dpy->head = qelt->next) == NULL)
+ dpy->tail = NULL;
+ }
+ qelt->qserial_num = 0;
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ dpy->qlen--;
+
+ if (_XIsEventCookie(dpy, &qelt->event)) {
+ XGenericEventCookie* cookie = &qelt->event.xcookie;
+ /* dpy->qfree is re-used, reset memory to avoid double free on
+ * _XFreeDisplayStructure */
+ cookie->data = NULL;
+ }
+}
+
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_XUnknownWireEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->u.u.type, dpy);
+#endif
+ return(False);
+}
+
+Bool
+_XUnknownWireEventCookie(
+ Display *dpy, /* pointer to display structure */
+ XGenericEventCookie *re, /* pointer to where event should be reformatted */
+ xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ fprintf(stderr,
+ "Xlib: unhandled wire cookie event! extension number = %d, display = %x\n.",
+ ((xGenericEvent*)event)->extension, dpy);
+#endif
+ return(False);
+}
+
+Bool
+_XUnknownCopyEventCookie(
+ Display *dpy, /* pointer to display structure */
+ XGenericEventCookie *in, /* source */
+ XGenericEventCookie *out) /* destination */
+{
+#ifdef notdef
+ fprintf(stderr,
+ "Xlib: unhandled cookie event copy! extension number = %d, display = %x\n.",
+ in->extension, dpy);
+#endif
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+_XUnknownNativeEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, dpy);
+#endif
+ return(0);
+}
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(
+ register Display *dpy, /* pointer to display structure */
+ register XEvent *re, /* pointer to where event should be reformatted */
+ register xEvent *event) /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+int _XDefaultIOError(
+ Display *dpy)
+{
+ if (ECHECK(EPIPE)) {
+ (void) fprintf (stderr,
+ "X connection to %s broken (explicit kill or server shutdown).\r\n",
+ DisplayString (dpy));
+ } else {
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+ errno, strerror (errno),
+#endif
+ DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ }
+ exit(1);
+ return(0); /* dummy - function should never return */
+}
+
+
+static int _XPrintDefaultError(
+ Display *dpy,
+ XErrorEvent *event,
+ FILE *fp)
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ const char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(
+ Display *dpy,
+ XErrorEvent *event)
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we)
+{
+ return True;
+}
+
+/*
+ * _XError - upcall internal or user protocol error handler
+ */
+int _XError (
+ Display *dpy,
+ register xError *rep)
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+ register _XAsyncHandler *async, *next;
+
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((*async->handler)(dpy, (xReply *)rep,
+ (char *)rep, SIZEOF(xError), async->data))
+ return 0;
+ }
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ int rtn_val;
+#if defined(XTHREADS) && !USE_XCB
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif /* XTHREADS && !USE_XCB */
+ rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
+#if defined(XTHREADS) && !USE_XCB
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif /* XTHREADS && !USE_XCB */
+ return rtn_val;
+ } else {
+ return _XDefaultError(dpy, (XErrorEvent *)&event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+int
+_XIOError (
+ Display *dpy)
+{
+ dpy->flags |= XlibDisplayIOError;
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+
+ /* This assumes that the thread calling exit will call any atexit handlers.
+ * If this does not hold, then an alternate solution would involve
+ * registering an atexit handler to take over the lock, which would only
+ * assume that the same thread calls all the atexit handlers. */
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+#endif
+ UnlockDisplay(dpy);
+
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+ exit (1);
+ return 0;
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. A single buffer is reused each time
+ * if possible. To be MT safe, you can only call this between a call to
+ * GetReq* and a call to Data* or _XSend*, or in a context when the thread
+ * is guaranteed to not unlock the display.
+ */
+char *_XAllocScratch(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Scratch space allocator you can call any time, multiple times, and be
+ * MT safe, but you must hand the buffer back with _XFreeTemp.
+ */
+char *_XAllocTemp(
+ register Display *dpy,
+ unsigned long nbytes)
+{
+ char *buf;
+
+ buf = _XAllocScratch(dpy, nbytes);
+ dpy->scratch_buffer = NULL;
+ dpy->scratch_length = 0;
+ return buf;
+}
+
+void _XFreeTemp(
+ register Display *dpy,
+ char *buf,
+ unsigned long nbytes)
+{
+ if (dpy->scratch_buffer)
+ Xfree(dpy->scratch_buffer);
+ dpy->scratch_buffer = buf;
+ dpy->scratch_length = nbytes;
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual(
+ Display *dpy,
+ VisualID id)
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+int
+XFree (void *data)
+{
+ Xfree (data);
+ return 1;
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(b1, b2, length)
+ register char *b1, *b2;
+ register length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#ifdef DataRoutineIsProcedure
+void Data(
+ Display *dpy,
+ char *data,
+ long len)
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ memcpy(dpy->bufptr, data, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ _XSend(dpy, data, len);
+ }
+}
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef LONG64
+int
+_XData32(
+ Display *dpy,
+ register long *data,
+ unsigned len)
+{
+ register int *buf;
+ register long i;
+
+ while (len) {
+ buf = (int *)dpy->bufptr;
+ i = dpy->bufmax - (char *)buf;
+ if (!i) {
+ _XFlush(dpy);
+ continue;
+ }
+ if (len < i)
+ i = len;
+ dpy->bufptr = (char *)buf + i;
+ len -= i;
+ i >>= 2;
+ while (--i >= 0)
+ *buf++ = *data++;
+ }
+ return 0;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData16(
+ register Display *dpy,
+ short *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData16 (
+ Display *dpy,
+ short *data,
+ unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32(
+ register Display *dpy
+ long *data,
+ unsigned len,
+ char *packbuffer)
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+void _XData32(
+ Display *dpy,
+ long *data,
+ unsigned len)
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3) && !defined(__QNX__)) || defined(hpux) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#else
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#endif
+
+/*
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+int _XGetHostname (
+ char *buf,
+ int maxlen)
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow(Display *dpy, Window w)
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return NULL;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
+
+#if defined(WIN32)
+
+/*
+ * These functions are intended to be used internally to Xlib only.
+ * These functions will always prefix the path with a DOS drive in the
+ * form "<drive-letter>:". As such, these functions are only suitable
+ * for use by Xlib function that supply a root-based path to some
+ * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
+ * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
+ */
+
+static int access_file (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = Xmalloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __UNIXOS2__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+
+#ifndef __UNIXOS2__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+int _XOpenFile(path, flags)
+ _Xconst char* path;
+ int flags;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XOpenFileMode(path, flags, mode)
+ _Xconst char* path;
+ int flags;
+ mode_t mode;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+void* _XFopenFile(path, mode)
+ _Xconst char* path;
+ _Xconst char* mode;
+{
+ char buf[MAX_PATH];
+ char* bufp = NULL;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XAccessFile(path)
+ _Xconst char* path;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ ret = AccessFile (path, buf, MAX_PATH, &bufp);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+#endif
+
+#ifdef WIN32
+#undef _Xdebug
+int _Xdebug = 0;
+int *_Xdebug_p = &_Xdebug;
+void (**_XCreateMutex_fn_p)(LockInfoPtr) = &_XCreateMutex_fn;
+void (**_XFreeMutex_fn_p)(LockInfoPtr) = &_XFreeMutex_fn;
+void (**_XLockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XLockMutex_fn;
+void (**_XUnlockMutex_fn_p)(LockInfoPtr
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+ ) = &_XUnlockMutex_fn;
+LockInfoPtr *_Xglobal_lock_p = &_Xglobal_lock;
+#endif
diff --git a/libX11/src/Xprivate.h b/libX11/src/Xprivate.h
index c2c7a0749..ce6e431ec 100644
--- a/libX11/src/Xprivate.h
+++ b/libX11/src/Xprivate.h
@@ -1,15 +1,28 @@
-/* Copyright (C) 2008 Jamey Sharp, Josh Triplett
- * This file is licensed under the MIT license. See the file COPYING.
- *
- * As Xlibint.h has long become effectively public API, this header exists
- * for new private functions that nothing outside of libX11 should call.
- */
-
-#ifndef XPRIVATE_H
-#define XPRIVATE_H
-
-extern int _XIDHandler(Display *dpy);
-extern void _XSetPrivSyncFunction(Display *dpy);
-extern void _XSetSeqSyncFunction(Display *dpy);
-
-#endif /* XPRIVATE_H */
+/* Copyright (C) 2008 Jamey Sharp, Josh Triplett
+ * This file is licensed under the MIT license. See the file COPYING.
+ *
+ * As Xlibint.h has long become effectively public API, this header exists
+ * for new private functions that nothing outside of libX11 should call.
+ */
+
+#ifndef XPRIVATE_H
+#define XPRIVATE_H
+
+extern void _XIDHandler(Display *dpy);
+extern void _XSeqSyncFunction(Display *dpy);
+extern void _XSetPrivSyncFunction(Display *dpy);
+extern void _XSetSeqSyncFunction(Display *dpy);
+
+#ifdef XTHREADS
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
+#else
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip)
+#endif
+#else /* XTHREADS else */
+#define InternalLockDisplay(d,wskip)
+#endif /* XTHREADS else */
+
+#endif /* XPRIVATE_H */
diff --git a/libX11/src/Xxcbint.h b/libX11/src/Xxcbint.h
index f6afa1834..06636ce86 100644
--- a/libX11/src/Xxcbint.h
+++ b/libX11/src/Xxcbint.h
@@ -1,46 +1,46 @@
-/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
- * This file is licensed under the MIT license. See the file COPYING. */
-
-#ifndef XXCBINT_H
-#define XXCBINT_H
-
-#include <assert.h>
-#include <stdint.h>
-#include <X11/Xlibint.h>
-#include <X11/Xlib-xcb.h>
-#include "locking.h"
-
-#define XLIB_SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
-
-typedef struct PendingRequest PendingRequest;
-struct PendingRequest {
- PendingRequest *next;
- unsigned long sequence;
-};
-
-typedef struct _X11XCBPrivate {
- xcb_connection_t *connection;
- PendingRequest *pending_requests;
- PendingRequest **pending_requests_tail;
- xcb_generic_event_t *next_event;
- char *real_bufmax;
- char *reply_data;
- int reply_length;
- int reply_consumed;
- uint64_t last_flushed;
- enum XEventQueueOwner event_owner;
- XID next_xid;
-
- /* handle simultaneous threads waiting for events,
- * used in wait_or_poll_for_event
- */
- xcondition_t event_notify;
- int event_waiter;
-} _X11XCBPrivate;
-
-/* xcb_disp.c */
-
-int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp);
-void _XFreeX11XCBStructure(Display *dpy);
-
-#endif /* XXCBINT_H */
+/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
+ * This file is licensed under the MIT license. See the file COPYING. */
+
+#ifndef XXCBINT_H
+#define XXCBINT_H
+
+#include <assert.h>
+#include <stdint.h>
+#include <X11/Xlibint.h>
+#include <X11/Xlib-xcb.h>
+#include "locking.h"
+
+#define XLIB_SEQUENCE_COMPARE(a,op,b) (((long) (a) - (long) (b)) op 0)
+
+typedef struct PendingRequest PendingRequest;
+struct PendingRequest {
+ PendingRequest *next;
+ unsigned long sequence;
+ unsigned reply_waiter;
+};
+
+typedef struct _X11XCBPrivate {
+ xcb_connection_t *connection;
+ PendingRequest *pending_requests;
+ PendingRequest *pending_requests_tail;
+ xcb_generic_event_t *next_event;
+ char *real_bufmax;
+ char *reply_data;
+ int reply_length;
+ int reply_consumed;
+ uint64_t last_flushed;
+ enum XEventQueueOwner event_owner;
+ XID next_xid;
+
+ /* handle simultaneous threads waiting for responses */
+ xcondition_t event_notify;
+ int event_waiter;
+ xcondition_t reply_notify;
+} _X11XCBPrivate;
+
+/* xcb_disp.c */
+
+int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp);
+void _XFreeX11XCBStructure(Display *dpy);
+
+#endif /* XXCBINT_H */
diff --git a/libX11/src/locking.c b/libX11/src/locking.c
index 3f93d0cd8..008a14863 100644
--- a/libX11/src/locking.c
+++ b/libX11/src/locking.c
@@ -1,620 +1,623 @@
-/*
-
-Copyright 1992, 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.
-
-*/
-
-/*
- * Author: Stephen Gildea, MIT X Consortium
- *
- * locking.c - multi-thread locking routines implemented in C Threads
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#undef _XLockMutex
-#undef _XUnlockMutex
-#undef _XCreateMutex
-#undef _XFreeMutex
-
-#ifdef XTHREADS
-
-#ifdef __UNIXWARE__
-#include <dlfcn.h>
-#endif
-
-#include "locking.h"
-#ifdef XTHREADS_WARN
-#include <stdio.h> /* for warn/debug stuff */
-#endif
-
-/* Additional arguments for source code location lock call was made from */
-#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
-# define XTHREADS_FILE_LINE_ARGS \
- , \
- char* file, /* source file, from macro */ \
- int line
-#else
-# define XTHREADS_FILE_LINE_ARGS /* None */
-#endif
-
-
-#define NUM_FREE_CVLS 4
-
-/* in lcWrap.c */
-extern LockInfoPtr _Xi18n_lock;
-
-#ifdef WIN32
-static DWORD _X_TlsIndex = (DWORD)-1;
-
-void _Xthread_init(void)
-{
- if (_X_TlsIndex == (DWORD)-1)
- _X_TlsIndex = TlsAlloc();
-}
-
-struct _xthread_waiter *
-_Xthread_waiter(void)
-{
- struct _xthread_waiter *me;
-
- if (!(me = TlsGetValue(_X_TlsIndex))) {
- me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter));
- me->sem = CreateSemaphore(NULL, 0, 1, NULL);
- me->next = NULL;
- TlsSetValue(_X_TlsIndex, me);
- }
- return me;
-}
-#endif /* WIN32 */
-
-static xthread_t _Xthread_self(void)
-{
- return xthread_self();
-}
-
-static LockInfoRec global_lock;
-static LockInfoRec i18n_lock;
-
-static void _XLockMutex(
- LockInfoPtr lip
- XTHREADS_FILE_LINE_ARGS
- )
-{
- xmutex_lock(lip->lock);
-}
-
-static void _XUnlockMutex(
- LockInfoPtr lip
- XTHREADS_FILE_LINE_ARGS
- )
-{
- xmutex_unlock(lip->lock);
-}
-
-static void _XCreateMutex(
- LockInfoPtr lip)
-{
- lip->lock = xmutex_malloc();
- if (lip->lock) {
- xmutex_init(lip->lock);
- xmutex_set_name(lip->lock, "Xlib");
- }
-}
-
-static void _XFreeMutex(
- LockInfoPtr lip)
-{
- xmutex_clear(lip->lock);
- xmutex_free(lip->lock);
-}
-
-#ifdef XTHREADS_WARN
-static char *locking_file;
-static int locking_line;
-static xthread_t locking_thread;
-static Bool xlibint_unlock = False; /* XlibInt.c may Unlock and re-Lock */
-
-/* history that is useful to examine in a debugger */
-#define LOCK_HIST_SIZE 21
-
-static struct {
- Bool lockp; /* True for lock, False for unlock */
- xthread_t thread;
- char *file;
- int line;
-} locking_history[LOCK_HIST_SIZE];
-
-int lock_hist_loc = 0; /* next slot to fill */
-
-static void _XLockDisplayWarn(
- Display *dpy,
- char *file, /* source file, from macro */
- int line)
-{
- xthread_t self;
- xthread_t old_locker;
-
- self = xthread_self();
- old_locker = locking_thread;
- if (xthread_have_id(old_locker)) {
- if (xthread_equal(old_locker, self))
- printf("Xlib ERROR: %s line %d thread %x: locking display already locked at %s line %d\n",
- file, line, self, locking_file, locking_line);
-#ifdef XTHREADS_DEBUG
- else
- printf("%s line %d: thread %x waiting on lock held by %s line %d thread %x\n",
- file, line, self,
- locking_file, locking_line, old_locker);
-#endif /* XTHREADS_DEBUG */
- }
-
- xmutex_lock(dpy->lock->mutex);
-
- if (strcmp(file, "XlibInt.c") == 0) {
- if (!xlibint_unlock)
- printf("Xlib ERROR: XlibInt.c line %d thread %x locking display it did not unlock\n",
- line, self);
- xlibint_unlock = False;
- }
-
-#ifdef XTHREADS_DEBUG
- /* if (old_locker && old_locker != self) */
- if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
- printf("%s line %d: thread %x got display lock\n", file, line, self);
-#endif /* XTHREADS_DEBUG */
-
- locking_thread = self;
- if (strcmp(file, "XlibInt.c") != 0) {
- locking_file = file;
- locking_line = line;
- }
- locking_history[lock_hist_loc].file = file;
- locking_history[lock_hist_loc].line = line;
- locking_history[lock_hist_loc].thread = self;
- locking_history[lock_hist_loc].lockp = True;
- lock_hist_loc++;
- if (lock_hist_loc >= LOCK_HIST_SIZE)
- lock_hist_loc = 0;
-}
-#endif /* XTHREADS_WARN */
-
-static void _XUnlockDisplay(
- Display *dpy
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
- xthread_t self = xthread_self();
-
-#ifdef XTHREADS_DEBUG
- if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
- printf("%s line %d: thread %x unlocking display\n", file, line, self);
-#endif /* XTHREADS_DEBUG */
-
- if (!xthread_have_id(locking_thread))
- printf("Xlib ERROR: %s line %d thread %x: unlocking display that is not locked\n",
- file, line, self);
- else if (strcmp(file, "XlibInt.c") == 0)
- xlibint_unlock = True;
-#ifdef XTHREADS_DEBUG
- else if (strcmp(file, locking_file) != 0)
- /* not always an error because locking_file is not per-thread */
- printf("%s line %d: unlocking display locked from %s line %d (probably okay)\n",
- file, line, locking_file, locking_line);
-#endif /* XTHREADS_DEBUG */
- xthread_clear_id(locking_thread);
-
- locking_history[lock_hist_loc].file = file;
- locking_history[lock_hist_loc].line = line;
- locking_history[lock_hist_loc].thread = self;
- locking_history[lock_hist_loc].lockp = False;
- lock_hist_loc++;
- if (lock_hist_loc >= LOCK_HIST_SIZE)
- lock_hist_loc = 0;
-#endif /* XTHREADS_WARN */
- xmutex_unlock(dpy->lock->mutex);
-}
-
-
-static struct _XCVList *_XCreateCVL(
- Display *dpy)
-{
- struct _XCVList *cvl;
-
- if ((cvl = dpy->lock->free_cvls) != NULL) {
- dpy->lock->free_cvls = cvl->next;
- dpy->lock->num_free_cvls--;
- } else {
- cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList));
- if (!cvl)
- return NULL;
- cvl->cv = xcondition_malloc();
- if (!cvl->cv) {
- Xfree(cvl);
- return NULL;
- }
- xcondition_init(cvl->cv);
- xcondition_set_name(cvl->cv, "Xlib read queue");
- }
- cvl->next = NULL;
- return cvl;
-}
-
-/* Put ourselves on the queue to read the connection.
- Allocates and returns a queue element. */
-
-static struct _XCVList *
-_XPushReader(
- Display *dpy,
- struct _XCVList ***tail)
-{
- struct _XCVList *cvl;
-
- cvl = _XCreateCVL(dpy);
-#ifdef XTHREADS_DEBUG
- printf("_XPushReader called in thread %x, pushing %x\n",
- xthread_self(), cvl);
-#endif
- **tail = cvl;
- *tail = &cvl->next;
- return cvl;
-}
-
-/* signal the next thread waiting to read the connection */
-
-static void _XPopReader(
- Display *dpy,
- struct _XCVList **list,
- struct _XCVList ***tail)
-{
- register struct _XCVList *front = *list;
-
-#ifdef XTHREADS_DEBUG
- printf("_XPopReader called in thread %x, popping %x\n",
- xthread_self(), front);
-#endif
-
- if (dpy->flags & XlibDisplayProcConni)
- /* we never added ourself in the first place */
- return;
-
- if (front) { /* check "front" for paranoia */
- *list = front->next;
- if (*tail == &front->next) /* did we free the last elt? */
- *tail = list;
- if (dpy->lock->num_free_cvls < NUM_FREE_CVLS) {
- front->next = dpy->lock->free_cvls;
- dpy->lock->free_cvls = front;
- dpy->lock->num_free_cvls++;
- } else {
- xcondition_clear(front->cv);
- Xfree((char *)front->cv);
- Xfree((char *)front);
- }
- }
-
- /* signal new front after it is in place */
- if ((dpy->lock->reply_first = (dpy->lock->reply_awaiters != NULL))) {
- ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
- } else if (dpy->lock->event_awaiters) {
- ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
- }
-}
-
-static void _XConditionWait(
- xcondition_t cv,
- xmutex_t mutex
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
- xthread_t self = xthread_self();
- char *old_file = locking_file;
- int old_line = locking_line;
-
-#ifdef XTHREADS_DEBUG
- printf("line %d thread %x in condition wait\n", line, self);
-#endif
- xthread_clear_id(locking_thread);
-
- locking_history[lock_hist_loc].file = file;
- locking_history[lock_hist_loc].line = line;
- locking_history[lock_hist_loc].thread = self;
- locking_history[lock_hist_loc].lockp = False;
- lock_hist_loc++;
- if (lock_hist_loc >= LOCK_HIST_SIZE)
- lock_hist_loc = 0;
-#endif /* XTHREADS_WARN */
-
- xcondition_wait(cv, mutex);
-
-#ifdef XTHREADS_WARN
- locking_thread = self;
- locking_file = old_file;
- locking_line = old_line;
-
- locking_history[lock_hist_loc].file = file;
- locking_history[lock_hist_loc].line = line;
- locking_history[lock_hist_loc].thread = self;
- locking_history[lock_hist_loc].lockp = True;
- lock_hist_loc++;
- if (lock_hist_loc >= LOCK_HIST_SIZE)
- lock_hist_loc = 0;
-#ifdef XTHREADS_DEBUG
- printf("line %d thread %x was signaled\n", line, self);
-#endif /* XTHREADS_DEBUG */
-#endif /* XTHREADS_WARN */
-}
-
-static void _XConditionSignal(
- xcondition_t cv
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
-#ifdef XTHREADS_DEBUG
- printf("line %d thread %x is signalling\n", line, xthread_self());
-#endif
-#endif
- xcondition_signal(cv);
-}
-
-
-static void _XConditionBroadcast(
- xcondition_t cv
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
-#ifdef XTHREADS_DEBUG
- printf("line %d thread %x is broadcasting\n", line, xthread_self());
-#endif
-#endif
- xcondition_broadcast(cv);
-}
-
-
-static void _XFreeDisplayLock(
- Display *dpy)
-{
- struct _XCVList *cvl;
-
- if (dpy->lock != NULL) {
- if (dpy->lock->mutex != NULL) {
- xmutex_clear(dpy->lock->mutex);
- xmutex_free(dpy->lock->mutex);
- }
- if (dpy->lock->cv != NULL) {
- xcondition_clear(dpy->lock->cv);
- xcondition_free(dpy->lock->cv);
- }
- if (dpy->lock->writers != NULL) {
- xcondition_clear(dpy->lock->writers);
- xcondition_free(dpy->lock->writers);
- }
- while ((cvl = dpy->lock->free_cvls)) {
- dpy->lock->free_cvls = cvl->next;
- xcondition_clear(cvl->cv);
- Xfree((char *)cvl->cv);
- Xfree((char *)cvl);
- }
- Xfree((char *)dpy->lock);
- dpy->lock = NULL;
- }
- if (dpy->lock_fns != NULL) {
- Xfree((char *)dpy->lock_fns);
- dpy->lock_fns = NULL;
- }
-}
-
-/*
- * wait for thread with user-level display lock to release it.
- */
-
-static void _XDisplayLockWait(
- Display *dpy)
-{
- xthread_t self;
-
- while (dpy->lock->locking_level > 0) {
- self = xthread_self();
- if (xthread_equal(dpy->lock->locking_thread, self))
- break;
- ConditionWait(dpy, dpy->lock->cv);
- }
-}
-
-static void _XLockDisplay(
- Display *dpy
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
- _XLockDisplayWarn(dpy, file, line);
-#else
- xmutex_lock(dpy->lock->mutex);
-#endif
- if (dpy->lock->locking_level > 0)
- _XDisplayLockWait(dpy);
-}
-
-/*
- * _XReply is allowed to exit from select/poll and clean up even if a
- * user-level lock is in force, so it uses this instead of _XFancyLockDisplay.
- */
-static void _XInternalLockDisplay(
- Display *dpy,
- Bool wskip
- XTHREADS_FILE_LINE_ARGS
- )
-{
-#ifdef XTHREADS_WARN
- _XLockDisplayWarn(dpy, file, line);
-#else
- xmutex_lock(dpy->lock->mutex);
-#endif
- if (!wskip && dpy->lock->locking_level > 0)
- _XDisplayLockWait(dpy);
-}
-
-static void _XUserLockDisplay(
- register Display* dpy)
-{
- if (++dpy->lock->locking_level == 1) {
- dpy->lock->lock_wait = _XDisplayLockWait;
- dpy->lock->locking_thread = xthread_self();
- }
-}
-
-static
-void _XUserUnlockDisplay(
- register Display* dpy)
-{
- if (dpy->lock->locking_level > 0 && --dpy->lock->locking_level == 0) {
- /* signal other threads that might be waiting in XLockDisplay */
- ConditionBroadcast(dpy, dpy->lock->cv);
- dpy->lock->lock_wait = NULL;
- xthread_clear_id(dpy->lock->locking_thread);
- }
-}
-
-/* returns 0 if initialized ok, -1 if unable to allocate
- a mutex or other memory */
-
-static int _XInitDisplayLock(
- Display *dpy)
-{
- dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs));
- if (dpy->lock_fns == NULL)
- return -1;
- dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo));
- if (dpy->lock == NULL) {
- _XFreeDisplayLock(dpy);
- return -1;
- }
- dpy->lock->cv = xcondition_malloc();
- dpy->lock->mutex = xmutex_malloc();
- dpy->lock->writers = xcondition_malloc();
- if (!dpy->lock->cv || !dpy->lock->mutex || !dpy->lock->writers) {
- _XFreeDisplayLock(dpy);
- return -1;
- }
-
- dpy->lock->reply_bytes_left = 0;
- dpy->lock->reply_was_read = False;
- dpy->lock->reply_awaiters = NULL;
- dpy->lock->reply_awaiters_tail = &dpy->lock->reply_awaiters;
- dpy->lock->event_awaiters = NULL;
- dpy->lock->event_awaiters_tail = &dpy->lock->event_awaiters;
- dpy->lock->reply_first = False;
- dpy->lock->locking_level = 0;
- dpy->lock->num_free_cvls = 0;
- dpy->lock->free_cvls = NULL;
- xthread_clear_id(dpy->lock->locking_thread);
- xthread_clear_id(dpy->lock->reading_thread);
- xthread_clear_id(dpy->lock->conni_thread);
- xmutex_init(dpy->lock->mutex);
- xmutex_set_name(dpy->lock->mutex, "Xlib Display");
- xcondition_init(dpy->lock->cv);
- xcondition_set_name(dpy->lock->cv, "XLockDisplay");
- xcondition_init(dpy->lock->writers);
- xcondition_set_name(dpy->lock->writers, "Xlib wait for writable");
- dpy->lock_fns->lock_display = _XLockDisplay;
- dpy->lock->internal_lock_display = _XInternalLockDisplay;
- dpy->lock_fns->unlock_display = _XUnlockDisplay;
- dpy->lock->user_lock_display = _XUserLockDisplay;
- dpy->lock->user_unlock_display = _XUserUnlockDisplay;
- dpy->lock->pop_reader = _XPopReader;
- dpy->lock->push_reader = _XPushReader;
- dpy->lock->condition_wait = _XConditionWait;
- dpy->lock->condition_signal = _XConditionSignal;
- dpy->lock->condition_broadcast = _XConditionBroadcast;
- dpy->lock->create_cvl = _XCreateCVL;
- dpy->lock->lock_wait = NULL; /* filled in by XLockDisplay() */
-
- return 0;
-}
-
-#ifdef __UNIXWARE__
-xthread_t __x11_thr_self() { return 0; }
-xthread_t (*_x11_thr_self)() = __x11_thr_self;
-#endif
-
-
-Status XInitThreads(void)
-{
- if (_Xglobal_lock)
- return 1;
-#ifdef __UNIXWARE__
- else {
- void *dl_handle = dlopen(NULL, RTLD_LAZY);
- if (!dl_handle ||
- ((_x11_thr_self = (xthread_t(*)())dlsym(dl_handle,"thr_self")) == 0)) {
- _x11_thr_self = __x11_thr_self;
- (void) fprintf (stderr,
- "XInitThreads called, but no libthread in the calling program!\n" );
- }
- }
-#endif /* __UNIXWARE__ */
-#ifdef xthread_init
- xthread_init(); /* return value? */
-#endif
- if (!(global_lock.lock = xmutex_malloc()))
- return 0;
- if (!(i18n_lock.lock = xmutex_malloc())) {
- xmutex_free(global_lock.lock);
- global_lock.lock = NULL;
- return 0;
- }
- _Xglobal_lock = &global_lock;
- xmutex_init(_Xglobal_lock->lock);
- xmutex_set_name(_Xglobal_lock->lock, "Xlib global");
- _Xi18n_lock = &i18n_lock;
- xmutex_init(_Xi18n_lock->lock);
- xmutex_set_name(_Xi18n_lock->lock, "Xlib i18n");
- _XLockMutex_fn = _XLockMutex;
- _XUnlockMutex_fn = _XUnlockMutex;
- _XCreateMutex_fn = _XCreateMutex;
- _XFreeMutex_fn = _XFreeMutex;
- _XInitDisplayLock_fn = _XInitDisplayLock;
- _XFreeDisplayLock_fn = _XFreeDisplayLock;
- _Xthread_self_fn = _Xthread_self;
-
-#ifdef XTHREADS_WARN
-#ifdef XTHREADS_DEBUG
- setlinebuf(stdout); /* for debugging messages */
-#endif
-#endif
-
- return 1;
-}
-
-#else /* XTHREADS */
-Status XInitThreads(void)
-{
- return 0;
-}
-#endif /* XTHREADS */
+/*
+
+Copyright 1992, 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.
+
+*/
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * locking.c - multi-thread locking routines implemented in C Threads
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+#undef _XLockMutex
+#undef _XUnlockMutex
+#undef _XCreateMutex
+#undef _XFreeMutex
+
+#ifdef XTHREADS
+
+#ifdef __UNIXWARE__
+#include <dlfcn.h>
+#endif
+
+#include "Xprivate.h"
+#include "locking.h"
+#ifdef XTHREADS_WARN
+#include <stdio.h> /* for warn/debug stuff */
+#endif
+
+/* Additional arguments for source code location lock call was made from */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+# define XTHREADS_FILE_LINE_ARGS \
+ , \
+ char* file, /* source file, from macro */ \
+ int line
+#else
+# define XTHREADS_FILE_LINE_ARGS /* None */
+#endif
+
+
+#define NUM_FREE_CVLS 4
+
+/* in lcWrap.c */
+extern LockInfoPtr _Xi18n_lock;
+
+#ifdef WIN32
+static DWORD _X_TlsIndex = (DWORD)-1;
+
+void _Xthread_init(void)
+{
+ if (_X_TlsIndex == (DWORD)-1)
+ _X_TlsIndex = TlsAlloc();
+}
+
+struct _xthread_waiter *
+_Xthread_waiter(void)
+{
+ struct _xthread_waiter *me;
+
+ if (!(me = TlsGetValue(_X_TlsIndex))) {
+ me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter));
+ me->sem = CreateSemaphore(NULL, 0, 1, NULL);
+ me->next = NULL;
+ TlsSetValue(_X_TlsIndex, me);
+ }
+ return me;
+}
+#endif /* WIN32 */
+
+static xthread_t _Xthread_self(void)
+{
+ return xthread_self();
+}
+
+static LockInfoRec global_lock;
+static LockInfoRec i18n_lock;
+
+static void _XLockMutex(
+ LockInfoPtr lip
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+ xmutex_lock(lip->lock);
+}
+
+static void _XUnlockMutex(
+ LockInfoPtr lip
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+ xmutex_unlock(lip->lock);
+}
+
+static void _XCreateMutex(
+ LockInfoPtr lip)
+{
+ lip->lock = xmutex_malloc();
+ if (lip->lock) {
+ xmutex_init(lip->lock);
+ xmutex_set_name(lip->lock, "Xlib");
+ }
+}
+
+static void _XFreeMutex(
+ LockInfoPtr lip)
+{
+ xmutex_clear(lip->lock);
+ xmutex_free(lip->lock);
+}
+
+#ifdef XTHREADS_WARN
+static char *locking_file;
+static int locking_line;
+static xthread_t locking_thread;
+static Bool xlibint_unlock = False; /* XlibInt.c may Unlock and re-Lock */
+
+/* history that is useful to examine in a debugger */
+#define LOCK_HIST_SIZE 21
+
+static struct {
+ Bool lockp; /* True for lock, False for unlock */
+ xthread_t thread;
+ char *file;
+ int line;
+} locking_history[LOCK_HIST_SIZE];
+
+int lock_hist_loc = 0; /* next slot to fill */
+
+static void _XLockDisplayWarn(
+ Display *dpy,
+ char *file, /* source file, from macro */
+ int line)
+{
+ xthread_t self;
+ xthread_t old_locker;
+
+ self = xthread_self();
+ old_locker = locking_thread;
+ if (xthread_have_id(old_locker)) {
+ if (xthread_equal(old_locker, self))
+ printf("Xlib ERROR: %s line %d thread %x: locking display already locked at %s line %d\n",
+ file, line, self, locking_file, locking_line);
+#ifdef XTHREADS_DEBUG
+ else
+ printf("%s line %d: thread %x waiting on lock held by %s line %d thread %x\n",
+ file, line, self,
+ locking_file, locking_line, old_locker);
+#endif /* XTHREADS_DEBUG */
+ }
+
+ xmutex_lock(dpy->lock->mutex);
+
+ if (strcmp(file, "XlibInt.c") == 0) {
+ if (!xlibint_unlock)
+ printf("Xlib ERROR: XlibInt.c line %d thread %x locking display it did not unlock\n",
+ line, self);
+ xlibint_unlock = False;
+ }
+
+#ifdef XTHREADS_DEBUG
+ /* if (old_locker && old_locker != self) */
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x got display lock\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ locking_thread = self;
+ if (strcmp(file, "XlibInt.c") != 0) {
+ locking_file = file;
+ locking_line = line;
+ }
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+}
+#endif /* XTHREADS_WARN */
+
+static void _XUnlockDisplay(
+ Display *dpy
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+
+#ifdef XTHREADS_DEBUG
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x unlocking display\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ if (!xthread_have_id(locking_thread))
+ printf("Xlib ERROR: %s line %d thread %x: unlocking display that is not locked\n",
+ file, line, self);
+ else if (strcmp(file, "XlibInt.c") == 0)
+ xlibint_unlock = True;
+#ifdef XTHREADS_DEBUG
+ else if (strcmp(file, locking_file) != 0)
+ /* not always an error because locking_file is not per-thread */
+ printf("%s line %d: unlocking display locked from %s line %d (probably okay)\n",
+ file, line, locking_file, locking_line);
+#endif /* XTHREADS_DEBUG */
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+ xmutex_unlock(dpy->lock->mutex);
+}
+
+
+static struct _XCVList *_XCreateCVL(
+ Display *dpy)
+{
+ struct _XCVList *cvl;
+
+ if ((cvl = dpy->lock->free_cvls) != NULL) {
+ dpy->lock->free_cvls = cvl->next;
+ dpy->lock->num_free_cvls--;
+ } else {
+ cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList));
+ if (!cvl)
+ return NULL;
+ cvl->cv = xcondition_malloc();
+ if (!cvl->cv) {
+ Xfree(cvl);
+ return NULL;
+ }
+ xcondition_init(cvl->cv);
+ xcondition_set_name(cvl->cv, "Xlib read queue");
+ }
+ cvl->next = NULL;
+ return cvl;
+}
+
+/* Put ourselves on the queue to read the connection.
+ Allocates and returns a queue element. */
+
+static struct _XCVList *
+_XPushReader(
+ Display *dpy,
+ struct _XCVList ***tail)
+{
+ struct _XCVList *cvl;
+
+ cvl = _XCreateCVL(dpy);
+#ifdef XTHREADS_DEBUG
+ printf("_XPushReader called in thread %x, pushing %x\n",
+ xthread_self(), cvl);
+#endif
+ **tail = cvl;
+ *tail = &cvl->next;
+ return cvl;
+}
+
+/* signal the next thread waiting to read the connection */
+
+static void _XPopReader(
+ Display *dpy,
+ struct _XCVList **list,
+ struct _XCVList ***tail)
+{
+ register struct _XCVList *front = *list;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XPopReader called in thread %x, popping %x\n",
+ xthread_self(), front);
+#endif
+
+ if (dpy->flags & XlibDisplayProcConni)
+ /* we never added ourself in the first place */
+ return;
+
+ if (front) { /* check "front" for paranoia */
+ *list = front->next;
+ if (*tail == &front->next) /* did we free the last elt? */
+ *tail = list;
+ if (dpy->lock->num_free_cvls < NUM_FREE_CVLS) {
+ front->next = dpy->lock->free_cvls;
+ dpy->lock->free_cvls = front;
+ dpy->lock->num_free_cvls++;
+ } else {
+ xcondition_clear(front->cv);
+ Xfree((char *)front->cv);
+ Xfree((char *)front);
+ }
+ }
+
+ /* signal new front after it is in place */
+ if ((dpy->lock->reply_first = (dpy->lock->reply_awaiters != NULL))) {
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ } else if (dpy->lock->event_awaiters) {
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+ }
+}
+
+static void _XConditionWait(
+ xcondition_t cv,
+ xmutex_t mutex
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+ char *old_file = locking_file;
+ int old_line = locking_line;
+
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x in condition wait\n", line, self);
+#endif
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+
+ xcondition_wait(cv, mutex);
+
+#ifdef XTHREADS_WARN
+ locking_thread = self;
+ locking_file = old_file;
+ locking_line = old_line;
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x was signaled\n", line, self);
+#endif /* XTHREADS_DEBUG */
+#endif /* XTHREADS_WARN */
+}
+
+static void _XConditionSignal(
+ xcondition_t cv
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is signalling\n", line, xthread_self());
+#endif
+#endif
+ xcondition_signal(cv);
+}
+
+
+static void _XConditionBroadcast(
+ xcondition_t cv
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is broadcasting\n", line, xthread_self());
+#endif
+#endif
+ xcondition_broadcast(cv);
+}
+
+
+static void _XFreeDisplayLock(
+ Display *dpy)
+{
+ struct _XCVList *cvl;
+
+ if (dpy->lock != NULL) {
+ if (dpy->lock->mutex != NULL) {
+ xmutex_clear(dpy->lock->mutex);
+ xmutex_free(dpy->lock->mutex);
+ }
+ if (dpy->lock->cv != NULL) {
+ xcondition_clear(dpy->lock->cv);
+ xcondition_free(dpy->lock->cv);
+ }
+ if (dpy->lock->writers != NULL) {
+ xcondition_clear(dpy->lock->writers);
+ xcondition_free(dpy->lock->writers);
+ }
+ while ((cvl = dpy->lock->free_cvls)) {
+ dpy->lock->free_cvls = cvl->next;
+ xcondition_clear(cvl->cv);
+ Xfree((char *)cvl->cv);
+ Xfree((char *)cvl);
+ }
+ Xfree((char *)dpy->lock);
+ dpy->lock = NULL;
+ }
+ if (dpy->lock_fns != NULL) {
+ Xfree((char *)dpy->lock_fns);
+ dpy->lock_fns = NULL;
+ }
+}
+
+/*
+ * wait for thread with user-level display lock to release it.
+ */
+
+static void _XDisplayLockWait(
+ Display *dpy)
+{
+ xthread_t self;
+
+ while (dpy->lock->locking_level > 0) {
+ self = xthread_self();
+ if (xthread_equal(dpy->lock->locking_thread, self))
+ break;
+ ConditionWait(dpy, dpy->lock->cv);
+ }
+}
+
+static void _XLockDisplay(
+ Display *dpy
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+ _XIDHandler(dpy);
+ _XSeqSyncFunction(dpy);
+}
+
+/*
+ * _XReply is allowed to exit from select/poll and clean up even if a
+ * user-level lock is in force, so it uses this instead of _XFancyLockDisplay.
+ */
+static void _XInternalLockDisplay(
+ Display *dpy,
+ Bool wskip
+ XTHREADS_FILE_LINE_ARGS
+ )
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (!wskip && dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+}
+
+static void _XUserLockDisplay(
+ register Display* dpy)
+{
+ if (++dpy->lock->locking_level == 1) {
+ dpy->lock->lock_wait = _XDisplayLockWait;
+ dpy->lock->locking_thread = xthread_self();
+ }
+}
+
+static
+void _XUserUnlockDisplay(
+ register Display* dpy)
+{
+ if (dpy->lock->locking_level > 0 && --dpy->lock->locking_level == 0) {
+ /* signal other threads that might be waiting in XLockDisplay */
+ ConditionBroadcast(dpy, dpy->lock->cv);
+ dpy->lock->lock_wait = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ }
+}
+
+/* returns 0 if initialized ok, -1 if unable to allocate
+ a mutex or other memory */
+
+static int _XInitDisplayLock(
+ Display *dpy)
+{
+ dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs));
+ if (dpy->lock_fns == NULL)
+ return -1;
+ dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo));
+ if (dpy->lock == NULL) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+ dpy->lock->cv = xcondition_malloc();
+ dpy->lock->mutex = xmutex_malloc();
+ dpy->lock->writers = xcondition_malloc();
+ if (!dpy->lock->cv || !dpy->lock->mutex || !dpy->lock->writers) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+
+ dpy->lock->reply_bytes_left = 0;
+ dpy->lock->reply_was_read = False;
+ dpy->lock->reply_awaiters = NULL;
+ dpy->lock->reply_awaiters_tail = &dpy->lock->reply_awaiters;
+ dpy->lock->event_awaiters = NULL;
+ dpy->lock->event_awaiters_tail = &dpy->lock->event_awaiters;
+ dpy->lock->reply_first = False;
+ dpy->lock->locking_level = 0;
+ dpy->lock->num_free_cvls = 0;
+ dpy->lock->free_cvls = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ xthread_clear_id(dpy->lock->reading_thread);
+ xthread_clear_id(dpy->lock->conni_thread);
+ xmutex_init(dpy->lock->mutex);
+ xmutex_set_name(dpy->lock->mutex, "Xlib Display");
+ xcondition_init(dpy->lock->cv);
+ xcondition_set_name(dpy->lock->cv, "XLockDisplay");
+ xcondition_init(dpy->lock->writers);
+ xcondition_set_name(dpy->lock->writers, "Xlib wait for writable");
+ dpy->lock_fns->lock_display = _XLockDisplay;
+ dpy->lock->internal_lock_display = _XInternalLockDisplay;
+ dpy->lock_fns->unlock_display = _XUnlockDisplay;
+ dpy->lock->user_lock_display = _XUserLockDisplay;
+ dpy->lock->user_unlock_display = _XUserUnlockDisplay;
+ dpy->lock->pop_reader = _XPopReader;
+ dpy->lock->push_reader = _XPushReader;
+ dpy->lock->condition_wait = _XConditionWait;
+ dpy->lock->condition_signal = _XConditionSignal;
+ dpy->lock->condition_broadcast = _XConditionBroadcast;
+ dpy->lock->create_cvl = _XCreateCVL;
+ dpy->lock->lock_wait = NULL; /* filled in by XLockDisplay() */
+
+ return 0;
+}
+
+#ifdef __UNIXWARE__
+xthread_t __x11_thr_self() { return 0; }
+xthread_t (*_x11_thr_self)() = __x11_thr_self;
+#endif
+
+
+Status XInitThreads(void)
+{
+ if (_Xglobal_lock)
+ return 1;
+#ifdef __UNIXWARE__
+ else {
+ void *dl_handle = dlopen(NULL, RTLD_LAZY);
+ if (!dl_handle ||
+ ((_x11_thr_self = (xthread_t(*)())dlsym(dl_handle,"thr_self")) == 0)) {
+ _x11_thr_self = __x11_thr_self;
+ (void) fprintf (stderr,
+ "XInitThreads called, but no libthread in the calling program!\n" );
+ }
+ }
+#endif /* __UNIXWARE__ */
+#ifdef xthread_init
+ xthread_init(); /* return value? */
+#endif
+ if (!(global_lock.lock = xmutex_malloc()))
+ return 0;
+ if (!(i18n_lock.lock = xmutex_malloc())) {
+ xmutex_free(global_lock.lock);
+ global_lock.lock = NULL;
+ return 0;
+ }
+ _Xglobal_lock = &global_lock;
+ xmutex_init(_Xglobal_lock->lock);
+ xmutex_set_name(_Xglobal_lock->lock, "Xlib global");
+ _Xi18n_lock = &i18n_lock;
+ xmutex_init(_Xi18n_lock->lock);
+ xmutex_set_name(_Xi18n_lock->lock, "Xlib i18n");
+ _XLockMutex_fn = _XLockMutex;
+ _XUnlockMutex_fn = _XUnlockMutex;
+ _XCreateMutex_fn = _XCreateMutex;
+ _XFreeMutex_fn = _XFreeMutex;
+ _XInitDisplayLock_fn = _XInitDisplayLock;
+ _XFreeDisplayLock_fn = _XFreeDisplayLock;
+ _Xthread_self_fn = _Xthread_self;
+
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ setlinebuf(stdout); /* for debugging messages */
+#endif
+#endif
+
+ return 1;
+}
+
+#else /* XTHREADS */
+Status XInitThreads(void)
+{
+ return 0;
+}
+#endif /* XTHREADS */
diff --git a/libX11/src/util/Makefile.am b/libX11/src/util/Makefile.am
index 7fc8da5c4..c0d4e7fe9 100644
--- a/libX11/src/util/Makefile.am
+++ b/libX11/src/util/Makefile.am
@@ -1,19 +1,21 @@
-
-noinst_PROGRAMS=makekeys
-
-makekeys_CFLAGS=$(X11_CFLAGS)
-
-CC = @CC_FOR_BUILD@
-
-EXTRA_DIST = mkks.sh
-
-if LINT
-# Check source code with tools like lint & sparse
-
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-lint:
- $(LINT) $(ALL_LINT_FLAGS) makekeys.c
-
-endif LINT
+
+noinst_PROGRAMS=makekeys
+
+makekeys_CFLAGS = \
+ $(X11_CFLAGS) \
+ $(CWARNFLAGS)
+
+CC = @CC_FOR_BUILD@
+
+EXTRA_DIST = mkks.sh
+
+if LINT
+# Check source code with tools like lint & sparse
+
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) makekeys.c
+
+endif LINT
diff --git a/libX11/src/util/Makefile.in b/libX11/src/util/Makefile.in
deleted file mode 100644
index 6fee791b5..000000000
--- a/libX11/src/util/Makefile.in
+++ /dev/null
@@ -1,565 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-noinst_PROGRAMS = makekeys$(EXEEXT)
-subdir = src/util
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h \
- $(top_builddir)/include/X11/XlibConf.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-PROGRAMS = $(noinst_PROGRAMS)
-makekeys_SOURCES = makekeys.c
-makekeys_OBJECTS = makekeys-makekeys.$(OBJEXT)
-makekeys_LDADD = $(LDADD)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-makekeys_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(makekeys_CFLAGS) \
- $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = makekeys.c
-DIST_SOURCES = makekeys.c
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
-ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APP_MAN_DIR = @APP_MAN_DIR@
-APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BIGFONT_CFLAGS = @BIGFONT_CFLAGS@
-BIGFONT_LIBS = @BIGFONT_LIBS@
-CC = @CC_FOR_BUILD@
-CCDEPMODE = @CCDEPMODE@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CHANGELOG_CMD = @CHANGELOG_CMD@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CWARNFLAGS = @CWARNFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DOLT_BASH = @DOLT_BASH@
-DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
-DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FILE_MAN_DIR = @FILE_MAN_DIR@
-FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
-GREP = @GREP@
-GROFF = @GROFF@
-I18N_MODULE_LIBS = @I18N_MODULE_LIBS@
-INSTALL = @INSTALL@
-INSTALL_CMD = @INSTALL_CMD@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-KEYSYMDEF = @KEYSYMDEF@
-LAUNCHD = @LAUNCHD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIB_MAN_DIR = @LIB_MAN_DIR@
-LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINT = @LINT@
-LINTLIB = @LINTLIB@
-LINT_FLAGS = @LINT_FLAGS@
-LN_S = @LN_S@
-LTCOMPILE = @LTCOMPILE@
-LTCXXCOMPILE = @LTCXXCOMPILE@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@
-MISC_MAN_DIR = @MISC_MAN_DIR@
-MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
-MKDIR_P = @MKDIR_P@
-NMEDIT = @NMEDIT@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PKG_CONFIG = @PKG_CONFIG@
-PS2PDF = @PS2PDF@
-RANLIB = @RANLIB@
-RAWCPP = @RAWCPP@
-RAWCPPFLAGS = @RAWCPPFLAGS@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WCHAR32 = @WCHAR32@
-X11_CFLAGS = @X11_CFLAGS@
-X11_DATADIR = @X11_DATADIR@
-X11_EXTRA_DEPS = @X11_EXTRA_DEPS@
-X11_LIBDIR = @X11_LIBDIR@
-X11_LIBS = @X11_LIBS@
-X11_LOCALEDATADIR = @X11_LOCALEDATADIR@
-X11_LOCALEDIR = @X11_LOCALEDIR@
-X11_LOCALELIBDIR = @X11_LOCALELIBDIR@
-XDMCP_CFLAGS = @XDMCP_CFLAGS@
-XDMCP_LIBS = @XDMCP_LIBS@
-XERRORDB = @XERRORDB@
-XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@
-XKEYSYMDB = @XKEYSYMDB@
-XLOCALEDATADIR = @XLOCALEDATADIR@
-XLOCALEDIR = @XLOCALEDIR@
-XLOCALELIBDIR = @XLOCALELIBDIR@
-XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@
-XTHREADLIB = @XTHREADLIB@
-XTHREAD_CFLAGS = @XTHREAD_CFLAGS@
-XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-makekeys_CFLAGS = $(X11_CFLAGS)
-EXTRA_DIST = mkks.sh
-
-# Check source code with tools like lint & sparse
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/util/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/util/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstPROGRAMS:
- @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
- echo " rm -f" $$list; \
- rm -f $$list || exit $$?; \
- test -n "$(EXEEXT)" || exit 0; \
- list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f" $$list; \
- rm -f $$list
-makekeys$(EXEEXT): $(makekeys_OBJECTS) $(makekeys_DEPENDENCIES)
- @rm -f makekeys$(EXEEXT)
- $(AM_V_CCLD)$(makekeys_LINK) $(makekeys_OBJECTS) $(makekeys_LDADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/makekeys-makekeys.Po@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-makekeys-makekeys.o: makekeys.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(makekeys_CFLAGS) $(CFLAGS) -MT makekeys-makekeys.o -MD -MP -MF $(DEPDIR)/makekeys-makekeys.Tpo -c -o makekeys-makekeys.o `test -f 'makekeys.c' || echo '$(srcdir)/'`makekeys.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/makekeys-makekeys.Tpo $(DEPDIR)/makekeys-makekeys.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='makekeys.c' object='makekeys-makekeys.o' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(makekeys_CFLAGS) $(CFLAGS) -c -o makekeys-makekeys.o `test -f 'makekeys.c' || echo '$(srcdir)/'`makekeys.c
-
-makekeys-makekeys.obj: makekeys.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(makekeys_CFLAGS) $(CFLAGS) -MT makekeys-makekeys.obj -MD -MP -MF $(DEPDIR)/makekeys-makekeys.Tpo -c -o makekeys-makekeys.obj `if test -f 'makekeys.c'; then $(CYGPATH_W) 'makekeys.c'; else $(CYGPATH_W) '$(srcdir)/makekeys.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/makekeys-makekeys.Tpo $(DEPDIR)/makekeys-makekeys.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='makekeys.c' object='makekeys-makekeys.obj' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(makekeys_CFLAGS) $(CFLAGS) -c -o makekeys-makekeys.obj `if test -f 'makekeys.c'; then $(CYGPATH_W) 'makekeys.c'; else $(CYGPATH_W) '$(srcdir)/makekeys.c'; fi`
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(PROGRAMS)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstPROGRAMS ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am
-
-
-@LINT_TRUE@lint:
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) makekeys.c
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/libX11/src/xcb_disp.c b/libX11/src/xcb_disp.c
index 2625966da..2def9b014 100644
--- a/libX11/src/xcb_disp.c
+++ b/libX11/src/xcb_disp.c
@@ -1,120 +1,122 @@
-/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
- * This file is licensed under the MIT license. See the file COPYING. */
-
-#include "Xlibint.h"
-#include "Xxcbint.h"
-#include <xcb/xcbext.h>
-#include <X11/Xatom.h>
-#include <X11/Xresource.h>
-#include <stdio.h>
-
-static xcb_auth_info_t xauth;
-
-static void *alloc_copy(const void *src, int *dstn, size_t n)
-{
- void *dst;
- if(n <= 0)
- {
- *dstn = 0;
- return NULL;
- }
- dst = Xmalloc(n);
- if(!dst)
- return NULL;
- memcpy(dst, src, n);
- *dstn = n;
- return dst;
-}
-
-void XSetAuthorization(char *name, int namelen, char *data, int datalen)
-{
- _XLockMutex(_Xglobal_lock);
- Xfree(xauth.name);
- Xfree(xauth.data);
-
- /* if either of these allocs fail, _XConnectXCB won't use this auth
- * data, so we don't need to check it here. */
- xauth.name = alloc_copy(name, &xauth.namelen, namelen);
- xauth.data = alloc_copy(data, &xauth.datalen, datalen);
-
-#if 0 /* but, for the paranoid among us: */
- if((namelen > 0 && !xauth.name) || (datalen > 0 && !xauth.data))
- {
- Xfree(xauth.name);
- Xfree(xauth.data);
- xauth.name = xauth.data = 0;
- xauth.namelen = xauth.datalen = 0;
- }
-#endif
-
- _XUnlockMutex(_Xglobal_lock);
-}
-
-int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp)
-{
- char *host;
- int n = 0;
- int len;
- xcb_connection_t *c;
-
- dpy->fd = -1;
-
- dpy->xcb = Xcalloc(1, sizeof(_X11XCBPrivate));
- if(!dpy->xcb)
- return 0;
-
-#ifdef HAVE_LAUNCHD
- if(!display || !*display) display = getenv("DISPLAY");
-
- if(display && strlen(display)>11 && !strncmp(display, "/tmp/launch", 11)) {
- /* do nothing -- the magic happens inside of xcb_connect */
- } else
-#endif
- {
- if(!xcb_parse_display(display, &host, &n, screenp))
- return 0;
-
- len = strlen(host) + (1 + 20 + 1 + 20 + 1);
- *fullnamep = Xmalloc(len);
- if (!*fullnamep) {
- free(host);
- return 0;
- }
-
- snprintf(*fullnamep, len, "%s:%d.%d", host, n, *screenp);
- free(host);
- }
-
- _XLockMutex(_Xglobal_lock);
- if(xauth.name && xauth.data)
- c = xcb_connect_to_display_with_auth_info(display, &xauth, NULL);
- else
- c = xcb_connect(display, NULL);
- _XUnlockMutex(_Xglobal_lock);
-
- dpy->fd = xcb_get_file_descriptor(c);
-
- dpy->xcb->connection = c;
- dpy->xcb->pending_requests_tail = &dpy->xcb->pending_requests;
- dpy->xcb->next_xid = xcb_generate_id(dpy->xcb->connection);
-
- dpy->xcb->event_notify = xcondition_malloc();
- if (!dpy->xcb->event_notify)
- return 0;
- xcondition_init(dpy->xcb->event_notify);
- return !xcb_connection_has_error(c);
-}
-
-void _XFreeX11XCBStructure(Display *dpy)
-{
- /* reply_data was allocated by system malloc, not Xmalloc */
- free(dpy->xcb->reply_data);
- while(dpy->xcb->pending_requests)
- {
- PendingRequest *tmp = dpy->xcb->pending_requests;
- dpy->xcb->pending_requests = tmp->next;
- free(tmp);
- }
- xcondition_free(dpy->xcb->event_notify);
- Xfree(dpy->xcb);
-}
+/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
+ * This file is licensed under the MIT license. See the file COPYING. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Xlibint.h"
+#include "Xxcbint.h"
+#include <xcb/xcbext.h>
+#include <X11/Xatom.h>
+#include <X11/Xresource.h>
+#include <stdio.h>
+
+static xcb_auth_info_t xauth;
+
+static void *alloc_copy(const void *src, int *dstn, size_t n)
+{
+ void *dst;
+ if(n <= 0)
+ {
+ *dstn = 0;
+ return NULL;
+ }
+ dst = Xmalloc(n);
+ if(!dst)
+ return NULL;
+ memcpy(dst, src, n);
+ *dstn = n;
+ return dst;
+}
+
+void XSetAuthorization(char *name, int namelen, char *data, int datalen)
+{
+ _XLockMutex(_Xglobal_lock);
+ Xfree(xauth.name);
+ Xfree(xauth.data);
+
+ /* if either of these allocs fail, _XConnectXCB won't use this auth
+ * data, so we don't need to check it here. */
+ xauth.name = alloc_copy(name, &xauth.namelen, namelen);
+ xauth.data = alloc_copy(data, &xauth.datalen, datalen);
+
+#if 0 /* but, for the paranoid among us: */
+ if((namelen > 0 && !xauth.name) || (datalen > 0 && !xauth.data))
+ {
+ Xfree(xauth.name);
+ Xfree(xauth.data);
+ xauth.name = xauth.data = 0;
+ xauth.namelen = xauth.datalen = 0;
+ }
+#endif
+
+ _XUnlockMutex(_Xglobal_lock);
+}
+
+int _XConnectXCB(Display *dpy, _Xconst char *display, char **fullnamep, int *screenp)
+{
+ char *host;
+ int n = 0;
+ int len;
+ xcb_connection_t *c;
+
+ dpy->fd = -1;
+
+ dpy->xcb = Xcalloc(1, sizeof(_X11XCBPrivate));
+ if(!dpy->xcb)
+ return 0;
+
+ if(!xcb_parse_display(display, &host, &n, screenp))
+ return 0;
+
+ len = strlen(host) + (1 + 20 + 1 + 20 + 1);
+ *fullnamep = Xmalloc(len);
+ if (!*fullnamep) {
+ free(host);
+ return 0;
+ }
+
+#ifdef HAVE_LAUNCHD
+ if(strncmp(host, "/tmp/launch", 11) == 0)
+ snprintf(*fullnamep, len, "%s:%d", host, n);
+ else
+#endif
+ snprintf(*fullnamep, len, "%s:%d.%d", host, n, *screenp);
+ free(host);
+
+ _XLockMutex(_Xglobal_lock);
+ if(xauth.name && xauth.data)
+ c = xcb_connect_to_display_with_auth_info(display, &xauth, NULL);
+ else
+ c = xcb_connect(display, NULL);
+ _XUnlockMutex(_Xglobal_lock);
+
+ dpy->fd = xcb_get_file_descriptor(c);
+
+ dpy->xcb->connection = c;
+ dpy->xcb->next_xid = xcb_generate_id(dpy->xcb->connection);
+
+ dpy->xcb->event_notify = xcondition_malloc();
+ dpy->xcb->reply_notify = xcondition_malloc();
+ if (!dpy->xcb->event_notify || !dpy->xcb->reply_notify)
+ return 0;
+ xcondition_init(dpy->xcb->event_notify);
+ xcondition_init(dpy->xcb->reply_notify);
+ return !xcb_connection_has_error(c);
+}
+
+void _XFreeX11XCBStructure(Display *dpy)
+{
+ /* reply_data was allocated by system malloc, not Xmalloc */
+ free(dpy->xcb->reply_data);
+ while(dpy->xcb->pending_requests)
+ {
+ PendingRequest *tmp = dpy->xcb->pending_requests;
+ dpy->xcb->pending_requests = tmp->next;
+ free(tmp);
+ }
+ xcondition_free(dpy->xcb->event_notify);
+ xcondition_free(dpy->xcb->reply_notify);
+ Xfree(dpy->xcb);
+}
diff --git a/libX11/src/xcb_io.c b/libX11/src/xcb_io.c
index aa10f6657..3733e1521 100644
--- a/libX11/src/xcb_io.c
+++ b/libX11/src/xcb_io.c
@@ -1,577 +1,684 @@
-/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
- * This file is licensed under the MIT license. See the file COPYING. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "Xlibint.h"
-#include "locking.h"
-#include "Xprivate.h"
-#include "Xxcbint.h"
-#include <xcb/xcbext.h>
-
-#include <assert.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif
-#include <sys/time.h>
-
-#include <X11/Xtrans/Xtrans.h>
-
-static void return_socket(void *closure)
-{
- Display *dpy = closure;
- LockDisplay(dpy);
- _XSend(dpy, NULL, 0);
- dpy->bufmax = dpy->buffer;
- UnlockDisplay(dpy);
-}
-
-static void require_socket(Display *dpy)
-{
- if(dpy->bufmax == dpy->buffer)
- {
- uint64_t sent;
- int flags = 0;
- /* if we don't own the event queue, we have to ask XCB
- * to set our errors aside for us. */
- if(dpy->xcb->event_owner != XlibOwnsEventQueue)
- flags = XCB_REQUEST_CHECKED;
- if(!xcb_take_socket(dpy->xcb->connection, return_socket, dpy,
- flags, &sent))
- _XIOError(dpy);
- /* Xlib uses unsigned long for sequence numbers. XCB
- * uses 64-bit internally, but currently exposes an
- * unsigned int API. If these differ, Xlib cannot track
- * the full 64-bit sequence number if 32-bit wrap
- * happens while Xlib does not own the socket. A
- * complete fix would be to make XCB's public API use
- * 64-bit sequence numbers. */
- assert(!(sizeof(unsigned long) > sizeof(unsigned int)
- && dpy->xcb->event_owner == XlibOwnsEventQueue
- && (sent - dpy->last_request_read >= (UINT64_C(1) << 32))));
- dpy->xcb->last_flushed = dpy->request = sent;
- dpy->bufmax = dpy->xcb->real_bufmax;
- }
-}
-
-/* Call internal connection callbacks for any fds that are currently
- * ready to read. This function will not block unless one of the
- * callbacks blocks.
- *
- * This code borrowed from _XWaitForReadable. Inverse call tree:
- * _XRead
- * _XWaitForWritable
- * _XFlush
- * _XSend
- * _XEventsQueued
- * _XReadEvents
- * _XRead[0-9]+
- * _XAllocIDs
- * _XReply
- * _XEatData
- * _XReadPad
- */
-static void check_internal_connections(Display *dpy)
-{
- struct _XConnectionInfo *ilist;
- fd_set r_mask;
- struct timeval tv;
- int result;
- int highest_fd = -1;
-
- if(dpy->flags & XlibDisplayProcConni || !dpy->im_fd_info)
- return;
-
- FD_ZERO(&r_mask);
- for(ilist = dpy->im_fd_info; ilist; ilist = ilist->next)
- {
- assert(ilist->fd >= 0);
- FD_SET(ilist->fd, &r_mask);
- if(ilist->fd > highest_fd)
- highest_fd = ilist->fd;
- }
- assert(highest_fd >= 0);
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- result = select(highest_fd + 1, &r_mask, NULL, NULL, &tv);
-
- if(result == -1)
- {
- if(errno == EINTR)
- return;
- _XIOError(dpy);
- }
-
- for(ilist = dpy->im_fd_info; result && ilist; ilist = ilist->next)
- if(FD_ISSET(ilist->fd, &r_mask))
- {
- _XProcessInternalConnection(dpy, ilist);
- --result;
- }
-}
-
-static void call_handlers(Display *dpy, xcb_generic_reply_t *buf)
-{
- _XAsyncHandler *async, *next;
- for(async = dpy->async_handlers; async; async = next)
- {
- next = async->next;
- if(async->handler(dpy, (xReply *) buf, (char *) buf, sizeof(xReply) + (buf->length << 2), async->data))
- return;
- }
- if(buf->response_type == 0) /* unhandled error */
- _XError(dpy, (xError *) buf);
-}
-
-static xcb_generic_event_t * wait_or_poll_for_event(Display *dpy, int wait)
-{
- xcb_connection_t *c = dpy->xcb->connection;
- xcb_generic_event_t *event;
- if(wait)
- {
- if(dpy->xcb->event_waiter)
- {
- ConditionWait(dpy, dpy->xcb->event_notify);
- event = xcb_poll_for_event(c);
- }
- else
- {
- dpy->xcb->event_waiter = 1;
- UnlockDisplay(dpy);
- event = xcb_wait_for_event(c);
- LockDisplay(dpy);
- dpy->xcb->event_waiter = 0;
- ConditionBroadcast(dpy, dpy->xcb->event_notify);
- }
- }
- else
- event = xcb_poll_for_event(c);
- return event;
-}
-
-/* Widen a 32-bit sequence number into a native-word-size (unsigned long)
- * sequence number. Treating the comparison as a 1 and shifting it avoids a
- * conditional branch, and shifting by 16 twice avoids a compiler warning when
- * sizeof(unsigned long) == 4. */
-static void widen(unsigned long *wide, unsigned int narrow)
-{
- unsigned long new = (*wide & ~0xFFFFFFFFUL) | narrow;
- *wide = new + ((unsigned long) (new < *wide) << 16 << 16);
-}
-
-static void process_responses(Display *dpy, int wait_for_first_event, xcb_generic_error_t **current_error, unsigned long current_request)
-{
- void *reply;
- xcb_generic_event_t *event = dpy->xcb->next_event;
- xcb_generic_error_t *error;
- xcb_connection_t *c = dpy->xcb->connection;
- if(!event && dpy->xcb->event_owner == XlibOwnsEventQueue)
- event = wait_or_poll_for_event(dpy, wait_for_first_event);
-
- require_socket(dpy);
-
- while(1)
- {
- PendingRequest *req = dpy->xcb->pending_requests;
- unsigned long event_sequence = dpy->last_request_read;
- if(event)
- widen(&event_sequence, event->full_sequence);
- assert(!(req && current_request && !XLIB_SEQUENCE_COMPARE(req->sequence, <=, current_request)));
- if(event && (!req || XLIB_SEQUENCE_COMPARE(event_sequence, <=, req->sequence)))
- {
- dpy->last_request_read = event_sequence;
- if(event->response_type != X_Error)
- {
- /* GenericEvents may be > 32 bytes. In this
- * case, the event struct is trailed by the
- * additional bytes. the xcb_generic_event_t
- * struct uses 4 bytes for internal numbering,
- * so we need to shift the trailing data to be
- * after the first 32 bytes. */
- if (event->response_type == GenericEvent &&
- ((xcb_ge_event_t*)event)->length)
- {
- memmove(&event->full_sequence,
- &event[1],
- ((xcb_ge_event_t*)event)->length * 4);
- }
- _XEnq(dpy, (xEvent *) event);
- wait_for_first_event = 0;
- }
- else if(current_error && event_sequence == current_request)
- {
- /* This can only occur when called from
- * _XReply, which doesn't need a new event. */
- *current_error = (xcb_generic_error_t *) event;
- event = NULL;
- break;
- }
- else
- _XError(dpy, (xError *) event);
- free(event);
- event = wait_or_poll_for_event(dpy, wait_for_first_event);
- }
- else if(req && req->sequence == current_request)
- {
- break;
- }
- else if(req && xcb_poll_for_reply(dpy->xcb->connection, req->sequence, &reply, &error))
- {
- uint64_t sequence = req->sequence;
- if(!reply)
- {
- dpy->xcb->pending_requests = req->next;
- if(!dpy->xcb->pending_requests)
- dpy->xcb->pending_requests_tail = &dpy->xcb->pending_requests;
- free(req);
- reply = error;
- }
- if(reply)
- {
- dpy->last_request_read = sequence;
- call_handlers(dpy, reply);
- free(reply);
- }
- }
- else
- break;
- }
-
- dpy->xcb->next_event = event;
-
- if(xcb_connection_has_error(c))
- _XIOError(dpy);
-
- assert(XLIB_SEQUENCE_COMPARE(dpy->last_request_read, <=, dpy->request));
-}
-
-int _XEventsQueued(Display *dpy, int mode)
-{
- if(dpy->flags & XlibDisplayIOError)
- return 0;
- if(dpy->xcb->event_owner != XlibOwnsEventQueue)
- return 0;
-
- if(mode == QueuedAfterFlush)
- _XSend(dpy, NULL, 0);
- else
- check_internal_connections(dpy);
- process_responses(dpy, 0, NULL, 0);
- return dpy->qlen;
-}
-
-/* _XReadEvents - Flush the output queue,
- * then read as many events as possible (but at least 1) and enqueue them
- */
-void _XReadEvents(Display *dpy)
-{
- if(dpy->flags & XlibDisplayIOError)
- return;
- _XSend(dpy, NULL, 0);
- if(dpy->xcb->event_owner != XlibOwnsEventQueue)
- return;
- check_internal_connections(dpy);
- do {
- process_responses(dpy, 1, NULL, 0);
- } while (dpy->qlen == 0);
-}
-
-/*
- * _XSend - Flush the buffer and send the client data. 32 bit word aligned
- * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
- *
- * Note that the connection must not be read from once the data currently
- * in the buffer has been written.
- */
-void _XSend(Display *dpy, const char *data, long size)
-{
- static const xReq dummy_request;
- static char const pad[3];
- struct iovec vec[3];
- uint64_t requests;
- _XExtension *ext;
- xcb_connection_t *c = dpy->xcb->connection;
- if(dpy->flags & XlibDisplayIOError)
- return;
-
- if(dpy->bufptr == dpy->buffer && !size)
- return;
-
- /* iff we asked XCB to set aside errors, we must pick those up
- * eventually. iff there are async handlers, we may have just
- * issued requests that will generate replies. in either case,
- * we need to remember to check later. */
- if(dpy->xcb->event_owner != XlibOwnsEventQueue || dpy->async_handlers)
- {
- uint64_t sequence;
- for(sequence = dpy->xcb->last_flushed; sequence < dpy->request; ++sequence)
- {
- PendingRequest *req = malloc(sizeof(PendingRequest));
- assert(req);
- req->next = NULL;
- req->sequence = sequence;
- *dpy->xcb->pending_requests_tail = req;
- dpy->xcb->pending_requests_tail = &req->next;
- }
- }
- requests = dpy->request - dpy->xcb->last_flushed;
- dpy->xcb->last_flushed = dpy->request;
-
- vec[0].iov_base = dpy->buffer;
- vec[0].iov_len = dpy->bufptr - dpy->buffer;
- vec[1].iov_base = (caddr_t) data;
- vec[1].iov_len = size;
- vec[2].iov_base = (caddr_t) pad;
- vec[2].iov_len = -size & 3;
-
- for(ext = dpy->flushes; ext; ext = ext->next_flush)
- {
- int i;
- for(i = 0; i < 3; ++i)
- if(vec[i].iov_len)
- ext->before_flush(dpy, &ext->codes, vec[i].iov_base, vec[i].iov_len);
- }
-
- if(xcb_writev(c, vec, 3, requests) < 0)
- _XIOError(dpy);
- dpy->bufptr = dpy->buffer;
- dpy->last_req = (char *) &dummy_request;
-
- check_internal_connections(dpy);
-
- _XSetSeqSyncFunction(dpy);
-}
-
-/*
- * _XFlush - Flush the X request buffer. If the buffer is empty, no
- * action is taken.
- */
-void _XFlush(Display *dpy)
-{
- require_socket(dpy);
- _XSend(dpy, NULL, 0);
-
- _XEventsQueued(dpy, QueuedAfterReading);
-}
-
-static const XID inval_id = ~0UL;
-
-int _XIDHandler(Display *dpy)
-{
- XID next;
-
- if (dpy->xcb->next_xid != inval_id)
- return 0;
-
- next = xcb_generate_id(dpy->xcb->connection);
- LockDisplay(dpy);
- dpy->xcb->next_xid = next;
-#ifdef XTHREADS
- if (dpy->lock)
- (*dpy->lock->user_unlock_display)(dpy);
-#endif
- UnlockDisplay(dpy);
- return 0;
-}
-
-/* _XAllocID - resource ID allocation routine. */
-XID _XAllocID(Display *dpy)
-{
- XID ret = dpy->xcb->next_xid;
- assert (ret != inval_id);
-#ifdef XTHREADS
- if (dpy->lock)
- (*dpy->lock->user_lock_display)(dpy);
-#endif
- dpy->xcb->next_xid = inval_id;
- _XSetPrivSyncFunction(dpy);
- return ret;
-}
-
-/* _XAllocIDs - multiple resource ID allocation routine. */
-void _XAllocIDs(Display *dpy, XID *ids, int count)
-{
- int i;
-#ifdef XTHREADS
- if (dpy->lock)
- (*dpy->lock->user_lock_display)(dpy);
- UnlockDisplay(dpy);
-#endif
- for (i = 0; i < count; i++)
- ids[i] = xcb_generate_id(dpy->xcb->connection);
-#ifdef XTHREADS
- LockDisplay(dpy);
- if (dpy->lock)
- (*dpy->lock->user_unlock_display)(dpy);
-#endif
-}
-
-static void _XFreeReplyData(Display *dpy, Bool force)
-{
- if(!force && dpy->xcb->reply_consumed < dpy->xcb->reply_length)
- return;
- free(dpy->xcb->reply_data);
- dpy->xcb->reply_data = NULL;
-}
-
-static PendingRequest * insert_pending_request(Display *dpy)
-{
- PendingRequest **cur = &dpy->xcb->pending_requests;
- while(*cur && XLIB_SEQUENCE_COMPARE((*cur)->sequence, <, dpy->request))
- cur = &((*cur)->next);
- if(!*cur || (*cur)->sequence != dpy->request)
- {
- PendingRequest *node = malloc(sizeof(PendingRequest));
- assert(node);
- node->next = *cur;
- node->sequence = dpy->request;
- if(cur == dpy->xcb->pending_requests_tail)
- dpy->xcb->pending_requests_tail = &(node->next);
- *cur = node;
- }
- return *cur;
-}
-
-/*
- * _XReply - Wait for a reply packet and copy its contents into the
- * specified rep.
- * extra: number of 32-bit words expected after the reply
- * discard: should I discard data following "extra" words?
- */
-Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
-{
- xcb_generic_error_t *error;
- xcb_connection_t *c = dpy->xcb->connection;
- char *reply;
- PendingRequest *current;
-
- assert(!dpy->xcb->reply_data);
-
- if(dpy->flags & XlibDisplayIOError)
- return 0;
-
- _XSend(dpy, NULL, 0);
- current = insert_pending_request(dpy);
- /* FIXME: drop the Display lock while waiting?
- * Complicates process_responses. */
- reply = xcb_wait_for_reply(c, current->sequence, &error);
-
- check_internal_connections(dpy);
- process_responses(dpy, 0, &error, current->sequence);
-
- if(error)
- {
- _XExtension *ext;
- xError *err = (xError *) error;
- int ret_code;
-
- dpy->last_request_read = error->full_sequence;
-
- /* Xlib is evil and assumes that even errors will be
- * copied into rep. */
- memcpy(rep, error, 32);
-
- /* do not die on "no such font", "can't allocate",
- "can't grab" failures */
- switch(err->errorCode)
- {
- case BadName:
- switch(err->majorCode)
- {
- case X_LookupColor:
- case X_AllocNamedColor:
- free(error);
- return 0;
- }
- break;
- case BadFont:
- if(err->majorCode == X_QueryFont) {
- free(error);
- return 0;
- }
- break;
- case BadAlloc:
- case BadAccess:
- free(error);
- return 0;
- }
-
- /*
- * we better see if there is an extension who may
- * want to suppress the error.
- */
- for(ext = dpy->ext_procs; ext; ext = ext->next)
- if(ext->error && ext->error(dpy, err, &ext->codes, &ret_code)) {
- free(error);
- return ret_code;
- }
-
- _XError(dpy, err);
- free(error);
- return 0;
- }
-
- /* it's not an error, but we don't have a reply, so it's an I/O
- * error. */
- if(!reply)
- {
- _XIOError(dpy);
- return 0;
- }
-
- dpy->last_request_read = current->sequence;
-
- /* there's no error and we have a reply. */
- dpy->xcb->reply_data = reply;
- dpy->xcb->reply_consumed = sizeof(xReply) + (extra * 4);
- dpy->xcb->reply_length = sizeof(xReply);
- if(dpy->xcb->reply_data[0] == 1)
- dpy->xcb->reply_length += (((xcb_generic_reply_t *) dpy->xcb->reply_data)->length * 4);
-
- /* error: Xlib asks too much. give them what we can anyway. */
- if(dpy->xcb->reply_length < dpy->xcb->reply_consumed)
- dpy->xcb->reply_consumed = dpy->xcb->reply_length;
-
- memcpy(rep, dpy->xcb->reply_data, dpy->xcb->reply_consumed);
- _XFreeReplyData(dpy, discard);
- return 1;
-}
-
-int _XRead(Display *dpy, char *data, long size)
-{
- assert(size >= 0);
- if(size == 0)
- return 0;
- assert(dpy->xcb->reply_data != NULL);
- assert(dpy->xcb->reply_consumed + size <= dpy->xcb->reply_length);
- memcpy(data, dpy->xcb->reply_data + dpy->xcb->reply_consumed, size);
- dpy->xcb->reply_consumed += size;
- _XFreeReplyData(dpy, False);
- return 0;
-}
-
-/*
- * _XReadPad - Read bytes from the socket taking into account incomplete
- * reads. If the number of bytes is not 0 mod 4, read additional pad
- * bytes.
- */
-void _XReadPad(Display *dpy, char *data, long size)
-{
- _XRead(dpy, data, size);
- dpy->xcb->reply_consumed += -size & 3;
- _XFreeReplyData(dpy, False);
-}
-
-/* Read and discard "n" 8-bit bytes of data */
-void _XEatData(Display *dpy, unsigned long n)
-{
- dpy->xcb->reply_consumed += n;
- _XFreeReplyData(dpy, False);
-}
+/* Copyright (C) 2003-2006 Jamey Sharp, Josh Triplett
+ * This file is licensed under the MIT license. See the file COPYING. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Xlibint.h"
+#include "locking.h"
+#include "Xprivate.h"
+#include "Xxcbint.h"
+#include <xcb/xcbext.h>
+
+#include <assert.h>
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif
+#include <sys/time.h>
+
+#include <X11/Xtrans/Xtrans.h>
+
+static void return_socket(void *closure)
+{
+ Display *dpy = closure;
+ InternalLockDisplay(dpy, /* don't skip user locks */ 0);
+ _XSend(dpy, NULL, 0);
+ dpy->bufmax = dpy->buffer;
+ UnlockDisplay(dpy);
+}
+
+static void require_socket(Display *dpy)
+{
+ if(dpy->bufmax == dpy->buffer)
+ {
+ uint64_t sent;
+ int flags = 0;
+ /* if we don't own the event queue, we have to ask XCB
+ * to set our errors aside for us. */
+ if(dpy->xcb->event_owner != XlibOwnsEventQueue)
+ flags = XCB_REQUEST_CHECKED;
+ if(!xcb_take_socket(dpy->xcb->connection, return_socket, dpy,
+ flags, &sent))
+ _XIOError(dpy);
+ /* Xlib uses unsigned long for sequence numbers. XCB
+ * uses 64-bit internally, but currently exposes an
+ * unsigned int API. If these differ, Xlib cannot track
+ * the full 64-bit sequence number if 32-bit wrap
+ * happens while Xlib does not own the socket. A
+ * complete fix would be to make XCB's public API use
+ * 64-bit sequence numbers. */
+ assert(!(sizeof(unsigned long) > sizeof(unsigned int)
+ && dpy->xcb->event_owner == XlibOwnsEventQueue
+ && (sent - dpy->last_request_read >= (UINT64_C(1) << 32))));
+ dpy->xcb->last_flushed = dpy->request = sent;
+ dpy->bufmax = dpy->xcb->real_bufmax;
+ }
+}
+
+/* Call internal connection callbacks for any fds that are currently
+ * ready to read. This function will not block unless one of the
+ * callbacks blocks.
+ *
+ * This code borrowed from _XWaitForReadable. Inverse call tree:
+ * _XRead
+ * _XWaitForWritable
+ * _XFlush
+ * _XSend
+ * _XEventsQueued
+ * _XReadEvents
+ * _XRead[0-9]+
+ * _XAllocIDs
+ * _XReply
+ * _XEatData
+ * _XReadPad
+ */
+static void check_internal_connections(Display *dpy)
+{
+ struct _XConnectionInfo *ilist;
+ fd_set r_mask;
+ struct timeval tv;
+ int result;
+ int highest_fd = -1;
+
+ if(dpy->flags & XlibDisplayProcConni || !dpy->im_fd_info)
+ return;
+
+ FD_ZERO(&r_mask);
+ for(ilist = dpy->im_fd_info; ilist; ilist = ilist->next)
+ {
+ assert(ilist->fd >= 0);
+ FD_SET(ilist->fd, &r_mask);
+ if(ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+ assert(highest_fd >= 0);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ result = select(highest_fd + 1, &r_mask, NULL, NULL, &tv);
+
+ if(result == -1)
+ {
+ if(errno == EINTR)
+ return;
+ _XIOError(dpy);
+ }
+
+ for(ilist = dpy->im_fd_info; result && ilist; ilist = ilist->next)
+ if(FD_ISSET(ilist->fd, &r_mask))
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ --result;
+ }
+}
+
+static PendingRequest *append_pending_request(Display *dpy, unsigned long sequence)
+{
+ PendingRequest *node = malloc(sizeof(PendingRequest));
+ assert(node);
+ node->next = NULL;
+ node->sequence = sequence;
+ node->reply_waiter = 0;
+ if(dpy->xcb->pending_requests_tail)
+ {
+ assert(XLIB_SEQUENCE_COMPARE(dpy->xcb->pending_requests_tail->sequence, <, node->sequence));
+ assert(dpy->xcb->pending_requests_tail->next == NULL);
+ dpy->xcb->pending_requests_tail->next = node;
+ }
+ else
+ dpy->xcb->pending_requests = node;
+ dpy->xcb->pending_requests_tail = node;
+ return node;
+}
+
+static void dequeue_pending_request(Display *dpy, PendingRequest *req)
+{
+ assert(req == dpy->xcb->pending_requests);
+ dpy->xcb->pending_requests = req->next;
+ if(!dpy->xcb->pending_requests)
+ {
+ assert(req == dpy->xcb->pending_requests_tail);
+ dpy->xcb->pending_requests_tail = NULL;
+ }
+ else
+ assert(XLIB_SEQUENCE_COMPARE(req->sequence, <, dpy->xcb->pending_requests->sequence));
+ free(req);
+}
+
+static int handle_error(Display *dpy, xError *err, Bool in_XReply)
+{
+ _XExtension *ext;
+ int ret_code;
+ /* Oddly, Xlib only allows extensions to suppress errors when
+ * those errors were seen by _XReply. */
+ if(in_XReply)
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for(ext = dpy->ext_procs; ext; ext = ext->next)
+ if(ext->error && (*ext->error)(dpy, err, &ext->codes, &ret_code))
+ return ret_code;
+ _XError(dpy, err);
+ return 0;
+}
+
+/* Widen a 32-bit sequence number into a native-word-size (unsigned long)
+ * sequence number. Treating the comparison as a 1 and shifting it avoids a
+ * conditional branch, and shifting by 16 twice avoids a compiler warning when
+ * sizeof(unsigned long) == 4. */
+static void widen(unsigned long *wide, unsigned int narrow)
+{
+ unsigned long new = (*wide & ~0xFFFFFFFFUL) | narrow;
+ *wide = new + ((unsigned long) (new < *wide) << 16 << 16);
+}
+
+/* Thread-safety rules:
+ *
+ * At most one thread can be reading from XCB's event queue at a time.
+ * If you are not the current event-reading thread and you need to find
+ * out if an event is available, you must wait.
+ *
+ * The same rule applies for reading replies.
+ *
+ * A single thread cannot be both the the event-reading and the
+ * reply-reading thread at the same time.
+ *
+ * We always look at both the current event and the first pending reply
+ * to decide which to process next.
+ *
+ * We always process all responses in sequence-number order, which may
+ * mean waiting for another thread (either the event_waiter or the
+ * reply_waiter) to handle an earlier response before we can process or
+ * return a later one. If so, we wait on the corresponding condition
+ * variable for that thread to process the response and wake us up.
+ */
+
+static xcb_generic_reply_t *poll_for_event(Display *dpy)
+{
+ /* Make sure the Display's sequence numbers are valid */
+ require_socket(dpy);
+
+ /* Precondition: This thread can safely get events from XCB. */
+ assert(dpy->xcb->event_owner == XlibOwnsEventQueue && !dpy->xcb->event_waiter);
+
+ if(!dpy->xcb->next_event)
+ dpy->xcb->next_event = xcb_poll_for_event(dpy->xcb->connection);
+
+ if(dpy->xcb->next_event)
+ {
+ PendingRequest *req = dpy->xcb->pending_requests;
+ xcb_generic_event_t *event = dpy->xcb->next_event;
+ unsigned long event_sequence = dpy->last_request_read;
+ widen(&event_sequence, event->full_sequence);
+ if(!req || XLIB_SEQUENCE_COMPARE(event_sequence, <, req->sequence)
+ || (event->response_type != X_Error && event_sequence == req->sequence))
+ {
+ assert(XLIB_SEQUENCE_COMPARE(event_sequence, <=, dpy->request));
+ dpy->last_request_read = event_sequence;
+ dpy->xcb->next_event = NULL;
+ return (xcb_generic_reply_t *) event;
+ }
+ }
+ return NULL;
+}
+
+static xcb_generic_reply_t *poll_for_response(Display *dpy)
+{
+ void *response;
+ xcb_generic_error_t *error;
+ PendingRequest *req;
+ while(!(response = poll_for_event(dpy)) &&
+ (req = dpy->xcb->pending_requests) &&
+ !req->reply_waiter &&
+ xcb_poll_for_reply(dpy->xcb->connection, req->sequence, &response, &error))
+ {
+ assert(XLIB_SEQUENCE_COMPARE(req->sequence, <=, dpy->request));
+ dpy->last_request_read = req->sequence;
+ if(!response)
+ dequeue_pending_request(dpy, req);
+ if(error)
+ return (xcb_generic_reply_t *) error;
+ }
+ return response;
+}
+
+static void handle_response(Display *dpy, xcb_generic_reply_t *response, Bool in_XReply)
+{
+ _XAsyncHandler *async, *next;
+ switch(response->response_type)
+ {
+ case X_Reply:
+ for(async = dpy->async_handlers; async; async = next)
+ {
+ next = async->next;
+ if(async->handler(dpy, (xReply *) response, (char *) response, sizeof(xReply) + (response->length << 2), async->data))
+ break;
+ }
+ break;
+
+ case X_Error:
+ handle_error(dpy, (xError *) response, in_XReply);
+ break;
+
+ default: /* event */
+ /* GenericEvents may be > 32 bytes. In this case, the
+ * event struct is trailed by the additional bytes. the
+ * xcb_generic_event_t struct uses 4 bytes for internal
+ * numbering, so we need to shift the trailing data to
+ * be after the first 32 bytes. */
+ if(response->response_type == GenericEvent && ((xcb_ge_event_t *) response)->length)
+ {
+ xcb_ge_event_t *event = (xcb_ge_event_t *) response;
+ memmove(&event->full_sequence, &event[1], event->length * 4);
+ }
+ _XEnq(dpy, (xEvent *) response);
+ break;
+ }
+ free(response);
+}
+
+int _XEventsQueued(Display *dpy, int mode)
+{
+ xcb_generic_reply_t *response;
+ if(dpy->flags & XlibDisplayIOError)
+ return 0;
+ if(dpy->xcb->event_owner != XlibOwnsEventQueue)
+ return 0;
+
+ if(mode == QueuedAfterFlush)
+ _XSend(dpy, NULL, 0);
+ else
+ check_internal_connections(dpy);
+
+ /* If another thread is blocked waiting for events, then we must
+ * let that thread pick up the next event. Since it blocked, we
+ * can reasonably claim there are no new events right now. */
+ if(!dpy->xcb->event_waiter)
+ {
+ while((response = poll_for_response(dpy)))
+ handle_response(dpy, response, False);
+ if(xcb_connection_has_error(dpy->xcb->connection))
+ _XIOError(dpy);
+ }
+ return dpy->qlen;
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(Display *dpy)
+{
+ xcb_generic_reply_t *response;
+ unsigned long serial;
+
+ if(dpy->flags & XlibDisplayIOError)
+ return;
+ _XSend(dpy, NULL, 0);
+ if(dpy->xcb->event_owner != XlibOwnsEventQueue)
+ return;
+ check_internal_connections(dpy);
+
+ serial = dpy->next_event_serial_num;
+ while(serial == dpy->next_event_serial_num || dpy->qlen == 0)
+ {
+ if(dpy->xcb->event_waiter)
+ {
+ ConditionWait(dpy, dpy->xcb->event_notify);
+ /* Maybe the other thread got us an event. */
+ continue;
+ }
+
+ if(!dpy->xcb->next_event)
+ {
+ xcb_generic_event_t *event;
+ dpy->xcb->event_waiter = 1;
+ UnlockDisplay(dpy);
+ event = xcb_wait_for_event(dpy->xcb->connection);
+ InternalLockDisplay(dpy, /* don't skip user locks */ 0);
+ dpy->xcb->event_waiter = 0;
+ ConditionBroadcast(dpy, dpy->xcb->event_notify);
+ if(!event)
+ _XIOError(dpy);
+ dpy->xcb->next_event = event;
+ }
+
+ /* We've established most of the conditions for
+ * poll_for_response to return non-NULL. The exceptions
+ * are connection shutdown, and finding that another
+ * thread is waiting for the next reply we'd like to
+ * process. */
+
+ response = poll_for_response(dpy);
+ if(response)
+ handle_response(dpy, response, False);
+ else if(dpy->xcb->pending_requests->reply_waiter)
+ { /* need braces around ConditionWait */
+ ConditionWait(dpy, dpy->xcb->reply_notify);
+ }
+ else
+ _XIOError(dpy);
+ }
+
+ /* The preceding loop established that there is no
+ * event_waiter--unless we just called ConditionWait because of
+ * a reply_waiter, in which case another thread may have become
+ * the event_waiter while we slept unlocked. */
+ if(!dpy->xcb->event_waiter)
+ while((response = poll_for_response(dpy)))
+ handle_response(dpy, response, False);
+ if(xcb_connection_has_error(dpy->xcb->connection))
+ _XIOError(dpy);
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ *
+ * Note that the connection must not be read from once the data currently
+ * in the buffer has been written.
+ */
+void _XSend(Display *dpy, const char *data, long size)
+{
+ static const xReq dummy_request;
+ static char const pad[3];
+ struct iovec vec[3];
+ uint64_t requests;
+ _XExtension *ext;
+ xcb_connection_t *c = dpy->xcb->connection;
+ if(dpy->flags & XlibDisplayIOError)
+ return;
+
+ if(dpy->bufptr == dpy->buffer && !size)
+ return;
+
+ /* iff we asked XCB to set aside errors, we must pick those up
+ * eventually. iff there are async handlers, we may have just
+ * issued requests that will generate replies. in either case,
+ * we need to remember to check later. */
+ if(dpy->xcb->event_owner != XlibOwnsEventQueue || dpy->async_handlers)
+ {
+ uint64_t sequence;
+ for(sequence = dpy->xcb->last_flushed + 1; sequence <= dpy->request; ++sequence)
+ append_pending_request(dpy, sequence);
+ }
+ requests = dpy->request - dpy->xcb->last_flushed;
+ dpy->xcb->last_flushed = dpy->request;
+
+ vec[0].iov_base = dpy->buffer;
+ vec[0].iov_len = dpy->bufptr - dpy->buffer;
+ vec[1].iov_base = (caddr_t) data;
+ vec[1].iov_len = size;
+ vec[2].iov_base = (caddr_t) pad;
+ vec[2].iov_len = -size & 3;
+
+ for(ext = dpy->flushes; ext; ext = ext->next_flush)
+ {
+ int i;
+ for(i = 0; i < 3; ++i)
+ if(vec[i].iov_len)
+ ext->before_flush(dpy, &ext->codes, vec[i].iov_base, vec[i].iov_len);
+ }
+
+ if(xcb_writev(c, vec, 3, requests) < 0)
+ _XIOError(dpy);
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *) &dummy_request;
+
+ check_internal_connections(dpy);
+
+ _XSetSeqSyncFunction(dpy);
+}
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken.
+ */
+void _XFlush(Display *dpy)
+{
+ require_socket(dpy);
+ _XSend(dpy, NULL, 0);
+
+ _XEventsQueued(dpy, QueuedAfterReading);
+}
+
+static const XID inval_id = ~0UL;
+
+void _XIDHandler(Display *dpy)
+{
+ if (dpy->xcb->next_xid == inval_id)
+ _XAllocIDs(dpy, &dpy->xcb->next_xid, 1);
+}
+
+/* _XAllocID - resource ID allocation routine. */
+XID _XAllocID(Display *dpy)
+{
+ XID ret = dpy->xcb->next_xid;
+ assert (ret != inval_id);
+ dpy->xcb->next_xid = inval_id;
+ _XSetPrivSyncFunction(dpy);
+ return ret;
+}
+
+/* _XAllocIDs - multiple resource ID allocation routine. */
+void _XAllocIDs(Display *dpy, XID *ids, int count)
+{
+ int i;
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif
+ for (i = 0; i < count; i++)
+ ids[i] = xcb_generate_id(dpy->xcb->connection);
+#ifdef XTHREADS
+ InternalLockDisplay(dpy, /* don't skip user locks */ 0);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif
+}
+
+static void _XFreeReplyData(Display *dpy, Bool force)
+{
+ if(!force && dpy->xcb->reply_consumed < dpy->xcb->reply_length)
+ return;
+ free(dpy->xcb->reply_data);
+ dpy->xcb->reply_data = NULL;
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep.
+ * extra: number of 32-bit words expected after the reply
+ * discard: should I discard data following "extra" words?
+ */
+Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard)
+{
+ xcb_generic_error_t *error;
+ xcb_connection_t *c = dpy->xcb->connection;
+ char *reply;
+ PendingRequest *current;
+
+ assert(!dpy->xcb->reply_data);
+
+ if(dpy->flags & XlibDisplayIOError)
+ return 0;
+
+ _XSend(dpy, NULL, 0);
+ if(dpy->xcb->pending_requests_tail && dpy->xcb->pending_requests_tail->sequence == dpy->request)
+ current = dpy->xcb->pending_requests_tail;
+ else
+ current = append_pending_request(dpy, dpy->request);
+ /* Don't let any other thread get this reply. */
+ current->reply_waiter = 1;
+
+ while(1)
+ {
+ PendingRequest *req = dpy->xcb->pending_requests;
+ xcb_generic_reply_t *response;
+
+ if(req != current && req->reply_waiter)
+ {
+ ConditionWait(dpy, dpy->xcb->reply_notify);
+ /* Another thread got this reply. */
+ continue;
+ }
+ req->reply_waiter = 1;
+ UnlockDisplay(dpy);
+ response = xcb_wait_for_reply(c, req->sequence, &error);
+ InternalLockDisplay(dpy, /* don't skip user locks */ 0);
+
+ /* We have the response we're looking for. Now, before
+ * letting anyone else process this sequence number, we
+ * need to process any events that should have come
+ * earlier. */
+
+ if(dpy->xcb->event_owner == XlibOwnsEventQueue)
+ {
+ xcb_generic_reply_t *event;
+ /* If some thread is already waiting for events,
+ * it will get the first one. That thread must
+ * process that event before we can continue. */
+ /* FIXME: That event might be after this reply,
+ * and might never even come--or there might be
+ * multiple threads trying to get events. */
+ while(dpy->xcb->event_waiter)
+ { /* need braces around ConditionWait */
+ ConditionWait(dpy, dpy->xcb->event_notify);
+ }
+ while((event = poll_for_event(dpy)))
+ handle_response(dpy, event, True);
+ }
+
+ req->reply_waiter = 0;
+ ConditionBroadcast(dpy, dpy->xcb->reply_notify);
+ assert(XLIB_SEQUENCE_COMPARE(req->sequence, <=, dpy->request));
+ dpy->last_request_read = req->sequence;
+ if(!response)
+ dequeue_pending_request(dpy, req);
+
+ if(req == current)
+ {
+ reply = (char *) response;
+ break;
+ }
+
+ if(error)
+ handle_response(dpy, (xcb_generic_reply_t *) error, True);
+ else if(response)
+ handle_response(dpy, response, True);
+ }
+ check_internal_connections(dpy);
+
+ if(dpy->xcb->next_event && dpy->xcb->next_event->response_type == X_Error)
+ {
+ xcb_generic_event_t *event = dpy->xcb->next_event;
+ unsigned long event_sequence = dpy->last_request_read;
+ widen(&event_sequence, event->full_sequence);
+ if(event_sequence == current->sequence)
+ {
+ error = (xcb_generic_error_t *) event;
+ dpy->xcb->next_event = NULL;
+ }
+ }
+
+ if(error)
+ {
+ int ret_code;
+
+ /* Xlib is evil and assumes that even errors will be
+ * copied into rep. */
+ memcpy(rep, error, 32);
+
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch(error->error_code)
+ {
+ case BadName:
+ switch(error->major_code)
+ {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ free(error);
+ return 0;
+ }
+ break;
+ case BadFont:
+ if(error->major_code == X_QueryFont) {
+ free(error);
+ return 0;
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ free(error);
+ return 0;
+ }
+
+ ret_code = handle_error(dpy, (xError *) error, True);
+ free(error);
+ return ret_code;
+ }
+
+ /* it's not an error, but we don't have a reply, so it's an I/O
+ * error. */
+ if(!reply)
+ {
+ _XIOError(dpy);
+ return 0;
+ }
+
+ /* there's no error and we have a reply. */
+ dpy->xcb->reply_data = reply;
+ dpy->xcb->reply_consumed = sizeof(xReply) + (extra * 4);
+ dpy->xcb->reply_length = sizeof(xReply);
+ if(dpy->xcb->reply_data[0] == 1)
+ dpy->xcb->reply_length += (((xcb_generic_reply_t *) dpy->xcb->reply_data)->length * 4);
+
+ /* error: Xlib asks too much. give them what we can anyway. */
+ if(dpy->xcb->reply_length < dpy->xcb->reply_consumed)
+ dpy->xcb->reply_consumed = dpy->xcb->reply_length;
+
+ memcpy(rep, dpy->xcb->reply_data, dpy->xcb->reply_consumed);
+ _XFreeReplyData(dpy, discard);
+ return 1;
+}
+
+int _XRead(Display *dpy, char *data, long size)
+{
+ assert(size >= 0);
+ if(size == 0)
+ return 0;
+ assert(dpy->xcb->reply_data != NULL);
+ assert(dpy->xcb->reply_consumed + size <= dpy->xcb->reply_length);
+ memcpy(data, dpy->xcb->reply_data + dpy->xcb->reply_consumed, size);
+ dpy->xcb->reply_consumed += size;
+ _XFreeReplyData(dpy, False);
+ return 0;
+}
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes.
+ */
+void _XReadPad(Display *dpy, char *data, long size)
+{
+ _XRead(dpy, data, size);
+ dpy->xcb->reply_consumed += -size & 3;
+ _XFreeReplyData(dpy, False);
+}
+
+/* Read and discard "n" 8-bit bytes of data */
+void _XEatData(Display *dpy, unsigned long n)
+{
+ dpy->xcb->reply_consumed += n;
+ _XFreeReplyData(dpy, False);
+}
diff --git a/libX11/src/xcms/Makefile.am b/libX11/src/xcms/Makefile.am
index 1f1b51d5b..aa4758063 100644
--- a/libX11/src/xcms/Makefile.am
+++ b/libX11/src/xcms/Makefile.am
@@ -1,100 +1,101 @@
-noinst_LTLIBRARIES = libxcms.la
-
-AM_CPPFLAGS= \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -I$(top_srcdir)/src \
- -D_BSD_SOURCE
-
-AM_CFLAGS= \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-libxcms_la_SOURCES = \
- AddDIC.c \
- AddSF.c \
- CCC.c \
- CvColW.c \
- CvCols.c \
- Cv.h \
- HVC.c \
- HVCGcC.c \
- HVCGcV.c \
- HVCGcVC.c \
- HVCMnV.c \
- HVCMxC.c \
- HVCMxV.c \
- HVCMxVC.c \
- HVCMxVs.c \
- HVCWpAj.c \
- IdOfPr.c \
- LRGB.c \
- Lab.c \
- LabGcC.c \
- LabGcL.c \
- LabGcLC.c \
- LabMnL.c \
- LabMxC.c \
- LabMxL.c \
- LabMxLC.c \
- LabWpAj.c \
- Luv.c \
- LuvGcC.c \
- LuvGcL.c \
- LuvGcLC.c \
- LuvMnL.c \
- LuvMxC.c \
- LuvMxL.c \
- LuvMxLC.c \
- LuvWpAj.c \
- OfCCC.c \
- PrOfId.c \
- QBlack.c \
- QBlue.c \
- QGreen.c \
- QRed.c \
- QWhite.c \
- QuCol.c \
- QuCols.c \
- SetCCC.c \
- SetGetCols.c \
- StCol.c \
- StCols.c \
- UNDEFINED.c \
- XRGB.c \
- XYZ.c \
- cmsAllCol.c \
- cmsAllNCol.c \
- cmsCmap.c \
- cmsColNm.c \
- cmsGlobls.c \
- cmsInt.c \
- cmsLkCol.c \
- cmsMath.c \
- cmsProp.c \
- cmsTrig.c \
- uvY.c \
- xyY.c \
- Xcmsint.h
-
-X11dir = $(libdir)/X11
-dist_X11_DATA = Xcms.txt
-
-
-if LINT
-# Check source code with tools like lint & sparse
-
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-lint:
- $(LINT) $(ALL_LINT_FLAGS) $(libxcms_la_SOURCES) -lm
-
-endif LINT
+noinst_LTLIBRARIES = libxcms.la
+
+AM_CPPFLAGS= \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/X11 \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/include/X11 \
+ -I$(top_srcdir)/src/xcms \
+ -I$(top_srcdir)/src/xkb \
+ -I$(top_srcdir)/src/xlibi18n \
+ -I$(top_srcdir)/src \
+ -D_BSD_SOURCE
+
+AM_CFLAGS= \
+ $(X11_CFLAGS) \
+ $(BIGFONT_CFLAGS) \
+ $(XDMCP_CFLAGS) \
+ $(XMALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+libxcms_la_SOURCES = \
+ AddDIC.c \
+ AddSF.c \
+ CCC.c \
+ CvColW.c \
+ CvCols.c \
+ Cv.h \
+ HVC.c \
+ HVCGcC.c \
+ HVCGcV.c \
+ HVCGcVC.c \
+ HVCMnV.c \
+ HVCMxC.c \
+ HVCMxV.c \
+ HVCMxVC.c \
+ HVCMxVs.c \
+ HVCWpAj.c \
+ IdOfPr.c \
+ LRGB.c \
+ Lab.c \
+ LabGcC.c \
+ LabGcL.c \
+ LabGcLC.c \
+ LabMnL.c \
+ LabMxC.c \
+ LabMxL.c \
+ LabMxLC.c \
+ LabWpAj.c \
+ Luv.c \
+ LuvGcC.c \
+ LuvGcL.c \
+ LuvGcLC.c \
+ LuvMnL.c \
+ LuvMxC.c \
+ LuvMxL.c \
+ LuvMxLC.c \
+ LuvWpAj.c \
+ OfCCC.c \
+ PrOfId.c \
+ QBlack.c \
+ QBlue.c \
+ QGreen.c \
+ QRed.c \
+ QWhite.c \
+ QuCol.c \
+ QuCols.c \
+ SetCCC.c \
+ SetGetCols.c \
+ StCol.c \
+ StCols.c \
+ UNDEFINED.c \
+ XRGB.c \
+ XYZ.c \
+ cmsAllCol.c \
+ cmsAllNCol.c \
+ cmsCmap.c \
+ cmsColNm.c \
+ cmsGlobls.c \
+ cmsInt.c \
+ cmsLkCol.c \
+ cmsMath.c \
+ cmsProp.c \
+ cmsTrig.c \
+ uvY.c \
+ xyY.c \
+ Xcmsint.h
+
+X11dir = $(libdir)/X11
+dist_X11_DATA = Xcms.txt
+
+
+if LINT
+# Check source code with tools like lint & sparse
+
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) $(libxcms_la_SOURCES) -lm
+
+endif LINT
diff --git a/libX11/src/xcms/Makefile.in b/libX11/src/xcms/Makefile.in
deleted file mode 100644
index 65400532b..000000000
--- a/libX11/src/xcms/Makefile.in
+++ /dev/null
@@ -1,750 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-subdir = src/xcms
-DIST_COMMON = $(dist_X11_DATA) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h \
- $(top_builddir)/include/X11/XlibConf.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-libxcms_la_LIBADD =
-am_libxcms_la_OBJECTS = AddDIC.lo AddSF.lo CCC.lo CvColW.lo CvCols.lo \
- HVC.lo HVCGcC.lo HVCGcV.lo HVCGcVC.lo HVCMnV.lo HVCMxC.lo \
- HVCMxV.lo HVCMxVC.lo HVCMxVs.lo HVCWpAj.lo IdOfPr.lo LRGB.lo \
- Lab.lo LabGcC.lo LabGcL.lo LabGcLC.lo LabMnL.lo LabMxC.lo \
- LabMxL.lo LabMxLC.lo LabWpAj.lo Luv.lo LuvGcC.lo LuvGcL.lo \
- LuvGcLC.lo LuvMnL.lo LuvMxC.lo LuvMxL.lo LuvMxLC.lo LuvWpAj.lo \
- OfCCC.lo PrOfId.lo QBlack.lo QBlue.lo QGreen.lo QRed.lo \
- QWhite.lo QuCol.lo QuCols.lo SetCCC.lo SetGetCols.lo StCol.lo \
- StCols.lo UNDEFINED.lo XRGB.lo XYZ.lo cmsAllCol.lo \
- cmsAllNCol.lo cmsCmap.lo cmsColNm.lo cmsGlobls.lo cmsInt.lo \
- cmsLkCol.lo cmsMath.lo cmsProp.lo cmsTrig.lo uvY.lo xyY.lo
-libxcms_la_OBJECTS = $(am_libxcms_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libxcms_la_SOURCES)
-DIST_SOURCES = $(libxcms_la_SOURCES)
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
- $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
- *) f=$$p;; \
- esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
- srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
- for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
- for p in $$list; do echo "$$p $$p"; done | \
- sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
- $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
- if (++n[$$2] == $(am__install_max)) \
- { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
- END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
- sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
- sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(X11dir)"
-DATA = $(dist_X11_DATA)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
-ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APP_MAN_DIR = @APP_MAN_DIR@
-APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BIGFONT_CFLAGS = @BIGFONT_CFLAGS@
-BIGFONT_LIBS = @BIGFONT_LIBS@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CHANGELOG_CMD = @CHANGELOG_CMD@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CWARNFLAGS = @CWARNFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DOLT_BASH = @DOLT_BASH@
-DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
-DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FILE_MAN_DIR = @FILE_MAN_DIR@
-FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
-GREP = @GREP@
-GROFF = @GROFF@
-I18N_MODULE_LIBS = @I18N_MODULE_LIBS@
-INSTALL = @INSTALL@
-INSTALL_CMD = @INSTALL_CMD@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-KEYSYMDEF = @KEYSYMDEF@
-LAUNCHD = @LAUNCHD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIB_MAN_DIR = @LIB_MAN_DIR@
-LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINT = @LINT@
-LINTLIB = @LINTLIB@
-LINT_FLAGS = @LINT_FLAGS@
-LN_S = @LN_S@
-LTCOMPILE = @LTCOMPILE@
-LTCXXCOMPILE = @LTCXXCOMPILE@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@
-MISC_MAN_DIR = @MISC_MAN_DIR@
-MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
-MKDIR_P = @MKDIR_P@
-NMEDIT = @NMEDIT@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PKG_CONFIG = @PKG_CONFIG@
-PS2PDF = @PS2PDF@
-RANLIB = @RANLIB@
-RAWCPP = @RAWCPP@
-RAWCPPFLAGS = @RAWCPPFLAGS@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WCHAR32 = @WCHAR32@
-X11_CFLAGS = @X11_CFLAGS@
-X11_DATADIR = @X11_DATADIR@
-X11_EXTRA_DEPS = @X11_EXTRA_DEPS@
-X11_LIBDIR = @X11_LIBDIR@
-X11_LIBS = @X11_LIBS@
-X11_LOCALEDATADIR = @X11_LOCALEDATADIR@
-X11_LOCALEDIR = @X11_LOCALEDIR@
-X11_LOCALELIBDIR = @X11_LOCALELIBDIR@
-XDMCP_CFLAGS = @XDMCP_CFLAGS@
-XDMCP_LIBS = @XDMCP_LIBS@
-XERRORDB = @XERRORDB@
-XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@
-XKEYSYMDB = @XKEYSYMDB@
-XLOCALEDATADIR = @XLOCALEDATADIR@
-XLOCALEDIR = @XLOCALEDIR@
-XLOCALELIBDIR = @XLOCALELIBDIR@
-XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@
-XTHREADLIB = @XTHREADLIB@
-XTHREAD_CFLAGS = @XTHREAD_CFLAGS@
-XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-noinst_LTLIBRARIES = libxcms.la
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -I$(top_srcdir)/src \
- -D_BSD_SOURCE
-
-AM_CFLAGS = \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-libxcms_la_SOURCES = \
- AddDIC.c \
- AddSF.c \
- CCC.c \
- CvColW.c \
- CvCols.c \
- Cv.h \
- HVC.c \
- HVCGcC.c \
- HVCGcV.c \
- HVCGcVC.c \
- HVCMnV.c \
- HVCMxC.c \
- HVCMxV.c \
- HVCMxVC.c \
- HVCMxVs.c \
- HVCWpAj.c \
- IdOfPr.c \
- LRGB.c \
- Lab.c \
- LabGcC.c \
- LabGcL.c \
- LabGcLC.c \
- LabMnL.c \
- LabMxC.c \
- LabMxL.c \
- LabMxLC.c \
- LabWpAj.c \
- Luv.c \
- LuvGcC.c \
- LuvGcL.c \
- LuvGcLC.c \
- LuvMnL.c \
- LuvMxC.c \
- LuvMxL.c \
- LuvMxLC.c \
- LuvWpAj.c \
- OfCCC.c \
- PrOfId.c \
- QBlack.c \
- QBlue.c \
- QGreen.c \
- QRed.c \
- QWhite.c \
- QuCol.c \
- QuCols.c \
- SetCCC.c \
- SetGetCols.c \
- StCol.c \
- StCols.c \
- UNDEFINED.c \
- XRGB.c \
- XYZ.c \
- cmsAllCol.c \
- cmsAllNCol.c \
- cmsCmap.c \
- cmsColNm.c \
- cmsGlobls.c \
- cmsInt.c \
- cmsLkCol.c \
- cmsMath.c \
- cmsProp.c \
- cmsTrig.c \
- uvY.c \
- xyY.c \
- Xcmsint.h
-
-X11dir = $(libdir)/X11
-dist_X11_DATA = Xcms.txt
-
-# Check source code with tools like lint & sparse
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/xcms/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/xcms/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
- @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-libxcms.la: $(libxcms_la_OBJECTS) $(libxcms_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(libxcms_la_OBJECTS) $(libxcms_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AddDIC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AddSF.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CCC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CvColW.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CvCols.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCGcC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCGcV.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCGcVC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCMnV.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCMxC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCMxV.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCMxVC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCMxVs.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HVCWpAj.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IdOfPr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LRGB.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lab.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabGcC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabGcL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabGcLC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabMnL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabMxC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabMxL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabMxLC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LabWpAj.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Luv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvGcC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvGcL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvGcLC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvMnL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvMxC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvMxL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvMxLC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LuvWpAj.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OfCCC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PrOfId.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QBlack.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QBlue.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QGreen.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QRed.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QWhite.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QuCols.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetCCC.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SetGetCols.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StCols.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UNDEFINED.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XRGB.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XYZ.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsAllCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsAllNCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsCmap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsColNm.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsGlobls.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsInt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsLkCol.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsMath.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsProp.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmsTrig.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uvY.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xyY.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-install-dist_X11DATA: $(dist_X11_DATA)
- @$(NORMAL_INSTALL)
- test -z "$(X11dir)" || $(MKDIR_P) "$(DESTDIR)$(X11dir)"
- @list='$(dist_X11_DATA)'; test -n "$(X11dir)" || list=; \
- for p in $$list; do \
- if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
- echo "$$d$$p"; \
- done | $(am__base_list) | \
- while read files; do \
- echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(X11dir)'"; \
- $(INSTALL_DATA) $$files "$(DESTDIR)$(X11dir)" || exit $$?; \
- done
-
-uninstall-dist_X11DATA:
- @$(NORMAL_UNINSTALL)
- @list='$(dist_X11_DATA)'; test -n "$(X11dir)" || list=; \
- files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
- test -n "$$files" || exit 0; \
- echo " ( cd '$(DESTDIR)$(X11dir)' && rm -f" $$files ")"; \
- cd "$(DESTDIR)$(X11dir)" && rm -f $$files
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES) $(DATA)
-installdirs:
- for dir in "$(DESTDIR)$(X11dir)"; do \
- test -z "$$dir" || $(MKDIR_P) "$$dir"; \
- done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am: install-dist_X11DATA
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am: uninstall-dist_X11DATA
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstLTLIBRARIES ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am \
- install-dist_X11DATA install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf install-pdf-am \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-dist_X11DATA
-
-
-@LINT_TRUE@lint:
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $(libxcms_la_SOURCES) -lm
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/libX11/src/xkb/Makefile.am b/libX11/src/xkb/Makefile.am
index 0141836c8..3e7ca1951 100644
--- a/libX11/src/xkb/Makefile.am
+++ b/libX11/src/xkb/Makefile.am
@@ -1,52 +1,53 @@
-AM_CPPFLAGS= \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -D_BSD_SOURCE
-
-AM_CFLAGS= \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-noinst_LTLIBRARIES = libxkb.la
-
-libxkb_la_SOURCES = \
- XKB.c \
- XKBBind.c \
- XKBCompat.c \
- XKBCtrls.c \
- XKBCvt.c \
- XKBGetMap.c \
- XKBGetByName.c \
- XKBNames.c \
- XKBRdBuf.c \
- XKBSetMap.c \
- XKBUse.c \
- XKBleds.c \
- XKBBell.c \
- XKBGeom.c \
- XKBSetGeom.c \
- XKBExtDev.c \
- XKBList.c \
- XKBMisc.c \
- XKBMAlloc.c \
- XKBGAlloc.c \
- XKBAlloc.c \
- XKBlibint.h
-
-if LINT
-# Check source code with tools like lint & sparse
-
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-lint:
- $(LINT) $(ALL_LINT_FLAGS) $(libxkb_la_SOURCES) -lm
-
-endif LINT
+AM_CPPFLAGS= \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/X11 \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/include/X11 \
+ -I$(top_srcdir)/src/xcms \
+ -I$(top_srcdir)/src/xkb \
+ -I$(top_srcdir)/src/xlibi18n \
+ -D_BSD_SOURCE
+
+AM_CFLAGS= \
+ $(X11_CFLAGS) \
+ $(BIGFONT_CFLAGS) \
+ $(XDMCP_CFLAGS) \
+ $(XMALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+noinst_LTLIBRARIES = libxkb.la
+
+libxkb_la_SOURCES = \
+ XKB.c \
+ XKBBind.c \
+ XKBCompat.c \
+ XKBCtrls.c \
+ XKBCvt.c \
+ XKBGetMap.c \
+ XKBGetByName.c \
+ XKBNames.c \
+ XKBRdBuf.c \
+ XKBSetMap.c \
+ XKBUse.c \
+ XKBleds.c \
+ XKBBell.c \
+ XKBGeom.c \
+ XKBSetGeom.c \
+ XKBExtDev.c \
+ XKBList.c \
+ XKBMisc.c \
+ XKBMAlloc.c \
+ XKBGAlloc.c \
+ XKBAlloc.c \
+ XKBlibint.h
+
+if LINT
+# Check source code with tools like lint & sparse
+
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) $(libxkb_la_SOURCES) -lm
+
+endif LINT
diff --git a/libX11/src/xkb/Makefile.in b/libX11/src/xkb/Makefile.in
deleted file mode 100644
index 0bfbce3fd..000000000
--- a/libX11/src/xkb/Makefile.in
+++ /dev/null
@@ -1,607 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-subdir = src/xkb
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h \
- $(top_builddir)/include/X11/XlibConf.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-libxkb_la_LIBADD =
-am_libxkb_la_OBJECTS = XKB.lo XKBBind.lo XKBCompat.lo XKBCtrls.lo \
- XKBCvt.lo XKBGetMap.lo XKBGetByName.lo XKBNames.lo XKBRdBuf.lo \
- XKBSetMap.lo XKBUse.lo XKBleds.lo XKBBell.lo XKBGeom.lo \
- XKBSetGeom.lo XKBExtDev.lo XKBList.lo XKBMisc.lo XKBMAlloc.lo \
- XKBGAlloc.lo XKBAlloc.lo
-libxkb_la_OBJECTS = $(am_libxkb_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libxkb_la_SOURCES)
-DIST_SOURCES = $(libxkb_la_SOURCES)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
-ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APP_MAN_DIR = @APP_MAN_DIR@
-APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BIGFONT_CFLAGS = @BIGFONT_CFLAGS@
-BIGFONT_LIBS = @BIGFONT_LIBS@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CHANGELOG_CMD = @CHANGELOG_CMD@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CWARNFLAGS = @CWARNFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DOLT_BASH = @DOLT_BASH@
-DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
-DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FILE_MAN_DIR = @FILE_MAN_DIR@
-FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
-GREP = @GREP@
-GROFF = @GROFF@
-I18N_MODULE_LIBS = @I18N_MODULE_LIBS@
-INSTALL = @INSTALL@
-INSTALL_CMD = @INSTALL_CMD@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-KEYSYMDEF = @KEYSYMDEF@
-LAUNCHD = @LAUNCHD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIB_MAN_DIR = @LIB_MAN_DIR@
-LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINT = @LINT@
-LINTLIB = @LINTLIB@
-LINT_FLAGS = @LINT_FLAGS@
-LN_S = @LN_S@
-LTCOMPILE = @LTCOMPILE@
-LTCXXCOMPILE = @LTCXXCOMPILE@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@
-MISC_MAN_DIR = @MISC_MAN_DIR@
-MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
-MKDIR_P = @MKDIR_P@
-NMEDIT = @NMEDIT@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PKG_CONFIG = @PKG_CONFIG@
-PS2PDF = @PS2PDF@
-RANLIB = @RANLIB@
-RAWCPP = @RAWCPP@
-RAWCPPFLAGS = @RAWCPPFLAGS@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WCHAR32 = @WCHAR32@
-X11_CFLAGS = @X11_CFLAGS@
-X11_DATADIR = @X11_DATADIR@
-X11_EXTRA_DEPS = @X11_EXTRA_DEPS@
-X11_LIBDIR = @X11_LIBDIR@
-X11_LIBS = @X11_LIBS@
-X11_LOCALEDATADIR = @X11_LOCALEDATADIR@
-X11_LOCALEDIR = @X11_LOCALEDIR@
-X11_LOCALELIBDIR = @X11_LOCALELIBDIR@
-XDMCP_CFLAGS = @XDMCP_CFLAGS@
-XDMCP_LIBS = @XDMCP_LIBS@
-XERRORDB = @XERRORDB@
-XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@
-XKEYSYMDB = @XKEYSYMDB@
-XLOCALEDATADIR = @XLOCALEDATADIR@
-XLOCALEDIR = @XLOCALEDIR@
-XLOCALELIBDIR = @XLOCALELIBDIR@
-XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@
-XTHREADLIB = @XTHREADLIB@
-XTHREAD_CFLAGS = @XTHREAD_CFLAGS@
-XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -D_BSD_SOURCE
-
-AM_CFLAGS = \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-noinst_LTLIBRARIES = libxkb.la
-libxkb_la_SOURCES = \
- XKB.c \
- XKBBind.c \
- XKBCompat.c \
- XKBCtrls.c \
- XKBCvt.c \
- XKBGetMap.c \
- XKBGetByName.c \
- XKBNames.c \
- XKBRdBuf.c \
- XKBSetMap.c \
- XKBUse.c \
- XKBleds.c \
- XKBBell.c \
- XKBGeom.c \
- XKBSetGeom.c \
- XKBExtDev.c \
- XKBList.c \
- XKBMisc.c \
- XKBMAlloc.c \
- XKBGAlloc.c \
- XKBAlloc.c \
- XKBlibint.h
-
-
-# Check source code with tools like lint & sparse
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/xkb/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/xkb/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
- @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-libxkb.la: $(libxkb_la_OBJECTS) $(libxkb_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(libxkb_la_OBJECTS) $(libxkb_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKB.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBAlloc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBBell.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBBind.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBCompat.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBCtrls.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBCvt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBExtDev.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBGAlloc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBGeom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBGetByName.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBGetMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBList.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBMAlloc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBMisc.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBNames.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBRdBuf.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBSetGeom.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBSetMap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBUse.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XKBleds.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstLTLIBRARIES ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am
-
-
-@LINT_TRUE@lint:
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $(libxkb_la_SOURCES) -lm
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/libX11/src/xlibi18n/Makefile.am b/libX11/src/xlibi18n/Makefile.am
index fa5a1c071..3215a42e6 100644
--- a/libX11/src/xlibi18n/Makefile.am
+++ b/libX11/src/xlibi18n/Makefile.am
@@ -1,151 +1,152 @@
-AM_CPPFLAGS= \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -I$(top_srcdir)/src \
- -D_BSD_SOURCE
-
-AM_CFLAGS= \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-noinst_LTLIBRARIES = libi18n.la
-
-
-#
-# Dynamic loading code for i18n modules
-#
-if XLIB_LOADABLE_I18N
-XI18N_DL_SOURCES = \
- XlcDL.c \
- XlcSL.c
-else
-#
-# Static interfaces to input/output methods
-#
-IM_LIBS = \
- ${top_builddir}/modules/im/ximcp/libximcp.la
-
-LC_LIBS = \
- ${top_builddir}/modules/lc/def/libxlcDef.la \
- ${top_builddir}/modules/lc/gen/libxlibi18n.la \
- ${top_builddir}/modules/lc/Utf8/libxlcUTF8Load.la \
- ${top_builddir}/modules/lc/xlocale/libxlocale.la
-
-OM_LIBS = \
- ${top_builddir}/modules/om/generic/libxomGeneric.la
-endif
-
-libi18n_la_LIBADD = \
- $(IM_LIBS) $(LC_LIBS) $(OM_LIBS)
-
-libi18n_la_SOURCES = \
- $(XI18N_DL_SOURCES) \
- XDefaultIMIF.c \
- XDefaultOMIF.c \
- xim_trans.c\
- ICWrap.c\
- IMWrap.c\
- imKStoUCS.c\
- lcCT.c\
- lcCharSet.c\
- lcConv.c\
- lcDB.c\
- lcDynamic.c\
- lcFile.c\
- lcGeneric.c\
- lcInit.c\
- lcPrTxt.c\
- lcPubWrap.c\
- lcPublic.c\
- lcRM.c\
- lcStd.c\
- lcTxtPr.c\
- lcUTF8.c\
- lcUtil.c\
- lcWrap.c\
- mbWMProps.c\
- mbWrap.c\
- utf8WMProps.c\
- utf8Wrap.c\
- wcWrap.c\
- Xaixlcint.h\
- XimImSw.h\
- XimProto.h\
- XimThai.h\
- XimTrInt.h\
- XimTrX.h\
- XimTrans.h\
- Ximint.h\
- XimintL.h\
- XimintP.h\
- XlcGeneric.h\
- XlcPubI.h\
- XlcPublic.h\
- Xlcint.h\
- lcUniConv/armscii_8.h\
- lcUniConv/ascii.h\
- lcUniConv/big5.h\
- lcUniConv/big5_emacs.h\
- lcUniConv/big5hkscs.h\
- lcUniConv/cp1133.h\
- lcUniConv/cp1251.h\
- lcUniConv/cp1255.h\
- lcUniConv/cp1256.h\
- lcUniConv/gb2312.h\
- lcUniConv/gbk.h\
- lcUniConv/georgian_academy.h\
- lcUniConv/georgian_ps.h\
- lcUniConv/iso8859_1.h\
- lcUniConv/iso8859_10.h\
- lcUniConv/iso8859_11.h\
- lcUniConv/iso8859_13.h\
- lcUniConv/iso8859_14.h\
- lcUniConv/iso8859_15.h\
- lcUniConv/iso8859_16.h\
- lcUniConv/iso8859_2.h\
- lcUniConv/iso8859_3.h\
- lcUniConv/iso8859_4.h\
- lcUniConv/iso8859_5.h\
- lcUniConv/iso8859_6.h\
- lcUniConv/iso8859_7.h\
- lcUniConv/iso8859_8.h\
- lcUniConv/iso8859_9.h\
- lcUniConv/iso8859_9e.h\
- lcUniConv/jisx0201.h\
- lcUniConv/jisx0208.h\
- lcUniConv/jisx0212.h\
- lcUniConv/koi8_c.h\
- lcUniConv/koi8_r.h\
- lcUniConv/koi8_u.h\
- lcUniConv/ksc5601.h\
- lcUniConv/mulelao.h\
- lcUniConv/tatar_cyr.h\
- lcUniConv/tcvn.h\
- lcUniConv/tis620.h\
- lcUniConv/ucs2be.h\
- lcUniConv/utf8.h\
- lcUniConv/viscii.h
-
-EXTRA_DIST = \
- lcUniConv/README \
- lcUniConv/COPYRIGHT \
- lcUniConv/8bit_tab_to_h.c \
- lcUniConv/cjk_tab_to_h.c
-
-if LINT
-# Check source code with tools like lint & sparse
-
-ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-lint:
- $(LINT) $(ALL_LINT_FLAGS) $(libi18n_la_SOURCES)
-
-endif LINT
+AM_CPPFLAGS= \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/include/X11 \
+ -I$(top_builddir)/include \
+ -I$(top_builddir)/include/X11 \
+ -I$(top_srcdir)/src/xcms \
+ -I$(top_srcdir)/src/xkb \
+ -I$(top_srcdir)/src/xlibi18n \
+ -I$(top_srcdir)/src \
+ -D_BSD_SOURCE
+
+AM_CFLAGS= \
+ $(X11_CFLAGS) \
+ $(BIGFONT_CFLAGS) \
+ $(XDMCP_CFLAGS) \
+ $(XMALLOC_ZERO_CFLAGS) \
+ $(CWARNFLAGS)
+
+noinst_LTLIBRARIES = libi18n.la
+
+
+#
+# Dynamic loading code for i18n modules
+#
+if XLIB_LOADABLE_I18N
+XI18N_DL_SOURCES = \
+ XlcDL.c \
+ XlcSL.c
+else
+#
+# Static interfaces to input/output methods
+#
+IM_LIBS = \
+ ${top_builddir}/modules/im/ximcp/libximcp.la
+
+LC_LIBS = \
+ ${top_builddir}/modules/lc/def/libxlcDef.la \
+ ${top_builddir}/modules/lc/gen/libxlibi18n.la \
+ ${top_builddir}/modules/lc/Utf8/libxlcUTF8Load.la \
+ ${top_builddir}/modules/lc/xlocale/libxlocale.la
+
+OM_LIBS = \
+ ${top_builddir}/modules/om/generic/libxomGeneric.la
+endif
+
+libi18n_la_LIBADD = \
+ $(IM_LIBS) $(LC_LIBS) $(OM_LIBS)
+
+libi18n_la_SOURCES = \
+ $(XI18N_DL_SOURCES) \
+ XDefaultIMIF.c \
+ XDefaultOMIF.c \
+ xim_trans.c\
+ ICWrap.c\
+ IMWrap.c\
+ imKStoUCS.c\
+ lcCT.c\
+ lcCharSet.c\
+ lcConv.c\
+ lcDB.c\
+ lcDynamic.c\
+ lcFile.c\
+ lcGeneric.c\
+ lcInit.c\
+ lcPrTxt.c\
+ lcPubWrap.c\
+ lcPublic.c\
+ lcRM.c\
+ lcStd.c\
+ lcTxtPr.c\
+ lcUTF8.c\
+ lcUtil.c\
+ lcWrap.c\
+ mbWMProps.c\
+ mbWrap.c\
+ utf8WMProps.c\
+ utf8Wrap.c\
+ wcWrap.c\
+ Xaixlcint.h\
+ XimImSw.h\
+ XimProto.h\
+ XimThai.h\
+ XimTrInt.h\
+ XimTrX.h\
+ XimTrans.h\
+ Ximint.h\
+ XimintL.h\
+ XimintP.h\
+ XlcGeneric.h\
+ XlcPubI.h\
+ XlcPublic.h\
+ Xlcint.h\
+ lcUniConv/armscii_8.h\
+ lcUniConv/ascii.h\
+ lcUniConv/big5.h\
+ lcUniConv/big5_emacs.h\
+ lcUniConv/big5hkscs.h\
+ lcUniConv/cp1133.h\
+ lcUniConv/cp1251.h\
+ lcUniConv/cp1255.h\
+ lcUniConv/cp1256.h\
+ lcUniConv/gb2312.h\
+ lcUniConv/gbk.h\
+ lcUniConv/georgian_academy.h\
+ lcUniConv/georgian_ps.h\
+ lcUniConv/iso8859_1.h\
+ lcUniConv/iso8859_10.h\
+ lcUniConv/iso8859_11.h\
+ lcUniConv/iso8859_13.h\
+ lcUniConv/iso8859_14.h\
+ lcUniConv/iso8859_15.h\
+ lcUniConv/iso8859_16.h\
+ lcUniConv/iso8859_2.h\
+ lcUniConv/iso8859_3.h\
+ lcUniConv/iso8859_4.h\
+ lcUniConv/iso8859_5.h\
+ lcUniConv/iso8859_6.h\
+ lcUniConv/iso8859_7.h\
+ lcUniConv/iso8859_8.h\
+ lcUniConv/iso8859_9.h\
+ lcUniConv/iso8859_9e.h\
+ lcUniConv/jisx0201.h\
+ lcUniConv/jisx0208.h\
+ lcUniConv/jisx0212.h\
+ lcUniConv/koi8_c.h\
+ lcUniConv/koi8_r.h\
+ lcUniConv/koi8_u.h\
+ lcUniConv/ksc5601.h\
+ lcUniConv/mulelao.h\
+ lcUniConv/tatar_cyr.h\
+ lcUniConv/tcvn.h\
+ lcUniConv/tis620.h\
+ lcUniConv/ucs2be.h\
+ lcUniConv/utf8.h\
+ lcUniConv/viscii.h
+
+EXTRA_DIST = \
+ lcUniConv/README \
+ lcUniConv/COPYRIGHT \
+ lcUniConv/8bit_tab_to_h.c \
+ lcUniConv/cjk_tab_to_h.c
+
+if LINT
+# Check source code with tools like lint & sparse
+
+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
+
+lint:
+ $(LINT) $(ALL_LINT_FLAGS) $(libi18n_la_SOURCES)
+
+endif LINT
diff --git a/libX11/src/xlibi18n/Makefile.in b/libX11/src/xlibi18n/Makefile.in
deleted file mode 100644
index c54895af1..000000000
--- a/libX11/src/xlibi18n/Makefile.in
+++ /dev/null
@@ -1,741 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# @configure_input@
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-@SET_MAKE@
-
-VPATH = @srcdir@
-pkgdatadir = $(datadir)/@PACKAGE@
-pkgincludedir = $(includedir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
-pkglibexecdir = $(libexecdir)/@PACKAGE@
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = @build@
-host_triplet = @host@
-subdir = src/xlibi18n
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/src/config.h \
- $(top_builddir)/include/X11/XlibConf.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-LTLIBRARIES = $(noinst_LTLIBRARIES)
-libi18n_la_DEPENDENCIES = $(IM_LIBS) $(LC_LIBS) $(OM_LIBS)
-am__libi18n_la_SOURCES_DIST = XlcDL.c XlcSL.c XDefaultIMIF.c \
- XDefaultOMIF.c xim_trans.c ICWrap.c IMWrap.c imKStoUCS.c \
- lcCT.c lcCharSet.c lcConv.c lcDB.c lcDynamic.c lcFile.c \
- lcGeneric.c lcInit.c lcPrTxt.c lcPubWrap.c lcPublic.c lcRM.c \
- lcStd.c lcTxtPr.c lcUTF8.c lcUtil.c lcWrap.c mbWMProps.c \
- mbWrap.c utf8WMProps.c utf8Wrap.c wcWrap.c Xaixlcint.h \
- XimImSw.h XimProto.h XimThai.h XimTrInt.h XimTrX.h XimTrans.h \
- Ximint.h XimintL.h XimintP.h XlcGeneric.h XlcPubI.h \
- XlcPublic.h Xlcint.h lcUniConv/armscii_8.h lcUniConv/ascii.h \
- lcUniConv/big5.h lcUniConv/big5_emacs.h lcUniConv/big5hkscs.h \
- lcUniConv/cp1133.h lcUniConv/cp1251.h lcUniConv/cp1255.h \
- lcUniConv/cp1256.h lcUniConv/gb2312.h lcUniConv/gbk.h \
- lcUniConv/georgian_academy.h lcUniConv/georgian_ps.h \
- lcUniConv/iso8859_1.h lcUniConv/iso8859_10.h \
- lcUniConv/iso8859_11.h lcUniConv/iso8859_13.h \
- lcUniConv/iso8859_14.h lcUniConv/iso8859_15.h \
- lcUniConv/iso8859_16.h lcUniConv/iso8859_2.h \
- lcUniConv/iso8859_3.h lcUniConv/iso8859_4.h \
- lcUniConv/iso8859_5.h lcUniConv/iso8859_6.h \
- lcUniConv/iso8859_7.h lcUniConv/iso8859_8.h \
- lcUniConv/iso8859_9.h lcUniConv/iso8859_9e.h \
- lcUniConv/jisx0201.h lcUniConv/jisx0208.h lcUniConv/jisx0212.h \
- lcUniConv/koi8_c.h lcUniConv/koi8_r.h lcUniConv/koi8_u.h \
- lcUniConv/ksc5601.h lcUniConv/mulelao.h lcUniConv/tatar_cyr.h \
- lcUniConv/tcvn.h lcUniConv/tis620.h lcUniConv/ucs2be.h \
- lcUniConv/utf8.h lcUniConv/viscii.h
-@XLIB_LOADABLE_I18N_TRUE@am__objects_1 = XlcDL.lo XlcSL.lo
-am_libi18n_la_OBJECTS = $(am__objects_1) XDefaultIMIF.lo \
- XDefaultOMIF.lo xim_trans.lo ICWrap.lo IMWrap.lo imKStoUCS.lo \
- lcCT.lo lcCharSet.lo lcConv.lo lcDB.lo lcDynamic.lo lcFile.lo \
- lcGeneric.lo lcInit.lo lcPrTxt.lo lcPubWrap.lo lcPublic.lo \
- lcRM.lo lcStd.lo lcTxtPr.lo lcUTF8.lo lcUtil.lo lcWrap.lo \
- mbWMProps.lo mbWrap.lo utf8WMProps.lo utf8Wrap.lo wcWrap.lo
-libi18n_la_OBJECTS = $(am_libi18n_la_OBJECTS)
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src -I$(top_builddir)/include/X11
-depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
- $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-CCLD = $(CC)
-LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo " GEN " $@;
-SOURCES = $(libi18n_la_SOURCES)
-DIST_SOURCES = $(am__libi18n_la_SOURCES_DIST)
-ETAGS = etags
-CTAGS = ctags
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = @ACLOCAL@
-ADMIN_MAN_DIR = @ADMIN_MAN_DIR@
-ADMIN_MAN_SUFFIX = @ADMIN_MAN_SUFFIX@
-AMTAR = @AMTAR@
-AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
-APP_MAN_DIR = @APP_MAN_DIR@
-APP_MAN_SUFFIX = @APP_MAN_SUFFIX@
-AR = @AR@
-AUTOCONF = @AUTOCONF@
-AUTOHEADER = @AUTOHEADER@
-AUTOMAKE = @AUTOMAKE@
-AWK = @AWK@
-BIGFONT_CFLAGS = @BIGFONT_CFLAGS@
-BIGFONT_LIBS = @BIGFONT_LIBS@
-CC = @CC@
-CCDEPMODE = @CCDEPMODE@
-CC_FOR_BUILD = @CC_FOR_BUILD@
-CFLAGS = @CFLAGS@
-CHANGELOG_CMD = @CHANGELOG_CMD@
-CPP = @CPP@
-CPPFLAGS = @CPPFLAGS@
-CWARNFLAGS = @CWARNFLAGS@
-CXX = @CXX@
-CXXCPP = @CXXCPP@
-CXXDEPMODE = @CXXDEPMODE@
-CXXFLAGS = @CXXFLAGS@
-CYGPATH_W = @CYGPATH_W@
-DEFS = @DEFS@
-DEPDIR = @DEPDIR@
-DOLT_BASH = @DOLT_BASH@
-DRIVER_MAN_DIR = @DRIVER_MAN_DIR@
-DRIVER_MAN_SUFFIX = @DRIVER_MAN_SUFFIX@
-DSYMUTIL = @DSYMUTIL@
-ECHO = @ECHO@
-ECHO_C = @ECHO_C@
-ECHO_N = @ECHO_N@
-ECHO_T = @ECHO_T@
-EGREP = @EGREP@
-EXEEXT = @EXEEXT@
-F77 = @F77@
-FFLAGS = @FFLAGS@
-FILE_MAN_DIR = @FILE_MAN_DIR@
-FILE_MAN_SUFFIX = @FILE_MAN_SUFFIX@
-GREP = @GREP@
-GROFF = @GROFF@
-I18N_MODULE_LIBS = @I18N_MODULE_LIBS@
-INSTALL = @INSTALL@
-INSTALL_CMD = @INSTALL_CMD@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-KEYSYMDEF = @KEYSYMDEF@
-LAUNCHD = @LAUNCHD@
-LDFLAGS = @LDFLAGS@
-LIBOBJS = @LIBOBJS@
-LIBS = @LIBS@
-LIBTOOL = @LIBTOOL@
-LIB_MAN_DIR = @LIB_MAN_DIR@
-LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
-LINT = @LINT@
-LINTLIB = @LINTLIB@
-LINT_FLAGS = @LINT_FLAGS@
-LN_S = @LN_S@
-LTCOMPILE = @LTCOMPILE@
-LTCXXCOMPILE = @LTCXXCOMPILE@
-LTLIBOBJS = @LTLIBOBJS@
-MAINT = @MAINT@
-MAKEINFO = @MAKEINFO@
-MALLOC_ZERO_CFLAGS = @MALLOC_ZERO_CFLAGS@
-MISC_MAN_DIR = @MISC_MAN_DIR@
-MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
-MKDIR_P = @MKDIR_P@
-NMEDIT = @NMEDIT@
-OBJEXT = @OBJEXT@
-PACKAGE = @PACKAGE@
-PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
-PACKAGE_NAME = @PACKAGE_NAME@
-PACKAGE_STRING = @PACKAGE_STRING@
-PACKAGE_TARNAME = @PACKAGE_TARNAME@
-PACKAGE_URL = @PACKAGE_URL@
-PACKAGE_VERSION = @PACKAGE_VERSION@
-PATH_SEPARATOR = @PATH_SEPARATOR@
-PERL = @PERL@
-PKG_CONFIG = @PKG_CONFIG@
-PS2PDF = @PS2PDF@
-RANLIB = @RANLIB@
-RAWCPP = @RAWCPP@
-RAWCPPFLAGS = @RAWCPPFLAGS@
-SED = @SED@
-SET_MAKE = @SET_MAKE@
-SHELL = @SHELL@
-STRIP = @STRIP@
-VERSION = @VERSION@
-WCHAR32 = @WCHAR32@
-X11_CFLAGS = @X11_CFLAGS@
-X11_DATADIR = @X11_DATADIR@
-X11_EXTRA_DEPS = @X11_EXTRA_DEPS@
-X11_LIBDIR = @X11_LIBDIR@
-X11_LIBS = @X11_LIBS@
-X11_LOCALEDATADIR = @X11_LOCALEDATADIR@
-X11_LOCALEDIR = @X11_LOCALEDIR@
-X11_LOCALELIBDIR = @X11_LOCALELIBDIR@
-XDMCP_CFLAGS = @XDMCP_CFLAGS@
-XDMCP_LIBS = @XDMCP_LIBS@
-XERRORDB = @XERRORDB@
-XKBPROTO_REQUIRES = @XKBPROTO_REQUIRES@
-XKEYSYMDB = @XKEYSYMDB@
-XLOCALEDATADIR = @XLOCALEDATADIR@
-XLOCALEDIR = @XLOCALEDIR@
-XLOCALELIBDIR = @XLOCALELIBDIR@
-XMALLOC_ZERO_CFLAGS = @XMALLOC_ZERO_CFLAGS@
-XTHREADLIB = @XTHREADLIB@
-XTHREAD_CFLAGS = @XTHREAD_CFLAGS@
-XTMALLOC_ZERO_CFLAGS = @XTMALLOC_ZERO_CFLAGS@
-abs_builddir = @abs_builddir@
-abs_srcdir = @abs_srcdir@
-abs_top_builddir = @abs_top_builddir@
-abs_top_srcdir = @abs_top_srcdir@
-ac_ct_CC = @ac_ct_CC@
-ac_ct_CXX = @ac_ct_CXX@
-ac_ct_F77 = @ac_ct_F77@
-am__include = @am__include@
-am__leading_dot = @am__leading_dot@
-am__quote = @am__quote@
-am__tar = @am__tar@
-am__untar = @am__untar@
-bindir = @bindir@
-build = @build@
-build_alias = @build_alias@
-build_cpu = @build_cpu@
-build_os = @build_os@
-build_vendor = @build_vendor@
-builddir = @builddir@
-datadir = @datadir@
-datarootdir = @datarootdir@
-docdir = @docdir@
-dvidir = @dvidir@
-exec_prefix = @exec_prefix@
-host = @host@
-host_alias = @host_alias@
-host_cpu = @host_cpu@
-host_os = @host_os@
-host_vendor = @host_vendor@
-htmldir = @htmldir@
-includedir = @includedir@
-infodir = @infodir@
-install_sh = @install_sh@
-libdir = @libdir@
-libexecdir = @libexecdir@
-localedir = @localedir@
-localstatedir = @localstatedir@
-mandir = @mandir@
-mkdir_p = @mkdir_p@
-oldincludedir = @oldincludedir@
-pdfdir = @pdfdir@
-prefix = @prefix@
-program_transform_name = @program_transform_name@
-psdir = @psdir@
-sbindir = @sbindir@
-sharedstatedir = @sharedstatedir@
-srcdir = @srcdir@
-sysconfdir = @sysconfdir@
-target_alias = @target_alias@
-top_build_prefix = @top_build_prefix@
-top_builddir = @top_builddir@
-top_srcdir = @top_srcdir@
-AM_CPPFLAGS = \
- -I$(top_srcdir)/include \
- -I$(top_srcdir)/include/X11 \
- -I$(top_builddir)/include \
- -I$(top_builddir)/include/X11 \
- -I$(top_srcdir)/src/xcms \
- -I$(top_srcdir)/src/xkb \
- -I$(top_srcdir)/src/xlibi18n \
- -I$(top_srcdir)/src \
- -D_BSD_SOURCE
-
-AM_CFLAGS = \
- $(X11_CFLAGS) \
- $(BIGFONT_CFLAGS) \
- $(XDMCP_CFLAGS) \
- $(XMALLOC_ZERO_CFLAGS)
-
-noinst_LTLIBRARIES = libi18n.la
-
-#
-# Dynamic loading code for i18n modules
-#
-@XLIB_LOADABLE_I18N_TRUE@XI18N_DL_SOURCES = \
-@XLIB_LOADABLE_I18N_TRUE@ XlcDL.c \
-@XLIB_LOADABLE_I18N_TRUE@ XlcSL.c
-
-#
-# Static interfaces to input/output methods
-#
-@XLIB_LOADABLE_I18N_FALSE@IM_LIBS = \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/im/ximcp/libximcp.la
-
-@XLIB_LOADABLE_I18N_FALSE@LC_LIBS = \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/lc/def/libxlcDef.la \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/lc/gen/libxlibi18n.la \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/lc/Utf8/libxlcUTF8Load.la \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/lc/xlocale/libxlocale.la
-
-@XLIB_LOADABLE_I18N_FALSE@OM_LIBS = \
-@XLIB_LOADABLE_I18N_FALSE@ ${top_builddir}/modules/om/generic/libxomGeneric.la
-
-libi18n_la_LIBADD = \
- $(IM_LIBS) $(LC_LIBS) $(OM_LIBS)
-
-libi18n_la_SOURCES = \
- $(XI18N_DL_SOURCES) \
- XDefaultIMIF.c \
- XDefaultOMIF.c \
- xim_trans.c\
- ICWrap.c\
- IMWrap.c\
- imKStoUCS.c\
- lcCT.c\
- lcCharSet.c\
- lcConv.c\
- lcDB.c\
- lcDynamic.c\
- lcFile.c\
- lcGeneric.c\
- lcInit.c\
- lcPrTxt.c\
- lcPubWrap.c\
- lcPublic.c\
- lcRM.c\
- lcStd.c\
- lcTxtPr.c\
- lcUTF8.c\
- lcUtil.c\
- lcWrap.c\
- mbWMProps.c\
- mbWrap.c\
- utf8WMProps.c\
- utf8Wrap.c\
- wcWrap.c\
- Xaixlcint.h\
- XimImSw.h\
- XimProto.h\
- XimThai.h\
- XimTrInt.h\
- XimTrX.h\
- XimTrans.h\
- Ximint.h\
- XimintL.h\
- XimintP.h\
- XlcGeneric.h\
- XlcPubI.h\
- XlcPublic.h\
- Xlcint.h\
- lcUniConv/armscii_8.h\
- lcUniConv/ascii.h\
- lcUniConv/big5.h\
- lcUniConv/big5_emacs.h\
- lcUniConv/big5hkscs.h\
- lcUniConv/cp1133.h\
- lcUniConv/cp1251.h\
- lcUniConv/cp1255.h\
- lcUniConv/cp1256.h\
- lcUniConv/gb2312.h\
- lcUniConv/gbk.h\
- lcUniConv/georgian_academy.h\
- lcUniConv/georgian_ps.h\
- lcUniConv/iso8859_1.h\
- lcUniConv/iso8859_10.h\
- lcUniConv/iso8859_11.h\
- lcUniConv/iso8859_13.h\
- lcUniConv/iso8859_14.h\
- lcUniConv/iso8859_15.h\
- lcUniConv/iso8859_16.h\
- lcUniConv/iso8859_2.h\
- lcUniConv/iso8859_3.h\
- lcUniConv/iso8859_4.h\
- lcUniConv/iso8859_5.h\
- lcUniConv/iso8859_6.h\
- lcUniConv/iso8859_7.h\
- lcUniConv/iso8859_8.h\
- lcUniConv/iso8859_9.h\
- lcUniConv/iso8859_9e.h\
- lcUniConv/jisx0201.h\
- lcUniConv/jisx0208.h\
- lcUniConv/jisx0212.h\
- lcUniConv/koi8_c.h\
- lcUniConv/koi8_r.h\
- lcUniConv/koi8_u.h\
- lcUniConv/ksc5601.h\
- lcUniConv/mulelao.h\
- lcUniConv/tatar_cyr.h\
- lcUniConv/tcvn.h\
- lcUniConv/tis620.h\
- lcUniConv/ucs2be.h\
- lcUniConv/utf8.h\
- lcUniConv/viscii.h
-
-EXTRA_DIST = \
- lcUniConv/README \
- lcUniConv/COPYRIGHT \
- lcUniConv/8bit_tab_to_h.c \
- lcUniConv/cjk_tab_to_h.c
-
-
-# Check source code with tools like lint & sparse
-@LINT_TRUE@ALL_LINT_FLAGS = $(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
-@LINT_TRUE@ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS)
-
-all: all-am
-
-.SUFFIXES:
-.SUFFIXES: .c .lo .o .obj
-$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/xlibi18n/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/xlibi18n/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-clean-noinstLTLIBRARIES:
- -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
- @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-libi18n.la: $(libi18n_la_OBJECTS) $(libi18n_la_DEPENDENCIES)
- $(AM_V_CCLD)$(LINK) $(libi18n_la_OBJECTS) $(libi18n_la_LIBADD) $(LIBS)
-
-mostlyclean-compile:
- -rm -f *.$(OBJEXT)
-
-distclean-compile:
- -rm -f *.tab.c
-
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ICWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IMWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XDefaultIMIF.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XDefaultOMIF.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XlcDL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XlcSL.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/imKStoUCS.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcCT.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcCharSet.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcConv.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcDB.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcDynamic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcFile.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcGeneric.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcInit.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcPrTxt.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcPubWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcPublic.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcRM.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcStd.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcTxtPr.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcUTF8.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcUtil.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lcWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbWMProps.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8WMProps.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8Wrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wcWrap.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xim_trans.Plo@am__quote@
-
-.c.o:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c $<
-
-.c.obj:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
-
-.c.lo:
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
-@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- set x; \
- here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- shift; \
- if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
- test -n "$$unique" || unique=$$empty_fix; \
- if test $$# -gt 0; then \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- "$$@" $$unique; \
- else \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$unique; \
- fi; \
- fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$unique" \
- || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$unique
-
-GTAGS:
- here=`$(am__cd) $(top_builddir) && pwd` \
- && $(am__cd) $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) "$$here"
-
-distclean-tags:
- -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
-check-am: all-am
-check: check-am
-all-am: Makefile $(LTLIBRARIES)
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
- mostlyclean-am
-
-distclean: distclean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
- distclean-tags
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic \
- mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-noinstLTLIBRARIES ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
- pdf pdf-am ps ps-am tags uninstall uninstall-am
-
-
-@LINT_TRUE@lint:
-@LINT_TRUE@ $(LINT) $(ALL_LINT_FLAGS) $(libi18n_la_SOURCES)
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
diff --git a/libX11/src/xlibi18n/lcUTF8.c b/libX11/src/xlibi18n/lcUTF8.c
index 7649bdbf4..5e47f23bb 100644
--- a/libX11/src/xlibi18n/lcUTF8.c
+++ b/libX11/src/xlibi18n/lcUTF8.c
@@ -1,2390 +1,2390 @@
-/******************************************************************
-
- Copyright 1993 by SunSoft, Inc.
- Copyright 1999-2000 by Bruno Haible
-
-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 names of SunSoft, Inc. and
-Bruno Haible not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior
-permission. SunSoft, Inc. and Bruno Haible make no representations
-about the suitability of this software for any purpose. It is
-provided "as is" without express or implied warranty.
-
-SunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
-TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible 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.
-
-******************************************************************/
-
-/*
- * This file contains:
- *
- * I. Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
- *
- * Used for three purposes:
- * 1. The UTF-8 locales, see below.
- * 2. Unicode aware applications for which the use of 8-bit character
- * sets is an anachronism.
- * 3. For conversion from keysym to locale encoding.
- *
- * II. Conversion files for an UTF-8 locale loader.
- * Supports: all locales with codeset UTF-8.
- * How: Provides converters for UTF-8.
- * Platforms: all systems.
- *
- * The loader itself is located in lcUTF8.c.
- */
-
-/*
- * The conversion from UTF-8 to CompoundText is realized in a very
- * conservative way. Recall that CompoundText data is used for inter-client
- * communication purposes. We distinguish three classes of clients:
- * - Clients which accept only those pieces of CompoundText which belong to
- * the character set understood by the current locale.
- * (Example: clients which are linked to an older X11 library.)
- * - Clients which accept CompoundText with multiple character sets and parse
- * it themselves.
- * (Example: emacs, xemacs.)
- * - Clients which rely entirely on the X{mb,wc}TextPropertyToTextList
- * functions for the conversion of CompoundText to their current locale's
- * multi-byte/wide-character format.
- * For best interoperation, the UTF-8 to CompoundText conversion proceeds as
- * follows. For every character, it first tests whether the character is
- * representable in the current locale's original (non-UTF-8) character set.
- * If not, it goes through the list of predefined character sets for
- * CompoundText and tests if the character is representable in that character
- * set. If so, it encodes the character using its code within that character
- * set. If not, it uses an UTF-8-in-CompoundText encapsulation. Since
- * clients of the first and second kind ignore such encapsulated text,
- * this encapsulation is kept to a minimum and terminated as early as possible.
- *
- * In a distant future, when clients of the first and second kind will have
- * disappeared, we will be able to stuff UTF-8 data directly in CompoundText
- * without first going through the list of predefined character sets.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include "Xlibint.h"
-#include "XlcPubI.h"
-#include "XlcGeneric.h"
-
-static XlcConv
-create_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
- if (conv == (XlcConv) NULL)
- return (XlcConv) NULL;
-
- conv->methods = methods;
- conv->state = NULL;
-
- return conv;
-}
-
-static void
-close_converter(
- XlcConv conv)
-{
- Xfree((char *) conv);
-}
-
-/* Replacement character for invalid multibyte sequence or wide character. */
-#define BAD_WCHAR ((ucs4_t) 0xfffd)
-#define BAD_CHAR '?'
-
-/***************************************************************************/
-/* Part I: Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
- *
- * Note that this code works in any locale. We store Unicode values in
- * `ucs4_t' variables, but don't pass them to the user.
- *
- * This code has to support all character sets that are used for CompoundText,
- * nothing more, nothing less. See the table in lcCT.c.
- * Since the conversion _to_ CompoundText is likely to need the tables for all
- * character sets at once, we don't use dynamic loading (of tables or shared
- * libraries through iconv()). Use a fixed set of tables instead.
- *
- * We use statically computed tables, not dynamically allocated arrays,
- * because it's more memory efficient: Different processes using the same
- * libX11 shared library share the "text" and read-only "data" sections.
- */
-
-typedef unsigned int ucs4_t;
-#define conv_t XlcConv
-
-typedef struct _Utf8ConvRec {
- const char *name;
- XrmQuark xrm_name;
- int (* cstowc) (XlcConv, ucs4_t *, unsigned char const *, int);
- int (* wctocs) (XlcConv, unsigned char *, ucs4_t, int);
-} Utf8ConvRec, *Utf8Conv;
-
-/*
- * int xxx_cstowc (XlcConv conv, ucs4_t *pwc, unsigned char const *s, int n)
- * converts the byte sequence starting at s to a wide character. Up to n bytes
- * are available at s. n is >= 1.
- * Result is number of bytes consumed (if a wide character was read),
- * or 0 if invalid, or -1 if n too small.
- *
- * int xxx_wctocs (XlcConv conv, unsigned char *r, ucs4_t wc, int n)
- * converts the wide character wc to the character set xxx, and stores the
- * result beginning at r. Up to n bytes may be written at r. n is >= 1.
- * Result is number of bytes written, or 0 if invalid, or -1 if n too small.
- */
-
-/* Return code if invalid. (xxx_mbtowc, xxx_wctomb) */
-#define RET_ILSEQ 0
-/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */
-#define RET_TOOFEW(n) (-1-(n))
-/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */
-#define RET_TOOSMALL -1
-
-/*
- * The tables below are bijective. It would be possible to extend the
- * xxx_wctocs tables to do some transliteration (e.g. U+201C,U+201D -> 0x22)
- * but *only* with characters not contained in any other table, and *only*
- * when the current locale is not an UTF-8 locale.
- */
-
-#include "lcUniConv/utf8.h"
-#include "lcUniConv/ucs2be.h"
-#ifdef notused
-#include "lcUniConv/ascii.h"
-#endif
-#include "lcUniConv/iso8859_1.h"
-#include "lcUniConv/iso8859_2.h"
-#include "lcUniConv/iso8859_3.h"
-#include "lcUniConv/iso8859_4.h"
-#include "lcUniConv/iso8859_5.h"
-#include "lcUniConv/iso8859_6.h"
-#include "lcUniConv/iso8859_7.h"
-#include "lcUniConv/iso8859_8.h"
-#include "lcUniConv/iso8859_9.h"
-#include "lcUniConv/iso8859_10.h"
-#include "lcUniConv/iso8859_11.h"
-#include "lcUniConv/iso8859_13.h"
-#include "lcUniConv/iso8859_14.h"
-#include "lcUniConv/iso8859_15.h"
-#include "lcUniConv/iso8859_16.h"
-#include "lcUniConv/iso8859_9e.h"
-#include "lcUniConv/jisx0201.h"
-#include "lcUniConv/tis620.h"
-#include "lcUniConv/koi8_r.h"
-#include "lcUniConv/koi8_u.h"
-#include "lcUniConv/koi8_c.h"
-#include "lcUniConv/armscii_8.h"
-#include "lcUniConv/cp1133.h"
-#include "lcUniConv/mulelao.h"
-#include "lcUniConv/viscii.h"
-#include "lcUniConv/tcvn.h"
-#include "lcUniConv/georgian_academy.h"
-#include "lcUniConv/georgian_ps.h"
-#include "lcUniConv/cp1251.h"
-#include "lcUniConv/cp1255.h"
-#include "lcUniConv/cp1256.h"
-#include "lcUniConv/tatar_cyr.h"
-
-typedef struct {
- unsigned short indx; /* index into big table */
- unsigned short used; /* bitmask of used entries */
-} Summary16;
-
-#include "lcUniConv/gb2312.h"
-#include "lcUniConv/jisx0208.h"
-#include "lcUniConv/jisx0212.h"
-#include "lcUniConv/ksc5601.h"
-#include "lcUniConv/big5.h"
-#include "lcUniConv/big5_emacs.h"
-#include "lcUniConv/big5hkscs.h"
-#include "lcUniConv/gbk.h"
-
-static Utf8ConvRec all_charsets[] = {
- /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
- (for lookup speed), once at the end (as a fallback). */
- { "ISO10646-1", NULLQUARK,
- utf8_mbtowc, utf8_wctomb
- },
-
- { "ISO8859-1", NULLQUARK,
- iso8859_1_mbtowc, iso8859_1_wctomb
- },
- { "ISO8859-2", NULLQUARK,
- iso8859_2_mbtowc, iso8859_2_wctomb
- },
- { "ISO8859-3", NULLQUARK,
- iso8859_3_mbtowc, iso8859_3_wctomb
- },
- { "ISO8859-4", NULLQUARK,
- iso8859_4_mbtowc, iso8859_4_wctomb
- },
- { "ISO8859-5", NULLQUARK,
- iso8859_5_mbtowc, iso8859_5_wctomb
- },
- { "ISO8859-6", NULLQUARK,
- iso8859_6_mbtowc, iso8859_6_wctomb
- },
- { "ISO8859-7", NULLQUARK,
- iso8859_7_mbtowc, iso8859_7_wctomb
- },
- { "ISO8859-8", NULLQUARK,
- iso8859_8_mbtowc, iso8859_8_wctomb
- },
- { "ISO8859-9", NULLQUARK,
- iso8859_9_mbtowc, iso8859_9_wctomb
- },
- { "ISO8859-10", NULLQUARK,
- iso8859_10_mbtowc, iso8859_10_wctomb
- },
- { "ISO8859-11", NULLQUARK,
- iso8859_11_mbtowc, iso8859_11_wctomb
- },
- { "ISO8859-13", NULLQUARK,
- iso8859_13_mbtowc, iso8859_13_wctomb
- },
- { "ISO8859-14", NULLQUARK,
- iso8859_14_mbtowc, iso8859_14_wctomb
- },
- { "ISO8859-15", NULLQUARK,
- iso8859_15_mbtowc, iso8859_15_wctomb
- },
- { "ISO8859-16", NULLQUARK,
- iso8859_16_mbtowc, iso8859_16_wctomb
- },
- { "JISX0201.1976-0", NULLQUARK,
- jisx0201_mbtowc, jisx0201_wctomb
- },
- { "TIS620-0", NULLQUARK,
- tis620_mbtowc, tis620_wctomb
- },
- { "GB2312.1980-0", NULLQUARK,
- gb2312_mbtowc, gb2312_wctomb
- },
- { "JISX0208.1983-0", NULLQUARK,
- jisx0208_mbtowc, jisx0208_wctomb
- },
- { "JISX0208.1990-0", NULLQUARK,
- jisx0208_mbtowc, jisx0208_wctomb
- },
- { "JISX0212.1990-0", NULLQUARK,
- jisx0212_mbtowc, jisx0212_wctomb
- },
- { "KSC5601.1987-0", NULLQUARK,
- ksc5601_mbtowc, ksc5601_wctomb
- },
- { "KOI8-R", NULLQUARK,
- koi8_r_mbtowc, koi8_r_wctomb
- },
- { "KOI8-U", NULLQUARK,
- koi8_u_mbtowc, koi8_u_wctomb
- },
- { "KOI8-C", NULLQUARK,
- koi8_c_mbtowc, koi8_c_wctomb
- },
- { "TATAR-CYR", NULLQUARK,
- tatar_cyr_mbtowc, tatar_cyr_wctomb
- },
- { "ARMSCII-8", NULLQUARK,
- armscii_8_mbtowc, armscii_8_wctomb
- },
- { "IBM-CP1133", NULLQUARK,
- cp1133_mbtowc, cp1133_wctomb
- },
- { "MULELAO-1", NULLQUARK,
- mulelao_mbtowc, mulelao_wctomb
- },
- { "VISCII1.1-1", NULLQUARK,
- viscii_mbtowc, viscii_wctomb
- },
- { "TCVN-5712", NULLQUARK,
- tcvn_mbtowc, tcvn_wctomb
- },
- { "GEORGIAN-ACADEMY", NULLQUARK,
- georgian_academy_mbtowc, georgian_academy_wctomb
- },
- { "GEORGIAN-PS", NULLQUARK,
- georgian_ps_mbtowc, georgian_ps_wctomb
- },
- { "ISO8859-9E", NULLQUARK,
- iso8859_9e_mbtowc, iso8859_9e_wctomb
- },
- { "MICROSOFT-CP1251", NULLQUARK,
- cp1251_mbtowc, cp1251_wctomb
- },
- { "MICROSOFT-CP1255", NULLQUARK,
- cp1255_mbtowc, cp1255_wctomb
- },
- { "MICROSOFT-CP1256", NULLQUARK,
- cp1256_mbtowc, cp1256_wctomb
- },
- { "BIG5-0", NULLQUARK,
- big5_mbtowc, big5_wctomb
- },
- { "BIG5-E0", NULLQUARK,
- big5_0_mbtowc, big5_0_wctomb
- },
- { "BIG5-E1", NULLQUARK,
- big5_1_mbtowc, big5_1_wctomb
- },
- { "GBK-0", NULLQUARK,
- gbk_mbtowc, gbk_wctomb
- },
- { "BIG5HKSCS-0", NULLQUARK,
- big5hkscs_mbtowc, big5hkscs_wctomb
- },
-
- /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
- (for lookup speed), once at the end (as a fallback). */
- { "ISO10646-1", NULLQUARK,
- utf8_mbtowc, utf8_wctomb
- },
-
- /* Encoding ISO10646-1 for fonts means UCS2-like encoding
- so for conversion to FontCharSet we need this record */
- { "ISO10646-1", NULLQUARK,
- ucs2be_mbtowc, ucs2be_wctomb
- }
-};
-
-#define charsets_table_size (sizeof(all_charsets)/sizeof(all_charsets[0]))
-#define all_charsets_count (charsets_table_size - 1)
-#define ucs2_conv_index (charsets_table_size - 1)
-
-static void
-init_all_charsets (void)
-{
- Utf8Conv convptr;
- int i;
-
- for (convptr = all_charsets, i = charsets_table_size; i > 0; convptr++, i--)
- convptr->xrm_name = XrmStringToQuark(convptr->name);
-}
-
-#define lazy_init_all_charsets() \
- do { \
- if (all_charsets[0].xrm_name == NULLQUARK) \
- init_all_charsets(); \
- } while (0)
-
-/* from XlcNCharSet to XlcNUtf8String */
-
-static int
-cstoutf8(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XlcCharSet charset;
- const char *name;
- Utf8Conv convptr;
- int i;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- if (num_args < 1)
- return -1;
-
- charset = (XlcCharSet) args[0];
- name = charset->encoding_name;
- /* not charset->name because the latter has a ":GL"/":GR" suffix */
-
- for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
- if (!strcmp(convptr->name, name))
- break;
- if (i == 0)
- return -1;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- ucs4_t wc;
- int consumed;
- int count;
-
- consumed = convptr->cstowc(conv, &wc, src, srcend-src);
- if (consumed == RET_ILSEQ)
- return -1;
- if (consumed == RET_TOOFEW(0))
- break;
-
- count = utf8_wctomb(NULL, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- unconv_num++;
- }
- src += consumed;
- dst += count;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_cstoutf8 = {
- close_converter,
- cstoutf8,
- NULL
-};
-
-static XlcConv
-open_cstoutf8(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- lazy_init_all_charsets();
- return create_conv(from_lcd, &methods_cstoutf8);
-}
-
-/* from XlcNUtf8String to XlcNCharSet */
-
-static XlcConv
-create_tocs_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
- CodeSet *codeset_list;
- int codeset_num;
- int charset_num;
- int i, j, k;
- Utf8Conv *preferred;
-
- lazy_init_all_charsets();
-
- codeset_list = XLC_GENERIC(lcd, codeset_list);
- codeset_num = XLC_GENERIC(lcd, codeset_num);
-
- charset_num = 0;
- for (i = 0; i < codeset_num; i++)
- charset_num += codeset_list[i]->num_charsets;
- if (charset_num > all_charsets_count-1)
- charset_num = all_charsets_count-1;
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)
- + (charset_num + 1) * sizeof(Utf8Conv));
- if (conv == (XlcConv) NULL)
- return (XlcConv) NULL;
- preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
-
- /* Loop through all codesets mentioned in the locale. */
- charset_num = 0;
- for (i = 0; i < codeset_num; i++) {
- XlcCharSet *charsets = codeset_list[i]->charset_list;
- int num_charsets = codeset_list[i]->num_charsets;
- for (j = 0; j < num_charsets; j++) {
- const char *name = charsets[j]->encoding_name;
- /* If it wasn't already encountered... */
- for (k = charset_num-1; k >= 0; k--)
- if (!strcmp(preferred[k]->name, name))
- break;
- if (k < 0) {
- /* Look it up in all_charsets[]. */
- for (k = 0; k < all_charsets_count-1; k++)
- if (!strcmp(all_charsets[k].name, name)) {
- /* Add it to the preferred set. */
- preferred[charset_num++] = &all_charsets[k];
- break;
- }
- }
- }
- }
- preferred[charset_num] = (Utf8Conv) NULL;
-
- conv->methods = methods;
- conv->state = (XPointer) preferred;
-
- return conv;
-}
-
-static void
-close_tocs_converter(
- XlcConv conv)
-{
- /* conv->state is allocated together with conv, free both at once. */
- Xfree((char *) conv);
-}
-
-/*
- * Converts a Unicode character to an appropriate character set. The NULL
- * terminated array of preferred character sets is passed as first argument.
- * If successful, *charsetp is set to the character set that was used, and
- * *sidep is set to the character set side (XlcGL or XlcGR).
- */
-static int
-charset_wctocs(
- Utf8Conv *preferred,
- Utf8Conv *charsetp,
- XlcSide *sidep,
- XlcConv conv,
- unsigned char *r,
- ucs4_t wc,
- int n)
-{
- int count;
- Utf8Conv convptr;
- int i;
-
- for (; *preferred != (Utf8Conv) NULL; preferred++) {
- convptr = *preferred;
- count = convptr->wctocs(conv, r, wc, n);
- if (count == RET_TOOSMALL)
- return RET_TOOSMALL;
- if (count != RET_ILSEQ) {
- *charsetp = convptr;
- *sidep = (*r < 0x80 ? XlcGL : XlcGR);
- return count;
- }
- }
- for (convptr = all_charsets+1, i = all_charsets_count-1; i > 0; convptr++, i--) {
- count = convptr->wctocs(conv, r, wc, n);
- if (count == RET_TOOSMALL)
- return RET_TOOSMALL;
- if (count != RET_ILSEQ) {
- *charsetp = convptr;
- *sidep = (*r < 0x80 ? XlcGL : XlcGR);
- return count;
- }
- }
- return RET_ILSEQ;
-}
-
-static int
-utf8tocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- ucs4_t wc;
- int consumed;
- int count;
-
- consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
- if (consumed == RET_TOOFEW(0))
- break;
- if (consumed == RET_ILSEQ) {
- src++;
- unconv_num++;
- continue;
- }
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src += consumed;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src += consumed;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src += consumed;
- dst += count;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_utf8tocs = {
- close_tocs_converter,
- utf8tocs,
- NULL
-};
-
-static XlcConv
-open_utf8tocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tocs_conv(from_lcd, &methods_utf8tocs);
-}
-
-/* from XlcNUtf8String to XlcNChar */
-
-static int
-utf8tocs1(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- ucs4_t wc;
- int consumed;
- int count;
-
- consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
- if (consumed == RET_TOOFEW(0))
- break;
- if (consumed == RET_ILSEQ) {
- src++;
- unconv_num++;
- continue;
- }
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src += consumed;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src += consumed;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src += consumed;
- dst += count;
- break;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_utf8tocs1 = {
- close_tocs_converter,
- utf8tocs1,
- NULL
-};
-
-static XlcConv
-open_utf8tocs1(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tocs_conv(from_lcd, &methods_utf8tocs1);
-}
-
-/* from XlcNUtf8String to XlcNString */
-
-static int
-utf8tostr(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- unsigned char c;
- ucs4_t wc;
- int consumed;
-
- consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
- if (consumed == RET_TOOFEW(0))
- break;
- if (dst == dstend)
- break;
- if (consumed == RET_ILSEQ) {
- consumed = 1;
- c = BAD_CHAR;
- unconv_num++;
- } else {
- if ((wc & ~(ucs4_t)0xff) != 0) {
- c = BAD_CHAR;
- unconv_num++;
- } else
- c = (unsigned char) wc;
- }
- *dst++ = c;
- src += consumed;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_utf8tostr = {
- close_converter,
- utf8tostr,
- NULL
-};
-
-static XlcConv
-open_utf8tostr(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_utf8tostr);
-}
-
-/* from XlcNString to XlcNUtf8String */
-
-static int
-strtoutf8(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
-
- while (src < srcend) {
- int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- dst += count;
- src++;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return 0;
-}
-
-static XlcConvMethodsRec methods_strtoutf8 = {
- close_converter,
- strtoutf8,
- NULL
-};
-
-static XlcConv
-open_strtoutf8(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_strtoutf8);
-}
-
-/* Support for the input methods. */
-
-XPointer
-_Utf8GetConvByName(
- const char *name)
-{
- XrmQuark xrm_name;
- Utf8Conv convptr;
- int i;
-
- if (name == NULL)
- return (XPointer) NULL;
-
- lazy_init_all_charsets();
- xrm_name = XrmStringToQuark(name);
-
- for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
- if (convptr->xrm_name == xrm_name)
- return (XPointer) convptr->wctocs;
- return (XPointer) NULL;
-}
-
-/* from XlcNUcsChar to XlcNChar, needed for input methods */
-
-static XlcConv
-create_ucstocs_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
-
- if (XLC_PUBLIC_PART(lcd)->codeset
- && _XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8") == 0) {
- XlcConv conv;
- Utf8Conv *preferred;
-
- lazy_init_all_charsets();
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
- if (conv == (XlcConv) NULL)
- return (XlcConv) NULL;
- preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
-
- preferred[0] = &all_charsets[0]; /* ISO10646 */
- preferred[1] = (Utf8Conv) NULL;
-
- conv->methods = methods;
- conv->state = (XPointer) preferred;
-
- return conv;
- } else {
- return create_tocs_conv(lcd, methods);
- }
-}
-
-static int
-charset_wctocs_exactly(
- Utf8Conv *preferred,
- Utf8Conv *charsetp,
- XlcSide *sidep,
- XlcConv conv,
- unsigned char *r,
- ucs4_t wc,
- int n)
-{
- int count;
- Utf8Conv convptr;
-
- for (; *preferred != (Utf8Conv) NULL; preferred++) {
- convptr = *preferred;
- count = convptr->wctocs(conv, r, wc, n);
- if (count == RET_TOOSMALL)
- return RET_TOOSMALL;
- if (count != RET_ILSEQ) {
- *charsetp = convptr;
- *sidep = (*r < 0x80 ? XlcGL : XlcGR);
- return count;
- }
- }
- return RET_ILSEQ;
-}
-
-static int
-ucstocs1(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- ucs4_t const *src = (ucs4_t const *) *from;
- unsigned char *dst = (unsigned char *) *to;
- int unconv_num = 0;
- Utf8Conv *preferred_charsets = (Utf8Conv *) conv->state;
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- XlcCharSet charset = NULL;
- int count;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- count = charset_wctocs_exactly(preferred_charsets, &chosen_charset,
- &chosen_side, conv, dst, *src, *to_left);
- if (count < 1) {
- unconv_num++;
- count = 0;
- } else {
- charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- }
- if (charset == NULL)
- return -1;
-
- *from = (XPointer) ++src;
- (*from_left)--;
- *to = (XPointer) dst;
- *to_left -= count;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_ucstocs1 = {
- close_tocs_converter,
- ucstocs1,
- NULL
-};
-
-static XlcConv
-open_ucstocs1(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_ucstocs_conv(from_lcd, &methods_ucstocs1);
-}
-
-/* from XlcNUcsChar to XlcNUtf8String, needed for input methods */
-
-static int
-ucstoutf8(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- const ucs4_t *src;
- const ucs4_t *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (const ucs4_t *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ)
- unconv_num++;
- src++;
- dst += count;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_ucstoutf8 = {
- close_converter,
- ucstoutf8,
- NULL
-};
-
-static XlcConv
-open_ucstoutf8(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_ucstoutf8);
-}
-
-/* Registers UTF-8 converters for a non-UTF-8 locale. */
-void
-_XlcAddUtf8Converters(
- XLCd lcd)
-{
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String, open_cstoutf8);
- _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNCharSet, open_utf8tocs);
- _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNChar, open_utf8tocs1);
- _XlcSetConverter(lcd, XlcNString, lcd, XlcNUtf8String, open_strtoutf8);
- _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNString, open_utf8tostr);
- _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNChar, open_ucstocs1);
- _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String, open_ucstoutf8);
-}
-
-/***************************************************************************/
-/* Part II: UTF-8 locale loader conversion files
- *
- * Here we can assume that "multi-byte" is UTF-8 and that `wchar_t' is Unicode.
- */
-
-/* from XlcNMultiByte to XlcNWideChar */
-
-static int
-utf8towcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- wchar_t *dst;
- wchar_t *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (wchar_t *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- ucs4_t wc;
- int consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
- if (consumed == RET_TOOFEW(0))
- break;
- if (consumed == RET_ILSEQ) {
- src++;
- *dst = BAD_WCHAR;
- unconv_num++;
- } else {
- src += consumed;
- *dst = wc;
- }
- dst++;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_utf8towcs = {
- close_converter,
- utf8towcs,
- NULL
-};
-
-static XlcConv
-open_utf8towcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_utf8towcs);
-}
-
-/* from XlcNWideChar to XlcNMultiByte */
-
-static int
-wcstoutf8(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- wchar_t const *src;
- wchar_t const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (wchar_t const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- unconv_num++;
- }
- dst += count;
- src++;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_wcstoutf8 = {
- close_converter,
- wcstoutf8,
- NULL
-};
-
-static XlcConv
-open_wcstoutf8(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_wcstoutf8);
-}
-
-/* from XlcNString to XlcNWideChar */
-
-static int
-our_strtowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- wchar_t *dst;
- wchar_t *dstend;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (wchar_t *) *to;
- dstend = dst + *to_left;
-
- while (src < srcend && dst < dstend)
- *dst++ = (wchar_t) *src++;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return 0;
-}
-
-static XlcConvMethodsRec methods_strtowcs = {
- close_converter,
- our_strtowcs,
- NULL
-};
-
-static XlcConv
-open_strtowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_strtowcs);
-}
-
-/* from XlcNWideChar to XlcNString */
-
-static int
-our_wcstostr(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- wchar_t const *src;
- wchar_t const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (wchar_t const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- unsigned int wc = *src++;
- if (wc < 0x80)
- *dst = wc;
- else {
- *dst = BAD_CHAR;
- unconv_num++;
- }
- dst++;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_wcstostr = {
- close_converter,
- our_wcstostr,
- NULL
-};
-
-static XlcConv
-open_wcstostr(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_wcstostr);
-}
-
-/* from XlcNCharSet to XlcNWideChar */
-
-static int
-cstowcs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- XlcCharSet charset;
- const char *name;
- Utf8Conv convptr;
- int i;
- unsigned char const *src;
- unsigned char const *srcend;
- wchar_t *dst;
- wchar_t *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- if (num_args < 1)
- return -1;
-
- charset = (XlcCharSet) args[0];
- name = charset->encoding_name;
- /* not charset->name because the latter has a ":GL"/":GR" suffix */
-
- for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
- if (!strcmp(convptr->name, name))
- break;
- if (i == 0)
- return -1;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (wchar_t *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- unsigned int wc;
- int consumed;
-
- consumed = convptr->cstowc(conv, &wc, src, srcend-src);
- if (consumed == RET_ILSEQ)
- return -1;
- if (consumed == RET_TOOFEW(0))
- break;
-
- *dst++ = wc;
- src += consumed;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_cstowcs = {
- close_converter,
- cstowcs,
- NULL
-};
-
-static XlcConv
-open_cstowcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- lazy_init_all_charsets();
- return create_conv(from_lcd, &methods_cstowcs);
-}
-
-/* from XlcNWideChar to XlcNCharSet */
-
-static int
-wcstocs(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- wchar_t const *src;
- wchar_t const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (wchar_t const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- wchar_t wc = *src;
- int count;
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src++;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src++;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src++;
- dst += count;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_wcstocs = {
- close_tocs_converter,
- wcstocs,
- NULL
-};
-
-static XlcConv
-open_wcstocs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tocs_conv(from_lcd, &methods_wcstocs);
-}
-
-/* from XlcNWideChar to XlcNChar */
-
-static int
-wcstocs1(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- wchar_t const *src;
- wchar_t const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (wchar_t const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- wchar_t wc = *src;
- int count;
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src++;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src++;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src++;
- dst += count;
- break;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec methods_wcstocs1 = {
- close_tocs_converter,
- wcstocs1,
- NULL
-};
-
-static XlcConv
-open_wcstocs1(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tocs_conv(from_lcd, &methods_wcstocs1);
-}
-
-/* trivial, no conversion */
-
-static int
-identity(
- XlcConv conv,
- XPointer *from,
- int *from_left,
- XPointer *to,
- int *to_left,
- XPointer *args,
- int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
-
- while (src < srcend && dst < dstend)
- *dst++ = *src++;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return 0;
-}
-
-static XlcConvMethodsRec methods_identity = {
- close_converter,
- identity,
- NULL
-};
-
-static XlcConv
-open_identity(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_conv(from_lcd, &methods_identity);
-}
-
-/* from MultiByte/WideChar to FontCharSet. */
-/* They really use converters to CharSet
- * but with different create_conv procedure. */
-
-static XlcConv
-create_tofontcs_conv(
- XLCd lcd,
- XlcConvMethods methods)
-{
- XlcConv conv;
- int i, num, k, count;
- char **value, buf[20];
- Utf8Conv *preferred;
-
- lazy_init_all_charsets();
-
- for (i = 0, num = 0;; i++) {
- sprintf(buf, "fs%d.charset.name", i);
- _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
- if (count < 1) {
- sprintf(buf, "fs%d.charset", i);
- _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
- if (count < 1)
- break;
- }
- num += count;
- }
-
- conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
- if (conv == (XlcConv) NULL)
- return (XlcConv) NULL;
- preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
-
- /* Loop through all fontsets mentioned in the locale. */
- for (i = 0, num = 0;; i++) {
- sprintf(buf, "fs%d.charset.name", i);
- _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
- if (count < 1) {
- sprintf(buf, "fs%d.charset", i);
- _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
- if (count < 1)
- break;
- }
- while (count-- > 0) {
- XlcCharSet charset = _XlcGetCharSet(*value++);
- const char *name;
-
- if (charset == (XlcCharSet) NULL)
- continue;
-
- name = charset->encoding_name;
- /* If it wasn't already encountered... */
- for (k = num - 1; k >= 0; k--)
- if (!strcmp(preferred[k]->name, name))
- break;
- if (k < 0) {
- /* For fonts "ISO10646-1" means ucs2, not utf8.*/
- if (!strcmp("ISO10646-1", name)) {
- preferred[num++] = &all_charsets[ucs2_conv_index];
- continue;
- }
- /* Look it up in all_charsets[]. */
- for (k = 0; k < all_charsets_count-1; k++)
- if (!strcmp(all_charsets[k].name, name)) {
- /* Add it to the preferred set. */
- preferred[num++] = &all_charsets[k];
- break;
- }
- }
- }
- }
- preferred[num] = (Utf8Conv) NULL;
-
- conv->methods = methods;
- conv->state = (XPointer) preferred;
-
- return conv;
-}
-
-static XlcConv
-open_wcstofcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tofontcs_conv(from_lcd, &methods_wcstocs);
-}
-
-static XlcConv
-open_utf8tofcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tofontcs_conv(from_lcd, &methods_utf8tocs);
-}
-
-/* ========================== iconv Stuff ================================ */
-
-/* from XlcNCharSet to XlcNMultiByte */
-
-static int
-iconv_cstombs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- XlcCharSet charset;
- const char *name;
- Utf8Conv convptr;
- int i;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- if (num_args < 1)
- return -1;
-
- charset = (XlcCharSet) args[0];
- name = charset->encoding_name;
- /* not charset->name because the latter has a ":GL"/":GR" suffix */
-
- for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
- if (!strcmp(convptr->name, name))
- break;
- if (i == 0)
- return -1;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- ucs4_t wc;
- int consumed;
- int count;
-
- consumed = convptr->cstowc(conv, &wc, src, srcend-src);
- if (consumed == RET_ILSEQ)
- return -1;
- if (consumed == RET_TOOFEW(0))
- break;
-
- /* Use stdc iconv to convert widechar -> multibyte */
-
- count = wctomb(dst, wc);
- if (count == 0)
- break;
- if (count == -1) {
- count = wctomb(dst, BAD_WCHAR);
- if (count == 0)
- break;
- unconv_num++;
- }
- src += consumed;
- dst += count;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-
-}
-
-static XlcConvMethodsRec iconv_cstombs_methods = {
- close_converter,
- iconv_cstombs,
- NULL
-};
-
-static XlcConv
-open_iconv_cstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- lazy_init_all_charsets();
- return create_conv(from_lcd, &iconv_cstombs_methods);
-}
-
-static int
-iconv_mbstocs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- wchar_t wc;
- int consumed;
- int count;
-
- /* Uses stdc iconv to convert multibyte -> widechar */
-
- consumed = mbtowc(&wc, src, srcend-src);
- if (consumed == 0)
- break;
- if (consumed == -1) {
- src++;
- unconv_num++;
- continue;
- }
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
-
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src += consumed;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src += consumed;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src += consumed;
- dst += count;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec iconv_mbstocs_methods = {
- close_tocs_converter,
- iconv_mbstocs,
- NULL
-};
-
-static XlcConv
-open_iconv_mbstocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_tocs_conv(from_lcd, &iconv_mbstocs_methods);
-}
-
-/* from XlcNMultiByte to XlcNChar */
-
-static int
-iconv_mbtocs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- Utf8Conv *preferred_charsets;
- XlcCharSet last_charset = NULL;
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- preferred_charsets = (Utf8Conv *) conv->state;
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend && dst < dstend) {
- Utf8Conv chosen_charset = NULL;
- XlcSide chosen_side = XlcNONE;
- wchar_t wc;
- int consumed;
- int count;
-
- /* Uses stdc iconv to convert multibyte -> widechar */
-
- consumed = mbtowc(&wc, src, srcend-src);
- if (consumed == 0)
- break;
- if (consumed == -1) {
- src++;
- unconv_num++;
- continue;
- }
-
- count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
- if (count == RET_TOOSMALL)
- break;
- if (count == RET_ILSEQ) {
- src += consumed;
- unconv_num++;
- continue;
- }
-
- if (last_charset == NULL) {
- last_charset =
- _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
- if (last_charset == NULL) {
- src += consumed;
- unconv_num++;
- continue;
- }
- } else {
- if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
- && (last_charset->side == XlcGLGR
- || last_charset->side == chosen_side)))
- break;
- }
- src += consumed;
- dst += count;
- }
-
- if (last_charset == NULL)
- return -1;
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- if (num_args >= 1)
- *((XlcCharSet *)args[0]) = last_charset;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec iconv_mbtocs_methods = {
- close_tocs_converter,
- iconv_mbtocs,
- NULL
-};
-
-static XlcConv
-open_iconv_mbtocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_tocs_conv(from_lcd, &iconv_mbtocs_methods );
-}
-
-/* from XlcNMultiByte to XlcNString */
-
-static int
-iconv_mbstostr(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
- int unconv_num;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
- unconv_num = 0;
-
- while (src < srcend) {
- unsigned char c;
- wchar_t wc;
- int consumed;
-
- /* Uses stdc iconv to convert multibyte -> widechar */
-
- consumed = mbtowc(&wc, src, srcend-src);
- if (consumed == 0)
- break;
- if (dst == dstend)
- break;
- if (consumed == -1) {
- consumed = 1;
- c = BAD_CHAR;
- unconv_num++;
- } else {
- if ((wc & ~(wchar_t)0xff) != 0) {
- c = BAD_CHAR;
- unconv_num++;
- } else
- c = (unsigned char) wc;
- }
- *dst++ = c;
- src += consumed;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec iconv_mbstostr_methods = {
- close_converter,
- iconv_mbstostr,
- NULL
-};
-
-static XlcConv
-open_iconv_mbstostr(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_conv(from_lcd, &iconv_mbstostr_methods);
-}
-
-/* from XlcNString to XlcNMultiByte */
-static int
-iconv_strtombs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- unsigned char const *src;
- unsigned char const *srcend;
- unsigned char *dst;
- unsigned char *dstend;
-
- if (from == NULL || *from == NULL)
- return 0;
-
- src = (unsigned char const *) *from;
- srcend = src + *from_left;
- dst = (unsigned char *) *to;
- dstend = dst + *to_left;
-
- while (src < srcend) {
- int count = wctomb(dst, *src);
- if (count < 0)
- break;
- dst += count;
- src++;
- }
-
- *from = (XPointer) src;
- *from_left = srcend - src;
- *to = (XPointer) dst;
- *to_left = dstend - dst;
-
- return 0;
-}
-
-static XlcConvMethodsRec iconv_strtombs_methods= {
- close_converter,
- iconv_strtombs,
- NULL
-};
-
-static XlcConv
-open_iconv_strtombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_conv(from_lcd, &iconv_strtombs_methods);
-}
-
-/***************************************************************************/
-/* Part II: An iconv locale loader.
- *
- *Here we can assume that "multi-byte" is iconv and that `wchar_t' is Unicode.
- */
-
-/* from XlcNMultiByte to XlcNWideChar */
-static int
-iconv_mbstowcs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- char *src = *((char **) from);
- wchar_t *dst = *((wchar_t **) to);
- int src_left = *from_left;
- int dst_left = *to_left;
- int length, unconv_num = 0;
-
- while (src_left > 0 && dst_left > 0) {
- length = mbtowc(dst, src, src_left);
-
- if (length > 0) {
- src += length;
- src_left -= length;
- if (dst)
- dst++;
- dst_left--;
- } else if (length < 0) {
- src++;
- src_left--;
- unconv_num++;
- } else {
- /* null ? */
- src++;
- src_left--;
- if (dst)
- *dst++ = L'\0';
- dst_left--;
- }
- }
-
- *from = (XPointer) src;
- if (dst)
- *to = (XPointer) dst;
- *from_left = src_left;
- *to_left = dst_left;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec iconv_mbstowcs_methods = {
- close_converter,
- iconv_mbstowcs,
- NULL
-} ;
-
-static XlcConv
-open_iconv_mbstowcs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_conv(from_lcd, &iconv_mbstowcs_methods);
-}
-
-static int
-iconv_wcstombs(XlcConv conv, XPointer *from, int *from_left,
- XPointer *to, int *to_left, XPointer *args, int num_args)
-{
- wchar_t *src = *((wchar_t **) from);
- char *dst = *((char **) to);
- int src_left = *from_left;
- int dst_left = *to_left;
- int length, unconv_num = 0;
-
- while (src_left > 0 && dst_left >= MB_CUR_MAX) {
- length = wctomb(dst, *src); /* XXX */
-
- if (length > 0) {
- src++;
- src_left--;
- if (dst)
- dst += length;
- dst_left -= length;
- } else if (length < 0) {
- src++;
- src_left--;
- unconv_num++;
- }
- }
-
- *from = (XPointer) src;
- if (dst)
- *to = (XPointer) dst;
- *from_left = src_left;
- *to_left = dst_left;
-
- return unconv_num;
-}
-
-static XlcConvMethodsRec iconv_wcstombs_methods = {
- close_converter,
- iconv_wcstombs,
- NULL
-} ;
-
-static XlcConv
-open_iconv_wcstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
-{
- return create_conv(from_lcd, &iconv_wcstombs_methods);
-}
-
-static XlcConv
-open_iconv_mbstofcs(
- XLCd from_lcd,
- const char *from_type,
- XLCd to_lcd,
- const char *to_type)
-{
- return create_tofontcs_conv(from_lcd, &iconv_mbstocs_methods);
-}
-
-/* Registers UTF-8 converters for a UTF-8 locale. */
-
-void
-_XlcAddUtf8LocaleConverters(
- XLCd lcd)
-{
- /* Register elementary converters. */
-
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_utf8towcs);
-
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstoutf8);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
-
- _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
-
- /* Register converters for XlcNCharSet. This implicitly provides
- * converters from and to XlcNCompoundText. */
-
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstoutf8);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_utf8tocs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_utf8tocs1);
-
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wcstocs1);
-
- _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtoutf8);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_utf8tostr);
- _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNMultiByte, open_identity);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String, open_identity);
-
- /* Register converters for XlcNFontCharSet */
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_utf8tofcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
-}
-
-void
-_XlcAddGB18030LocaleConverters(
- XLCd lcd)
-{
-
- /* Register elementary converters. */
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_iconv_mbstowcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_iconv_wcstombs);
-
- /* Register converters for XlcNCharSet. This implicitly provides
- * converters from and to XlcNCompoundText. */
-
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_iconv_cstombs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_iconv_mbstocs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_iconv_mbtocs);
- _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_iconv_strtombs);
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_iconv_mbstostr);
-
- /* Register converters for XlcNFontCharSet */
- _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_iconv_mbstofcs);
-
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
- _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
- _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wcstocs1);
-
- /* Register converters for XlcNFontCharSet */
- _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
-}
+/******************************************************************
+
+ Copyright 1993 by SunSoft, Inc.
+ Copyright 1999-2000 by Bruno Haible
+
+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 names of SunSoft, Inc. and
+Bruno Haible not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission. SunSoft, Inc. and Bruno Haible make no representations
+about the suitability of this software for any purpose. It is
+provided "as is" without express or implied warranty.
+
+SunSoft Inc. AND Bruno Haible DISCLAIM ALL WARRANTIES WITH REGARD
+TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL SunSoft, Inc. OR Bruno Haible 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.
+
+******************************************************************/
+
+/*
+ * This file contains:
+ *
+ * I. Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
+ *
+ * Used for three purposes:
+ * 1. The UTF-8 locales, see below.
+ * 2. Unicode aware applications for which the use of 8-bit character
+ * sets is an anachronism.
+ * 3. For conversion from keysym to locale encoding.
+ *
+ * II. Conversion files for an UTF-8 locale loader.
+ * Supports: all locales with codeset UTF-8.
+ * How: Provides converters for UTF-8.
+ * Platforms: all systems.
+ *
+ * The loader itself is located in lcUTF8.c.
+ */
+
+/*
+ * The conversion from UTF-8 to CompoundText is realized in a very
+ * conservative way. Recall that CompoundText data is used for inter-client
+ * communication purposes. We distinguish three classes of clients:
+ * - Clients which accept only those pieces of CompoundText which belong to
+ * the character set understood by the current locale.
+ * (Example: clients which are linked to an older X11 library.)
+ * - Clients which accept CompoundText with multiple character sets and parse
+ * it themselves.
+ * (Example: emacs, xemacs.)
+ * - Clients which rely entirely on the X{mb,wc}TextPropertyToTextList
+ * functions for the conversion of CompoundText to their current locale's
+ * multi-byte/wide-character format.
+ * For best interoperation, the UTF-8 to CompoundText conversion proceeds as
+ * follows. For every character, it first tests whether the character is
+ * representable in the current locale's original (non-UTF-8) character set.
+ * If not, it goes through the list of predefined character sets for
+ * CompoundText and tests if the character is representable in that character
+ * set. If so, it encodes the character using its code within that character
+ * set. If not, it uses an UTF-8-in-CompoundText encapsulation. Since
+ * clients of the first and second kind ignore such encapsulated text,
+ * this encapsulation is kept to a minimum and terminated as early as possible.
+ *
+ * In a distant future, when clients of the first and second kind will have
+ * disappeared, we will be able to stuff UTF-8 data directly in CompoundText
+ * without first going through the list of predefined character sets.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include "XlcGeneric.h"
+
+static XlcConv
+create_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = NULL;
+
+ return conv;
+}
+
+static void
+close_converter(
+ XlcConv conv)
+{
+ Xfree((char *) conv);
+}
+
+/* Replacement character for invalid multibyte sequence or wide character. */
+#define BAD_WCHAR ((ucs4_t) 0xfffd)
+#define BAD_CHAR '?'
+
+/***************************************************************************/
+/* Part I: Conversion routines CompoundText/CharSet <--> Unicode/UTF-8.
+ *
+ * Note that this code works in any locale. We store Unicode values in
+ * `ucs4_t' variables, but don't pass them to the user.
+ *
+ * This code has to support all character sets that are used for CompoundText,
+ * nothing more, nothing less. See the table in lcCT.c.
+ * Since the conversion _to_ CompoundText is likely to need the tables for all
+ * character sets at once, we don't use dynamic loading (of tables or shared
+ * libraries through iconv()). Use a fixed set of tables instead.
+ *
+ * We use statically computed tables, not dynamically allocated arrays,
+ * because it's more memory efficient: Different processes using the same
+ * libX11 shared library share the "text" and read-only "data" sections.
+ */
+
+typedef unsigned int ucs4_t;
+#define conv_t XlcConv
+
+typedef struct _Utf8ConvRec {
+ const char *name;
+ XrmQuark xrm_name;
+ int (* cstowc) (XlcConv, ucs4_t *, unsigned char const *, int);
+ int (* wctocs) (XlcConv, unsigned char *, ucs4_t, int);
+} Utf8ConvRec, *Utf8Conv;
+
+/*
+ * int xxx_cstowc (XlcConv conv, ucs4_t *pwc, unsigned char const *s, int n)
+ * converts the byte sequence starting at s to a wide character. Up to n bytes
+ * are available at s. n is >= 1.
+ * Result is number of bytes consumed (if a wide character was read),
+ * or 0 if invalid, or -1 if n too small.
+ *
+ * int xxx_wctocs (XlcConv conv, unsigned char *r, ucs4_t wc, int n)
+ * converts the wide character wc to the character set xxx, and stores the
+ * result beginning at r. Up to n bytes may be written at r. n is >= 1.
+ * Result is number of bytes written, or 0 if invalid, or -1 if n too small.
+ */
+
+/* Return code if invalid. (xxx_mbtowc, xxx_wctomb) */
+#define RET_ILSEQ 0
+/* Return code if only a shift sequence of n bytes was read. (xxx_mbtowc) */
+#define RET_TOOFEW(n) (-1-(n))
+/* Return code if output buffer is too small. (xxx_wctomb, xxx_reset) */
+#define RET_TOOSMALL -1
+
+/*
+ * The tables below are bijective. It would be possible to extend the
+ * xxx_wctocs tables to do some transliteration (e.g. U+201C,U+201D -> 0x22)
+ * but *only* with characters not contained in any other table, and *only*
+ * when the current locale is not an UTF-8 locale.
+ */
+
+#include "lcUniConv/utf8.h"
+#include "lcUniConv/ucs2be.h"
+#ifdef notused
+#include "lcUniConv/ascii.h"
+#endif
+#include "lcUniConv/iso8859_1.h"
+#include "lcUniConv/iso8859_2.h"
+#include "lcUniConv/iso8859_3.h"
+#include "lcUniConv/iso8859_4.h"
+#include "lcUniConv/iso8859_5.h"
+#include "lcUniConv/iso8859_6.h"
+#include "lcUniConv/iso8859_7.h"
+#include "lcUniConv/iso8859_8.h"
+#include "lcUniConv/iso8859_9.h"
+#include "lcUniConv/iso8859_10.h"
+#include "lcUniConv/iso8859_11.h"
+#include "lcUniConv/iso8859_13.h"
+#include "lcUniConv/iso8859_14.h"
+#include "lcUniConv/iso8859_15.h"
+#include "lcUniConv/iso8859_16.h"
+#include "lcUniConv/iso8859_9e.h"
+#include "lcUniConv/jisx0201.h"
+#include "lcUniConv/tis620.h"
+#include "lcUniConv/koi8_r.h"
+#include "lcUniConv/koi8_u.h"
+#include "lcUniConv/koi8_c.h"
+#include "lcUniConv/armscii_8.h"
+#include "lcUniConv/cp1133.h"
+#include "lcUniConv/mulelao.h"
+#include "lcUniConv/viscii.h"
+#include "lcUniConv/tcvn.h"
+#include "lcUniConv/georgian_academy.h"
+#include "lcUniConv/georgian_ps.h"
+#include "lcUniConv/cp1251.h"
+#include "lcUniConv/cp1255.h"
+#include "lcUniConv/cp1256.h"
+#include "lcUniConv/tatar_cyr.h"
+
+typedef struct {
+ unsigned short indx; /* index into big table */
+ unsigned short used; /* bitmask of used entries */
+} Summary16;
+
+#include "lcUniConv/gb2312.h"
+#include "lcUniConv/jisx0208.h"
+#include "lcUniConv/jisx0212.h"
+#include "lcUniConv/ksc5601.h"
+#include "lcUniConv/big5.h"
+#include "lcUniConv/big5_emacs.h"
+#include "lcUniConv/big5hkscs.h"
+#include "lcUniConv/gbk.h"
+
+static Utf8ConvRec all_charsets[] = {
+ /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
+ (for lookup speed), once at the end (as a fallback). */
+ { "ISO10646-1", NULLQUARK,
+ utf8_mbtowc, utf8_wctomb
+ },
+
+ { "ISO8859-1", NULLQUARK,
+ iso8859_1_mbtowc, iso8859_1_wctomb
+ },
+ { "ISO8859-2", NULLQUARK,
+ iso8859_2_mbtowc, iso8859_2_wctomb
+ },
+ { "ISO8859-3", NULLQUARK,
+ iso8859_3_mbtowc, iso8859_3_wctomb
+ },
+ { "ISO8859-4", NULLQUARK,
+ iso8859_4_mbtowc, iso8859_4_wctomb
+ },
+ { "ISO8859-5", NULLQUARK,
+ iso8859_5_mbtowc, iso8859_5_wctomb
+ },
+ { "ISO8859-6", NULLQUARK,
+ iso8859_6_mbtowc, iso8859_6_wctomb
+ },
+ { "ISO8859-7", NULLQUARK,
+ iso8859_7_mbtowc, iso8859_7_wctomb
+ },
+ { "ISO8859-8", NULLQUARK,
+ iso8859_8_mbtowc, iso8859_8_wctomb
+ },
+ { "ISO8859-9", NULLQUARK,
+ iso8859_9_mbtowc, iso8859_9_wctomb
+ },
+ { "ISO8859-10", NULLQUARK,
+ iso8859_10_mbtowc, iso8859_10_wctomb
+ },
+ { "ISO8859-11", NULLQUARK,
+ iso8859_11_mbtowc, iso8859_11_wctomb
+ },
+ { "ISO8859-13", NULLQUARK,
+ iso8859_13_mbtowc, iso8859_13_wctomb
+ },
+ { "ISO8859-14", NULLQUARK,
+ iso8859_14_mbtowc, iso8859_14_wctomb
+ },
+ { "ISO8859-15", NULLQUARK,
+ iso8859_15_mbtowc, iso8859_15_wctomb
+ },
+ { "ISO8859-16", NULLQUARK,
+ iso8859_16_mbtowc, iso8859_16_wctomb
+ },
+ { "JISX0201.1976-0", NULLQUARK,
+ jisx0201_mbtowc, jisx0201_wctomb
+ },
+ { "TIS620-0", NULLQUARK,
+ tis620_mbtowc, tis620_wctomb
+ },
+ { "GB2312.1980-0", NULLQUARK,
+ gb2312_mbtowc, gb2312_wctomb
+ },
+ { "JISX0208.1983-0", NULLQUARK,
+ jisx0208_mbtowc, jisx0208_wctomb
+ },
+ { "JISX0208.1990-0", NULLQUARK,
+ jisx0208_mbtowc, jisx0208_wctomb
+ },
+ { "JISX0212.1990-0", NULLQUARK,
+ jisx0212_mbtowc, jisx0212_wctomb
+ },
+ { "KSC5601.1987-0", NULLQUARK,
+ ksc5601_mbtowc, ksc5601_wctomb
+ },
+ { "KOI8-R", NULLQUARK,
+ koi8_r_mbtowc, koi8_r_wctomb
+ },
+ { "KOI8-U", NULLQUARK,
+ koi8_u_mbtowc, koi8_u_wctomb
+ },
+ { "KOI8-C", NULLQUARK,
+ koi8_c_mbtowc, koi8_c_wctomb
+ },
+ { "TATAR-CYR", NULLQUARK,
+ tatar_cyr_mbtowc, tatar_cyr_wctomb
+ },
+ { "ARMSCII-8", NULLQUARK,
+ armscii_8_mbtowc, armscii_8_wctomb
+ },
+ { "IBM-CP1133", NULLQUARK,
+ cp1133_mbtowc, cp1133_wctomb
+ },
+ { "MULELAO-1", NULLQUARK,
+ mulelao_mbtowc, mulelao_wctomb
+ },
+ { "VISCII1.1-1", NULLQUARK,
+ viscii_mbtowc, viscii_wctomb
+ },
+ { "TCVN-5712", NULLQUARK,
+ tcvn_mbtowc, tcvn_wctomb
+ },
+ { "GEORGIAN-ACADEMY", NULLQUARK,
+ georgian_academy_mbtowc, georgian_academy_wctomb
+ },
+ { "GEORGIAN-PS", NULLQUARK,
+ georgian_ps_mbtowc, georgian_ps_wctomb
+ },
+ { "ISO8859-9E", NULLQUARK,
+ iso8859_9e_mbtowc, iso8859_9e_wctomb
+ },
+ { "MICROSOFT-CP1251", NULLQUARK,
+ cp1251_mbtowc, cp1251_wctomb
+ },
+ { "MICROSOFT-CP1255", NULLQUARK,
+ cp1255_mbtowc, cp1255_wctomb
+ },
+ { "MICROSOFT-CP1256", NULLQUARK,
+ cp1256_mbtowc, cp1256_wctomb
+ },
+ { "BIG5-0", NULLQUARK,
+ big5_mbtowc, big5_wctomb
+ },
+ { "BIG5-E0", NULLQUARK,
+ big5_0_mbtowc, big5_0_wctomb
+ },
+ { "BIG5-E1", NULLQUARK,
+ big5_1_mbtowc, big5_1_wctomb
+ },
+ { "GBK-0", NULLQUARK,
+ gbk_mbtowc, gbk_wctomb
+ },
+ { "BIG5HKSCS-0", NULLQUARK,
+ big5hkscs_mbtowc, big5hkscs_wctomb
+ },
+
+ /* The ISO10646-1/UTF-8 entry occurs twice, once at the beginning
+ (for lookup speed), once at the end (as a fallback). */
+ { "ISO10646-1", NULLQUARK,
+ utf8_mbtowc, utf8_wctomb
+ },
+
+ /* Encoding ISO10646-1 for fonts means UCS2-like encoding
+ so for conversion to FontCharSet we need this record */
+ { "ISO10646-1", NULLQUARK,
+ ucs2be_mbtowc, ucs2be_wctomb
+ }
+};
+
+#define charsets_table_size (sizeof(all_charsets)/sizeof(all_charsets[0]))
+#define all_charsets_count (charsets_table_size - 1)
+#define ucs2_conv_index (charsets_table_size - 1)
+
+static void
+init_all_charsets (void)
+{
+ Utf8Conv convptr;
+ int i;
+
+ for (convptr = all_charsets, i = charsets_table_size; i > 0; convptr++, i--)
+ convptr->xrm_name = XrmStringToQuark(convptr->name);
+}
+
+#define lazy_init_all_charsets() \
+ do { \
+ if (all_charsets[0].xrm_name == NULLQUARK) \
+ init_all_charsets(); \
+ } while (0)
+
+/* from XlcNCharSet to XlcNUtf8String */
+
+static int
+cstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XlcCharSet charset;
+ const char *name;
+ Utf8Conv convptr;
+ int i;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+ name = charset->encoding_name;
+ /* not charset->name because the latter has a ":GL"/":GR" suffix */
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (!strcmp(convptr->name, name))
+ break;
+ if (i == 0)
+ return -1;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = convptr->cstowc(conv, &wc, src, srcend-src);
+ if (consumed == RET_ILSEQ)
+ return -1;
+ if (consumed == RET_TOOFEW(0))
+ break;
+
+ count = utf8_wctomb(NULL, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ unconv_num++;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_cstoutf8 = {
+ close_converter,
+ cstoutf8,
+ NULL
+};
+
+static XlcConv
+open_cstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ lazy_init_all_charsets();
+ return create_conv(from_lcd, &methods_cstoutf8);
+}
+
+/* from XlcNUtf8String to XlcNCharSet */
+
+static XlcConv
+create_tocs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ CodeSet *codeset_list;
+ int codeset_num;
+ int charset_num;
+ int i, j, k;
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ codeset_list = XLC_GENERIC(lcd, codeset_list);
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ charset_num = 0;
+ for (i = 0; i < codeset_num; i++)
+ charset_num += codeset_list[i]->num_charsets;
+ if (charset_num > all_charsets_count-1)
+ charset_num = all_charsets_count-1;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec)
+ + (charset_num + 1) * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ /* Loop through all codesets mentioned in the locale. */
+ charset_num = 0;
+ for (i = 0; i < codeset_num; i++) {
+ XlcCharSet *charsets = codeset_list[i]->charset_list;
+ int num_charsets = codeset_list[i]->num_charsets;
+ for (j = 0; j < num_charsets; j++) {
+ const char *name = charsets[j]->encoding_name;
+ /* If it wasn't already encountered... */
+ for (k = charset_num-1; k >= 0; k--)
+ if (!strcmp(preferred[k]->name, name))
+ break;
+ if (k < 0) {
+ /* Look it up in all_charsets[]. */
+ for (k = 0; k < all_charsets_count-1; k++)
+ if (!strcmp(all_charsets[k].name, name)) {
+ /* Add it to the preferred set. */
+ preferred[charset_num++] = &all_charsets[k];
+ break;
+ }
+ }
+ }
+ }
+ preferred[charset_num] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+}
+
+static void
+close_tocs_converter(
+ XlcConv conv)
+{
+ /* conv->state is allocated together with conv, free both at once. */
+ Xfree((char *) conv);
+}
+
+/*
+ * Converts a Unicode character to an appropriate character set. The NULL
+ * terminated array of preferred character sets is passed as first argument.
+ * If successful, *charsetp is set to the character set that was used, and
+ * *sidep is set to the character set side (XlcGL or XlcGR).
+ */
+static int
+charset_wctocs(
+ Utf8Conv *preferred,
+ Utf8Conv *charsetp,
+ XlcSide *sidep,
+ XlcConv conv,
+ unsigned char *r,
+ ucs4_t wc,
+ int n)
+{
+ int count;
+ Utf8Conv convptr;
+ int i;
+
+ for (; *preferred != (Utf8Conv) NULL; preferred++) {
+ convptr = *preferred;
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ for (convptr = all_charsets+1, i = all_charsets_count-1; i > 0; convptr++, i--) {
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static int
+utf8tocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tocs = {
+ close_tocs_converter,
+ utf8tocs,
+ NULL
+};
+
+static XlcConv
+open_utf8tocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_utf8tocs);
+}
+
+/* from XlcNUtf8String to XlcNChar */
+
+static int
+utf8tocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ break;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tocs1 = {
+ close_tocs_converter,
+ utf8tocs1,
+ NULL
+};
+
+static XlcConv
+open_utf8tocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_utf8tocs1);
+}
+
+/* from XlcNUtf8String to XlcNString */
+
+static int
+utf8tostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ unsigned char c;
+ ucs4_t wc;
+ int consumed;
+
+ consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (dst == dstend)
+ break;
+ if (consumed == RET_ILSEQ) {
+ consumed = 1;
+ c = BAD_CHAR;
+ unconv_num++;
+ } else {
+ if ((wc & ~(ucs4_t)0xff) != 0) {
+ c = BAD_CHAR;
+ unconv_num++;
+ } else
+ c = (unsigned char) wc;
+ }
+ *dst++ = c;
+ src += consumed;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8tostr = {
+ close_converter,
+ utf8tostr,
+ NULL
+};
+
+static XlcConv
+open_utf8tostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_utf8tostr);
+}
+
+/* from XlcNString to XlcNUtf8String */
+
+static int
+strtoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ dst += count;
+ src++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_strtoutf8 = {
+ close_converter,
+ strtoutf8,
+ NULL
+};
+
+static XlcConv
+open_strtoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_strtoutf8);
+}
+
+/* Support for the input methods. */
+
+XPointer
+_Utf8GetConvByName(
+ const char *name)
+{
+ XrmQuark xrm_name;
+ Utf8Conv convptr;
+ int i;
+
+ if (name == NULL)
+ return (XPointer) NULL;
+
+ lazy_init_all_charsets();
+ xrm_name = XrmStringToQuark(name);
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (convptr->xrm_name == xrm_name)
+ return (XPointer) convptr->wctocs;
+ return (XPointer) NULL;
+}
+
+/* from XlcNUcsChar to XlcNChar, needed for input methods */
+
+static XlcConv
+create_ucstocs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+
+ if (XLC_PUBLIC_PART(lcd)->codeset
+ && _XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8") == 0) {
+ XlcConv conv;
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + 2 * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ preferred[0] = &all_charsets[0]; /* ISO10646 */
+ preferred[1] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+ } else {
+ return create_tocs_conv(lcd, methods);
+ }
+}
+
+static int
+charset_wctocs_exactly(
+ Utf8Conv *preferred,
+ Utf8Conv *charsetp,
+ XlcSide *sidep,
+ XlcConv conv,
+ unsigned char *r,
+ ucs4_t wc,
+ int n)
+{
+ int count;
+ Utf8Conv convptr;
+
+ for (; *preferred != (Utf8Conv) NULL; preferred++) {
+ convptr = *preferred;
+ count = convptr->wctocs(conv, r, wc, n);
+ if (count == RET_TOOSMALL)
+ return RET_TOOSMALL;
+ if (count != RET_ILSEQ) {
+ *charsetp = convptr;
+ *sidep = (*r < 0x80 ? XlcGL : XlcGR);
+ return count;
+ }
+ }
+ return RET_ILSEQ;
+}
+
+static int
+ucstocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ ucs4_t const *src = (ucs4_t const *) *from;
+ unsigned char *dst = (unsigned char *) *to;
+ int unconv_num = 0;
+ Utf8Conv *preferred_charsets = (Utf8Conv *) conv->state;
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ XlcCharSet charset = NULL;
+ int count;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ count = charset_wctocs_exactly(preferred_charsets, &chosen_charset,
+ &chosen_side, conv, dst, *src, *to_left);
+ if (count < 1) {
+ unconv_num++;
+ count = 0;
+ } else {
+ charset = _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ }
+ if (charset == NULL)
+ return -1;
+
+ *from = (XPointer) ++src;
+ (*from_left)--;
+ *to = (XPointer) dst;
+ *to_left -= count;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstocs1 = {
+ close_tocs_converter,
+ ucstocs1,
+ NULL
+};
+
+static XlcConv
+open_ucstocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_ucstocs_conv(from_lcd, &methods_ucstocs1);
+}
+
+/* from XlcNUcsChar to XlcNUtf8String, needed for input methods */
+
+static int
+ucstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ const ucs4_t *src;
+ const ucs4_t *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (const ucs4_t *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ)
+ unconv_num++;
+ src++;
+ dst += count;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_ucstoutf8 = {
+ close_converter,
+ ucstoutf8,
+ NULL
+};
+
+static XlcConv
+open_ucstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_ucstoutf8);
+}
+
+/* Registers UTF-8 converters for a non-UTF-8 locale. */
+void
+_XlcAddUtf8Converters(
+ XLCd lcd)
+{
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNUtf8String, open_cstoutf8);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNCharSet, open_utf8tocs);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNChar, open_utf8tocs1);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNUtf8String, open_strtoutf8);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNString, open_utf8tostr);
+ _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNChar, open_ucstocs1);
+ _XlcSetConverter(lcd, XlcNUcsChar, lcd, XlcNUtf8String, open_ucstoutf8);
+}
+
+/***************************************************************************/
+/* Part II: UTF-8 locale loader conversion files
+ *
+ * Here we can assume that "multi-byte" is UTF-8 and that `wchar_t' is Unicode.
+ */
+
+/* from XlcNMultiByte to XlcNWideChar */
+
+static int
+utf8towcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ ucs4_t wc;
+ int consumed = utf8_mbtowc(NULL, &wc, src, srcend-src);
+ if (consumed == RET_TOOFEW(0))
+ break;
+ if (consumed == RET_ILSEQ) {
+ src++;
+ *dst = BAD_WCHAR;
+ unconv_num++;
+ } else {
+ src += consumed;
+ *dst = wc;
+ }
+ dst++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_utf8towcs = {
+ close_converter,
+ utf8towcs,
+ NULL
+};
+
+static XlcConv
+open_utf8towcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_utf8towcs);
+}
+
+/* from XlcNWideChar to XlcNMultiByte */
+
+static int
+wcstoutf8(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ int count = utf8_wctomb(NULL, dst, *src, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ count = utf8_wctomb(NULL, dst, BAD_WCHAR, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ unconv_num++;
+ }
+ dst += count;
+ src++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstoutf8 = {
+ close_converter,
+ wcstoutf8,
+ NULL
+};
+
+static XlcConv
+open_wcstoutf8(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_wcstoutf8);
+}
+
+/* from XlcNString to XlcNWideChar */
+
+static int
+our_strtowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend && dst < dstend)
+ *dst++ = (wchar_t) *src++;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_strtowcs = {
+ close_converter,
+ our_strtowcs,
+ NULL
+};
+
+static XlcConv
+open_strtowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_strtowcs);
+}
+
+/* from XlcNWideChar to XlcNString */
+
+static int
+our_wcstostr(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ unsigned int wc = *src++;
+ if (wc < 0x80)
+ *dst = wc;
+ else {
+ *dst = BAD_CHAR;
+ unconv_num++;
+ }
+ dst++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstostr = {
+ close_converter,
+ our_wcstostr,
+ NULL
+};
+
+static XlcConv
+open_wcstostr(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_wcstostr);
+}
+
+/* from XlcNCharSet to XlcNWideChar */
+
+static int
+cstowcs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ XlcCharSet charset;
+ const char *name;
+ Utf8Conv convptr;
+ int i;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ wchar_t *dst;
+ wchar_t *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+ name = charset->encoding_name;
+ /* not charset->name because the latter has a ":GL"/":GR" suffix */
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (!strcmp(convptr->name, name))
+ break;
+ if (i == 0)
+ return -1;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (wchar_t *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ unsigned int wc;
+ int consumed;
+
+ consumed = convptr->cstowc(conv, &wc, src, srcend-src);
+ if (consumed == RET_ILSEQ)
+ return -1;
+ if (consumed == RET_TOOFEW(0))
+ break;
+
+ *dst++ = wc;
+ src += consumed;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_cstowcs = {
+ close_converter,
+ cstowcs,
+ NULL
+};
+
+static XlcConv
+open_cstowcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ lazy_init_all_charsets();
+ return create_conv(from_lcd, &methods_cstowcs);
+}
+
+/* from XlcNWideChar to XlcNCharSet */
+
+static int
+wcstocs(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc = *src;
+ int count;
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src++;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstocs = {
+ close_tocs_converter,
+ wcstocs,
+ NULL
+};
+
+static XlcConv
+open_wcstocs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_wcstocs);
+}
+
+/* from XlcNWideChar to XlcNChar */
+
+static int
+wcstocs1(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ wchar_t const *src;
+ wchar_t const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (wchar_t const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc = *src;
+ int count;
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src++;
+ dst += count;
+ break;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec methods_wcstocs1 = {
+ close_tocs_converter,
+ wcstocs1,
+ NULL
+};
+
+static XlcConv
+open_wcstocs1(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &methods_wcstocs1);
+}
+
+/* trivial, no conversion */
+
+static int
+identity(
+ XlcConv conv,
+ XPointer *from,
+ int *from_left,
+ XPointer *to,
+ int *to_left,
+ XPointer *args,
+ int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend && dst < dstend)
+ *dst++ = *src++;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec methods_identity = {
+ close_converter,
+ identity,
+ NULL
+};
+
+static XlcConv
+open_identity(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_conv(from_lcd, &methods_identity);
+}
+
+/* from MultiByte/WideChar to FontCharSet. */
+/* They really use converters to CharSet
+ * but with different create_conv procedure. */
+
+static XlcConv
+create_tofontcs_conv(
+ XLCd lcd,
+ XlcConvMethods methods)
+{
+ XlcConv conv;
+ int i, num, k, count;
+ char **value, buf[20];
+ Utf8Conv *preferred;
+
+ lazy_init_all_charsets();
+
+ for (i = 0, num = 0;; i++) {
+ sprintf(buf, "fs%d.charset.name", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ sprintf(buf, "fs%d.charset", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+ num += count;
+ }
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec) + (num + 1) * sizeof(Utf8Conv));
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+ preferred = (Utf8Conv *) ((char *) conv + sizeof(XlcConvRec));
+
+ /* Loop through all fontsets mentioned in the locale. */
+ for (i = 0, num = 0;; i++) {
+ sprintf(buf, "fs%d.charset.name", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ sprintf(buf, "fs%d.charset", i);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+ while (count-- > 0) {
+ XlcCharSet charset = _XlcGetCharSet(*value++);
+ const char *name;
+
+ if (charset == (XlcCharSet) NULL)
+ continue;
+
+ name = charset->encoding_name;
+ /* If it wasn't already encountered... */
+ for (k = num - 1; k >= 0; k--)
+ if (!strcmp(preferred[k]->name, name))
+ break;
+ if (k < 0) {
+ /* For fonts "ISO10646-1" means ucs2, not utf8.*/
+ if (!strcmp("ISO10646-1", name)) {
+ preferred[num++] = &all_charsets[ucs2_conv_index];
+ continue;
+ }
+ /* Look it up in all_charsets[]. */
+ for (k = 0; k < all_charsets_count-1; k++)
+ if (!strcmp(all_charsets[k].name, name)) {
+ /* Add it to the preferred set. */
+ preferred[num++] = &all_charsets[k];
+ break;
+ }
+ }
+ }
+ }
+ preferred[num] = (Utf8Conv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) preferred;
+
+ return conv;
+}
+
+static XlcConv
+open_wcstofcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tofontcs_conv(from_lcd, &methods_wcstocs);
+}
+
+static XlcConv
+open_utf8tofcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tofontcs_conv(from_lcd, &methods_utf8tocs);
+}
+
+/* ========================== iconv Stuff ================================ */
+
+/* from XlcNCharSet to XlcNMultiByte */
+
+static int
+iconv_cstombs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ XlcCharSet charset;
+ char const *name;
+ Utf8Conv convptr;
+ int i;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+ name = charset->encoding_name;
+ /* not charset->name because the latter has a ":GL"/":GR" suffix */
+
+ for (convptr = all_charsets, i = all_charsets_count-1; i > 0; convptr++, i--)
+ if (!strcmp(convptr->name, name))
+ break;
+ if (i == 0)
+ return -1;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ ucs4_t wc;
+ int consumed;
+ int count;
+
+ consumed = convptr->cstowc(conv, &wc, src, srcend-src);
+ if (consumed == RET_ILSEQ)
+ return -1;
+ if (consumed == RET_TOOFEW(0))
+ break;
+
+ /* Use stdc iconv to convert widechar -> multibyte */
+
+ count = wctomb((char *)dst, wc);
+ if (count == 0)
+ break;
+ if (count == -1) {
+ count = wctomb((char *)dst, BAD_WCHAR);
+ if (count == 0)
+ break;
+ unconv_num++;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+
+}
+
+static XlcConvMethodsRec iconv_cstombs_methods = {
+ close_converter,
+ iconv_cstombs,
+ NULL
+};
+
+static XlcConv
+open_iconv_cstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ lazy_init_all_charsets();
+ return create_conv(from_lcd, &iconv_cstombs_methods);
+}
+
+static int
+iconv_mbstocs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc;
+ int consumed;
+ int count;
+
+ /* Uses stdc iconv to convert multibyte -> widechar */
+
+ consumed = mbtowc(&wc, (const char *)src, srcend-src);
+ if (consumed == 0)
+ break;
+ if (consumed == -1) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec iconv_mbstocs_methods = {
+ close_tocs_converter,
+ iconv_mbstocs,
+ NULL
+};
+
+static XlcConv
+open_iconv_mbstocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &iconv_mbstocs_methods);
+}
+
+/* from XlcNMultiByte to XlcNChar */
+
+static int
+iconv_mbtocs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ Utf8Conv *preferred_charsets;
+ XlcCharSet last_charset = NULL;
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ preferred_charsets = (Utf8Conv *) conv->state;
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend && dst < dstend) {
+ Utf8Conv chosen_charset = NULL;
+ XlcSide chosen_side = XlcNONE;
+ wchar_t wc;
+ int consumed;
+ int count;
+
+ /* Uses stdc iconv to convert multibyte -> widechar */
+
+ consumed = mbtowc(&wc, (const char *)src, srcend-src);
+ if (consumed == 0)
+ break;
+ if (consumed == -1) {
+ src++;
+ unconv_num++;
+ continue;
+ }
+
+ count = charset_wctocs(preferred_charsets, &chosen_charset, &chosen_side, conv, dst, wc, dstend-dst);
+ if (count == RET_TOOSMALL)
+ break;
+ if (count == RET_ILSEQ) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+
+ if (last_charset == NULL) {
+ last_charset =
+ _XlcGetCharSetWithSide(chosen_charset->name, chosen_side);
+ if (last_charset == NULL) {
+ src += consumed;
+ unconv_num++;
+ continue;
+ }
+ } else {
+ if (!(last_charset->xrm_encoding_name == chosen_charset->xrm_name
+ && (last_charset->side == XlcGLGR
+ || last_charset->side == chosen_side)))
+ break;
+ }
+ src += consumed;
+ dst += count;
+ }
+
+ if (last_charset == NULL)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ if (num_args >= 1)
+ *((XlcCharSet *)args[0]) = last_charset;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec iconv_mbtocs_methods = {
+ close_tocs_converter,
+ iconv_mbtocs,
+ NULL
+};
+
+static XlcConv
+open_iconv_mbtocs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_tocs_conv(from_lcd, &iconv_mbtocs_methods );
+}
+
+/* from XlcNMultiByte to XlcNString */
+
+static int
+iconv_mbstostr(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+ int unconv_num;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+ unconv_num = 0;
+
+ while (src < srcend) {
+ unsigned char c;
+ wchar_t wc;
+ int consumed;
+
+ /* Uses stdc iconv to convert multibyte -> widechar */
+
+ consumed = mbtowc(&wc, (const char *)src, srcend-src);
+ if (consumed == 0)
+ break;
+ if (dst == dstend)
+ break;
+ if (consumed == -1) {
+ consumed = 1;
+ c = BAD_CHAR;
+ unconv_num++;
+ } else {
+ if ((wc & ~(wchar_t)0xff) != 0) {
+ c = BAD_CHAR;
+ unconv_num++;
+ } else
+ c = (unsigned char) wc;
+ }
+ *dst++ = c;
+ src += consumed;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec iconv_mbstostr_methods = {
+ close_converter,
+ iconv_mbstostr,
+ NULL
+};
+
+static XlcConv
+open_iconv_mbstostr(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_conv(from_lcd, &iconv_mbstostr_methods);
+}
+
+/* from XlcNString to XlcNMultiByte */
+static int
+iconv_strtombs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ unsigned char const *src;
+ unsigned char const *srcend;
+ unsigned char *dst;
+ unsigned char *dstend;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (unsigned char const *) *from;
+ srcend = src + *from_left;
+ dst = (unsigned char *) *to;
+ dstend = dst + *to_left;
+
+ while (src < srcend) {
+ int count = wctomb((char *)dst, *src);
+ if (count < 0)
+ break;
+ dst += count;
+ src++;
+ }
+
+ *from = (XPointer) src;
+ *from_left = srcend - src;
+ *to = (XPointer) dst;
+ *to_left = dstend - dst;
+
+ return 0;
+}
+
+static XlcConvMethodsRec iconv_strtombs_methods= {
+ close_converter,
+ iconv_strtombs,
+ NULL
+};
+
+static XlcConv
+open_iconv_strtombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_conv(from_lcd, &iconv_strtombs_methods);
+}
+
+/***************************************************************************/
+/* Part II: An iconv locale loader.
+ *
+ *Here we can assume that "multi-byte" is iconv and that `wchar_t' is Unicode.
+ */
+
+/* from XlcNMultiByte to XlcNWideChar */
+static int
+iconv_mbstowcs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ char *src = *((char **) from);
+ wchar_t *dst = *((wchar_t **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = mbtowc(dst, src, src_left);
+
+ if (length > 0) {
+ src += length;
+ src_left -= length;
+ if (dst)
+ dst++;
+ dst_left--;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ } else {
+ /* null ? */
+ src++;
+ src_left--;
+ if (dst)
+ *dst++ = L'\0';
+ dst_left--;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec iconv_mbstowcs_methods = {
+ close_converter,
+ iconv_mbstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_iconv_mbstowcs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_conv(from_lcd, &iconv_mbstowcs_methods);
+}
+
+static int
+iconv_wcstombs(XlcConv conv, XPointer *from, int *from_left,
+ XPointer *to, int *to_left, XPointer *args, int num_args)
+{
+ wchar_t *src = *((wchar_t **) from);
+ char *dst = *((char **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left >= MB_CUR_MAX) {
+ length = wctomb(dst, *src); /* XXX */
+
+ if (length > 0) {
+ src++;
+ src_left--;
+ if (dst)
+ dst += length;
+ dst_left -= length;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static XlcConvMethodsRec iconv_wcstombs_methods = {
+ close_converter,
+ iconv_wcstombs,
+ NULL
+} ;
+
+static XlcConv
+open_iconv_wcstombs(XLCd from_lcd, const char *from_type, XLCd to_lcd, const char *to_type)
+{
+ return create_conv(from_lcd, &iconv_wcstombs_methods);
+}
+
+static XlcConv
+open_iconv_mbstofcs(
+ XLCd from_lcd,
+ const char *from_type,
+ XLCd to_lcd,
+ const char *to_type)
+{
+ return create_tofontcs_conv(from_lcd, &iconv_mbstocs_methods);
+}
+
+/* Registers UTF-8 converters for a UTF-8 locale. */
+
+void
+_XlcAddUtf8LocaleConverters(
+ XLCd lcd)
+{
+ /* Register elementary converters. */
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_utf8towcs);
+
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstoutf8);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+
+ /* Register converters for XlcNCharSet. This implicitly provides
+ * converters from and to XlcNCompoundText. */
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstoutf8);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_utf8tocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_utf8tocs1);
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wcstocs1);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtoutf8);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_utf8tostr);
+ _XlcSetConverter(lcd, XlcNUtf8String, lcd, XlcNMultiByte, open_identity);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNUtf8String, open_identity);
+
+ /* Register converters for XlcNFontCharSet */
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_utf8tofcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
+}
+
+void
+_XlcAddGB18030LocaleConverters(
+ XLCd lcd)
+{
+
+ /* Register elementary converters. */
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_iconv_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_iconv_wcstombs);
+
+ /* Register converters for XlcNCharSet. This implicitly provides
+ * converters from and to XlcNCompoundText. */
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_iconv_cstombs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_iconv_mbstocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_iconv_mbtocs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_iconv_strtombs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_iconv_mbstostr);
+
+ /* Register converters for XlcNFontCharSet */
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNFontCharSet, open_iconv_mbstofcs);
+
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wcstocs1);
+
+ /* Register converters for XlcNFontCharSet */
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNFontCharSet, open_wcstofcs);
+}