diff options
Diffstat (limited to 'nx-X11/lib')
39 files changed, 0 insertions, 39769 deletions
diff --git a/nx-X11/lib/X11/ChkIfEv.c.NX.original b/nx-X11/lib/X11/ChkIfEv.c.NX.original deleted file mode 100644 index 0217af830..000000000 --- a/nx-X11/lib/X11/ChkIfEv.c.NX.original +++ /dev/null @@ -1,138 +0,0 @@ -/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1985, 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. - -*/ -/* $XFree86$ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Check existing events in queue to find if any match. If so, return. - * If not, flush buffer and see if any more events are readable. If one - * matches, return. If all else fails, tell the user no events found. - */ - -Bool XCheckIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 3; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 2: - _XEventsQueued(dpy, QueuedAfterReading); - break; - case 1: - _XFlush(dpy); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} - -#ifdef NX_TRANS_SOCKET - -/* - * This is just like XCheckIfEvent() but doesn't - * flush the output buffer if it can't read new - * events. - */ - -Bool XCheckIfEventNoFlush (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 2; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 1: - _XEventsQueued(dpy, QueuedAfterReading); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} - -#endif diff --git a/nx-X11/lib/X11/ChkIfEv.c.X.original b/nx-X11/lib/X11/ChkIfEv.c.X.original deleted file mode 100644 index ff74bcd73..000000000 --- a/nx-X11/lib/X11/ChkIfEv.c.X.original +++ /dev/null @@ -1,85 +0,0 @@ -/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -Copyright 1985, 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. - -*/ -/* $XFree86$ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Check existing events in queue to find if any match. If so, return. - * If not, flush buffer and see if any more events are readable. If one - * matches, return. If all else fails, tell the user no events found. - */ - -Bool XCheckIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; /* XEvent to be filled in. */ - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - int n; /* time through count */ - - LockDisplay(dpy); - prev = NULL; - for (n = 3; --n >= 0;) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return True; - } - } - if (prev) - qe_serial = prev->qserial_num; - switch (n) { - case 2: - _XEventsQueued(dpy, QueuedAfterReading); - break; - case 1: - _XFlush(dpy); - break; - } - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } - UnlockDisplay(dpy); - return False; -} diff --git a/nx-X11/lib/X11/ConnDis.c.NX.original b/nx-X11/lib/X11/ConnDis.c.NX.original deleted file mode 100644 index 30146a9f1..000000000 --- a/nx-X11/lib/X11/ConnDis.c.NX.original +++ /dev/null @@ -1,1465 +0,0 @@ -/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */ -/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -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. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */ - -/* - * 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> -#include <X11/Xdmcp.h> -#include <stdio.h> -#include <ctype.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 - -#ifdef LOCALCONN -#include <sys/utsname.h> -#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 (char *src, int len) -{ - char *dst = Xmalloc (len + 1); - - if (dst) { - strncpy (dst, src, len); - dst[len] = '\0'; - } - - return dst; -} - - -/* - * 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; -#ifdef LOCALCONN - struct utsname sys; -#endif -#ifdef TCPCONN - char *tcphostname = NULL; /* A place to save hostname pointer */ -#endif - - p = display_name; - - saddrlen = 0; /* set so that we can clear later */ - saddr = NULL; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Called with display_name [%s].\n", display_name); -#endif - -#ifdef NX_TRANS_SOCKET - - /* - * Check if user selected the "nx" - * protocol or an "nx" hostname. - */ - - if (!strncasecmp(p, "nx/", 3) || !strcasecmp(p, "nx") || - !strncasecmp(p, "nx:", 3) || !strncasecmp(p, "nx,", 3)) - { - if (*(display_name + 2) == '/') - { - p += 3; - } - - pprotocol = copystring ("nx", 2); - - if (!pprotocol) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Forced protocol to [%s].\n", pprotocol); -#endif - - } - else - { - -#endif - - /* - * 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 */ -#ifdef NX_TRANS_SOCKET - - } /* End of step 0. */ - - /* - * Check if user specified the "nx" protocol or - * hostname is "nx" or in the form "nx,...". - */ - - if (pprotocol && !strcasecmp(pprotocol, "nx")) - { - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Checking hostname [%s].\n", p); -#endif - - /* - * Options can include a "display=" tuple so - * need to scan right to left. - */ - - lastp = p; - lastc = NULL; - - for (; *p; p++) - if (*p == ':') - lastc = p; - - /* - * Don't complain if no screen was provided. - */ - - if (lastc) - { - phostname = copystring (lastp, lastc - lastp); - - p = lastc; - } - else - { - phostname = copystring (lastp, strlen(lastp)); - } - - if (!phostname) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Forced hostname [%s].\n", phostname); -#endif - - } - else - { - -#endif - - /* - * 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; - -#ifdef LOCALCONN - /* check if phostname == localnodename AND protocol not specified */ - if (!pprotocol && phostname && uname(&sys) >= 0 && - !strncmp(phostname, sys.nodename, - (strlen(sys.nodename) < strlen(phostname) ? - strlen(phostname) : strlen(sys.nodename)))) - { -#ifdef TCPCONN - /* - * We'll first attempt to connect using the local transport. If - * this fails (which is the case if sshd X protocol forwarding is - * being used), retry using tcp and this hostname. - */ - tcphostname = copystring(phostname, strlen(phostname)); -#endif - Xfree (phostname); - phostname = copystring ("unix", 4); - } -#endif - -#ifdef NX_TRANS_SOCKET - - } /* End of step 1. */ - - /* - * Check if no display was specified. In this case - * search the "port=n" option in NX host string. - */ - - if (*p) - { - -#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); - -#ifdef NX_TRANS_SOCKET - - } - else - { - char *host = NULL; - char *name = NULL; - char *value = NULL; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Searching port in port [%s].\n", phostname); -#endif - - if (!strncasecmp(phostname, "nx,", 3)) - { - host = copystring(phostname + 3, strlen(phostname) - 3); - } - - if (!host) goto bad; - - idisplay = -1; - - name = strtok(host, "="); - - while (name) - { - value = strtok(NULL, ","); - - if (value == NULL || strstr(value, "=") != NULL || - strstr(name, ",") != NULL || strlen(value) >= 128) - { - Xfree(host); - - goto bad; - } - else if (strcasecmp(name, "port") == 0) - { - idisplay = atoi(value); - - pdpynum = copystring(value, strlen(value)); - - if (!pdpynum) goto bad; - - break; - } - - name = strtok(NULL, "="); - } - - Xfree(host); - - if (idisplay == -1) - { - goto bad; - } - - } /* End of step 2. */ - -#endif - - - /* - * 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 ConnectionFlags - * build parameter the hostname string. If phostname is NULL or equals - * the string "local", then choose the best transport. If phostname - * is "unix", then choose BSD UNIX domain sockets (if configured). - */ - -#ifdef NX_TRANS_SOCKET - - /* - * If user selected the "nx" protocol - * force "local" transport. - */ - - if (pprotocol && !strcasecmp(pprotocol, "nx")) - { - pprotocol = copystring ("local", 5); - - if (!pprotocol) goto bad; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_X11TransConnectDisplay: Converted protocol to [%s].\n", pprotocol); -#endif - - } - -#endif - -#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN) - if (!pprotocol) { - if (!phostname) { -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - pprotocol = copystring ("local", 5); -#if defined(TCPCONN) - tcphostname = copystring("localhost", 9); -#endif - } - else - { -#endif - pprotocol = copystring ("tcp", 3); - } - } -#endif - -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - /* - * Now that the defaults have been established, see if we have any - * special names that we have to override: - * - * :N => if UNIXCONN then unix-domain-socket - * ::N => if UNIXCONN then unix-domain-socket - * unix:N => if UNIXCONN then unix-domain-socket - * - * Note that if UNIXCONN isn't defined, then we can use the default - * transport connection function set above. - */ - - if (!phostname) { -#ifdef apollo - ; /* Unix domain sockets are *really* bad on apollos */ -#else - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); -#endif - } - else if (strcmp (phostname, "unix") == 0) { - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); - } -#endif - -#if defined(TCPCONN) - connect: -#endif - /* - * 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). - */ -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Entering connection loop.\n"); -#endif - for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- ) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransOpenCOTSClient(address) with address [%s].\n", address); -#endif - if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) - { - break; - } -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConnect(trans_conn,address).\n"); -#endif - if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 ) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransClose(trans_conn).\n"); -#endif - _X11TransClose(trans_conn); - trans_conn = NULL; - - if (connect_stat == TRANS_TRY_CONNECT_AGAIN) - { - sleep(1); - continue; - } - else - break; - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr).\n"); -#endif - _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Going to call _X11TransConvertAddress(&family, &saddrlen, &saddr).\n"); -#endif - if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 ) - { - _X11TransClose(trans_conn); - trans_conn = NULL; - sleep(1); - if (saddr) - { - free ((char *) saddr); - saddr = NULL; - } - continue; - } - - break; - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "_X11TransConnectDisplay: Out of connection loop.\n"); -#endif - 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 - */ - 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; - - 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); -#ifdef TCPCONN - if (tcphostname) Xfree (tcphostname); -#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(TCPCONN) - if (tcphostname) { - pprotocol = copystring("tcp", 3); - phostname = tcphostname; - tcphostname = NULL; - goto connect; - } -#endif - - 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 NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, len); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - -#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(servername, window, cred_out, len) - 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(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/nx-X11/lib/X11/ConnDis.c.X.original b/nx-X11/lib/X11/ConnDis.c.X.original deleted file mode 100644 index 30616d207..000000000 --- a/nx-X11/lib/X11/ConnDis.c.X.original +++ /dev/null @@ -1,1233 +0,0 @@ -/* $XdotOrg: xc/lib/X11/ConnDis.c,v 1.10 2005/07/03 07:00:55 daniels Exp $ */ -/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/ConnDis.c,v 3.28 2003/12/02 23:33:17 herrb Exp $ */ - -/* - * 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> -#include <X11/Xdmcp.h> -#include <stdio.h> -#include <ctype.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 - -#ifdef LOCALCONN -#include <sys/utsname.h> -#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 (char *src, int len) -{ - char *dst = Xmalloc (len + 1); - - if (dst) { - strncpy (dst, src, len); - dst[len] = '\0'; - } - - return dst; -} - - -/* - * 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; -#ifdef LOCALCONN - struct utsname sys; -#endif -#ifdef TCPCONN - char *tcphostname = NULL; /* A place to save hostname pointer */ -#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; - -#ifdef LOCALCONN - /* check if phostname == localnodename AND protocol not specified */ - if (!pprotocol && phostname && uname(&sys) >= 0 && - !strncmp(phostname, sys.nodename, - (strlen(sys.nodename) < strlen(phostname) ? - strlen(phostname) : strlen(sys.nodename)))) - { -#ifdef TCPCONN - /* - * We'll first attempt to connect using the local transport. If - * this fails (which is the case if sshd X protocol forwarding is - * being used), retry using tcp and this hostname. - */ - tcphostname = copystring(phostname, strlen(phostname)); -#endif - Xfree (phostname); - phostname = copystring ("unix", 4); - } -#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 ConnectionFlags - * build parameter the hostname string. If phostname is NULL or equals - * the string "local", then choose the best transport. If phostname - * is "unix", then choose BSD UNIX domain sockets (if configured). - */ - -#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN) || defined(MNX_TCPCONN) || defined(OS2PIPECONN) - if (!pprotocol) { - if (!phostname) { -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - pprotocol = copystring ("local", 5); -#if defined(TCPCONN) - tcphostname = copystring("localhost", 9); -#endif - } - else - { -#endif - pprotocol = copystring ("tcp", 3); - } - } -#endif - -#if defined(UNIXCONN) || defined(LOCALCONN) || defined(OS2PIPECONN) - /* - * Now that the defaults have been established, see if we have any - * special names that we have to override: - * - * :N => if UNIXCONN then unix-domain-socket - * ::N => if UNIXCONN then unix-domain-socket - * unix:N => if UNIXCONN then unix-domain-socket - * - * Note that if UNIXCONN isn't defined, then we can use the default - * transport connection function set above. - */ - - if (!phostname) { -#ifdef apollo - ; /* Unix domain sockets are *really* bad on apollos */ -#else - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); -#endif - } - else if (strcmp (phostname, "unix") == 0) { - if( pprotocol ) Xfree(pprotocol); - pprotocol = copystring ("local", 5); - } -#endif - -#if defined(TCPCONN) - connect: -#endif - /* - * 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) - { - sleep(1); - 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; - sleep(1); - 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 - */ - 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; - - 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); -#ifdef TCPCONN - if (tcphostname) Xfree (tcphostname); -#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(TCPCONN) - if (tcphostname) { - pprotocol = copystring("tcp", 3); - phostname = tcphostname; - tcphostname = NULL; - goto connect; - } -#endif - - 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(servername, window, cred_out, len) - 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(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/nx-X11/lib/X11/IfEvent.c.NX.original b/nx-X11/lib/X11/IfEvent.c.NX.original deleted file mode 100644 index a7c0cb188..000000000 --- a/nx-X11/lib/X11/IfEvent.c.NX.original +++ /dev/null @@ -1,80 +0,0 @@ -/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Flush output and (wait for and) return the next event matching the - * predicate in the queue. - */ - -int -XIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; - char *arg; -{ - register _XQEvent *qelt, *prev; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} diff --git a/nx-X11/lib/X11/IfEvent.c.X.original b/nx-X11/lib/X11/IfEvent.c.X.original deleted file mode 100644 index 55e7829ca..000000000 --- a/nx-X11/lib/X11/IfEvent.c.X.original +++ /dev/null @@ -1,75 +0,0 @@ -/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/IfEvent.c,v 1.4 2001/12/14 19:54:01 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * Flush output and (wait for and) return the next event matching the - * predicate in the queue. - */ - -int -XIfEvent (dpy, event, predicate, arg) - register Display *dpy; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); /* function to call */ - register XEvent *event; - char *arg; -{ - register _XQEvent *qelt, *prev; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} diff --git a/nx-X11/lib/X11/Imakefile.NX.original b/nx-X11/lib/X11/Imakefile.NX.original deleted file mode 100644 index d8d0601b8..000000000 --- a/nx-X11/lib/X11/Imakefile.NX.original +++ /dev/null @@ -1,1237 +0,0 @@ -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $ - - - - HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \ - Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h - -#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer && !NXAgentServer -all:: - -BuildIncludes($(HEADERS),IncSubdir,..) - -#else - -#if NXLibraries - -#ifdef SunArchitecture -NX_INCLUDES = -I../../../nxcomp -I/usr/sfw/include -#else -NX_INCLUDES = -I../../../nxcomp -#endif - -NX_DEFINES = -DNX_TRANS_SOCKET \ - -DNX_TRANS_EXIT - -# -DNX_TRANS_CHANGE \ -# -DNX_TRANS_WARN \ -# -DNX_TRANS_INFO \ -# -DNX_TRANS_TEST \ -# -DNX_TRANS_DEBUG \ - -#ifdef cygwinArchitecture -NX_XCOMPLIBNAME = cygXcomp.dll -NX_XCOMPEXTLIBNAME = cygXcompext.dll -#else -NX_XCOMPLIBNAME = libXcomp.so -NX_XCOMPEXTLIBNAME = libXcompext.so -#endif - -NX_XCOMPLIBDIR = $(XTOP)/../nxcomp -NX_XCOMPLIBLINK = Xcomp -NX_XCOMPLIBTARGET = $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) -NX_REQUIREDLIBS = -L$(NX_XCOMPLIBDIR) -l$(NX_XCOMPLIBLINK) -NX_XCOMPDEPTARGET = $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) -NX_XCOMPCONFIGTARGET = $(NX_XCOMPLIBDIR)/config.status - -NX_XCOMPEXTLIBDIR = $(XTOP)/../nxcompext -NX_XCOMPEXTLIBTARGET = $(NX_XCOMPEXTLIBDIR)/$(NX_XCOMPEXTLIBNAME) -NX_XCOMPEXTCONFIGTARGET = $(NX_XCOMPEXTLIBDIR)/config.status - -#endif - -#if BuildLoadableXlibI18n -#define IHaveSubdirs -#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" -#define NoLibSubdirs -#endif - -#define DoNormalLib NormalLibX11 -#define DoSharedLib SharedLibX11 -#define DoExtraLib SharedLibX11 -#define DoDebugLib DebugLibX11 -#define DoProfileLib ProfileLibX11 -#define LibName X11 -#define SoRev SOXLIBREV -#define HugeLibrary YES -#define IncSubdir X11 - -#if BuildLoadableXlibI18n -SUBDIRS = xlibi18n -#endif - -#include <Threads.tmpl> - -#ifndef MotifBC -#define MotifBC NO -#endif - -#ifdef SharedX11Reqs -REQUIREDX11LIBS = SharedX11Reqs -#endif -#if BuildLoadableXlibI18n -REQUIREDI18NLIBS = DlLibrary -#endif -#ifdef cygwinArchitecture -EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity -#endif - -REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) $(NX_REQUIREDLIBS) - -#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture) -XBSDLIB = /**/ -#endif -#if defined(LunaArchitecture) && defined(Mc88000Architecture) -EXTRA_LIBRARIES = /**/ -#endif -#if Malloc0ReturnsNull - MALLOC_DEFINES = XMalloc0ReturnsNullDefines -#endif -#if HasXdmAuth - XDMAUTHDEFS = -DHASXDMAUTH - XDMAUTHOBJS = Wrap.o Wraphelp.o - XDMAUTHSRCS = Wrap.c Wraphelp.c -#endif -#if BuildXKBlib - XKB_DEFINES = -DXKB - XKBSRCS = 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 - XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \ - XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \ - XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \ - XKBList.o XKBMisc.o \ - XKBMAlloc.o XKBGAlloc.o XKBAlloc.o -#endif -#if HasSecureRPC - RPCDEFS = -DSECURE_RPC -#endif -#if HasPoll - POLL_DEFINES = -DUSE_POLL -#endif - CONN_DEFINES = $(CONNECTION_FLAGS) - XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) - XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) -#if HasBSD44Sockets - SOCK_DEFINES = -DBSD44SOCKETS -#endif -#if HasShm - SHM_DEFINES = -DHAS_SHM -#endif - - XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines - - EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\" - KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\" - CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\" -#if HasSnprintf - MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11 -#endif -#if MotifBC - BC_DEFINES = -DMOTIFBC -#endif -#if NoRConst - RCONST_DEFINES = -DNORCONST -#endif -#if DisableXLocaleDirEnv - SETID_DEFINES = -DNO_XLOCALEDIR -#elif HasIssetugid - SETID_DEFINES = -DHASSETUGID -#elif HasGetresuid - SETID_DEFINES = -DHASGETRESUID -#endif - XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\" -#if HasKrb5 - K5OBJS = k5encode.o - K5SRCS = k5encode.c - K5INCL = Krb5Includes - K5DEFS = Krb5Defines -#endif -#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \ - defined(OpenBSDArchitecture) -THRSTUBSRCS = UIThrStubs.c -THRSTUBOBJS = UIThrStubs.o -#endif -#if BuildLoadableXlibXcursor -XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\" -#endif -#if NeedLibInsideFlag - LIB_DEFINES = -D_XLIBINT_ -#endif -#if defined(LibDirName) - POSTLOCALELIBDIR = LibDirName - POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\" -#endif - DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\ - $(POSTLOCALELIBDEFINES) $(NX_INCLUDES) $(NX_DEFINES) - OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS) - DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines - AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o - AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c - SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */ - LINTLIBS = - -#if BuildLoadableXlibI18n && DoSharedLib -EXTRASHAREDSRC = $(SHAREDLCSRCS) -#endif -#if !BuildLoadableXlibI18n || DoNormalLib -EXTRASTATICSRC = $(STATICLCSRCS) -#endif - -EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC) - -SRCS1 = \ - Context.c \ - Depths.c \ - ParseCmd.c \ - Quarks.c \ - AllCells.c \ - AllPlanes.c \ - AllowEv.c \ - AutoRep.c \ - Backgnd.c \ - BdrWidth.c \ - Bell.c \ - Border.c \ - ChAccCon.c \ - ChClMode.c \ - ChActPGb.c \ - ChCmap.c \ - ChGC.c \ - ChKeyCon.c \ - ChPntCon.c \ - ChProp.c \ - ChSaveSet.c \ - ChWAttrs.c \ - ChWindow.c \ - ChkIfEv.c \ - ChkMaskEv.c \ - ChkWinEv.c \ - ChkTypEv.c \ - ChkTypWEv.c \ - CirWin.c \ - CirWinDn.c \ - CirWinUp.c \ - ClDisplay.c \ - Clear.c \ - ClearArea.c \ - ConfWind.c \ - ConnDis.c \ - ConvSel.c \ - CopyArea.c \ - CopyCmap.c \ - CopyGC.c \ - CopyPlane.c \ - CrBFData.c \ - CrCmap.c \ - CrCursor.c \ - CrGC.c \ - CrGlCur.c \ - CrPFBData.c \ - CrPixmap.c \ - CrWindow.c \ - Cursor.c \ - DefCursor.c \ - DelProp.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 \ - EvToWire.c \ - FetchName.c \ - FillArc.c \ - FillArcs.c \ - FillPoly.c \ - FillRct.c \ - FillRcts.c \ - Flush.c \ - Font.c \ - FontNames.c \ - FontInfo.c \ - FreeCmap.c \ - FreeCols.c \ - FreeCurs.c \ - FreeEData.c \ - FreeGC.c \ - FreePix.c \ - FSSaver.c \ - GCMisc.c \ - Geom.c \ - GetAtomNm.c \ - GetColor.c \ - GetDflt.c \ - GetFPath.c \ - GetFProp.c \ - GetGeom.c \ - GetHColor.c \ - GetHints.c \ - GetIFocus.c \ - GetImage.c \ - GetKCnt.c \ - GetMoEv.c \ - GetPCnt.c \ - GetPntMap.c \ - GetProp.c \ - GetSOwner.c \ - GetSSaver.c \ - GetStCmap.c \ - GetWAttrs.c \ - GrButton.c \ - GrKey.c \ - GrKeybd.c \ - GrPointer.c \ - GrServer.c \ - Host.c \ - IfEvent.c \ - ImUtil.c \ - ImText.c \ - ImText16.c \ - InitExt.c \ - InsCmap.c \ - IntAtom.c \ - KeyBind.c \ - KeysymStr.c \ - KillCl.c \ - LiHosts.c \ - LiICmaps.c \ - LiProps.c \ - ListExt.c \ - LoadFont.c \ - LookupCol.c \ - LowerWin.c - -OBJS1 = \ - Context.o \ - Depths.o \ - ParseCmd.o \ - Quarks.o \ - AllCells.o \ - AllPlanes.o \ - AllowEv.o \ - AutoRep.o \ - Backgnd.o \ - BdrWidth.o \ - Bell.o \ - Border.o \ - ChAccCon.o \ - ChClMode.o \ - ChActPGb.o \ - ChCmap.o \ - ChGC.o \ - ChKeyCon.o \ - ChPntCon.o \ - ChProp.o \ - ChSaveSet.o \ - ChWAttrs.o \ - ChWindow.o \ - ChkIfEv.o \ - ChkMaskEv.o \ - ChkWinEv.o \ - ChkTypEv.o \ - ChkTypWEv.o \ - CirWin.o \ - CirWinDn.o \ - CirWinUp.o \ - ClDisplay.o \ - Clear.o \ - ClearArea.o \ - ConfWind.o \ - ConnDis.o \ - ConvSel.o \ - CopyArea.o \ - CopyCmap.o \ - CopyGC.o \ - CopyPlane.o \ - CrBFData.o \ - CrCmap.o \ - CrCursor.o \ - CrGC.o \ - CrGlCur.o \ - CrPFBData.o \ - CrPixmap.o \ - CrWindow.o \ - Cursor.o \ - DefCursor.o \ - DelProp.o \ - DestSubs.o \ - DestWind.o \ - DisName.o \ - DrArc.o \ - DrArcs.o \ - DrLine.o \ - DrLines.o \ - DrPoint.o \ - DrPoints.o \ - DrRect.o \ - DrRects.o \ - DrSegs.o \ - ErrDes.o \ - ErrHndlr.o \ - EvToWire.o \ - FetchName.o \ - FillArc.o \ - FillArcs.o \ - FillPoly.o \ - FillRct.o \ - FillRcts.o \ - Flush.o \ - Font.o \ - FontNames.o \ - FontInfo.o \ - FreeCmap.o \ - FreeCols.o \ - FreeCurs.o \ - FreeEData.o \ - FreeGC.o \ - FreePix.o \ - FSSaver.o \ - GCMisc.o \ - Geom.o \ - GetAtomNm.o \ - GetColor.o \ - GetDflt.o \ - GetFPath.o \ - GetFProp.o \ - GetGeom.o \ - GetHColor.o \ - GetHints.o \ - GetIFocus.o \ - GetImage.o \ - GetKCnt.o \ - GetMoEv.o \ - GetPCnt.o \ - GetPntMap.o \ - GetProp.o \ - GetSOwner.o \ - GetSSaver.o \ - GetStCmap.o \ - GetWAttrs.o \ - GrButton.o \ - GrKey.o \ - GrKeybd.o \ - GrPointer.o \ - GrServer.o \ - Host.o \ - IfEvent.o \ - ImUtil.o \ - ImText.o \ - ImText16.o \ - InitExt.o \ - InsCmap.o \ - IntAtom.o \ - KeyBind.o \ - KeysymStr.o \ - KillCl.o \ - LiHosts.o \ - LiICmaps.o \ - LiProps.o \ - ListExt.o \ - LoadFont.o \ - LookupCol.o \ - LowerWin.o - -SRCS2 = \ - Macros.c \ - MapRaised.c \ - MapSubs.c \ - MapWindow.c \ - MaskEvent.c \ - Misc.c \ - ModMap.c \ - MoveWin.c \ - NextEvent.c \ - OpenDis.c \ - ParseCol.c \ - ParseGeom.c \ - PeekEvent.c \ - PeekIfEv.c \ - Pending.c \ - PmapBgnd.c \ - PmapBord.c \ - PolyReg.c \ - PolyTxt.c \ - PolyTxt16.c \ - PutBEvent.c \ - PutImage.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 \ - Region.c \ - RepWindow.c \ - RestackWs.c \ - RotProp.c \ - ScrResStr.c \ - SelInput.c \ - SendEvent.c \ - SetBack.c \ - SetCRects.c \ - SetClMask.c \ - SetClOrig.c \ - SetDashes.c \ - SetFPath.c \ - SetFont.c \ - SetFore.c \ - SetFunc.c \ - SetHints.c \ - SetIFocus.c \ - SetLStyle.c \ - SetPMask.c \ - SetPntMap.c \ - SetSOwner.c \ - SetSSaver.c \ - SetState.c \ - SetStip.c \ - SetStCmap.c \ - SetTile.c \ - SetTSOrig.c \ - StBytes.c \ - StColor.c \ - StColors.c \ - StNColor.c \ - StName.c \ - StrKeysym.c \ - Sync.c \ - Synchro.c \ - Text.c \ - Text16.c \ - TextExt.c \ - TextExt16.c \ - TrCoords.c \ - UndefCurs.c \ - UngrabBut.c \ - UngrabKbd.c \ - UngrabKey.c \ - UngrabPtr.c \ - UngrabSvr.c \ - UninsCmap.c \ - UnldFont.c \ - UnmapSubs.c \ - UnmapWin.c \ - VisUtil.c \ - WarpPtr.c \ - WinEvent.c \ - Window.c \ - WrBitF.c \ - XlibAsync.c \ - XlibInt.c \ - Xrm.c \ - evtomask.c \ - globals.c \ - GetGCVals.c \ - GetNrmHint.c \ - GetRGBCMap.c \ - GetTxtProp.c \ - GetWMCMapW.c \ - GetWMProto.c \ - Iconify.c \ - PixFormats.c \ - PropAlloc.c \ - ReconfWM.c \ - SetNrmHint.c \ - SetRGBCMap.c \ - SetTxtProp.c \ - SetWMCMapW.c \ - SetWMProto.c \ - StrToText.c \ - TextToStr.c \ - Withdraw.c \ - WMGeom.c \ - WMProps.c \ - $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS) - -OBJS2 = \ - Macros.o \ - MapRaised.o \ - MapSubs.o \ - MapWindow.o \ - MaskEvent.o \ - Misc.o \ - ModMap.o \ - MoveWin.o \ - NextEvent.o \ - OpenDis.o \ - ParseCol.o \ - ParseGeom.o \ - PeekEvent.o \ - PeekIfEv.o \ - Pending.o \ - PmapBgnd.o \ - PmapBord.o \ - PolyReg.o \ - PolyTxt.o \ - PolyTxt16.o \ - PutBEvent.o \ - PutImage.o \ - QuBest.o \ - QuColor.o \ - QuColors.o \ - QuCurShp.o \ - QuExt.o \ - QuKeybd.o \ - QuPntr.o \ - QuStipShp.o \ - QuTextE16.o \ - QuTextExt.o \ - QuTileShp.o \ - QuTree.o \ - RaiseWin.o \ - RdBitF.o \ - RecolorC.o \ - ReconfWin.o \ - Region.o \ - RepWindow.o \ - RestackWs.o \ - RotProp.o \ - ScrResStr.o \ - SelInput.o \ - SendEvent.o \ - SetBack.o \ - SetCRects.o \ - SetClMask.o \ - SetClOrig.o \ - SetDashes.o \ - SetFPath.o \ - SetFont.o \ - SetFore.o \ - SetFunc.o \ - SetHints.o \ - SetIFocus.o \ - SetLStyle.o \ - SetPMask.o \ - SetPntMap.o \ - SetSOwner.o \ - SetSSaver.o \ - SetState.o \ - SetStip.o \ - SetStCmap.o \ - SetTile.o \ - SetTSOrig.o \ - StBytes.o \ - StColor.o \ - StColors.o \ - StNColor.o \ - StName.o \ - StrKeysym.o \ - Sync.o \ - Synchro.o \ - Text.o \ - Text16.o \ - TextExt.o \ - TextExt16.o \ - TrCoords.o \ - UndefCurs.o \ - UngrabBut.o \ - UngrabKbd.o \ - UngrabKey.o \ - UngrabPtr.o \ - UngrabSvr.o \ - UninsCmap.o \ - UnldFont.o \ - UnmapSubs.o \ - UnmapWin.o \ - VisUtil.o \ - WarpPtr.o \ - WinEvent.o \ - Window.o \ - WrBitF.o \ - XlibAsync.o \ - XlibInt.o \ - Xrm.o \ - evtomask.o \ - globals.o \ - GetGCVals.o \ - GetNrmHint.o \ - GetRGBCMap.o \ - GetTxtProp.o \ - GetWMCMapW.o \ - GetWMProto.o \ - Iconify.o \ - PixFormats.o \ - PropAlloc.o \ - ReconfWM.o \ - SetNrmHint.o \ - SetRGBCMap.o \ - SetTxtProp.o \ - SetWMCMapW.o \ - SetWMProto.o \ - StrToText.o \ - TextToStr.o \ - Withdraw.o \ - WMGeom.o \ - WMProps.o \ - $(AUTHOBJS) \ - $(XDMAUTHOBJS) \ - $(K5OBJS) \ - $(THRSTUBOBJS) - -SRCS3 = \ - 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 \ - XYZ.c \ - uvY.c \ - xyY.c \ - HVC.c \ - HVCGcC.c \ - HVCGcV.c \ - HVCGcVC.c \ - HVCMnV.c \ - HVCMxC.c \ - HVCMxV.c \ - HVCMxVC.c \ - HVCMxVs.c \ - HVCWpAj.c \ - UNDEFINED.c \ - AddDIC.c \ - AddSF.c \ - cmsAllNCol.c \ - cmsAllCol.c \ - CCC.c \ - cmsCmap.c \ - cmsColNm.c \ - CvColW.c \ - CvCols.c \ - cmsGlobls.c \ - IdOfPr.c \ - cmsInt.c \ - LRGB.c \ - cmsLkCol.c \ - cmsMath.c \ - OfCCC.c \ - PrOfId.c \ - cmsProp.c \ - QBlack.c \ - QBlue.c \ - QGreen.c \ - QRed.c \ - QWhite.c \ - QuCol.c \ - QuCols.c \ - SetCCC.c \ - SetGetCols.c \ - StCol.c \ - StCols.c \ - cmsTrig.c \ - XRGB.c \ - FSWrap.c \ - ICWrap.c \ - IMWrap.c \ - OCWrap.c \ - OMWrap.c \ - lcWrap.c \ - mbWMProps.c \ - utf8WMProps.c \ - mbWrap.c \ - wcWrap.c \ - utf8Wrap.c \ - FilterEv.c \ - RegstFlt.c \ - locking.c \ - LockDis.c \ - x11trans.c \ - ximtrans.c \ - $(XKBSRCS) $(LCSRCS) $(MISCSRCS) - -OBJS3 = \ - Lab.o \ - LabGcC.o \ - LabGcL.o \ - LabGcLC.o \ - LabMnL.o \ - LabMxC.o \ - LabMxL.o \ - LabMxLC.o \ - LabWpAj.o \ - Luv.o \ - LuvGcC.o \ - LuvGcL.o \ - LuvGcLC.o \ - LuvMnL.o \ - LuvMxC.o \ - LuvMxL.o \ - LuvMxLC.o \ - LuvWpAj.o \ - XYZ.o \ - uvY.o \ - xyY.o \ - HVC.o \ - HVCGcC.o \ - HVCGcV.o \ - HVCGcVC.o \ - HVCMnV.o \ - HVCMxC.o \ - HVCMxV.o \ - HVCMxVC.o \ - HVCMxVs.o \ - HVCWpAj.o \ - UNDEFINED.o \ - AddDIC.o \ - AddSF.o \ - cmsAllNCol.o \ - cmsAllCol.o \ - CCC.o \ - cmsCmap.o \ - cmsColNm.o \ - CvColW.o \ - CvCols.o \ - cmsGlobls.o \ - IdOfPr.o \ - cmsInt.o \ - LRGB.o \ - cmsLkCol.o \ - cmsMath.o \ - OfCCC.o \ - PrOfId.o \ - cmsProp.o \ - QBlack.o \ - QBlue.o \ - QGreen.o \ - QRed.o \ - QWhite.o \ - QuCol.o \ - QuCols.o \ - SetCCC.o \ - SetGetCols.o \ - StCol.o \ - StCols.o \ - cmsTrig.o \ - XRGB.o \ - FSWrap.o \ - ICWrap.o \ - IMWrap.o \ - OCWrap.o \ - OMWrap.o \ - lcWrap.o \ - mbWMProps.o \ - utf8WMProps.o \ - mbWrap.o \ - wcWrap.o \ - utf8Wrap.o \ - FilterEv.o \ - RegstFlt.o \ - locking.o \ - LockDis.o \ - x11trans.o \ - ximtrans.o \ - $(XKBOBJS) $(LCOBJS) $(MISCOBJS) - -#if BuildLoadableXlibI18n -LC_DYNDEFINES = -DUSE_DYNAMIC_LC -#endif - -SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c - -SHAREDI18NSTATICSRCS = \ - XDefaultIMIF.c XDefaultOMIF.c - -STATICLCDEPSYMSRCS = - -STATICI18NSTATICSRCS = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRm.c \ - imRmAttr.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrX.c \ - imTransR.c \ - imTrans.c \ - lcEuc.c \ - lcGenConv.c \ - lcJis.c \ - lcSjis.c \ - lcUTF8Load.c \ - omDefault.c \ - omGeneric.c \ - omImText.c \ - omText.c \ - omTextEsc.c \ - omTextExt.c \ - omTextPer.c \ - omXChar.c - -LCSRCS = \ - SetLocale.c \ - imConv.c \ - imKStoUCS.c \ - lcCT.c \ - lcCharSet.c \ - lcConv.c \ - lcDB.c \ - lcDefConv.c \ - lcFile.c \ - lcGeneric.c \ - lcInit.c \ - lcPrTxt.c \ - lcPubWrap.c \ - lcPublic.c \ - lcRM.c \ - lcStd.c \ - lcTxtPr.c \ - lcUtil.c \ - lcUTF8.c - -STATICLCSRCS = \ - $(STATICLCDEPSYMSRCS) \ - $(STATICI18NSTATICSRCS) - -SHAREDLCSRCS = \ - $(SHAREDLCDEPSYMSRCS) \ - $(SHAREDI18NSTATICSRCS) - -SHAREDLCDEPOBJS = XlcDL.o XlcSL.o -SHAREDI18NSTATICOBJS = \ - XDefaultIMIF.o XDefaultOMIF.o -STATICLCDEPOBJS = -STATICI18NSTATICOBJS = \ - imCallbk.o \ - imDefFlt.o \ - imDefIc.o \ - imDefIm.o \ - imDefLkup.o \ - imDispch.o \ - imEvToWire.o \ - imExten.o \ - imImSw.o \ - imInsClbk.o \ - imInt.o \ - imLcFlt.o \ - imLcGIc.o \ - imLcIc.o \ - imLcIm.o \ - imLcLkup.o \ - imLcPrs.o \ - imLcSIc.o \ - imRm.o \ - imRmAttr.o \ - imThaiFlt.o \ - imThaiIc.o \ - imThaiIm.o \ - imTrX.o \ - imTransR.o \ - imTrans.o \ - lcEuc.o \ - lcGenConv.o \ - lcJis.o \ - lcSjis.o \ - lcUTF8Load.o \ - omDefault.o \ - omGeneric.o \ - omImText.o \ - omText.o \ - omTextEsc.o \ - omTextExt.o \ - omTextPer.o \ - omXChar.o - -LCOBJS = \ - SetLocale.o \ - imConv.o \ - imKStoUCS.o \ - lcCT.o \ - lcCharSet.o \ - lcConv.o \ - lcDB.o \ - lcDefConv.o \ - lcFile.o \ - lcGeneric.o \ - lcInit.o \ - lcPrTxt.o \ - lcPubWrap.o \ - lcPublic.o \ - lcRM.o \ - lcStd.o \ - lcTxtPr.o \ - lcUtil.o \ - lcUTF8.o - -STATICLCOBJS = \ - $(STATICLCDEPOBJS) \ - $(STATICI18NSTATICOBJS) - -SHAREDLCOBJS = \ - $(SHAREDLCDEPOBJS) \ - $(SHAREDI18NSTATICOBJS) - -#ifdef OS2Architecture -MISCSRCS = os2Stubs.c -#endif - -#ifdef OS2Architecture -MISCOBJS = os2Stubs.o -#endif - -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -EXTRAUNSHAREDOBJS = $(STATICLCOBJS) - -#if BuildLoadableXlibI18n -EXTRASHAREDOBJS = $(SHAREDLCOBJS) -# else -EXTRASHAREDOBJS = $(STATICLCOBJS) -#endif - -#include <Library.tmpl> - -SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES)) -SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES)) -SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS)) -SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES)) -LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES)) -LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES)) -SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS)) -SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES)) -SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES)) -SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES)) -SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES)) -SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES)) -#if BuildXKBlib -SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES)) -#endif -#if HasKrb5 -SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL)) -#endif -#if BuildLoadableXlibI18n -SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -#endif -#if BuildLoadableXlibXcursor -SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -#endif - -#if InstallXcmsTxt -InstallNonExecFile(Xcms.txt,$(LIBDIR)) -#endif -InstallNonExecFile(XErrorDB,$(LIBDIR)) -InstallNonExecFile(XKeysymDB,$(LIBDIR)) -InstallLintLibrary(X11,$(LINTLIBDIR)) - - -LinkSourceFile(AuDispose.c,$(XAUTHSRC)) -LinkSourceFile(AuGetBest.c,$(XAUTHSRC)) -LinkSourceFile(AuFileName.c,$(XAUTHSRC)) -LinkSourceFile(AuRead.c,$(XAUTHSRC)) -#if HasKrb5 -LinkSourceFile(k5encode.c,$(XAUTHSRC)) -#endif -#if HasXdmAuth -LinkSourceFile(Wrap.h,$(XDMCPLIBSRC)) -LinkSourceFile(Wrap.c,$(XDMCPLIBSRC)) -LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC)) -#endif - -#ifdef QNX4Architecture -LOCAL_LDFLAGS=-F -#endif - -MAKEKEYS = ./makekeys - -#if CrossCompiling -HOST_LDLIBS= -HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \ - $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES) -#else -HOST_LDLIBS=$(LDLIBS) -HOST_CFLAGS=$(CFLAGS) -#endif - -ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c - RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf) - -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS)) - RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h) - $(MV) ks_tables_h $@ - RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h) - -includes:: ks_tables.h - -#if NXLibraries - -$(NX_XCOMPCONFIGTARGET): - cd ../../../nxcomp && \ - ./configure - -$(NX_XCOMPEXTCONFIGTARGET): - cd ../../../nxcompext && \ - ./configure - -#ifdef SunArchitecture -$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET) - cd $(NX_XCOMPLIBDIR) && \ - gmake - -$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET) - cd ../../../nxcompext && \ - gmake - -#else -$(NX_XCOMPLIBTARGET): $(NX_XCOMPCONFIGTARGET) - cd $(NX_XCOMPLIBDIR) && \ - make - -$(NX_XCOMPEXTLIBTARGET): $(NX_XCOMPEXTCONFIGTARGET) - cd ../../../nxcompext && \ - make - -#endif - -depend:: $(NX_XCOMPLIBTARGET) - -all:: $(NX_XCOMPLIBTARGET) - -$(NX_XCOMPDEPTARGET): - ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME) $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) - ln -s $(NX_XCOMPLIBDIR)/$(NX_XCOMPLIBNAME).1 $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1 - -depend:: $(NX_XCOMPLIBTARGET) - -all:: $(NX_XCOMPDEPTARGET) $(NX_XCOMPEXTLIBTARGET) - -clean:: - rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME) - rm -f $(BUILDLIBDIR)/$(NX_XCOMPLIBNAME).1 - -#endif - -depend:: ks_tables.h - -clean:: - RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys)) - - -DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS)) - -#if BuildLoadableXlibI18n -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) -MakeLintLibSubdirs($(LINTSUBDIRS)) -MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln) -#endif -#endif - -includes:: XlibConf.h - -#include <Threads.tmpl> - -#if ThreadedProject -#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\ - echo '#define XTHREADS' >> $@ @@\ - echo '#endif' >> $@ -#else -#define XThreadsDefine echo '#undef XTHREADS' >> $@ -#endif - -#if HasThreadSafeAPI -#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\ - echo '#define XUSE_MTSAFE_API' >> $@ @@\ - echo '#endif' >> $@ -#else -#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@ -#endif - -XlibConf.h: - echo '/* Defines needed to use Xlib from non-imake projects */' > $@ - XThreadsDefine - MTSafeAPIDefine diff --git a/nx-X11/lib/X11/Imakefile.X.original b/nx-X11/lib/X11/Imakefile.X.original deleted file mode 100644 index 1f2c9b2bc..000000000 --- a/nx-X11/lib/X11/Imakefile.X.original +++ /dev/null @@ -1,1134 +0,0 @@ -XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ - - - - -XCOMM $XFree86: xc/lib/X11/Imakefile,v 3.52 2003/05/27 16:53:15 tsi Exp $ - - - - HEADERS = Xlib.h Xresource.h Xutil.h cursorfont.h Xlibint.h \ - Xcms.h Xlocale.h XKBlib.h XlibConf.h Xregion.h ImUtil.h - -#if BuildServersOnly && !XWinServer && !XnestServer && !BuildGLXLibrary && !BuildClients && !XdmxServer -all:: - -BuildIncludes($(HEADERS),IncSubdir,..) - -#else - -#if BuildLoadableXlibI18n -#define IHaveSubdirs -#define PassCDebugFlags CDEBUGFLAGS="$(CDEBUGFLAGS)" -#define NoLibSubdirs -#endif - -#define DoNormalLib NormalLibX11 -#define DoSharedLib SharedLibX11 -#define DoExtraLib SharedLibX11 -#define DoDebugLib DebugLibX11 -#define DoProfileLib ProfileLibX11 -#define LibName X11 -#define SoRev SOXLIBREV -#define HugeLibrary YES -#define IncSubdir X11 - -#if BuildLoadableXlibI18n -SUBDIRS = xlibi18n -#endif - -#include <Threads.tmpl> - -#ifndef MotifBC -#define MotifBC NO -#endif - -#ifdef SharedX11Reqs -REQUIREDX11LIBS = SharedX11Reqs -#endif -#if BuildLoadableXlibI18n -REQUIREDI18NLIBS = DlLibrary -#endif -#ifdef cygwinArchitecture -EXCLUDE_SYMBOL = -Wl,--exclude-symbol,XdmcpWrap:_XdmcpWrapperToOddParity -#endif - -REQUIREDLIBS=$(REQUIREDX11LIBS) $(REQUIREDI18NLIBS) $(EXCLUDE_SYMBOL) - -#if defined(MacIIArchitecture) || defined(SequentArchitecture) || defined(i386ScoArchitecture) -XBSDLIB = /**/ -#endif -#if defined(LunaArchitecture) && defined(Mc88000Architecture) -EXTRA_LIBRARIES = /**/ -#endif -#if Malloc0ReturnsNull - MALLOC_DEFINES = XMalloc0ReturnsNullDefines -#endif -#if HasXdmAuth - XDMAUTHDEFS = -DHASXDMAUTH - XDMAUTHOBJS = Wrap.o Wraphelp.o - XDMAUTHSRCS = Wrap.c Wraphelp.c -#endif -#if BuildXKBlib - XKB_DEFINES = -DXKB - XKBSRCS = 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 - XKBOBJS = XKB.o XKBBind.o XKBCompat.o XKBCtrls.o XKBCvt.o XKBGetMap.o \ - XKBGetByName.o XKBNames.o XKBRdBuf.o XKBSetMap.o XKBUse.o \ - XKBleds.o XKBBell.o XKBGeom.o XKBSetGeom.o XKBExtDev.o \ - XKBList.o XKBMisc.o \ - XKBMAlloc.o XKBGAlloc.o XKBAlloc.o -#endif -#if HasSecureRPC - RPCDEFS = -DSECURE_RPC -#endif -#if HasPoll - POLL_DEFINES = -DUSE_POLL -#endif - CONN_DEFINES = $(CONNECTION_FLAGS) - XTRANS_X_DEFINES = -DX11_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) - XTRANS_XIM_DEFINES = -DXIM_t -DTRANS_CLIENT $(XTRANS_FAILDEFINES) -#if HasBSD44Sockets - SOCK_DEFINES = -DBSD44SOCKETS -#endif -#if HasShm - SHM_DEFINES = -DHAS_SHM -#endif - - XF86BIGFONT_DEFINES = XF86BigfontExtensionDefines - - EDB_DEFINES = -DERRORDB=\"$(LIBDIR)/XErrorDB\" - KDB_DEFINES = -DKEYSYMDB=\"$(LIBDIR)/XKeysymDB\" - CMS_DEFINES = -DXCMSDB=\"$(LIBDIR)/Xcms.txt\" -#if HasSnprintf - MISC_DEFINES = -DHAS_SNPRINTF -DLIBX11 -#endif -#if MotifBC - BC_DEFINES = -DMOTIFBC -#endif -#if NoRConst - RCONST_DEFINES = -DNORCONST -#endif -#if DisableXLocaleDirEnv - SETID_DEFINES = -DNO_XLOCALEDIR -#elif HasIssetugid - SETID_DEFINES = -DHASSETUGID -#elif HasGetresuid - SETID_DEFINES = -DHASGETRESUID -#endif - XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\" -#if HasKrb5 - K5OBJS = k5encode.o - K5SRCS = k5encode.c - K5INCL = Krb5Includes - K5DEFS = Krb5Defines -#endif -#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \ - defined(OpenBSDArchitecture) -THRSTUBSRCS = UIThrStubs.c -THRSTUBOBJS = UIThrStubs.o -#endif -#if BuildLoadableXlibXcursor -XCURSOR_DEFINES = -DUSE_DYNAMIC_XCURSOR -DLIBXCURSOR=\"libXcursor.so.$(SOXCURSORREV)\" -#endif -#if NeedLibInsideFlag - LIB_DEFINES = -D_XLIBINT_ -#endif -#if defined(LibDirName) - POSTLOCALELIBDIR = LibDirName - POSTLOCALELIBDEFINES = -DPOSTLOCALELIBDIR=\"$(POSTLOCALELIBDIR)\" -#endif - DEFINES = $(MALLOC_DEFINES) $(LIB_DEFINES) $(MISC_DEFINES)\ - $(POSTLOCALELIBDEFINES) - OPEN_DEFINES = -I$(EXTINCSRC) $(K5INCL) $(K5DEFS) - DEPEND_DEFINES = $(OPEN_DEFINES) $(TRANS_INCLUDES) $(CONN_DEFINES) $(THREADS_DEFINES) DependDefines - AUTHOBJS = AuDispose.o AuGetBest.o AuFileName.o AuRead.o - AUTHSRCS = AuDispose.c AuGetBest.c AuFileName.c AuRead.c - SRCS = $(SRCS1) $(SRCS2) $(SRCS3) $(EXTRASRCS) /* try *.c if you have trouble */ - LINTLIBS = - -#if BuildLoadableXlibI18n && DoSharedLib -EXTRASHAREDSRC = $(SHAREDLCSRCS) -#endif -#if !BuildLoadableXlibI18n || DoNormalLib -EXTRASTATICSRC = $(STATICLCSRCS) -#endif - -EXTRASRCS = $(EXTRASHAREDSRC) $(EXTRASTATICSRC) - -SRCS1 = \ - Context.c \ - Depths.c \ - ParseCmd.c \ - Quarks.c \ - AllCells.c \ - AllPlanes.c \ - AllowEv.c \ - AutoRep.c \ - Backgnd.c \ - BdrWidth.c \ - Bell.c \ - Border.c \ - ChAccCon.c \ - ChClMode.c \ - ChActPGb.c \ - ChCmap.c \ - ChGC.c \ - ChKeyCon.c \ - ChPntCon.c \ - ChProp.c \ - ChSaveSet.c \ - ChWAttrs.c \ - ChWindow.c \ - ChkIfEv.c \ - ChkMaskEv.c \ - ChkWinEv.c \ - ChkTypEv.c \ - ChkTypWEv.c \ - CirWin.c \ - CirWinDn.c \ - CirWinUp.c \ - ClDisplay.c \ - Clear.c \ - ClearArea.c \ - ConfWind.c \ - ConnDis.c \ - ConvSel.c \ - CopyArea.c \ - CopyCmap.c \ - CopyGC.c \ - CopyPlane.c \ - CrBFData.c \ - CrCmap.c \ - CrCursor.c \ - CrGC.c \ - CrGlCur.c \ - CrPFBData.c \ - CrPixmap.c \ - CrWindow.c \ - Cursor.c \ - DefCursor.c \ - DelProp.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 \ - EvToWire.c \ - FetchName.c \ - FillArc.c \ - FillArcs.c \ - FillPoly.c \ - FillRct.c \ - FillRcts.c \ - Flush.c \ - Font.c \ - FontNames.c \ - FontInfo.c \ - FreeCmap.c \ - FreeCols.c \ - FreeCurs.c \ - FreeEData.c \ - FreeGC.c \ - FreePix.c \ - FSSaver.c \ - GCMisc.c \ - Geom.c \ - GetAtomNm.c \ - GetColor.c \ - GetDflt.c \ - GetFPath.c \ - GetFProp.c \ - GetGeom.c \ - GetHColor.c \ - GetHints.c \ - GetIFocus.c \ - GetImage.c \ - GetKCnt.c \ - GetMoEv.c \ - GetPCnt.c \ - GetPntMap.c \ - GetProp.c \ - GetSOwner.c \ - GetSSaver.c \ - GetStCmap.c \ - GetWAttrs.c \ - GrButton.c \ - GrKey.c \ - GrKeybd.c \ - GrPointer.c \ - GrServer.c \ - Host.c \ - IfEvent.c \ - ImUtil.c \ - ImText.c \ - ImText16.c \ - InitExt.c \ - InsCmap.c \ - IntAtom.c \ - KeyBind.c \ - KeysymStr.c \ - KillCl.c \ - LiHosts.c \ - LiICmaps.c \ - LiProps.c \ - ListExt.c \ - LoadFont.c \ - LookupCol.c \ - LowerWin.c - -OBJS1 = \ - Context.o \ - Depths.o \ - ParseCmd.o \ - Quarks.o \ - AllCells.o \ - AllPlanes.o \ - AllowEv.o \ - AutoRep.o \ - Backgnd.o \ - BdrWidth.o \ - Bell.o \ - Border.o \ - ChAccCon.o \ - ChClMode.o \ - ChActPGb.o \ - ChCmap.o \ - ChGC.o \ - ChKeyCon.o \ - ChPntCon.o \ - ChProp.o \ - ChSaveSet.o \ - ChWAttrs.o \ - ChWindow.o \ - ChkIfEv.o \ - ChkMaskEv.o \ - ChkWinEv.o \ - ChkTypEv.o \ - ChkTypWEv.o \ - CirWin.o \ - CirWinDn.o \ - CirWinUp.o \ - ClDisplay.o \ - Clear.o \ - ClearArea.o \ - ConfWind.o \ - ConnDis.o \ - ConvSel.o \ - CopyArea.o \ - CopyCmap.o \ - CopyGC.o \ - CopyPlane.o \ - CrBFData.o \ - CrCmap.o \ - CrCursor.o \ - CrGC.o \ - CrGlCur.o \ - CrPFBData.o \ - CrPixmap.o \ - CrWindow.o \ - Cursor.o \ - DefCursor.o \ - DelProp.o \ - DestSubs.o \ - DestWind.o \ - DisName.o \ - DrArc.o \ - DrArcs.o \ - DrLine.o \ - DrLines.o \ - DrPoint.o \ - DrPoints.o \ - DrRect.o \ - DrRects.o \ - DrSegs.o \ - ErrDes.o \ - ErrHndlr.o \ - EvToWire.o \ - FetchName.o \ - FillArc.o \ - FillArcs.o \ - FillPoly.o \ - FillRct.o \ - FillRcts.o \ - Flush.o \ - Font.o \ - FontNames.o \ - FontInfo.o \ - FreeCmap.o \ - FreeCols.o \ - FreeCurs.o \ - FreeEData.o \ - FreeGC.o \ - FreePix.o \ - FSSaver.o \ - GCMisc.o \ - Geom.o \ - GetAtomNm.o \ - GetColor.o \ - GetDflt.o \ - GetFPath.o \ - GetFProp.o \ - GetGeom.o \ - GetHColor.o \ - GetHints.o \ - GetIFocus.o \ - GetImage.o \ - GetKCnt.o \ - GetMoEv.o \ - GetPCnt.o \ - GetPntMap.o \ - GetProp.o \ - GetSOwner.o \ - GetSSaver.o \ - GetStCmap.o \ - GetWAttrs.o \ - GrButton.o \ - GrKey.o \ - GrKeybd.o \ - GrPointer.o \ - GrServer.o \ - Host.o \ - IfEvent.o \ - ImUtil.o \ - ImText.o \ - ImText16.o \ - InitExt.o \ - InsCmap.o \ - IntAtom.o \ - KeyBind.o \ - KeysymStr.o \ - KillCl.o \ - LiHosts.o \ - LiICmaps.o \ - LiProps.o \ - ListExt.o \ - LoadFont.o \ - LookupCol.o \ - LowerWin.o - -SRCS2 = \ - Macros.c \ - MapRaised.c \ - MapSubs.c \ - MapWindow.c \ - MaskEvent.c \ - Misc.c \ - ModMap.c \ - MoveWin.c \ - NextEvent.c \ - OpenDis.c \ - ParseCol.c \ - ParseGeom.c \ - PeekEvent.c \ - PeekIfEv.c \ - Pending.c \ - PmapBgnd.c \ - PmapBord.c \ - PolyReg.c \ - PolyTxt.c \ - PolyTxt16.c \ - PutBEvent.c \ - PutImage.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 \ - Region.c \ - RepWindow.c \ - RestackWs.c \ - RotProp.c \ - ScrResStr.c \ - SelInput.c \ - SendEvent.c \ - SetBack.c \ - SetCRects.c \ - SetClMask.c \ - SetClOrig.c \ - SetDashes.c \ - SetFPath.c \ - SetFont.c \ - SetFore.c \ - SetFunc.c \ - SetHints.c \ - SetIFocus.c \ - SetLStyle.c \ - SetPMask.c \ - SetPntMap.c \ - SetSOwner.c \ - SetSSaver.c \ - SetState.c \ - SetStip.c \ - SetStCmap.c \ - SetTile.c \ - SetTSOrig.c \ - StBytes.c \ - StColor.c \ - StColors.c \ - StNColor.c \ - StName.c \ - StrKeysym.c \ - Sync.c \ - Synchro.c \ - Text.c \ - Text16.c \ - TextExt.c \ - TextExt16.c \ - TrCoords.c \ - UndefCurs.c \ - UngrabBut.c \ - UngrabKbd.c \ - UngrabKey.c \ - UngrabPtr.c \ - UngrabSvr.c \ - UninsCmap.c \ - UnldFont.c \ - UnmapSubs.c \ - UnmapWin.c \ - VisUtil.c \ - WarpPtr.c \ - WinEvent.c \ - Window.c \ - WrBitF.c \ - XlibAsync.c \ - XlibInt.c \ - Xrm.c \ - evtomask.c \ - globals.c \ - GetGCVals.c \ - GetNrmHint.c \ - GetRGBCMap.c \ - GetTxtProp.c \ - GetWMCMapW.c \ - GetWMProto.c \ - Iconify.c \ - PixFormats.c \ - PropAlloc.c \ - ReconfWM.c \ - SetNrmHint.c \ - SetRGBCMap.c \ - SetTxtProp.c \ - SetWMCMapW.c \ - SetWMProto.c \ - StrToText.c \ - TextToStr.c \ - Withdraw.c \ - WMGeom.c \ - WMProps.c \ - $(AUTHSRCS) $(XDMAUTHSRCS) $(K5SRCS) $(THRSTUBSRCS) - -OBJS2 = \ - Macros.o \ - MapRaised.o \ - MapSubs.o \ - MapWindow.o \ - MaskEvent.o \ - Misc.o \ - ModMap.o \ - MoveWin.o \ - NextEvent.o \ - OpenDis.o \ - ParseCol.o \ - ParseGeom.o \ - PeekEvent.o \ - PeekIfEv.o \ - Pending.o \ - PmapBgnd.o \ - PmapBord.o \ - PolyReg.o \ - PolyTxt.o \ - PolyTxt16.o \ - PutBEvent.o \ - PutImage.o \ - QuBest.o \ - QuColor.o \ - QuColors.o \ - QuCurShp.o \ - QuExt.o \ - QuKeybd.o \ - QuPntr.o \ - QuStipShp.o \ - QuTextE16.o \ - QuTextExt.o \ - QuTileShp.o \ - QuTree.o \ - RaiseWin.o \ - RdBitF.o \ - RecolorC.o \ - ReconfWin.o \ - Region.o \ - RepWindow.o \ - RestackWs.o \ - RotProp.o \ - ScrResStr.o \ - SelInput.o \ - SendEvent.o \ - SetBack.o \ - SetCRects.o \ - SetClMask.o \ - SetClOrig.o \ - SetDashes.o \ - SetFPath.o \ - SetFont.o \ - SetFore.o \ - SetFunc.o \ - SetHints.o \ - SetIFocus.o \ - SetLStyle.o \ - SetPMask.o \ - SetPntMap.o \ - SetSOwner.o \ - SetSSaver.o \ - SetState.o \ - SetStip.o \ - SetStCmap.o \ - SetTile.o \ - SetTSOrig.o \ - StBytes.o \ - StColor.o \ - StColors.o \ - StNColor.o \ - StName.o \ - StrKeysym.o \ - Sync.o \ - Synchro.o \ - Text.o \ - Text16.o \ - TextExt.o \ - TextExt16.o \ - TrCoords.o \ - UndefCurs.o \ - UngrabBut.o \ - UngrabKbd.o \ - UngrabKey.o \ - UngrabPtr.o \ - UngrabSvr.o \ - UninsCmap.o \ - UnldFont.o \ - UnmapSubs.o \ - UnmapWin.o \ - VisUtil.o \ - WarpPtr.o \ - WinEvent.o \ - Window.o \ - WrBitF.o \ - XlibAsync.o \ - XlibInt.o \ - Xrm.o \ - evtomask.o \ - globals.o \ - GetGCVals.o \ - GetNrmHint.o \ - GetRGBCMap.o \ - GetTxtProp.o \ - GetWMCMapW.o \ - GetWMProto.o \ - Iconify.o \ - PixFormats.o \ - PropAlloc.o \ - ReconfWM.o \ - SetNrmHint.o \ - SetRGBCMap.o \ - SetTxtProp.o \ - SetWMCMapW.o \ - SetWMProto.o \ - StrToText.o \ - TextToStr.o \ - Withdraw.o \ - WMGeom.o \ - WMProps.o \ - $(AUTHOBJS) \ - $(XDMAUTHOBJS) \ - $(K5OBJS) \ - $(THRSTUBOBJS) - -SRCS3 = \ - 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 \ - XYZ.c \ - uvY.c \ - xyY.c \ - HVC.c \ - HVCGcC.c \ - HVCGcV.c \ - HVCGcVC.c \ - HVCMnV.c \ - HVCMxC.c \ - HVCMxV.c \ - HVCMxVC.c \ - HVCMxVs.c \ - HVCWpAj.c \ - UNDEFINED.c \ - AddDIC.c \ - AddSF.c \ - cmsAllNCol.c \ - cmsAllCol.c \ - CCC.c \ - cmsCmap.c \ - cmsColNm.c \ - CvColW.c \ - CvCols.c \ - cmsGlobls.c \ - IdOfPr.c \ - cmsInt.c \ - LRGB.c \ - cmsLkCol.c \ - cmsMath.c \ - OfCCC.c \ - PrOfId.c \ - cmsProp.c \ - QBlack.c \ - QBlue.c \ - QGreen.c \ - QRed.c \ - QWhite.c \ - QuCol.c \ - QuCols.c \ - SetCCC.c \ - SetGetCols.c \ - StCol.c \ - StCols.c \ - cmsTrig.c \ - XRGB.c \ - FSWrap.c \ - ICWrap.c \ - IMWrap.c \ - OCWrap.c \ - OMWrap.c \ - lcWrap.c \ - mbWMProps.c \ - utf8WMProps.c \ - mbWrap.c \ - wcWrap.c \ - utf8Wrap.c \ - FilterEv.c \ - RegstFlt.c \ - locking.c \ - LockDis.c \ - x11trans.c \ - ximtrans.c \ - $(XKBSRCS) $(LCSRCS) $(MISCSRCS) - -OBJS3 = \ - Lab.o \ - LabGcC.o \ - LabGcL.o \ - LabGcLC.o \ - LabMnL.o \ - LabMxC.o \ - LabMxL.o \ - LabMxLC.o \ - LabWpAj.o \ - Luv.o \ - LuvGcC.o \ - LuvGcL.o \ - LuvGcLC.o \ - LuvMnL.o \ - LuvMxC.o \ - LuvMxL.o \ - LuvMxLC.o \ - LuvWpAj.o \ - XYZ.o \ - uvY.o \ - xyY.o \ - HVC.o \ - HVCGcC.o \ - HVCGcV.o \ - HVCGcVC.o \ - HVCMnV.o \ - HVCMxC.o \ - HVCMxV.o \ - HVCMxVC.o \ - HVCMxVs.o \ - HVCWpAj.o \ - UNDEFINED.o \ - AddDIC.o \ - AddSF.o \ - cmsAllNCol.o \ - cmsAllCol.o \ - CCC.o \ - cmsCmap.o \ - cmsColNm.o \ - CvColW.o \ - CvCols.o \ - cmsGlobls.o \ - IdOfPr.o \ - cmsInt.o \ - LRGB.o \ - cmsLkCol.o \ - cmsMath.o \ - OfCCC.o \ - PrOfId.o \ - cmsProp.o \ - QBlack.o \ - QBlue.o \ - QGreen.o \ - QRed.o \ - QWhite.o \ - QuCol.o \ - QuCols.o \ - SetCCC.o \ - SetGetCols.o \ - StCol.o \ - StCols.o \ - cmsTrig.o \ - XRGB.o \ - FSWrap.o \ - ICWrap.o \ - IMWrap.o \ - OCWrap.o \ - OMWrap.o \ - lcWrap.o \ - mbWMProps.o \ - utf8WMProps.o \ - mbWrap.o \ - wcWrap.o \ - utf8Wrap.o \ - FilterEv.o \ - RegstFlt.o \ - locking.o \ - LockDis.o \ - x11trans.o \ - ximtrans.o \ - $(XKBOBJS) $(LCOBJS) $(MISCOBJS) - -#if BuildLoadableXlibI18n -LC_DYNDEFINES = -DUSE_DYNAMIC_LC -#endif - -SHAREDLCDEPSYMSRCS = XlcDL.c XlcSL.c - -SHAREDI18NSTATICSRCS = \ - XDefaultIMIF.c XDefaultOMIF.c - -STATICLCDEPSYMSRCS = - -STATICI18NSTATICSRCS = \ - imCallbk.c \ - imDefFlt.c \ - imDefIc.c \ - imDefIm.c \ - imDefLkup.c \ - imDispch.c \ - imEvToWire.c \ - imExten.c \ - imImSw.c \ - imInsClbk.c \ - imInt.c \ - imLcFlt.c \ - imLcGIc.c \ - imLcIc.c \ - imLcIm.c \ - imLcLkup.c \ - imLcPrs.c \ - imLcSIc.c \ - imRm.c \ - imRmAttr.c \ - imThaiFlt.c \ - imThaiIc.c \ - imThaiIm.c \ - imTrX.c \ - imTransR.c \ - imTrans.c \ - lcEuc.c \ - lcGenConv.c \ - lcJis.c \ - lcSjis.c \ - lcUTF8Load.c \ - omDefault.c \ - omGeneric.c \ - omImText.c \ - omText.c \ - omTextEsc.c \ - omTextExt.c \ - omTextPer.c \ - omXChar.c - -LCSRCS = \ - SetLocale.c \ - imConv.c \ - imKStoUCS.c \ - lcCT.c \ - lcCharSet.c \ - lcConv.c \ - lcDB.c \ - lcDefConv.c \ - lcFile.c \ - lcGeneric.c \ - lcInit.c \ - lcPrTxt.c \ - lcPubWrap.c \ - lcPublic.c \ - lcRM.c \ - lcStd.c \ - lcTxtPr.c \ - lcUtil.c \ - lcUTF8.c - -STATICLCSRCS = \ - $(STATICLCDEPSYMSRCS) \ - $(STATICI18NSTATICSRCS) - -SHAREDLCSRCS = \ - $(SHAREDLCDEPSYMSRCS) \ - $(SHAREDI18NSTATICSRCS) - -SHAREDLCDEPOBJS = XlcDL.o XlcSL.o -SHAREDI18NSTATICOBJS = \ - XDefaultIMIF.o XDefaultOMIF.o -STATICLCDEPOBJS = -STATICI18NSTATICOBJS = \ - imCallbk.o \ - imDefFlt.o \ - imDefIc.o \ - imDefIm.o \ - imDefLkup.o \ - imDispch.o \ - imEvToWire.o \ - imExten.o \ - imImSw.o \ - imInsClbk.o \ - imInt.o \ - imLcFlt.o \ - imLcGIc.o \ - imLcIc.o \ - imLcIm.o \ - imLcLkup.o \ - imLcPrs.o \ - imLcSIc.o \ - imRm.o \ - imRmAttr.o \ - imThaiFlt.o \ - imThaiIc.o \ - imThaiIm.o \ - imTrX.o \ - imTransR.o \ - imTrans.o \ - lcEuc.o \ - lcGenConv.o \ - lcJis.o \ - lcSjis.o \ - lcUTF8Load.o \ - omDefault.o \ - omGeneric.o \ - omImText.o \ - omText.o \ - omTextEsc.o \ - omTextExt.o \ - omTextPer.o \ - omXChar.o - -LCOBJS = \ - SetLocale.o \ - imConv.o \ - imKStoUCS.o \ - lcCT.o \ - lcCharSet.o \ - lcConv.o \ - lcDB.o \ - lcDefConv.o \ - lcFile.o \ - lcGeneric.o \ - lcInit.o \ - lcPrTxt.o \ - lcPubWrap.o \ - lcPublic.o \ - lcRM.o \ - lcStd.o \ - lcTxtPr.o \ - lcUtil.o \ - lcUTF8.o - -STATICLCOBJS = \ - $(STATICLCDEPOBJS) \ - $(STATICI18NSTATICOBJS) - -SHAREDLCOBJS = \ - $(SHAREDLCDEPOBJS) \ - $(SHAREDI18NSTATICOBJS) - -#ifdef OS2Architecture -MISCSRCS = os2Stubs.c -#endif - -#ifdef OS2Architecture -MISCOBJS = os2Stubs.o -#endif - -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) - -EXTRAUNSHAREDOBJS = $(STATICLCOBJS) - -#if BuildLoadableXlibI18n -EXTRASHAREDOBJS = $(SHAREDLCOBJS) -# else -EXTRASHAREDOBJS = $(STATICLCOBJS) -#endif - -#include <Library.tmpl> - -SpecialCLibObjectRule(ErrDes,$(ICONFIGFILES),$(EDB_DEFINES)) -SpecialCLibObjectRule(StrKeysym,$(ICONFIGFILES),$(KDB_DEFINES)) -SpecialCLibObjectRule(ConnDis,$(ICONFIGFILES),$(XDMAUTHDEFS) $(RPCDEFS) $(CONN_DEFINES) $(SOCK_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES) $(K5INCL) $(K5DEFS)) -SpecialCLibObjectRule(x11trans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_X_DEFINES) $(POLL_DEFINES)) -LinkFile(x11trans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(ximtrans,$(ICONFIGFILES),$(TRANS_INCLUDES) $(CONN_DEFINES) $(SOCK_DEFINES) $(XTRANS_XIM_DEFINES) $(POLL_DEFINES)) -LinkFile(ximtrans.c,$(TRANSCOMMSRC)/transport.c) -SpecialCLibObjectRule(OpenDis,$(ICONFIGFILES),$(BC_DEFINES) $(OPEN_DEFINES) $(XTRANS_X_DEFINES) $(XKB_DEFINES)) -SpecialCLibObjectRule(Wrap,$(ICONFIGFILES),$(XDMAUTHDEFS)) -SpecialCLibObjectRule(XlibInt,$(ICONFIGFILES),$(CONN_DEFINES) $(POLL_DEFINES) $(XTRANS_X_DEFINES)) -SpecialCLibObjectRule(Font,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(FontInfo,$(ICONFIGFILES),$(SHM_DEFINES) $(XF86BIGFONT_DEFINES)) -SpecialCLibObjectRule(cmsColNm,$(ICONFIGFILES),$(CMS_DEFINES)) -SpecialCLibObjectRule(globals,$(ICONFIGFILES),$(CONN_DEFINES)) -SpecialCLibObjectRule(Context,$(ICONFIGFILES),$(BC_DEFINES)) -SpecialCLibObjectRule(Xrm,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(imTransR,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(imTrans,$(ICONFIGFILES),$(CONN_DEFINES) $(XTRANS_XIM_DEFINES)) -SpecialCLibObjectRule(lcFile,$(ICONFIGFILES),$(XLC_DEFINES) $(SETID_DEFINES)) -#if BuildXKBlib -SpecialCLibObjectRule(XKBCvt,$(_NOOP_),$(RCONST_DEFINES)) -SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES)) -SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES)) -#endif -#if HasKrb5 -SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL)) -#endif -#if BuildLoadableXlibI18n -SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -SpecialCLibObjectRuleSeparateOpts(lcPublic,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES)) -#endif -#if BuildLoadableXlibXcursor -SpecialCLibObjectRuleSeparateOpts(CrCursor,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrGlCur,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(CrPixmap,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -SpecialCLibObjectRuleSeparateOpts(PutImage,$(ICONFIGFILES),$(_NOOP_),$(XCURSOR_DEFINES)) -#endif - -#if InstallXcmsTxt -InstallNonExecFile(Xcms.txt,$(LIBDIR)) -#endif -InstallNonExecFile(XErrorDB,$(LIBDIR)) -InstallNonExecFile(XKeysymDB,$(LIBDIR)) -InstallLintLibrary(X11,$(LINTLIBDIR)) - - -LinkSourceFile(AuDispose.c,$(XAUTHSRC)) -LinkSourceFile(AuGetBest.c,$(XAUTHSRC)) -LinkSourceFile(AuFileName.c,$(XAUTHSRC)) -LinkSourceFile(AuRead.c,$(XAUTHSRC)) -#if HasKrb5 -LinkSourceFile(k5encode.c,$(XAUTHSRC)) -#endif -#if HasXdmAuth -LinkSourceFile(Wrap.h,$(XDMCPLIBSRC)) -LinkSourceFile(Wrap.c,$(XDMCPLIBSRC)) -LinkSourceFile(Wraphelp.c,$(XDMCPLIBSRC)) -#endif - -#ifdef QNX4Architecture -LOCAL_LDFLAGS=-F -#endif - -MAKEKEYS = ./makekeys - -#if CrossCompiling -HOST_LDLIBS= -HOST_CFLAGS=$(TOP_INCLUDES) $(INCLUDES) $(BOOTSTRAPCFLAGS) \ - $(CROSSCOMPILEDEFINES) $(CROSSCOMPILEBOOTSTRAPDEFINES) -#else -HOST_LDLIBS=$(LDLIBS) -HOST_CFLAGS=$(CFLAGS) -#endif - -ks_tables.h: $(XINCLUDESRC)/keysymdef.h util/makekeys.c - RemoveFiles($@ HostProgramTargetName(makekeys) makekeys.Osuf) - -HostLinkRule(HostProgramTargetName(makekeys),$(HOST_CFLAGS) $(LOCAL_LDFLAGS),util/makekeys.c,$(HOST_LDLIBS)) - RunProgram(MAKEKEYS,< $(XINCLUDESRC)/keysymdef.h > ks_tables_h) - $(MV) ks_tables_h $@ - RemoveFiles(HostProgramTargetName(makekeys) makekeys.Osuf ks_tables_h) - -includes:: ks_tables.h - -depend:: ks_tables.h - -clean:: - RemoveFiles(ks_tables_h ks_tables.h HostProgramTargetName(makekeys)) - - -DependTarget3($(SRCS1),$(SRCS2),$(SRCS3) $(EXTRASRCS)) - -#if BuildLoadableXlibI18n -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) -MakeLintLibSubdirs($(LINTSUBDIRS)) -MakeLintSubdirs($(LINTSUBDIRS),install.ln,install.ln) -#endif -#endif - -includes:: XlibConf.h - -#include <Threads.tmpl> - -#if ThreadedProject -#define XThreadsDefine echo '#ifndef XTHREADS' >> $@ @@\ - echo '#define XTHREADS' >> $@ @@\ - echo '#endif' >> $@ -#else -#define XThreadsDefine echo '#undef XTHREADS' >> $@ -#endif - -#if HasThreadSafeAPI -#define MTSafeAPIDefine echo '#ifndef XUSE_MTSAFE_API' >> $@ @@\ - echo '#define XUSE_MTSAFE_API' >> $@ @@\ - echo '#endif' >> $@ -#else -#define MTSafeAPIDefine echo '#undef XUSE_MTSAFE_API' >> $@ -#endif - -XlibConf.h: - echo '/* Defines needed to use Xlib from non-imake projects */' > $@ - XThreadsDefine - MTSafeAPIDefine diff --git a/nx-X11/lib/X11/MaskEvent.c.NX.original b/nx-X11/lib/X11/MaskEvent.c.NX.original deleted file mode 100644 index c48a960d2..000000000 --- a/nx-X11/lib/X11/MaskEvent.c.NX.original +++ /dev/null @@ -1,84 +0,0 @@ -/* $Xorg: MaskEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -extern long const _Xevent_to_mask[]; -#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask) -#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\ - Button4MotionMask|Button5MotionMask) - -/* - * return the next event in the queue matching one of the events in the mask. - * If no event, flush output, and wait until match succeeds. - * Events earlier in the queue are not discarded. - */ - -int -XMaskEvent (dpy, mask, event) - register Display *dpy; - long mask; /* Selected event mask. */ - register XEvent *event; /* XEvent to be filled in. */ -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if ((qelt->event.type < LASTEvent) && - (_Xevent_to_mask[qelt->event.type] & mask) && - ((qelt->event.type != MotionNotify) || - (mask & AllPointers) || - (mask & AllButtons & qelt->event.xmotion.state))) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} diff --git a/nx-X11/lib/X11/MaskEvent.c.X.original b/nx-X11/lib/X11/MaskEvent.c.X.original deleted file mode 100644 index c5f41b54d..000000000 --- a/nx-X11/lib/X11/MaskEvent.c.X.original +++ /dev/null @@ -1,79 +0,0 @@ -/* $Xorg: MaskEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/MaskEvent.c,v 3.5 2001/10/28 03:32:30 tsi Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -extern long const _Xevent_to_mask[]; -#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask) -#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\ - Button4MotionMask|Button5MotionMask) - -/* - * return the next event in the queue matching one of the events in the mask. - * If no event, flush output, and wait until match succeeds. - * Events earlier in the queue are not discarded. - */ - -int -XMaskEvent (dpy, mask, event) - register Display *dpy; - long mask; /* Selected event mask. */ - register XEvent *event; /* XEvent to be filled in. */ -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if ((qelt->event.type < LASTEvent) && - (_Xevent_to_mask[qelt->event.type] & mask) && - ((qelt->event.type != MotionNotify) || - (mask & AllPointers) || - (mask & AllButtons & qelt->event.xmotion.state))) { - *event = qelt->event; - _XDeq(dpy, prev, qelt); - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} diff --git a/nx-X11/lib/X11/OpenDis.c.NX.original b/nx-X11/lib/X11/OpenDis.c.NX.original deleted file mode 100644 index e9d019723..000000000 --- a/nx-X11/lib/X11/OpenDis.c.NX.original +++ /dev/null @@ -1,911 +0,0 @@ -/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/extensions/bigreqstr.h> -#include <stdio.h> -#include "Xintconn.h" - -#ifdef XKB -#include "XKBlib.h" -#endif /* XKB */ - -#ifdef NX_TRANS_SOCKET -extern void *_X11TransSocketProxyConnInfo(XtransConnInfo); -#endif - -#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; - -#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); -static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len, - XPointer data); - -/* - * 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 */ - int endian; /* to determine which endian. */ - xConnClientPrefix client; /* client information */ - xConnSetupPrefix prefix; /* prefix information */ - int vendorlen; /* length of vendor string */ - char *setup = NULL; /* memory allocated at startup */ - char *fullname = NULL; /* expanded name of display */ - int idisplay; /* display number */ - int iscreen; /* screen number */ - int prefixread = 0; /* setup prefix already read? */ - 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 */ - char *conn_auth_name, *conn_auth_data; - int conn_auth_namelen, conn_auth_datalen; - unsigned long mask; - long int conn_buf_size; - char *xlib_buffer_size; - - bzero((char *) &client, sizeof(client)); - bzero((char *) &prefix, sizeof(prefix)); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXOpenDisplay: Called with display [%s].\n", display); -#endif - /* - * 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 ((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); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXOpenDisplay: Connected display with dpy->fd = [%d].\n", dpy->fd); -#endif - /* 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 - if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == 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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf (stderr, "Xlib: Running with XLIBBUFFERSIZE [%d] XLIBMINBUFSIZE [%d] " - "buffer size [%ld].\n", XLIBDEFAULTBUFSIZE, XLIBMINBUFSIZE, conn_buf_size); -#endif - - if ((dpy->bufptr = dpy->buffer = Xcalloc(1, conn_buf_size)) == NULL) { - OutOfMemory (dpy, setup); - return(NULL); - } - dpy->bufmax = dpy->buffer + conn_buf_size; - - /* 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); - } - -/* - * 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 */ -#ifdef NX_TRANS_SOCKET - if (_X11TransSocketProxyConnInfo(dpy->trans_conn) == NULL) { - fprintf (stderr, "Xlib: client uses different protocol version (%d) " - "than server (%d)!\r\n", X_PROTOCOL, prefix.majorVersion); - } -#else - fprintf (stderr, - "Xlib: client uses different protocol version (%d) than server (%d)!\r\n", - X_PROTOCOL, prefix.majorVersion); -#endif - _XDisconnectDisplay (dpy->trans_conn); - Xfree ((char *)dpy); - return(NULL); - } - - 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); - } - -/* - * 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 */ - - - memmove (setup, u.vendor + vendorlen, - (int) setuplength - sz_xConnSetup - vendorlen); - u.vendor = setup; -/* - * 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... - */ - - Xfree (setup); /* all finished with setup information */ - -/* - * Make sure default screen is legal. - */ - if (iscreen >= dpy->nscreens) { - OutOfMemory(dpy, (char *) NULL); - return(NULL); - } - -/* - * finished calling internal routines, now unlock for external routines - */ - UnlockDisplay(dpy); - -/* - * 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); - { - _XAsyncHandler async; - _XBigReqState async_state; - xQueryExtensionReq *qreq; - xGetPropertyReply reply; - xGetPropertyReq *req; - 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); - - 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)); - } - 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; - } - } - UnlockDisplay(dpy); - -#ifdef MOTIFBC - { - extern Display *_XHeadOfDisplayList; - _XHeadOfDisplayList = dpy; - } -#endif -#ifdef XKB - XkbUseExtension(dpy,NULL,NULL); -#endif -/* - * and return successfully - */ -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "XOpenDisplay: Returning display at [%p].\n", dpy); -#endif - return(dpy); -} - -static Bool -_XBigReqHandler(dpy, rep, buf, len, data) - 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; -} - - -/* 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(dpy) - register Display *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); - - Xfree ((char *)dpy); -} - -/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL - after this returns. */ - -static void OutOfMemory (dpy, setup) - Display *dpy; - char *setup; -{ - _XDisconnectDisplay (dpy->trans_conn); - _XFreeDisplayStructure (dpy); - if (setup) Xfree (setup); -} diff --git a/nx-X11/lib/X11/OpenDis.c.X.original b/nx-X11/lib/X11/OpenDis.c.X.original deleted file mode 100644 index 121291b5f..000000000 --- a/nx-X11/lib/X11/OpenDis.c.X.original +++ /dev/null @@ -1,869 +0,0 @@ -/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/OpenDis.c,v 3.16 2003/07/04 16:24:23 eich Exp $ */ - -#define NEED_REPLIES -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xtrans/Xtrans.h> -#include <X11/Xatom.h> -#include <X11/Xresource.h> -#include <X11/extensions/bigreqstr.h> -#include <stdio.h> -#include "Xintconn.h" - -#ifdef XKB -#include "XKBlib.h" -#endif /* XKB */ - -#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; - -#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); -static Bool _XBigReqHandler(Display *dpy, xReply *rep, char *buf, int len, - XPointer data); - -/* - * 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 */ - int endian; /* to determine which endian. */ - xConnClientPrefix client; /* client information */ - xConnSetupPrefix prefix; /* prefix information */ - int vendorlen; /* length of vendor string */ - char *setup = NULL; /* memory allocated at startup */ - char *fullname = NULL; /* expanded name of display */ - int idisplay; /* display number */ - int iscreen; /* screen number */ - int prefixread = 0; /* setup prefix already read? */ - 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 */ - char *conn_auth_name, *conn_auth_data; - int conn_auth_namelen, conn_auth_datalen; - unsigned long mask; - long int conn_buf_size; - char *xlib_buffer_size; - - 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; - } -/* - * 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 ((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); - - /* 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 - if ((xlib_buffer_size = getenv("XLIBBUFFERSIZE")) == 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; - - /* 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); - } - -/* - * 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); - } - - 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); - } - -/* - * 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 */ - - - memmove (setup, u.vendor + vendorlen, - (int) setuplength - sz_xConnSetup - vendorlen); - u.vendor = setup; -/* - * 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... - */ - - Xfree (setup); /* all finished with setup information */ - -/* - * Make sure default screen is legal. - */ - if (iscreen >= dpy->nscreens) { - OutOfMemory(dpy, (char *) NULL); - return(NULL); - } - -/* - * finished calling internal routines, now unlock for external routines - */ - UnlockDisplay(dpy); - -/* - * 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); - { - _XAsyncHandler async; - _XBigReqState async_state; - xQueryExtensionReq *qreq; - xGetPropertyReply reply; - xGetPropertyReq *req; - 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); - - 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)); - } - 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; - } - } - UnlockDisplay(dpy); - -#ifdef MOTIFBC - { - extern Display *_XHeadOfDisplayList; - _XHeadOfDisplayList = dpy; - } -#endif -#ifdef XKB - XkbUseExtension(dpy,NULL,NULL); -#endif -/* - * and return successfully - */ - return(dpy); -} - -static Bool -_XBigReqHandler(dpy, rep, buf, len, data) - 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; -} - - -/* 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(dpy) - register Display *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); - - Xfree ((char *)dpy); -} - -/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL - after this returns. */ - -static void OutOfMemory (dpy, setup) - Display *dpy; - char *setup; -{ - _XDisconnectDisplay (dpy->trans_conn); - _XFreeDisplayStructure (dpy); - if (setup) Xfree (setup); -} diff --git a/nx-X11/lib/X11/PeekIfEv.c.NX.original b/nx-X11/lib/X11/PeekIfEv.c.NX.original deleted file mode 100644 index a8da27932..000000000 --- a/nx-X11/lib/X11/PeekIfEv.c.NX.original +++ /dev/null @@ -1,81 +0,0 @@ -/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * return the next event in the queue that satisfies the predicate. - * BUT do not remove it from the queue. - * If none found, flush, and then wait until one satisfies the predicate. - */ - -int -XPeekIfEvent (dpy, event, predicate, arg) - register Display *dpy; - register XEvent *event; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return 0; - } -#endif - } -} - diff --git a/nx-X11/lib/X11/PeekIfEv.c.X.original b/nx-X11/lib/X11/PeekIfEv.c.X.original deleted file mode 100644 index beb991a07..000000000 --- a/nx-X11/lib/X11/PeekIfEv.c.X.original +++ /dev/null @@ -1,76 +0,0 @@ -/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/PeekIfEv.c,v 1.4 2001/12/14 19:54:03 dawes Exp $ */ - -#define NEED_EVENTS -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* - * return the next event in the queue that satisfies the predicate. - * BUT do not remove it from the queue. - * If none found, flush, and then wait until one satisfies the predicate. - */ - -int -XPeekIfEvent (dpy, event, predicate, arg) - register Display *dpy; - register XEvent *event; - Bool (*predicate)( - Display* /* display */, - XEvent* /* event */, - char* /* arg */ - ); - char *arg; -{ - register _XQEvent *prev, *qelt; - unsigned long qe_serial = 0; - - LockDisplay(dpy); - prev = NULL; - while (1) { - for (qelt = prev ? prev->next : dpy->head; - qelt; - prev = qelt, qelt = qelt->next) { - if(qelt->qserial_num > qe_serial - && (*predicate)(dpy, &qelt->event, arg)) { - *event = qelt->event; - UnlockDisplay(dpy); - return 0; - } - } - if (prev) - qe_serial = prev->qserial_num; - _XReadEvents(dpy); - if (prev && prev->qserial_num != qe_serial) - /* another thread has snatched this event */ - prev = NULL; - } -} - diff --git a/nx-X11/lib/X11/Pending.c.NX.original b/nx-X11/lib/X11/Pending.c.NX.original deleted file mode 100644 index 34e7cf6ca..000000000 --- a/nx-X11/lib/X11/Pending.c.NX.original +++ /dev/null @@ -1,69 +0,0 @@ -/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -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. - -*/ - -#include <stdio.h> - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* Read in pending events if needed and return the number of queued events. */ - -int XEventsQueued (dpy, mode) - register Display *dpy; - int mode; -{ - int ret_val; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXEventsQueued: Called with a display at [%p].\n", dpy); -#endif - - LockDisplay(dpy); - if (dpy->qlen || (mode == QueuedAlready)) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, mode); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "\nXEventsQueued: Going to unlock the display at [%p].\n", dpy); -#endif - UnlockDisplay(dpy); - return ret_val; -} - -int XPending (dpy) - register Display *dpy; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, QueuedAfterFlush); - UnlockDisplay(dpy); - return ret_val; -} diff --git a/nx-X11/lib/X11/Pending.c.X.original b/nx-X11/lib/X11/Pending.c.X.original deleted file mode 100644 index 480ec6cf0..000000000 --- a/nx-X11/lib/X11/Pending.c.X.original +++ /dev/null @@ -1,60 +0,0 @@ -/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */ -/* - -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. - -*/ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" - -/* Read in pending events if needed and return the number of queued events. */ - -int XEventsQueued (dpy, mode) - register Display *dpy; - int mode; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen || (mode == QueuedAlready)) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, mode); - UnlockDisplay(dpy); - return ret_val; -} - -int XPending (dpy) - register Display *dpy; -{ - int ret_val; - LockDisplay(dpy); - if (dpy->qlen) - ret_val = dpy->qlen; - else - ret_val = _XEventsQueued (dpy, QueuedAfterFlush); - UnlockDisplay(dpy); - return ret_val; -} diff --git a/nx-X11/lib/X11/XKBMAlloc.c.NX.original b/nx-X11/lib/X11/XKBMAlloc.c.NX.original deleted file mode 100644 index d57d9a58d..000000000 --- a/nx-X11/lib/X11/XKBMAlloc.c.NX.original +++ /dev/null @@ -1,1023 +0,0 @@ -/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS 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. - -********************************************************/ -/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#elif defined(HAVE_CONFIG_H) -#include <config.h> -#endif - -#ifndef XKB_IN_SERVER - -#include <stdio.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include "Xlibint.h" -#include <X11/extensions/XKBproto.h> -#include <X11/keysym.h> -#include "XKBlibint.h" - -#else - -#include <stdio.h> -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#include "misc.h" -#include "inputstr.h" -#include <X11/keysym.h> -#define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> - -#endif /* XKB_IN_SERVER */ - -/***====================================================================***/ - -Status -XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes) -{ -register int i; -XkbClientMapPtr map; - - if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes))) - return BadValue; - if ((which&XkbKeySymsMask)&& - ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code))) { -#ifdef DEBUG -fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n", - xkb->min_key_code,xkb->max_key_code); -#endif - return BadValue; - } - - if (xkb->map==NULL) { - map= _XkbTypedCalloc(1,XkbClientMapRec); - if (map==NULL) - return BadAlloc; - xkb->map= map; - } - else map= xkb->map; - - if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) { - if (map->types==NULL) { - map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) - return BadAlloc; - map->num_types= 0; - map->size_types= nTotalTypes; - } - else if (map->size_types<nTotalTypes) { - XkbKeyTypeRec *prev_types = map->types; - - map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) { - _XkbFree(prev_types); - map->num_types= map->size_types= 0; - return BadAlloc; - } - map->size_types= nTotalTypes; - bzero(&map->types[map->num_types], - ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec))); - } - } - if (which&XkbKeySymsMask) { - int nKeys= XkbNumKeys(xkb); - if (map->syms==NULL) { - map->size_syms= (nKeys*15)/10; - map->syms= _XkbTypedCalloc(map->size_syms,KeySym); - if (!map->syms) { - map->size_syms= 0; - return BadAlloc; - } - map->num_syms= 1; - map->syms[0]= NoSymbol; - } - if (map->key_sym_map==NULL) { - i= xkb->max_key_code+1; - map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec); - if (map->key_sym_map==NULL) - return BadAlloc; - } - } - if (which&XkbModifierMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->modmap==NULL) { - i= xkb->max_key_code+1; - map->modmap= _XkbTypedCalloc(i,unsigned char); - if (map->modmap==NULL) - return BadAlloc; - } - } - return Success; -} - -Status -XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions) -{ -register int i; -XkbServerMapPtr map; - - if (xkb==NULL) - return BadMatch; - if (xkb->server==NULL) { - map= _XkbTypedCalloc(1,XkbServerMapRec); - if (map==NULL) - return BadAlloc; - for (i=0;i<XkbNumVirtualMods;i++) { - map->vmods[i]= XkbNoModifierMask; - } - xkb->server= map; - } - else map= xkb->server; - if (which&XkbExplicitComponentsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->explicit==NULL) { - i= xkb->max_key_code+1; - map->explicit= _XkbTypedCalloc(i,unsigned char); - if (map->explicit==NULL) - return BadAlloc; - } - } - if (which&XkbKeyActionsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (nNewActions<1) - nNewActions= 1; - if (map->acts==NULL) { - map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction); - if (map->acts==NULL) - return BadAlloc; - map->num_acts= 1; - map->size_acts= nNewActions+1; - } - else if ((map->size_acts-map->num_acts)<nNewActions) { - unsigned need; - XkbAction *prev_acts = map->acts; - need= map->num_acts+nNewActions; - map->acts= _XkbTypedRealloc(map->acts,need,XkbAction); - if (map->acts==NULL) { - _XkbFree(prev_acts); - map->num_acts= map->size_acts= 0; - return BadAlloc; - } - map->size_acts= need; - bzero(&map->acts[map->num_acts], - ((map->size_acts-map->num_acts)*sizeof(XkbAction))); - } - if (map->key_acts==NULL) { - i= xkb->max_key_code+1; - map->key_acts= _XkbTypedCalloc(i,unsigned short); - if (map->key_acts==NULL) - return BadAlloc; - } - } - if (which&XkbKeyBehaviorsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->behaviors==NULL) { - i= xkb->max_key_code+1; - map->behaviors= _XkbTypedCalloc(i,XkbBehavior); - if (map->behaviors==NULL) - return BadAlloc; - } - } - if (which&XkbVirtualModMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->vmodmap==NULL) { - i= xkb->max_key_code+1; - map->vmodmap= _XkbTypedCalloc(i,unsigned short); - if (map->vmodmap==NULL) - return BadAlloc; - } - } - return Success; -} - -/***====================================================================***/ - -Status -XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) -{ - if ((!from)||(!into)) - return BadMatch; - if (into->map) { - _XkbFree(into->map); - into->map= NULL; - } - if (into->preserve) { - _XkbFree(into->preserve); - into->preserve= NULL; - } - if (into->level_names) { - _XkbFree(into->level_names); - into->level_names= NULL; - } - *into= *from; - if ((from->map)&&(into->map_count>0)) { - into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec); - if (!into->map) - return BadAlloc; - memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec)); - } - if ((from->preserve)&&(into->map_count>0)) { - into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec); - if (!into->preserve) - return BadAlloc; - memcpy(into->preserve,from->preserve, - into->map_count*sizeof(XkbModsRec)); - } - if ((from->level_names)&&(into->num_levels>0)) { - into->level_names= _XkbTypedCalloc(into->num_levels,Atom); - if (!into->level_names) - return BadAlloc; - memcpy(into->level_names,from->level_names, - into->num_levels*sizeof(Atom)); - } - return Success; -} - -Status -XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types) -{ -register int i,rtrn; - - if ((!from)||(!into)||(num_types<0)) - return BadMatch; - for (i=0;i<num_types;i++) { - if ((rtrn= XkbCopyKeyType(from++,into++))!=Success) - return rtrn; - } - return Success; -} - -XkbKeyTypePtr -XkbAddKeyType( XkbDescPtr xkb, - Atom name, - int map_count, - Bool want_preserve, - int num_lvls) -{ -register int i; -unsigned tmp; -XkbKeyTypePtr type; -XkbClientMapPtr map; - - if ((!xkb)||(num_lvls<1)) - return NULL; - map= xkb->map; - if ((map)&&(map->types)) { - for (i=0;i<map->num_types;i++) { - if (map->types[i].name==name) { - Status status; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) { - tmp= XkbNumRequiredTypes+1; - if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success) - return NULL; - tmp= 0; - if (map->num_types<=XkbKeypadIndex) - tmp|= XkbKeypadMask; - if (map->num_types<=XkbAlphabeticIndex) - tmp|= XkbAlphabeticMask; - if (map->num_types<=XkbTwoLevelIndex) - tmp|= XkbTwoLevelMask; - if (map->num_types<=XkbOneLevelIndex) - tmp|= XkbOneLevelMask; - if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) { - for (i=0;i<map->num_types;i++) { - Status status; - if (map->types[i].name!=name) - continue; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((map->num_types<=map->size_types)&& - (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) { - return NULL; - } - type= &map->types[map->num_types]; - map->num_types++; - bzero((char *)type,sizeof(XkbKeyTypeRec)); - type->num_levels= num_lvls; - type->map_count= map_count; - type->name= name; - if (map_count>0) { - type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec); - if (!type->map) { - map->num_types--; - return NULL; - } - if (want_preserve) { - type->preserve= _XkbTypedCalloc(map_count,XkbModsRec); - if (!type->preserve) { - _XkbFree(type->map); - map->num_types--; - return NULL; - } - } - } - return type; -} - -Status -XkbResizeKeyType( XkbDescPtr xkb, - int type_ndx, - int map_count, - Bool want_preserve, - int new_num_lvls) -{ -XkbKeyTypePtr type; -KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; - - if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)|| - (new_num_lvls<1)) - return BadValue; - switch (type_ndx) { - case XkbOneLevelIndex: - if (new_num_lvls!=1) - return BadMatch; - break; - case XkbTwoLevelIndex: - case XkbAlphabeticIndex: - case XkbKeypadIndex: - if (new_num_lvls!=2) - return BadMatch; - break; - } - type= &xkb->map->types[type_ndx]; - if (map_count==0) { - if (type->map!=NULL) - _XkbFree(type->map); - type->map= NULL; - if (type->preserve!=NULL) - _XkbFree(type->preserve); - type->preserve= NULL; - type->map_count= 0; - } - else { - XkbKTMapEntryRec *prev_map = type->map; - - if ((map_count>type->map_count)||(type->map==NULL)) - type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec); - if (!type->map) { - if (prev_map) - _XkbFree(prev_map); - return BadAlloc; - } - if (want_preserve) { - XkbModsRec *prev_preserve = type->preserve; - - if ((map_count>type->map_count)||(type->preserve==NULL)) { - type->preserve= _XkbTypedRealloc(type->preserve,map_count, - XkbModsRec); - } - if (!type->preserve) { - if (prev_preserve) - _XkbFree(prev_preserve); - return BadAlloc; - } - } - else if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= map_count; - } - - if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) { - Atom * prev_level_names = type->level_names; - - type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom); - if (!type->level_names) { - if (prev_level_names) - _XkbFree(prev_level_names); - return BadAlloc; - } - } - /* - * Here's the theory: - * If the width of the type changed, we might have to resize the symbol - * maps for any keys that use the type for one or more groups. This is - * expensive, so we'll try to cull out any keys that are obviously okay: - * In any case: - * - keys that have a group width <= the old width are okay (because - * they could not possibly have been associated with the old type) - * If the key type increased in size: - * - keys that already have a group width >= to the new width are okay - * + keys that have a group width >= the old width but < the new width - * might have to be enlarged. - * If the key type decreased in size: - * - keys that have a group width > the old width don't have to be - * resized (because they must have some other wider type associated - * with some group). - * + keys that have a group width == the old width might have to be - * shrunk. - * The possibilities marked with '+' require us to examine the key types - * associated with each group for the key. - */ - bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode)); - nMatchingKeys= 0; - if (new_num_lvls>type->num_levels) { - int nTotal; - KeySym * newSyms; - int width,match,nResize; - register int i,g,nSyms; - - nResize= 0; - for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - if ((!match)||(width>=new_num_lvls)) - nTotal+= XkbKeyNumSyms(xkb,i); - else { - nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - nResize++; - } - } - if (nResize>0) { - int nextMatch; - xkb->map->size_syms= (nTotal*12)/10; - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return BadAlloc; - nextMatch= 0; - nSyms= 1; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - if (matchingKeys[nextMatch]==i) { - KeySym *pOld; - nextMatch++; - width= XkbKeyGroupsWidth(xkb,i); - pOld= XkbKeySymsPtr(xkb,i); - for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) { - memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g], - width*sizeof(KeySym)); - } - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - } - else { - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i), - XkbKeyNumSyms(xkb,i)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumSyms(xkb,i); - } - } - type->num_levels= new_num_lvls; - _XkbFree(xkb->map->syms); - xkb->map->syms= newSyms; - xkb->map->num_syms= nSyms; - return Success; - } - } - else if (new_num_lvls<type->num_levels) { - int width,match; - register int g,i; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - } - } - if (nMatchingKeys>0) { - int key,firstClear; - register int i,g; - if (new_num_lvls>type->num_levels) - firstClear= type->num_levels; - else firstClear= new_num_lvls; - for (i=0;i<nMatchingKeys;i++) { - KeySym * pSyms; - int width,nClear; - - key= matchingKeys[i]; - width= XkbKeyGroupsWidth(xkb,key); - nClear= width-firstClear; - pSyms= XkbKeySymsPtr(xkb,key); - for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) { - if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) { - if (nClear>0) - bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym)); - } - } - } - } - type->num_levels= new_num_lvls; - return Success; -} - -KeySym * -XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed) -{ -register int i,nSyms,nKeySyms; -unsigned nOldSyms; -KeySym *newSyms; - - if (needed==0) { - xkb->map->key_sym_map[key].offset= 0; - return xkb->map->syms; - } - nOldSyms= XkbKeyNumSyms(xkb,key); - if (nOldSyms>=(unsigned)needed) { - return XkbKeySymsPtr(xkb,key); - } - if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) { - if (nOldSyms>0) { - memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key), - nOldSyms*sizeof(KeySym)); - } - if ((needed-nOldSyms)>0) { - bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)], - (needed-nOldSyms)*sizeof(KeySym)); - } - xkb->map->key_sym_map[key].offset = xkb->map->num_syms; - xkb->map->num_syms+= needed; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; - } - xkb->map->size_syms+= (needed>32?needed:32); - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return NULL; - newSyms[0]= NoSymbol; - nSyms = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nCopy; - - nCopy= nKeySyms= XkbKeyNumSyms(xkb,i); - if ((nKeySyms==0)&&(i!=key)) - continue; - if (i==key) - nKeySyms= needed; - if (nCopy!=0) - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym)); - if (nKeySyms>nCopy) - bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset = nSyms; - nSyms+= nKeySyms; - } - _XkbFree(xkb->map->syms); - xkb->map->syms = newSyms; - xkb->map->num_syms = nSyms; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; -} - -static unsigned -_ExtendRange( unsigned int old_flags, - unsigned int flag, - KeyCode newKC, - KeyCode * old_min, - unsigned char * old_num) -{ - if ((old_flags&flag)==0) { - old_flags|= flag; - *old_min= newKC; - *old_num= 1; - } - else { - int last= (*old_min)+(*old_num)-1; - if (newKC<*old_min) { - *old_min= newKC; - *old_num= (last-newKC)+1; - } - else if (newKC>last) { - *old_num= (newKC-(*old_min))+1; - } - } - return old_flags; -} - -Status -XkbChangeKeycodeRange( XkbDescPtr xkb, - int minKC, - int maxKC, - XkbChangesPtr changes) -{ -int tmp; - - if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode)) - return BadValue; - if (minKC>maxKC) - return BadMatch; - if (minKC<xkb->min_key_code) { - if (changes) - changes->map.min_key_code= minKC; - tmp= xkb->min_key_code-minKC; - if (xkb->map) { - if (xkb->map->key_sym_map) { - bzero((char *)&xkb->map->key_sym_map[minKC], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,minKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - bzero((char *)&xkb->map->modmap[minKC],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - bzero((char *)&xkb->server->behaviors[minKC], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,minKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - bzero((char *)&xkb->server->key_acts[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,minKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - bzero((char *)&xkb->server->vmodmap[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,minKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->min_key_code= minKC; - } - if (maxKC>xkb->max_key_code) { - if (changes) - changes->map.max_key_code= maxKC; - tmp= maxKC-xkb->max_key_code; - if (xkb->map) { - if (xkb->map->key_sym_map) { - XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map; - - xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map, - (maxKC+1),XkbSymMapRec); - if (!xkb->map->key_sym_map) { - _XkbFree(prev_key_sym_map); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code+1], - tmp*sizeof(XkbSymMapRec)); -#else - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code], - tmp*sizeof(XkbSymMapRec)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,maxKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - unsigned char *prev_modmap = xkb->map->modmap; - - xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap, - (maxKC+1),unsigned char); - if (!xkb->map->modmap) { - _XkbFree(prev_modmap); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->map->modmap[xkb->max_key_code+1],tmp); -#else - bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - XkbBehavior *prev_behaviors = xkb->server->behaviors; - - xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors, - (maxKC+1),XkbBehavior); - if (!xkb->server->behaviors) { - _XkbFree(prev_behaviors); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->behaviors[xkb->max_key_code+1], - tmp*sizeof(XkbBehavior)); -#else - bzero((char *)&xkb->server->behaviors[xkb->max_key_code], - tmp*sizeof(XkbBehavior)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,maxKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - unsigned short *prev_key_acts = xkb->server->key_acts; - - xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts, - (maxKC+1),unsigned short); - if (!xkb->server->key_acts) { - _XkbFree(prev_key_acts); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->key_acts[xkb->max_key_code+1], - tmp*sizeof(unsigned short)); -#else - bzero((char *)&xkb->server->key_acts[xkb->max_key_code], - tmp*sizeof(unsigned short)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,maxKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - unsigned short *prev_vmodmap = xkb->server->vmodmap; - - xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap, - (maxKC+1),unsigned short); - if (!xkb->server->vmodmap) { - _XkbFree(prev_vmodmap); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code+1], - tmp*sizeof(unsigned short)); -#else - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code], - tmp*sizeof(unsigned short)); -#endif - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - XkbKeyNameRec *prev_keys = xkb->names->keys; - - xkb->names->keys= _XkbTypedRealloc(xkb->names->keys, - (maxKC+1),XkbKeyNameRec); - if (!xkb->names->keys) { - _XkbFree(prev_keys); - return BadAlloc; - } -#ifdef NXAGENT_SERVER - bzero((char *)&xkb->names->keys[xkb->max_key_code+1], - tmp*sizeof(XkbKeyNameRec)); -#else - bzero((char *)&xkb->names->keys[xkb->max_key_code], - tmp*sizeof(XkbKeyNameRec)); -#endif - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,maxKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->max_key_code= maxKC; - } - return Success; -} - -XkbAction * -XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed) -{ -register int i,nActs; -XkbAction *newActs; - - if (needed==0) { - xkb->server->key_acts[key]= 0; - return NULL; - } - if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed)) - return XkbKeyActionsPtr(xkb,key); - if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) { - xkb->server->key_acts[key]= xkb->server->num_acts; - xkb->server->num_acts+= needed; - return &xkb->server->acts[xkb->server->key_acts[key]]; - } - xkb->server->size_acts= xkb->server->num_acts+needed+8; - newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction); - if (newActs==NULL) - return NULL; - newActs[0].type = XkbSA_NoAction; - nActs = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nKeyActs,nCopy; - - if ((xkb->server->key_acts[i]==0)&&(i!=key)) - continue; - - nCopy= nKeyActs= XkbKeyNumActions(xkb,i); - if (i==key) { - nKeyActs= needed; - if (needed<nCopy) - nCopy= needed; - } - - if (nCopy>0) - memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i), - nCopy*sizeof(XkbAction)); - if (nCopy<nKeyActs) - bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction)); - xkb->server->key_acts[i]= nActs; - nActs+= nKeyActs; - } - _XkbFree(xkb->server->acts); - xkb->server->acts = newActs; - xkb->server->num_acts= nActs; - return &xkb->server->acts[xkb->server->key_acts[key]]; -} - -void -XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbClientMapPtr map; - - if ((xkb==NULL)||(xkb->map==NULL)) - return; - if (freeMap) - what= XkbAllClientInfoMask; - map= xkb->map; - if (what&XkbKeyTypesMask) { - if (map->types!=NULL) { - if (map->num_types>0) { - register int i; - XkbKeyTypePtr type; - for (i=0,type=map->types;i<map->num_types;i++,type++) { - if (type->map!=NULL) { - _XkbFree(type->map); - type->map= NULL; - } - if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= 0; - if (type->level_names!=NULL) { - _XkbFree(type->level_names); - type->level_names= NULL; - } - } - } - _XkbFree(map->types); - map->num_types= map->size_types= 0; - map->types= NULL; - } - } - if (what&XkbKeySymsMask) { - if (map->key_sym_map!=NULL) { - _XkbFree(map->key_sym_map); - map->key_sym_map= NULL; - } - if (map->syms!=NULL) { - _XkbFree(map->syms); - map->size_syms= map->num_syms= 0; - map->syms= NULL; - } - } - if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) { - _XkbFree(map->modmap); - map->modmap= NULL; - } - if (freeMap) { - _XkbFree(xkb->map); - xkb->map= NULL; - } - return; -} - -void -XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbServerMapPtr map; - - if ((xkb==NULL)||(xkb->server==NULL)) - return; - if (freeMap) - what= XkbAllServerInfoMask; - map= xkb->server; - if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) { - _XkbFree(map->explicit); - map->explicit= NULL; - } - if (what&XkbKeyActionsMask) { - if (map->key_acts!=NULL) { - _XkbFree(map->key_acts); - map->key_acts= NULL; - } - if (map->acts!=NULL) { - _XkbFree(map->acts); - map->num_acts= map->size_acts= 0; - map->acts= NULL; - } - } - if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) { - _XkbFree(map->behaviors); - map->behaviors= NULL; - } - if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) { - _XkbFree(map->vmodmap); - map->vmodmap= NULL; - } - - if (freeMap) { - _XkbFree(xkb->server); - xkb->server= NULL; - } - return; -} diff --git a/nx-X11/lib/X11/XKBMAlloc.c.X.original b/nx-X11/lib/X11/XKBMAlloc.c.X.original deleted file mode 100644 index 91d87d57c..000000000 --- a/nx-X11/lib/X11/XKBMAlloc.c.X.original +++ /dev/null @@ -1,994 +0,0 @@ -/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS 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. - -********************************************************/ -/* $XFree86: xc/lib/X11/XKBMAlloc.c,v 3.11 2001/01/17 19:41:48 dawes Exp $ */ - -#ifdef HAVE_DIX_CONFIG_H -#include <dix-config.h> -#elif defined(HAVE_CONFIG_H) -#include <config.h> -#endif - -#ifndef XKB_IN_SERVER - -#include <stdio.h> -#define NEED_REPLIES -#define NEED_EVENTS -#include "Xlibint.h" -#include <X11/extensions/XKBproto.h> -#include <X11/keysym.h> -#include "XKBlibint.h" - -#else - -#include <stdio.h> -#include <X11/X.h> -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#include "misc.h" -#include "inputstr.h" -#include <X11/keysym.h> -#define XKBSRV_NEED_FILE_FUNCS -#include <X11/extensions/XKBsrv.h> - -#endif /* XKB_IN_SERVER */ - -/***====================================================================***/ - -Status -XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes) -{ -register int i; -XkbClientMapPtr map; - - if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes))) - return BadValue; - if ((which&XkbKeySymsMask)&& - ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code))) { -#ifdef DEBUG -fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n", - xkb->min_key_code,xkb->max_key_code); -#endif - return BadValue; - } - - if (xkb->map==NULL) { - map= _XkbTypedCalloc(1,XkbClientMapRec); - if (map==NULL) - return BadAlloc; - xkb->map= map; - } - else map= xkb->map; - - if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) { - if (map->types==NULL) { - map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) - return BadAlloc; - map->num_types= 0; - map->size_types= nTotalTypes; - } - else if (map->size_types<nTotalTypes) { - XkbKeyTypeRec *prev_types = map->types; - - map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec); - if (map->types==NULL) { - _XkbFree(prev_types); - map->num_types= map->size_types= 0; - return BadAlloc; - } - map->size_types= nTotalTypes; - bzero(&map->types[map->num_types], - ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec))); - } - } - if (which&XkbKeySymsMask) { - int nKeys= XkbNumKeys(xkb); - if (map->syms==NULL) { - map->size_syms= (nKeys*15)/10; - map->syms= _XkbTypedCalloc(map->size_syms,KeySym); - if (!map->syms) { - map->size_syms= 0; - return BadAlloc; - } - map->num_syms= 1; - map->syms[0]= NoSymbol; - } - if (map->key_sym_map==NULL) { - i= xkb->max_key_code+1; - map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec); - if (map->key_sym_map==NULL) - return BadAlloc; - } - } - if (which&XkbModifierMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->modmap==NULL) { - i= xkb->max_key_code+1; - map->modmap= _XkbTypedCalloc(i,unsigned char); - if (map->modmap==NULL) - return BadAlloc; - } - } - return Success; -} - -Status -XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions) -{ -register int i; -XkbServerMapPtr map; - - if (xkb==NULL) - return BadMatch; - if (xkb->server==NULL) { - map= _XkbTypedCalloc(1,XkbServerMapRec); - if (map==NULL) - return BadAlloc; - for (i=0;i<XkbNumVirtualMods;i++) { - map->vmods[i]= XkbNoModifierMask; - } - xkb->server= map; - } - else map= xkb->server; - if (which&XkbExplicitComponentsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->explicit==NULL) { - i= xkb->max_key_code+1; - map->explicit= _XkbTypedCalloc(i,unsigned char); - if (map->explicit==NULL) - return BadAlloc; - } - } - if (which&XkbKeyActionsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (nNewActions<1) - nNewActions= 1; - if (map->acts==NULL) { - map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction); - if (map->acts==NULL) - return BadAlloc; - map->num_acts= 1; - map->size_acts= nNewActions+1; - } - else if ((map->size_acts-map->num_acts)<nNewActions) { - unsigned need; - XkbAction *prev_acts = map->acts; - need= map->num_acts+nNewActions; - map->acts= _XkbTypedRealloc(map->acts,need,XkbAction); - if (map->acts==NULL) { - _XkbFree(prev_acts); - map->num_acts= map->size_acts= 0; - return BadAlloc; - } - map->size_acts= need; - bzero(&map->acts[map->num_acts], - ((map->size_acts-map->num_acts)*sizeof(XkbAction))); - } - if (map->key_acts==NULL) { - i= xkb->max_key_code+1; - map->key_acts= _XkbTypedCalloc(i,unsigned short); - if (map->key_acts==NULL) - return BadAlloc; - } - } - if (which&XkbKeyBehaviorsMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->behaviors==NULL) { - i= xkb->max_key_code+1; - map->behaviors= _XkbTypedCalloc(i,XkbBehavior); - if (map->behaviors==NULL) - return BadAlloc; - } - } - if (which&XkbVirtualModMapMask) { - if ((!XkbIsLegalKeycode(xkb->min_key_code))|| - (!XkbIsLegalKeycode(xkb->max_key_code))|| - (xkb->max_key_code<xkb->min_key_code)) - return BadMatch; - if (map->vmodmap==NULL) { - i= xkb->max_key_code+1; - map->vmodmap= _XkbTypedCalloc(i,unsigned short); - if (map->vmodmap==NULL) - return BadAlloc; - } - } - return Success; -} - -/***====================================================================***/ - -Status -XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into) -{ - if ((!from)||(!into)) - return BadMatch; - if (into->map) { - _XkbFree(into->map); - into->map= NULL; - } - if (into->preserve) { - _XkbFree(into->preserve); - into->preserve= NULL; - } - if (into->level_names) { - _XkbFree(into->level_names); - into->level_names= NULL; - } - *into= *from; - if ((from->map)&&(into->map_count>0)) { - into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec); - if (!into->map) - return BadAlloc; - memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec)); - } - if ((from->preserve)&&(into->map_count>0)) { - into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec); - if (!into->preserve) - return BadAlloc; - memcpy(into->preserve,from->preserve, - into->map_count*sizeof(XkbModsRec)); - } - if ((from->level_names)&&(into->num_levels>0)) { - into->level_names= _XkbTypedCalloc(into->num_levels,Atom); - if (!into->level_names) - return BadAlloc; - memcpy(into->level_names,from->level_names, - into->num_levels*sizeof(Atom)); - } - return Success; -} - -Status -XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types) -{ -register int i,rtrn; - - if ((!from)||(!into)||(num_types<0)) - return BadMatch; - for (i=0;i<num_types;i++) { - if ((rtrn= XkbCopyKeyType(from++,into++))!=Success) - return rtrn; - } - return Success; -} - -XkbKeyTypePtr -XkbAddKeyType( XkbDescPtr xkb, - Atom name, - int map_count, - Bool want_preserve, - int num_lvls) -{ -register int i; -unsigned tmp; -XkbKeyTypePtr type; -XkbClientMapPtr map; - - if ((!xkb)||(num_lvls<1)) - return NULL; - map= xkb->map; - if ((map)&&(map->types)) { - for (i=0;i<map->num_types;i++) { - if (map->types[i].name==name) { - Status status; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) { - tmp= XkbNumRequiredTypes+1; - if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success) - return NULL; - tmp= 0; - if (map->num_types<=XkbKeypadIndex) - tmp|= XkbKeypadMask; - if (map->num_types<=XkbAlphabeticIndex) - tmp|= XkbAlphabeticMask; - if (map->num_types<=XkbTwoLevelIndex) - tmp|= XkbTwoLevelMask; - if (map->num_types<=XkbOneLevelIndex) - tmp|= XkbOneLevelMask; - if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) { - for (i=0;i<map->num_types;i++) { - Status status; - if (map->types[i].name!=name) - continue; - status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls); - return (status==Success?&map->types[i]:NULL); - } - } - } - if ((map->num_types<=map->size_types)&& - (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) { - return NULL; - } - type= &map->types[map->num_types]; - map->num_types++; - bzero((char *)type,sizeof(XkbKeyTypeRec)); - type->num_levels= num_lvls; - type->map_count= map_count; - type->name= name; - if (map_count>0) { - type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec); - if (!type->map) { - map->num_types--; - return NULL; - } - if (want_preserve) { - type->preserve= _XkbTypedCalloc(map_count,XkbModsRec); - if (!type->preserve) { - _XkbFree(type->map); - map->num_types--; - return NULL; - } - } - } - return type; -} - -Status -XkbResizeKeyType( XkbDescPtr xkb, - int type_ndx, - int map_count, - Bool want_preserve, - int new_num_lvls) -{ -XkbKeyTypePtr type; -KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys; - - if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)|| - (new_num_lvls<1)) - return BadValue; - switch (type_ndx) { - case XkbOneLevelIndex: - if (new_num_lvls!=1) - return BadMatch; - break; - case XkbTwoLevelIndex: - case XkbAlphabeticIndex: - case XkbKeypadIndex: - if (new_num_lvls!=2) - return BadMatch; - break; - } - type= &xkb->map->types[type_ndx]; - if (map_count==0) { - if (type->map!=NULL) - _XkbFree(type->map); - type->map= NULL; - if (type->preserve!=NULL) - _XkbFree(type->preserve); - type->preserve= NULL; - type->map_count= 0; - } - else { - XkbKTMapEntryRec *prev_map = type->map; - - if ((map_count>type->map_count)||(type->map==NULL)) - type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec); - if (!type->map) { - if (prev_map) - _XkbFree(prev_map); - return BadAlloc; - } - if (want_preserve) { - XkbModsRec *prev_preserve = type->preserve; - - if ((map_count>type->map_count)||(type->preserve==NULL)) { - type->preserve= _XkbTypedRealloc(type->preserve,map_count, - XkbModsRec); - } - if (!type->preserve) { - if (prev_preserve) - _XkbFree(prev_preserve); - return BadAlloc; - } - } - else if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= map_count; - } - - if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) { - Atom * prev_level_names = type->level_names; - - type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom); - if (!type->level_names) { - if (prev_level_names) - _XkbFree(prev_level_names); - return BadAlloc; - } - } - /* - * Here's the theory: - * If the width of the type changed, we might have to resize the symbol - * maps for any keys that use the type for one or more groups. This is - * expensive, so we'll try to cull out any keys that are obviously okay: - * In any case: - * - keys that have a group width <= the old width are okay (because - * they could not possibly have been associated with the old type) - * If the key type increased in size: - * - keys that already have a group width >= to the new width are okay - * + keys that have a group width >= the old width but < the new width - * might have to be enlarged. - * If the key type decreased in size: - * - keys that have a group width > the old width don't have to be - * resized (because they must have some other wider type associated - * with some group). - * + keys that have a group width == the old width might have to be - * shrunk. - * The possibilities marked with '+' require us to examine the key types - * associated with each group for the key. - */ - bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode)); - nMatchingKeys= 0; - if (new_num_lvls>type->num_levels) { - int nTotal; - KeySym * newSyms; - int width,match,nResize; - register int i,g,nSyms; - - nResize= 0; - for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - if ((!match)||(width>=new_num_lvls)) - nTotal+= XkbKeyNumSyms(xkb,i); - else { - nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - nResize++; - } - } - if (nResize>0) { - int nextMatch; - xkb->map->size_syms= (nTotal*12)/10; - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return BadAlloc; - nextMatch= 0; - nSyms= 1; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - if (matchingKeys[nextMatch]==i) { - KeySym *pOld; - nextMatch++; - width= XkbKeyGroupsWidth(xkb,i); - pOld= XkbKeySymsPtr(xkb,i); - for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) { - memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g], - width*sizeof(KeySym)); - } - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls; - } - else { - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i), - XkbKeyNumSyms(xkb,i)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset= nSyms; - nSyms+= XkbKeyNumSyms(xkb,i); - } - } - type->num_levels= new_num_lvls; - _XkbFree(xkb->map->syms); - xkb->map->syms= newSyms; - xkb->map->num_syms= nSyms; - return Success; - } - } - else if (new_num_lvls<type->num_levels) { - int width,match; - register int g,i; - for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) { - width= XkbKeyGroupsWidth(xkb,i); - if (width<type->num_levels) - continue; - for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) { - if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) { - matchingKeys[nMatchingKeys++]= i; - match= 1; - } - } - } - } - if (nMatchingKeys>0) { - int key,firstClear; - register int i,g; - if (new_num_lvls>type->num_levels) - firstClear= type->num_levels; - else firstClear= new_num_lvls; - for (i=0;i<nMatchingKeys;i++) { - KeySym * pSyms; - int width,nClear; - - key= matchingKeys[i]; - width= XkbKeyGroupsWidth(xkb,key); - nClear= width-firstClear; - pSyms= XkbKeySymsPtr(xkb,key); - for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) { - if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) { - if (nClear>0) - bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym)); - } - } - } - } - type->num_levels= new_num_lvls; - return Success; -} - -KeySym * -XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed) -{ -register int i,nSyms,nKeySyms; -unsigned nOldSyms; -KeySym *newSyms; - - if (needed==0) { - xkb->map->key_sym_map[key].offset= 0; - return xkb->map->syms; - } - nOldSyms= XkbKeyNumSyms(xkb,key); - if (nOldSyms>=(unsigned)needed) { - return XkbKeySymsPtr(xkb,key); - } - if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) { - if (nOldSyms>0) { - memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key), - nOldSyms*sizeof(KeySym)); - } - if ((needed-nOldSyms)>0) { - bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)], - (needed-nOldSyms)*sizeof(KeySym)); - } - xkb->map->key_sym_map[key].offset = xkb->map->num_syms; - xkb->map->num_syms+= needed; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; - } - xkb->map->size_syms+= (needed>32?needed:32); - newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym); - if (newSyms==NULL) - return NULL; - newSyms[0]= NoSymbol; - nSyms = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nCopy; - - nCopy= nKeySyms= XkbKeyNumSyms(xkb,i); - if ((nKeySyms==0)&&(i!=key)) - continue; - if (i==key) - nKeySyms= needed; - if (nCopy!=0) - memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym)); - if (nKeySyms>nCopy) - bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym)); - xkb->map->key_sym_map[i].offset = nSyms; - nSyms+= nKeySyms; - } - _XkbFree(xkb->map->syms); - xkb->map->syms = newSyms; - xkb->map->num_syms = nSyms; - return &xkb->map->syms[xkb->map->key_sym_map[key].offset]; -} - -static unsigned -_ExtendRange( unsigned int old_flags, - unsigned int flag, - KeyCode newKC, - KeyCode * old_min, - unsigned char * old_num) -{ - if ((old_flags&flag)==0) { - old_flags|= flag; - *old_min= newKC; - *old_num= 1; - } - else { - int last= (*old_min)+(*old_num)-1; - if (newKC<*old_min) { - *old_min= newKC; - *old_num= (last-newKC)+1; - } - else if (newKC>last) { - *old_num= (newKC-(*old_min))+1; - } - } - return old_flags; -} - -Status -XkbChangeKeycodeRange( XkbDescPtr xkb, - int minKC, - int maxKC, - XkbChangesPtr changes) -{ -int tmp; - - if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode)) - return BadValue; - if (minKC>maxKC) - return BadMatch; - if (minKC<xkb->min_key_code) { - if (changes) - changes->map.min_key_code= minKC; - tmp= xkb->min_key_code-minKC; - if (xkb->map) { - if (xkb->map->key_sym_map) { - bzero((char *)&xkb->map->key_sym_map[minKC], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,minKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - bzero((char *)&xkb->map->modmap[minKC],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - bzero((char *)&xkb->server->behaviors[minKC], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,minKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - bzero((char *)&xkb->server->key_acts[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,minKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - bzero((char *)&xkb->server->vmodmap[minKC], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,minKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,minKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->min_key_code= minKC; - } - if (maxKC>xkb->max_key_code) { - if (changes) - changes->map.max_key_code= maxKC; - tmp= maxKC-xkb->max_key_code; - if (xkb->map) { - if (xkb->map->key_sym_map) { - XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map; - - xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map, - (maxKC+1),XkbSymMapRec); - if (!xkb->map->key_sym_map) { - _XkbFree(prev_key_sym_map); - return BadAlloc; - } - bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code], - tmp*sizeof(XkbSymMapRec)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeySymsMask,maxKC, - &changes->map.first_key_sym, - &changes->map.num_key_syms); - } - } - if (xkb->map->modmap) { - unsigned char *prev_modmap = xkb->map->modmap; - - xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap, - (maxKC+1),unsigned char); - if (!xkb->map->modmap) { - _XkbFree(prev_modmap); - return BadAlloc; - } - bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbModifierMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_modmap_keys); - } - } - } - if (xkb->server) { - if (xkb->server->behaviors) { - XkbBehavior *prev_behaviors = xkb->server->behaviors; - - xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors, - (maxKC+1),XkbBehavior); - if (!xkb->server->behaviors) { - _XkbFree(prev_behaviors); - return BadAlloc; - } - bzero((char *)&xkb->server->behaviors[xkb->max_key_code], - tmp*sizeof(XkbBehavior)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyBehaviorsMask,maxKC, - &changes->map.first_key_behavior, - &changes->map.num_key_behaviors); - } - } - if (xkb->server->key_acts) { - unsigned short *prev_key_acts = xkb->server->key_acts; - - xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts, - (maxKC+1),unsigned short); - if (!xkb->server->key_acts) { - _XkbFree(prev_key_acts); - return BadAlloc; - } - bzero((char *)&xkb->server->key_acts[xkb->max_key_code], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbKeyActionsMask,maxKC, - &changes->map.first_key_act, - &changes->map.num_key_acts); - } - } - if (xkb->server->vmodmap) { - unsigned short *prev_vmodmap = xkb->server->vmodmap; - - xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap, - (maxKC+1),unsigned short); - if (!xkb->server->vmodmap) { - _XkbFree(prev_vmodmap); - return BadAlloc; - } - bzero((char *)&xkb->server->vmodmap[xkb->max_key_code], - tmp*sizeof(unsigned short)); - if (changes) { - changes->map.changed= _ExtendRange(changes->map.changed, - XkbVirtualModMapMask,maxKC, - &changes->map.first_modmap_key, - &changes->map.num_vmodmap_keys); - } - } - } - if ((xkb->names)&&(xkb->names->keys)) { - XkbKeyNameRec *prev_keys = xkb->names->keys; - - xkb->names->keys= _XkbTypedRealloc(xkb->names->keys, - (maxKC+1),XkbKeyNameRec); - if (!xkb->names->keys) { - _XkbFree(prev_keys); - return BadAlloc; - } - bzero((char *)&xkb->names->keys[xkb->max_key_code], - tmp*sizeof(XkbKeyNameRec)); - if (changes) { - changes->names.changed= _ExtendRange(changes->names.changed, - XkbKeyNamesMask,maxKC, - &changes->names.first_key, - &changes->names.num_keys); - } - } - xkb->max_key_code= maxKC; - } - return Success; -} - -XkbAction * -XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed) -{ -register int i,nActs; -XkbAction *newActs; - - if (needed==0) { - xkb->server->key_acts[key]= 0; - return NULL; - } - if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed)) - return XkbKeyActionsPtr(xkb,key); - if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) { - xkb->server->key_acts[key]= xkb->server->num_acts; - xkb->server->num_acts+= needed; - return &xkb->server->acts[xkb->server->key_acts[key]]; - } - xkb->server->size_acts= xkb->server->num_acts+needed+8; - newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction); - if (newActs==NULL) - return NULL; - newActs[0].type = XkbSA_NoAction; - nActs = 1; - for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) { - int nKeyActs,nCopy; - - if ((xkb->server->key_acts[i]==0)&&(i!=key)) - continue; - - nCopy= nKeyActs= XkbKeyNumActions(xkb,i); - if (i==key) { - nKeyActs= needed; - if (needed<nCopy) - nCopy= needed; - } - - if (nCopy>0) - memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i), - nCopy*sizeof(XkbAction)); - if (nCopy<nKeyActs) - bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction)); - xkb->server->key_acts[i]= nActs; - nActs+= nKeyActs; - } - _XkbFree(xkb->server->acts); - xkb->server->acts = newActs; - xkb->server->num_acts= nActs; - return &xkb->server->acts[xkb->server->key_acts[key]]; -} - -void -XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbClientMapPtr map; - - if ((xkb==NULL)||(xkb->map==NULL)) - return; - if (freeMap) - what= XkbAllClientInfoMask; - map= xkb->map; - if (what&XkbKeyTypesMask) { - if (map->types!=NULL) { - if (map->num_types>0) { - register int i; - XkbKeyTypePtr type; - for (i=0,type=map->types;i<map->num_types;i++,type++) { - if (type->map!=NULL) { - _XkbFree(type->map); - type->map= NULL; - } - if (type->preserve!=NULL) { - _XkbFree(type->preserve); - type->preserve= NULL; - } - type->map_count= 0; - if (type->level_names!=NULL) { - _XkbFree(type->level_names); - type->level_names= NULL; - } - } - } - _XkbFree(map->types); - map->num_types= map->size_types= 0; - map->types= NULL; - } - } - if (what&XkbKeySymsMask) { - if (map->key_sym_map!=NULL) { - _XkbFree(map->key_sym_map); - map->key_sym_map= NULL; - } - if (map->syms!=NULL) { - _XkbFree(map->syms); - map->size_syms= map->num_syms= 0; - map->syms= NULL; - } - } - if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) { - _XkbFree(map->modmap); - map->modmap= NULL; - } - if (freeMap) { - _XkbFree(xkb->map); - xkb->map= NULL; - } - return; -} - -void -XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap) -{ -XkbServerMapPtr map; - - if ((xkb==NULL)||(xkb->server==NULL)) - return; - if (freeMap) - what= XkbAllServerInfoMask; - map= xkb->server; - if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) { - _XkbFree(map->explicit); - map->explicit= NULL; - } - if (what&XkbKeyActionsMask) { - if (map->key_acts!=NULL) { - _XkbFree(map->key_acts); - map->key_acts= NULL; - } - if (map->acts!=NULL) { - _XkbFree(map->acts); - map->num_acts= map->size_acts= 0; - map->acts= NULL; - } - } - if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) { - _XkbFree(map->behaviors); - map->behaviors= NULL; - } - if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) { - _XkbFree(map->vmodmap); - map->vmodmap= NULL; - } - - if (freeMap) { - _XkbFree(xkb->server); - xkb->server= NULL; - } - return; -} diff --git a/nx-X11/lib/X11/Xlib.h.NX.original b/nx-X11/lib/X11/Xlib.h.NX.original deleted file mode 100644 index e21d9ffac..000000000 --- a/nx-X11/lib/X11/Xlib.h.NX.original +++ /dev/null @@ -1,4029 +0,0 @@ -/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */ -/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1991, 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. - -*/ -/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */ - - -/* - * Xlib.h - Header definition and support file for the C subroutine - * interface library (Xlib) to the X Window System Protocol (V11). - * Structures and symbols starting with "_" are private to the library. - */ -#ifndef _XLIB_H_ -#define _XLIB_H_ - -#define XlibSpecificationRelease 6 - -#ifdef USG -#ifndef __TYPES__ -#include <sys/types.h> /* forgot to protect it... */ -#define __TYPES__ -#endif /* __TYPES__ */ -#else -#if defined(_POSIX_SOURCE) && defined(MOTOROLA) -#undef _POSIX_SOURCE -#include <sys/types.h> -#define _POSIX_SOURCE -#else -#include <sys/types.h> -#endif -#endif /* USG */ - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <stdint.h> -#endif - -#include <X11/X.h> - -/* applications should not depend on these two headers being included! */ -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> - -#ifndef X_WCHAR -#ifdef X_NOT_STDC_ENV -#ifndef ISC -#define X_WCHAR -#endif -#endif -#endif - -#ifndef X_WCHAR -#include <stddef.h> -#else -#ifdef __UNIXOS2__ -#include <stdlib.h> -#else -/* replace this with #include or typedef appropriate for your system */ -typedef unsigned long wchar_t; -#endif -#endif - -#if defined(ISC) && defined(USE_XMBTOWC) -#define wctomb(a,b) _Xwctomb(a,b) -#define mblen(a,b) _Xmblen(a,b) -#ifndef USE_XWCHAR_STRING -#define mbtowc(a,b,c) _Xmbtowc(a,b,c) -#endif -#endif - -extern int -_Xmblen( -#ifdef ISC - char const *str, - size_t len -#else - char *str, - int len -#endif - ); - -/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in - November 2000. Its presence is indicated through the following macro. */ -#define X_HAVE_UTF8_STRING 1 - -typedef char *XPointer; - -#define Bool int -#define Status int -#define True 1 -#define False 0 - -#define QueuedAlready 0 -#define QueuedAfterReading 1 -#define QueuedAfterFlush 2 - -#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) -#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) -#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) -#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) -#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) -#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) -#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) -#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) -#define AllPlanes ((unsigned long)~0L) -#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) -#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) -#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) -#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) -#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) -#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) -#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) -#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) -#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) -#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) -#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) -#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) -#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) -#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) -#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) -#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) -#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) -#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ -#define NextRequest(dpy) XNextRequest(dpy) -#else -#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) -#endif -#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) - -/* macros for screen oriented applications (toolkit) */ -#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) -#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) -#define DisplayOfScreen(s) ((s)->display) -#define RootWindowOfScreen(s) ((s)->root) -#define BlackPixelOfScreen(s) ((s)->black_pixel) -#define WhitePixelOfScreen(s) ((s)->white_pixel) -#define DefaultColormapOfScreen(s)((s)->cmap) -#define DefaultDepthOfScreen(s) ((s)->root_depth) -#define DefaultGCOfScreen(s) ((s)->default_gc) -#define DefaultVisualOfScreen(s)((s)->root_visual) -#define WidthOfScreen(s) ((s)->width) -#define HeightOfScreen(s) ((s)->height) -#define WidthMMOfScreen(s) ((s)->mwidth) -#define HeightMMOfScreen(s) ((s)->mheight) -#define PlanesOfScreen(s) ((s)->root_depth) -#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) -#define MinCmapsOfScreen(s) ((s)->min_maps) -#define MaxCmapsOfScreen(s) ((s)->max_maps) -#define DoesSaveUnders(s) ((s)->save_unders) -#define DoesBackingStore(s) ((s)->backing_store) -#define EventMaskOfScreen(s) ((s)->root_input_mask) - -/* - * Extensions need a way to hang private data on some structures. - */ -typedef struct _XExtData { - int number; /* number returned by XRegisterExtension */ - struct _XExtData *next; /* next item on list of data for structure */ - int (*free_private)( /* called to free private storage */ - struct _XExtData *extension - ); - XPointer private_data; /* data private to this extension. */ -} XExtData; - -/* - * This file contains structures used by the extension mechanism. - */ -typedef struct { /* public to extension, cannot be changed */ - int extension; /* extension number */ - int major_opcode; /* major op-code assigned by server */ - int first_event; /* first event number for the extension */ - int first_error; /* first error number for the extension */ -} XExtCodes; - -/* - * Data structure for retrieving info about pixmap formats. - */ - -typedef struct { - int depth; - int bits_per_pixel; - int scanline_pad; -} XPixmapFormatValues; - - -/* - * Data structure for setting graphics context. - */ -typedef struct { - int function; /* logical operation */ - unsigned long plane_mask;/* plane mask */ - unsigned long foreground;/* foreground pixel */ - unsigned long background;/* background pixel */ - int line_width; /* line width */ - int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ - int cap_style; /* CapNotLast, CapButt, - CapRound, CapProjecting */ - int join_style; /* JoinMiter, JoinRound, JoinBevel */ - int fill_style; /* FillSolid, FillTiled, - FillStippled, FillOpaeueStippled */ - int fill_rule; /* EvenOddRule, WindingRule */ - int arc_mode; /* ArcChord, ArcPieSlice */ - Pixmap tile; /* tile pixmap for tiling operations */ - Pixmap stipple; /* stipple 1 plane pixmap for stipping */ - int ts_x_origin; /* offset for tile or stipple operations */ - int ts_y_origin; - Font font; /* default text font for text operations */ - int subwindow_mode; /* ClipByChildren, IncludeInferiors */ - Bool graphics_exposures;/* boolean, should exposures be generated */ - int clip_x_origin; /* origin for clipping */ - int clip_y_origin; - Pixmap clip_mask; /* bitmap clipping; other calls for rects */ - int dash_offset; /* patterned/dashed line information */ - char dashes; -} XGCValues; - -/* - * Graphics context. The contents of this structure are implementation - * dependent. A GC should be treated as opaque by application code. - */ - -typedef struct _XGC -#ifdef XLIB_ILLEGAL_ACCESS -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - /* there is more to this structure, but it is private to Xlib */ -} -#endif -*GC; - -/* - * Visual structure; contains information about colormapping possible. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - VisualID visualid; /* visual id of this visual */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ class of screen (monochrome, etc.) */ -#else - int class; /* class of screen (monochrome, etc.) */ -#endif - unsigned long red_mask, green_mask, blue_mask; /* mask values */ - int bits_per_rgb; /* log base 2 of distinct color values */ - int map_entries; /* color map entries */ -} Visual; - -/* - * Depth structure; contains information for each possible depth. - */ -typedef struct { - int depth; /* this depth (Z) of the depth */ - int nvisuals; /* number of Visual types at this depth */ - Visual *visuals; /* list of visuals possible at this depth */ -} Depth; - -/* - * Information about the screen. The contents of this structure are - * implementation dependent. A Screen should be treated as opaque - * by application code. - */ - -struct _XDisplay; /* Forward declare before use for C++ */ - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - struct _XDisplay *display;/* back pointer to display structure */ - Window root; /* Root window id. */ - int width, height; /* width and height of screen */ - int mwidth, mheight; /* width and height of in millimeters */ - int ndepths; /* number of depths possible */ - Depth *depths; /* list of allowable depths on the screen */ - int root_depth; /* bits per pixel */ - Visual *root_visual; /* root visual */ - GC default_gc; /* GC for the root root visual */ - Colormap cmap; /* default color map */ - unsigned long white_pixel; - unsigned long black_pixel; /* White and Black pixel values */ - int max_maps, min_maps; /* max and min color maps */ - int backing_store; /* Never, WhenMapped, Always */ - Bool save_unders; - long root_input_mask; /* initial root input mask */ -} Screen; - -/* - * Format structure; describes ZFormat data the screen will understand. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - int depth; /* depth of this image format */ - int bits_per_pixel; /* bits/pixel at this depth */ - int scanline_pad; /* scanline must padded to this multiple */ -} ScreenFormat; - -/* - * Data structure for setting window attributes. - */ -typedef struct { - Pixmap background_pixmap; /* background or None or ParentRelative */ - unsigned long background_pixel; /* background pixel */ - Pixmap border_pixmap; /* border of the window */ - unsigned long border_pixel; /* border pixel value */ - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preseved if possible */ - unsigned long backing_pixel;/* value to use in restoring planes */ - Bool save_under; /* should bits under be saved? (popups) */ - long event_mask; /* set of events that should be saved */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Colormap colormap; /* color map to be associated with window */ - Cursor cursor; /* cursor to be displayed (or None) */ -} XSetWindowAttributes; - -typedef struct { - int x, y; /* location of window */ - int width, height; /* width and height of window */ - int border_width; /* border width of window */ - int depth; /* depth of window */ - Visual *visual; /* the associated visual structure */ - Window root; /* root of screen containing window */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ InputOutput, InputOnly*/ -#else - int class; /* InputOutput, InputOnly*/ -#endif - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preserved if possible */ - unsigned long backing_pixel;/* value to be used when restoring planes */ - Bool save_under; /* boolean, should bits under be saved? */ - Colormap colormap; /* color map to be associated with window */ - Bool map_installed; /* boolean, is color map currently installed*/ - int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ - long all_event_masks; /* set of events all people have interest in*/ - long your_event_mask; /* my event mask */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Screen *screen; /* back pointer to correct screen */ -} XWindowAttributes; - -/* - * Data structure for host setting; getting routines. - * - */ - -typedef struct { - int family; /* for example FamilyInternet */ - int length; /* length of address, in bytes */ - char *address; /* pointer to where to find the bytes */ -} XHostAddress; - -/* - * Data structure for ServerFamilyInterpreted addresses in host routines - */ -typedef struct { - int typelength; /* length of type string, in bytes */ - int valuelength; /* length of value string, in bytes */ - char *type; /* pointer to where to find the type string */ - char *value; /* pointer to where to find the address */ -} XServerInterpretedAddress; - -/* - * Data structure for "image" data, used by image manipulation routines. - */ -typedef struct _XImage { - int width, height; /* size of image */ - int xoffset; /* number of pixels offset in X direction */ - int format; /* XYBitmap, XYPixmap, ZPixmap */ - char *data; /* pointer to image data */ - int byte_order; /* data byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* quant. of scanline 8, 16, 32 */ - int bitmap_bit_order; /* LSBFirst, MSBFirst */ - int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ - int depth; /* depth of image */ - int bytes_per_line; /* accelarator to next line */ - int bits_per_pixel; /* bits per pixel (ZPixmap) */ - unsigned long red_mask; /* bits in z arrangment */ - unsigned long green_mask; - unsigned long blue_mask; - XPointer obdata; /* hook for the object routines to hang on */ - struct funcs { /* image manipulation routines */ - struct _XImage *(*create_image)( - struct _XDisplay* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */); - int (*destroy_image) (struct _XImage *); - unsigned long (*get_pixel) (struct _XImage *, int, int); - int (*put_pixel) (struct _XImage *, int, int, unsigned long); - struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); - int (*add_pixel) (struct _XImage *, long); - } f; -} XImage; - -/* - * Data structure for XReconfigureWindow - */ -typedef struct { - int x, y; - int width, height; - int border_width; - Window sibling; - int stack_mode; -} XWindowChanges; - -/* - * Data structure used by color operations - */ -typedef struct { - unsigned long pixel; - unsigned short red, green, blue; - char flags; /* do_red, do_green, do_blue */ - char pad; -} XColor; - -/* - * Data structures for graphics operations. On most machines, these are - * congruent with the wire protocol structures, so reformatting the data - * can be avoided on these architectures. - */ -typedef struct { - short x1, y1, x2, y2; -} XSegment; - -typedef struct { - short x, y; -} XPoint; - -typedef struct { - short x, y; - unsigned short width, height; -} XRectangle; - -typedef struct { - short x, y; - unsigned short width, height; - short angle1, angle2; -} XArc; - - -/* Data structure for XChangeKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - int bell_pitch; - int bell_duration; - int led; - int led_mode; - int key; - int auto_repeat_mode; /* On, Off, Default */ -} XKeyboardControl; - -/* Data structure for XGetKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - unsigned int bell_pitch, bell_duration; - unsigned long led_mask; - int global_auto_repeat; - char auto_repeats[32]; -} XKeyboardState; - -/* Data structure for XGetMotionEvents. */ - -typedef struct { - Time time; - short x, y; -} XTimeCoord; - -/* Data structure for X{Set,Get}ModifierMapping */ - -typedef struct { - int max_keypermod; /* The server's max # of keys per modifier */ - KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ -} XModifierKeymap; - - -/* - * Display datatype maintaining display specific data. - * The contents of this structure are implementation dependent. - * A Display should be treated as opaque by application code. - */ -#ifndef XLIB_ILLEGAL_ACCESS -typedef struct _XDisplay Display; -#endif - -struct _XPrivate; /* Forward declare before use for C++ */ -struct _XrmHashBucketRec; - -typedef struct -#ifdef XLIB_ILLEGAL_ACCESS -_XDisplay -#endif -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XPrivate *private1; - int fd; /* Network socket. */ - int private2; - int proto_major_version;/* major version of server's X protocol */ - int proto_minor_version;/* minor version of servers X protocol */ - char *vendor; /* vendor of the server hardware */ - XID private3; - XID private4; - XID private5; - int private6; - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int private8; - int release; /* release of the server */ - struct _XPrivate *private9, *private10; - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - XPointer private11; - XPointer private12; - XPointer private13; - XPointer private14; - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*private15)( - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long private16; - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - XPointer private17; - XPointer private18; - int private19; - char *xdefaults; /* contents of defaults from server */ - /* there is more to this structure, but it is private to Xlib */ -} -#ifdef XLIB_ILLEGAL_ACCESS -Display, -#endif -*_XPrivDisplay; - -#undef _XEVENT_ -#ifndef _XEVENT_ -/* - * Definitions of specific events. - */ -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int keycode; /* detail */ - Bool same_screen; /* same screen flag */ -} XKeyEvent; -typedef XKeyEvent XKeyPressedEvent; -typedef XKeyEvent XKeyReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int button; /* detail */ - Bool same_screen; /* same screen flag */ -} XButtonEvent; -typedef XButtonEvent XButtonPressedEvent; -typedef XButtonEvent XButtonReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - char is_hint; /* detail */ - Bool same_screen; /* same screen flag */ -} XMotionEvent; -typedef XMotionEvent XPointerMovedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual - */ - Bool same_screen; /* same screen flag */ - Bool focus; /* boolean focus */ - unsigned int state; /* key or button mask */ -} XCrossingEvent; -typedef XCrossingEvent XEnterWindowEvent; -typedef XCrossingEvent XLeaveWindowEvent; - -typedef struct { - int type; /* FocusIn or FocusOut */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* window of event */ - int mode; /* NotifyNormal, NotifyWhileGrabbed, - NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, - * NotifyPointerRoot, NotifyDetailNone - */ -} XFocusChangeEvent; -typedef XFocusChangeEvent XFocusInEvent; -typedef XFocusChangeEvent XFocusOutEvent; - -/* generated on EnterWindow and FocusIn when KeyMapState selected */ -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - char key_vector[32]; -} XKeymapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ -} XExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XGraphicsExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XNoExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int state; /* Visibility state */ -} XVisibilityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; /* parent of the window */ - Window window; /* window id of window created */ - int x, y; /* window location */ - int width, height; /* size of window */ - int border_width; /* border width */ - Bool override_redirect; /* creation should be overridden */ -} XCreateWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; -} XDestroyWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool from_configure; -} XUnmapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool override_redirect; /* boolean, is override set... */ -} XMapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; -} XMapRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Window parent; - int x, y; - Bool override_redirect; -} XReparentEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - Bool override_redirect; -} XConfigureEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; -} XGravityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int width, height; -} XResizeRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - int detail; /* Above, Below, TopIf, BottomIf, Opposite */ - unsigned long value_mask; -} XConfigureRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom atom; - Time time; - int state; /* NewValue, Deleted */ -} XPropertyEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom selection; - Time time; -} XSelectionClearEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window owner; - Window requestor; - Atom selection; - Atom target; - Atom property; - Time time; -} XSelectionRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window requestor; - Atom selection; - Atom target; - Atom property; /* ATOM or None */ - Time time; -} XSelectionEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Colormap colormap; /* COLORMAP or None */ -#if defined(__cplusplus) || defined(c_plusplus) - Bool c_new; /* C++ */ -#else - Bool new; -#endif - int state; /* ColormapInstalled, ColormapUninstalled */ -} XColormapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom message_type; - int format; - union { - char b[20]; - short s[10]; - long l[5]; - } data; -} XClientMessageEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* unused */ - int request; /* one of MappingModifier, MappingKeyboard, - MappingPointer */ - int first_keycode; /* first keycode */ - int count; /* defines range of change w. first_keycode*/ -} XMappingEvent; - -typedef struct { - int type; - Display *display; /* Display the event was read from */ - XID resourceid; /* resource id */ - unsigned long serial; /* serial number of failed request */ - unsigned char error_code; /* error code of failed request */ - unsigned char request_code; /* Major op-code of failed request */ - unsigned char minor_code; /* Minor op-code of failed request */ -} XErrorEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display;/* Display the event was read from */ - Window window; /* window on which event was requested in event mask */ -} XAnyEvent; - -/* - * this union is defined so Xlib can always use the same sized - * event structure internally, to avoid memory fragmentation. - */ -typedef union _XEvent { - int type; /* must not be changed; first element */ - XAnyEvent xany; - XKeyEvent xkey; - XButtonEvent xbutton; - XMotionEvent xmotion; - XCrossingEvent xcrossing; - XFocusChangeEvent xfocus; - XExposeEvent xexpose; - XGraphicsExposeEvent xgraphicsexpose; - XNoExposeEvent xnoexpose; - XVisibilityEvent xvisibility; - XCreateWindowEvent xcreatewindow; - XDestroyWindowEvent xdestroywindow; - XUnmapEvent xunmap; - XMapEvent xmap; - XMapRequestEvent xmaprequest; - XReparentEvent xreparent; - XConfigureEvent xconfigure; - XGravityEvent xgravity; - XResizeRequestEvent xresizerequest; - XConfigureRequestEvent xconfigurerequest; - XCirculateEvent xcirculate; - XCirculateRequestEvent xcirculaterequest; - XPropertyEvent xproperty; - XSelectionClearEvent xselectionclear; - XSelectionRequestEvent xselectionrequest; - XSelectionEvent xselection; - XColormapEvent xcolormap; - XClientMessageEvent xclient; - XMappingEvent xmapping; - XErrorEvent xerror; - XKeymapEvent xkeymap; - long pad[24]; -} XEvent; -#endif - -#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) - -/* - * per character font metric information. - */ -typedef struct { - short lbearing; /* origin to left edge of raster */ - short rbearing; /* origin to right edge of raster */ - short width; /* advance to next char's origin */ - short ascent; /* baseline to top edge of raster */ - short descent; /* baseline to bottom edge of raster */ - unsigned short attributes; /* per char flags (not predefined) */ -} XCharStruct; - -/* - * To allow arbitrary information with fonts, there are additional properties - * returned. - */ -typedef struct { - Atom name; - unsigned long card32; -} XFontProp; - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - Font fid; /* Font id for this font */ - unsigned direction; /* hint about direction the font is painted */ - unsigned min_char_or_byte2;/* first character */ - unsigned max_char_or_byte2;/* last character */ - unsigned min_byte1; /* first row that exists */ - unsigned max_byte1; /* last row that exists */ - Bool all_chars_exist;/* flag if all characters have non-zero size*/ - unsigned default_char; /* char to print for undefined character */ - int n_properties; /* how many properties there are */ - XFontProp *properties; /* pointer to array of additional properties*/ - XCharStruct min_bounds; /* minimum bounds over all existing char*/ - XCharStruct max_bounds; /* maximum bounds over all existing char*/ - XCharStruct *per_char; /* first_char to last_char information */ - int ascent; /* log. extent above baseline for spacing */ - int descent; /* log. descent below baseline for spacing */ -} XFontStruct; - -/* - * PolyText routines take these as arguments. - */ -typedef struct { - char *chars; /* pointer to string */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem; - -typedef struct { /* normal 16 bit characters are two bytes */ - unsigned char byte1; - unsigned char byte2; -} XChar2b; - -typedef struct { - XChar2b *chars; /* two byte characters */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem16; - - -typedef union { Display *display; - GC gc; - Visual *visual; - Screen *screen; - ScreenFormat *pixmap_format; - XFontStruct *font; } XEDataObject; - -typedef struct { - XRectangle max_ink_extent; - XRectangle max_logical_extent; -} XFontSetExtents; - -/* unused: -typedef void (*XOMProc)(); - */ - -typedef struct _XOM *XOM; -typedef struct _XOC *XOC, *XFontSet; - -typedef struct { - char *chars; - int nchars; - int delta; - XFontSet font_set; -} XmbTextItem; - -typedef struct { - wchar_t *chars; - int nchars; - int delta; - XFontSet font_set; -} XwcTextItem; - -#define XNRequiredCharSet "requiredCharSet" -#define XNQueryOrientation "queryOrientation" -#define XNBaseFontName "baseFontName" -#define XNOMAutomatic "omAutomatic" -#define XNMissingCharSet "missingCharSet" -#define XNDefaultString "defaultString" -#define XNOrientation "orientation" -#define XNDirectionalDependentDrawing "directionalDependentDrawing" -#define XNContextualDrawing "contextualDrawing" -#define XNFontInfo "fontInfo" - -typedef struct { - int charset_count; - char **charset_list; -} XOMCharSetList; - -typedef enum { - XOMOrientation_LTR_TTB, - XOMOrientation_RTL_TTB, - XOMOrientation_TTB_LTR, - XOMOrientation_TTB_RTL, - XOMOrientation_Context -} XOrientation; - -typedef struct { - int num_orientation; - XOrientation *orientation; /* Input Text description */ -} XOMOrientation; - -typedef struct { - int num_font; - XFontStruct **font_struct_list; - char **font_name_list; -} XOMFontInfo; - -typedef struct _XIM *XIM; -typedef struct _XIC *XIC; - -typedef void (*XIMProc)( - XIM, - XPointer, - XPointer -); - -typedef Bool (*XICProc)( - XIC, - XPointer, - XPointer -); - -typedef void (*XIDProc)( - Display*, - XPointer, - XPointer -); - -typedef unsigned long XIMStyle; - -typedef struct { - unsigned short count_styles; - XIMStyle *supported_styles; -} XIMStyles; - -#define XIMPreeditArea 0x0001L -#define XIMPreeditCallbacks 0x0002L -#define XIMPreeditPosition 0x0004L -#define XIMPreeditNothing 0x0008L -#define XIMPreeditNone 0x0010L -#define XIMStatusArea 0x0100L -#define XIMStatusCallbacks 0x0200L -#define XIMStatusNothing 0x0400L -#define XIMStatusNone 0x0800L - -#define XNVaNestedList "XNVaNestedList" -#define XNQueryInputStyle "queryInputStyle" -#define XNClientWindow "clientWindow" -#define XNInputStyle "inputStyle" -#define XNFocusWindow "focusWindow" -#define XNResourceName "resourceName" -#define XNResourceClass "resourceClass" -#define XNGeometryCallback "geometryCallback" -#define XNDestroyCallback "destroyCallback" -#define XNFilterEvents "filterEvents" -#define XNPreeditStartCallback "preeditStartCallback" -#define XNPreeditDoneCallback "preeditDoneCallback" -#define XNPreeditDrawCallback "preeditDrawCallback" -#define XNPreeditCaretCallback "preeditCaretCallback" -#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" -#define XNPreeditAttributes "preeditAttributes" -#define XNStatusStartCallback "statusStartCallback" -#define XNStatusDoneCallback "statusDoneCallback" -#define XNStatusDrawCallback "statusDrawCallback" -#define XNStatusAttributes "statusAttributes" -#define XNArea "area" -#define XNAreaNeeded "areaNeeded" -#define XNSpotLocation "spotLocation" -#define XNColormap "colorMap" -#define XNStdColormap "stdColorMap" -#define XNForeground "foreground" -#define XNBackground "background" -#define XNBackgroundPixmap "backgroundPixmap" -#define XNFontSet "fontSet" -#define XNLineSpace "lineSpace" -#define XNCursor "cursor" - -#define XNQueryIMValuesList "queryIMValuesList" -#define XNQueryICValuesList "queryICValuesList" -#define XNVisiblePosition "visiblePosition" -#define XNR6PreeditCallback "r6PreeditCallback" -#define XNStringConversionCallback "stringConversionCallback" -#define XNStringConversion "stringConversion" -#define XNResetState "resetState" -#define XNHotKey "hotKey" -#define XNHotKeyState "hotKeyState" -#define XNPreeditState "preeditState" -#define XNSeparatorofNestedList "separatorofNestedList" - -#define XBufferOverflow -1 -#define XLookupNone 1 -#define XLookupChars 2 -#define XLookupKeySym 3 -#define XLookupBoth 4 - -typedef void *XVaNestedList; - -typedef struct { - XPointer client_data; - XIMProc callback; -} XIMCallback; - -typedef struct { - XPointer client_data; - XICProc callback; -} XICCallback; - -typedef unsigned long XIMFeedback; - -#define XIMReverse 1L -#define XIMUnderline (1L<<1) -#define XIMHighlight (1L<<2) -#define XIMPrimary (1L<<5) -#define XIMSecondary (1L<<6) -#define XIMTertiary (1L<<7) -#define XIMVisibleToForward (1L<<8) -#define XIMVisibleToBackword (1L<<9) -#define XIMVisibleToCenter (1L<<10) - -typedef struct _XIMText { - unsigned short length; - XIMFeedback *feedback; - Bool encoding_is_wchar; - union { - char *multi_byte; - wchar_t *wide_char; - } string; -} XIMText; - -typedef unsigned long XIMPreeditState; - -#define XIMPreeditUnKnown 0L -#define XIMPreeditEnable 1L -#define XIMPreeditDisable (1L<<1) - -typedef struct _XIMPreeditStateNotifyCallbackStruct { - XIMPreeditState state; -} XIMPreeditStateNotifyCallbackStruct; - -typedef unsigned long XIMResetState; - -#define XIMInitialState 1L -#define XIMPreserveState (1L<<1) - -typedef unsigned long XIMStringConversionFeedback; - -#define XIMStringConversionLeftEdge (0x00000001) -#define XIMStringConversionRightEdge (0x00000002) -#define XIMStringConversionTopEdge (0x00000004) -#define XIMStringConversionBottomEdge (0x00000008) -#define XIMStringConversionConcealed (0x00000010) -#define XIMStringConversionWrapped (0x00000020) - -typedef struct _XIMStringConversionText { - unsigned short length; - XIMStringConversionFeedback *feedback; - Bool encoding_is_wchar; - union { - char *mbs; - wchar_t *wcs; - } string; -} XIMStringConversionText; - -typedef unsigned short XIMStringConversionPosition; - -typedef unsigned short XIMStringConversionType; - -#define XIMStringConversionBuffer (0x0001) -#define XIMStringConversionLine (0x0002) -#define XIMStringConversionWord (0x0003) -#define XIMStringConversionChar (0x0004) - -typedef unsigned short XIMStringConversionOperation; - -#define XIMStringConversionSubstitution (0x0001) -#define XIMStringConversionRetrieval (0x0002) - -typedef enum { - XIMForwardChar, XIMBackwardChar, - XIMForwardWord, XIMBackwardWord, - XIMCaretUp, XIMCaretDown, - XIMNextLine, XIMPreviousLine, - XIMLineStart, XIMLineEnd, - XIMAbsolutePosition, - XIMDontChange -} XIMCaretDirection; - -typedef struct _XIMStringConversionCallbackStruct { - XIMStringConversionPosition position; - XIMCaretDirection direction; - XIMStringConversionOperation operation; - unsigned short factor; - XIMStringConversionText *text; -} XIMStringConversionCallbackStruct; - -typedef struct _XIMPreeditDrawCallbackStruct { - int caret; /* Cursor offset within pre-edit string */ - int chg_first; /* Starting change position */ - int chg_length; /* Length of the change in character count */ - XIMText *text; -} XIMPreeditDrawCallbackStruct; - -typedef enum { - XIMIsInvisible, /* Disable caret feedback */ - XIMIsPrimary, /* UI defined caret feedback */ - XIMIsSecondary /* UI defined caret feedback */ -} XIMCaretStyle; - -typedef struct _XIMPreeditCaretCallbackStruct { - int position; /* Caret offset within pre-edit string */ - XIMCaretDirection direction; /* Caret moves direction */ - XIMCaretStyle style; /* Feedback of the caret */ -} XIMPreeditCaretCallbackStruct; - -typedef enum { - XIMTextType, - XIMBitmapType -} XIMStatusDataType; - -typedef struct _XIMStatusDrawCallbackStruct { - XIMStatusDataType type; - union { - XIMText *text; - Pixmap bitmap; - } data; -} XIMStatusDrawCallbackStruct; - -typedef struct _XIMHotKeyTrigger { - KeySym keysym; - int modifier; - int modifier_mask; -} XIMHotKeyTrigger; - -typedef struct _XIMHotKeyTriggers { - int num_hot_key; - XIMHotKeyTrigger *key; -} XIMHotKeyTriggers; - -typedef unsigned long XIMHotKeyState; - -#define XIMHotKeyStateON (0x0001L) -#define XIMHotKeyStateOFF (0x0002L) - -typedef struct { - unsigned short count_values; - char **supported_values; -} XIMValuesList; - -_XFUNCPROTOBEGIN - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _Xdebug (*_Xdebug_p) -#endif - -extern int _Xdebug; - -extern XFontStruct *XLoadQueryFont( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XFontStruct *XQueryFont( - Display* /* display */, - XID /* font_ID */ -); - - -extern XTimeCoord *XGetMotionEvents( - Display* /* display */, - Window /* w */, - Time /* start */, - Time /* stop */, - int* /* nevents_return */ -); - -extern XModifierKeymap *XDeleteModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XGetModifierMapping( - Display* /* display */ -); - -extern XModifierKeymap *XInsertModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XNewModifiermap( - int /* max_keys_per_mod */ -); - -extern XImage *XCreateImage( - Display* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */ -); -extern Status XInitImage( - XImage* /* image */ -); -extern XImage *XGetImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */ -); -extern XImage *XGetSubImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */, - XImage* /* dest_image */, - int /* dest_x */, - int /* dest_y */ -); - -/* - * X function declarations. - */ -extern Display *XOpenDisplay( - _Xconst char* /* display_name */ -); - -extern void XrmInitialize( - void -); - -extern char *XFetchBytes( - Display* /* display */, - int* /* nbytes_return */ -); -extern char *XFetchBuffer( - Display* /* display */, - int* /* nbytes_return */, - int /* buffer */ -); -extern char *XGetAtomName( - Display* /* display */, - Atom /* atom */ -); -extern Status XGetAtomNames( - Display* /* dpy */, - Atom* /* atoms */, - int /* count */, - char** /* names_return */ -); -extern char *XGetDefault( - Display* /* display */, - _Xconst char* /* program */, - _Xconst char* /* option */ -); -extern char *XDisplayName( - _Xconst char* /* string */ -); -extern char *XKeysymToString( - KeySym /* keysym */ -); - -extern int (*XSynchronize( - Display* /* display */, - Bool /* onoff */ -))( - Display* /* display */ -); -extern int (*XSetAfterFunction( - Display* /* display */, - int (*) ( - Display* /* display */ - ) /* procedure */ -))( - Display* /* display */ -); -extern Atom XInternAtom( - Display* /* display */, - _Xconst char* /* atom_name */, - Bool /* only_if_exists */ -); -extern Status XInternAtoms( - Display* /* dpy */, - char** /* names */, - int /* count */, - Bool /* onlyIfExists */, - Atom* /* atoms_return */ -); -extern Colormap XCopyColormapAndFree( - Display* /* display */, - Colormap /* colormap */ -); -extern Colormap XCreateColormap( - Display* /* display */, - Window /* w */, - Visual* /* visual */, - int /* alloc */ -); -extern Cursor XCreatePixmapCursor( - Display* /* display */, - Pixmap /* source */, - Pixmap /* mask */, - XColor* /* foreground_color */, - XColor* /* background_color */, - unsigned int /* x */, - unsigned int /* y */ -); -extern Cursor XCreateGlyphCursor( - Display* /* display */, - Font /* source_font */, - Font /* mask_font */, - unsigned int /* source_char */, - unsigned int /* mask_char */, - XColor _Xconst * /* foreground_color */, - XColor _Xconst * /* background_color */ -); -extern Cursor XCreateFontCursor( - Display* /* display */, - unsigned int /* shape */ -); -extern Font XLoadFont( - Display* /* display */, - _Xconst char* /* name */ -); -extern GC XCreateGC( - Display* /* display */, - Drawable /* d */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); -extern GContext XGContextFromGC( - GC /* gc */ -); -extern void XFlushGC( - Display* /* display */, - GC /* gc */ -); -extern Pixmap XCreatePixmap( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* depth */ -); -extern Pixmap XCreateBitmapFromData( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* data */, - unsigned int /* width */, - unsigned int /* height */ -); -extern Pixmap XCreatePixmapFromBitmapData( - Display* /* display */, - Drawable /* d */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* fg */, - unsigned long /* bg */, - unsigned int /* depth */ -); -extern Window XCreateSimpleWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - unsigned long /* border */, - unsigned long /* background */ -); -extern Window XGetSelectionOwner( - Display* /* display */, - Atom /* selection */ -); -extern Window XCreateWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - int /* depth */, - unsigned int /* class */, - Visual* /* visual */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); -extern Colormap *XListInstalledColormaps( - Display* /* display */, - Window /* w */, - int* /* num_return */ -); -extern char **XListFonts( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* actual_count_return */ -); -extern char **XListFontsWithInfo( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* count_return */, - XFontStruct** /* info_return */ -); -extern char **XGetFontPath( - Display* /* display */, - int* /* npaths_return */ -); -extern char **XListExtensions( - Display* /* display */, - int* /* nextensions_return */ -); -extern Atom *XListProperties( - Display* /* display */, - Window /* w */, - int* /* num_prop_return */ -); -extern XHostAddress *XListHosts( - Display* /* display */, - int* /* nhosts_return */, - Bool* /* state_return */ -); -extern KeySym XKeycodeToKeysym( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* keycode */, -#else - KeyCode /* keycode */, -#endif - int /* index */ -); -extern KeySym XLookupKeysym( - XKeyEvent* /* key_event */, - int /* index */ -); -extern KeySym *XGetKeyboardMapping( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* first_keycode */, -#else - KeyCode /* first_keycode */, -#endif - int /* keycode_count */, - int* /* keysyms_per_keycode_return */ -); -extern KeySym XStringToKeysym( - _Xconst char* /* string */ -); -extern long XMaxRequestSize( - Display* /* display */ -); -extern long XExtendedMaxRequestSize( - Display* /* display */ -); -extern char *XResourceManagerString( - Display* /* display */ -); -extern char *XScreenResourceString( - Screen* /* screen */ -); -extern unsigned long XDisplayMotionBufferSize( - Display* /* display */ -); -extern VisualID XVisualIDFromVisual( - Visual* /* visual */ -); - -/* multithread routines */ - -extern Status XInitThreads( - void -); - -extern void XLockDisplay( - Display* /* display */ -); - -extern void XUnlockDisplay( - Display* /* display */ -); - -/* routines for dealing with extensions */ - -extern XExtCodes *XInitExtension( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XExtCodes *XAddExtension( - Display* /* display */ -); -extern XExtData *XFindOnExtensionList( - XExtData** /* structure */, - int /* number */ -); -extern XExtData **XEHeadOfExtensionList( - XEDataObject /* object */ -); - -/* these are routines for which there are also macros */ -extern Window XRootWindow( - Display* /* display */, - int /* screen_number */ -); -extern Window XDefaultRootWindow( - Display* /* display */ -); -extern Window XRootWindowOfScreen( - Screen* /* screen */ -); -extern Visual *XDefaultVisual( - Display* /* display */, - int /* screen_number */ -); -extern Visual *XDefaultVisualOfScreen( - Screen* /* screen */ -); -extern GC XDefaultGC( - Display* /* display */, - int /* screen_number */ -); -extern GC XDefaultGCOfScreen( - Screen* /* screen */ -); -extern unsigned long XBlackPixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XWhitePixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XAllPlanes( - void -); -extern unsigned long XBlackPixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XWhitePixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XNextRequest( - Display* /* display */ -); -extern unsigned long XLastKnownRequestProcessed( - Display* /* display */ -); -extern char *XServerVendor( - Display* /* display */ -); -extern char *XDisplayString( - Display* /* display */ -); -extern Colormap XDefaultColormap( - Display* /* display */, - int /* screen_number */ -); -extern Colormap XDefaultColormapOfScreen( - Screen* /* screen */ -); -extern Display *XDisplayOfScreen( - Screen* /* screen */ -); -extern Screen *XScreenOfDisplay( - Display* /* display */, - int /* screen_number */ -); -extern Screen *XDefaultScreenOfDisplay( - Display* /* display */ -); -extern long XEventMaskOfScreen( - Screen* /* screen */ -); - -extern int XScreenNumberOfScreen( - Screen* /* screen */ -); - -typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */, - XErrorEvent* /* error_event */ -); - -extern XErrorHandler XSetErrorHandler ( - XErrorHandler /* handler */ -); - - -typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */ -); - -extern XIOErrorHandler XSetIOErrorHandler ( - XIOErrorHandler /* handler */ -); - - -extern XPixmapFormatValues *XListPixmapFormats( - Display* /* display */, - int* /* count_return */ -); -extern int *XListDepths( - Display* /* display */, - int /* screen_number */, - int* /* count_return */ -); - -/* ICCCM routines for things that don't require special include files; */ -/* other declarations are given in Xutil.h */ -extern Status XReconfigureWMWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */, - unsigned int /* mask */, - XWindowChanges* /* changes */ -); - -extern Status XGetWMProtocols( - Display* /* display */, - Window /* w */, - Atom** /* protocols_return */, - int* /* count_return */ -); -extern Status XSetWMProtocols( - Display* /* display */, - Window /* w */, - Atom* /* protocols */, - int /* count */ -); -extern Status XIconifyWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XWithdrawWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XGetCommand( - Display* /* display */, - Window /* w */, - char*** /* argv_return */, - int* /* argc_return */ -); -extern Status XGetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window** /* windows_return */, - int* /* count_return */ -); -extern Status XSetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window* /* colormap_windows */, - int /* count */ -); -extern void XFreeStringList( - char** /* list */ -); -extern int XSetTransientForHint( - Display* /* display */, - Window /* w */, - Window /* prop_window */ -); - -/* The following are given in alphabetical order */ - -extern int XActivateScreenSaver( - Display* /* display */ -); - -extern int XAddHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XAddHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XAddToExtensionList( - struct _XExtData** /* structure */, - XExtData* /* ext_data */ -); - -extern int XAddToSaveSet( - Display* /* display */, - Window /* w */ -); - -extern Status XAllocColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* screen_in_out */ -); - -extern Status XAllocColorCells( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* plane_masks_return */, - unsigned int /* nplanes */, - unsigned long* /* pixels_return */, - unsigned int /* npixels */ -); - -extern Status XAllocColorPlanes( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* pixels_return */, - int /* ncolors */, - int /* nreds */, - int /* ngreens */, - int /* nblues */, - unsigned long* /* rmask_return */, - unsigned long* /* gmask_return */, - unsigned long* /* bmask_return */ -); - -extern Status XAllocNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* screen_def_return */, - XColor* /* exact_def_return */ -); - -extern int XAllowEvents( - Display* /* display */, - int /* event_mode */, - Time /* time */ -); - -extern int XAutoRepeatOff( - Display* /* display */ -); - -extern int XAutoRepeatOn( - Display* /* display */ -); - -extern int XBell( - Display* /* display */, - int /* percent */ -); - -extern int XBitmapBitOrder( - Display* /* display */ -); - -extern int XBitmapPad( - Display* /* display */ -); - -extern int XBitmapUnit( - Display* /* display */ -); - -extern int XCellsOfScreen( - Screen* /* screen */ -); - -extern int XChangeActivePointerGrab( - Display* /* display */, - unsigned int /* event_mask */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XChangeGC( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); - -extern int XChangeKeyboardControl( - Display* /* display */, - unsigned long /* value_mask */, - XKeyboardControl* /* values */ -); - -extern int XChangeKeyboardMapping( - Display* /* display */, - int /* first_keycode */, - int /* keysyms_per_keycode */, - KeySym* /* keysyms */, - int /* num_codes */ -); - -extern int XChangePointerControl( - Display* /* display */, - Bool /* do_accel */, - Bool /* do_threshold */, - int /* accel_numerator */, - int /* accel_denominator */, - int /* threshold */ -); - -extern int XChangeProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - Atom /* type */, - int /* format */, - int /* mode */, - _Xconst unsigned char* /* data */, - int /* nelements */ -); - -extern int XChangeSaveSet( - Display* /* display */, - Window /* w */, - int /* change_mode */ -); - -extern int XChangeWindowAttributes( - Display* /* display */, - Window /* w */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); - -extern Bool XCheckIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -#ifdef NX_TRANS_SOCKET - -/* - * This is just like XCheckIfEvent() but doesn't - * flush the output buffer if it can't read new - * events. - */ - -extern Bool XCheckIfEventNoFlush( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -#endif - -extern Bool XCheckMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedEvent( - Display* /* display */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedWindowEvent( - Display* /* display */, - Window /* w */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XCirculateSubwindows( - Display* /* display */, - Window /* w */, - int /* direction */ -); - -extern int XCirculateSubwindowsDown( - Display* /* display */, - Window /* w */ -); - -extern int XCirculateSubwindowsUp( - Display* /* display */, - Window /* w */ -); - -extern int XClearArea( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - Bool /* exposures */ -); - -extern int XClearWindow( - Display* /* display */, - Window /* w */ -); - -extern int XCloseDisplay( - Display* /* display */ -); - -extern int XConfigureWindow( - Display* /* display */, - Window /* w */, - unsigned int /* value_mask */, - XWindowChanges* /* values */ -); - -extern int XConnectionNumber( - Display* /* display */ -); - -extern int XConvertSelection( - Display* /* display */, - Atom /* selection */, - Atom /* target */, - Atom /* property */, - Window /* requestor */, - Time /* time */ -); - -extern int XCopyArea( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XCopyGC( - Display* /* display */, - GC /* src */, - unsigned long /* valuemask */, - GC /* dest */ -); - -extern int XCopyPlane( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */, - unsigned long /* plane */ -); - -extern int XDefaultDepth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDefaultDepthOfScreen( - Screen* /* screen */ -); - -extern int XDefaultScreen( - Display* /* display */ -); - -extern int XDefineCursor( - Display* /* display */, - Window /* w */, - Cursor /* cursor */ -); - -extern int XDeleteProperty( - Display* /* display */, - Window /* w */, - Atom /* property */ -); - -extern int XDestroyWindow( - Display* /* display */, - Window /* w */ -); - -extern int XDestroySubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XDoesBackingStore( - Screen* /* screen */ -); - -extern Bool XDoesSaveUnders( - Screen* /* screen */ -); - -extern int XDisableAccessControl( - Display* /* display */ -); - - -extern int XDisplayCells( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeight( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeightMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayKeycodes( - Display* /* display */, - int* /* min_keycodes_return */, - int* /* max_keycodes_return */ -); - -extern int XDisplayPlanes( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidthMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDrawArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XDrawArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XDrawImageString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawImageString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawLine( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x1 */, - int /* y1 */, - int /* x2 */, - int /* y2 */ -); - -extern int XDrawLines( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawPoint( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */ -); - -extern int XDrawPoints( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XDrawRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XDrawSegments( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XSegment* /* segments */, - int /* nsegments */ -); - -extern int XDrawString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem* /* items */, - int /* nitems */ -); - -extern int XDrawText16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem16* /* items */, - int /* nitems */ -); - -extern int XEnableAccessControl( - Display* /* display */ -); - -extern int XEventsQueued( - Display* /* display */, - int /* mode */ -); - -extern Status XFetchName( - Display* /* display */, - Window /* w */, - char** /* window_name_return */ -); - -extern int XFillArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XFillArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XFillPolygon( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* shape */, - int /* mode */ -); - -extern int XFillRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XFillRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XFlush( - Display* /* display */ -); - -extern int XForceScreenSaver( - Display* /* display */, - int /* mode */ -); - -extern int XFree( - void* /* data */ -); - -extern int XFreeColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XFreeColors( - Display* /* display */, - Colormap /* colormap */, - unsigned long* /* pixels */, - int /* npixels */, - unsigned long /* planes */ -); - -extern int XFreeCursor( - Display* /* display */, - Cursor /* cursor */ -); - -extern int XFreeExtensionList( - char** /* list */ -); - -extern int XFreeFont( - Display* /* display */, - XFontStruct* /* font_struct */ -); - -extern int XFreeFontInfo( - char** /* names */, - XFontStruct* /* free_info */, - int /* actual_count */ -); - -extern int XFreeFontNames( - char** /* list */ -); - -extern int XFreeFontPath( - char** /* list */ -); - -extern int XFreeGC( - Display* /* display */, - GC /* gc */ -); - -extern int XFreeModifiermap( - XModifierKeymap* /* modmap */ -); - -extern int XFreePixmap( - Display* /* display */, - Pixmap /* pixmap */ -); - -extern int XGeometry( - Display* /* display */, - int /* screen */, - _Xconst char* /* position */, - _Xconst char* /* default_position */, - unsigned int /* bwidth */, - unsigned int /* fwidth */, - unsigned int /* fheight */, - int /* xadder */, - int /* yadder */, - int* /* x_return */, - int* /* y_return */, - int* /* width_return */, - int* /* height_return */ -); - -extern int XGetErrorDatabaseText( - Display* /* display */, - _Xconst char* /* name */, - _Xconst char* /* message */, - _Xconst char* /* default_string */, - char* /* buffer_return */, - int /* length */ -); - -extern int XGetErrorText( - Display* /* display */, - int /* code */, - char* /* buffer_return */, - int /* length */ -); - -extern Bool XGetFontProperty( - XFontStruct* /* font_struct */, - Atom /* atom */, - unsigned long* /* value_return */ -); - -extern Status XGetGCValues( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values_return */ -); - -extern Status XGetGeometry( - Display* /* display */, - Drawable /* d */, - Window* /* root_return */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned int* /* border_width_return */, - unsigned int* /* depth_return */ -); - -extern Status XGetIconName( - Display* /* display */, - Window /* w */, - char** /* icon_name_return */ -); - -extern int XGetInputFocus( - Display* /* display */, - Window* /* focus_return */, - int* /* revert_to_return */ -); - -extern int XGetKeyboardControl( - Display* /* display */, - XKeyboardState* /* values_return */ -); - -extern int XGetPointerControl( - Display* /* display */, - int* /* accel_numerator_return */, - int* /* accel_denominator_return */, - int* /* threshold_return */ -); - -extern int XGetPointerMapping( - Display* /* display */, - unsigned char* /* map_return */, - int /* nmap */ -); - -extern int XGetScreenSaver( - Display* /* display */, - int* /* timeout_return */, - int* /* interval_return */, - int* /* prefer_blanking_return */, - int* /* allow_exposures_return */ -); - -extern Status XGetTransientForHint( - Display* /* display */, - Window /* w */, - Window* /* prop_window_return */ -); - -extern int XGetWindowProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - long /* long_offset */, - long /* long_length */, - Bool /* delete */, - Atom /* req_type */, - Atom* /* actual_type_return */, - int* /* actual_format_return */, - unsigned long* /* nitems_return */, - unsigned long* /* bytes_after_return */, - unsigned char** /* prop_return */ -); - -extern Status XGetWindowAttributes( - Display* /* display */, - Window /* w */, - XWindowAttributes* /* window_attributes_return */ -); - -extern int XGrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */ -); - -extern int XGrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */ -); - -extern int XGrabKeyboard( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */, - Time /* time */ -); - -extern int XGrabPointer( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XGrabServer( - Display* /* display */ -); - -extern int XHeightMMOfScreen( - Screen* /* screen */ -); - -extern int XHeightOfScreen( - Screen* /* screen */ -); - -extern int XIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XImageByteOrder( - Display* /* display */ -); - -extern int XInstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern KeyCode XKeysymToKeycode( - Display* /* display */, - KeySym /* keysym */ -); - -extern int XKillClient( - Display* /* display */, - XID /* resource */ -); - -extern Status XLookupColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* exact_def_return */, - XColor* /* screen_def_return */ -); - -extern int XLowerWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMapRaised( - Display* /* display */, - Window /* w */ -); - -extern int XMapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XMapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XMaxCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMinCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMoveResizeWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XMoveWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */ -); - -extern int XNextEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XNoOp( - Display* /* display */ -); - -extern Status XParseColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* spec */, - XColor* /* exact_def_return */ -); - -extern int XParseGeometry( - _Xconst char* /* parsestring */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XPeekEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XPeekIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XPending( - Display* /* display */ -); - -extern int XPlanesOfScreen( - Screen* /* screen */ -); - -extern int XProtocolRevision( - Display* /* display */ -); - -extern int XProtocolVersion( - Display* /* display */ -); - - -extern int XPutBackEvent( - Display* /* display */, - XEvent* /* event */ -); - -extern int XPutImage( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XImage* /* image */, - int /* src_x */, - int /* src_y */, - int /* dest_x */, - int /* dest_y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XQLength( - Display* /* display */ -); - -extern Status XQueryBestCursor( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestSize( - Display* /* display */, - int /* class */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestStipple( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestTile( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XQueryColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* def_in_out */ -); - -extern int XQueryColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* defs_in_out */, - int /* ncolors */ -); - -extern Bool XQueryExtension( - Display* /* display */, - _Xconst char* /* name */, - int* /* major_opcode_return */, - int* /* first_event_return */, - int* /* first_error_return */ -); - -extern int XQueryKeymap( - Display* /* display */, - char [32] /* keys_return */ -); - -extern Bool XQueryPointer( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* child_return */, - int* /* root_x_return */, - int* /* root_y_return */, - int* /* win_x_return */, - int* /* win_y_return */, - unsigned int* /* mask_return */ -); - -extern int XQueryTextExtents( - Display* /* display */, - XID /* font_ID */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XQueryTextExtents16( - Display* /* display */, - XID /* font_ID */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern Status XQueryTree( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* parent_return */, - Window** /* children_return */, - unsigned int* /* nchildren_return */ -); - -extern int XRaiseWindow( - Display* /* display */, - Window /* w */ -); - -extern int XReadBitmapFile( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - Pixmap* /* bitmap_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XReadBitmapFileData( - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned char** /* data_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XRebindKeysym( - Display* /* display */, - KeySym /* keysym */, - KeySym* /* list */, - int /* mod_count */, - _Xconst unsigned char* /* string */, - int /* bytes_string */ -); - -extern int XRecolorCursor( - Display* /* display */, - Cursor /* cursor */, - XColor* /* foreground_color */, - XColor* /* background_color */ -); - -extern int XRefreshKeyboardMapping( - XMappingEvent* /* event_map */ -); - -extern int XRemoveFromSaveSet( - Display* /* display */, - Window /* w */ -); - -extern int XRemoveHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XRemoveHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XReparentWindow( - Display* /* display */, - Window /* w */, - Window /* parent */, - int /* x */, - int /* y */ -); - -extern int XResetScreenSaver( - Display* /* display */ -); - -extern int XResizeWindow( - Display* /* display */, - Window /* w */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XRestackWindows( - Display* /* display */, - Window* /* windows */, - int /* nwindows */ -); - -extern int XRotateBuffers( - Display* /* display */, - int /* rotate */ -); - -extern int XRotateWindowProperties( - Display* /* display */, - Window /* w */, - Atom* /* properties */, - int /* num_prop */, - int /* npositions */ -); - -extern int XScreenCount( - Display* /* display */ -); - -extern int XSelectInput( - Display* /* display */, - Window /* w */, - long /* event_mask */ -); - -extern Status XSendEvent( - Display* /* display */, - Window /* w */, - Bool /* propagate */, - long /* event_mask */, - XEvent* /* event_send */ -); - -extern int XSetAccessControl( - Display* /* display */, - int /* mode */ -); - -extern int XSetArcMode( - Display* /* display */, - GC /* gc */, - int /* arc_mode */ -); - -extern int XSetBackground( - Display* /* display */, - GC /* gc */, - unsigned long /* background */ -); - -extern int XSetClipMask( - Display* /* display */, - GC /* gc */, - Pixmap /* pixmap */ -); - -extern int XSetClipOrigin( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */ -); - -extern int XSetClipRectangles( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */, - XRectangle* /* rectangles */, - int /* n */, - int /* ordering */ -); - -extern int XSetCloseDownMode( - Display* /* display */, - int /* close_mode */ -); - -extern int XSetCommand( - Display* /* display */, - Window /* w */, - char** /* argv */, - int /* argc */ -); - -extern int XSetDashes( - Display* /* display */, - GC /* gc */, - int /* dash_offset */, - _Xconst char* /* dash_list */, - int /* n */ -); - -extern int XSetFillRule( - Display* /* display */, - GC /* gc */, - int /* fill_rule */ -); - -extern int XSetFillStyle( - Display* /* display */, - GC /* gc */, - int /* fill_style */ -); - -extern int XSetFont( - Display* /* display */, - GC /* gc */, - Font /* font */ -); - -extern int XSetFontPath( - Display* /* display */, - char** /* directories */, - int /* ndirs */ -); - -extern int XSetForeground( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */ -); - -extern int XSetFunction( - Display* /* display */, - GC /* gc */, - int /* function */ -); - -extern int XSetGraphicsExposures( - Display* /* display */, - GC /* gc */, - Bool /* graphics_exposures */ -); - -extern int XSetIconName( - Display* /* display */, - Window /* w */, - _Xconst char* /* icon_name */ -); - -extern int XSetInputFocus( - Display* /* display */, - Window /* focus */, - int /* revert_to */, - Time /* time */ -); - -extern int XSetLineAttributes( - Display* /* display */, - GC /* gc */, - unsigned int /* line_width */, - int /* line_style */, - int /* cap_style */, - int /* join_style */ -); - -extern int XSetModifierMapping( - Display* /* display */, - XModifierKeymap* /* modmap */ -); - -extern int XSetPlaneMask( - Display* /* display */, - GC /* gc */, - unsigned long /* plane_mask */ -); - -extern int XSetPointerMapping( - Display* /* display */, - _Xconst unsigned char* /* map */, - int /* nmap */ -); - -extern int XSetScreenSaver( - Display* /* display */, - int /* timeout */, - int /* interval */, - int /* prefer_blanking */, - int /* allow_exposures */ -); - -extern int XSetSelectionOwner( - Display* /* display */, - Atom /* selection */, - Window /* owner */, - Time /* time */ -); - -extern int XSetState( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */, - unsigned long /* background */, - int /* function */, - unsigned long /* plane_mask */ -); - -extern int XSetStipple( - Display* /* display */, - GC /* gc */, - Pixmap /* stipple */ -); - -extern int XSetSubwindowMode( - Display* /* display */, - GC /* gc */, - int /* subwindow_mode */ -); - -extern int XSetTSOrigin( - Display* /* display */, - GC /* gc */, - int /* ts_x_origin */, - int /* ts_y_origin */ -); - -extern int XSetTile( - Display* /* display */, - GC /* gc */, - Pixmap /* tile */ -); - -extern int XSetWindowBackground( - Display* /* display */, - Window /* w */, - unsigned long /* background_pixel */ -); - -extern int XSetWindowBackgroundPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* background_pixmap */ -); - -extern int XSetWindowBorder( - Display* /* display */, - Window /* w */, - unsigned long /* border_pixel */ -); - -extern int XSetWindowBorderPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* border_pixmap */ -); - -extern int XSetWindowBorderWidth( - Display* /* display */, - Window /* w */, - unsigned int /* width */ -); - -extern int XSetWindowColormap( - Display* /* display */, - Window /* w */, - Colormap /* colormap */ -); - -extern int XStoreBuffer( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */, - int /* buffer */ -); - -extern int XStoreBytes( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */ -); - -extern int XStoreColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */ -); - -extern int XStoreColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */, - int /* ncolors */ -); - -extern int XStoreName( - Display* /* display */, - Window /* w */, - _Xconst char* /* window_name */ -); - -extern int XStoreNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color */, - unsigned long /* pixel */, - int /* flags */ -); - -extern int XSync( - Display* /* display */, - Bool /* discard */ -); - -extern int XTextExtents( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextExtents16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextWidth( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int XTextWidth16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -extern Bool XTranslateCoordinates( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - int* /* dest_x_return */, - int* /* dest_y_return */, - Window* /* child_return */ -); - -extern int XUndefineCursor( - Display* /* display */, - Window /* w */ -); - -extern int XUngrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKeyboard( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabPointer( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabServer( - Display* /* display */ -); - -extern int XUninstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XUnloadFont( - Display* /* display */, - Font /* font */ -); - -extern int XUnmapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XUnmapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XVendorRelease( - Display* /* display */ -); - -extern int XWarpPointer( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - unsigned int /* src_width */, - unsigned int /* src_height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XWidthMMOfScreen( - Screen* /* screen */ -); - -extern int XWidthOfScreen( - Screen* /* screen */ -); - -extern int XWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XWriteBitmapFile( - Display* /* display */, - _Xconst char* /* filename */, - Pixmap /* bitmap */, - unsigned int /* width */, - unsigned int /* height */, - int /* x_hot */, - int /* y_hot */ -); - -extern Bool XSupportsLocale (void); - -extern char *XSetLocaleModifiers( - const char* /* modifier_list */ -); - -extern XOM XOpenOM( - Display* /* display */, - struct _XrmHashBucketRec* /* rdb */, - _Xconst char* /* res_name */, - _Xconst char* /* res_class */ -); - -extern Status XCloseOM( - XOM /* om */ -); - -extern char *XSetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern char *XGetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfOM( - XOM /* om */ -); - -extern char *XLocaleOfOM( - XOM /* om */ -); - -extern XOC XCreateOC( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern void XDestroyOC( - XOC /* oc */ -); - -extern XOM XOMOfOC( - XOC /* oc */ -); - -extern char *XSetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern char *XGetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern XFontSet XCreateFontSet( - Display* /* display */, - _Xconst char* /* base_font_name_list */, - char*** /* missing_charset_list */, - int* /* missing_charset_count */, - char** /* def_string */ -); - -extern void XFreeFontSet( - Display* /* display */, - XFontSet /* font_set */ -); - -extern int XFontsOfFontSet( - XFontSet /* font_set */, - XFontStruct*** /* font_struct_list */, - char*** /* font_name_list */ -); - -extern char *XBaseFontNameListOfFontSet( - XFontSet /* font_set */ -); - -extern char *XLocaleOfFontSet( - XFontSet /* font_set */ -); - -extern Bool XContextDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XDirectionalDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XContextualDrawing( - XFontSet /* font_set */ -); - -extern XFontSetExtents *XExtentsOfFontSet( - XFontSet /* font_set */ -); - -extern int XmbTextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XwcTextEscapement( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern int Xutf8TextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XmbTextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int XwcTextExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int Xutf8TextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XmbTextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XwcTextPerCharExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status Xutf8TextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern void XmbDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XwcDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XwcTextItem* /* text_items */, - int /* nitems */ -); - -extern void Xutf8DrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XmbDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XmbDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern XIM XOpenIM( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */ -); - -extern Status XCloseIM( - XIM /* im */ -); - -extern char *XGetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern char *XSetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfIM( - XIM /* im */ -); - -extern char *XLocaleOfIM( - XIM /* im*/ -); - -extern XIC XCreateIC( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern void XDestroyIC( - XIC /* ic */ -); - -extern void XSetICFocus( - XIC /* ic */ -); - -extern void XUnsetICFocus( - XIC /* ic */ -); - -extern wchar_t *XwcResetIC( - XIC /* ic */ -); - -extern char *XmbResetIC( - XIC /* ic */ -); - -extern char *Xutf8ResetIC( - XIC /* ic */ -); - -extern char *XSetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern char *XGetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern XIM XIMOfIC( - XIC /* ic */ -); - -extern Bool XFilterEvent( - XEvent* /* event */, - Window /* window */ -); - -extern int XmbLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int XwcLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - wchar_t* /* buffer_return */, - int /* wchars_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int Xutf8LookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern XVaNestedList XVaCreateNestedList( - int /*unused*/, ... -) _X_SENTINEL(0); - -/* internal connections for IMs */ - -extern Bool XRegisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -extern Bool XUnregisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -typedef void (*XConnectionWatchProc)( - Display* /* dpy */, - XPointer /* client_data */, - int /* fd */, - Bool /* opening */, /* open or close flag */ - XPointer* /* watch_data */ /* open sets, close uses */ -); - - -extern Status XInternalConnectionNumbers( - Display* /* dpy */, - int** /* fd_return */, - int* /* count_return */ -); - -extern void XProcessInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -extern Status XAddConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XRemoveConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XSetAuthorization( - char * /* name */, - int /* namelen */, - char * /* data */, - int /* datalen */ -); - -extern int _Xmbtowc( - wchar_t * /* wstr */, -#ifdef ISC - char const * /* str */, - size_t /* len */ -#else - char * /* str */, - int /* len */ -#endif -); - -extern int _Xwctomb( - char * /* str */, - wchar_t /* wc */ -); - -_XFUNCPROTOEND - -#endif /* _XLIB_H_ */ diff --git a/nx-X11/lib/X11/Xlib.h.X.original b/nx-X11/lib/X11/Xlib.h.X.original deleted file mode 100644 index b1535f9b1..000000000 --- a/nx-X11/lib/X11/Xlib.h.X.original +++ /dev/null @@ -1,4008 +0,0 @@ -/* $XdotOrg: xc/lib/X11/Xlib.h,v 1.6 2005/11/08 06:33:25 jkj Exp $ */ -/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -Copyright 1985, 1986, 1987, 1991, 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. - -*/ -/* $XFree86: xc/lib/X11/Xlib.h,v 3.25 2003/11/17 22:20:10 dawes Exp $ */ - - -/* - * Xlib.h - Header definition and support file for the C subroutine - * interface library (Xlib) to the X Window System Protocol (V11). - * Structures and symbols starting with "_" are private to the library. - */ -#ifndef _XLIB_H_ -#define _XLIB_H_ - -#define XlibSpecificationRelease 6 - -#ifdef USG -#ifndef __TYPES__ -#include <sys/types.h> /* forgot to protect it... */ -#define __TYPES__ -#endif /* __TYPES__ */ -#else -#if defined(_POSIX_SOURCE) && defined(MOTOROLA) -#undef _POSIX_SOURCE -#include <sys/types.h> -#define _POSIX_SOURCE -#else -#include <sys/types.h> -#endif -#endif /* USG */ - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <stdint.h> -#endif - -#include <X11/X.h> - -/* applications should not depend on these two headers being included! */ -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> - -#ifndef X_WCHAR -#ifdef X_NOT_STDC_ENV -#ifndef ISC -#define X_WCHAR -#endif -#endif -#endif - -#ifndef X_WCHAR -#include <stddef.h> -#else -#ifdef __UNIXOS2__ -#include <stdlib.h> -#else -/* replace this with #include or typedef appropriate for your system */ -typedef unsigned long wchar_t; -#endif -#endif - -#if defined(ISC) && defined(USE_XMBTOWC) -#define wctomb(a,b) _Xwctomb(a,b) -#define mblen(a,b) _Xmblen(a,b) -#ifndef USE_XWCHAR_STRING -#define mbtowc(a,b,c) _Xmbtowc(a,b,c) -#endif -#endif - -extern int -_Xmblen( -#ifdef ISC - char const *str, - size_t len -#else - char *str, - int len -#endif - ); - -/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in - November 2000. Its presence is indicated through the following macro. */ -#define X_HAVE_UTF8_STRING 1 - -typedef char *XPointer; - -#define Bool int -#define Status int -#define True 1 -#define False 0 - -#define QueuedAlready 0 -#define QueuedAfterReading 1 -#define QueuedAfterFlush 2 - -#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) -#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) -#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) -#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) -#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) -#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) -#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) -#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) -#define AllPlanes ((unsigned long)~0L) -#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) -#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) -#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) -#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) -#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) -#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) -#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) -#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) -#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) -#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) -#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) -#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) -#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) -#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) -#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) -#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) -#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) -#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) -#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ -#define NextRequest(dpy) XNextRequest(dpy) -#else -#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) -#endif -#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) - -/* macros for screen oriented applications (toolkit) */ -#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) -#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) -#define DisplayOfScreen(s) ((s)->display) -#define RootWindowOfScreen(s) ((s)->root) -#define BlackPixelOfScreen(s) ((s)->black_pixel) -#define WhitePixelOfScreen(s) ((s)->white_pixel) -#define DefaultColormapOfScreen(s)((s)->cmap) -#define DefaultDepthOfScreen(s) ((s)->root_depth) -#define DefaultGCOfScreen(s) ((s)->default_gc) -#define DefaultVisualOfScreen(s)((s)->root_visual) -#define WidthOfScreen(s) ((s)->width) -#define HeightOfScreen(s) ((s)->height) -#define WidthMMOfScreen(s) ((s)->mwidth) -#define HeightMMOfScreen(s) ((s)->mheight) -#define PlanesOfScreen(s) ((s)->root_depth) -#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) -#define MinCmapsOfScreen(s) ((s)->min_maps) -#define MaxCmapsOfScreen(s) ((s)->max_maps) -#define DoesSaveUnders(s) ((s)->save_unders) -#define DoesBackingStore(s) ((s)->backing_store) -#define EventMaskOfScreen(s) ((s)->root_input_mask) - -/* - * Extensions need a way to hang private data on some structures. - */ -typedef struct _XExtData { - int number; /* number returned by XRegisterExtension */ - struct _XExtData *next; /* next item on list of data for structure */ - int (*free_private)( /* called to free private storage */ - struct _XExtData *extension - ); - XPointer private_data; /* data private to this extension. */ -} XExtData; - -/* - * This file contains structures used by the extension mechanism. - */ -typedef struct { /* public to extension, cannot be changed */ - int extension; /* extension number */ - int major_opcode; /* major op-code assigned by server */ - int first_event; /* first event number for the extension */ - int first_error; /* first error number for the extension */ -} XExtCodes; - -/* - * Data structure for retrieving info about pixmap formats. - */ - -typedef struct { - int depth; - int bits_per_pixel; - int scanline_pad; -} XPixmapFormatValues; - - -/* - * Data structure for setting graphics context. - */ -typedef struct { - int function; /* logical operation */ - unsigned long plane_mask;/* plane mask */ - unsigned long foreground;/* foreground pixel */ - unsigned long background;/* background pixel */ - int line_width; /* line width */ - int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ - int cap_style; /* CapNotLast, CapButt, - CapRound, CapProjecting */ - int join_style; /* JoinMiter, JoinRound, JoinBevel */ - int fill_style; /* FillSolid, FillTiled, - FillStippled, FillOpaeueStippled */ - int fill_rule; /* EvenOddRule, WindingRule */ - int arc_mode; /* ArcChord, ArcPieSlice */ - Pixmap tile; /* tile pixmap for tiling operations */ - Pixmap stipple; /* stipple 1 plane pixmap for stipping */ - int ts_x_origin; /* offset for tile or stipple operations */ - int ts_y_origin; - Font font; /* default text font for text operations */ - int subwindow_mode; /* ClipByChildren, IncludeInferiors */ - Bool graphics_exposures;/* boolean, should exposures be generated */ - int clip_x_origin; /* origin for clipping */ - int clip_y_origin; - Pixmap clip_mask; /* bitmap clipping; other calls for rects */ - int dash_offset; /* patterned/dashed line information */ - char dashes; -} XGCValues; - -/* - * Graphics context. The contents of this structure are implementation - * dependent. A GC should be treated as opaque by application code. - */ - -typedef struct _XGC -#ifdef XLIB_ILLEGAL_ACCESS -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - /* there is more to this structure, but it is private to Xlib */ -} -#endif -*GC; - -/* - * Visual structure; contains information about colormapping possible. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - VisualID visualid; /* visual id of this visual */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ class of screen (monochrome, etc.) */ -#else - int class; /* class of screen (monochrome, etc.) */ -#endif - unsigned long red_mask, green_mask, blue_mask; /* mask values */ - int bits_per_rgb; /* log base 2 of distinct color values */ - int map_entries; /* color map entries */ -} Visual; - -/* - * Depth structure; contains information for each possible depth. - */ -typedef struct { - int depth; /* this depth (Z) of the depth */ - int nvisuals; /* number of Visual types at this depth */ - Visual *visuals; /* list of visuals possible at this depth */ -} Depth; - -/* - * Information about the screen. The contents of this structure are - * implementation dependent. A Screen should be treated as opaque - * by application code. - */ - -struct _XDisplay; /* Forward declare before use for C++ */ - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - struct _XDisplay *display;/* back pointer to display structure */ - Window root; /* Root window id. */ - int width, height; /* width and height of screen */ - int mwidth, mheight; /* width and height of in millimeters */ - int ndepths; /* number of depths possible */ - Depth *depths; /* list of allowable depths on the screen */ - int root_depth; /* bits per pixel */ - Visual *root_visual; /* root visual */ - GC default_gc; /* GC for the root root visual */ - Colormap cmap; /* default color map */ - unsigned long white_pixel; - unsigned long black_pixel; /* White and Black pixel values */ - int max_maps, min_maps; /* max and min color maps */ - int backing_store; /* Never, WhenMapped, Always */ - Bool save_unders; - long root_input_mask; /* initial root input mask */ -} Screen; - -/* - * Format structure; describes ZFormat data the screen will understand. - */ -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - int depth; /* depth of this image format */ - int bits_per_pixel; /* bits/pixel at this depth */ - int scanline_pad; /* scanline must padded to this multiple */ -} ScreenFormat; - -/* - * Data structure for setting window attributes. - */ -typedef struct { - Pixmap background_pixmap; /* background or None or ParentRelative */ - unsigned long background_pixel; /* background pixel */ - Pixmap border_pixmap; /* border of the window */ - unsigned long border_pixel; /* border pixel value */ - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preseved if possible */ - unsigned long backing_pixel;/* value to use in restoring planes */ - Bool save_under; /* should bits under be saved? (popups) */ - long event_mask; /* set of events that should be saved */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Colormap colormap; /* color map to be associated with window */ - Cursor cursor; /* cursor to be displayed (or None) */ -} XSetWindowAttributes; - -typedef struct { - int x, y; /* location of window */ - int width, height; /* width and height of window */ - int border_width; /* border width of window */ - int depth; /* depth of window */ - Visual *visual; /* the associated visual structure */ - Window root; /* root of screen containing window */ -#if defined(__cplusplus) || defined(c_plusplus) - int c_class; /* C++ InputOutput, InputOnly*/ -#else - int class; /* InputOutput, InputOnly*/ -#endif - int bit_gravity; /* one of bit gravity values */ - int win_gravity; /* one of the window gravity values */ - int backing_store; /* NotUseful, WhenMapped, Always */ - unsigned long backing_planes;/* planes to be preserved if possible */ - unsigned long backing_pixel;/* value to be used when restoring planes */ - Bool save_under; /* boolean, should bits under be saved? */ - Colormap colormap; /* color map to be associated with window */ - Bool map_installed; /* boolean, is color map currently installed*/ - int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ - long all_event_masks; /* set of events all people have interest in*/ - long your_event_mask; /* my event mask */ - long do_not_propagate_mask; /* set of events that should not propagate */ - Bool override_redirect; /* boolean value for override-redirect */ - Screen *screen; /* back pointer to correct screen */ -} XWindowAttributes; - -/* - * Data structure for host setting; getting routines. - * - */ - -typedef struct { - int family; /* for example FamilyInternet */ - int length; /* length of address, in bytes */ - char *address; /* pointer to where to find the bytes */ -} XHostAddress; - -/* - * Data structure for ServerFamilyInterpreted addresses in host routines - */ -typedef struct { - int typelength; /* length of type string, in bytes */ - int valuelength; /* length of value string, in bytes */ - char *type; /* pointer to where to find the type string */ - char *value; /* pointer to where to find the address */ -} XServerInterpretedAddress; - -/* - * Data structure for "image" data, used by image manipulation routines. - */ -typedef struct _XImage { - int width, height; /* size of image */ - int xoffset; /* number of pixels offset in X direction */ - int format; /* XYBitmap, XYPixmap, ZPixmap */ - char *data; /* pointer to image data */ - int byte_order; /* data byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* quant. of scanline 8, 16, 32 */ - int bitmap_bit_order; /* LSBFirst, MSBFirst */ - int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ - int depth; /* depth of image */ - int bytes_per_line; /* accelarator to next line */ - int bits_per_pixel; /* bits per pixel (ZPixmap) */ - unsigned long red_mask; /* bits in z arrangment */ - unsigned long green_mask; - unsigned long blue_mask; - XPointer obdata; /* hook for the object routines to hang on */ - struct funcs { /* image manipulation routines */ - struct _XImage *(*create_image)( - struct _XDisplay* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */); - int (*destroy_image) (struct _XImage *); - unsigned long (*get_pixel) (struct _XImage *, int, int); - int (*put_pixel) (struct _XImage *, int, int, unsigned long); - struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); - int (*add_pixel) (struct _XImage *, long); - } f; -} XImage; - -/* - * Data structure for XReconfigureWindow - */ -typedef struct { - int x, y; - int width, height; - int border_width; - Window sibling; - int stack_mode; -} XWindowChanges; - -/* - * Data structure used by color operations - */ -typedef struct { - unsigned long pixel; - unsigned short red, green, blue; - char flags; /* do_red, do_green, do_blue */ - char pad; -} XColor; - -/* - * Data structures for graphics operations. On most machines, these are - * congruent with the wire protocol structures, so reformatting the data - * can be avoided on these architectures. - */ -typedef struct { - short x1, y1, x2, y2; -} XSegment; - -typedef struct { - short x, y; -} XPoint; - -typedef struct { - short x, y; - unsigned short width, height; -} XRectangle; - -typedef struct { - short x, y; - unsigned short width, height; - short angle1, angle2; -} XArc; - - -/* Data structure for XChangeKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - int bell_pitch; - int bell_duration; - int led; - int led_mode; - int key; - int auto_repeat_mode; /* On, Off, Default */ -} XKeyboardControl; - -/* Data structure for XGetKeyboardControl */ - -typedef struct { - int key_click_percent; - int bell_percent; - unsigned int bell_pitch, bell_duration; - unsigned long led_mask; - int global_auto_repeat; - char auto_repeats[32]; -} XKeyboardState; - -/* Data structure for XGetMotionEvents. */ - -typedef struct { - Time time; - short x, y; -} XTimeCoord; - -/* Data structure for X{Set,Get}ModifierMapping */ - -typedef struct { - int max_keypermod; /* The server's max # of keys per modifier */ - KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ -} XModifierKeymap; - - -/* - * Display datatype maintaining display specific data. - * The contents of this structure are implementation dependent. - * A Display should be treated as opaque by application code. - */ -#ifndef XLIB_ILLEGAL_ACCESS -typedef struct _XDisplay Display; -#endif - -struct _XPrivate; /* Forward declare before use for C++ */ -struct _XrmHashBucketRec; - -typedef struct -#ifdef XLIB_ILLEGAL_ACCESS -_XDisplay -#endif -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XPrivate *private1; - int fd; /* Network socket. */ - int private2; - int proto_major_version;/* major version of server's X protocol */ - int proto_minor_version;/* minor version of servers X protocol */ - char *vendor; /* vendor of the server hardware */ - XID private3; - XID private4; - XID private5; - int private6; - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int private8; - int release; /* release of the server */ - struct _XPrivate *private9, *private10; - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - XPointer private11; - XPointer private12; - XPointer private13; - XPointer private14; - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*private15)( - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long private16; - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - XPointer private17; - XPointer private18; - int private19; - char *xdefaults; /* contents of defaults from server */ - /* there is more to this structure, but it is private to Xlib */ -} -#ifdef XLIB_ILLEGAL_ACCESS -Display, -#endif -*_XPrivDisplay; - -#undef _XEVENT_ -#ifndef _XEVENT_ -/* - * Definitions of specific events. - */ -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int keycode; /* detail */ - Bool same_screen; /* same screen flag */ -} XKeyEvent; -typedef XKeyEvent XKeyPressedEvent; -typedef XKeyEvent XKeyReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window it is reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - unsigned int button; /* detail */ - Bool same_screen; /* same screen flag */ -} XButtonEvent; -typedef XButtonEvent XButtonPressedEvent; -typedef XButtonEvent XButtonReleasedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - unsigned int state; /* key or button mask */ - char is_hint; /* detail */ - Bool same_screen; /* same screen flag */ -} XMotionEvent; -typedef XMotionEvent XPointerMovedEvent; - -typedef struct { - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* "event" window reported relative to */ - Window root; /* root window that the event occurred on */ - Window subwindow; /* child window */ - Time time; /* milliseconds */ - int x, y; /* pointer x, y coordinates in event window */ - int x_root, y_root; /* coordinates relative to root */ - int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual - */ - Bool same_screen; /* same screen flag */ - Bool focus; /* boolean focus */ - unsigned int state; /* key or button mask */ -} XCrossingEvent; -typedef XCrossingEvent XEnterWindowEvent; -typedef XCrossingEvent XLeaveWindowEvent; - -typedef struct { - int type; /* FocusIn or FocusOut */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* window of event */ - int mode; /* NotifyNormal, NotifyWhileGrabbed, - NotifyGrab, NotifyUngrab */ - int detail; - /* - * NotifyAncestor, NotifyVirtual, NotifyInferior, - * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, - * NotifyPointerRoot, NotifyDetailNone - */ -} XFocusChangeEvent; -typedef XFocusChangeEvent XFocusInEvent; -typedef XFocusChangeEvent XFocusOutEvent; - -/* generated on EnterWindow and FocusIn when KeyMapState selected */ -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - char key_vector[32]; -} XKeymapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ -} XExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int x, y; - int width, height; - int count; /* if non-zero, at least this many more */ - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XGraphicsExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; - int major_code; /* core is CopyArea or CopyPlane */ - int minor_code; /* not defined in the core */ -} XNoExposeEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int state; /* Visibility state */ -} XVisibilityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; /* parent of the window */ - Window window; /* window id of window created */ - int x, y; /* window location */ - int width, height; /* size of window */ - int border_width; /* border width */ - Bool override_redirect; /* creation should be overridden */ -} XCreateWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; -} XDestroyWindowEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool from_configure; -} XUnmapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Bool override_redirect; /* boolean, is override set... */ -} XMapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; -} XMapRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - Window parent; - int x, y; - Bool override_redirect; -} XReparentEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - Bool override_redirect; -} XConfigureEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int x, y; -} XGravityEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - int width, height; -} XResizeRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int x, y; - int width, height; - int border_width; - Window above; - int detail; /* Above, Below, TopIf, BottomIf, Opposite */ - unsigned long value_mask; -} XConfigureRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window event; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window parent; - Window window; - int place; /* PlaceOnTop, PlaceOnBottom */ -} XCirculateRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom atom; - Time time; - int state; /* NewValue, Deleted */ -} XPropertyEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom selection; - Time time; -} XSelectionClearEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window owner; - Window requestor; - Atom selection; - Atom target; - Atom property; - Time time; -} XSelectionRequestEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window requestor; - Atom selection; - Atom target; - Atom property; /* ATOM or None */ - Time time; -} XSelectionEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Colormap colormap; /* COLORMAP or None */ -#if defined(__cplusplus) || defined(c_plusplus) - Bool c_new; /* C++ */ -#else - Bool new; -#endif - int state; /* ColormapInstalled, ColormapUninstalled */ -} XColormapEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; - Atom message_type; - int format; - union { - char b[20]; - short s[10]; - long l[5]; - } data; -} XClientMessageEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Window window; /* unused */ - int request; /* one of MappingModifier, MappingKeyboard, - MappingPointer */ - int first_keycode; /* first keycode */ - int count; /* defines range of change w. first_keycode*/ -} XMappingEvent; - -typedef struct { - int type; - Display *display; /* Display the event was read from */ - XID resourceid; /* resource id */ - unsigned long serial; /* serial number of failed request */ - unsigned char error_code; /* error code of failed request */ - unsigned char request_code; /* Major op-code of failed request */ - unsigned char minor_code; /* Minor op-code of failed request */ -} XErrorEvent; - -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display;/* Display the event was read from */ - Window window; /* window on which event was requested in event mask */ -} XAnyEvent; - -/* - * this union is defined so Xlib can always use the same sized - * event structure internally, to avoid memory fragmentation. - */ -typedef union _XEvent { - int type; /* must not be changed; first element */ - XAnyEvent xany; - XKeyEvent xkey; - XButtonEvent xbutton; - XMotionEvent xmotion; - XCrossingEvent xcrossing; - XFocusChangeEvent xfocus; - XExposeEvent xexpose; - XGraphicsExposeEvent xgraphicsexpose; - XNoExposeEvent xnoexpose; - XVisibilityEvent xvisibility; - XCreateWindowEvent xcreatewindow; - XDestroyWindowEvent xdestroywindow; - XUnmapEvent xunmap; - XMapEvent xmap; - XMapRequestEvent xmaprequest; - XReparentEvent xreparent; - XConfigureEvent xconfigure; - XGravityEvent xgravity; - XResizeRequestEvent xresizerequest; - XConfigureRequestEvent xconfigurerequest; - XCirculateEvent xcirculate; - XCirculateRequestEvent xcirculaterequest; - XPropertyEvent xproperty; - XSelectionClearEvent xselectionclear; - XSelectionRequestEvent xselectionrequest; - XSelectionEvent xselection; - XColormapEvent xcolormap; - XClientMessageEvent xclient; - XMappingEvent xmapping; - XErrorEvent xerror; - XKeymapEvent xkeymap; - long pad[24]; -} XEvent; -#endif - -#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) - -/* - * per character font metric information. - */ -typedef struct { - short lbearing; /* origin to left edge of raster */ - short rbearing; /* origin to right edge of raster */ - short width; /* advance to next char's origin */ - short ascent; /* baseline to top edge of raster */ - short descent; /* baseline to bottom edge of raster */ - unsigned short attributes; /* per char flags (not predefined) */ -} XCharStruct; - -/* - * To allow arbitrary information with fonts, there are additional properties - * returned. - */ -typedef struct { - Atom name; - unsigned long card32; -} XFontProp; - -typedef struct { - XExtData *ext_data; /* hook for extension to hang data */ - Font fid; /* Font id for this font */ - unsigned direction; /* hint about direction the font is painted */ - unsigned min_char_or_byte2;/* first character */ - unsigned max_char_or_byte2;/* last character */ - unsigned min_byte1; /* first row that exists */ - unsigned max_byte1; /* last row that exists */ - Bool all_chars_exist;/* flag if all characters have non-zero size*/ - unsigned default_char; /* char to print for undefined character */ - int n_properties; /* how many properties there are */ - XFontProp *properties; /* pointer to array of additional properties*/ - XCharStruct min_bounds; /* minimum bounds over all existing char*/ - XCharStruct max_bounds; /* maximum bounds over all existing char*/ - XCharStruct *per_char; /* first_char to last_char information */ - int ascent; /* log. extent above baseline for spacing */ - int descent; /* log. descent below baseline for spacing */ -} XFontStruct; - -/* - * PolyText routines take these as arguments. - */ -typedef struct { - char *chars; /* pointer to string */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem; - -typedef struct { /* normal 16 bit characters are two bytes */ - unsigned char byte1; - unsigned char byte2; -} XChar2b; - -typedef struct { - XChar2b *chars; /* two byte characters */ - int nchars; /* number of characters */ - int delta; /* delta between strings */ - Font font; /* font to print it in, None don't change */ -} XTextItem16; - - -typedef union { Display *display; - GC gc; - Visual *visual; - Screen *screen; - ScreenFormat *pixmap_format; - XFontStruct *font; } XEDataObject; - -typedef struct { - XRectangle max_ink_extent; - XRectangle max_logical_extent; -} XFontSetExtents; - -/* unused: -typedef void (*XOMProc)(); - */ - -typedef struct _XOM *XOM; -typedef struct _XOC *XOC, *XFontSet; - -typedef struct { - char *chars; - int nchars; - int delta; - XFontSet font_set; -} XmbTextItem; - -typedef struct { - wchar_t *chars; - int nchars; - int delta; - XFontSet font_set; -} XwcTextItem; - -#define XNRequiredCharSet "requiredCharSet" -#define XNQueryOrientation "queryOrientation" -#define XNBaseFontName "baseFontName" -#define XNOMAutomatic "omAutomatic" -#define XNMissingCharSet "missingCharSet" -#define XNDefaultString "defaultString" -#define XNOrientation "orientation" -#define XNDirectionalDependentDrawing "directionalDependentDrawing" -#define XNContextualDrawing "contextualDrawing" -#define XNFontInfo "fontInfo" - -typedef struct { - int charset_count; - char **charset_list; -} XOMCharSetList; - -typedef enum { - XOMOrientation_LTR_TTB, - XOMOrientation_RTL_TTB, - XOMOrientation_TTB_LTR, - XOMOrientation_TTB_RTL, - XOMOrientation_Context -} XOrientation; - -typedef struct { - int num_orientation; - XOrientation *orientation; /* Input Text description */ -} XOMOrientation; - -typedef struct { - int num_font; - XFontStruct **font_struct_list; - char **font_name_list; -} XOMFontInfo; - -typedef struct _XIM *XIM; -typedef struct _XIC *XIC; - -typedef void (*XIMProc)( - XIM, - XPointer, - XPointer -); - -typedef Bool (*XICProc)( - XIC, - XPointer, - XPointer -); - -typedef void (*XIDProc)( - Display*, - XPointer, - XPointer -); - -typedef unsigned long XIMStyle; - -typedef struct { - unsigned short count_styles; - XIMStyle *supported_styles; -} XIMStyles; - -#define XIMPreeditArea 0x0001L -#define XIMPreeditCallbacks 0x0002L -#define XIMPreeditPosition 0x0004L -#define XIMPreeditNothing 0x0008L -#define XIMPreeditNone 0x0010L -#define XIMStatusArea 0x0100L -#define XIMStatusCallbacks 0x0200L -#define XIMStatusNothing 0x0400L -#define XIMStatusNone 0x0800L - -#define XNVaNestedList "XNVaNestedList" -#define XNQueryInputStyle "queryInputStyle" -#define XNClientWindow "clientWindow" -#define XNInputStyle "inputStyle" -#define XNFocusWindow "focusWindow" -#define XNResourceName "resourceName" -#define XNResourceClass "resourceClass" -#define XNGeometryCallback "geometryCallback" -#define XNDestroyCallback "destroyCallback" -#define XNFilterEvents "filterEvents" -#define XNPreeditStartCallback "preeditStartCallback" -#define XNPreeditDoneCallback "preeditDoneCallback" -#define XNPreeditDrawCallback "preeditDrawCallback" -#define XNPreeditCaretCallback "preeditCaretCallback" -#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" -#define XNPreeditAttributes "preeditAttributes" -#define XNStatusStartCallback "statusStartCallback" -#define XNStatusDoneCallback "statusDoneCallback" -#define XNStatusDrawCallback "statusDrawCallback" -#define XNStatusAttributes "statusAttributes" -#define XNArea "area" -#define XNAreaNeeded "areaNeeded" -#define XNSpotLocation "spotLocation" -#define XNColormap "colorMap" -#define XNStdColormap "stdColorMap" -#define XNForeground "foreground" -#define XNBackground "background" -#define XNBackgroundPixmap "backgroundPixmap" -#define XNFontSet "fontSet" -#define XNLineSpace "lineSpace" -#define XNCursor "cursor" - -#define XNQueryIMValuesList "queryIMValuesList" -#define XNQueryICValuesList "queryICValuesList" -#define XNVisiblePosition "visiblePosition" -#define XNR6PreeditCallback "r6PreeditCallback" -#define XNStringConversionCallback "stringConversionCallback" -#define XNStringConversion "stringConversion" -#define XNResetState "resetState" -#define XNHotKey "hotKey" -#define XNHotKeyState "hotKeyState" -#define XNPreeditState "preeditState" -#define XNSeparatorofNestedList "separatorofNestedList" - -#define XBufferOverflow -1 -#define XLookupNone 1 -#define XLookupChars 2 -#define XLookupKeySym 3 -#define XLookupBoth 4 - -typedef void *XVaNestedList; - -typedef struct { - XPointer client_data; - XIMProc callback; -} XIMCallback; - -typedef struct { - XPointer client_data; - XICProc callback; -} XICCallback; - -typedef unsigned long XIMFeedback; - -#define XIMReverse 1L -#define XIMUnderline (1L<<1) -#define XIMHighlight (1L<<2) -#define XIMPrimary (1L<<5) -#define XIMSecondary (1L<<6) -#define XIMTertiary (1L<<7) -#define XIMVisibleToForward (1L<<8) -#define XIMVisibleToBackword (1L<<9) -#define XIMVisibleToCenter (1L<<10) - -typedef struct _XIMText { - unsigned short length; - XIMFeedback *feedback; - Bool encoding_is_wchar; - union { - char *multi_byte; - wchar_t *wide_char; - } string; -} XIMText; - -typedef unsigned long XIMPreeditState; - -#define XIMPreeditUnKnown 0L -#define XIMPreeditEnable 1L -#define XIMPreeditDisable (1L<<1) - -typedef struct _XIMPreeditStateNotifyCallbackStruct { - XIMPreeditState state; -} XIMPreeditStateNotifyCallbackStruct; - -typedef unsigned long XIMResetState; - -#define XIMInitialState 1L -#define XIMPreserveState (1L<<1) - -typedef unsigned long XIMStringConversionFeedback; - -#define XIMStringConversionLeftEdge (0x00000001) -#define XIMStringConversionRightEdge (0x00000002) -#define XIMStringConversionTopEdge (0x00000004) -#define XIMStringConversionBottomEdge (0x00000008) -#define XIMStringConversionConcealed (0x00000010) -#define XIMStringConversionWrapped (0x00000020) - -typedef struct _XIMStringConversionText { - unsigned short length; - XIMStringConversionFeedback *feedback; - Bool encoding_is_wchar; - union { - char *mbs; - wchar_t *wcs; - } string; -} XIMStringConversionText; - -typedef unsigned short XIMStringConversionPosition; - -typedef unsigned short XIMStringConversionType; - -#define XIMStringConversionBuffer (0x0001) -#define XIMStringConversionLine (0x0002) -#define XIMStringConversionWord (0x0003) -#define XIMStringConversionChar (0x0004) - -typedef unsigned short XIMStringConversionOperation; - -#define XIMStringConversionSubstitution (0x0001) -#define XIMStringConversionRetrieval (0x0002) - -typedef enum { - XIMForwardChar, XIMBackwardChar, - XIMForwardWord, XIMBackwardWord, - XIMCaretUp, XIMCaretDown, - XIMNextLine, XIMPreviousLine, - XIMLineStart, XIMLineEnd, - XIMAbsolutePosition, - XIMDontChange -} XIMCaretDirection; - -typedef struct _XIMStringConversionCallbackStruct { - XIMStringConversionPosition position; - XIMCaretDirection direction; - XIMStringConversionOperation operation; - unsigned short factor; - XIMStringConversionText *text; -} XIMStringConversionCallbackStruct; - -typedef struct _XIMPreeditDrawCallbackStruct { - int caret; /* Cursor offset within pre-edit string */ - int chg_first; /* Starting change position */ - int chg_length; /* Length of the change in character count */ - XIMText *text; -} XIMPreeditDrawCallbackStruct; - -typedef enum { - XIMIsInvisible, /* Disable caret feedback */ - XIMIsPrimary, /* UI defined caret feedback */ - XIMIsSecondary /* UI defined caret feedback */ -} XIMCaretStyle; - -typedef struct _XIMPreeditCaretCallbackStruct { - int position; /* Caret offset within pre-edit string */ - XIMCaretDirection direction; /* Caret moves direction */ - XIMCaretStyle style; /* Feedback of the caret */ -} XIMPreeditCaretCallbackStruct; - -typedef enum { - XIMTextType, - XIMBitmapType -} XIMStatusDataType; - -typedef struct _XIMStatusDrawCallbackStruct { - XIMStatusDataType type; - union { - XIMText *text; - Pixmap bitmap; - } data; -} XIMStatusDrawCallbackStruct; - -typedef struct _XIMHotKeyTrigger { - KeySym keysym; - int modifier; - int modifier_mask; -} XIMHotKeyTrigger; - -typedef struct _XIMHotKeyTriggers { - int num_hot_key; - XIMHotKeyTrigger *key; -} XIMHotKeyTriggers; - -typedef unsigned long XIMHotKeyState; - -#define XIMHotKeyStateON (0x0001L) -#define XIMHotKeyStateOFF (0x0002L) - -typedef struct { - unsigned short count_values; - char **supported_values; -} XIMValuesList; - -_XFUNCPROTOBEGIN - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _Xdebug (*_Xdebug_p) -#endif - -extern int _Xdebug; - -extern XFontStruct *XLoadQueryFont( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XFontStruct *XQueryFont( - Display* /* display */, - XID /* font_ID */ -); - - -extern XTimeCoord *XGetMotionEvents( - Display* /* display */, - Window /* w */, - Time /* start */, - Time /* stop */, - int* /* nevents_return */ -); - -extern XModifierKeymap *XDeleteModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XGetModifierMapping( - Display* /* display */ -); - -extern XModifierKeymap *XInsertModifiermapEntry( - XModifierKeymap* /* modmap */, -#if NeedWidePrototypes - unsigned int /* keycode_entry */, -#else - KeyCode /* keycode_entry */, -#endif - int /* modifier */ -); - -extern XModifierKeymap *XNewModifiermap( - int /* max_keys_per_mod */ -); - -extern XImage *XCreateImage( - Display* /* display */, - Visual* /* visual */, - unsigned int /* depth */, - int /* format */, - int /* offset */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - int /* bitmap_pad */, - int /* bytes_per_line */ -); -extern Status XInitImage( - XImage* /* image */ -); -extern XImage *XGetImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */ -); -extern XImage *XGetSubImage( - Display* /* display */, - Drawable /* d */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* plane_mask */, - int /* format */, - XImage* /* dest_image */, - int /* dest_x */, - int /* dest_y */ -); - -/* - * X function declarations. - */ -extern Display *XOpenDisplay( - _Xconst char* /* display_name */ -); - -extern void XrmInitialize( - void -); - -extern char *XFetchBytes( - Display* /* display */, - int* /* nbytes_return */ -); -extern char *XFetchBuffer( - Display* /* display */, - int* /* nbytes_return */, - int /* buffer */ -); -extern char *XGetAtomName( - Display* /* display */, - Atom /* atom */ -); -extern Status XGetAtomNames( - Display* /* dpy */, - Atom* /* atoms */, - int /* count */, - char** /* names_return */ -); -extern char *XGetDefault( - Display* /* display */, - _Xconst char* /* program */, - _Xconst char* /* option */ -); -extern char *XDisplayName( - _Xconst char* /* string */ -); -extern char *XKeysymToString( - KeySym /* keysym */ -); - -extern int (*XSynchronize( - Display* /* display */, - Bool /* onoff */ -))( - Display* /* display */ -); -extern int (*XSetAfterFunction( - Display* /* display */, - int (*) ( - Display* /* display */ - ) /* procedure */ -))( - Display* /* display */ -); -extern Atom XInternAtom( - Display* /* display */, - _Xconst char* /* atom_name */, - Bool /* only_if_exists */ -); -extern Status XInternAtoms( - Display* /* dpy */, - char** /* names */, - int /* count */, - Bool /* onlyIfExists */, - Atom* /* atoms_return */ -); -extern Colormap XCopyColormapAndFree( - Display* /* display */, - Colormap /* colormap */ -); -extern Colormap XCreateColormap( - Display* /* display */, - Window /* w */, - Visual* /* visual */, - int /* alloc */ -); -extern Cursor XCreatePixmapCursor( - Display* /* display */, - Pixmap /* source */, - Pixmap /* mask */, - XColor* /* foreground_color */, - XColor* /* background_color */, - unsigned int /* x */, - unsigned int /* y */ -); -extern Cursor XCreateGlyphCursor( - Display* /* display */, - Font /* source_font */, - Font /* mask_font */, - unsigned int /* source_char */, - unsigned int /* mask_char */, - XColor _Xconst * /* foreground_color */, - XColor _Xconst * /* background_color */ -); -extern Cursor XCreateFontCursor( - Display* /* display */, - unsigned int /* shape */ -); -extern Font XLoadFont( - Display* /* display */, - _Xconst char* /* name */ -); -extern GC XCreateGC( - Display* /* display */, - Drawable /* d */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); -extern GContext XGContextFromGC( - GC /* gc */ -); -extern void XFlushGC( - Display* /* display */, - GC /* gc */ -); -extern Pixmap XCreatePixmap( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* depth */ -); -extern Pixmap XCreateBitmapFromData( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* data */, - unsigned int /* width */, - unsigned int /* height */ -); -extern Pixmap XCreatePixmapFromBitmapData( - Display* /* display */, - Drawable /* d */, - char* /* data */, - unsigned int /* width */, - unsigned int /* height */, - unsigned long /* fg */, - unsigned long /* bg */, - unsigned int /* depth */ -); -extern Window XCreateSimpleWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - unsigned long /* border */, - unsigned long /* background */ -); -extern Window XGetSelectionOwner( - Display* /* display */, - Atom /* selection */ -); -extern Window XCreateWindow( - Display* /* display */, - Window /* parent */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int /* border_width */, - int /* depth */, - unsigned int /* class */, - Visual* /* visual */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); -extern Colormap *XListInstalledColormaps( - Display* /* display */, - Window /* w */, - int* /* num_return */ -); -extern char **XListFonts( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* actual_count_return */ -); -extern char **XListFontsWithInfo( - Display* /* display */, - _Xconst char* /* pattern */, - int /* maxnames */, - int* /* count_return */, - XFontStruct** /* info_return */ -); -extern char **XGetFontPath( - Display* /* display */, - int* /* npaths_return */ -); -extern char **XListExtensions( - Display* /* display */, - int* /* nextensions_return */ -); -extern Atom *XListProperties( - Display* /* display */, - Window /* w */, - int* /* num_prop_return */ -); -extern XHostAddress *XListHosts( - Display* /* display */, - int* /* nhosts_return */, - Bool* /* state_return */ -); -extern KeySym XKeycodeToKeysym( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* keycode */, -#else - KeyCode /* keycode */, -#endif - int /* index */ -); -extern KeySym XLookupKeysym( - XKeyEvent* /* key_event */, - int /* index */ -); -extern KeySym *XGetKeyboardMapping( - Display* /* display */, -#if NeedWidePrototypes - unsigned int /* first_keycode */, -#else - KeyCode /* first_keycode */, -#endif - int /* keycode_count */, - int* /* keysyms_per_keycode_return */ -); -extern KeySym XStringToKeysym( - _Xconst char* /* string */ -); -extern long XMaxRequestSize( - Display* /* display */ -); -extern long XExtendedMaxRequestSize( - Display* /* display */ -); -extern char *XResourceManagerString( - Display* /* display */ -); -extern char *XScreenResourceString( - Screen* /* screen */ -); -extern unsigned long XDisplayMotionBufferSize( - Display* /* display */ -); -extern VisualID XVisualIDFromVisual( - Visual* /* visual */ -); - -/* multithread routines */ - -extern Status XInitThreads( - void -); - -extern void XLockDisplay( - Display* /* display */ -); - -extern void XUnlockDisplay( - Display* /* display */ -); - -/* routines for dealing with extensions */ - -extern XExtCodes *XInitExtension( - Display* /* display */, - _Xconst char* /* name */ -); - -extern XExtCodes *XAddExtension( - Display* /* display */ -); -extern XExtData *XFindOnExtensionList( - XExtData** /* structure */, - int /* number */ -); -extern XExtData **XEHeadOfExtensionList( - XEDataObject /* object */ -); - -/* these are routines for which there are also macros */ -extern Window XRootWindow( - Display* /* display */, - int /* screen_number */ -); -extern Window XDefaultRootWindow( - Display* /* display */ -); -extern Window XRootWindowOfScreen( - Screen* /* screen */ -); -extern Visual *XDefaultVisual( - Display* /* display */, - int /* screen_number */ -); -extern Visual *XDefaultVisualOfScreen( - Screen* /* screen */ -); -extern GC XDefaultGC( - Display* /* display */, - int /* screen_number */ -); -extern GC XDefaultGCOfScreen( - Screen* /* screen */ -); -extern unsigned long XBlackPixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XWhitePixel( - Display* /* display */, - int /* screen_number */ -); -extern unsigned long XAllPlanes( - void -); -extern unsigned long XBlackPixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XWhitePixelOfScreen( - Screen* /* screen */ -); -extern unsigned long XNextRequest( - Display* /* display */ -); -extern unsigned long XLastKnownRequestProcessed( - Display* /* display */ -); -extern char *XServerVendor( - Display* /* display */ -); -extern char *XDisplayString( - Display* /* display */ -); -extern Colormap XDefaultColormap( - Display* /* display */, - int /* screen_number */ -); -extern Colormap XDefaultColormapOfScreen( - Screen* /* screen */ -); -extern Display *XDisplayOfScreen( - Screen* /* screen */ -); -extern Screen *XScreenOfDisplay( - Display* /* display */, - int /* screen_number */ -); -extern Screen *XDefaultScreenOfDisplay( - Display* /* display */ -); -extern long XEventMaskOfScreen( - Screen* /* screen */ -); - -extern int XScreenNumberOfScreen( - Screen* /* screen */ -); - -typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */, - XErrorEvent* /* error_event */ -); - -extern XErrorHandler XSetErrorHandler ( - XErrorHandler /* handler */ -); - - -typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ - Display* /* display */ -); - -extern XIOErrorHandler XSetIOErrorHandler ( - XIOErrorHandler /* handler */ -); - - -extern XPixmapFormatValues *XListPixmapFormats( - Display* /* display */, - int* /* count_return */ -); -extern int *XListDepths( - Display* /* display */, - int /* screen_number */, - int* /* count_return */ -); - -/* ICCCM routines for things that don't require special include files; */ -/* other declarations are given in Xutil.h */ -extern Status XReconfigureWMWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */, - unsigned int /* mask */, - XWindowChanges* /* changes */ -); - -extern Status XGetWMProtocols( - Display* /* display */, - Window /* w */, - Atom** /* protocols_return */, - int* /* count_return */ -); -extern Status XSetWMProtocols( - Display* /* display */, - Window /* w */, - Atom* /* protocols */, - int /* count */ -); -extern Status XIconifyWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XWithdrawWindow( - Display* /* display */, - Window /* w */, - int /* screen_number */ -); -extern Status XGetCommand( - Display* /* display */, - Window /* w */, - char*** /* argv_return */, - int* /* argc_return */ -); -extern Status XGetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window** /* windows_return */, - int* /* count_return */ -); -extern Status XSetWMColormapWindows( - Display* /* display */, - Window /* w */, - Window* /* colormap_windows */, - int /* count */ -); -extern void XFreeStringList( - char** /* list */ -); -extern int XSetTransientForHint( - Display* /* display */, - Window /* w */, - Window /* prop_window */ -); - -/* The following are given in alphabetical order */ - -extern int XActivateScreenSaver( - Display* /* display */ -); - -extern int XAddHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XAddHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XAddToExtensionList( - struct _XExtData** /* structure */, - XExtData* /* ext_data */ -); - -extern int XAddToSaveSet( - Display* /* display */, - Window /* w */ -); - -extern Status XAllocColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* screen_in_out */ -); - -extern Status XAllocColorCells( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* plane_masks_return */, - unsigned int /* nplanes */, - unsigned long* /* pixels_return */, - unsigned int /* npixels */ -); - -extern Status XAllocColorPlanes( - Display* /* display */, - Colormap /* colormap */, - Bool /* contig */, - unsigned long* /* pixels_return */, - int /* ncolors */, - int /* nreds */, - int /* ngreens */, - int /* nblues */, - unsigned long* /* rmask_return */, - unsigned long* /* gmask_return */, - unsigned long* /* bmask_return */ -); - -extern Status XAllocNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* screen_def_return */, - XColor* /* exact_def_return */ -); - -extern int XAllowEvents( - Display* /* display */, - int /* event_mode */, - Time /* time */ -); - -extern int XAutoRepeatOff( - Display* /* display */ -); - -extern int XAutoRepeatOn( - Display* /* display */ -); - -extern int XBell( - Display* /* display */, - int /* percent */ -); - -extern int XBitmapBitOrder( - Display* /* display */ -); - -extern int XBitmapPad( - Display* /* display */ -); - -extern int XBitmapUnit( - Display* /* display */ -); - -extern int XCellsOfScreen( - Screen* /* screen */ -); - -extern int XChangeActivePointerGrab( - Display* /* display */, - unsigned int /* event_mask */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XChangeGC( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values */ -); - -extern int XChangeKeyboardControl( - Display* /* display */, - unsigned long /* value_mask */, - XKeyboardControl* /* values */ -); - -extern int XChangeKeyboardMapping( - Display* /* display */, - int /* first_keycode */, - int /* keysyms_per_keycode */, - KeySym* /* keysyms */, - int /* num_codes */ -); - -extern int XChangePointerControl( - Display* /* display */, - Bool /* do_accel */, - Bool /* do_threshold */, - int /* accel_numerator */, - int /* accel_denominator */, - int /* threshold */ -); - -extern int XChangeProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - Atom /* type */, - int /* format */, - int /* mode */, - _Xconst unsigned char* /* data */, - int /* nelements */ -); - -extern int XChangeSaveSet( - Display* /* display */, - Window /* w */, - int /* change_mode */ -); - -extern int XChangeWindowAttributes( - Display* /* display */, - Window /* w */, - unsigned long /* valuemask */, - XSetWindowAttributes* /* attributes */ -); - -extern Bool XCheckIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern Bool XCheckMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedEvent( - Display* /* display */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckTypedWindowEvent( - Display* /* display */, - Window /* w */, - int /* event_type */, - XEvent* /* event_return */ -); - -extern Bool XCheckWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XCirculateSubwindows( - Display* /* display */, - Window /* w */, - int /* direction */ -); - -extern int XCirculateSubwindowsDown( - Display* /* display */, - Window /* w */ -); - -extern int XCirculateSubwindowsUp( - Display* /* display */, - Window /* w */ -); - -extern int XClearArea( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - Bool /* exposures */ -); - -extern int XClearWindow( - Display* /* display */, - Window /* w */ -); - -extern int XCloseDisplay( - Display* /* display */ -); - -extern int XConfigureWindow( - Display* /* display */, - Window /* w */, - unsigned int /* value_mask */, - XWindowChanges* /* values */ -); - -extern int XConnectionNumber( - Display* /* display */ -); - -extern int XConvertSelection( - Display* /* display */, - Atom /* selection */, - Atom /* target */, - Atom /* property */, - Window /* requestor */, - Time /* time */ -); - -extern int XCopyArea( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XCopyGC( - Display* /* display */, - GC /* src */, - unsigned long /* valuemask */, - GC /* dest */ -); - -extern int XCopyPlane( - Display* /* display */, - Drawable /* src */, - Drawable /* dest */, - GC /* gc */, - int /* src_x */, - int /* src_y */, - unsigned int /* width */, - unsigned int /* height */, - int /* dest_x */, - int /* dest_y */, - unsigned long /* plane */ -); - -extern int XDefaultDepth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDefaultDepthOfScreen( - Screen* /* screen */ -); - -extern int XDefaultScreen( - Display* /* display */ -); - -extern int XDefineCursor( - Display* /* display */, - Window /* w */, - Cursor /* cursor */ -); - -extern int XDeleteProperty( - Display* /* display */, - Window /* w */, - Atom /* property */ -); - -extern int XDestroyWindow( - Display* /* display */, - Window /* w */ -); - -extern int XDestroySubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XDoesBackingStore( - Screen* /* screen */ -); - -extern Bool XDoesSaveUnders( - Screen* /* screen */ -); - -extern int XDisableAccessControl( - Display* /* display */ -); - - -extern int XDisplayCells( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeight( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayHeightMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayKeycodes( - Display* /* display */, - int* /* min_keycodes_return */, - int* /* max_keycodes_return */ -); - -extern int XDisplayPlanes( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidth( - Display* /* display */, - int /* screen_number */ -); - -extern int XDisplayWidthMM( - Display* /* display */, - int /* screen_number */ -); - -extern int XDrawArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XDrawArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XDrawImageString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawImageString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawLine( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x1 */, - int /* y1 */, - int /* x2 */, - int /* y2 */ -); - -extern int XDrawLines( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawPoint( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */ -); - -extern int XDrawPoints( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* mode */ -); - -extern int XDrawRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XDrawRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XDrawSegments( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XSegment* /* segments */, - int /* nsegments */ -); - -extern int XDrawString( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* string */, - int /* length */ -); - -extern int XDrawString16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst XChar2b* /* string */, - int /* length */ -); - -extern int XDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem* /* items */, - int /* nitems */ -); - -extern int XDrawText16( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XTextItem16* /* items */, - int /* nitems */ -); - -extern int XEnableAccessControl( - Display* /* display */ -); - -extern int XEventsQueued( - Display* /* display */, - int /* mode */ -); - -extern Status XFetchName( - Display* /* display */, - Window /* w */, - char** /* window_name_return */ -); - -extern int XFillArc( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */, - int /* angle1 */, - int /* angle2 */ -); - -extern int XFillArcs( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XArc* /* arcs */, - int /* narcs */ -); - -extern int XFillPolygon( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XPoint* /* points */, - int /* npoints */, - int /* shape */, - int /* mode */ -); - -extern int XFillRectangle( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XFillRectangles( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XRectangle* /* rectangles */, - int /* nrectangles */ -); - -extern int XFlush( - Display* /* display */ -); - -extern int XForceScreenSaver( - Display* /* display */, - int /* mode */ -); - -extern int XFree( - void* /* data */ -); - -extern int XFreeColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XFreeColors( - Display* /* display */, - Colormap /* colormap */, - unsigned long* /* pixels */, - int /* npixels */, - unsigned long /* planes */ -); - -extern int XFreeCursor( - Display* /* display */, - Cursor /* cursor */ -); - -extern int XFreeExtensionList( - char** /* list */ -); - -extern int XFreeFont( - Display* /* display */, - XFontStruct* /* font_struct */ -); - -extern int XFreeFontInfo( - char** /* names */, - XFontStruct* /* free_info */, - int /* actual_count */ -); - -extern int XFreeFontNames( - char** /* list */ -); - -extern int XFreeFontPath( - char** /* list */ -); - -extern int XFreeGC( - Display* /* display */, - GC /* gc */ -); - -extern int XFreeModifiermap( - XModifierKeymap* /* modmap */ -); - -extern int XFreePixmap( - Display* /* display */, - Pixmap /* pixmap */ -); - -extern int XGeometry( - Display* /* display */, - int /* screen */, - _Xconst char* /* position */, - _Xconst char* /* default_position */, - unsigned int /* bwidth */, - unsigned int /* fwidth */, - unsigned int /* fheight */, - int /* xadder */, - int /* yadder */, - int* /* x_return */, - int* /* y_return */, - int* /* width_return */, - int* /* height_return */ -); - -extern int XGetErrorDatabaseText( - Display* /* display */, - _Xconst char* /* name */, - _Xconst char* /* message */, - _Xconst char* /* default_string */, - char* /* buffer_return */, - int /* length */ -); - -extern int XGetErrorText( - Display* /* display */, - int /* code */, - char* /* buffer_return */, - int /* length */ -); - -extern Bool XGetFontProperty( - XFontStruct* /* font_struct */, - Atom /* atom */, - unsigned long* /* value_return */ -); - -extern Status XGetGCValues( - Display* /* display */, - GC /* gc */, - unsigned long /* valuemask */, - XGCValues* /* values_return */ -); - -extern Status XGetGeometry( - Display* /* display */, - Drawable /* d */, - Window* /* root_return */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned int* /* border_width_return */, - unsigned int* /* depth_return */ -); - -extern Status XGetIconName( - Display* /* display */, - Window /* w */, - char** /* icon_name_return */ -); - -extern int XGetInputFocus( - Display* /* display */, - Window* /* focus_return */, - int* /* revert_to_return */ -); - -extern int XGetKeyboardControl( - Display* /* display */, - XKeyboardState* /* values_return */ -); - -extern int XGetPointerControl( - Display* /* display */, - int* /* accel_numerator_return */, - int* /* accel_denominator_return */, - int* /* threshold_return */ -); - -extern int XGetPointerMapping( - Display* /* display */, - unsigned char* /* map_return */, - int /* nmap */ -); - -extern int XGetScreenSaver( - Display* /* display */, - int* /* timeout_return */, - int* /* interval_return */, - int* /* prefer_blanking_return */, - int* /* allow_exposures_return */ -); - -extern Status XGetTransientForHint( - Display* /* display */, - Window /* w */, - Window* /* prop_window_return */ -); - -extern int XGetWindowProperty( - Display* /* display */, - Window /* w */, - Atom /* property */, - long /* long_offset */, - long /* long_length */, - Bool /* delete */, - Atom /* req_type */, - Atom* /* actual_type_return */, - int* /* actual_format_return */, - unsigned long* /* nitems_return */, - unsigned long* /* bytes_after_return */, - unsigned char** /* prop_return */ -); - -extern Status XGetWindowAttributes( - Display* /* display */, - Window /* w */, - XWindowAttributes* /* window_attributes_return */ -); - -extern int XGrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */ -); - -extern int XGrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */ -); - -extern int XGrabKeyboard( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - int /* pointer_mode */, - int /* keyboard_mode */, - Time /* time */ -); - -extern int XGrabPointer( - Display* /* display */, - Window /* grab_window */, - Bool /* owner_events */, - unsigned int /* event_mask */, - int /* pointer_mode */, - int /* keyboard_mode */, - Window /* confine_to */, - Cursor /* cursor */, - Time /* time */ -); - -extern int XGrabServer( - Display* /* display */ -); - -extern int XHeightMMOfScreen( - Screen* /* screen */ -); - -extern int XHeightOfScreen( - Screen* /* screen */ -); - -extern int XIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XImageByteOrder( - Display* /* display */ -); - -extern int XInstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern KeyCode XKeysymToKeycode( - Display* /* display */, - KeySym /* keysym */ -); - -extern int XKillClient( - Display* /* display */, - XID /* resource */ -); - -extern Status XLookupColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color_name */, - XColor* /* exact_def_return */, - XColor* /* screen_def_return */ -); - -extern int XLowerWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMapRaised( - Display* /* display */, - Window /* w */ -); - -extern int XMapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XMapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XMaskEvent( - Display* /* display */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XMaxCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMinCmapsOfScreen( - Screen* /* screen */ -); - -extern int XMoveResizeWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XMoveWindow( - Display* /* display */, - Window /* w */, - int /* x */, - int /* y */ -); - -extern int XNextEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XNoOp( - Display* /* display */ -); - -extern Status XParseColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* spec */, - XColor* /* exact_def_return */ -); - -extern int XParseGeometry( - _Xconst char* /* parsestring */, - int* /* x_return */, - int* /* y_return */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XPeekEvent( - Display* /* display */, - XEvent* /* event_return */ -); - -extern int XPeekIfEvent( - Display* /* display */, - XEvent* /* event_return */, - Bool (*) ( - Display* /* display */, - XEvent* /* event */, - XPointer /* arg */ - ) /* predicate */, - XPointer /* arg */ -); - -extern int XPending( - Display* /* display */ -); - -extern int XPlanesOfScreen( - Screen* /* screen */ -); - -extern int XProtocolRevision( - Display* /* display */ -); - -extern int XProtocolVersion( - Display* /* display */ -); - - -extern int XPutBackEvent( - Display* /* display */, - XEvent* /* event */ -); - -extern int XPutImage( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - XImage* /* image */, - int /* src_x */, - int /* src_y */, - int /* dest_x */, - int /* dest_y */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XQLength( - Display* /* display */ -); - -extern Status XQueryBestCursor( - Display* /* display */, - Drawable /* d */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestSize( - Display* /* display */, - int /* class */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestStipple( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern Status XQueryBestTile( - Display* /* display */, - Drawable /* which_screen */, - unsigned int /* width */, - unsigned int /* height */, - unsigned int* /* width_return */, - unsigned int* /* height_return */ -); - -extern int XQueryColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* def_in_out */ -); - -extern int XQueryColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* defs_in_out */, - int /* ncolors */ -); - -extern Bool XQueryExtension( - Display* /* display */, - _Xconst char* /* name */, - int* /* major_opcode_return */, - int* /* first_event_return */, - int* /* first_error_return */ -); - -extern int XQueryKeymap( - Display* /* display */, - char [32] /* keys_return */ -); - -extern Bool XQueryPointer( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* child_return */, - int* /* root_x_return */, - int* /* root_y_return */, - int* /* win_x_return */, - int* /* win_y_return */, - unsigned int* /* mask_return */ -); - -extern int XQueryTextExtents( - Display* /* display */, - XID /* font_ID */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XQueryTextExtents16( - Display* /* display */, - XID /* font_ID */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern Status XQueryTree( - Display* /* display */, - Window /* w */, - Window* /* root_return */, - Window* /* parent_return */, - Window** /* children_return */, - unsigned int* /* nchildren_return */ -); - -extern int XRaiseWindow( - Display* /* display */, - Window /* w */ -); - -extern int XReadBitmapFile( - Display* /* display */, - Drawable /* d */, - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - Pixmap* /* bitmap_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XReadBitmapFileData( - _Xconst char* /* filename */, - unsigned int* /* width_return */, - unsigned int* /* height_return */, - unsigned char** /* data_return */, - int* /* x_hot_return */, - int* /* y_hot_return */ -); - -extern int XRebindKeysym( - Display* /* display */, - KeySym /* keysym */, - KeySym* /* list */, - int /* mod_count */, - _Xconst unsigned char* /* string */, - int /* bytes_string */ -); - -extern int XRecolorCursor( - Display* /* display */, - Cursor /* cursor */, - XColor* /* foreground_color */, - XColor* /* background_color */ -); - -extern int XRefreshKeyboardMapping( - XMappingEvent* /* event_map */ -); - -extern int XRemoveFromSaveSet( - Display* /* display */, - Window /* w */ -); - -extern int XRemoveHost( - Display* /* display */, - XHostAddress* /* host */ -); - -extern int XRemoveHosts( - Display* /* display */, - XHostAddress* /* hosts */, - int /* num_hosts */ -); - -extern int XReparentWindow( - Display* /* display */, - Window /* w */, - Window /* parent */, - int /* x */, - int /* y */ -); - -extern int XResetScreenSaver( - Display* /* display */ -); - -extern int XResizeWindow( - Display* /* display */, - Window /* w */, - unsigned int /* width */, - unsigned int /* height */ -); - -extern int XRestackWindows( - Display* /* display */, - Window* /* windows */, - int /* nwindows */ -); - -extern int XRotateBuffers( - Display* /* display */, - int /* rotate */ -); - -extern int XRotateWindowProperties( - Display* /* display */, - Window /* w */, - Atom* /* properties */, - int /* num_prop */, - int /* npositions */ -); - -extern int XScreenCount( - Display* /* display */ -); - -extern int XSelectInput( - Display* /* display */, - Window /* w */, - long /* event_mask */ -); - -extern Status XSendEvent( - Display* /* display */, - Window /* w */, - Bool /* propagate */, - long /* event_mask */, - XEvent* /* event_send */ -); - -extern int XSetAccessControl( - Display* /* display */, - int /* mode */ -); - -extern int XSetArcMode( - Display* /* display */, - GC /* gc */, - int /* arc_mode */ -); - -extern int XSetBackground( - Display* /* display */, - GC /* gc */, - unsigned long /* background */ -); - -extern int XSetClipMask( - Display* /* display */, - GC /* gc */, - Pixmap /* pixmap */ -); - -extern int XSetClipOrigin( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */ -); - -extern int XSetClipRectangles( - Display* /* display */, - GC /* gc */, - int /* clip_x_origin */, - int /* clip_y_origin */, - XRectangle* /* rectangles */, - int /* n */, - int /* ordering */ -); - -extern int XSetCloseDownMode( - Display* /* display */, - int /* close_mode */ -); - -extern int XSetCommand( - Display* /* display */, - Window /* w */, - char** /* argv */, - int /* argc */ -); - -extern int XSetDashes( - Display* /* display */, - GC /* gc */, - int /* dash_offset */, - _Xconst char* /* dash_list */, - int /* n */ -); - -extern int XSetFillRule( - Display* /* display */, - GC /* gc */, - int /* fill_rule */ -); - -extern int XSetFillStyle( - Display* /* display */, - GC /* gc */, - int /* fill_style */ -); - -extern int XSetFont( - Display* /* display */, - GC /* gc */, - Font /* font */ -); - -extern int XSetFontPath( - Display* /* display */, - char** /* directories */, - int /* ndirs */ -); - -extern int XSetForeground( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */ -); - -extern int XSetFunction( - Display* /* display */, - GC /* gc */, - int /* function */ -); - -extern int XSetGraphicsExposures( - Display* /* display */, - GC /* gc */, - Bool /* graphics_exposures */ -); - -extern int XSetIconName( - Display* /* display */, - Window /* w */, - _Xconst char* /* icon_name */ -); - -extern int XSetInputFocus( - Display* /* display */, - Window /* focus */, - int /* revert_to */, - Time /* time */ -); - -extern int XSetLineAttributes( - Display* /* display */, - GC /* gc */, - unsigned int /* line_width */, - int /* line_style */, - int /* cap_style */, - int /* join_style */ -); - -extern int XSetModifierMapping( - Display* /* display */, - XModifierKeymap* /* modmap */ -); - -extern int XSetPlaneMask( - Display* /* display */, - GC /* gc */, - unsigned long /* plane_mask */ -); - -extern int XSetPointerMapping( - Display* /* display */, - _Xconst unsigned char* /* map */, - int /* nmap */ -); - -extern int XSetScreenSaver( - Display* /* display */, - int /* timeout */, - int /* interval */, - int /* prefer_blanking */, - int /* allow_exposures */ -); - -extern int XSetSelectionOwner( - Display* /* display */, - Atom /* selection */, - Window /* owner */, - Time /* time */ -); - -extern int XSetState( - Display* /* display */, - GC /* gc */, - unsigned long /* foreground */, - unsigned long /* background */, - int /* function */, - unsigned long /* plane_mask */ -); - -extern int XSetStipple( - Display* /* display */, - GC /* gc */, - Pixmap /* stipple */ -); - -extern int XSetSubwindowMode( - Display* /* display */, - GC /* gc */, - int /* subwindow_mode */ -); - -extern int XSetTSOrigin( - Display* /* display */, - GC /* gc */, - int /* ts_x_origin */, - int /* ts_y_origin */ -); - -extern int XSetTile( - Display* /* display */, - GC /* gc */, - Pixmap /* tile */ -); - -extern int XSetWindowBackground( - Display* /* display */, - Window /* w */, - unsigned long /* background_pixel */ -); - -extern int XSetWindowBackgroundPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* background_pixmap */ -); - -extern int XSetWindowBorder( - Display* /* display */, - Window /* w */, - unsigned long /* border_pixel */ -); - -extern int XSetWindowBorderPixmap( - Display* /* display */, - Window /* w */, - Pixmap /* border_pixmap */ -); - -extern int XSetWindowBorderWidth( - Display* /* display */, - Window /* w */, - unsigned int /* width */ -); - -extern int XSetWindowColormap( - Display* /* display */, - Window /* w */, - Colormap /* colormap */ -); - -extern int XStoreBuffer( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */, - int /* buffer */ -); - -extern int XStoreBytes( - Display* /* display */, - _Xconst char* /* bytes */, - int /* nbytes */ -); - -extern int XStoreColor( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */ -); - -extern int XStoreColors( - Display* /* display */, - Colormap /* colormap */, - XColor* /* color */, - int /* ncolors */ -); - -extern int XStoreName( - Display* /* display */, - Window /* w */, - _Xconst char* /* window_name */ -); - -extern int XStoreNamedColor( - Display* /* display */, - Colormap /* colormap */, - _Xconst char* /* color */, - unsigned long /* pixel */, - int /* flags */ -); - -extern int XSync( - Display* /* display */, - Bool /* discard */ -); - -extern int XTextExtents( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextExtents16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* nchars */, - int* /* direction_return */, - int* /* font_ascent_return */, - int* /* font_descent_return */, - XCharStruct* /* overall_return */ -); - -extern int XTextWidth( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int XTextWidth16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -extern Bool XTranslateCoordinates( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - int* /* dest_x_return */, - int* /* dest_y_return */, - Window* /* child_return */ -); - -extern int XUndefineCursor( - Display* /* display */, - Window /* w */ -); - -extern int XUngrabButton( - Display* /* display */, - unsigned int /* button */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKey( - Display* /* display */, - int /* keycode */, - unsigned int /* modifiers */, - Window /* grab_window */ -); - -extern int XUngrabKeyboard( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabPointer( - Display* /* display */, - Time /* time */ -); - -extern int XUngrabServer( - Display* /* display */ -); - -extern int XUninstallColormap( - Display* /* display */, - Colormap /* colormap */ -); - -extern int XUnloadFont( - Display* /* display */, - Font /* font */ -); - -extern int XUnmapSubwindows( - Display* /* display */, - Window /* w */ -); - -extern int XUnmapWindow( - Display* /* display */, - Window /* w */ -); - -extern int XVendorRelease( - Display* /* display */ -); - -extern int XWarpPointer( - Display* /* display */, - Window /* src_w */, - Window /* dest_w */, - int /* src_x */, - int /* src_y */, - unsigned int /* src_width */, - unsigned int /* src_height */, - int /* dest_x */, - int /* dest_y */ -); - -extern int XWidthMMOfScreen( - Screen* /* screen */ -); - -extern int XWidthOfScreen( - Screen* /* screen */ -); - -extern int XWindowEvent( - Display* /* display */, - Window /* w */, - long /* event_mask */, - XEvent* /* event_return */ -); - -extern int XWriteBitmapFile( - Display* /* display */, - _Xconst char* /* filename */, - Pixmap /* bitmap */, - unsigned int /* width */, - unsigned int /* height */, - int /* x_hot */, - int /* y_hot */ -); - -extern Bool XSupportsLocale (void); - -extern char *XSetLocaleModifiers( - const char* /* modifier_list */ -); - -extern XOM XOpenOM( - Display* /* display */, - struct _XrmHashBucketRec* /* rdb */, - _Xconst char* /* res_name */, - _Xconst char* /* res_class */ -); - -extern Status XCloseOM( - XOM /* om */ -); - -extern char *XSetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern char *XGetOMValues( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfOM( - XOM /* om */ -); - -extern char *XLocaleOfOM( - XOM /* om */ -); - -extern XOC XCreateOC( - XOM /* om */, - ... -) _X_SENTINEL(0); - -extern void XDestroyOC( - XOC /* oc */ -); - -extern XOM XOMOfOC( - XOC /* oc */ -); - -extern char *XSetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern char *XGetOCValues( - XOC /* oc */, - ... -) _X_SENTINEL(0); - -extern XFontSet XCreateFontSet( - Display* /* display */, - _Xconst char* /* base_font_name_list */, - char*** /* missing_charset_list */, - int* /* missing_charset_count */, - char** /* def_string */ -); - -extern void XFreeFontSet( - Display* /* display */, - XFontSet /* font_set */ -); - -extern int XFontsOfFontSet( - XFontSet /* font_set */, - XFontStruct*** /* font_struct_list */, - char*** /* font_name_list */ -); - -extern char *XBaseFontNameListOfFontSet( - XFontSet /* font_set */ -); - -extern char *XLocaleOfFontSet( - XFontSet /* font_set */ -); - -extern Bool XContextDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XDirectionalDependentDrawing( - XFontSet /* font_set */ -); - -extern Bool XContextualDrawing( - XFontSet /* font_set */ -); - -extern XFontSetExtents *XExtentsOfFontSet( - XFontSet /* font_set */ -); - -extern int XmbTextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XwcTextEscapement( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern int Xutf8TextEscapement( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern int XmbTextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int XwcTextExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern int Xutf8TextExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XmbTextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status XwcTextPerCharExtents( - XFontSet /* font_set */, - _Xconst wchar_t* /* text */, - int /* num_wchars */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern Status Xutf8TextPerCharExtents( - XFontSet /* font_set */, - _Xconst char* /* text */, - int /* bytes_text */, - XRectangle* /* ink_extents_buffer */, - XRectangle* /* logical_extents_buffer */, - int /* buffer_size */, - int* /* num_chars */, - XRectangle* /* overall_ink_return */, - XRectangle* /* overall_logical_return */ -); - -extern void XmbDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XwcDrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XwcTextItem* /* text_items */, - int /* nitems */ -); - -extern void Xutf8DrawText( - Display* /* display */, - Drawable /* d */, - GC /* gc */, - int /* x */, - int /* y */, - XmbTextItem* /* text_items */, - int /* nitems */ -); - -extern void XmbDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XmbDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern void XwcDrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst wchar_t* /* text */, - int /* num_wchars */ -); - -extern void Xutf8DrawImageString( - Display* /* display */, - Drawable /* d */, - XFontSet /* font_set */, - GC /* gc */, - int /* x */, - int /* y */, - _Xconst char* /* text */, - int /* bytes_text */ -); - -extern XIM XOpenIM( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */ -); - -extern Status XCloseIM( - XIM /* im */ -); - -extern char *XGetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern char *XSetIMValues( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern Display *XDisplayOfIM( - XIM /* im */ -); - -extern char *XLocaleOfIM( - XIM /* im*/ -); - -extern XIC XCreateIC( - XIM /* im */, ... -) _X_SENTINEL(0); - -extern void XDestroyIC( - XIC /* ic */ -); - -extern void XSetICFocus( - XIC /* ic */ -); - -extern void XUnsetICFocus( - XIC /* ic */ -); - -extern wchar_t *XwcResetIC( - XIC /* ic */ -); - -extern char *XmbResetIC( - XIC /* ic */ -); - -extern char *Xutf8ResetIC( - XIC /* ic */ -); - -extern char *XSetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern char *XGetICValues( - XIC /* ic */, ... -) _X_SENTINEL(0); - -extern XIM XIMOfIC( - XIC /* ic */ -); - -extern Bool XFilterEvent( - XEvent* /* event */, - Window /* window */ -); - -extern int XmbLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int XwcLookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - wchar_t* /* buffer_return */, - int /* wchars_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern int Xutf8LookupString( - XIC /* ic */, - XKeyPressedEvent* /* event */, - char* /* buffer_return */, - int /* bytes_buffer */, - KeySym* /* keysym_return */, - Status* /* status_return */ -); - -extern XVaNestedList XVaCreateNestedList( - int /*unused*/, ... -) _X_SENTINEL(0); - -/* internal connections for IMs */ - -extern Bool XRegisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -extern Bool XUnregisterIMInstantiateCallback( - Display* /* dpy */, - struct _XrmHashBucketRec* /* rdb */, - char* /* res_name */, - char* /* res_class */, - XIDProc /* callback */, - XPointer /* client_data */ -); - -typedef void (*XConnectionWatchProc)( - Display* /* dpy */, - XPointer /* client_data */, - int /* fd */, - Bool /* opening */, /* open or close flag */ - XPointer* /* watch_data */ /* open sets, close uses */ -); - - -extern Status XInternalConnectionNumbers( - Display* /* dpy */, - int** /* fd_return */, - int* /* count_return */ -); - -extern void XProcessInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -extern Status XAddConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XRemoveConnectionWatch( - Display* /* dpy */, - XConnectionWatchProc /* callback */, - XPointer /* client_data */ -); - -extern void XSetAuthorization( - char * /* name */, - int /* namelen */, - char * /* data */, - int /* datalen */ -); - -extern int _Xmbtowc( - wchar_t * /* wstr */, -#ifdef ISC - char const * /* str */, - size_t /* len */ -#else - char * /* str */, - int /* len */ -#endif -); - -extern int _Xwctomb( - char * /* str */, - wchar_t /* wc */ -); - -_XFUNCPROTOEND - -#endif /* _XLIB_H_ */ diff --git a/nx-X11/lib/X11/XlibAsync.c.NX.original b/nx-X11/lib/X11/XlibAsync.c.NX.original deleted file mode 100644 index 70bd82bad..000000000 --- a/nx-X11/lib/X11/XlibAsync.c.NX.original +++ /dev/null @@ -1,181 +0,0 @@ -/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -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. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -#define NEED_REPLIES -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xos.h> - -/*ARGSUSED*/ -Bool -_XAsyncErrorHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - register _XAsyncErrorState *state; - - state = (_XAsyncErrorState *)data; - if (rep->generic.type == X_Error && - (!state->error_code || - rep->error.errorCode == state->error_code) && - (!state->major_opcode || - rep->error.majorCode == state->major_opcode) && - (!state->minor_opcode || - rep->error.minorCode == state->minor_opcode) && - (!state->min_sequence_number || - (state->min_sequence_number <= dpy->last_request_read)) && - (!state->max_sequence_number || - (state->max_sequence_number >= dpy->last_request_read))) { - state->last_error_received = rep->error.errorCode; - state->error_count++; - return True; - } - return False; -} - -void _XDeqAsyncHandler(dpy, handler) - Display *dpy; - register _XAsyncHandler *handler; -{ - register _XAsyncHandler **prev; - register _XAsyncHandler *async; - - for (prev = &dpy->async_handlers; - (async = *prev) && (async != handler); - prev = &async->next) - ; - if (async) - *prev = async->next; -} - -char * -_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard) - register Display *dpy; - register char *replbuf; /* data is read into this buffer */ - register xReply *rep; /* value passed to calling handler */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int extra; /* extra words to read, ala _XReply */ - Bool discard; /* discard after extra?, ala _XReply */ -{ - if (extra == 0) { - if (discard && (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - return (char *)rep; - } - - if (extra <= rep->generic.length) { - int size = SIZEOF(xReply) + (extra << 2); - if (size > len) { - memcpy(replbuf, buf, len); - _XRead(dpy, replbuf + len, size - len); - buf = replbuf; - len = size; -#ifdef MUSTCOPY - } else { - memcpy(replbuf, buf, size); - buf = replbuf; -#endif - } - - if (discard && rep->generic.length > extra && - (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - - return buf; - } - /* - *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... - */ - if ((rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _XIOError (dpy); - return (char *)rep; -} - -void -_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal) - Display *dpy; - char *data; /* data is read into this buffer */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int skip; /* number of bytes already read in previous - _XGetAsyncReply or _XGetAsyncData calls */ - int datalen; /* size of data buffer in bytes */ - int discardtotal; /* min. bytes to consume (after skip) */ -{ - buf += skip; - len -= skip; - if (!data) { - if (datalen > len) - _XEatData(dpy, datalen - len); - } else if (datalen <= len) { - memcpy(data, buf, datalen); - } else { - memcpy(data, buf, len); - _XRead(dpy, data + len, datalen - len); - } - if (discardtotal > len) { - if (datalen > len) - len = datalen; - _XEatData(dpy, discardtotal - len); - } -} diff --git a/nx-X11/lib/X11/XlibAsync.c.X.original b/nx-X11/lib/X11/XlibAsync.c.X.original deleted file mode 100644 index a0314ba81..000000000 --- a/nx-X11/lib/X11/XlibAsync.c.X.original +++ /dev/null @@ -1,156 +0,0 @@ -/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -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. - -*/ - -#define NEED_REPLIES -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xlibint.h> -#include <X11/Xos.h> - -/*ARGSUSED*/ -Bool -_XAsyncErrorHandler(dpy, rep, buf, len, data) - register Display *dpy; - register xReply *rep; - char *buf; - int len; - XPointer data; -{ - register _XAsyncErrorState *state; - - state = (_XAsyncErrorState *)data; - if (rep->generic.type == X_Error && - (!state->error_code || - rep->error.errorCode == state->error_code) && - (!state->major_opcode || - rep->error.majorCode == state->major_opcode) && - (!state->minor_opcode || - rep->error.minorCode == state->minor_opcode) && - (!state->min_sequence_number || - (state->min_sequence_number <= dpy->last_request_read)) && - (!state->max_sequence_number || - (state->max_sequence_number >= dpy->last_request_read))) { - state->last_error_received = rep->error.errorCode; - state->error_count++; - return True; - } - return False; -} - -void _XDeqAsyncHandler(dpy, handler) - Display *dpy; - register _XAsyncHandler *handler; -{ - register _XAsyncHandler **prev; - register _XAsyncHandler *async; - - for (prev = &dpy->async_handlers; - (async = *prev) && (async != handler); - prev = &async->next) - ; - if (async) - *prev = async->next; -} - -char * -_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard) - register Display *dpy; - register char *replbuf; /* data is read into this buffer */ - register xReply *rep; /* value passed to calling handler */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int extra; /* extra words to read, ala _XReply */ - Bool discard; /* discard after extra?, ala _XReply */ -{ - if (extra == 0) { - if (discard && (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - return (char *)rep; - } - - if (extra <= rep->generic.length) { - int size = SIZEOF(xReply) + (extra << 2); - if (size > len) { - memcpy(replbuf, buf, len); - _XRead(dpy, replbuf + len, size - len); - buf = replbuf; - len = size; -#ifdef MUSTCOPY - } else { - memcpy(replbuf, buf, size); - buf = replbuf; -#endif - } - - if (discard && rep->generic.length > extra && - (rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - - return buf; - } - /* - *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... - */ - if ((rep->generic.length << 2) > len) - _XEatData (dpy, (rep->generic.length << 2) - len); - _XIOError (dpy); - return (char *)rep; -} - -void -_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal) - Display *dpy; - char *data; /* data is read into this buffer */ - char *buf; /* value passed to calling handler */ - int len; /* value passed to calling handler */ - int skip; /* number of bytes already read in previous - _XGetAsyncReply or _XGetAsyncData calls */ - int datalen; /* size of data buffer in bytes */ - int discardtotal; /* min. bytes to consume (after skip) */ -{ - buf += skip; - len -= skip; - if (!data) { - if (datalen > len) - _XEatData(dpy, datalen - len); - } else if (datalen <= len) { - memcpy(data, buf, datalen); - } else { - memcpy(data, buf, len); - _XRead(dpy, data + len, datalen - len); - } - if (discardtotal > len) { - if (datalen > len) - len = datalen; - _XEatData(dpy, discardtotal - len); - } -} diff --git a/nx-X11/lib/X11/XlibInt.c.NX.original b/nx-X11/lib/X11/XlibInt.c.NX.original deleted file mode 100644 index 47e2ea139..000000000 --- a/nx-X11/lib/X11/XlibInt.c.NX.original +++ /dev/null @@ -1,4167 +0,0 @@ -/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -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. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */ - -/* - * 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_ -#endif -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xpoll.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/extensions/xcmiscstr.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)()) - -#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 - -#else /* XTHREADS else */ - -#define UnlockNextReplyReader(d) -#define UnlockNextEventReader(d) -#define InternalLockDisplay(d,wskip) - -#endif /* XTHREADS else */ - -#include "NX.h" - -#ifdef NX_TRANS_SOCKET - -#include "NX.h" -#include "NXvars.h" - -static struct timeval retry; - -/* - * From Xtranssock.c. Presently the congestion state - * is reported by the proxy to the application, by - * invoking the callback directly. The function will - * be possibly used in the future, to be able to track - * the bandwidth usage even when the NX transport is - * not running. Note that in this sample implementation - * the congestion state is checked very often and can - * be surely optimized. - */ - -#ifdef NX_TRANS_CHANGE - -extern int _X11TransSocketCongestionChange(XtransConnInfo, int *); - -#endif - -#endif /* #ifdef NX_TRANS_SOCKET */ - -/* 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 -#ifdef ISC -#define ECHECK(err) ((errno == err) || ETEST()) -#else -#define ECHECK(err) (errno == err) -#endif -#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__ -#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t) -#include <limits.h> -#define MAX_PATH _POSIX_PATH_MAX -#endif - -#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); - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info); - -#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10) - -/* - * 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. - */ - -static xReq _dummy_request = { - 0, 0, 0 -}; - -#ifdef NX_TRANS_SOCKET - -/* - * Replace the standard Select with a version giving NX a - * chance to check its own descriptors. This doesn't cover - * the cases where the system is using poll or when system- - * specific defines override the Select definition (OS/2). - */ - -int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XSelect: Called with [%d][%p][%p][%p][%p].\n", - maxfds, (void *) readfds, (void *) writefds, (void *) exceptfds, - (void *) timeout); -#endif - - if (NXTransRunning(NX_FD_ANY)) - { - fd_set t_readfds, t_writefds; - struct timeval t_timeout; - - int n, r, e; - -#ifdef NX_TRANS_TEST - - if (exceptfds != NULL) - { - fprintf(stderr, "_XSelect: WARNING! Can't handle exception fds in select.\n"); - } - -#endif - - if (readfds == NULL) - { - FD_ZERO(&t_readfds); - - readfds = &t_readfds; - } - - if (writefds == NULL) - { - FD_ZERO(&t_writefds); - - writefds = &t_writefds; - } - - if (timeout == NULL) - { - t_timeout.tv_sec = 10; - t_timeout.tv_usec = 0; - - timeout = &t_timeout; - } - - n = maxfds; - - /* - * If the transport is gone avoid - * sleeping until the timeout. - */ - - if (NXTransPrepare(&n, readfds, writefds, timeout) != 0) - { - NXTransSelect(&r, &e, &n, readfds, writefds, timeout); - - NXTransExecute(&r, &e, &n, readfds, writefds, timeout); - - errno = e; - - return r; - } - else - { - return 0; - } - } - else - { - return select(maxfds, readfds, writefds, exceptfds, timeout); - } -} - -#else /* #ifdef NX_TRANS_SOCKET */ - -int _XSelect(int maxfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout) -{ - return select(maxfds, readfds, writefds, exceptfds, timeout); -} - -#endif /* #ifdef NX_TRANS_SOCKET */ - -/* - * 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#ifdef NX_TRANS_SOCKET - - if (_XGetIOError(dpy)) { - return; - } - -#endif - -#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 - -#ifndef NX_TRANS_SOCKET -#ifdef USE_POLL - filedes.events = POLLIN; - filedes.events |= POLLOUT; -#else - FD_SET(dpy->fd, &r_mask); - FD_SET(dpy->fd, &w_mask); -#endif -#endif /* #ifndef NX_TRANS_SOCKET */ - - do { -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the registered client to perform - * any needed operation before entering the select. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XWaitForWritable: WAIT! Waiting for the display to become writable.\n"); -#endif - NXTransFlush(dpy->fd); - - if (_NXDisplayBlockFunction != NULL) { - (*_NXDisplayBlockFunction)(dpy, NXBlockWrite); - } - - /* - * Need to set again the descriptors as we could have - * run multiple selects before having the possibility - * to read or write to the X connection. - */ - -#ifdef USE_POLL - filedes.events = POLLIN; - filedes.events |= POLLOUT; -#else - FD_SET(dpy->fd, &r_mask); - FD_SET(dpy->fd, &w_mask); -#endif -#endif /* #ifdef NX_TRANS_SOCKET */ - - UnlockDisplay(dpy); -#ifdef USE_POLL -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Calling poll().\n"); -#endif - nfound = poll (&filedes, 1, -1); -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Calling select() after [%ld] ms.\n", - NXTransTime()); -#endif -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the callback to detect - * the failure of the display even if we - * miss the interrupt inside the select. - */ - - if (_NXDisplayErrorFunction != NULL) { - retry.tv_sec = 5; - retry.tv_usec = 0; - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, &retry); - } else { - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL); - } -#else - nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL); -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForWritable: Out of select() with [%d] after [%ld] ms.\n", - nfound, NXTransTime()); - - if (FD_ISSET(dpy->fd, &r_mask)) - { - BytesReadable_t pend; - - _X11TransBytesReadable(dpy->trans_conn, &pend); - - fprintf(stderr, "_XWaitForWritable: Descriptor [%d] is ready with [%ld] bytes to read.\n", - dpy->fd, pend); - } - - if (FD_ISSET(dpy->fd, &w_mask)) - { - fprintf(stderr, "_XWaitForWritable: Descriptor [%d] has become writable.\n\n", - dpy->fd); - } -#endif -#endif - InternalLockDisplay(dpy, cv != NULL); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif - -#ifdef NX_TRANS_SOCKET - if (nfound <= 0) { - if ((nfound == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } - } -#else - if (nfound < 0 && !ECHECK(EINTR)) - _XIOError(dpy); -#endif - } 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) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return; - } -#else - _XIOError(dpy); -#endif - 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; - } - } -} - - -#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 -} - -/* 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 - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return -1; - } -#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 -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Calling poll().\n"); -#endif - result = poll(filedes, - (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length, - -1); -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Calling select().\n"); -#endif -#ifdef NX_TRANS_SOCKET - /* - * Give a chance to the registered application - * to perform any needed operation. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XWaitForReadable: WAIT! Waiting for the display to become readable.\n"); -#endif - NXTransFlush(dpy->fd); - - if (_NXDisplayBlockFunction != NULL) { - (*_NXDisplayBlockFunction)(dpy, NXBlockRead); - } - - if (_NXDisplayErrorFunction != NULL) { - retry.tv_sec = 5; - retry.tv_usec = 0; - result = Select(highest_fd + 1, &r_mask, NULL, NULL, &retry); - } else { - result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL); - } -#else - result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL); -#endif -#endif -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XWaitForReadable: Out of select with result [%d] and errno [%d].\n", - result, (result < 0 ? errno : 0)); -#endif - InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#ifdef NX_TRANS_SOCKET - if (result <= 0) { - if ((result == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return -1; - } - continue; - } -#else - if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy); - if (result <= 0) - continue; -#endif -#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; -} - -static -int _XSeqSyncFunction( - register Display *dpy) -{ - xGetInputFocusReply rep; - register xReq *req; - -#ifdef NX_TRANS_SOCKET -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XSeqSyncFunction: Going to synchronize the display.\n"); -#endif - if (dpy->flags & XlibDisplayIOError) - { -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XSeqSyncFunction: Returning 0 with I/O error detected.\n"); -#endif - return 0; - } -#endif - - LockDisplay(dpy); - if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { - GetEmptyReq(GetInputFocus, req); - (void) _XReply (dpy, (xReply *)&rep, 0, xTrue); - } - /* could get XID handler while waiting for reply in MT env */ - if (dpy->synchandler == _XSeqSyncFunction) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -#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; -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XFlushInt: Entering flush with [%d] bytes to write.\n", - (dpy->bufptr - dpy->buffer)); -#endif - /* 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) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XFlushInt: Returning with I/O error detected.\n"); -#endif - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *)&_dummy_request; - return; - } - -#ifdef XTHREADS -#ifdef NX_TRANS_SOCKET - while (dpy->flags & XlibDisplayWriting) { - if (_XGetIOError(dpy)) { - return; - } -#else - while (dpy->flags & XlibDisplayWriting) { -#endif - 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) { -#ifdef NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, write_stat); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - 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 -#ifdef NX_TRANS_SOCKET - } else if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - } else if (!ECHECK(EINTR)) { - /* Write failed! */ - /* errno set by write system call. */ - _XIOError(dpy); - } -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } - dpy->last_req = (char *)&_dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - 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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - if (dpy->flags & XlibDisplayIOError) { - fprintf(stderr, "_XEventsQueued: Returning [%d] after display failure.\n", - dpy->qlen); - } -#endif - 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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Checking bytes readable.\n"); -#endif - if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return (dpy->qlen); - } -#else - _XIOError(dpy); -#endif -#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 -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Calling poll().\n"); -#endif - filedes.fd = dpy->fd; - filedes.events = POLLIN; - if ((result = poll(&filedes, 1, 0))) -#else -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Calling select().\n"); -#endif - 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) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return (dpy->qlen); - } -#else - _XIOError(dpy); -#endif - /* we should not get zero, if we do, force a read */ - if (!pend) - pend = SIZEOF(xReply); - } -#ifdef NX_TRANS_SOCKET - if (result <= 0) { - if ((result == -1 && !ECHECK(EINTR)) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return (dpy->qlen); - } - } -#else - else if (result < 0 && !ECHECK(EINTR)) - _XIOError(dpy); -#endif - } - } -#endif /* XCONN_CHECK_FREQ */ - if (!(len = pend)) { - /* _XFlush can enqueue events */ -#ifdef XTHREADS - if (cvl) -#endif - { - UnlockNextEventReader(dpy); - } - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEventsQueued: Returning [%d].\n", dpy->qlen); -#endif - 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 NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return(dpy->qlen); - } -#endif -#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) -#ifdef NX_TRANS_SOCKET - { - _XIOError(dpy); - - return; - } -#else - _XIOError(dpy); -#endif - 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; -#ifdef NX_TRANS_SOCKET - if (dpy->flags & XlibDisplayIOError) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReadEvents: Returning with I/O error detected.\n"); -#endif - return; - } -#endif - 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 */ - _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - - if ((dpy->flags & XlibDisplayIOError) || size == 0) - return 0; - ESET(0); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - while (1) { - /* - * Need to check the congestion state - * after the read so split the statement - * in multiple blocks. - */ - - bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size); - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } - if (bytes_read == size) { - break; - } -#else - while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size)) - != size) { -#endif - - 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); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return -1; -#else - _XIOError(dpy); -#endif - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ -#ifdef NX_TRANS_SOCKET - if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return -1; - } -#else - if (!ECHECK(EINTR)) - _XIOError(dpy); -#endif - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return -1; - } -#endif - } -#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; -} - -#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 */ - - -/* - * _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#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); -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - while (1) { - bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2); - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } - if (bytes_read == size) { - break; - } -#else - while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) { -#endif - - 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); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return; -#else - _XIOError(dpy); -#endif - } - - else /* bytes_read is less than 0; presumably -1 */ { - /* If it's a system call interrupt, it's not an error. */ -#ifdef NX_TRANS_SOCKET - if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - if (!ECHECK(EINTR)) - _XIOError(dpy); -#endif - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } -#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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_CHANGE) - int congestion; -#endif - -#ifdef NX_TRANS_SOCKET -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XSend: Sending data with [%d] bytes to write.\n", - (dpy->bufptr - dpy->buffer)); -#endif - if (!size || (dpy->flags & XlibDisplayIOError)) - { - if (dpy->flags & XlibDisplayIOError) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XSend: Returning with I/O error detected.\n"); -#endif - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *)&_dummy_request; - } - - return; - } -#else - if (!size || (dpy->flags & XlibDisplayIOError)) return; -#endif - 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) { -#ifdef NX_TRANS_SOCKET - if (_NXDisplayWriteFunction != NULL) { - (*_NXDisplayWriteFunction)(dpy, len); - } -#ifdef NX_TRANS_CHANGE - if (_NXDisplayCongestionFunction != NULL && - _X11TransSocketCongestionChange(dpy->trans_conn, &congestion) == 1) { - (*_NXDisplayCongestionFunction)(dpy, congestion); - } -#endif -#endif - 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 -#ifdef NX_TRANS_SOCKET - } else if (!ECHECK(EINTR) || - (_NXDisplayErrorFunction != NULL && - (*_NXDisplayErrorFunction)(dpy, _XGetIOError(dpy)))) { - _XIOError(dpy); - return; - } -#else - } else if (!ECHECK(EINTR)) { - _XIOError(dpy); - } -#endif -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - return; - } -#endif - } - dpy->last_req = (char *) & _dummy_request; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - 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; - } -} - -static int -_XIDHandler( - register Display *dpy) -{ - xXCMiscGetXIDRangeReply grep; - register xXCMiscGetXIDRangeReq *greq; - - LockDisplay(dpy); - _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; - } - } - if (dpy->flags & XlibDisplayPrivSync) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - 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) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - 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) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - } - } - for (i = grep.count; i < count; i++) - ids[i] = XAllocID(dpy); -} - -/* - * 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) { - -#ifdef NX_TRANS_SOCKET - - if (_NXLostSequenceFunction != NULL) - { - (*_NXLostSequenceFunction)(dpy, newseq, dpy->request, - (unsigned int) rep->type); - } - else - { - (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, - (unsigned int) rep->type); - } - -#else /* #ifdef NX_TRANS_SOCKET */ - - (void) fprintf (stderr, - "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n", - newseq, dpy->request, - (unsigned int) rep->type); - -#endif /* #ifdef NX_TRANS_SOCKET */ - - newseq -= 0x10000; - } - } - - dpy->last_request_read = newseq; - return(newseq); -} - -/* - * _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 defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReply: Going to wait for an X reply.\n"); -#endif - -#ifdef NX_TRANS_SOCKET - if (dpy->flags & XlibDisplayIOError) - { -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "_XReply: Returning 0 with I/O error detected.\n"); -#endif - return 0; - } -#else - if (dpy->flags & XlibDisplayIOError) - return 0; -#endif - -#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 - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XReply: Going to flush the display buffer.\n"); -#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 - -#ifdef NX_TRANS_SOCKET - /* - * We are going to block waiting for the remote - * X server. Be sure that the proxy has flushed - * all the data. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XReply: Requesting a flush of the NX transport.\n"); -#endif - - NXTransFlush(dpy->fd); -#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); -#ifdef NX_TRANS_SOCKET - /* - * The original code has provision - * for returning already. - */ -#endif - _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; - } -#ifdef NX_TRANS_SOCKET - if (_XGetIOError(dpy)) { - UnlockNextReplyReader(dpy); - return 0; - } -#endif - } -} - -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)) { -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _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)) - { -#ifdef NX_TRANS_SOCKET - - /* - * The original code has provision - * for returning already. - */ - -#endif - _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; -} - -/* - * 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XRegisterInternalConnection: Got called.\n"); -#endif - - 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XUnregisterInternalConnection: Got called.\n"); -#endif - - 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XInternalConnectionNumbers: Got called.\n"); -#endif - - 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; -} - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info) -{ - dpy->flags |= XlibDisplayProcConni; -#ifdef XTHREADS - 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 */ - UnlockDisplay(dpy); - (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data); - LockDisplay(dpy); -#ifdef XTHREADS - if (dpy->lock) - xthread_clear_id(dpy->lock->conni_thread); -#endif /* XTHREADS */ - 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XProcessInternalConnection: Got called.\n"); -#endif - - 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XAddConnectionWatch: Got called.\n"); -#endif - - 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; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "XRemoveConnectionWatch: Got called.\n"); -#endif - - 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 */ - - -/* Read and discard "n" 8-bit bytes of data */ - -void _XEatData( - Display *dpy, - register unsigned long n) -{ -#define SCRATCHSIZE 2048 - char buf[SCRATCHSIZE]; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_DEBUG) - fprintf(stderr, "_XEatData: Going to eat [%ld] bytes of data from descriptor [%d].\n", - n, dpy->fd); -#endif - while (n > 0) { - register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n; - (void) _XRead (dpy, buf, bytes_read); - n -= bytes_read; - } -#undef SCRATCHSIZE -} - - -/* - * _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; - - 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); -#ifdef NX_TRANS_SOCKET - _XIOError(dpy); - - return; -#else - _XIOError(dpy); -#endif - } - qelt->next = NULL; - /* go call through display to find proper event reformatter */ - if ((*dpy->event_vec[event->u.u.type & 0177])(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--; -} - -/* - * 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); -} - -/*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)); - - } -#ifdef NX_TRANS_SOCKET - if (_NXHandleDisplayError == 1) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XDefaultIOError: Going to return from the error handler.\n"); -#endif - return 0; - } - else - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XDefaultIOError: Going to exit from the program.\n"); -#endif -#ifdef NX_TRANS_EXIT - NXTransExit(1); -#else - exit(1); -#endif - } -#else - exit(1); -#endif /* #ifdef NX_TRANS_SOCKET */ - - 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]; - 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, he, we) - 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; -#ifdef XTHREADS - if (dpy->lock) - (*dpy->lock->user_lock_display)(dpy); - UnlockDisplay(dpy); -#endif /* XTHREADS */ - rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */ -#ifdef XTHREADS - LockDisplay(dpy); - if (dpy->lock) - (*dpy->lock->user_unlock_display)(dpy); -#endif /* XTHREADS */ - 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 - - if (_XIOErrorFunction != NULL) - (*_XIOErrorFunction)(dpy); - else - _XDefaultIOError(dpy); -#ifdef NX_TRANS_SOCKET - /* - * Check if we are supposed to return in the case - * of a display failure. The client which originated - * the X operation will have to check the value of - * the XlibDisplayIOError flag and handle appropria- - * tely the display disconnection. - */ - - if (_NXHandleDisplayError == 0) - { -#ifdef NX_TRANS_EXIT - NXTransExit(1); -#else - exit(1); -#endif - } - - /* - * We are going to return. Reset the display - * buffers. Further writes will be discarded. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display buffer.\n"); -#endif - - dpy->bufptr = dpy->buffer; - dpy->last_req = (char *) &_dummy_request; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_XIOError: Resetting the display flags.\n"); -#endif - - dpy->flags &= ~XlibDisplayProcConni; - dpy->flags &= ~XlibDisplayPrivSync; - dpy->flags &= ~XlibDisplayReadEvents; - dpy->flags &= ~XlibDisplayWriting; - dpy->flags &= ~XlibDisplayReply; -#else - exit (1); -#endif - 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(USG) || 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 (dpy, w) - 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 None; - } - 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; -} - -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/nx-X11/lib/X11/XlibInt.c.X.original b/nx-X11/lib/X11/XlibInt.c.X.original deleted file mode 100644 index c042eb2e4..000000000 --- a/nx-X11/lib/X11/XlibInt.c.X.original +++ /dev/null @@ -1,3429 +0,0 @@ -/* $Xorg: XlibInt.c,v 1.8 2001/02/09 02:03:38 xorgcvs Exp $ */ -/* - -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. - -*/ -/* $XFree86: xc/lib/X11/XlibInt.c,v 3.38 2003/10/30 21:55:05 alanh Exp $ */ - -/* - * 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_ -#endif -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xlibint.h" -#include <X11/Xpoll.h> -#include <X11/Xtrans/Xtrans.h> -#include <X11/extensions/xcmiscstr.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)()) - -#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 - -#else /* XTHREADS else */ - -#define UnlockNextReplyReader(d) -#define UnlockNextEventReader(d) -#define InternalLockDisplay(d,wskip) - -#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 -#ifdef ISC -#define ECHECK(err) ((errno == err) || ETEST()) -#else -#define ECHECK(err) (errno == err) -#endif -#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__ -#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t) -#include <limits.h> -#define MAX_PATH _POSIX_PATH_MAX -#endif - -#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); - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info); - -#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10) - -/* - * 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. - */ - -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)) - _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; - } - } -} - - -#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 -} - -/* 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)) _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; -} - -static -int _XSeqSyncFunction( - register Display *dpy) -{ - xGetInputFocusReply rep; - register xReq *req; - - LockDisplay(dpy); - if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) { - GetEmptyReq(GetInputFocus, req); - (void) _XReply (dpy, (xReply *)&rep, 0, xTrue); - } - /* could get XID handler while waiting for reply in MT env */ - if (dpy->synchandler == _XSeqSyncFunction) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - SyncHandle(); - return 0; -} - -#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; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - 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)) - _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 */ - _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; -} - -#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 */ - - -/* - * _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; - if ((dpy->request - dpy->last_request_read) >= SEQLIMIT && - !(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->synchandler = _XSeqSyncFunction; - dpy->flags |= XlibDisplayPrivSync; - } - 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; - } -} - -static int -_XIDHandler( - register Display *dpy) -{ - xXCMiscGetXIDRangeReply grep; - register xXCMiscGetXIDRangeReq *greq; - - LockDisplay(dpy); - _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; - } - } - if (dpy->flags & XlibDisplayPrivSync) { - dpy->synchandler = dpy->savedsynchandler; - dpy->flags &= ~XlibDisplayPrivSync; - } - UnlockDisplay(dpy); - 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) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - 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) { - if (!(dpy->flags & XlibDisplayPrivSync)) { - dpy->savedsynchandler = dpy->synchandler; - dpy->flags |= XlibDisplayPrivSync; - } - dpy->synchandler = _XIDHandler; - dpy->resource_max = dpy->resource_mask + 1; - } - } - } - for (i = grep.count; i < count; i++) - ids[i] = XAllocID(dpy); -} - -/* - * 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); -} - -/* - * _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; -} - -/* - * 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; -} - -static void _XProcessInternalConnection( - Display *dpy, - struct _XConnectionInfo *conn_info) -{ - dpy->flags |= XlibDisplayProcConni; -#ifdef XTHREADS - 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 */ - UnlockDisplay(dpy); - (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data); - LockDisplay(dpy); -#ifdef XTHREADS - if (dpy->lock) - xthread_clear_id(dpy->lock->conni_thread); -#endif /* XTHREADS */ - 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 */ - - -/* 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 -} - - -/* - * _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; - - 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; - /* go call through display to find proper event reformatter */ - if ((*dpy->event_vec[event->u.u.type & 0177])(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--; -} - -/* - * 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); -} - -/*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]; - 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, he, we) - 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; -#ifdef XTHREADS - if (dpy->lock) - (*dpy->lock->user_lock_display)(dpy); - UnlockDisplay(dpy); -#endif /* XTHREADS */ - rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */ -#ifdef XTHREADS - LockDisplay(dpy); - if (dpy->lock) - (*dpy->lock->user_unlock_display)(dpy); -#endif /* XTHREADS */ - 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 - - 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(USG) || 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 (dpy, w) - 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 None; - } - 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; -} - -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/nx-X11/lib/X11/Xlibint.h.NX.original b/nx-X11/lib/X11/Xlibint.h.NX.original deleted file mode 100644 index 56da2349b..000000000 --- a/nx-X11/lib/X11/Xlibint.h.NX.original +++ /dev/null @@ -1,1346 +0,0 @@ -/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */ - -/* - -Copyright 1984, 1985, 1987, 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. - -*/ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */ - -#ifndef _XLIBINT_H_ -#define _XLIBINT_H_ 1 - -/* - * Xlibint.h - Header definition and support file for the internal - * support routines used by the C subroutine interface - * library (Xlib) to the X Window System. - * - * Warning, there be dragons here.... - */ - -#include <X11/Xlib.h> -#include <X11/Xproto.h> /* to declare xEvent */ -#include <X11/XlibConf.h> /* for configured options like XTHREADS */ - -#ifdef NX_TRANS_SOCKET - -#include "NXvars.h" - -#define _XGetIOError(dpy) \ - (dpy -> flags & XlibDisplayIOError) - -#endif - -#ifdef WIN32 -#define _XFlush _XFlushIt -#endif - -/* - * If your BytesReadable correctly detects broken connections, then - * you should NOT define XCONN_CHECK_FREQ. - */ -#ifndef XCONN_CHECK_FREQ -#define XCONN_CHECK_FREQ 256 -#endif - -struct _XGC -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - Bool rects; /* boolean: TRUE if clipmask is list of rectangles */ - Bool dashes; /* boolean: TRUE if dash-list is really a list */ - unsigned long dirty;/* cache dirty bits */ - XGCValues values; /* shadow structure of values */ -}; - -struct _XDisplay -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XFreeFuncs *free_funcs; /* internal free functions */ - int fd; /* Network socket. */ - int conn_checker; /* ugly thing used by _XEventsQueued */ - int proto_major_version;/* maj. version of server's X protocol */ - int proto_minor_version;/* minor version of server's X protocol */ - char *vendor; /* vendor of the server hardware */ - XID resource_base; /* resource ID base */ - XID resource_mask; /* resource ID mask bits */ - XID resource_id; /* allocator current ID */ - int resource_shift; /* allocator shift to correct bits */ - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int vnumber; /* Xlib's X protocol version number. */ - int release; /* release of the server */ - struct _XSQEvent *head, *tail; /* Input event queue. */ - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - char *last_req; /* beginning of last request, or dummy */ - char *buffer; /* Output buffer starting address. */ - char *bufptr; /* Output buffer index pointer. */ - char *bufmax; /* Output buffer maximum+1 address. */ - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*synchandler)( /* Synchronization handler */ - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long flags; /* internal connection flags */ - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - KeySym *keysyms; /* This server's keysyms */ - XModifierKeymap *modifiermap; /* This server's modifier keymap */ - int keysyms_per_keycode;/* number of rows */ - char *xdefaults; /* contents of defaults from server */ - char *scratch_buffer; /* place to hang scratch buffer */ - unsigned long scratch_length; /* length of scratch buffer */ - int ext_number; /* extension number on this display */ - struct _XExten *ext_procs; /* extensions initialized on this display */ - /* - * the following can be fixed size, as the protocol defines how - * much address space is available. - * While this could be done using the extension vector, there - * may be MANY events processed, so a search through the extension - * list to find the right procedure for each event might be - * expensive if many extensions are being used. - */ - Bool (*event_vec[128])( /* vector for wire to event */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - Status (*wire_vec[128])( /* vector for event to wire */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - KeySym lock_meaning; /* for XLookupString */ - struct _XLockInfo *lock; /* multi-thread state, display lock */ - struct _XInternalAsync *async_handlers; /* for internal async */ - unsigned long bigreq_size; /* max size of big requests */ - struct _XLockPtrs *lock_fns; /* pointers to threads functions */ - void (*idlist_alloc)( /* XID list allocator function */ - Display * /* dpy */, - XID * /* ids */, - int /* count */ - ); - /* things above this line should not move, for binary compatibility */ - struct _XKeytrans *key_bindings; /* for XLookupString */ - Font cursor_font; /* for XCreateFontCursor */ - struct _XDisplayAtoms *atoms; /* for XInternAtom */ - unsigned int mode_switch; /* keyboard group modifiers */ - unsigned int num_lock; /* keyboard numlock modifiers */ - struct _XContextDB *context_db; /* context database */ - Bool (**error_vec)( /* vector for wire to error */ - Display * /* display */, - XErrorEvent * /* he */, - xError * /* we */ - ); - /* - * Xcms information - */ - struct { - XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */ - XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */ - XPointer perVisualIntensityMaps; - /* linked list of XcmsIntensityMap */ - } cms; - struct _XIMFilter *im_filters; - struct _XSQEvent *qfree; /* unallocated event queue elements */ - unsigned long next_event_serial_num; /* inserted into next queue elt */ - struct _XExten *flushes; /* Flush hooks */ - struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */ - int im_fd_length; /* number of im_fd_info */ - struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */ - int watcher_count; /* number of conn_watchers */ - XPointer filedes; /* struct pollfd cache for _XWaitForReadable */ - int (*savedsynchandler)( /* user synchandler when Xlib usurps */ - Display * /* dpy */ - ); - XID resource_max; /* allocator max ID */ - int xcmisc_opcode; /* major opcode for XC-MISC */ - struct _XkbInfoRec *xkb_info; /* XKB info */ - struct _XtransConnInfo *trans_conn; /* transport connection object */ -}; - -#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n) - -/* - * define the following if you want the Data macro to be a procedure instead - */ -#ifdef CRAY -#define DataRoutineIsProcedure -#endif /* CRAY */ - -#ifndef _XEVENT_ -/* - * _QEvent datatype for use in input queueing. - */ -typedef struct _XSQEvent -{ - struct _XSQEvent *next; - XEvent event; - unsigned long qserial_num; /* so multi-threaded code can find new ones */ -} _XQEvent; -#endif - -#ifdef XTHREADS /* for xReply */ -#define NEED_REPLIES -#endif - -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#ifdef __sgi -#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */ -#endif -#include <errno.h> -#define _XBCOPYFUNC _Xbcopy -#include <X11/Xfuncs.h> -#include <X11/Xosdefs.h> - -/* Utek leaves kernel macros around in include files (bleah) */ -#ifdef dirty -#undef dirty -#endif - -#include <stdlib.h> -#include <string.h> - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -/* - * The following definitions can be used for locking requests in multi-threaded - * address spaces. - */ -#ifdef XTHREADS -/* Author: Stephen Gildea, MIT X Consortium - * - * declarations for C Threads locking - */ - -typedef struct _LockInfoRec *LockInfoPtr; - -/* interfaces for locking.c */ -struct _XLockPtrs { - /* used by all, including extensions; do not move */ - void (*lock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); - void (*unlock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); -}; - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _XCreateMutex_fn (*_XCreateMutex_fn_p) -#define _XFreeMutex_fn (*_XFreeMutex_fn_p) -#define _XLockMutex_fn (*_XLockMutex_fn_p) -#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p) -#define _Xglobal_lock (*_Xglobal_lock_p) -#endif - -/* in XlibInt.c */ -extern void (*_XCreateMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XFreeMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); -extern void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); - -extern LockInfoPtr _Xglobal_lock; - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__) -#else -/* used everywhere, so must be fast if not using threads */ -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock) -#endif -#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock); -#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock); - -#else /* XTHREADS */ -#define LockDisplay(dis) -#define _XLockMutex(lock) -#define _XUnlockMutex(lock) -#define UnlockDisplay(dis) -#define _XCreateMutex(lock) -#define _XFreeMutex(lock) -#endif - -#define Xfree(ptr) free((ptr)) - -/* - * Note that some machines do not return a valid pointer for malloc(0), in - * which case we provide an alternate under the control of the - * define MALLOC_0_RETURNS_NULL. This is necessary because some - * Xlib code expects malloc(0) to return a valid pointer to storage. - */ -#ifdef MALLOC_0_RETURNS_NULL - -# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size))) -# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size))) -# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize)) - -#else - -# define Xmalloc(size) malloc((size)) -# define Xrealloc(ptr, size) realloc((ptr), (size)) -# define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) - -#endif - -#include <stddef.h> - -#define LOCKED 1 -#define UNLOCKED 0 - -#ifdef NX_TRANS_SOCKET -#ifndef BUFSIZE /* Output buffer size is configurable */ -#define BUFSIZE 8192 /* but this is still used for reading. */ -#endif -#else -#ifndef BUFSIZE -#define BUFSIZE 2048 /* X output buffer size. */ -#endif -#endif -#ifndef PTSPERBATCH -#define PTSPERBATCH 1024 /* point batching */ -#endif -#ifndef WLNSPERBATCH -#define WLNSPERBATCH 50 /* wide line batching */ -#endif -#ifndef ZLNSPERBATCH -#define ZLNSPERBATCH 1024 /* thin line batching */ -#endif -#ifndef WRCTSPERBATCH -#define WRCTSPERBATCH 10 /* wide line rectangle batching */ -#endif -#ifndef ZRCTSPERBATCH -#define ZRCTSPERBATCH 256 /* thin line rectangle batching */ -#endif -#ifndef FRCTSPERBATCH -#define FRCTSPERBATCH 256 /* filled rectangle batching */ -#endif -#ifndef FARCSPERBATCH -#define FARCSPERBATCH 256 /* filled arc batching */ -#endif -#ifndef CURSORFONT -#define CURSORFONT "cursor" /* standard cursor fonts */ -#endif - -/* - * Display flags - */ -#define XlibDisplayIOError (1L << 0) -#define XlibDisplayClosing (1L << 1) -#define XlibDisplayNoXkb (1L << 2) -#define XlibDisplayPrivSync (1L << 3) -#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */ -#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */ -#define XlibDisplayReply (1L << 5) /* in _XReply */ -#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */ -#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */ - -/* - * X Protocol packetizing macros. - */ - -/* Need to start requests on 64 bit word boundaries - * on a CRAY computer so add a NoOp (127) if needed. - * A character pointer on a CRAY computer will be non-zero - * after shifting right 61 bits of it is not pointing to - * a word boundary. - */ -#ifdef WORD64 -#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\ - dpy->last_req = dpy->bufptr;\ - *(dpy->bufptr) = X_NoOperation;\ - *(dpy->bufptr+1) = 0;\ - *(dpy->bufptr+2) = 0;\ - *(dpy->bufptr+3) = 1;\ - dpy->request++;\ - dpy->bufptr += 4;\ - } -#else /* else does not require alignment on 64-bit boundaries */ -#define WORD64ALIGN -#endif /* WORD64 */ - - -/* - * GetReq - Get the next available X request packet in the buffer and - * return it. - * - * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc. - * "req" is the name of the request pointer. - * - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req))>>2;\ - dpy->bufptr += SIZEOF(x##name##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req))>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req);\ - dpy->request++ -#endif - -/* GetReqExtra is the same as GetReq, but allocates "n" additional - bytes after the request. "n" must be a multiple of 4! */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x##name##Req) + n;\ - dpy->request++ -#else -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\ - dpy->request++ -#endif - - -/* - * GetResReq is for those requests that have a resource ID - * (Window, Pixmap, GContext, etc.) as their single argument. - * "rid" is the name of the resource. - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#else -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#endif - -/* - * GetEmptyReq is for those requests that have no arguments - * at all. - */ -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#else -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#endif - -#ifdef WORD64 -#define MakeBigReq(req,n) \ - { \ - char _BRdat[4]; \ - unsigned long _BRlen = req->length - 1; \ - req->length = 0; \ - memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - memcpy(((char *)req) + 4, _BRdat, 4); \ - Data32(dpy, (long *)&_BRdat, 4); \ - } -#else -#ifdef LONG64 -#define MakeBigReq(req,n) \ - { \ - CARD64 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#else -#define MakeBigReq(req,n) \ - { \ - CARD32 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#endif -#endif - -#define SetReqLen(req,n,badlen) \ - if ((req->length + n) > (unsigned)65535) { \ - if (dpy->bigreq_size) { \ - MakeBigReq(req,n) \ - } else { \ - n = badlen; \ - req->length += n; \ - } \ - } else \ - req->length += n - -#define SyncHandle() \ - if (dpy->synchandler) (*dpy->synchandler)(dpy) - -extern void _XFlushGCCache(Display *dpy, GC gc); -#define FlushGC(dpy, gc) \ - if ((gc)->dirty) _XFlushGCCache((dpy), (gc)) -/* - * Data - Place data in the buffer and pad the end to provide - * 32 bit word alignment. Transmit if the buffer fills. - * - * "dpy" is a pointer to a Display. - * "data" is a pinter to a data buffer. - * "len" is the length of the data buffer. - */ -#ifndef DataRoutineIsProcedure -#define Data(dpy, data, 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 */ - - -/* Allocate bytes from the buffer. No padding is done, so if - * the length is not a multiple of 4, the caller must be - * careful to leave the buffer aligned after sending the - * current request. - * - * "type" is the type of the pointer being assigned to. - * "ptr" is the pointer being assigned to. - * "n" is the number of bytes to allocate. - * - * Example: - * xTextElt *elt; - * BufAlloc (xTextElt *, elt, nbytes) - */ - -#define BufAlloc(type, ptr, n) \ - if (dpy->bufptr + (n) > dpy->bufmax) \ - _XFlush (dpy); \ - ptr = (type) dpy->bufptr; \ - (void)ptr; \ - dpy->bufptr += (n); - -#ifdef WORD64 -#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len) -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -#else -#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len)) -#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#ifdef LONG64 -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -extern int _XData32( - Display *dpy, - register long *data, - unsigned len -); -extern void _XRead32( - Display *dpy, - register long *data, - long len -); -#else -#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#endif -#endif /* not WORD64 */ - -#define PackData16(dpy,data,len) Data16 (dpy, data, len) -#define PackData32(dpy,data,len) Data32 (dpy, data, len) - -/* Xlib manual is bogus */ -#define PackData(dpy,data,len) PackData16 (dpy, data, len) - -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) - -#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ - (((cs)->rbearing|(cs)->lbearing| \ - (cs)->ascent|(cs)->descent) == 0)) - -/* - * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit - * character. If the character is in the column and exists, then return the - * appropriate metrics (note that fonts with common per-character metrics will - * return min_bounds). If none of these hold true, try again with the default - * char. - */ -#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ -{ \ - cs = def; \ - if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ - CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) - - - -/* - * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and - * column. This is used for fonts that have more than row zero. - */ -#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ -{ \ - cs = def; \ - if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ - col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[((row - fs->min_byte1) * \ - (fs->max_char_or_byte2 - \ - fs->min_char_or_byte2 + 1)) + \ - (col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ -{ \ - unsigned int r = (fs->default_char >> 8); \ - unsigned int c = (fs->default_char & 0xff); \ - CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ -} - - -#ifdef MUSTCOPY - -/* for when 32-bit alignment is not good enough */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); } - -#else - -/* srcvar must be a variable for large architecture version */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { *(CARD32 *)(dstaddr) = (srcvar); } - -#endif /* MUSTCOPY */ - -typedef struct _XInternalAsync { - struct _XInternalAsync *next; - /* - * handler arguments: - * rep is the generic reply that caused this handler - * to be invoked. It must also be passed to _XGetAsyncReply. - * buf and len are opaque values that must be passed to - * _XGetAsyncReply or _XGetAsyncData. - * data is the closure stored in this struct. - * The handler returns True iff it handled this reply. - */ - Bool (*handler)( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ - ); - XPointer data; -} _XAsyncHandler; - -typedef struct _XAsyncEState { - unsigned long min_sequence_number; - unsigned long max_sequence_number; - unsigned char error_code; - unsigned char major_opcode; - unsigned short minor_opcode; - unsigned char last_error_received; - int error_count; -} _XAsyncErrorState; - -extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler); -#define DeqAsyncHandler(dpy,handler) { \ - if (dpy->async_handlers == (handler)) \ - dpy->async_handlers = (handler)->next; \ - else \ - _XDeqAsyncHandler(dpy, handler); \ - } - -typedef void (*FreeFuncType) ( - Display* /* display */ -); - -typedef int (*FreeModmapType) ( - XModifierKeymap* /* modmap */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XFreeFuncs { - FreeFuncType atoms; /* _XFreeAtomTable */ - FreeModmapType modifiermap; /* XFreeModifierMap */ - FreeFuncType key_bindings; /* _XFreeKeyBindings */ - FreeFuncType context_db; /* _XFreeContextDB */ - FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */ - FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */ - FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */ - FreeFuncType im_filters; /* _XFreeIMFilters */ - FreeFuncType xkb; /* _XkbFreeInfo */ -} _XFreeFuncRec; - -/* types for InitExt.c */ -typedef int (*CreateGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CopyGCType)( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FlushGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FreeGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CreateFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*FreeFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*CloseDisplayType) ( - Display* /* display */, - XExtCodes* /* codes */ -); - -typedef int (*ErrorType) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ -); - -typedef char* (*ErrorStringType) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ -); - -typedef void (*PrintErrorType)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ -); - -typedef void (*BeforeFlushType)( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XExten { /* private to extension mechanism */ - struct _XExten *next; /* next in list */ - XExtCodes codes; /* public information, all extension told */ - CreateGCType create_GC; /* routine to call when GC created */ - CopyGCType copy_GC; /* routine to call when GC copied */ - FlushGCType flush_GC; /* routine to call when GC flushed */ - FreeGCType free_GC; /* routine to call when GC freed */ - CreateFontType create_Font; /* routine to call when Font created */ - FreeFontType free_Font; /* routine to call when Font freed */ - CloseDisplayType close_display; /* routine to call when connection closed */ - ErrorType error; /* who to call when an error occurs */ - ErrorStringType error_string; /* routine to supply error string */ - char *name; /* name of this extension */ - PrintErrorType error_values; /* routine to supply error values */ - BeforeFlushType before_flush; /* routine to call when sending data */ - struct _XExten *next_flush; /* next in list of those with flushes */ -} _XExtension; - -/* extension hooks */ - -#ifdef DataRoutineIsProcedure -extern void Data(Display *dpy, char *data, long len); -#endif -extern int _XError( - Display* /* dpy */, - xError* /* rep */ -); -extern int _XIOError( - Display* /* dpy */ -); -extern int (*_XIOErrorFunction)( - Display* /* dpy */ -); -extern int (*_XErrorFunction)( - Display* /* dpy */, - XErrorEvent* /* error_event */ -); -extern void _XEatData( - Display* /* dpy */, - unsigned long /* n */ -); -extern char *_XAllocScratch( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern char *_XAllocTemp( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern void _XFreeTemp( - Display* /* dpy */, - char* /* buf */, - unsigned long /* nbytes */ -); -extern Visual *_XVIDtoVisual( - Display* /* dpy */, - VisualID /* id */ -); -extern unsigned long _XSetLastRequestRead( - Display* /* dpy */, - xGenericReply* /* rep */ -); -extern int _XGetHostname( - char* /* buf */, - int /* maxlen */ -); -extern Screen *_XScreenOfWindow( - Display* /* dpy */, - Window /* w */ -); -extern Bool _XAsyncErrorHandler( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ -); -extern char *_XGetAsyncReply( - Display* /* dpy */, - char* /* replbuf */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - int /* extra */, - Bool /* discard */ -); -extern void _XGetAsyncData( - Display* /* dpy */, - char * /* data */, - char * /* buf */, - int /* len */, - int /* skip */, - int /* datalen */, - int /* discardtotal */ -); -extern void _XFlush( - Display* /* dpy */ -); -extern int _XEventsQueued( - Display* /* dpy */, - int /* mode */ -); -extern void _XReadEvents( - Display* /* dpy */ -); -extern int _XRead( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XReadPad( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XSend( - Display* /* dpy */, - _Xconst char* /* data */, - long /* size */ -); -extern Status _XReply( - Display* /* dpy */, - xReply* /* rep */, - int /* extra */, - Bool /* discard */ -); -extern void _XEnq( - Display* /* dpy */, - xEvent* /* event */ -); -extern void _XDeq( - Display* /* dpy */, - _XQEvent* /* prev */, - _XQEvent* /* qelt */ -); - -extern Bool _XUnknownWireEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); -extern Status _XUnknownNativeEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); - -extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event); -extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we); -extern Bool _XPollfdCacheInit(Display *dpy); -extern void _XPollfdCacheAdd(Display *dpy, int fd); -extern void _XPollfdCacheDel(Display *dpy, int fd); -extern XID _XAllocID(Display *dpy); -extern void _XAllocIDs(Display *dpy, XID *ids, int count); - -extern int _XFreeExtData( - XExtData* /* extension */ -); - -extern int (*XESetCreateGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCopyGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFlushGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFreeGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCreateFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetFreeFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetCloseDisplay( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XExtCodes* -); - -extern int (*XESetError( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ - ) /* proc */ -))( - Display*, xError*, XExtCodes*, int* -); - -extern char* (*XESetErrorString( - Display* /* display */, - int /* extension */, - char* (*) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ - ) /* proc */ -))( - Display*, int, XExtCodes*, char*, int -); - -extern void (*XESetPrintErrorValues ( - Display* /* display */, - int /* extension */, - void (*)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ - ) /* proc */ -))( - Display*, XErrorEvent*, void* -); - -extern Bool (*XESetWireToEvent( - Display* /* display */, - int /* event_number */, - Bool (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Status (*XESetEventToWire( - Display* /* display */, - int /* event_number */, - Status (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Bool (*XESetWireToError( - Display* /* display */, - int /* error_number */, - Bool (*) ( - Display* /* display */, - XErrorEvent* /* he */, - xError* /* we */ - ) /* proc */ -))( - Display*, XErrorEvent*, xError* -); - -extern void (*XESetBeforeFlush( - Display* /* display */, - int /* error_number */, - void (*) ( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ - ) /* proc */ -))( - Display*, XExtCodes*, _Xconst char*, long -); - -/* internal connections for IMs */ - -typedef void (*_XInternalConnectionProc)( - Display* /* dpy */, - int /* fd */, - XPointer /* call_data */ -); - - -extern Status _XRegisterInternalConnection( - Display* /* dpy */, - int /* fd */, - _XInternalConnectionProc /* callback */, - XPointer /* call_data */ -); - -extern void _XUnregisterInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -/* Display structure has pointers to these */ - -struct _XConnectionInfo { /* info from _XRegisterInternalConnection */ - int fd; - _XInternalConnectionProc read_callback; - XPointer call_data; - XPointer *watch_data; /* set/used by XConnectionWatchProc */ - struct _XConnectionInfo *next; -}; - -struct _XConnWatchInfo { /* info from XAddConnectionWatch */ - XConnectionWatchProc fn; - XPointer client_data; - struct _XConnWatchInfo *next; -}; - -#ifdef __UNIXOS2__ -extern char* __XOS2RedirRoot( - char* -); -#endif - -extern int _XTextHeight( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int _XTextHeight16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -#if defined(WIN32) - -extern int _XOpenFile( - _Xconst char* /* path */, - int /* flags */ -); - -extern void* _XFopenFile( - _Xconst char* /* path */, - _Xconst char* /* mode */ -); - -extern int _XAccessFile( - _Xconst char* /* path */ -); -#else -#define _XOpenFile(path,flags) open(path,flags) -#define _XFopenFile(path,mode) fopen(path,mode) -#endif - -/* EvToWire.c */ -extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event); - -extern int _XF86LoadQueryLocaleFont( - Display* /* dpy */, - _Xconst char* /* name*/, - XFontStruct** /* xfp*/, - Font* /* fidp */ -); - -extern void _XProcessWindowAttributes ( - register Display *dpy, - xChangeWindowAttributesReq *req, - register unsigned long valuemask, - register XSetWindowAttributes *attributes); - -extern int _XDefaultError( - Display *dpy, - XErrorEvent *event); - -extern int _XDefaultIOError( - Display *dpy); - -extern void _XSetClipRectangles ( - register Display *dpy, - GC gc, - int clip_x_origin, int clip_y_origin, - XRectangle *rectangles, - int n, - int ordering); - -Status _XGetWindowAttributes( - register Display *dpy, - Window w, - XWindowAttributes *attr); - -int _XPutBackEvent ( - register Display *dpy, - register XEvent *event); - -_XFUNCPROTOEND - -#endif /* _XLIBINT_H_ */ diff --git a/nx-X11/lib/X11/Xlibint.h.X.original b/nx-X11/lib/X11/Xlibint.h.X.original deleted file mode 100644 index 8517f6539..000000000 --- a/nx-X11/lib/X11/Xlibint.h.X.original +++ /dev/null @@ -1,1313 +0,0 @@ -/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */ - -/* - -Copyright 1984, 1985, 1987, 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. - -*/ -/* $XFree86: xc/lib/X11/Xlibint.h,v 3.27 2003/05/27 22:26:26 tsi Exp $ */ - -#ifndef _XLIBINT_H_ -#define _XLIBINT_H_ 1 - -/* - * Xlibint.h - Header definition and support file for the internal - * support routines used by the C subroutine interface - * library (Xlib) to the X Window System. - * - * Warning, there be dragons here.... - */ - -#include <X11/Xlib.h> -#include <X11/Xproto.h> /* to declare xEvent */ -#include <X11/XlibConf.h> /* for configured options like XTHREADS */ - -#ifdef WIN32 -#define _XFlush _XFlushIt -#endif - -/* - * If your BytesReadable correctly detects broken connections, then - * you should NOT define XCONN_CHECK_FREQ. - */ -#ifndef XCONN_CHECK_FREQ -#define XCONN_CHECK_FREQ 256 -#endif - -struct _XGC -{ - XExtData *ext_data; /* hook for extension to hang data */ - GContext gid; /* protocol ID for graphics context */ - Bool rects; /* boolean: TRUE if clipmask is list of rectangles */ - Bool dashes; /* boolean: TRUE if dash-list is really a list */ - unsigned long dirty;/* cache dirty bits */ - XGCValues values; /* shadow structure of values */ -}; - -struct _XDisplay -{ - XExtData *ext_data; /* hook for extension to hang data */ - struct _XFreeFuncs *free_funcs; /* internal free functions */ - int fd; /* Network socket. */ - int conn_checker; /* ugly thing used by _XEventsQueued */ - int proto_major_version;/* maj. version of server's X protocol */ - int proto_minor_version;/* minor version of server's X protocol */ - char *vendor; /* vendor of the server hardware */ - XID resource_base; /* resource ID base */ - XID resource_mask; /* resource ID mask bits */ - XID resource_id; /* allocator current ID */ - int resource_shift; /* allocator shift to correct bits */ - XID (*resource_alloc)( /* allocator function */ - struct _XDisplay* - ); - int byte_order; /* screen byte order, LSBFirst, MSBFirst */ - int bitmap_unit; /* padding and data requirements */ - int bitmap_pad; /* padding requirements on bitmaps */ - int bitmap_bit_order; /* LeastSignificant or MostSignificant */ - int nformats; /* number of pixmap formats in list */ - ScreenFormat *pixmap_format; /* pixmap format list */ - int vnumber; /* Xlib's X protocol version number. */ - int release; /* release of the server */ - struct _XSQEvent *head, *tail; /* Input event queue. */ - int qlen; /* Length of input event queue */ - unsigned long last_request_read; /* seq number of last event read */ - unsigned long request; /* sequence number of last request. */ - char *last_req; /* beginning of last request, or dummy */ - char *buffer; /* Output buffer starting address. */ - char *bufptr; /* Output buffer index pointer. */ - char *bufmax; /* Output buffer maximum+1 address. */ - unsigned max_request_size; /* maximum number 32 bit words in request*/ - struct _XrmHashBucketRec *db; - int (*synchandler)( /* Synchronization handler */ - struct _XDisplay* - ); - char *display_name; /* "host:display" string used on this connect*/ - int default_screen; /* default screen for operations */ - int nscreens; /* number of screens on this server*/ - Screen *screens; /* pointer to list of screens */ - unsigned long motion_buffer; /* size of motion buffer */ - unsigned long flags; /* internal connection flags */ - int min_keycode; /* minimum defined keycode */ - int max_keycode; /* maximum defined keycode */ - KeySym *keysyms; /* This server's keysyms */ - XModifierKeymap *modifiermap; /* This server's modifier keymap */ - int keysyms_per_keycode;/* number of rows */ - char *xdefaults; /* contents of defaults from server */ - char *scratch_buffer; /* place to hang scratch buffer */ - unsigned long scratch_length; /* length of scratch buffer */ - int ext_number; /* extension number on this display */ - struct _XExten *ext_procs; /* extensions initialized on this display */ - /* - * the following can be fixed size, as the protocol defines how - * much address space is available. - * While this could be done using the extension vector, there - * may be MANY events processed, so a search through the extension - * list to find the right procedure for each event might be - * expensive if many extensions are being used. - */ - Bool (*event_vec[128])( /* vector for wire to event */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - Status (*wire_vec[128])( /* vector for event to wire */ - Display * /* dpy */, - XEvent * /* re */, - xEvent * /* event */ - ); - KeySym lock_meaning; /* for XLookupString */ - struct _XLockInfo *lock; /* multi-thread state, display lock */ - struct _XInternalAsync *async_handlers; /* for internal async */ - unsigned long bigreq_size; /* max size of big requests */ - struct _XLockPtrs *lock_fns; /* pointers to threads functions */ - void (*idlist_alloc)( /* XID list allocator function */ - Display * /* dpy */, - XID * /* ids */, - int /* count */ - ); - /* things above this line should not move, for binary compatibility */ - struct _XKeytrans *key_bindings; /* for XLookupString */ - Font cursor_font; /* for XCreateFontCursor */ - struct _XDisplayAtoms *atoms; /* for XInternAtom */ - unsigned int mode_switch; /* keyboard group modifiers */ - unsigned int num_lock; /* keyboard numlock modifiers */ - struct _XContextDB *context_db; /* context database */ - Bool (**error_vec)( /* vector for wire to error */ - Display * /* display */, - XErrorEvent * /* he */, - xError * /* we */ - ); - /* - * Xcms information - */ - struct { - XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */ - XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */ - XPointer perVisualIntensityMaps; - /* linked list of XcmsIntensityMap */ - } cms; - struct _XIMFilter *im_filters; - struct _XSQEvent *qfree; /* unallocated event queue elements */ - unsigned long next_event_serial_num; /* inserted into next queue elt */ - struct _XExten *flushes; /* Flush hooks */ - struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */ - int im_fd_length; /* number of im_fd_info */ - struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */ - int watcher_count; /* number of conn_watchers */ - XPointer filedes; /* struct pollfd cache for _XWaitForReadable */ - int (*savedsynchandler)( /* user synchandler when Xlib usurps */ - Display * /* dpy */ - ); - XID resource_max; /* allocator max ID */ - int xcmisc_opcode; /* major opcode for XC-MISC */ - struct _XkbInfoRec *xkb_info; /* XKB info */ - struct _XtransConnInfo *trans_conn; /* transport connection object */ -}; - -#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n) - -/* - * define the following if you want the Data macro to be a procedure instead - */ -#ifdef CRAY -#define DataRoutineIsProcedure -#endif /* CRAY */ - -#ifndef _XEVENT_ -/* - * _QEvent datatype for use in input queueing. - */ -typedef struct _XSQEvent -{ - struct _XSQEvent *next; - XEvent event; - unsigned long qserial_num; /* so multi-threaded code can find new ones */ -} _XQEvent; -#endif - -#ifdef XTHREADS /* for xReply */ -#define NEED_REPLIES -#endif - -#define NEED_EVENTS -#define NEED_REPLIES -#include <X11/Xproto.h> -#ifdef __sgi -#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */ -#endif -#include <errno.h> -#define _XBCOPYFUNC _Xbcopy -#include <X11/Xfuncs.h> -#include <X11/Xosdefs.h> - -/* Utek leaves kernel macros around in include files (bleah) */ -#ifdef dirty -#undef dirty -#endif - -#include <stdlib.h> -#include <string.h> - -#include <X11/Xfuncproto.h> - -_XFUNCPROTOBEGIN - -/* - * The following definitions can be used for locking requests in multi-threaded - * address spaces. - */ -#ifdef XTHREADS -/* Author: Stephen Gildea, MIT X Consortium - * - * declarations for C Threads locking - */ - -typedef struct _LockInfoRec *LockInfoPtr; - -/* interfaces for locking.c */ -struct _XLockPtrs { - /* used by all, including extensions; do not move */ - void (*lock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); - void (*unlock_display)( - Display *dpy -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char *file - , int line -#endif - ); -}; - -#if defined(WIN32) && !defined(_XLIBINT_) -#define _XCreateMutex_fn (*_XCreateMutex_fn_p) -#define _XFreeMutex_fn (*_XFreeMutex_fn_p) -#define _XLockMutex_fn (*_XLockMutex_fn_p) -#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p) -#define _Xglobal_lock (*_Xglobal_lock_p) -#endif - -/* in XlibInt.c */ -extern void (*_XCreateMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XFreeMutex_fn)( - LockInfoPtr /* lock */ -); -extern void (*_XLockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); -extern void (*_XUnlockMutex_fn)( - LockInfoPtr /* lock */ -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) - , char * /* file */ - , int /* line */ -#endif -); - -extern LockInfoPtr _Xglobal_lock; - -#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE) -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__) -#else -/* used everywhere, so must be fast if not using threads */ -#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d) -#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d) -#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock) -#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock) -#endif -#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock); -#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock); - -#else /* XTHREADS */ -#define LockDisplay(dis) -#define _XLockMutex(lock) -#define _XUnlockMutex(lock) -#define UnlockDisplay(dis) -#define _XCreateMutex(lock) -#define _XFreeMutex(lock) -#endif - -#define Xfree(ptr) free((ptr)) - -/* - * Note that some machines do not return a valid pointer for malloc(0), in - * which case we provide an alternate under the control of the - * define MALLOC_0_RETURNS_NULL. This is necessary because some - * Xlib code expects malloc(0) to return a valid pointer to storage. - */ -#ifdef MALLOC_0_RETURNS_NULL - -# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size))) -# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size))) -# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize)) - -#else - -# define Xmalloc(size) malloc((size)) -# define Xrealloc(ptr, size) realloc((ptr), (size)) -# define Xcalloc(nelem, elsize) calloc((nelem), (elsize)) - -#endif - -#include <stddef.h> - -#define LOCKED 1 -#define UNLOCKED 0 - -#ifndef BUFSIZE -#define BUFSIZE 2048 /* X output buffer size. */ -#endif -#ifndef PTSPERBATCH -#define PTSPERBATCH 1024 /* point batching */ -#endif -#ifndef WLNSPERBATCH -#define WLNSPERBATCH 50 /* wide line batching */ -#endif -#ifndef ZLNSPERBATCH -#define ZLNSPERBATCH 1024 /* thin line batching */ -#endif -#ifndef WRCTSPERBATCH -#define WRCTSPERBATCH 10 /* wide line rectangle batching */ -#endif -#ifndef ZRCTSPERBATCH -#define ZRCTSPERBATCH 256 /* thin line rectangle batching */ -#endif -#ifndef FRCTSPERBATCH -#define FRCTSPERBATCH 256 /* filled rectangle batching */ -#endif -#ifndef FARCSPERBATCH -#define FARCSPERBATCH 256 /* filled arc batching */ -#endif -#ifndef CURSORFONT -#define CURSORFONT "cursor" /* standard cursor fonts */ -#endif - -/* - * Display flags - */ -#define XlibDisplayIOError (1L << 0) -#define XlibDisplayClosing (1L << 1) -#define XlibDisplayNoXkb (1L << 2) -#define XlibDisplayPrivSync (1L << 3) -#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */ -#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */ -#define XlibDisplayReply (1L << 5) /* in _XReply */ -#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */ -#define XlibDisplayDfltRMDB (1L << 7) /* mark if RM db from XGetDefault */ - -/* - * X Protocol packetizing macros. - */ - -/* Need to start requests on 64 bit word boundaries - * on a CRAY computer so add a NoOp (127) if needed. - * A character pointer on a CRAY computer will be non-zero - * after shifting right 61 bits of it is not pointing to - * a word boundary. - */ -#ifdef WORD64 -#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\ - dpy->last_req = dpy->bufptr;\ - *(dpy->bufptr) = X_NoOperation;\ - *(dpy->bufptr+1) = 0;\ - *(dpy->bufptr+2) = 0;\ - *(dpy->bufptr+3) = 1;\ - dpy->request++;\ - dpy->bufptr += 4;\ - } -#else /* else does not require alignment on 64-bit boundaries */ -#define WORD64ALIGN -#endif /* WORD64 */ - - -/* - * GetReq - Get the next available X request packet in the buffer and - * return it. - * - * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc. - * "req" is the name of the request pointer. - * - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req))>>2;\ - dpy->bufptr += SIZEOF(x##name##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define GetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req))>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req);\ - dpy->request++ -#endif - -/* GetReqExtra is the same as GetReq, but allocates "n" additional - bytes after the request. "n" must be a multiple of 4! */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##name##Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x##name##Req) + n;\ - dpy->request++ -#else -#define GetReqExtra(name, n, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\ - dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\ - dpy->request++ -#endif - - -/* - * GetResReq is for those requests that have a resource ID - * (Window, Pixmap, GContext, etc.) as their single argument. - * "rid" is the name of the resource. - */ - -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#else -#define GetResReq(name, rid, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 2;\ - req->id = (rid);\ - dpy->bufptr += SIZEOF(xResourceReq);\ - dpy->request++ -#endif - -/* - * GetEmptyReq is for those requests that have no arguments - * at all. - */ -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#else -#define GetEmptyReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xReq *) (dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = 1;\ - dpy->bufptr += SIZEOF(xReq);\ - dpy->request++ -#endif - -#ifdef WORD64 -#define MakeBigReq(req,n) \ - { \ - char _BRdat[4]; \ - unsigned long _BRlen = req->length - 1; \ - req->length = 0; \ - memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - memcpy(((char *)req) + 4, _BRdat, 4); \ - Data32(dpy, (long *)&_BRdat, 4); \ - } -#else -#ifdef LONG64 -#define MakeBigReq(req,n) \ - { \ - CARD64 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#else -#define MakeBigReq(req,n) \ - { \ - CARD32 _BRdat; \ - CARD32 _BRlen = req->length - 1; \ - req->length = 0; \ - _BRdat = ((CARD32 *)req)[_BRlen]; \ - memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \ - ((CARD32 *)req)[1] = _BRlen + n + 2; \ - Data32(dpy, &_BRdat, 4); \ - } -#endif -#endif - -#define SetReqLen(req,n,badlen) \ - if ((req->length + n) > (unsigned)65535) { \ - if (dpy->bigreq_size) { \ - MakeBigReq(req,n) \ - } else { \ - n = badlen; \ - req->length += n; \ - } \ - } else \ - req->length += n - -#define SyncHandle() \ - if (dpy->synchandler) (*dpy->synchandler)(dpy) - -extern void _XFlushGCCache(Display *dpy, GC gc); -#define FlushGC(dpy, gc) \ - if ((gc)->dirty) _XFlushGCCache((dpy), (gc)) -/* - * Data - Place data in the buffer and pad the end to provide - * 32 bit word alignment. Transmit if the buffer fills. - * - * "dpy" is a pointer to a Display. - * "data" is a pinter to a data buffer. - * "len" is the length of the data buffer. - */ -#ifndef DataRoutineIsProcedure -#define Data(dpy, data, 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 */ - - -/* Allocate bytes from the buffer. No padding is done, so if - * the length is not a multiple of 4, the caller must be - * careful to leave the buffer aligned after sending the - * current request. - * - * "type" is the type of the pointer being assigned to. - * "ptr" is the pointer being assigned to. - * "n" is the number of bytes to allocate. - * - * Example: - * xTextElt *elt; - * BufAlloc (xTextElt *, elt, nbytes) - */ - -#define BufAlloc(type, ptr, n) \ - if (dpy->bufptr + (n) > dpy->bufmax) \ - _XFlush (dpy); \ - ptr = (type) dpy->bufptr; \ - (void)ptr; \ - dpy->bufptr += (n); - -#ifdef WORD64 -#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len) -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -#else -#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len)) -#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#ifdef LONG64 -#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len) -extern int _XData32( - Display *dpy, - register long *data, - unsigned len -); -extern void _XRead32( - Display *dpy, - register long *data, - long len -); -#else -#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len)) -#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len)) -#endif -#endif /* not WORD64 */ - -#define PackData16(dpy,data,len) Data16 (dpy, data, len) -#define PackData32(dpy,data,len) Data32 (dpy, data, len) - -/* Xlib manual is bogus */ -#define PackData(dpy,data,len) PackData16 (dpy, data, len) - -#define min(a,b) (((a) < (b)) ? (a) : (b)) -#define max(a,b) (((a) > (b)) ? (a) : (b)) - -#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \ - (((cs)->rbearing|(cs)->lbearing| \ - (cs)->ascent|(cs)->descent) == 0)) - -/* - * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit - * character. If the character is in the column and exists, then return the - * appropriate metrics (note that fonts with common per-character metrics will - * return min_bounds). If none of these hold true, try again with the default - * char. - */ -#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ -{ \ - cs = def; \ - if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_1D(fs,cs) \ - CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) - - - -/* - * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and - * column. This is used for fonts that have more than row zero. - */ -#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ -{ \ - cs = def; \ - if (row >= fs->min_byte1 && row <= fs->max_byte1 && \ - col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \ - if (fs->per_char == NULL) { \ - cs = &fs->min_bounds; \ - } else { \ - cs = &fs->per_char[((row - fs->min_byte1) * \ - (fs->max_char_or_byte2 - \ - fs->min_char_or_byte2 + 1)) + \ - (col - fs->min_char_or_byte2)]; \ - if (CI_NONEXISTCHAR(cs)) cs = def; \ - } \ - } \ -} - -#define CI_GET_DEFAULT_INFO_2D(fs,cs) \ -{ \ - unsigned int r = (fs->default_char >> 8); \ - unsigned int c = (fs->default_char & 0xff); \ - CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ -} - - -#ifdef MUSTCOPY - -/* for when 32-bit alignment is not good enough */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); } - -#else - -/* srcvar must be a variable for large architecture version */ -#define OneDataCard32(dpy,dstaddr,srcvar) \ - { *(CARD32 *)(dstaddr) = (srcvar); } - -#endif /* MUSTCOPY */ - -typedef struct _XInternalAsync { - struct _XInternalAsync *next; - /* - * handler arguments: - * rep is the generic reply that caused this handler - * to be invoked. It must also be passed to _XGetAsyncReply. - * buf and len are opaque values that must be passed to - * _XGetAsyncReply or _XGetAsyncData. - * data is the closure stored in this struct. - * The handler returns True iff it handled this reply. - */ - Bool (*handler)( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ - ); - XPointer data; -} _XAsyncHandler; - -typedef struct _XAsyncEState { - unsigned long min_sequence_number; - unsigned long max_sequence_number; - unsigned char error_code; - unsigned char major_opcode; - unsigned short minor_opcode; - unsigned char last_error_received; - int error_count; -} _XAsyncErrorState; - -extern void _XDeqAsyncHandler(Display *dpy, _XAsyncHandler *handler); -#define DeqAsyncHandler(dpy,handler) { \ - if (dpy->async_handlers == (handler)) \ - dpy->async_handlers = (handler)->next; \ - else \ - _XDeqAsyncHandler(dpy, handler); \ - } - -typedef void (*FreeFuncType) ( - Display* /* display */ -); - -typedef int (*FreeModmapType) ( - XModifierKeymap* /* modmap */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XFreeFuncs { - FreeFuncType atoms; /* _XFreeAtomTable */ - FreeModmapType modifiermap; /* XFreeModifierMap */ - FreeFuncType key_bindings; /* _XFreeKeyBindings */ - FreeFuncType context_db; /* _XFreeContextDB */ - FreeFuncType defaultCCCs; /* _XcmsFreeDefaultCCCs */ - FreeFuncType clientCmaps; /* _XcmsFreeClientCmaps */ - FreeFuncType intensityMaps; /* _XcmsFreeIntensityMaps */ - FreeFuncType im_filters; /* _XFreeIMFilters */ - FreeFuncType xkb; /* _XkbFreeInfo */ -} _XFreeFuncRec; - -/* types for InitExt.c */ -typedef int (*CreateGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CopyGCType)( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FlushGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*FreeGCType) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ -); - -typedef int (*CreateFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*FreeFontType) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ -); - -typedef int (*CloseDisplayType) ( - Display* /* display */, - XExtCodes* /* codes */ -); - -typedef int (*ErrorType) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ -); - -typedef char* (*ErrorStringType) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ -); - -typedef void (*PrintErrorType)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ -); - -typedef void (*BeforeFlushType)( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ -); - -/* - * This structure is private to the library. - */ -typedef struct _XExten { /* private to extension mechanism */ - struct _XExten *next; /* next in list */ - XExtCodes codes; /* public information, all extension told */ - CreateGCType create_GC; /* routine to call when GC created */ - CopyGCType copy_GC; /* routine to call when GC copied */ - FlushGCType flush_GC; /* routine to call when GC flushed */ - FreeGCType free_GC; /* routine to call when GC freed */ - CreateFontType create_Font; /* routine to call when Font created */ - FreeFontType free_Font; /* routine to call when Font freed */ - CloseDisplayType close_display; /* routine to call when connection closed */ - ErrorType error; /* who to call when an error occurs */ - ErrorStringType error_string; /* routine to supply error string */ - char *name; /* name of this extension */ - PrintErrorType error_values; /* routine to supply error values */ - BeforeFlushType before_flush; /* routine to call when sending data */ - struct _XExten *next_flush; /* next in list of those with flushes */ -} _XExtension; - -/* extension hooks */ - -#ifdef DataRoutineIsProcedure -extern void Data(Display *dpy, char *data, long len); -#endif -extern int _XError( - Display* /* dpy */, - xError* /* rep */ -); -extern int _XIOError( - Display* /* dpy */ -); -extern int (*_XIOErrorFunction)( - Display* /* dpy */ -); -extern int (*_XErrorFunction)( - Display* /* dpy */, - XErrorEvent* /* error_event */ -); -extern void _XEatData( - Display* /* dpy */, - unsigned long /* n */ -); -extern char *_XAllocScratch( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern char *_XAllocTemp( - Display* /* dpy */, - unsigned long /* nbytes */ -); -extern void _XFreeTemp( - Display* /* dpy */, - char* /* buf */, - unsigned long /* nbytes */ -); -extern Visual *_XVIDtoVisual( - Display* /* dpy */, - VisualID /* id */ -); -extern unsigned long _XSetLastRequestRead( - Display* /* dpy */, - xGenericReply* /* rep */ -); -extern int _XGetHostname( - char* /* buf */, - int /* maxlen */ -); -extern Screen *_XScreenOfWindow( - Display* /* dpy */, - Window /* w */ -); -extern Bool _XAsyncErrorHandler( - Display* /* dpy */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - XPointer /* data */ -); -extern char *_XGetAsyncReply( - Display* /* dpy */, - char* /* replbuf */, - xReply* /* rep */, - char* /* buf */, - int /* len */, - int /* extra */, - Bool /* discard */ -); -extern void _XGetAsyncData( - Display* /* dpy */, - char * /* data */, - char * /* buf */, - int /* len */, - int /* skip */, - int /* datalen */, - int /* discardtotal */ -); -extern void _XFlush( - Display* /* dpy */ -); -extern int _XEventsQueued( - Display* /* dpy */, - int /* mode */ -); -extern void _XReadEvents( - Display* /* dpy */ -); -extern int _XRead( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XReadPad( - Display* /* dpy */, - char* /* data */, - long /* size */ -); -extern void _XSend( - Display* /* dpy */, - _Xconst char* /* data */, - long /* size */ -); -extern Status _XReply( - Display* /* dpy */, - xReply* /* rep */, - int /* extra */, - Bool /* discard */ -); -extern void _XEnq( - Display* /* dpy */, - xEvent* /* event */ -); -extern void _XDeq( - Display* /* dpy */, - _XQEvent* /* prev */, - _XQEvent* /* qelt */ -); - -extern Bool _XUnknownWireEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); -extern Status _XUnknownNativeEvent( - Display* /* dpy */, - XEvent* /* re */, - xEvent* /* event */ -); - -extern Bool _XWireToEvent(Display *dpy, XEvent *re, xEvent *event); -extern Bool _XDefaultWireError(Display *display, XErrorEvent *he, xError *we); -extern Bool _XPollfdCacheInit(Display *dpy); -extern void _XPollfdCacheAdd(Display *dpy, int fd); -extern void _XPollfdCacheDel(Display *dpy, int fd); -extern XID _XAllocID(Display *dpy); -extern void _XAllocIDs(Display *dpy, XID *ids, int count); - -extern int _XFreeExtData( - XExtData* /* extension */ -); - -extern int (*XESetCreateGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCopyGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFlushGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetFreeGC( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - GC /* gc */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, GC, XExtCodes* -); - -extern int (*XESetCreateFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetFreeFont( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XFontStruct* /* fs */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XFontStruct*, XExtCodes* -); - -extern int (*XESetCloseDisplay( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - XExtCodes* /* codes */ - ) /* proc */ -))( - Display*, XExtCodes* -); - -extern int (*XESetError( - Display* /* display */, - int /* extension */, - int (*) ( - Display* /* display */, - xError* /* err */, - XExtCodes* /* codes */, - int* /* ret_code */ - ) /* proc */ -))( - Display*, xError*, XExtCodes*, int* -); - -extern char* (*XESetErrorString( - Display* /* display */, - int /* extension */, - char* (*) ( - Display* /* display */, - int /* code */, - XExtCodes* /* codes */, - char* /* buffer */, - int /* nbytes */ - ) /* proc */ -))( - Display*, int, XExtCodes*, char*, int -); - -extern void (*XESetPrintErrorValues ( - Display* /* display */, - int /* extension */, - void (*)( - Display* /* display */, - XErrorEvent* /* ev */, - void* /* fp */ - ) /* proc */ -))( - Display*, XErrorEvent*, void* -); - -extern Bool (*XESetWireToEvent( - Display* /* display */, - int /* event_number */, - Bool (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Status (*XESetEventToWire( - Display* /* display */, - int /* event_number */, - Status (*) ( - Display* /* display */, - XEvent* /* re */, - xEvent* /* event */ - ) /* proc */ -))( - Display*, XEvent*, xEvent* -); - -extern Bool (*XESetWireToError( - Display* /* display */, - int /* error_number */, - Bool (*) ( - Display* /* display */, - XErrorEvent* /* he */, - xError* /* we */ - ) /* proc */ -))( - Display*, XErrorEvent*, xError* -); - -extern void (*XESetBeforeFlush( - Display* /* display */, - int /* error_number */, - void (*) ( - Display* /* display */, - XExtCodes* /* codes */, - _Xconst char* /* data */, - long /* len */ - ) /* proc */ -))( - Display*, XExtCodes*, _Xconst char*, long -); - -/* internal connections for IMs */ - -typedef void (*_XInternalConnectionProc)( - Display* /* dpy */, - int /* fd */, - XPointer /* call_data */ -); - - -extern Status _XRegisterInternalConnection( - Display* /* dpy */, - int /* fd */, - _XInternalConnectionProc /* callback */, - XPointer /* call_data */ -); - -extern void _XUnregisterInternalConnection( - Display* /* dpy */, - int /* fd */ -); - -/* Display structure has pointers to these */ - -struct _XConnectionInfo { /* info from _XRegisterInternalConnection */ - int fd; - _XInternalConnectionProc read_callback; - XPointer call_data; - XPointer *watch_data; /* set/used by XConnectionWatchProc */ - struct _XConnectionInfo *next; -}; - -struct _XConnWatchInfo { /* info from XAddConnectionWatch */ - XConnectionWatchProc fn; - XPointer client_data; - struct _XConnWatchInfo *next; -}; - -#ifdef __UNIXOS2__ -extern char* __XOS2RedirRoot( - char* -); -#endif - -extern int _XTextHeight( - XFontStruct* /* font_struct */, - _Xconst char* /* string */, - int /* count */ -); - -extern int _XTextHeight16( - XFontStruct* /* font_struct */, - _Xconst XChar2b* /* string */, - int /* count */ -); - -#if defined(WIN32) - -extern int _XOpenFile( - _Xconst char* /* path */, - int /* flags */ -); - -extern void* _XFopenFile( - _Xconst char* /* path */, - _Xconst char* /* mode */ -); - -extern int _XAccessFile( - _Xconst char* /* path */ -); -#else -#define _XOpenFile(path,flags) open(path,flags) -#define _XFopenFile(path,mode) fopen(path,mode) -#endif - -/* EvToWire.c */ -extern Status _XEventToWire(Display *dpy, XEvent *re, xEvent *event); - -extern int _XF86LoadQueryLocaleFont( - Display* /* dpy */, - _Xconst char* /* name*/, - XFontStruct** /* xfp*/, - Font* /* fidp */ -); - -extern void _XProcessWindowAttributes ( - register Display *dpy, - xChangeWindowAttributesReq *req, - register unsigned long valuemask, - register XSetWindowAttributes *attributes); - -extern int _XDefaultError( - Display *dpy, - XErrorEvent *event); - -extern int _XDefaultIOError( - Display *dpy); - -extern void _XSetClipRectangles ( - register Display *dpy, - GC gc, - int clip_x_origin, int clip_y_origin, - XRectangle *rectangles, - int n, - int ordering); - -Status _XGetWindowAttributes( - register Display *dpy, - Window w, - XWindowAttributes *attr); - -int _XPutBackEvent ( - register Display *dpy, - register XEvent *event); - -_XFUNCPROTOEND - -#endif /* _XLIBINT_H_ */ diff --git a/nx-X11/lib/X11/cmsProp.c.X.original b/nx-X11/lib/X11/cmsProp.c.X.original deleted file mode 100644 index 4040a05ce..000000000 --- a/nx-X11/lib/X11/cmsProp.c.X.original +++ /dev/null @@ -1,148 +0,0 @@ -/* $Xorg: cmsProp.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */ - -/* - * - * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc. - * All Rights Reserved - * - * This file is a component of an X Window System-specific implementation - * of Xcms based on the TekColor Color Management System. Permission is - * hereby granted to use, copy, modify, sell, and otherwise distribute this - * software and its documentation for any purpose and without fee, provided - * that this copyright, permission, and disclaimer notice is reproduced in - * all copies of this software and in supporting documentation. TekColor - * is a trademark of Tektronix, Inc. - * - * Tektronix makes no representation about the suitability of this software - * for any purpose. It is provided "as is" and with all faults. - * - * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE, - * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE. - * - * NAME - * XcmsProp.c - * - * DESCRIPTION - * This utility routines for manipulating properties. - * - */ -/* $XFree86$ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xatom.h> -#include "Xlibint.h" -#include "Xcmsint.h" -#include "Cv.h" - - -/************************************************************************ - * * - * API PRIVATE ROUTINES * - * * - ************************************************************************/ - - -/* - * NAME - * _XcmsGetElement -- get an element value from the property passed - * - * SYNOPSIS - */ -unsigned long -_XcmsGetElement( - int format, - char **pValue, - unsigned long *pCount) -/* - * DESCRIPTION - * Get the next element from the property and return it. - * Also increment the pointer the amount needed. - * - * Returns - * unsigned long - */ -{ - unsigned long value; - - switch (format) { - case 32: - value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF; - *pValue += sizeof(unsigned long); - *pCount -= 1; - break; - case 16: - value = *((unsigned short *)(*pValue)); - *pValue += sizeof(unsigned short); - *pCount -= 1; - break; - case 8: - value = *((unsigned char *) (*pValue)); - *pValue += 1; - *pCount -= 1; - break; - default: - value = 0; - break; - } - return(value); -} - - -/* - * NAME - * _XcmsGetProperty -- Determine the existance of a property - * - * SYNOPSIS - */ -int -_XcmsGetProperty( - Display *pDpy, - Window w, - Atom property, - int *pFormat, - unsigned long *pNItems, - unsigned long *pNBytes, - char **pValue) -/* - * DESCRIPTION - * - * Returns - * 0 if property does not exist. - * 1 if property exists. - */ -{ - char *prop_ret; - int format_ret; - long len = 6516; - unsigned long nitems_ret, after_ret; - Atom atom_ret; - - while (XGetWindowProperty (pDpy, w, property, 0, len, False, - XA_INTEGER, &atom_ret, &format_ret, - &nitems_ret, &after_ret, - (unsigned char **)&prop_ret)) { - if (after_ret > 0) { - len += nitems_ret * (format_ret >> 3); - XFree (prop_ret); - } else { - break; - } - } - if (format_ret == 0 || nitems_ret == 0) { - /* the property does not exist or is of an unexpected type */ - return(XcmsFailure); - } - - *pFormat = format_ret; - *pNItems = nitems_ret; - *pNBytes = nitems_ret * (format_ret >> 3); - *pValue = prop_ret; - return(XcmsSuccess); -} diff --git a/nx-X11/lib/Xau/AuRead.c.NX.original b/nx-X11/lib/Xau/AuRead.c.NX.original deleted file mode 100644 index 60a0d747f..000000000 --- a/nx-X11/lib/Xau/AuRead.c.NX.original +++ /dev/null @@ -1,137 +0,0 @@ -/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 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. - -*/ -/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <stdlib.h> -#include <errno.h> - -static int -read_short (unsigned short *shortp, FILE *file) -{ - unsigned char file_short[2]; - - /* - * Added a check on EINTR to prevent the fread() call to be - * interrupted by any signal not blocked by OsBlockSignals(). - */ - - for (;;) { - if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) { - if (errno == EINTR && ferror (file)) { - perror ("Reading from auth file"); - clearerr (file); - continue; - } - return 0; - } - break; - } - *shortp = file_short[0] * 256 + file_short[1]; - return 1; -} - -static int -read_counted_string (unsigned short *countp, char **stringp, FILE *file) -{ - unsigned short len; - char *data; - - if (read_short (&len, file) == 0) - return 0; - if (len == 0) { - data = 0; - } else { - data = malloc ((unsigned) len); - if (!data) - return 0; - for (;;) - { - if (fread (data, (int) sizeof (char), (int) len, file) != len) - { - if (errno == EINTR && ferror (file)) - { - perror ("Reading from auth file"); - clearerr (file); - continue; - } - bzero (data, len); - free (data); - return 0; - } - break; - } - } - *stringp = data; - *countp = len; - return 1; -} - -Xauth * -XauReadAuth (auth_file) -FILE *auth_file; -{ - Xauth local; - Xauth *ret; - - if (read_short (&local.family, auth_file) == 0) - return 0; - if (read_counted_string (&local.address_length, &local.address, auth_file) == 0) - return 0; - if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) { - if (local.address) free (local.address); - return 0; - } - if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - return 0; - } - if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - return 0; - } - ret = (Xauth *) malloc (sizeof (Xauth)); - if (!ret) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - if (local.data) { - bzero (local.data, local.data_length); - free (local.data); - } - return 0; - } - *ret = local; - return ret; -} diff --git a/nx-X11/lib/Xau/AuRead.c.X.original b/nx-X11/lib/Xau/AuRead.c.X.original deleted file mode 100644 index f7cdf8f3a..000000000 --- a/nx-X11/lib/Xau/AuRead.c.X.original +++ /dev/null @@ -1,111 +0,0 @@ -/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */ - -/* - -Copyright 1988, 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. - -*/ -/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <X11/Xauth.h> -#include <stdlib.h> - -static int -read_short (unsigned short *shortp, FILE *file) -{ - unsigned char file_short[2]; - - if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) - return 0; - *shortp = file_short[0] * 256 + file_short[1]; - return 1; -} - -static int -read_counted_string (unsigned short *countp, char **stringp, FILE *file) -{ - unsigned short len; - char *data; - - if (read_short (&len, file) == 0) - return 0; - if (len == 0) { - data = 0; - } else { - data = malloc ((unsigned) len); - if (!data) - return 0; - if (fread (data, (int) sizeof (char), (int) len, file) != len) { - bzero (data, len); - free (data); - return 0; - } - } - *stringp = data; - *countp = len; - return 1; -} - -Xauth * -XauReadAuth (auth_file) -FILE *auth_file; -{ - Xauth local; - Xauth *ret; - - if (read_short (&local.family, auth_file) == 0) - return 0; - if (read_counted_string (&local.address_length, &local.address, auth_file) == 0) - return 0; - if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) { - if (local.address) free (local.address); - return 0; - } - if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - return 0; - } - if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - return 0; - } - ret = (Xauth *) malloc (sizeof (Xauth)); - if (!ret) { - if (local.address) free (local.address); - if (local.number) free (local.number); - if (local.name) free (local.name); - if (local.data) { - bzero (local.data, local.data_length); - free (local.data); - } - return 0; - } - *ret = local; - return ret; -} diff --git a/nx-X11/lib/Xpm/Imakefile.NX.original b/nx-X11/lib/Xpm/Imakefile.NX.original deleted file mode 100644 index dd98b2fb8..000000000 --- a/nx-X11/lib/Xpm/Imakefile.NX.original +++ /dev/null @@ -1,126 +0,0 @@ -XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $ - -/* This is a simplified version of the standard Xpm Imakefile */ - -#ifdef SunArchitecture -#define DoNormalLib YES -#else -#define DoNormalLib NormalLibXpm -#endif -#define DoSharedLib SharedLibXpm -#define DoExtraLib SharedLibXpm -#define DoDebugLib DebugLibXpm -#define DoProfileLib ProfileLibXpm -#define HasSharedData NO -#define LibName Xpm -#define SoRev SOXPMREV -#define IncSubdir X11 - -#ifdef SharedXpmReqs -REQUIREDLIBS = SharedXpmReqs -#endif - -/* - * if your system doesn't provide strcasecmp add -DNEED_STRCASECMP - * if your system doesn't provide strdup add -DNEED_STRDUP - * if your system doesn't provide pipe add -DNO_ZPIPE - * if on your system sprintf doesn't return the number of bytes transmitted - * add -DVOID_SPRINTF - * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read - * name.xpm , add -DSTAT_ZFILE - */ - -#if defined(LinuxArchitecture) -ZFILEDEF = -DSTAT_ZFILE -#endif -#if defined(UltrixArchitecture) || \ - (defined(MipsArchitecture) && !defined(SGIArchitecture)) -STRDUPDEF = -DNEED_STRDUP -#endif - -#if !HasStrcasecmp -STRCASECMPDEF = -DNEED_STRCASECMP -#endif - -#if defined(SunArchitecture) && !defined(SVR4Architecture) -SPRINTFDEF = -DVOID_SPRINTF -#endif - -#if HasStrlcat -STRLCATDEF = -DHAS_STRLCAT -#endif - -#if HasSnprintf -SNPRINTFDEF = -DHAS_SNPRINTF -#else -SNPRINTFDEF = -Dsnprintf=_XpmSnprintf -SNPRINTFSRCS = snprintf.c -SNPRINTFOBJS = snprintf.o -#endif - -#if defined(Win32Architecture) -ZPIPEDEF = -DNO_ZPIPE -#endif - -DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \ - $(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF) - -HEADERS = xpm.h - - SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \ - CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \ - CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \ - CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \ - Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \ - $(SNPRINTFSRCS) - - OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \ - CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \ - CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \ - CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \ - Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \ - $(SNPRINTFOBJS) - - XPMDIR = $(TOP)/extras/Xpm - XPMLIBDIR = $(TOP)/extras/Xpm/lib - - INCLUDES = -I$(XPMLIBDIR) - LINTLIBS = $(LINTXTOLL) $(LINTXLIB) - -#include <Library.tmpl> - -LinkSourceFile(data.c,$(XPMLIBDIR)) -LinkSourceFile(create.c,$(XPMLIBDIR)) -LinkSourceFile(misc.c,$(XPMLIBDIR)) -LinkSourceFile(rgb.c,$(XPMLIBDIR)) -LinkSourceFile(scan.c,$(XPMLIBDIR)) -LinkSourceFile(parse.c,$(XPMLIBDIR)) -LinkSourceFile(hashtab.c,$(XPMLIBDIR)) -LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToI.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToP.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToDat.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(Attrib.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrI.c,$(XPMLIBDIR)) -LinkSourceFile(Image.c,$(XPMLIBDIR)) -LinkSourceFile(Info.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(xpm.h,$(XPMLIBDIR)) - -#if !HasSnprintf -LinkSourceFile(snprintf.c,$(LIBSRC)/misc) -#endif - -DependTarget() diff --git a/nx-X11/lib/Xpm/Imakefile.X.original b/nx-X11/lib/Xpm/Imakefile.X.original deleted file mode 100644 index 9899fe209..000000000 --- a/nx-X11/lib/Xpm/Imakefile.X.original +++ /dev/null @@ -1,122 +0,0 @@ -XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $ - -/* This is a simplified version of the standard Xpm Imakefile */ - -#define DoNormalLib NormalLibXpm -#define DoSharedLib SharedLibXpm -#define DoExtraLib SharedLibXpm -#define DoDebugLib DebugLibXpm -#define DoProfileLib ProfileLibXpm -#define HasSharedData NO -#define LibName Xpm -#define SoRev SOXPMREV -#define IncSubdir X11 - -#ifdef SharedXpmReqs -REQUIREDLIBS = SharedXpmReqs -#endif - -/* - * if your system doesn't provide strcasecmp add -DNEED_STRCASECMP - * if your system doesn't provide strdup add -DNEED_STRDUP - * if your system doesn't provide pipe add -DNO_ZPIPE - * if on your system sprintf doesn't return the number of bytes transmitted - * add -DVOID_SPRINTF - * if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read - * name.xpm , add -DSTAT_ZFILE - */ - -#if defined(LinuxArchitecture) -ZFILEDEF = -DSTAT_ZFILE -#endif -#if defined(UltrixArchitecture) || \ - (defined(MipsArchitecture) && !defined(SGIArchitecture)) -STRDUPDEF = -DNEED_STRDUP -#endif - -#if !HasStrcasecmp -STRCASECMPDEF = -DNEED_STRCASECMP -#endif - -#if defined(SunArchitecture) && !defined(SVR4Architecture) -SPRINTFDEF = -DVOID_SPRINTF -#endif - -#if HasStrlcat -STRLCATDEF = -DHAS_STRLCAT -#endif - -#if HasSnprintf -SNPRINTFDEF = -DHAS_SNPRINTF -#else -SNPRINTFDEF = -Dsnprintf=_XpmSnprintf -SNPRINTFSRCS = snprintf.c -SNPRINTFOBJS = snprintf.o -#endif - -#if defined(Win32Architecture) -ZPIPEDEF = -DNO_ZPIPE -#endif - -DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \ - $(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF) - -HEADERS = xpm.h - - SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \ - CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \ - CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \ - CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \ - Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \ - $(SNPRINTFSRCS) - - OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \ - CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \ - CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \ - CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \ - Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \ - $(SNPRINTFOBJS) - - XPMDIR = $(TOP)/extras/Xpm - XPMLIBDIR = $(TOP)/extras/Xpm/lib - - INCLUDES = -I$(XPMLIBDIR) - LINTLIBS = $(LINTXTOLL) $(LINTXLIB) - -#include <Library.tmpl> - -LinkSourceFile(data.c,$(XPMLIBDIR)) -LinkSourceFile(create.c,$(XPMLIBDIR)) -LinkSourceFile(misc.c,$(XPMLIBDIR)) -LinkSourceFile(rgb.c,$(XPMLIBDIR)) -LinkSourceFile(scan.c,$(XPMLIBDIR)) -LinkSourceFile(parse.c,$(XPMLIBDIR)) -LinkSourceFile(hashtab.c,$(XPMLIBDIR)) -LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToI.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToP.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToDat.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR)) -LinkSourceFile(Attrib.c,$(XPMLIBDIR)) -LinkSourceFile(CrIFrP.c,$(XPMLIBDIR)) -LinkSourceFile(CrPFrI.c,$(XPMLIBDIR)) -LinkSourceFile(Image.c,$(XPMLIBDIR)) -LinkSourceFile(Info.c,$(XPMLIBDIR)) -LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR)) -LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR)) -LinkSourceFile(xpm.h,$(XPMLIBDIR)) - -#if !HasSnprintf -LinkSourceFile(snprintf.c,$(LIBSRC)/misc) -#endif - -DependTarget() diff --git a/nx-X11/lib/Xrender/Glyph.c.NX.original b/nx-X11/lib/Xrender/Glyph.c.NX.original deleted file mode 100644 index e25805f5c..000000000 --- a/nx-X11/lib/Xrender/Glyph.c.NX.original +++ /dev/null @@ -1,1169 +0,0 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * 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. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xrenderint.h" - -/* - * NX_RENDER_CLEANUP enables cleaning of padding bytes - */ - -#define NX_RENDER_CLEANUP - -#define PANIC -#define WARNING -#undef TEST -#undef DEBUG -#undef DUMP - -#ifdef NX_RENDER_CLEANUP - -#include <stdio.h> - -#define ROUNDUP(nbits, pad) ((((nbits) + ((pad)-1)) / (pad)) * ((pad)>>3)) - -#endif /* NX_RENDER_CLEANUP */ - -GlyphSet -XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - GlyphSet gsid; - xRenderCreateGlyphSetReq *req; - - RenderCheckExtension (dpy, info, 0); - LockDisplay(dpy); - GetReq(RenderCreateGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCreateGlyphSet; - req->gsid = gsid = XAllocID(dpy); - req->format = format->id; - UnlockDisplay(dpy); - SyncHandle(); - return gsid; -} - -GlyphSet -XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - GlyphSet gsid; - xRenderReferenceGlyphSetReq *req; - - RenderCheckExtension (dpy, info, 0); - LockDisplay(dpy); - GetReq(RenderReferenceGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderReferenceGlyphSet; - req->gsid = gsid = XAllocID(dpy); - req->existing = existing; - UnlockDisplay(dpy); - SyncHandle(); - return gsid; -} - -void -XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderFreeGlyphSetReq *req; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderFreeGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderFreeGlyphSet; - req->glyphset = glyphset; - UnlockDisplay(dpy); - SyncHandle(); -} - -#ifdef NX_RENDER_CLEANUP - -void -XRenderCleanGlyphs(xGlyphInfo *gi, - int nglyphs, - CARD8 *images, - int depth, - Display *dpy) -{ - - int widthInBits; - int bytesPerLine; - int bytesToClean; - int bitsToClean; - int widthInBytes; - int height = gi -> height; - register int i; - int j; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: Found a Glyph with Depth %d, width %d, pad %d.\n", - depth, gi -> width, dpy -> bitmap_pad); - #endif - - while (nglyphs > 0) - { - if (depth == 24) - { - widthInBits = gi -> width * 32; - - bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad); - - bytesToClean = bytesPerLine * height; - - #ifdef DUBUG - fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 24, bytes to clean is %d" - "width in bits is %d bytes per line [%d] height [%d].\n", bytesToClean, - widthInBits, bytesPerLine, height); - #endif - - if (dpy -> byte_order == LSBFirst) - { - for (i = 3; i < bytesToClean; i += 4) - { - images[i] = 0x00; - } - } - else - { - for (i = 0; i < bytesToClean; i += 4) - { - images[i] = 0x00; - } - } - - #ifdef DUMP - fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) - { - fprintf(stderr, "[%d]", images[i]); - } - fprintf(stderr,"\n"); - #endif - - images += bytesToClean; - - gi++; - - nglyphs--; - } - else if (depth == 1) - { - widthInBits = gi -> width; - - bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad); - - bitsToClean = (bytesPerLine << 3) - (gi -> width); - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 1, width [%d], height [%d], bitsToClean [%d]," - " bytesPerLine [%d].\n", gi -> width, height, bitsToClean, bytesPerLine); - #endif - - bytesToClean = bitsToClean >> 3; - - bitsToClean &= 7; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: bitsToClean &=7 is %d, bytesToCLean is %d." - " byte_order is %d, bitmap_bit_order is %d.\n", bitsToClean, bytesToClean, - dpy -> byte_order, dpy -> bitmap_bit_order); - #endif - - for (i = 1; i <= height; i++) - { - if (dpy -> byte_order == dpy -> bitmap_bit_order) - { - for (j = 1; j <= bytesToClean; j++) - { - images[i * bytesPerLine - j] = 0x00; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: byte_order = bitmap_bit_orde, cleaning %d, i=%d, j=%d.\n" - , (i * bytesPerLine - j), i, j); - #endif - - } - } - else - { - for (j = bytesToClean; j >= 1; j--) - { - images[i * bytesPerLine - j] = 0x00; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: byte_order %d, bitmap_bit_order %d, cleaning %d, i=%d, j=%d.\n" - , dpy -> byte_order, dpy -> bitmap_bit_order, (i * bytesPerLine - j), i, j); - #endif - - } - } - - if (dpy -> bitmap_bit_order == MSBFirst) - { - images[i * bytesPerLine - j] &= 0xff << bitsToClean; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: byte_order MSBFirst, cleaning %d, i=%d, j=%d.\n" - , (i * bytesPerLine - j), i, j); - #endif - } - else - { - images[i * bytesPerLine - j] &= 0xff >> bitsToClean; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: byte_order LSBFirst, cleaning %d, i=%d, j=%d.\n" - , (i * bytesPerLine - j), i, j); - #endif - } - } - - #ifdef DUMP - fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) - { - fprintf(stderr, "[%d]", images[i]); - } - fprintf(stderr,"\n"); - #endif - - images += bytesPerLine * height; - - gi++; - - nglyphs--; - } - else if ((depth == 8) || (depth == 16) ) - { - widthInBits = gi -> width * depth; - - bytesPerLine = ROUNDUP(widthInBits, dpy -> bitmap_pad); - - widthInBytes = (widthInBits >> 3); - - bytesToClean = bytesPerLine - widthInBytes; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: nglyphs is %d, width of glyph in bits is %d, in bytes is %d.\n", - nglyphs, widthInBits, widthInBytes); - - fprintf(stderr, "nxagentCleanGlyphs: bytesPerLine is %d bytes, there are %d scanlines.\n", bytesPerLine, height); - - fprintf(stderr, "nxagentCleanGlyphs: Bytes to clean for each scanline are %d.\n", bytesToClean); - #endif - - if (bytesToClean > 0) - { - while (height > 0) - { - i = bytesToClean; - - while (i > 0) - { - *(images + (bytesPerLine - i)) = 0; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: cleaned a byte.\n"); - #endif - - i--; - } - - #ifdef DUMP - fprintf(stderr, "nxagentCleanGlyphs: depth %d, bytesToClean %d, scanline: ", depth, bytesToClean); - for (i = 0; i < bytesPerLine; i++) - { - fprintf(stderr, "[%d]", images[i]); - } - fprintf(stderr,"\n"); - #endif - - images += bytesPerLine; - - height--; - } - } - - gi++; - - nglyphs--; - - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: Breaking Out.\n"); - #endif - } - else if (depth == 32) - { - #ifdef DEBUG - fprintf(stderr, "nxagentCleanGlyphs: Found glyph with depth 32.\n"); - #endif - - gi++; - - nglyphs--; - } - else - { - #ifdef WARNING - fprintf(stderr, "nxagentCleanGlyphs: Unrecognized glyph, depth is not 8/16/24/32, it appears to be %d.\n", - depth); - #endif - - gi++; - - nglyphs--; - } - } -} - -#endif /* #ifdef NX_RENDER_CLEANUP */ - -void -XRenderAddGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - _Xconst XGlyphInfo *glyphs, - int nglyphs, - _Xconst char *images, - int nbyte_images) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderAddGlyphsReq *req; - long len; - - if (nbyte_images & 3) - nbyte_images += 4 - (nbyte_images & 3); - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderAddGlyphs, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderAddGlyphs; - req->glyphset = glyphset; - req->nglyphs = nglyphs; - len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2; - SetReqLen(req, len, len); - Data32 (dpy, (long *) gids, nglyphs * 4); - Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo)); - Data (dpy, images, nbyte_images); - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderFreeGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - int nglyphs) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderFreeGlyphsReq *req; - long len; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderFreeGlyphs, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderFreeGlyphs; - req->glyphset = glyphset; - len = nglyphs; - SetReqLen(req, len, len); - len <<= 2; - Data32 (dpy, (long *) gids, len); - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeString8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst char *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs8, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs8; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 252 glyphs in each - * bucket - */ - -#define MAX_8 252 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_8) - { - nbytes = MAX_8 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_8; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), string, MAX_8); - nchar = nchar - MAX_8; - string += MAX_8; - } - - if (nchar) - { - nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3; - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), string, nchar); - } -#undef MAX_8 - - UnlockDisplay(dpy); - SyncHandle(); -} -void -XRenderCompositeString16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned short *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs16, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs16; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - -#define MAX_16 254 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_16-1) / MAX_16) + nchar * 2; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_16) - { - nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_16; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2); - nchar = nchar - MAX_16; - string += MAX_16; - } - - if (nchar) - { - nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3; - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), (char *) string, nchar * 2); - } -#undef MAX_16 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeString32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned int *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs32, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs32; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - -#define MAX_32 254 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_32) - { - nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_32; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4); - nchar = nchar - MAX_32; - string += MAX_32; - } - - if (nchar) - { - nbytes = nchar * 4 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), (char *) string, nchar * 4); - } -#undef MAX_32 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt8 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst char *chars; - int nchars; - - #ifdef NX_RENDER_CLEANUP - - char tmpChar[4]; - int bytes_to_clean; - int bytes_to_write; - - #endif /* NX_RENDER_CLEANUP */ - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs8, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs8; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_8 252 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 252 glyphs in each - * bucket - */ - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars; - len += (elen + 3) >> 2; - } - - req->length += len; - - /* - * Send the glyphs - */ - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_8 ? MAX_8 : nchars; - - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - - #ifdef NX_RENDER_CLEANUP - - bytes_to_write = this_chars & ~3; - - bytes_to_clean = ((this_chars + 3) & ~3) - this_chars; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText8: bytes_to_write %d, bytes_to_clean are %d," - " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars); - #endif - - if (bytes_to_clean > 0) - { - if (bytes_to_write > 0) - { - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText8: found %d clean bytes, bytes_to_clean are %d," - " this_chars %d.\n", bytes_to_write, bytes_to_clean, this_chars); - #endif - - Data (dpy, chars, bytes_to_write); - chars += bytes_to_write; - } - - bytes_to_write = this_chars % 4; - memcpy (tmpChar, chars, bytes_to_write); - chars += bytes_to_write; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText8: last 32 bit, bytes_to_write are %d," - " bytes_to_clean are %d, this_chars are %d.\n", bytes_to_write, bytes_to_clean, this_chars); - #endif - - #ifdef DUMP - fprintf(stderr, "XRenderCompositeText8: bytes_to_clean %d, ", bytes_to_clean); - #endif - - while (bytes_to_clean > 0) - { - tmpChar[4 - bytes_to_clean] = 0; - bytes_to_clean--; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText8: Cleaned %d byte.\n", 4 - bytes_to_clean); - #endif - } - - Data (dpy, tmpChar, 4); - nchars -= this_chars; - - #ifdef DUMP - fprintf(stderr, "Data: "); - for (i = 0; i < 4; i++) - { - fprintf(stderr, "[%d]", tmpChar[i]); - } - fprintf(stderr,"\n"); - #endif - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText8: nchars now is %d.\n", nchars); - #endif - - continue; - } - - #endif /* NX_RENDER_CLEANUP */ - - Data (dpy, chars, this_chars); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_8 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt16 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs16Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst unsigned short *chars; - int nchars; - - #ifdef NX_RENDER_CLEANUP - - int bytes_to_write; - int bytes_to_clean; - char tmpChar[4]; - - #endif /* NX_RENDER_CLEANUP */ - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs16, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs16; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_16 254 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 254 glyphs in each - * bucket - */ - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2; - len += (elen + 3) >> 2; - } - - req->length += len; - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_16 ? MAX_16 : nchars; - int this_bytes = this_chars * 2; - - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - - #ifdef NX_RENDER_CLEANUP - - bytes_to_write = this_bytes & ~3; - bytes_to_clean = ((this_bytes + 3) & ~3) - this_bytes; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText16: this_chars %d, this_bytes %d.\n" - "bytes_to_write %d, bytes_to_clean are %d.\n", this_chars, this_bytes, - bytes_to_write, bytes_to_clean); - #endif - - if (bytes_to_clean > 0) - { - if (bytes_to_write > 0) - { - Data16 (dpy, chars, bytes_to_write); - - /* - * Cast chars to avoid errors with pointer arithmetic. - */ - - chars = (unsigned short *) ((char *) chars + bytes_to_write); - } - - bytes_to_write = this_bytes % 4; - memcpy (tmpChar, (char *) chars, bytes_to_write); - chars = (unsigned short *) ((char *) chars + bytes_to_write); - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText16: last 32 bit, bytes_to_write are %d," - " bytes_to_clean are %d.\n", bytes_to_write, bytes_to_clean); - #endif - - while (bytes_to_clean > 0) - { - tmpChar[4 - bytes_to_clean] = 0; - bytes_to_clean--; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText16: Cleaned %d byte.\n", 4 - bytes_to_clean); - #endif - } - - Data16 (dpy, tmpChar, 4); - nchars -= this_chars; - - #ifdef DEBUG - fprintf(stderr, "XRenderCompositeText16: nchars now is %d.\n", nchars); - #endif - - continue; - } - - #endif /* NX_RENDER_CLEANUP */ - - Data16 (dpy, chars, this_bytes); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_16 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt32 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs32Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst unsigned int *chars; - int nchars; - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - - GetReq(RenderCompositeGlyphs32, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs32; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_32 254 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4; - len += (elen + 3) >> 2; - } - - req->length += len; - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_32 ? MAX_32 : nchars; - int this_bytes = this_chars * 4; - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - - #ifdef NX_RENDER_CLEANUP - - elt->pad1 = 0; - elt->pad2 = 0; - - #endif /* NX_RENDER_CLEANUP */ - - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - - #ifdef TEST - fprintf(stderr, "XRenderCompositeText32: this_chars %d, this_bytes %d.\n", - this_chars, this_bytes); - #endif - - DataInt32 (dpy, chars, this_bytes); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_32 - - UnlockDisplay(dpy); - SyncHandle(); -} diff --git a/nx-X11/lib/Xrender/Glyph.c.X.original b/nx-X11/lib/Xrender/Glyph.c.X.original deleted file mode 100644 index 894bb77f2..000000000 --- a/nx-X11/lib/Xrender/Glyph.c.X.original +++ /dev/null @@ -1,712 +0,0 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * 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. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "Xrenderint.h" - -GlyphSet -XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - GlyphSet gsid; - xRenderCreateGlyphSetReq *req; - - RenderCheckExtension (dpy, info, 0); - LockDisplay(dpy); - GetReq(RenderCreateGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCreateGlyphSet; - req->gsid = gsid = XAllocID(dpy); - req->format = format->id; - UnlockDisplay(dpy); - SyncHandle(); - return gsid; -} - -GlyphSet -XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - GlyphSet gsid; - xRenderReferenceGlyphSetReq *req; - - RenderCheckExtension (dpy, info, 0); - LockDisplay(dpy); - GetReq(RenderReferenceGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderReferenceGlyphSet; - req->gsid = gsid = XAllocID(dpy); - req->existing = existing; - UnlockDisplay(dpy); - SyncHandle(); - return gsid; -} - -void -XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderFreeGlyphSetReq *req; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderFreeGlyphSet, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderFreeGlyphSet; - req->glyphset = glyphset; - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderAddGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - _Xconst XGlyphInfo *glyphs, - int nglyphs, - _Xconst char *images, - int nbyte_images) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderAddGlyphsReq *req; - long len; - - if (nbyte_images & 3) - nbyte_images += 4 - (nbyte_images & 3); - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderAddGlyphs, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderAddGlyphs; - req->glyphset = glyphset; - req->nglyphs = nglyphs; - len = (nglyphs * (SIZEOF (xGlyphInfo) + 4) + nbyte_images) >> 2; - SetReqLen(req, len, len); - Data32 (dpy, (long *) gids, nglyphs * 4); - Data16 (dpy, (short *) glyphs, nglyphs * SIZEOF (xGlyphInfo)); - Data (dpy, images, nbyte_images); - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderFreeGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - int nglyphs) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderFreeGlyphsReq *req; - long len; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - GetReq(RenderFreeGlyphs, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderFreeGlyphs; - req->glyphset = glyphset; - len = nglyphs; - SetReqLen(req, len, len); - len <<= 2; - Data32 (dpy, (long *) gids, len); - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeString8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst char *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs8, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs8; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 252 glyphs in each - * bucket - */ - -#define MAX_8 252 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_8-1) / MAX_8) + nchar; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_8) - { - nbytes = MAX_8 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_8; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), string, MAX_8); - nchar = nchar - MAX_8; - string += MAX_8; - } - - if (nchar) - { - nbytes = (nchar + SIZEOF(xGlyphElt) + 3) & ~3; - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), string, nchar); - } -#undef MAX_8 - - UnlockDisplay(dpy); - SyncHandle(); -} -void -XRenderCompositeString16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned short *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs16, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs16; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - -#define MAX_16 254 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_16-1) / MAX_16) + nchar * 2; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_16) - { - nbytes = MAX_16 * 2 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_16; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), (char *) string, MAX_16 * 2); - nchar = nchar - MAX_16; - string += MAX_16; - } - - if (nchar) - { - nbytes = (nchar * 2 + SIZEOF(xGlyphElt) + 3) & ~3; - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), (char *) string, nchar * 2); - } -#undef MAX_16 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeString32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned int *string, - int nchar) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - long len; - xGlyphElt *elt; - int nbytes; - - if (!nchar) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs32, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs32; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - -#define MAX_32 254 - - len = SIZEOF(xGlyphElt) * ((nchar + MAX_32-1) / MAX_32) + nchar * 4; - - req->length += (len + 3)>>2; /* convert to number of 32-bit words */ - - /* - * If the entire request does not fit into the remaining space in the - * buffer, flush the buffer first. - */ - - if (dpy->bufptr + len > dpy->bufmax) - _XFlush (dpy); - - while(nchar > MAX_32) - { - nbytes = MAX_32 * 4 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = MAX_32; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - memcpy ((char *) (elt + 1), (char *) string, MAX_32 * 4); - nchar = nchar - MAX_32; - string += MAX_32; - } - - if (nchar) - { - nbytes = nchar * 4 + SIZEOF(xGlyphElt); - BufAlloc (xGlyphElt *, elt, nbytes); - elt->len = nchar; - elt->deltax = xDst; - elt->deltay = yDst; - memcpy ((char *) (elt + 1), (char *) string, nchar * 4); - } -#undef MAX_32 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt8 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs8Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst char *chars; - int nchars; - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs8, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs8; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_8 252 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 252 glyphs in each - * bucket - */ - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_8-1) / MAX_8) + nchars; - len += (elen + 3) >> 2; - } - - req->length += len; - - /* - * Send the glyphs - */ - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_8 ? MAX_8 : nchars; - - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - Data (dpy, chars, this_chars); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_8 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt16 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs16Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst unsigned short *chars; - int nchars; - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - GetReq(RenderCompositeGlyphs16, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs16; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_16 254 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - /* - * xGlyphElt must be aligned on a 32-bit boundary; this is - * easily done by filling no more than 254 glyphs in each - * bucket - */ - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_16-1) / MAX_16) + nchars * 2; - len += (elen + 3) >> 2; - } - - req->length += len; - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_16 ? MAX_16 : nchars; - int this_bytes = this_chars * 2; - - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - Data16 (dpy, chars, this_bytes); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_16 - - UnlockDisplay(dpy); - SyncHandle(); -} - -void -XRenderCompositeText32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt32 *elts, - int nelt) -{ - XRenderExtDisplayInfo *info = XRenderFindDisplay (dpy); - xRenderCompositeGlyphs32Req *req; - GlyphSet glyphset; - long len; - long elen; - xGlyphElt *elt; - int i; - _Xconst unsigned int *chars; - int nchars; - - if (!nelt) - return; - - RenderSimpleCheckExtension (dpy, info); - LockDisplay(dpy); - - - GetReq(RenderCompositeGlyphs32, req); - req->reqType = info->codes->major_opcode; - req->renderReqType = X_RenderCompositeGlyphs32; - req->op = op; - req->src = src; - req->dst = dst; - req->maskFormat = maskFormat ? maskFormat->id : None; - req->glyphset = elts[0].glyphset; - req->xSrc = xSrc; - req->ySrc = ySrc; - - /* - * Compute the space necessary - */ - len = 0; - -#define MAX_32 254 - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Check for glyphset change - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - len += (SIZEOF (xGlyphElt) + 4) >> 2; - } - nchars = elts[i].nchars; - elen = SIZEOF(xGlyphElt) * ((nchars + MAX_32) / MAX_32) + nchars *4; - len += (elen + 3) >> 2; - } - - req->length += len; - - glyphset = elts[0].glyphset; - for (i = 0; i < nelt; i++) - { - /* - * Switch glyphsets - */ - if (elts[i].glyphset != glyphset) - { - glyphset = elts[i].glyphset; - BufAlloc (xGlyphElt *, elt, SIZEOF (xGlyphElt)); - elt->len = 0xff; - elt->deltax = 0; - elt->deltay = 0; - Data32(dpy, &glyphset, 4); - } - nchars = elts[i].nchars; - xDst = elts[i].xOff; - yDst = elts[i].yOff; - chars = elts[i].chars; - while (nchars) - { - int this_chars = nchars > MAX_32 ? MAX_32 : nchars; - int this_bytes = this_chars * 4; - BufAlloc (xGlyphElt *, elt, SIZEOF(xGlyphElt)) - elt->len = this_chars; - elt->deltax = xDst; - elt->deltay = yDst; - xDst = 0; - yDst = 0; - DataInt32 (dpy, chars, this_bytes); - nchars -= this_chars; - chars += this_chars; - } - } -#undef MAX_32 - - UnlockDisplay(dpy); - SyncHandle(); -} diff --git a/nx-X11/lib/Xrender/Xrender.h.NX.original b/nx-X11/lib/Xrender/Xrender.h.NX.original deleted file mode 100644 index 4d125cd81..000000000 --- a/nx-X11/lib/Xrender/Xrender.h.NX.original +++ /dev/null @@ -1,544 +0,0 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * 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. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifndef _XRENDER_H_ -#define _XRENDER_H_ - -#define NX_CLEANUP - -#include <X11/extensions/render.h> - -#include <X11/Xlib.h> -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> -#include <X11/Xutil.h> - -#ifdef NX_CLEANUP -#include "renderproto.h" -#endif - -typedef struct { - short red; - short redMask; - short green; - short greenMask; - short blue; - short blueMask; - short alpha; - short alphaMask; -} XRenderDirectFormat; - -typedef struct { - PictFormat id; - int type; - int depth; - XRenderDirectFormat direct; - Colormap colormap; -} XRenderPictFormat; - -#define PictFormatID (1 << 0) -#define PictFormatType (1 << 1) -#define PictFormatDepth (1 << 2) -#define PictFormatRed (1 << 3) -#define PictFormatRedMask (1 << 4) -#define PictFormatGreen (1 << 5) -#define PictFormatGreenMask (1 << 6) -#define PictFormatBlue (1 << 7) -#define PictFormatBlueMask (1 << 8) -#define PictFormatAlpha (1 << 9) -#define PictFormatAlphaMask (1 << 10) -#define PictFormatColormap (1 << 11) - -typedef struct _XRenderPictureAttributes { - int repeat; - Picture alpha_map; - int alpha_x_origin; - int alpha_y_origin; - int clip_x_origin; - int clip_y_origin; - Pixmap clip_mask; - Bool graphics_exposures; - int subwindow_mode; - int poly_edge; - int poly_mode; - Atom dither; - Bool component_alpha; -} XRenderPictureAttributes; - -typedef struct { - unsigned short red; - unsigned short green; - unsigned short blue; - unsigned short alpha; -} XRenderColor; - -typedef struct _XGlyphInfo { - unsigned short width; - unsigned short height; - short x; - short y; - short xOff; - short yOff; -} XGlyphInfo; - -typedef struct _XGlyphElt8 { - GlyphSet glyphset; - _Xconst char *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt8; - -typedef struct _XGlyphElt16 { - GlyphSet glyphset; - _Xconst unsigned short *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt16; - -typedef struct _XGlyphElt32 { - GlyphSet glyphset; - _Xconst unsigned int *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt32; - -typedef double XDouble; - -typedef struct _XPointDouble { - XDouble x, y; -} XPointDouble; - -#define XDoubleToFixed(f) ((XFixed) ((f) * 65536)) -#define XFixedToDouble(f) (((XDouble) (f)) / 65536) - -typedef int XFixed; - -typedef struct _XPointFixed { - XFixed x, y; -} XPointFixed; - -typedef struct _XLineFixed { - XPointFixed p1, p2; -} XLineFixed; - -typedef struct _XTriangle { - XPointFixed p1, p2, p3; -} XTriangle; - -typedef struct _XCircle { - XFixed x; - XFixed y; - XFixed radius; -} XCircle; - -typedef struct _XTrapezoid { - XFixed top, bottom; - XLineFixed left, right; -} XTrapezoid; - -typedef struct _XTransform { - XFixed matrix[3][3]; -} XTransform; - -typedef struct _XFilters { - int nfilter; - char **filter; - int nalias; - short *alias; -} XFilters; - -typedef struct _XIndexValue { - unsigned long pixel; - unsigned short red, green, blue, alpha; -} XIndexValue; - -typedef struct _XAnimCursor { - Cursor cursor; - unsigned long delay; -} XAnimCursor; - -typedef struct _XSpanFix { - XFixed left, right, y; -} XSpanFix; - -typedef struct _XTrap { - XSpanFix top, bottom; -} XTrap; - -typedef struct _XLinearGradient { - XPointFixed p1; - XPointFixed p2; -} XLinearGradient; - -typedef struct _XRadialGradient { - XCircle inner; - XCircle outer; -} XRadialGradient; - -typedef struct _XConicalGradient { - XPointFixed center; - XFixed angle; /* in degrees */ -} XConicalGradient; - -_XFUNCPROTOBEGIN - -Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep); - -Status XRenderQueryVersion (Display *dpy, - int *major_versionp, - int *minor_versionp); - -Status XRenderQueryFormats (Display *dpy); - -int XRenderQuerySubpixelOrder (Display *dpy, int screen); - -Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel); - -XRenderPictFormat * -XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual); - -XRenderPictFormat * -XRenderFindFormat (Display *dpy, - unsigned long mask, - _Xconst XRenderPictFormat *templ, - int count); - -#define PictStandardARGB32 0 -#define PictStandardRGB24 1 -#define PictStandardA8 2 -#define PictStandardA4 3 -#define PictStandardA1 4 -#define PictStandardNUM 5 - -XRenderPictFormat * -XRenderFindStandardFormat (Display *dpy, - int format); - -XIndexValue * -XRenderQueryPictIndexValues(Display *dpy, - _Xconst XRenderPictFormat *format, - int *num); - -Picture -XRenderCreatePicture (Display *dpy, - Drawable drawable, - _Xconst XRenderPictFormat *format, - unsigned long valuemask, - _Xconst XRenderPictureAttributes *attributes); - -void -XRenderChangePicture (Display *dpy, - Picture picture, - unsigned long valuemask, - _Xconst XRenderPictureAttributes *attributes); - -void -XRenderSetPictureClipRectangles (Display *dpy, - Picture picture, - int xOrigin, - int yOrigin, - _Xconst XRectangle *rects, - int n); - -void -XRenderSetPictureClipRegion (Display *dpy, - Picture picture, - Region r); - -void -XRenderSetPictureTransform (Display *dpy, - Picture picture, - XTransform *transform); - -void -XRenderFreePicture (Display *dpy, - Picture picture); - -void -XRenderComposite (Display *dpy, - int op, - Picture src, - Picture mask, - Picture dst, - int src_x, - int src_y, - int mask_x, - int mask_y, - int dst_x, - int dst_y, - unsigned int width, - unsigned int height); - -GlyphSet -XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format); - -GlyphSet -XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing); - -void -XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset); - -#ifdef NX_CLEANUP - -void XRenderCleanGlyphs (xGlyphInfo *gi, - int nglyphs, - CARD8 *images, - int depth, - Display *dpy); - -#endif /* #ifdef NX_CLEANUP */ - -void -XRenderAddGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - _Xconst XGlyphInfo *glyphs, - int nglyphs, - _Xconst char *images, - int nbyte_images); - -void -XRenderFreeGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - int nglyphs); - -void -XRenderCompositeString8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst char *string, - int nchar); - -void -XRenderCompositeString16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned short *string, - int nchar); - -void -XRenderCompositeString32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned int *string, - int nchar); - -void -XRenderCompositeText8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt8 *elts, - int nelt); - -void -XRenderCompositeText16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt16 *elts, - int nelt); - -void -XRenderCompositeText32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt32 *elts, - int nelt); - -void -XRenderFillRectangle (Display *dpy, - int op, - Picture dst, - _Xconst XRenderColor *color, - int x, - int y, - unsigned int width, - unsigned int height); - -void -XRenderFillRectangles (Display *dpy, - int op, - Picture dst, - _Xconst XRenderColor *color, - _Xconst XRectangle *rectangles, - int n_rects); - -void -XRenderCompositeTrapezoids (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XTrapezoid *traps, - int ntrap); - -void -XRenderCompositeTriangles (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XTriangle *triangles, - int ntriangle); - -void -XRenderCompositeTriStrip (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XPointFixed *points, - int npoint); - -void -XRenderCompositeTriFan (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XPointFixed *points, - int npoint); - -void -XRenderCompositeDoublePoly (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XPointDouble *fpoints, - int npoints, - int winding); -Status -XRenderParseColor(Display *dpy, - char *spec, - XRenderColor *def); - -Cursor -XRenderCreateCursor (Display *dpy, - Picture source, - unsigned int x, - unsigned int y); - -XFilters * -XRenderQueryFilters (Display *dpy, Drawable drawable); - -void -XRenderSetPictureFilter (Display *dpy, - Picture picture, - char *filter, - XFixed *params, - int nparams); - -Cursor -XRenderCreateAnimCursor (Display *dpy, - int ncursor, - XAnimCursor *cursors); - - -void -XRenderAddTraps (Display *dpy, - Picture picture, - int xOff, - int yOff, - _Xconst XTrap *traps, - int ntrap); - -Picture XRenderCreateSolidFill (Display *dpy, - const XRenderColor *color); - -Picture XRenderCreateLinearGradient (Display *dpy, - const XLinearGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -Picture XRenderCreateRadialGradient (Display *dpy, - const XRadialGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -Picture XRenderCreateConicalGradient (Display *dpy, - const XConicalGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -_XFUNCPROTOEND - -#endif /* _XRENDER_H_ */ diff --git a/nx-X11/lib/Xrender/Xrender.h.X.original b/nx-X11/lib/Xrender/Xrender.h.X.original deleted file mode 100644 index 4e4723a64..000000000 --- a/nx-X11/lib/Xrender/Xrender.h.X.original +++ /dev/null @@ -1,528 +0,0 @@ -/* - * - * Copyright © 2000 SuSE, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of SuSE not be used in advertising or - * publicity pertaining to distribution of the software without specific, - * written prior permission. SuSE makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE - * 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. - * - * Author: Keith Packard, SuSE, Inc. - */ - -#ifndef _XRENDER_H_ -#define _XRENDER_H_ - -#include <X11/extensions/render.h> - -#include <X11/Xlib.h> -#include <X11/Xfuncproto.h> -#include <X11/Xosdefs.h> -#include <X11/Xutil.h> - -typedef struct { - short red; - short redMask; - short green; - short greenMask; - short blue; - short blueMask; - short alpha; - short alphaMask; -} XRenderDirectFormat; - -typedef struct { - PictFormat id; - int type; - int depth; - XRenderDirectFormat direct; - Colormap colormap; -} XRenderPictFormat; - -#define PictFormatID (1 << 0) -#define PictFormatType (1 << 1) -#define PictFormatDepth (1 << 2) -#define PictFormatRed (1 << 3) -#define PictFormatRedMask (1 << 4) -#define PictFormatGreen (1 << 5) -#define PictFormatGreenMask (1 << 6) -#define PictFormatBlue (1 << 7) -#define PictFormatBlueMask (1 << 8) -#define PictFormatAlpha (1 << 9) -#define PictFormatAlphaMask (1 << 10) -#define PictFormatColormap (1 << 11) - -typedef struct _XRenderPictureAttributes { - int repeat; - Picture alpha_map; - int alpha_x_origin; - int alpha_y_origin; - int clip_x_origin; - int clip_y_origin; - Pixmap clip_mask; - Bool graphics_exposures; - int subwindow_mode; - int poly_edge; - int poly_mode; - Atom dither; - Bool component_alpha; -} XRenderPictureAttributes; - -typedef struct { - unsigned short red; - unsigned short green; - unsigned short blue; - unsigned short alpha; -} XRenderColor; - -typedef struct _XGlyphInfo { - unsigned short width; - unsigned short height; - short x; - short y; - short xOff; - short yOff; -} XGlyphInfo; - -typedef struct _XGlyphElt8 { - GlyphSet glyphset; - _Xconst char *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt8; - -typedef struct _XGlyphElt16 { - GlyphSet glyphset; - _Xconst unsigned short *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt16; - -typedef struct _XGlyphElt32 { - GlyphSet glyphset; - _Xconst unsigned int *chars; - int nchars; - int xOff; - int yOff; -} XGlyphElt32; - -typedef double XDouble; - -typedef struct _XPointDouble { - XDouble x, y; -} XPointDouble; - -#define XDoubleToFixed(f) ((XFixed) ((f) * 65536)) -#define XFixedToDouble(f) (((XDouble) (f)) / 65536) - -typedef int XFixed; - -typedef struct _XPointFixed { - XFixed x, y; -} XPointFixed; - -typedef struct _XLineFixed { - XPointFixed p1, p2; -} XLineFixed; - -typedef struct _XTriangle { - XPointFixed p1, p2, p3; -} XTriangle; - -typedef struct _XCircle { - XFixed x; - XFixed y; - XFixed radius; -} XCircle; - -typedef struct _XTrapezoid { - XFixed top, bottom; - XLineFixed left, right; -} XTrapezoid; - -typedef struct _XTransform { - XFixed matrix[3][3]; -} XTransform; - -typedef struct _XFilters { - int nfilter; - char **filter; - int nalias; - short *alias; -} XFilters; - -typedef struct _XIndexValue { - unsigned long pixel; - unsigned short red, green, blue, alpha; -} XIndexValue; - -typedef struct _XAnimCursor { - Cursor cursor; - unsigned long delay; -} XAnimCursor; - -typedef struct _XSpanFix { - XFixed left, right, y; -} XSpanFix; - -typedef struct _XTrap { - XSpanFix top, bottom; -} XTrap; - -typedef struct _XLinearGradient { - XPointFixed p1; - XPointFixed p2; -} XLinearGradient; - -typedef struct _XRadialGradient { - XCircle inner; - XCircle outer; -} XRadialGradient; - -typedef struct _XConicalGradient { - XPointFixed center; - XFixed angle; /* in degrees */ -} XConicalGradient; - -_XFUNCPROTOBEGIN - -Bool XRenderQueryExtension (Display *dpy, int *event_basep, int *error_basep); - -Status XRenderQueryVersion (Display *dpy, - int *major_versionp, - int *minor_versionp); - -Status XRenderQueryFormats (Display *dpy); - -int XRenderQuerySubpixelOrder (Display *dpy, int screen); - -Bool XRenderSetSubpixelOrder (Display *dpy, int screen, int subpixel); - -XRenderPictFormat * -XRenderFindVisualFormat (Display *dpy, _Xconst Visual *visual); - -XRenderPictFormat * -XRenderFindFormat (Display *dpy, - unsigned long mask, - _Xconst XRenderPictFormat *templ, - int count); - -#define PictStandardARGB32 0 -#define PictStandardRGB24 1 -#define PictStandardA8 2 -#define PictStandardA4 3 -#define PictStandardA1 4 -#define PictStandardNUM 5 - -XRenderPictFormat * -XRenderFindStandardFormat (Display *dpy, - int format); - -XIndexValue * -XRenderQueryPictIndexValues(Display *dpy, - _Xconst XRenderPictFormat *format, - int *num); - -Picture -XRenderCreatePicture (Display *dpy, - Drawable drawable, - _Xconst XRenderPictFormat *format, - unsigned long valuemask, - _Xconst XRenderPictureAttributes *attributes); - -void -XRenderChangePicture (Display *dpy, - Picture picture, - unsigned long valuemask, - _Xconst XRenderPictureAttributes *attributes); - -void -XRenderSetPictureClipRectangles (Display *dpy, - Picture picture, - int xOrigin, - int yOrigin, - _Xconst XRectangle *rects, - int n); - -void -XRenderSetPictureClipRegion (Display *dpy, - Picture picture, - Region r); - -void -XRenderSetPictureTransform (Display *dpy, - Picture picture, - XTransform *transform); - -void -XRenderFreePicture (Display *dpy, - Picture picture); - -void -XRenderComposite (Display *dpy, - int op, - Picture src, - Picture mask, - Picture dst, - int src_x, - int src_y, - int mask_x, - int mask_y, - int dst_x, - int dst_y, - unsigned int width, - unsigned int height); - -GlyphSet -XRenderCreateGlyphSet (Display *dpy, _Xconst XRenderPictFormat *format); - -GlyphSet -XRenderReferenceGlyphSet (Display *dpy, GlyphSet existing); - -void -XRenderFreeGlyphSet (Display *dpy, GlyphSet glyphset); - -void -XRenderAddGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - _Xconst XGlyphInfo *glyphs, - int nglyphs, - _Xconst char *images, - int nbyte_images); - -void -XRenderFreeGlyphs (Display *dpy, - GlyphSet glyphset, - _Xconst Glyph *gids, - int nglyphs); - -void -XRenderCompositeString8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst char *string, - int nchar); - -void -XRenderCompositeString16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned short *string, - int nchar); - -void -XRenderCompositeString32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - GlyphSet glyphset, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst unsigned int *string, - int nchar); - -void -XRenderCompositeText8 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt8 *elts, - int nelt); - -void -XRenderCompositeText16 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt16 *elts, - int nelt); - -void -XRenderCompositeText32 (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XGlyphElt32 *elts, - int nelt); - -void -XRenderFillRectangle (Display *dpy, - int op, - Picture dst, - _Xconst XRenderColor *color, - int x, - int y, - unsigned int width, - unsigned int height); - -void -XRenderFillRectangles (Display *dpy, - int op, - Picture dst, - _Xconst XRenderColor *color, - _Xconst XRectangle *rectangles, - int n_rects); - -void -XRenderCompositeTrapezoids (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XTrapezoid *traps, - int ntrap); - -void -XRenderCompositeTriangles (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XTriangle *triangles, - int ntriangle); - -void -XRenderCompositeTriStrip (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XPointFixed *points, - int npoint); - -void -XRenderCompositeTriFan (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - _Xconst XPointFixed *points, - int npoint); - -void -XRenderCompositeDoublePoly (Display *dpy, - int op, - Picture src, - Picture dst, - _Xconst XRenderPictFormat *maskFormat, - int xSrc, - int ySrc, - int xDst, - int yDst, - _Xconst XPointDouble *fpoints, - int npoints, - int winding); -Status -XRenderParseColor(Display *dpy, - char *spec, - XRenderColor *def); - -Cursor -XRenderCreateCursor (Display *dpy, - Picture source, - unsigned int x, - unsigned int y); - -XFilters * -XRenderQueryFilters (Display *dpy, Drawable drawable); - -void -XRenderSetPictureFilter (Display *dpy, - Picture picture, - char *filter, - XFixed *params, - int nparams); - -Cursor -XRenderCreateAnimCursor (Display *dpy, - int ncursor, - XAnimCursor *cursors); - - -void -XRenderAddTraps (Display *dpy, - Picture picture, - int xOff, - int yOff, - _Xconst XTrap *traps, - int ntrap); - -Picture XRenderCreateSolidFill (Display *dpy, - const XRenderColor *color); - -Picture XRenderCreateLinearGradient (Display *dpy, - const XLinearGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -Picture XRenderCreateRadialGradient (Display *dpy, - const XRadialGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -Picture XRenderCreateConicalGradient (Display *dpy, - const XConicalGradient *gradient, - const XFixed *stops, - const XRenderColor *colors, - int nstops); - -_XFUNCPROTOEND - -#endif /* _XRENDER_H_ */ diff --git a/nx-X11/lib/font/fontfile/encparse.c.NX.original b/nx-X11/lib/font/fontfile/encparse.c.NX.original deleted file mode 100644 index 6262aff07..000000000 --- a/nx-X11/lib/font/fontfile/encparse.c.NX.original +++ /dev/null @@ -1,966 +0,0 @@ -/* -Copyright (c) 1998-2001 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */ - -/* Parser for encoding files */ - -/* This code assumes that we are using ASCII. We don't use the ctype - functions, as they depend on the current locale. On the other - hand, we do use strcasecmp, but only on strings that we've checked - to be pure ASCII. Bloody ``Code Set Independence''. */ - -#include <string.h> -#include <stdio.h> - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <strings.h> -#endif - -#ifndef FONTENC_NO_LIBFONT - -#include <X11/fonts/fntfilio.h> -#include <X11/fonts/fntfilst.h> - -#else - -#include <stdlib.h> -#define xalloc(n) malloc(n) -#define xrealloc(p, n) realloc(p, n) -#define xfree(p) free(p) - -#include "zlib.h" -typedef gzFile FontFilePtr; -#define FontFileGetc(f) gzgetc(f) -#define FontFileOpen(filename) gzopen(filename, "rb") -#define FontFileClose(f) gzclose(f) - -#define MAXFONTFILENAMELEN 1024 -#define MAXFONTNAMELEN 1024 - -#endif - -#include <X11/fonts/fontenc.h> -#include "fontencI.h" - -#define MAXALIASES 20 - -#define EOF_TOKEN -1 -#define ERROR_TOKEN -2 -#define EOL_TOKEN 0 -#define NUMBER_TOKEN 1 -#define KEYWORD_TOKEN 2 - -#define EOF_LINE -1 -#define ERROR_LINE -2 -#define STARTENCODING_LINE 1 -#define STARTMAPPING_LINE 2 -#define ENDMAPPING_LINE 3 -#define CODE_LINE 4 -#define CODE_RANGE_LINE 5 -#define CODE_UNDEFINE_LINE 6 -#define NAME_LINE 7 -#define SIZE_LINE 8 -#define ALIAS_LINE 9 -#define FIRSTINDEX_LINE 10 - -/* Return from lexer */ -#define MAXKEYWORDLEN 100 - -static long number_value; -static char keyword_value[MAXKEYWORDLEN+1]; - -static long value1, value2, value3; - -/* Lexer code */ - -/* Skip to the beginning of new line */ -static void -skipEndOfLine(FontFilePtr f, int c) -{ - if(c == 0) - c = FontFileGetc(f); - - for(;;) - if(c <= 0 || c == '\n') - return; - else - c = FontFileGetc(f); -} - -/* Get a number; we're at the first digit. */ -static unsigned -getnum(FontFilePtr f, int c, int *cp) -{ - unsigned n = 0; - int base = 10; - - /* look for `0' or `0x' prefix */ - if(c == '0') { - c = FontFileGetc(f); - base = 8; - if(c == 'x' || c == 'X') { - base = 16; - c = FontFileGetc(f); - } - } - - /* accumulate digits */ - for(;;) { - if ('0' <= c && c <= '9') { - n *= base; n += c - '0'; - } else if('a' <= c && c <= 'f') { - n *= base; n += c - 'a' + 10; - } else if('A' <=c && c <= 'F') { - n *= base; n += c - 'A' + 10; - } else - break; - c = FontFileGetc(f); - } - - *cp = c; return n; -} - -/* Skip to beginning of new line; return 1 if only whitespace was found. */ -static int -endOfLine(FontFilePtr f, int c) -{ - if(c == 0) - c = FontFileGetc(f); - - for(;;) { - if(c <= 0 || c == '\n') - return 1; - else if(c == '#') { - skipEndOfLine(f,c); - return 1; - } - else if(c == ' ' || c == '\t') { - skipEndOfLine(f,c); - return 0; - } - c = FontFileGetc(f); - } -} - -/* Get a token; we're at first char */ -static int -gettoken(FontFilePtr f, int c, int *cp) -{ - char *p; - - if(c <= 0) - c = FontFileGetc(f); - - if(c <= 0) { - return EOF_TOKEN; - } - - while(c == ' ' || c == '\t') - c = FontFileGetc(f); - - if(c=='\n') { - return EOL_TOKEN; - } else if(c == '#') { - skipEndOfLine(f,c); - return EOL_TOKEN; - } else if(c >= '0' && c <= '9') { - number_value = getnum(f,c,cp); - return NUMBER_TOKEN; - } else if((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - c == '/' || c == '_' || c == '-' || c == '.') { - p = keyword_value; - *p++ = c; - while(p-keyword_value < MAXKEYWORDLEN) { - c = FontFileGetc(f); - if(c <= ' ' || c > '~' || c == '#') - break; - *p++ = c; - } - *cp = c; - *p = '\0'; - return KEYWORD_TOKEN; - } else { - *cp = c; - return ERROR_TOKEN; - } -} - -/* Parse a line. - * Always skips to the beginning of a new line, even if an error occurs */ -static int -getnextline(FontFilePtr f) -{ - int c, token; - c = FontFileGetc(f); - if(c <= 0) - return EOF_LINE; - - again: - token=gettoken(f,c,&c); - - switch(token) { - case EOF_TOKEN: - return EOF_LINE; - case EOL_TOKEN: - /* empty line */ - c = FontFileGetc(f); - goto again; - case NUMBER_TOKEN: - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value3 = number_value; - return CODE_RANGE_LINE; - case EOL_TOKEN: - return CODE_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - case KEYWORD_TOKEN: - if(!endOfLine(f,c)) - return ERROR_LINE; - else - return NAME_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - case KEYWORD_TOKEN: - if(!strcasecmp(keyword_value, "STARTENCODING")) { - token = gettoken(f,c,&c); - if(token == KEYWORD_TOKEN) { - if(endOfLine(f,c)) - return STARTENCODING_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "ALIAS")) { - token = gettoken(f,c,&c); - if(token == KEYWORD_TOKEN) { - if(endOfLine(f,c)) - return ALIAS_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "SIZE")) { - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - return SIZE_LINE; - case EOL_TOKEN: - value2=0; - return SIZE_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) { - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - return FIRSTINDEX_LINE; - case EOL_TOKEN: - value2 = 0; - return FIRSTINDEX_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "STARTMAPPING")) { - keyword_value[0] = 0; - value1 = 0; value1 = 0; - /* first a keyword */ - token = gettoken(f,c,&c); - if(token != KEYWORD_TOKEN) { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - /* optional first integer */ - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - } else if(token == EOL_TOKEN) { - return STARTMAPPING_LINE; - } else { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - /* optional second integer */ - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value2 = number_value; - } else if(token == EOL_TOKEN) { - return STARTMAPPING_LINE; - } else { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - if(!endOfLine(f,c)) - return ERROR_LINE; - else { - return STARTMAPPING_LINE; - } - } else if(!strcasecmp(keyword_value, "UNDEFINE")) { - /* first integer */ - token = gettoken(f,c,&c); - if(token != NUMBER_TOKEN) { - skipEndOfLine(f,c); - return ERROR_LINE; - } - value1 = number_value; - /* optional second integer */ - token = gettoken(f,c,&c); - if(token == EOL_TOKEN) { - value2 = value1; - return CODE_UNDEFINE_LINE; - } else if(token == NUMBER_TOKEN) { - value2 = number_value; - if(endOfLine(f,c)) { - return CODE_UNDEFINE_LINE; - } else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "ENDENCODING")) { - if(endOfLine(f,c)) - return EOF_LINE; - else - return ERROR_LINE; - } else if(!strcasecmp(keyword_value, "ENDMAPPING")) { - if(endOfLine(f,c)) - return ENDMAPPING_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - default: - return ERROR_LINE; - } -} - -static void -install_mapping(FontEncPtr encoding, FontMapPtr mapping) -{ - FontMapPtr m; - - if(encoding->mappings == NULL) - encoding->mappings = mapping; - else { - m = encoding->mappings; - while(m->next != NULL) - m = m->next; - m->next = mapping; - } - mapping->next = NULL; - mapping->encoding = encoding; -} - -static int -setCode(unsigned from, unsigned to, unsigned row_size, - unsigned *first, unsigned *last, - unsigned *encsize, unsigned short **enc) -{ - unsigned index, i; - unsigned short *newenc; - - if(from>0xFFFF) - return 0; /* success */ - - if(row_size==0) - index=from; - else { - if((value1 & 0xFF) >= row_size) - return 0; /* ignore out of range mappings */ - index = (from>>8) * row_size + (from&0xFF); - } - - /* Optimize away useless identity mappings. This is only expected - to be useful with linear encodings. */ - if(index == to && (index < *first || index > *last)) - return 0; - if(*encsize == 0) { - *encsize = (index < 256) ? 256 : 0x10000; - *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short)); - if(*enc == NULL) { - *encsize = 0; - return 1; - } - } else if(*encsize <= index) { - *encsize = 0x10000; - if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL) - return 1; - *enc = newenc; - } - if(*first > *last) { - *first = *last = index; - } - if(index < *first) { - for(i = index; i < *first; i++) - (*enc)[i] = i; - *first = index; - } - if(index > *last) { - for(i = *last + 1; i <= index; i++) - (*enc)[i] = i; - *last = index; - } - (*enc)[index] = to; - return 0; -} - -/* Parser. If headerOnly is true, we're only interested in the - data contained in the encoding file's header. */ - -/* As font encodings are currently never freed, the allocations done - by this function are mostly its private business. Note, however, - that FontEncIdentify needs to free the header fields -- so if you - change this function, you may need to change FontEncIdentify. */ - -/* I want a garbage collector. */ - -static FontEncPtr -parseEncodingFile(FontFilePtr f, int headerOnly) -{ - int line; - - unsigned short *enc=NULL; - char **nam = NULL, **newnam; - unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0; - FontEncPtr encoding = NULL; - FontMapPtr mapping = NULL; - FontEncSimpleMapPtr sm; - FontEncSimpleNamePtr sn; - char *aliases[MAXALIASES]; - int numaliases=0; - -#if 0 - /* GCC complains about unused labels. Please fix GCC rather than - obfuscating my code. */ - no_encoding: -#endif - line = getnextline(f); - switch(line) { - case EOF_LINE: - goto error; - case STARTENCODING_LINE: - encoding = (FontEncPtr)xalloc(sizeof(FontEncRec)); - if(encoding == NULL) - goto error; - encoding->name = (char*)xalloc(strlen(keyword_value)+1); - if(encoding->name == NULL) - goto error; - strcpy(encoding->name, keyword_value); - encoding->size = 256; - encoding->row_size = 0; - encoding->mappings = NULL; - encoding->next = NULL; - encoding->first = encoding->first_col=0; - goto no_mapping; - default: - goto error; - } - - no_mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto done; - case ALIAS_LINE: - if(numaliases < MAXALIASES) { - aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1); - if(aliases[numaliases] == NULL) - goto error; - strcpy(aliases[numaliases], keyword_value); - numaliases++; - } - goto no_mapping; - case SIZE_LINE: - encoding->size = value1; - encoding->row_size = value2; - goto no_mapping; - case FIRSTINDEX_LINE: - encoding->first = value1; - encoding->first_col = value2; - goto no_mapping; - case STARTMAPPING_LINE: - if(headerOnly) - goto done; - if(!strcasecmp(keyword_value, "unicode")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_UNICODE; - mapping->pid = 0; - mapping->eid = 0; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto mapping; - } else if(!strcasecmp(keyword_value, "cmap")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_TRUETYPE; - mapping->pid = value1; - mapping->eid = value2; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto mapping; - } else if(!strcasecmp(keyword_value, "postscript")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_POSTSCRIPT; - mapping->pid = 0; - mapping->eid = 0; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto string_mapping; - } else { /* unknown mapping type -- ignore */ - goto skipmapping; - } - /* NOTREACHED */ - goto error; - default: goto no_mapping; /* ignore unknown lines */ - } - - skipmapping: - line = getnextline(f); - switch(line) { - case ENDMAPPING_LINE: - goto no_mapping; - case EOF_LINE: - goto error; - default: - goto skipmapping; - } - - mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto error; - case ENDMAPPING_LINE: - mapping->recode = FontEncSimpleRecode; - mapping->name = FontEncUndefinedName; - mapping->client_data = sm = - (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec)); - if(sm == NULL) - goto error; - sm->row_size = encoding->row_size; - if(first <= last) { - sm->first = first; - sm->len=last-first+1; - sm->map = - (unsigned short*)xalloc(sm->len * sizeof(unsigned short)); - if(sm->map == NULL) { - xfree(sm); - mapping->client_data = sm = NULL; - goto error; - } - } else { - sm->first = 0; - sm->len = 0; - sm->map = 0; - } - for(i=0; i < sm->len; i++) - sm -> map[i] = enc[first+i]; - install_mapping(encoding, mapping); - mapping = 0; - first = 0xFFFF; last=0; - goto no_mapping; - - case CODE_LINE: - if(setCode(value1, value2, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - goto mapping; - - case CODE_RANGE_LINE: - if(value1 > 0x10000) - value1 = 0x10000; - if(value2 > 0x10000) - value2 = 0x10000; - if(value2 < value1) - goto mapping; - /* Do the last value first to avoid having to realloc() */ - if(setCode(value2, value3+(value2-value1), encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - for(i=value1; i<value2; i++) { - if(setCode(i, value3+(i-value1), encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - } - goto mapping; - - case CODE_UNDEFINE_LINE: - if(value1 > 0x10000) - value1 = 0x10000; - if(value2 > 0x10000) - value2 = 0x10000; - if(value2 < value1) - goto mapping; - /* Do the last value first to avoid having to realloc() */ - if(setCode(value2, 0, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - for(i = value1; i < value2; i++) { - if(setCode(i, 0, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - } - goto mapping; - - default: goto mapping; /* ignore unknown lines */ - } - - string_mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto error; - case ENDMAPPING_LINE: - mapping->recode = FontEncUndefinedRecode; - mapping->name = FontEncSimpleName; - mapping->client_data = sn = - (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec)); - if(sn == NULL) - goto error; - if(first > last) { - xfree(sn); - mapping->client_data = sn = NULL; - goto error; - } - sn->first = first; - sn->len = last - first + 1; - sn->map = (char**)xalloc(sn->len*sizeof(char*)); - if(sn->map == NULL) { - xfree(sn); - mapping->client_data = sn = NULL; - goto error; - } - for(i = 0; i < sn->len; i++) - sn->map[i] = nam[first+i]; - install_mapping(encoding,mapping); - mapping = 0; - first = 0xFFFF; last=0; - goto no_mapping; - case NAME_LINE: - if(value1 >= 0x10000) goto string_mapping; - if(namsize == 0) { - namsize = (value1) < 256 ? 256 : 0x10000; - nam = (char**)xalloc(namsize * sizeof(char*)); - if(nam == NULL) { - namsize=0; - goto error; - } - } else if(namsize <= value1) { - namsize = 0x10000; - if((newnam = (char**)xrealloc(nam, namsize)) == NULL) - goto error; - nam = newnam; - } - if(first > last) { - first = last = value1; - } - if(value1 < first) { - for(i = value1; i < first; i++) - nam[i] = NULL; - first = value1; - } - if(value1 > last) { - for(i=last+1; i <= value1; i++) - nam[i]=NULL; - last = value1; - } - nam[value1] = (char*)xalloc(strlen(keyword_value)+1); - if(nam[value1] == NULL) { - goto error; - } - strcpy(nam[value1], keyword_value); - goto string_mapping; - - default: goto string_mapping; /* ignore unknown lines */ - } - - done: - if(encsize) xfree(enc); encsize=0; enc = NULL; - if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */ - - encoding->aliases=NULL; - if(numaliases) { - encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*)); - if(encoding->aliases == NULL) - goto error; - for(i=0; i<numaliases; i++) - encoding->aliases[i] = aliases[i]; - encoding->aliases[numaliases]=NULL; - } - - return encoding; - -error: - if(encsize) xfree(enc); encsize=0; - if(namsize) { - for(i = first; i <= last; i++) - if(nam[i]) - xfree(nam[i]); - xfree(nam); - namsize = 0; - } - if(mapping) { - if(mapping->client_data) xfree(mapping->client_data); - xfree(mapping); - } - if(encoding) { - if(encoding->name) xfree(encoding->name); - for(mapping = encoding->mappings; mapping; mapping = mapping->next) { - if(mapping->client_data) xfree(mapping->client_data); - xfree(mapping); - } - xfree(encoding); - } - for(i = 0; i < numaliases; i++) - xfree(aliases[i]); - /* We don't need to free sn and sm as they handled locally in the body.*/ - return 0; -} - -char* -FontEncDirectory() -{ - static char* dir = NULL; - - if(dir == NULL) { - char *c = getenv("FONT_ENCODINGS_DIRECTORY"); - if(c) { - dir = malloc(strlen(c) + 1); - if(!dir) - return NULL; - strcpy(dir, c); - } else { - dir = FONT_ENCODINGS_DIRECTORY; - } - } - return dir; -} - -static void -parseFontFileName(const char *fontFileName, char *buf, char *dir) -{ - const char *p; - char *q, *lastslash; - - for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) { - *q = *p; - if(*p == '/') - lastslash = q+1; - } - - if(!lastslash) - lastslash = dir; - - *lastslash = '\0'; - - if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) { - strcpy(buf, dir); - strcat(buf, "encodings.dir"); - } -} - -static FontEncPtr -FontEncReallyReallyLoad(const char *charset, - const char *dirname, const char *dir) -{ - FontFilePtr f; - FILE *file; - FontEncPtr encoding; - char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN], - buf[MAXFONTFILENAMELEN]; - int count, n; - static char format[24] = ""; - - /* As we don't really expect to open encodings that often, we don't - take the trouble of caching encodings directories. */ - - if((file = fopen(dirname, "r")) == NULL) { - return NULL; - } - - count = fscanf(file, "%d\n", &n); - if(count == EOF || count != 1) { - fclose(file); - return NULL; - } - - encoding = NULL; - if (!format[0]) { - sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1, - (int)sizeof(file_name) - 1); - } - for(;;) { - count = fscanf(file, format, encoding_name, file_name); - if(count == EOF) - break; - if(count != 2) - break; - - if(!strcasecmp(encoding_name, charset)) { - /* Found it */ - if(file_name[0] != '/') { - if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) { - fclose(file); - return NULL; - } - strcpy(buf, dir); - strcat(buf, file_name); - } else { - strcpy(buf , file_name); - } - - f = FontFileOpen(buf); - if(f == NULL) { - fclose(file); - return NULL; - } - encoding = parseEncodingFile(f, 0); - FontFileClose(f); - break; - } - } - - fclose(file); - - return encoding; -} - -/* Parser ntrypoint -- used by FontEncLoad */ -FontEncPtr -FontEncReallyLoad(const char *charset, const char *fontFileName) -{ - FontEncPtr encoding; - char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN]; - char *d; - - if(fontFileName) { - parseFontFileName(fontFileName, dirname, dir); - encoding = FontEncReallyReallyLoad(charset, dirname, dir); - if(encoding) - return(encoding); - } - - d = FontEncDirectory(); - if(d) { - parseFontFileName(d, NULL, dir); - encoding = FontEncReallyReallyLoad(charset, d, dir); - return encoding; - } - - return NULL; -} - -/* Return a NULL-terminated array of encoding names. Note that this - * function has incestuous knowledge of the allocations done by - * parseEncodingFile. */ - -char ** -FontEncIdentify(const char *fileName) -{ - FontFilePtr f; - FontEncPtr encoding; - char **names, **name, **alias; - int numaliases; - - if((f = FontFileOpen(fileName))==NULL) { - return NULL; - } - encoding = parseEncodingFile(f, 1); - FontFileClose(f); - - if(!encoding) - return NULL; - - numaliases = 0; - if(encoding->aliases) - for(alias = encoding->aliases; *alias; alias++) - numaliases++; - - names = (char**)xalloc((numaliases+2)*sizeof(char*)); - if(names == NULL) { - if(encoding->aliases) - xfree(encoding->aliases); - xfree(encoding); - return NULL; - } - - name = names; - *(name++) = encoding->name; - if(numaliases > 0) - for(alias = encoding->aliases; *alias; alias++, name++) - *name = *alias; - - *name = 0; - xfree(encoding->aliases); - xfree(encoding); - - return names; -} diff --git a/nx-X11/lib/font/fontfile/encparse.c.X.original b/nx-X11/lib/font/fontfile/encparse.c.X.original deleted file mode 100644 index 285f5a17d..000000000 --- a/nx-X11/lib/font/fontfile/encparse.c.X.original +++ /dev/null @@ -1,963 +0,0 @@ -/* -Copyright (c) 1998-2001 by Juliusz Chroboczek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -/* $XFree86: xc/lib/font/fontfile/encparse.c,v 1.20tsi Exp $ */ - -/* Parser for encoding files */ - -/* This code assumes that we are using ASCII. We don't use the ctype - functions, as they depend on the current locale. On the other - hand, we do use strcasecmp, but only on strings that we've checked - to be pure ASCII. Bloody ``Code Set Independence''. */ - -#include <string.h> -#include <stdio.h> - -#if defined(__SCO__) || defined(__UNIXWARE__) -#include <strings.h> -#endif - -#ifndef FONTENC_NO_LIBFONT - -#include <X11/fonts/fntfilio.h> -#include <X11/fonts/fntfilst.h> - -#else - -#include <stdlib.h> -#define xalloc(n) malloc(n) -#define xrealloc(p, n) realloc(p, n) -#define xfree(p) free(p) - -#include "zlib.h" -typedef gzFile FontFilePtr; -#define FontFileGetc(f) gzgetc(f) -#define FontFileOpen(filename) gzopen(filename, "rb") -#define FontFileClose(f) gzclose(f) - -#define MAXFONTFILENAMELEN 1024 -#define MAXFONTNAMELEN 1024 - -#endif - -#include <X11/fonts/fontenc.h> -#include "fontencI.h" - -#define MAXALIASES 20 - -#define EOF_TOKEN -1 -#define ERROR_TOKEN -2 -#define EOL_TOKEN 0 -#define NUMBER_TOKEN 1 -#define KEYWORD_TOKEN 2 - -#define EOF_LINE -1 -#define ERROR_LINE -2 -#define STARTENCODING_LINE 1 -#define STARTMAPPING_LINE 2 -#define ENDMAPPING_LINE 3 -#define CODE_LINE 4 -#define CODE_RANGE_LINE 5 -#define CODE_UNDEFINE_LINE 6 -#define NAME_LINE 7 -#define SIZE_LINE 8 -#define ALIAS_LINE 9 -#define FIRSTINDEX_LINE 10 - -/* Return from lexer */ -#define MAXKEYWORDLEN 100 - -static long number_value; -static char keyword_value[MAXKEYWORDLEN+1]; - -static long value1, value2, value3; - -/* Lexer code */ - -/* Skip to the beginning of new line */ -static void -skipEndOfLine(FontFilePtr f, int c) -{ - if(c == 0) - c = FontFileGetc(f); - - for(;;) - if(c <= 0 || c == '\n') - return; - else - c = FontFileGetc(f); -} - -/* Get a number; we're at the first digit. */ -static unsigned -getnum(FontFilePtr f, int c, int *cp) -{ - unsigned n = 0; - int base = 10; - - /* look for `0' or `0x' prefix */ - if(c == '0') { - c = FontFileGetc(f); - base = 8; - if(c == 'x' || c == 'X') { - base = 16; - c = FontFileGetc(f); - } - } - - /* accumulate digits */ - for(;;) { - if ('0' <= c && c <= '9') { - n *= base; n += c - '0'; - } else if('a' <= c && c <= 'f') { - n *= base; n += c - 'a' + 10; - } else if('A' <=c && c <= 'F') { - n *= base; n += c - 'A' + 10; - } else - break; - c = FontFileGetc(f); - } - - *cp = c; return n; -} - -/* Skip to beginning of new line; return 1 if only whitespace was found. */ -static int -endOfLine(FontFilePtr f, int c) -{ - if(c == 0) - c = FontFileGetc(f); - - for(;;) { - if(c <= 0 || c == '\n') - return 1; - else if(c == '#') { - skipEndOfLine(f,c); - return 1; - } - else if(c == ' ' || c == '\t') { - skipEndOfLine(f,c); - return 0; - } - c = FontFileGetc(f); - } -} - -/* Get a token; we're at first char */ -static int -gettoken(FontFilePtr f, int c, int *cp) -{ - char *p; - - if(c <= 0) - c = FontFileGetc(f); - - if(c <= 0) { - return EOF_TOKEN; - } - - while(c == ' ' || c == '\t') - c = FontFileGetc(f); - - if(c=='\n') { - return EOL_TOKEN; - } else if(c == '#') { - skipEndOfLine(f,c); - return EOL_TOKEN; - } else if(c >= '0' && c <= '9') { - number_value = getnum(f,c,cp); - return NUMBER_TOKEN; - } else if((c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') || - c == '/' || c == '_' || c == '-' || c == '.') { - p = keyword_value; - *p++ = c; - while(p-keyword_value < MAXKEYWORDLEN) { - c = FontFileGetc(f); - if(c <= ' ' || c > '~' || c == '#') - break; - *p++ = c; - } - *cp = c; - *p = '\0'; - return KEYWORD_TOKEN; - } else { - *cp = c; - return ERROR_TOKEN; - } -} - -/* Parse a line. - * Always skips to the beginning of a new line, even if an error occurs */ -static int -getnextline(FontFilePtr f) -{ - int c, token; - c = FontFileGetc(f); - if(c <= 0) - return EOF_LINE; - - again: - token=gettoken(f,c,&c); - - switch(token) { - case EOF_TOKEN: - return EOF_LINE; - case EOL_TOKEN: - /* empty line */ - c = FontFileGetc(f); - goto again; - case NUMBER_TOKEN: - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value3 = number_value; - return CODE_RANGE_LINE; - case EOL_TOKEN: - return CODE_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - case KEYWORD_TOKEN: - if(!endOfLine(f,c)) - return ERROR_LINE; - else - return NAME_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - case KEYWORD_TOKEN: - if(!strcasecmp(keyword_value, "STARTENCODING")) { - token = gettoken(f,c,&c); - if(token == KEYWORD_TOKEN) { - if(endOfLine(f,c)) - return STARTENCODING_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "ALIAS")) { - token = gettoken(f,c,&c); - if(token == KEYWORD_TOKEN) { - if(endOfLine(f,c)) - return ALIAS_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "SIZE")) { - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - return SIZE_LINE; - case EOL_TOKEN: - value2=0; - return SIZE_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "FIRSTINDEX")) { - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - token = gettoken(f,c,&c); - switch(token) { - case NUMBER_TOKEN: - value2 = number_value; - return FIRSTINDEX_LINE; - case EOL_TOKEN: - value2 = 0; - return FIRSTINDEX_LINE; - default: - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "STARTMAPPING")) { - keyword_value[0] = 0; - value1 = 0; value1 = 0; - /* first a keyword */ - token = gettoken(f,c,&c); - if(token != KEYWORD_TOKEN) { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - /* optional first integer */ - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value1 = number_value; - } else if(token == EOL_TOKEN) { - return STARTMAPPING_LINE; - } else { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - /* optional second integer */ - token = gettoken(f,c,&c); - if(token == NUMBER_TOKEN) { - value2 = number_value; - } else if(token == EOL_TOKEN) { - return STARTMAPPING_LINE; - } else { - skipEndOfLine(f, c); - return ERROR_LINE; - } - - if(!endOfLine(f,c)) - return ERROR_LINE; - else { - return STARTMAPPING_LINE; - } - } else if(!strcasecmp(keyword_value, "UNDEFINE")) { - /* first integer */ - token = gettoken(f,c,&c); - if(token != NUMBER_TOKEN) { - skipEndOfLine(f,c); - return ERROR_LINE; - } - value1 = number_value; - /* optional second integer */ - token = gettoken(f,c,&c); - if(token == EOL_TOKEN) { - value2 = value1; - return CODE_UNDEFINE_LINE; - } else if(token == NUMBER_TOKEN) { - value2 = number_value; - if(endOfLine(f,c)) { - return CODE_UNDEFINE_LINE; - } else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - } else if(!strcasecmp(keyword_value, "ENDENCODING")) { - if(endOfLine(f,c)) - return EOF_LINE; - else - return ERROR_LINE; - } else if(!strcasecmp(keyword_value, "ENDMAPPING")) { - if(endOfLine(f,c)) - return ENDMAPPING_LINE; - else - return ERROR_LINE; - } else { - skipEndOfLine(f,c); - return ERROR_LINE; - } - default: - return ERROR_LINE; - } -} - -static void -install_mapping(FontEncPtr encoding, FontMapPtr mapping) -{ - FontMapPtr m; - - if(encoding->mappings == NULL) - encoding->mappings = mapping; - else { - m = encoding->mappings; - while(m->next != NULL) - m = m->next; - m->next = mapping; - } - mapping->next = NULL; - mapping->encoding = encoding; -} - -static int -setCode(unsigned from, unsigned to, unsigned row_size, - unsigned *first, unsigned *last, - unsigned *encsize, unsigned short **enc) -{ - unsigned index, i; - unsigned short *newenc; - - if(from>0xFFFF) - return 0; /* success */ - - if(row_size==0) - index=from; - else { - if((value1 & 0xFF) >= row_size) - return 0; /* ignore out of range mappings */ - index = (from>>8) * row_size + (from&0xFF); - } - - /* Optimize away useless identity mappings. This is only expected - to be useful with linear encodings. */ - if(index == to && (index < *first || index > *last)) - return 0; - if(*encsize == 0) { - *encsize = (index < 256) ? 256 : 0x10000; - *enc = (unsigned short*)xalloc((*encsize) * sizeof(unsigned short)); - if(*enc == NULL) { - *encsize = 0; - return 1; - } - } else if(*encsize <= index) { - *encsize = 0x10000; - if((newenc = (unsigned short*)xrealloc(enc, *encsize))==NULL) - return 1; - *enc = newenc; - } - if(*first > *last) { - *first = *last = index; - } - if(index < *first) { - for(i = index; i < *first; i++) - (*enc)[i] = i; - *first = index; - } - if(index > *last) { - for(i = *last + 1; i <= index; i++) - (*enc)[i] = i; - *last = index; - } - (*enc)[index] = to; - return 0; -} - -/* Parser. If headerOnly is true, we're only interested in the - data contained in the encoding file's header. */ - -/* As font encodings are currently never freed, the allocations done - by this function are mostly its private business. Note, however, - that FontEncIdentify needs to free the header fields -- so if you - change this function, you may need to change FontEncIdentify. */ - -/* I want a garbage collector. */ - -static FontEncPtr -parseEncodingFile(FontFilePtr f, int headerOnly) -{ - int line; - - unsigned short *enc=NULL; - char **nam = NULL, **newnam; - unsigned i, first = 0xFFFF, last=0, encsize=0, namsize=0; - FontEncPtr encoding = NULL; - FontMapPtr mapping = NULL; - FontEncSimpleMapPtr sm; - FontEncSimpleNamePtr sn; - char *aliases[MAXALIASES]; - int numaliases=0; - -#if 0 - /* GCC complains about unused labels. Please fix GCC rather than - obfuscating my code. */ - no_encoding: -#endif - line = getnextline(f); - switch(line) { - case EOF_LINE: - goto error; - case STARTENCODING_LINE: - encoding = (FontEncPtr)xalloc(sizeof(FontEncRec)); - if(encoding == NULL) - goto error; - encoding->name = (char*)xalloc(strlen(keyword_value)+1); - if(encoding->name == NULL) - goto error; - strcpy(encoding->name, keyword_value); - encoding->size = 256; - encoding->row_size = 0; - encoding->mappings = NULL; - encoding->next = NULL; - encoding->first = encoding->first_col=0; - goto no_mapping; - default: - goto error; - } - - no_mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto done; - case ALIAS_LINE: - if(numaliases < MAXALIASES) { - aliases[numaliases] = (char*)xalloc(strlen(keyword_value)+1); - if(aliases[numaliases] == NULL) - goto error; - strcpy(aliases[numaliases], keyword_value); - numaliases++; - } - goto no_mapping; - case SIZE_LINE: - encoding->size = value1; - encoding->row_size = value2; - goto no_mapping; - case FIRSTINDEX_LINE: - encoding->first = value1; - encoding->first_col = value2; - goto no_mapping; - case STARTMAPPING_LINE: - if(headerOnly) - goto done; - if(!strcasecmp(keyword_value, "unicode")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_UNICODE; - mapping->pid = 0; - mapping->eid = 0; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto mapping; - } else if(!strcasecmp(keyword_value, "cmap")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_TRUETYPE; - mapping->pid = value1; - mapping->eid = value2; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto mapping; - } else if(!strcasecmp(keyword_value, "postscript")) { - mapping = (FontMapPtr)xalloc(sizeof(FontMapRec)); - if(mapping == NULL) - goto error; - mapping->type = FONT_ENCODING_POSTSCRIPT; - mapping->pid = 0; - mapping->eid = 0; - mapping->recode = 0; - mapping->name = 0; - mapping->client_data = 0; - mapping->next = 0; - goto string_mapping; - } else { /* unknown mapping type -- ignore */ - goto skipmapping; - } - /* NOTREACHED */ - goto error; - default: goto no_mapping; /* ignore unknown lines */ - } - - skipmapping: - line = getnextline(f); - switch(line) { - case ENDMAPPING_LINE: - goto no_mapping; - case EOF_LINE: - goto error; - default: - goto skipmapping; - } - - mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto error; - case ENDMAPPING_LINE: - mapping->recode = FontEncSimpleRecode; - mapping->name = FontEncUndefinedName; - mapping->client_data = sm = - (FontEncSimpleMapPtr)xalloc(sizeof(FontEncSimpleMapRec)); - if(sm == NULL) - goto error; - sm->row_size = encoding->row_size; - if(first <= last) { - sm->first = first; - sm->len=last-first+1; - sm->map = - (unsigned short*)xalloc(sm->len * sizeof(unsigned short)); - if(sm->map == NULL) { - xfree(sm); - mapping->client_data = sm = NULL; - goto error; - } - } else { - sm->first = 0; - sm->len = 0; - sm->map = 0; - } - for(i=0; i < sm->len; i++) - sm -> map[i] = enc[first+i]; - install_mapping(encoding, mapping); - mapping = 0; - first = 0xFFFF; last=0; - goto no_mapping; - - case CODE_LINE: - if(setCode(value1, value2, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - goto mapping; - - case CODE_RANGE_LINE: - if(value1 > 0x10000) - value1 = 0x10000; - if(value2 > 0x10000) - value2 = 0x10000; - if(value2 < value1) - goto mapping; - /* Do the last value first to avoid having to realloc() */ - if(setCode(value2, value3+(value2-value1), encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - for(i=value1; i<value2; i++) { - if(setCode(i, value3+(i-value1), encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - } - goto mapping; - - case CODE_UNDEFINE_LINE: - if(value1 > 0x10000) - value1 = 0x10000; - if(value2 > 0x10000) - value2 = 0x10000; - if(value2 < value1) - goto mapping; - /* Do the last value first to avoid having to realloc() */ - if(setCode(value2, 0, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - for(i = value1; i < value2; i++) { - if(setCode(i, 0, encoding->row_size, - &first, &last, &encsize, &enc)) - goto error; - } - goto mapping; - - default: goto mapping; /* ignore unknown lines */ - } - - string_mapping: - line = getnextline(f); - switch(line) { - case EOF_LINE: goto error; - case ENDMAPPING_LINE: - mapping->recode = FontEncUndefinedRecode; - mapping->name = FontEncSimpleName; - mapping->client_data = sn = - (FontEncSimpleNamePtr)xalloc(sizeof(FontEncSimpleNameRec)); - if(sn == NULL) - goto error; - if(first > last) { - xfree(sn); - mapping->client_data = sn = NULL; - goto error; - } - sn->first = first; - sn->len = last - first + 1; - sn->map = (char**)xalloc(sn->len*sizeof(char*)); - if(sn->map == NULL) { - xfree(sn); - mapping->client_data = sn = NULL; - goto error; - } - for(i = 0; i < sn->len; i++) - sn->map[i] = nam[first+i]; - install_mapping(encoding,mapping); - mapping = 0; - first = 0xFFFF; last=0; - goto no_mapping; - case NAME_LINE: - if(value1 >= 0x10000) goto string_mapping; - if(namsize == 0) { - namsize = (value1) < 256 ? 256 : 0x10000; - nam = (char**)xalloc(namsize * sizeof(char*)); - if(nam == NULL) { - namsize=0; - goto error; - } - } else if(namsize <= value1) { - namsize = 0x10000; - if((newnam = (char**)xrealloc(nam, namsize)) == NULL) - goto error; - nam = newnam; - } - if(first > last) { - first = last = value1; - } - if(value1 < first) { - for(i = value1; i < first; i++) - nam[i] = NULL; - first = value1; - } - if(value1 > last) { - for(i=last+1; i <= value1; i++) - nam[i]=NULL; - last = value1; - } - nam[value1] = (char*)xalloc(strlen(keyword_value)+1); - if(nam[value1] == NULL) { - goto error; - } - strcpy(nam[value1], keyword_value); - goto string_mapping; - - default: goto string_mapping; /* ignore unknown lines */ - } - - done: - if(encsize) xfree(enc); encsize=0; enc = NULL; - if(namsize) xfree(nam); namsize=0; nam = NULL; /* don't free entries! */ - - encoding->aliases=NULL; - if(numaliases) { - encoding->aliases = (char**)xalloc((numaliases+1)*sizeof(char*)); - if(encoding->aliases == NULL) - goto error; - for(i=0; i<numaliases; i++) - encoding->aliases[i] = aliases[i]; - encoding->aliases[numaliases]=NULL; - } - - return encoding; - -error: - if(encsize) xfree(enc); encsize=0; - if(namsize) { - for(i = first; i <= last; i++) - if(nam[i]) - xfree(nam[i]); - xfree(nam); - namsize = 0; - } - if(mapping) { - if(mapping->client_data) xfree(mapping->client_data); - xfree(mapping); - } - if(encoding) { - if(encoding->name) xfree(encoding->name); - for(mapping = encoding->mappings; mapping; mapping = mapping->next) { - if(mapping->client_data) xfree(mapping->client_data); - xfree(mapping); - } - xfree(encoding); - } - for(i = 0; i < numaliases; i++) - xfree(aliases[i]); - /* We don't need to free sn and sm as they handled locally in the body.*/ - return 0; -} - -char* -FontEncDirectory() -{ - static char* dir = NULL; - - if(dir == NULL) { - char *c = getenv("FONT_ENCODINGS_DIRECTORY"); - if(c) { - dir = malloc(strlen(c) + 1); - if(!dir) - return NULL; - strcpy(dir, c); - } else { - dir = FONT_ENCODINGS_DIRECTORY; - } - } - return dir; -} - -static void -parseFontFileName(const char *fontFileName, char *buf, char *dir) -{ - const char *p; - char *q, *lastslash; - - for(p = fontFileName, q = dir, lastslash = NULL; *p; p++, q++) { - *q = *p; - if(*p == '/') - lastslash = q+1; - } - - if(!lastslash) - lastslash = dir; - - *lastslash = '\0'; - - if(buf && strlen(dir) + 14 < MAXFONTFILENAMELEN) { - strcpy(buf, dir); - strcat(buf, "encodings.dir"); - } -} - -static FontEncPtr -FontEncReallyReallyLoad(const char *charset, - const char *dirname, const char *dir) -{ - FontFilePtr f; - FILE *file; - FontEncPtr encoding; - char file_name[MAXFONTFILENAMELEN], encoding_name[MAXFONTNAMELEN], - buf[MAXFONTFILENAMELEN]; - int count, n; - static char format[24] = ""; - - /* As we don't really expect to open encodings that often, we don't - take the trouble of caching encodings directories. */ - - if((file = fopen(dirname, "r")) == NULL) { - return NULL; - } - - count = fscanf(file, "%d\n", &n); - if(count == EOF || count != 1) { - fclose(file); - return NULL; - } - - encoding = NULL; - if (!format[0]) { - sprintf(format, "%%%ds %%%d[^\n]\n", (int)sizeof(encoding_name) - 1, - (int)sizeof(file_name) - 1); - } - for(;;) { - count = fscanf(file, format, encoding_name, file_name); - if(count == EOF) - break; - if(count != 2) - break; - - if(!strcasecmp(encoding_name, charset)) { - /* Found it */ - if(file_name[0] != '/') { - if(strlen(dir) + strlen(file_name) >= MAXFONTFILENAMELEN) - return NULL; - strcpy(buf, dir); - strcat(buf, file_name); - } else { - strcpy(buf , file_name); - } - - f = FontFileOpen(buf); - if(f == NULL) { - return NULL; - } - encoding = parseEncodingFile(f, 0); - FontFileClose(f); - break; - } - } - - fclose(file); - - return encoding; -} - -/* Parser ntrypoint -- used by FontEncLoad */ -FontEncPtr -FontEncReallyLoad(const char *charset, const char *fontFileName) -{ - FontEncPtr encoding; - char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN]; - char *d; - - if(fontFileName) { - parseFontFileName(fontFileName, dirname, dir); - encoding = FontEncReallyReallyLoad(charset, dirname, dir); - if(encoding) - return(encoding); - } - - d = FontEncDirectory(); - if(d) { - parseFontFileName(d, NULL, dir); - encoding = FontEncReallyReallyLoad(charset, d, dir); - return encoding; - } - - return NULL; -} - -/* Return a NULL-terminated array of encoding names. Note that this - * function has incestuous knowledge of the allocations done by - * parseEncodingFile. */ - -char ** -FontEncIdentify(const char *fileName) -{ - FontFilePtr f; - FontEncPtr encoding; - char **names, **name, **alias; - int numaliases; - - if((f = FontFileOpen(fileName))==NULL) { - return NULL; - } - encoding = parseEncodingFile(f, 1); - FontFileClose(f); - - if(!encoding) - return NULL; - - numaliases = 0; - if(encoding->aliases) - for(alias = encoding->aliases; *alias; alias++) - numaliases++; - - names = (char**)xalloc((numaliases+2)*sizeof(char*)); - if(names == NULL) { - if(encoding->aliases) - xfree(encoding->aliases); - xfree(encoding); - return NULL; - } - - name = names; - *(name++) = encoding->name; - if(numaliases > 0) - for(alias = encoding->aliases; *alias; alias++, name++) - *name = *alias; - - *name = 0; - xfree(encoding->aliases); - xfree(encoding); - - return names; -} diff --git a/nx-X11/lib/xtrans/Xtranssock.c.NX.original b/nx-X11/lib/xtrans/Xtranssock.c.NX.original deleted file mode 100644 index 50b677057..000000000 --- a/nx-X11/lib/xtrans/Xtranssock.c.NX.original +++ /dev/null @@ -1,3417 +0,0 @@ -/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.11 2005/11/08 06:33:26 jkj Exp $ */ -/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */ -/* - -Copyright 1993, 1994, 1998 The Open Group -Copyright 2002 Sun Microsystems, Inc. All rights reserved. - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the copyright holders shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from the copyright holders. - -*/ -/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.68 2004/01/07 04:28:02 dawes Exp $ */ - -/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name NCR not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. NCR makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/**************************************************************************/ -/* */ -/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/. */ -/* */ -/* NX-X11, NX protocol compression and NX extensions to this software */ -/* are copyright of NoMachine. Redistribution and use of the present */ -/* software is allowed according to terms specified in the file LICENSE */ -/* which comes in the source distribution. */ -/* */ -/* Check http://www.nomachine.com/licensing.html for applicability. */ -/* */ -/* NX and NoMachine are trademarks of Medialogic S.p.A. */ -/* */ -/* All rights reserved. */ -/* */ -/**************************************************************************/ - -#ifdef NX_TRANS_SOCKET - -#ifdef NX_TRANS_DEBUG -#define XTRANSDEBUG 5 -#endif - -#ifndef PF_LOCAL -#define PF_LOCAL PF_UNIX -#endif - -#endif - -#include <ctype.h> -#ifdef XTHREADS -#include <X11/Xthreads.h> -#endif - -#ifndef WIN32 - -#if defined(TCPCONN) || defined(UNIXCONN) -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#endif - -#if defined(TCPCONN) || defined(UNIXCONN) -#define X_INCLUDE_NETDB_H -#define XOS_USE_NO_LOCKING -#include <X11/Xos_r.h> -#endif - -#ifdef UNIXCONN -#ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif -#endif -#include <sys/stat.h> -#endif - -#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV)) -#define NO_TCP_H -#endif - -#ifndef NO_TCP_H -#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5) -#include <sys/param.h> -#endif /* osf */ -#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) -#include <sys/param.h> -#include <machine/endian.h> -#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */ -#include <netinet/tcp.h> -#endif /* !NO_TCP_H */ - -#include <sys/ioctl.h> -#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_) -#include <sys/filio.h> -#endif - -#if (defined(i386) && defined(SYSV)) && !defined(SCO325) && !defined(sun) -#include <net/errno.h> -#endif - -#if (defined(i386) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_) -#include <sys/stropts.h> -#endif - -#else /* !WIN32 */ - -#include <X11/Xwinsock.h> -#include <X11/Xwindows.h> -#include <X11/Xw32defs.h> -#undef close -#define close closesocket -#define ECONNREFUSED WSAECONNREFUSED -#define EADDRINUSE WSAEADDRINUSE -#define EPROTOTYPE WSAEPROTOTYPE -#undef EWOULDBLOCK -#define EWOULDBLOCK WSAEWOULDBLOCK -#define EINPROGRESS WSAEINPROGRESS -#undef EINTR -#define EINTR WSAEINTR -#define X_INCLUDE_NETDB_H -#define XOS_USE_MTSAFE_NETDBAPI -#include <X11/Xos_r.h> -#endif /* WIN32 */ - -#if defined(SO_DONTLINGER) && defined(SO_LINGER) -#undef SO_DONTLINGER -#endif - -#if defined(__UNIXOS2__) -#if defined(NOT_EMX09A) -static int IBMsockInit = 0; -#define SocketInitOnce()\ - if (!IBMsockInit) {\ - sock_init();\ - IBMsockInit = 1;\ - } -#undef EINTR -#define EINTR SOCEINTR -#undef EINVAL -#define EINVAL SOCEINVAL -#undef errno -#define errno sock_errno() -#undef close -#define close soclose -#undef ioctl -#define ioctl sockioctl -#else -#define SocketInitOnce() /**/ -#endif -/* this is still not there */ -#define SOCKET int -#else -/* others don't need this */ -#define SocketInitOnce() /**/ -#endif - -#define MIN_BACKLOG 128 -#ifdef SOMAXCONN -#if SOMAXCONN > MIN_BACKLOG -#define BACKLOG SOMAXCONN -#endif -#endif -#ifndef BACKLOG -#define BACKLOG MIN_BACKLOG -#endif -/* - * This is the Socket implementation of the X Transport service layer - * - * This file contains the implementation for both the UNIX and INET domains, - * and can be built for either one, or both. - * - */ - -typedef struct _Sockettrans2dev { - char *transname; - int family; - int devcotsname; - int devcltsname; - int protocol; -} Sockettrans2dev; - -static Sockettrans2dev Sockettrans2devtab[] = { -#ifdef TCPCONN - {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, -#if !defined(IPv6) || !defined(AF_INET6) - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, -#else /* IPv6 */ - {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */ - {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, -#endif -#endif /* TCPCONN */ -#ifdef UNIXCONN - {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, -#if !defined(LOCALCONN) - {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, -#endif /* !LOCALCONN */ -#endif /* UNIXCONN */ -}; - -#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev)) - -#ifdef TCPCONN -static int TRANS(SocketINETClose) (XtransConnInfo ciptr); -#endif - -#ifdef UNIXCONN - -#ifdef hpux - -#if defined(X11_t) -#define UNIX_PATH "/usr/spool/sockets/X11/" -#define UNIX_DIR "/usr/spool/sockets/X11" -#define OLD_UNIX_PATH "/tmp/.X11-unix/X" -#endif /* X11_t */ -#if defined(XIM_t) -#define UNIX_PATH "/usr/spool/sockets/XIM/" -#define UNIX_DIR "/usr/spool/sockets/XIM" -#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM" -#endif /* XIM_t */ -#if defined(FS_t) || defined(FONT_t) -#define UNIX_PATH "/usr/spool/sockets/fontserv/" -#define UNIX_DIR "/usr/spool/sockets/fontserv" -#endif /* FS_t || FONT_t */ -#if defined(ICE_t) -#define UNIX_PATH "/usr/spool/sockets/ICE/" -#define UNIX_DIR "/usr/spool/sockets/ICE" -#endif /* ICE_t */ -#if defined(TEST_t) -#define UNIX_PATH "/usr/spool/sockets/xtrans_test/" -#define UNIX_DIR "/usr/spool/sockets/xtrans_test" -#endif -#if defined(LBXPROXY_t) -#define UNIX_PATH "/usr/spool/sockets/X11/" -#define UNIX_DIR "/usr/spool/sockets/X11" -#endif - -#else /* !hpux */ - -#if defined(X11_t) -#define UNIX_PATH "/tmp/.X11-unix/X" -#define UNIX_DIR "/tmp/.X11-unix" -#endif /* X11_t */ -#if defined(XIM_t) -#define UNIX_PATH "/tmp/.XIM-unix/XIM" -#define UNIX_DIR "/tmp/.XIM-unix" -#endif /* XIM_t */ -#if defined(FS_t) || defined(FONT_t) -#define UNIX_PATH "/tmp/.font-unix/fs" -#define UNIX_DIR "/tmp/.font-unix" -#endif /* FS_t || FONT_t */ -#if defined(ICE_t) -#define UNIX_PATH "/tmp/.ICE-unix/" -#define UNIX_DIR "/tmp/.ICE-unix" -#endif /* ICE_t */ -#if defined(TEST_t) -#define UNIX_PATH "/tmp/.Test-unix/test" -#define UNIX_DIR "/tmp/.Test-unix" -#endif -#if defined(LBXPROXY_t) -#define UNIX_PATH "/tmp/.X11-unix/X" -#define UNIX_DIR "/tmp/.X11-unix" -#endif - -#endif /* hpux */ - -#endif /* UNIXCONN */ - -#define PORTBUFSIZE 32 - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 255 -#endif - -/* - * This provides compatibility for apps linked against system libraries - * that don't have IPv6 support. - */ -#if defined(IPv6) && defined(AF_INET6) -static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT; -#pragma weak in6addr_any = local_in6addr_any -#ifndef __USLC__ -#pragma weak getaddrinfo -#endif -static int haveIPv6 = 1; -#endif - -#ifndef X11_t - -/* - * No NX changes if this is not - * compiled as a X11 transport. - */ - -#undef NX_TRANS_SOCKET - -#endif - -#ifdef NX_TRANS_SOCKET - -#ifdef TRANS_CLIENT - -#include "NX.h" - -typedef struct -{ - XtransConnInfo info; - int local; - int remote; - int congestion; - -} _NXProxyConnInfo; - -#define NX_PROXY_CONN_LIMIT 256 - -static _NXProxyConnInfo *_NXProxyConnInfoTab[NX_PROXY_CONN_LIMIT]; - -#endif /* #ifdef TRANS_CLIENT */ - -/* - * Override the UNIX_DIR and UNIX_PATH settings and - * make them configurable, based on the NX_TEMP or - * the TEMP environment. - * - * We must be careful as the same defines are used - * for different directories, based on the subsystem - * that is compiling this, while we want to override - * only the '/tmp/.X11-unix' and '/tmp/.X11-unix/X' - * settings. - */ - -static char _NXUnixDir[1024]; -static char _NXUnixPath[1024]; - -static char *_NXGetUnixDir(char *dir) -{ - const char *tempDir; - - PRMSG (3, "_NXGetUnixDir(%s)\n", dir, 0, 0); - - if (strcmp(dir, UNIX_DIR) != 0) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: Returning other Unix directory [%s].\n", dir); -#endif - return dir; - } - - /* - * Check the environment only once. - */ - - if (*_NXUnixDir != '\0') - { - return _NXUnixDir; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: Trying with the NX_TEMP environment.\n"); -#endif - - tempDir = getenv("NX_TEMP"); - - if (tempDir == NULL || *tempDir == '\0') - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: Trying with the TEMP environment.\n"); -#endif - - tempDir = getenv("TEMP"); - } - - if (tempDir != NULL && *tempDir != '\0') - { - if (strlen(tempDir) + strlen("/.X11-unix") + 1 > 1024) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: WARNING! Maximum length of X11 Unix directory exceeded.\n"); -#endif - goto _NXGetUnixDirError; - } - - strcpy(_NXUnixDir, tempDir); - strcat(_NXUnixDir, "/.X11-unix"); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: Using X11 Unix directory [%s].\n", _NXUnixDir); -#endif - - return _NXUnixDir; - } - -_NXGetUnixDirError: - - strcpy(_NXUnixDir, dir); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixDir: Returning default X11 Unix directory [%s].\n", _NXUnixDir); -#endif - - return _NXUnixDir; -} - -static char *_NXGetUnixPath(char *path) -{ - const char *unixDir; - - PRMSG (3, "_NXGetUnixPath(%s)\n", path, 0, 0); - - if (strcmp(path, UNIX_PATH) != 0) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixPath: Returning other X11 Unix path [%s].\n", path); -#endif - return path; - } - - /* - * Check the environment only once. - */ - - if (*_NXUnixPath != '\0') - { - return _NXUnixPath; - } - - unixDir = _NXGetUnixDir(UNIX_DIR); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixPath: Got X11 Unix directory [%s].\n", unixDir); -#endif - - if (strlen(unixDir) + strlen("/X") + 1 > 1024) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixPath: WARNING! Maximum length of X11 Unix path exceeded.\n"); -#endif - - goto _NXGetUnixPathError; - } - - strcpy(_NXUnixPath, unixDir); - strcat(_NXUnixPath, "/X"); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixPath: Returning X11 Unix path [%s].\n", _NXUnixPath); -#endif - - return _NXUnixPath; - -_NXGetUnixPathError: - - strcpy(_NXUnixPath, path); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetUnixPath: Returning default X11 Unix path [%s].\n", _NXUnixPath); -#endif - - return _NXUnixPath; -} - -#ifdef hpux - -static char *_NXGetOldUnixPath(char *path) -{ - PRMSG (3, "_NXGetOldUnixPath(%s)\n", path, 0, 0); - - if (strcmp(path, OLD_UNIX_PATH) == 0) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetOldUnixPath: Returning X11 Unix path [%s].\n", - _NXGetUnixPath(path)); -#endif - - return _NXGetUnixPath(path); - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "_NXGetOldUnixPath: Returning other old X11 Unix path [%s].\n", path); -#endif - - return path; -} - -#endif /* #ifdef hpux */ - -/* - * Forcibly close any connection attempt on the - * listening socket. Need this to avoid loopback - * connections to the agent server. - */ - -#ifdef TRANS_SERVER - -void TRANS(SocketRejectConnection) (XtransConnInfo ciptr) -{ - size_t sa_l = sizeof(struct sockaddr); - struct sockaddr sa; - fd_set fs; - struct timeval t; - int f; - - PRMSG (3, "SocketRejectConnection(%x)\n", ciptr, 0, 0); - - FD_ZERO(&fs); - FD_SET(ciptr -> fd, &fs); - - t.tv_sec = 0; - t.tv_usec = 0; - - /* - * Check if there is an awaiting connection. - */ - - if (select(ciptr -> fd + 1, &fs, NULL, NULL, &t) == 1) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketRejectConnection: Accepting connection attempt on fd [%d].\n", - ciptr -> fd); -#endif - /* - * If there is one, close it. - */ - - if ((f = accept(ciptr -> fd, &sa, &sa_l)) >= 0) - { -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketRejectConnection: Closing connection attempt on fd [%d].\n", - ciptr -> fd); -#endif - close(f); - } - } -} - -#endif /* #ifdef TRANS_SERVER */ - -#ifdef TRANS_CLIENT - -void *TRANS(SocketProxyConnInfo) (XtransConnInfo ciptr) -{ - if (_NXProxyConnInfoTab[ciptr->fd] != NULL) - { - return ciptr->priv; - } - - return NULL; -} - -static XtransConnInfo TRANS(SocketCreateConnInfo) () -{ - XtransConnInfo ciptr; - - int fds[2]; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCreateConnInfo: Going to create the NX connection info.\n"); -#endif - - if ((ciptr = (XtransConnInfo) xcalloc (1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketCreateConnInfo: malloc failed\n", 0, 0, 0); - return NULL; - } - - /* - * Create a pair of sockets. We'll communicate with - * the NX proxy by reading and writing to our end. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCreateConnInfo: Going to create the NX socketpair.\n"); -#endif - - if (socketpair(PF_LOCAL, SOCK_STREAM, 0, fds) < 0) - { - PRMSG (1, "SocketCreateConnInfo: socketpair() failed.\n", 0, 0, 0); - xfree ((char *) ciptr); - return NULL; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCreateConnInfo: X socket end is [%d] NX proxy end is [%d].\n", - fds[0], fds[1]); -#endif - - /* - * Save in _NXProxyConnInfoTab the local and remote end of - * the socketpair. The remote end will be used by the proxy. - * When the memory-to-memory transport is activated, the - * agent and the proxy don't read or write to the real des- - * criptors but the communication takes place by reading - * and writing to the proxy's buffers. - */ - - ciptr->fd = fds[0]; - - if (ciptr->fd >= NX_PROXY_CONN_LIMIT) - { - PRMSG (1, "SocketCreateConnInfo: No space for a new _NXProxyConnInfo for [%d].\n", - ciptr->fd, 0, 0); - xfree ((char *) ciptr); - return NULL; - } - else if (_NXProxyConnInfoTab[ciptr->fd] != NULL) - { - PRMSG (1, "SocketCreateConnInfo: _NXProxyConnInfo for [%d] is not NULL. Exiting.\n", - ciptr->fd, 0, 0); - exit(1); - } - - _NXProxyConnInfoTab[ciptr->fd] = (_NXProxyConnInfo *) xcalloc(1, sizeof(_NXProxyConnInfo)); - - if (_NXProxyConnInfoTab[ciptr->fd] == NULL) - { - PRMSG (1, "SocketCreateConnInfo: Alloc of _NXProxyConnInfo failed.\n", 0, 0, 0); - xfree ((char *) ciptr); - return NULL; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCreateConnInfo: Allocated new _NXProxyConnInfo for [%d].\n", - ciptr->fd); -#endif - - _NXProxyConnInfoTab[ciptr->fd]->info = ciptr; - _NXProxyConnInfoTab[ciptr->fd]->local = fds[0]; - _NXProxyConnInfoTab[ciptr->fd]->remote = fds[1]; - _NXProxyConnInfoTab[ciptr->fd]->congestion = 0; - - ciptr->priv = (char *) _NXProxyConnInfoTab[ciptr->fd]; - - return ciptr; -} - -static int TRANS(SocketConnectConnInfo) (XtransConnInfo ciptr, char *host, char *port) -{ - int fds[2]; - char display[1024]; - - _NXProxyConnInfo *proxy_conn; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketConnectConnInfo: Going to connect NX fd [%d] to host [%s] port [%s].\n", - ciptr->fd, host, port); -#endif - - /* - * We should have already created the socket pair. - */ - - proxy_conn = (_NXProxyConnInfo *) ciptr->priv; - - if (proxy_conn == NULL) - { - PRMSG (1, "SocketConnectConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0); - - exit(1); - } - else if (_NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv) - { - PRMSG (1, "SocketConnectConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n", - 0, 0, 0); - - exit(1); - } - - if (strlen(host) + strlen(port) + 1 >= 1023) - { - PRMSG (1, "SocketConnectConnInfo: Length of NX display string '%s:%s' would exceed %d characters.\n", - host, port, 1023); - - return TRANS_CONNECT_FAILED; - } - - sprintf(display, "%s:%s", host, port); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketConnectConnInfo: Setting close-on-exec flag on local NX descriptor [%d].\n", - proxy_conn -> local); -#endif - -#ifdef F_SETFD -#ifdef FD_CLOEXEC - if (fcntl(proxy_conn -> local, F_SETFD, FD_CLOEXEC) != 0) -#else - if (fcntl(proxy_conn -> local, F_SETFD, 1) != 0) -#endif -#endif - { - PRMSG (1, "SocketConnectConnInfo: Cannot set close-on-exec on local NX descriptor [%d].\n", - proxy_conn -> local, 0, 0); - - return TRANS_CONNECT_FAILED; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketConnectConnInfo: Creating the NX transport with display [%s].\n", - display); -#endif - - if (NXTransCreate(NX_FD_ANY, NX_MODE_CLIENT, display) < 0) - { - PRMSG (1, "SocketConnectConnInfo: Cannot create the NX transport.\n", - 0, 0, 0); - - return TRANS_CONNECT_FAILED; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketConnectConnInfo: Starting the NX agent with descriptor [%d].\n", - proxy_conn -> remote); -#endif - - fds[0] = proxy_conn -> local; - fds[1] = proxy_conn -> remote; - - NXTransAgent(fds); - - return 0; -} - -static void TRANS(SocketCloseConnInfo) (XtransConnInfo ciptr) -{ - _NXProxyConnInfo *proxy_conn; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCloseConnInfo: Going to close the NX fd [%d].\n", ciptr->fd); -#endif - - proxy_conn = (_NXProxyConnInfo *) ciptr->priv; - - if (proxy_conn == NULL) - { - PRMSG (1, "SocketCloseConnInfo: Pointer to _NXProxyConnInfo is NULL. Exiting.\n", 0, 0, 0); - - exit(1); - } - else if (ciptr->fd >= NX_PROXY_CONN_LIMIT || - _NXProxyConnInfoTab[ciptr->fd] != (_NXProxyConnInfo *) ciptr->priv) - { - PRMSG (1, "SocketCloseConnInfo: Can't find _NXProxyConnInfo in table. Exiting.\n", - 0, 0, 0); - exit(1); - } - else if (_NXProxyConnInfoTab[ciptr->fd] -> info != ciptr || - _NXProxyConnInfoTab[ciptr->fd] -> local != ciptr->fd) - { - PRMSG (1, "SocketCloseConnInfo: Invalid _NXProxyConnInfo structure for [%d]. Exiting.\n", - ciptr->fd, 0, 0); - exit(1); - } - else if (proxy_conn->local < 0 || proxy_conn->remote < 0) - { - PRMSG (1, "SocketCloseConnInfo: Invalid socket pair in NX connection for [%d]. Exiting.\n", - ciptr->fd, 0, 0); - exit(1); - } - - NXTransClose(ciptr->fd); - - /* - * Get rid of the _NXProxyConnInfo structure. - */ - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCloseConnInfo: Freeing _NXProxyConnInfo structure for [%d].\n", - ciptr->fd); -#endif - - xfree((char *) _NXProxyConnInfoTab[ciptr->fd]); - - _NXProxyConnInfoTab[ciptr->fd] = NULL; - - ciptr->priv = NULL; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCloseConnInfo: Should now close the local descriptor [%d].\n", - ciptr->fd); -#endif -} - -#endif /* #ifdef TRANS_CLIENT */ - -#if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE) - -/* - * Check the congestion state of the NX transport - * and return 1 if there has been a change. This - * can be extended by adding a few counters track- - * ing the bandwidth usage of the X11 connection. - */ - -int TRANS(SocketCongestionChange) (XtransConnInfo ciptr, int *state) -{ - int congestion; - - _NXProxyConnInfo *proxy_conn; - - PRMSG (3, "SocketCongestionChange(%x)\n", ciptr, 0, 0); - - proxy_conn = (_NXProxyConnInfo *) ciptr->priv; - - if (proxy_conn == NULL) - { -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "SocketCongestionChange: Descriptor [%d] doesn't appear to be a NX connection.\n", - ciptr->fd); -#endif - return 0; - } - -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "SocketCongestionChange: Checking congestion on fd [%d] with old state [%d].\n", - ciptr->fd, proxy_conn->congestion); -#endif - - congestion = NXTransCongestion(ciptr->fd); - - if (congestion != proxy_conn->congestion) - { - proxy_conn->congestion = congestion; - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCongestionChange: Change detected on fd [%d] with new state [%d].\n", - ciptr->fd, proxy_conn->congestion); -#endif - return 1; - } - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketCongestionChange: No change on fd [%d] with current state [%d].\n", - ciptr->fd, congestion); -#endif - return 0; -} - -#endif /* #if defined(TRANS_CLIENT) && defined(NX_TRANS_CHANGE) */ - -#endif /* #ifdef NX_TRANS_SOCKET */ - -/* - * These are some utility function used by the real interface function below. - */ - -static int -TRANS(SocketSelectFamily) (int first, char *family) - -{ - int i; - - PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0); - - for (i = first + 1; i < NUMSOCKETFAMILIES;i++) - { - if (!strcmp (family, Sockettrans2devtab[i].transname)) - return i; - } - - return (first == -1 ? -2 : -1); -} - - -/* - * This function gets the local address of the socket and stores it in the - * XtransConnInfo structure for the connection. - */ - -static int -TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage socknamev6; -#endif - struct sockaddr_in socknamev4; - void *socknamePtr; -#if defined(SVR4) || defined(__SCO__) - size_t namelen; -#else - int namelen; -#endif - - PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0); - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - namelen = sizeof(socknamev6); - socknamePtr = &socknamev6; - } - else -#endif - { - namelen = sizeof(socknamev4); - socknamePtr = &socknamev4; - } - - if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr, - (void *)&namelen) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n", - EGET(),0, 0); - return -1; - } - - /* - * Everything looks good: fill in the XtransConnInfo structure. - */ - - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketINETGetAddr: Can't allocate space for the addr\n", - 0, 0, 0); - return -1; - } - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family; - } - else -#endif - { - ciptr->family = socknamev4.sin_family; - } - ciptr->addrlen = namelen; - memcpy (ciptr->addr, socknamePtr, ciptr->addrlen); - - return 0; -} - - -/* - * This function gets the remote address of the socket and stores it in the - * XtransConnInfo structure for the connection. - */ - -static int -TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage socknamev6; -#endif - struct sockaddr_in socknamev4; - void *socknamePtr; -#if defined(SVR4) || defined(__SCO__) - size_t namelen; -#else - int namelen; -#endif - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && ciptr->family == AF_INET6) - { - namelen = sizeof(socknamev6); - socknamePtr = &socknamev6; - } - else -#endif - { - namelen = sizeof(socknamev4); - socknamePtr = &socknamev4; - } - - PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0); - - if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr, - (void *)&namelen) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n", - EGET(), 0, 0); - return -1; - } - - /* - * Everything looks good: fill in the XtransConnInfo structure. - */ - - if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketINETGetPeerAddr: Can't allocate space for the addr\n", - 0, 0, 0); - return -1; - } - - ciptr->peeraddrlen = namelen; - memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen); - - return 0; -} - - -static XtransConnInfo -TRANS(SocketOpen) (int i, int type) - -{ - XtransConnInfo ciptr; - - PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0); - -#if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; - - if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6) - return NULL; -#endif - - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0); - return NULL; - } - - if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type, - Sockettrans2devtab[i].protocol)) < 0 -#ifndef WIN32 -#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t) - || ciptr->fd >= TRANS_OPEN_MAX -#endif -#endif - ) { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (2, "SocketOpen: socket() failed for %s\n", - Sockettrans2devtab[i].transname, 0, 0); - - xfree ((char *) ciptr); - return NULL; - } - -#ifdef TCP_NODELAY - if (Sockettrans2devtab[i].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[i].family == AF_INET6 -#endif - ) - { - /* - * turn off TCP coalescence for INET sockets - */ - - int tmp = 1; - setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (int)); - } -#endif - - return ciptr; -} - - -#ifdef TRANS_REOPEN - -static XtransConnInfo -TRANS(SocketReopen) (int i, int type, int fd, char *port) - -{ - XtransConnInfo ciptr; - - PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port); - - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketReopen: malloc failed\n", 0, 0, 0); - return NULL; - } - - ciptr->fd = fd; - - return ciptr; -} - -#endif /* TRANS_REOPEN */ - - -/* - * These functions are the interface supplied in the Xtransport structure - */ - -#ifdef TRANS_CLIENT - -static XtransConnInfo -TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol, - char *host, char *port, int previndex) -{ - XtransConnInfo ciptr; - int i = previndex; - - PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n", - protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) { - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) && - (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3))) - { - ciptr = TRANS(SocketCreateConnInfo) (); - - if (ciptr == NULL) - { - PRMSG (1, "SocketOpenCOTSClient: Unable to create the NX connection info for %s.\n", - transname, 0, 0); - - return NULL; - } - - ciptr->index = i; - - return ciptr; - } - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n", - transname, 0, 0); - else - PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n", - transname, 0, 0); - return NULL; - } - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - ciptr->priv = NULL; - -#endif - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -static XtransConnInfo -TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol, - char *host, char *port) -{ - return TRANS(SocketOpenCOTSClientBase)( - thistrans->TransName, protocol, host, port, -1); -} - - -#endif /* TRANS_CLIENT */ - - -#ifdef TRANS_SERVER - -static XtransConnInfo -TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* - * Using this prevents the bind() check for an existing server listening - * on the same port, but it is required for other reasons. - */ -#ifdef SO_REUSEADDR - - /* - * SO_REUSEADDR only applied to AF_INET && AF_INET6 - */ - - if (Sockettrans2devtab[i].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[i].family == AF_INET6 -#endif - ) - { - int one = 1; - setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR, - (char *) &one, sizeof (int)); - } -#endif -#ifdef IPV6_V6ONLY - if (Sockettrans2devtab[i].family == AF_INET6) - { - int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); - } -#endif - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_CLIENT - -static XtransConnInfo -TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if ((!strcmp(protocol, "local") || !strcmp(protocol, "nx")) && - (!strcasecmp(host, "nx") || !strncasecmp(host, "nx,", 3))) - { - ciptr = TRANS(SocketCreateConnInfo) (); - - if (ciptr == NULL) - { - PRMSG (1, "SocketOpenCLTSClient: Unable to create the NX connection info for %s.\n", - thistrans->TransName, 0, 0); - - return NULL; - } - - ciptr->index = i; - - return ciptr; - } - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - ciptr->priv = NULL; - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_CLIENT */ - - -#ifdef TRANS_SERVER - -static XtransConnInfo -TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - -#ifdef IPV6_V6ONLY - if (Sockettrans2devtab[i].family == AF_INET6) - { - int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); - } -#endif - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_REOPEN - -static XtransConnInfo -TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2, - "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketReopen) ( - i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -static XtransConnInfo -TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2, - "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketReopen) ( - i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_REOPEN */ - - -static int -TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg) - -{ - PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg); - -#ifdef NX_TRANS_TEST - fprintf(stderr, "SocketSetOption: WARNING! Not setting option [%d] with value [%d] on descriptor [%d].\n", - option, arg, ciptr -> fd); -#endif - - return -1; -} - -#ifdef UNIXCONN -static int -set_sun_path(const char *port, const char *upath, char *path) -{ - struct sockaddr_un s; - int maxlen = sizeof(s.sun_path) - 1; - - if (!port || !*port || !path) - return -1; - - if (*port == '/') { /* a full pathname */ - if (strlen(port) > maxlen) - return -1; - sprintf(path, "%s", port); - } else { - if (strlen(port) + strlen(upath) > maxlen) - return -1; - sprintf(path, "%s%s", upath, port); - } - return 0; -} -#endif - -#ifdef TRANS_SERVER - -static int -TRANS(SocketCreateListener) (XtransConnInfo ciptr, - struct sockaddr *sockname, - int socknamelen, unsigned int flags) - -{ - int namelen = socknamelen; - int fd = ciptr->fd; - int retry; - - PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[ciptr->index].family == AF_INET6 -#endif - ) - retry = 20; - else - retry = 0; - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "SocketCreateListener: Creating listener for ciptr at [%p] on path [%s].\n", - (void *) ciptr, ((struct sockaddr_un *) sockname)->sun_family == AF_UNIX ? - ((struct sockaddr_un *) sockname)->sun_path : "TCP"); -#endif - while (bind (fd, (struct sockaddr *) sockname, namelen) < 0) - { - if (errno == EADDRINUSE) { - if (flags & ADDR_IN_USE_ALLOWED) - break; - else - return TRANS_ADDR_IN_USE; - } - - if (retry-- == 0) { - PRMSG (1, "SocketCreateListener: failed to bind listener\n", - 0, 0, 0); - close (fd); - return TRANS_CREATE_LISTENER_FAILED; - } -#ifdef SO_REUSEADDR - sleep (1); -#else - sleep (10); -#endif /* SO_REUSEDADDR */ - } - - if (Sockettrans2devtab[ciptr->index].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[ciptr->index].family == AF_INET6 -#endif - ) { -#ifdef SO_DONTLINGER - setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); -#else -#ifdef SO_LINGER - { - static int linger[2] = { 0, 0 }; - setsockopt (fd, SOL_SOCKET, SO_LINGER, - (char *) linger, sizeof (linger)); - } -#endif -#endif -} - - if (listen (fd, BACKLOG) < 0) - { - PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0); - close (fd); - return TRANS_CREATE_LISTENER_FAILED; - } - - /* Set a flag to indicate that this connection is a listener */ - - ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "SocketCreateListener: Set flags to [%d] for ciptr [%p].\n", - ciptr->flags, (void *) ciptr); -#endif - - return 0; -} - -#ifdef TCPCONN -static int -TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage sockname; -#else - struct sockaddr_in sockname; -#endif - unsigned short sport; - int namelen = sizeof(sockname); - int status; - long tmpport; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgetservbynameparams sparams; -#endif - struct servent *servp; - -#ifdef X11_t - char portbuf[PORTBUFSIZE]; -#endif - - PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0); - -#ifdef X11_t - /* - * X has a well known port, that is transport dependent. It is easier - * to handle it here, than try and come up with a transport independent - * representation that can be passed in and resolved the usual way. - * - * The port that is passed here is really a string containing the idisplay - * from ConnectDisplay(). - */ - - if (is_numeric (port)) - { - /* fixup the server port address */ - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf,"%lu", tmpport); - port = portbuf; - } -#endif - - if (port && *port) - { - /* Check to see if the port string is just a number (handles X11) */ - - if (!is_numeric (port)) - { - if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) - { - PRMSG (1, - "SocketINETCreateListener: Unable to get service for %s\n", - port, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - /* we trust getservbyname to return a valid number */ - sport = servp->s_port; - } - else - { - tmpport = strtol (port, (char**)NULL, 10); - /* - * check that somehow the port address isn't negative or in - * the range of reserved port addresses. This can happen and - * be very bad if the server is suid-root and the user does - * something (dumb) like `X :60049`. - */ - if (tmpport < 1024 || tmpport > USHRT_MAX) - return TRANS_CREATE_LISTENER_FAILED; - - sport = (unsigned short) tmpport; - } - } - else - sport = 0; - - bzero(&sockname, sizeof(sockname)); -#if defined(IPv6) && defined(AF_INET6) - if (Sockettrans2devtab[ciptr->index].family == AF_INET) { - namelen = sizeof (struct sockaddr_in); -#ifdef BSD44SOCKETS - ((struct sockaddr_in *)&sockname)->sin_len = namelen; -#endif - ((struct sockaddr_in *)&sockname)->sin_family = AF_INET; - ((struct sockaddr_in *)&sockname)->sin_port = htons(sport); - ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY); - } else { - namelen = sizeof (struct sockaddr_in6); -#ifdef SIN6_LEN - ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname); -#endif - ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6; - ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport); - ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any; - } -#else -#ifdef BSD44SOCKETS - sockname.sin_len = sizeof (sockname); -#endif - sockname.sin_family = AF_INET; - sockname.sin_port = htons (sport); - sockname.sin_addr.s_addr = htonl (INADDR_ANY); -#endif - - if ((status = TRANS(SocketCreateListener) (ciptr, - (struct sockaddr *) &sockname, namelen, flags)) < 0) - { - PRMSG (1, - "SocketINETCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); - return status; - } - - if (TRANS(SocketINETGetAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETCreateListener: ...SocketINETGetAddr() failed\n", - 0, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - - return 0; -} - -#endif /* SOCKCONN */ - - -#ifdef UNIXCONN - -static int -TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, - unsigned int flags) - -{ - struct sockaddr_un sockname; - int namelen; - int oldUmask; - int status; - unsigned int mode; - - PRMSG (2, "SocketUNIXCreateListener(%s)\n", - port ? port : "NULL", 0, 0); - - /* Make sure the directory is created */ - - oldUmask = umask (0); - -#ifdef UNIX_DIR -#ifdef HAS_STICKY_DIR_BIT - mode = 01777; -#else - mode = 0777; -#endif -#ifdef NX_TRANS_SOCKET - if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) { - PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n", - _NXGetUnixDir(UNIX_DIR), errno, 0); -#else - if (trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); -#endif - (void) umask (oldUmask); - return TRANS_CREATE_LISTENER_FAILED; - } -#endif - - sockname.sun_family = AF_UNIX; - - if (port && *port) { -#ifdef NX_TRANS_SOCKET - if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) { -#else - if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) { -#endif - PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - } else { -#ifdef NX_TRANS_SOCKET - sprintf (sockname.sun_path, "%s%ld", _NXGetUnixPath(UNIX_PATH), (long)getpid()); -#else - sprintf (sockname.sun_path, "%s%ld", UNIX_PATH, (long)getpid()); -#endif - } - -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx) - sockname.sun_len = strlen(sockname.sun_path); - namelen = SUN_LEN(&sockname); -#else - namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family); -#endif - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "SocketUNIXCreateListener: Unlinking path [%s] for ciptr at [%p].\n", - sockname.sun_path, (void *) ciptr); -#endif - unlink (sockname.sun_path); - - if ((status = TRANS(SocketCreateListener) (ciptr, - (struct sockaddr *) &sockname, namelen, flags)) < 0) - { - PRMSG (1, - "SocketUNIXCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); - (void) umask (oldUmask); - return status; - } - - /* - * Now that the listener is esablished, create the addr info for - * this connection. getpeername() doesn't work for UNIX Domain Sockets - * on some systems (hpux at least), so we will just do it manually, instead - * of calling something like TRANS(SocketUNIXGetAddr). - */ - - namelen = sizeof (sockname); /* this will always make it the same size */ - - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); - (void) umask (oldUmask); - return TRANS_CREATE_LISTENER_FAILED; - } - - ciptr->family = sockname.sun_family; - ciptr->addrlen = namelen; - memcpy (ciptr->addr, &sockname, ciptr->addrlen); - - (void) umask (oldUmask); - - return 0; -} - - -static int -TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr) - -{ - /* - * See if the unix domain socket has disappeared. If it has, recreate it. - */ - - struct sockaddr_un *unsock = (struct sockaddr_un *) ciptr->addr; - struct stat statb; - int status = TRANS_RESET_NOOP; - unsigned int mode; - - PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0); - - if (stat (unsock->sun_path, &statb) == -1 || - ((statb.st_mode & S_IFMT) != -#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK) - S_IFIFO)) -#else - S_IFSOCK)) -#endif - { - int oldUmask = umask (0); - -#ifdef UNIX_DIR -#ifdef HAS_STICKY_DIR_BIT - mode = 01777; -#else - mode = 0777; -#endif -#ifdef NX_TRANS_SOCKET - if (trans_mkdir(_NXGetUnixDir(UNIX_DIR), mode) == -1) { - PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n", - _NXGetUnixDir(UNIX_DIR), errno, 0); -#else - if (trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); -#endif - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } -#endif - - close (ciptr->fd); - unlink (unsock->sun_path); - - if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - { - TRANS(FreeConnInfo) (ciptr); - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } - - if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0) - { - close (ciptr->fd); - TRANS(FreeConnInfo) (ciptr); - return TRANS_RESET_FAILURE; - } - - if (listen (ciptr->fd, BACKLOG) < 0) - { - close (ciptr->fd); - TRANS(FreeConnInfo) (ciptr); - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } - - umask (oldUmask); - - status = TRANS_RESET_NEW_FD; - } - - return status; -} - -#endif /* UNIXCONN */ - - -#ifdef TCPCONN - -static XtransConnInfo -TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) - -{ - XtransConnInfo newciptr; - struct sockaddr_in sockname; - int namelen = sizeof(sockname); - - PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0); - - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - if ((newciptr->fd = accept (ciptr->fd, - (struct sockaddr *) &sockname, (void *)&namelen)) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0); - xfree (newciptr); - *status = TRANS_ACCEPT_FAILED; - return NULL; - } - -#ifdef TCP_NODELAY - { - /* - * turn off TCP coalescence for INET sockets - */ - - int tmp = 1; - setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (int)); - } -#endif - - /* - * Get this address again because the transport may give a more - * specific address now that a connection is established. - */ - - if (TRANS(SocketINETGetAddr) (newciptr) < 0) - { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); - close (newciptr->fd); - xfree (newciptr); - *status = TRANS_ACCEPT_MISC_ERROR; - return NULL; - } - - if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0) - { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); - close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); - *status = TRANS_ACCEPT_MISC_ERROR; - return NULL; - } - - *status = 0; - - return newciptr; -} - -#endif /* TCPCONN */ - - -#ifdef UNIXCONN -static XtransConnInfo -TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) - -{ - XtransConnInfo newciptr; - struct sockaddr_un sockname; -#if defined(SVR4) || defined(__SCO__) - size_t namelen = sizeof sockname; -#else - int namelen = sizeof sockname; -#endif - - PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0); - - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - if ((newciptr->fd = accept (ciptr->fd, - (struct sockaddr *) &sockname, (void *)&namelen)) < 0) - { - PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0); - xfree (newciptr); - *status = TRANS_ACCEPT_FAILED; - return NULL; - } - - /* - * Get the socket name and the peer name from the listener socket, - * since this is unix domain. - */ - - if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) - { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); - close (newciptr->fd); - xfree (newciptr); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - - newciptr->addrlen = ciptr->addrlen; - memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen); - - if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL) - { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); - close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - newciptr->peeraddrlen = ciptr->addrlen; - memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen); - - newciptr->family = AF_UNIX; - - *status = 0; - - return newciptr; -} - -#endif /* UNIXCONN */ - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_CLIENT - -#ifdef TCPCONN - -#if defined(IPv6) && defined(AF_INET6) -struct addrlist { - struct addrinfo * addr; - struct addrinfo * firstaddr; - char port[PORTBUFSIZE]; - char host[MAXHOSTNAMELEN]; -}; -static struct addrlist *addrlist = NULL; -#endif - - -static int -TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) - -{ - struct sockaddr * socketaddr = NULL; - int socketaddrlen = 0; - int res; -#if defined(IPv6) && defined(AF_INET6) - struct addrinfo hints; - char ntopbuf[INET6_ADDRSTRLEN]; - int resetonce = 0; -#endif - struct sockaddr_in sockname; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; - _Xgetservbynameparams sparams; -#endif - struct hostent *hostp; - struct servent *servp; - unsigned long tmpaddr; -#ifdef X11_t - char portbuf[PORTBUFSIZE]; -#endif - - long tmpport; - char hostnamebuf[256]; /* tmp space */ - - PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); - - if (!host) - { - hostnamebuf[0] = '\0'; - (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf); - host = hostnamebuf; - } - -#ifdef X11_t - /* - * X has a well known port, that is transport dependent. It is easier - * to handle it here, than try and come up with a transport independent - * representation that can be passed in and resolved the usual way. - * - * The port that is passed here is really a string containing the idisplay - * from ConnectDisplay(). - */ - - if (is_numeric (port)) - { - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf, "%lu", tmpport); - port = portbuf; - } -#endif - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) { - if (addrlist != NULL) { - if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) { - if (addrlist->firstaddr) - freeaddrinfo(addrlist->firstaddr); - addrlist->firstaddr = NULL; - } - } else { - addrlist = malloc(sizeof(struct addrlist)); - addrlist->firstaddr = NULL; - } - - if (addrlist->firstaddr == NULL) { - strncpy(addrlist->port, port, sizeof(addrlist->port)); - addrlist->port[sizeof(addrlist->port) - 1] = '\0'; - strncpy(addrlist->host, host, sizeof(addrlist->host)); - addrlist->host[sizeof(addrlist->host) - 1] = '\0'; - - bzero(&hints,sizeof(hints)); - hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname; - - res = getaddrinfo(host,port,&hints,&addrlist->firstaddr); - if (res != 0) { - PRMSG (1, "SocketINETConnect() can't get address " - "for %s:%s: %s\n", host, port, gai_strerror(res)); - ESET(EINVAL); - return TRANS_CONNECT_FAILED; - } - for (res = 0, addrlist->addr = addrlist->firstaddr; - addrlist->addr ; res++) { - addrlist->addr = addrlist->addr->ai_next; - } - PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0); - res = 0; - addrlist->addr = NULL; - } - - while (socketaddr == NULL) { - if (addrlist->addr == NULL) { - if (resetonce) { - /* Already checked entire list - no usable addresses */ - PRMSG (1, "SocketINETConnect() no usable address " - "for %s:%s\n", host, port, 0); - return TRANS_CONNECT_FAILED; - } else { - /* Go back to beginning of list */ - resetonce = 1; - addrlist->addr = addrlist->firstaddr; - } - } - - socketaddr = addrlist->addr->ai_addr; - socketaddrlen = addrlist->addr->ai_addrlen; - - if (addrlist->addr->ai_family == AF_INET) { - struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr; - - PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n", - inet_ntop(addrlist->addr->ai_family,&sin->sin_addr, - ntopbuf,sizeof(ntopbuf)), 0, 0); - - PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n", - ntohs(sin->sin_port), 0, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET6) { - if (strcmp(Sockettrans2devtab[ciptr->index].transname, - "tcp") == 0) { - XtransConnInfo newciptr; - - /* - * Our socket is an IPv6 socket, but the address is - * IPv4. Close it and get an IPv4 socket. This is - * needed for IPv4 connections to work on platforms - * that don't allow IPv4 over IPv6 sockets. - */ - TRANS(SocketINETClose)(ciptr); - newciptr = TRANS(SocketOpenCOTSClientBase)( - "tcp", "tcp", host, port, ciptr->index); - if (newciptr) - ciptr->fd = newciptr->fd; - if (!newciptr || - Sockettrans2devtab[newciptr->index].family != - AF_INET) { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv4 " - " socketfor IPv4 address\n", 0,0,0); - } - if (newciptr) - xfree(newciptr); - } else { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect Skipping IPv4 address\n", - 0,0,0); - } - } - } else if (addrlist->addr->ai_family == AF_INET6) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr; - - PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n", - inet_ntop(addrlist->addr->ai_family, - &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)), - 0, 0); - PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n", - ntohs(sin6->sin6_port), 0, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET) { - if (strcmp(Sockettrans2devtab[ciptr->index].transname, - "tcp") == 0) { - XtransConnInfo newciptr; - - /* - * Close the IPv4 socket and try to open an IPv6 socket. - */ - TRANS(SocketINETClose)(ciptr); - newciptr = TRANS(SocketOpenCOTSClientBase)( - "tcp", "tcp", host, port, -1); - if (newciptr) - ciptr->fd = newciptr->fd; - if (!newciptr || - Sockettrans2devtab[newciptr->index].family != - AF_INET6) { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv6 " - "socket for IPv6 address\n", 0,0,0); - } - if (newciptr) - xfree(newciptr); - } - else - { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n", - 0,0,0); - } - } - } else { - socketaddr = NULL; /* Unsupported address type */ - } - if (socketaddr == NULL) { - addrlist->addr = addrlist->addr->ai_next; - } - } - } else -#endif - { - /* - * Build the socket name. - */ - -#ifdef BSD44SOCKETS - sockname.sin_len = sizeof (struct sockaddr_in); -#endif - sockname.sin_family = AF_INET; - - /* - * fill in sin_addr - */ - -#ifndef INADDR_NONE -#define INADDR_NONE ((in_addr_t) 0xffffffff) -#endif - - /* check for ww.xx.yy.zz host string */ - - if (isascii (host[0]) && isdigit (host[0])) { - tmpaddr = inet_addr (host); /* returns network byte order */ - } else { - tmpaddr = INADDR_NONE; - } - - PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0); - - if (tmpaddr == INADDR_NONE) { - if ((hostp = _XGethostbyname(host,hparams)) == NULL) { - PRMSG (1,"SocketINETConnect: Can't get address for %s\n", - host, 0, 0); - ESET(EINVAL); - return TRANS_CONNECT_FAILED; - } - if (hostp->h_addrtype != AF_INET) { /* is IP host? */ - PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0); - ESET(EPROTOTYPE); - return TRANS_CONNECT_FAILED; - } - -#if defined(CRAY) && defined(OLDTCP) - /* Only Cray UNICOS3 and UNICOS4 will define this */ - { - long t; - memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t)); - sockname.sin_addr = t; - } -#else - memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr, - sizeof (sockname.sin_addr)); -#endif /* CRAY and OLDTCP */ - - } else { -#if defined(CRAY) && defined(OLDTCP) - /* Only Cray UNICOS3 and UNICOS4 will define this */ - sockname.sin_addr = tmpaddr; -#else - sockname.sin_addr.s_addr = tmpaddr; -#endif /* CRAY and OLDTCP */ - } - - /* - * fill in sin_port - */ - - /* Check for number in the port string */ - - if (!is_numeric (port)) { - if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) { - PRMSG (1,"SocketINETConnect: can't get service for %s\n", - port, 0, 0); - return TRANS_CONNECT_FAILED; - } - sockname.sin_port = htons (servp->s_port); - } else { - tmpport = strtol (port, (char**)NULL, 10); - if (tmpport < 1024 || tmpport > USHRT_MAX) - return TRANS_CONNECT_FAILED; - sockname.sin_port = htons (((unsigned short) tmpport)); - } - - PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n", - ntohs(sockname.sin_port), 0, 0); - socketaddr = (struct sockaddr *) &sockname; - socketaddrlen = sizeof(sockname); - } - - /* - * Turn on socket keepalive so the client process will eventually - * be notified with a SIGPIPE signal if the display server fails - * to respond to a periodic transmission of messages - * on the connected socket. - * This is useful to avoid hung application processes when the - * processes are not spawned from the xdm session and - * the display server terminates abnormally. - * (Someone turned off the power switch.) - */ - - { - int tmp = 1; - setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE, - (char *) &tmp, sizeof (int)); - } - - /* - * Do the connect() - */ - - if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0) - { -#ifdef WIN32 - int olderrno = WSAGetLastError(); -#else - int olderrno = errno; -#endif - - /* - * If the error was ECONNREFUSED, the server may be overloaded - * and we should try again. - * - * If the error was EWOULDBLOCK or EINPROGRESS then the socket - * was non-blocking and we should poll using select - * - * If the error was EINTR, the connect was interrupted and we - * should try again. - * - * If multiple addresses are found for a host then we should - * try to connect again with a different address for a larger - * number of errors that made us quit before, since those - * could be caused by trying to use an IPv6 address to contact - * a machine with an IPv4-only server or other reasons that - * only affect one of a set of addresses. - */ - - if (olderrno == ECONNREFUSED || olderrno == EINTR -#if defined(IPv6) && defined(AF_INET6) - || (haveIPv6 && ((addrlist->addr->ai_next != NULL) || - (addrlist->addr != addrlist->firstaddr)) && - (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT || - olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT -#if defined(EHOSTDOWN) - || olderrno == EHOSTDOWN -#endif - )) -#endif - ) - res = TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS) - res = TRANS_IN_PROGRESS; - else - { - PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n", - olderrno,0, 0); - - res = TRANS_CONNECT_FAILED; - } - } else { - res = 0; - - - /* - * Sync up the address fields of ciptr. - */ - - if (TRANS(SocketINETGetAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); - res = TRANS_CONNECT_FAILED; - } - - else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); - res = TRANS_CONNECT_FAILED; - } - } - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && res != 0) { - addrlist->addr = addrlist->addr->ai_next; - } -#endif - - return res; -} - -#endif /* TCPCONN */ - - - -#ifdef UNIXCONN - -/* - * Make sure 'host' is really local. - */ - -static int -UnixHostReallyLocal (char *host) - -{ - char hostnamebuf[256]; - -#if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; -#endif - - TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf)); - - if (strcmp (hostnamebuf, host) == 0) - { - return (1); - } -#if defined(IPv6) && defined(AF_INET6) - else if (haveIPv6) - { - struct addrinfo *localhostaddr; - struct addrinfo *otherhostaddr; - struct addrinfo *i, *j; - int equiv = 0; - - if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0) - return 0; - if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) { - freeaddrinfo(localhostaddr); - return 0; - } - - for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) { - for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) { - if (i->ai_family == j->ai_family) { - if (i->ai_family == AF_INET) { - struct sockaddr_in *sinA - = (struct sockaddr_in *) i->ai_addr; - struct sockaddr_in *sinB - = (struct sockaddr_in *) j->ai_addr; - struct in_addr *A = &sinA->sin_addr; - struct in_addr *B = &sinB->sin_addr; - - if (memcmp(A,B,sizeof(struct in_addr)) == 0) { - equiv = 1; - } - } else if (i->ai_family == AF_INET6) { - struct sockaddr_in6 *sinA - = (struct sockaddr_in6 *) i->ai_addr; - struct sockaddr_in6 *sinB - = (struct sockaddr_in6 *) j->ai_addr; - struct in6_addr *A = &sinA->sin6_addr; - struct in6_addr *B = &sinB->sin6_addr; - - if (memcmp(A,B,sizeof(struct in6_addr)) == 0) { - equiv = 1; - } - } - } - } - } - - freeaddrinfo(localhostaddr); - freeaddrinfo(otherhostaddr); - return equiv; - } -#endif - else - { - /* - * A host may have more than one network address. If any of the - * network addresses of 'host' (specified to the connect call) - * match any of the network addresses of 'hostname' (determined - * by TRANS(GetHostname)), then the two hostnames are equivalent, - * and we know that 'host' is really a local host. - */ - char specified_local_addr_list[10][4]; - int scount, equiv, i, j; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - struct hostent *hostp; - - if ((hostp = _XGethostbyname (host,hparams)) == NULL) - return (0); - - scount = 0; - while (hostp->h_addr_list[scount] && scount <= 8) - { - /* - * The 2nd call to gethostname() overrides the data - * from the 1st call, so we must save the address list. - */ - - specified_local_addr_list[scount][0] = - hostp->h_addr_list[scount][0]; - specified_local_addr_list[scount][1] = - hostp->h_addr_list[scount][1]; - specified_local_addr_list[scount][2] = - hostp->h_addr_list[scount][2]; - specified_local_addr_list[scount][3] = - hostp->h_addr_list[scount][3]; - scount++; - } - if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL) - return (0); - - equiv = 0; - i = 0; - - while (i < scount && !equiv) - { - j = 0; - - while (hostp->h_addr_list[j]) - { - if ((specified_local_addr_list[i][0] == - hostp->h_addr_list[j][0]) && - (specified_local_addr_list[i][1] == - hostp->h_addr_list[j][1]) && - (specified_local_addr_list[i][2] == - hostp->h_addr_list[j][2]) && - (specified_local_addr_list[i][3] == - hostp->h_addr_list[j][3])) - { - /* They're equal, so we're done */ - - equiv = 1; - break; - } - - j++; - } - - i++; - } - return (equiv); - } -} - -static int -TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) - -{ - struct sockaddr_un sockname; - int namelen; - -#if defined(hpux) && defined(X11_t) - struct sockaddr_un old_sockname; - int old_namelen; -#endif - - - PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port); - - /* - * Make sure 'host' is really local. If not, we return failure. - * The reason we make this check is because a process may advertise - * a "local" network ID for which it can accept connections, but if - * a process on a remote machine tries to connect to this network ID, - * we know for sure it will fail. - */ - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - if (strcmp(host, "unix") != 0 && strcasecmp(host, "nx") != 0 && - strncasecmp(host, "nx,", 3) != 0 && !UnixHostReallyLocal (host)) -#else - if (strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host)) -#endif - { - PRMSG (1, - "SocketUNIXConnect: Cannot connect to non-local host %s\n", - host, 0, 0); - return TRANS_CONNECT_FAILED; - } - - - /* - * Check the port. - */ - - if (!port || !*port) - { - PRMSG (1,"SocketUNIXConnect: Missing port specification\n", - 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - - /* - * Build the socket name. - */ - - sockname.sun_family = AF_UNIX; - -#ifdef NX_TRANS_SOCKET - if (set_sun_path(port, _NXGetUnixPath(UNIX_PATH), sockname.sun_path) != 0) { -#else - if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) { -#endif - PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx) - sockname.sun_len = strlen (sockname.sun_path); - namelen = SUN_LEN (&sockname); -#else - namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family); -#endif - - -#if defined(hpux) && defined(X11_t) - /* - * This is gross, but it was in Xlib - */ - old_sockname.sun_family = AF_UNIX; -#ifdef NX_TRANS_SOCKET - if (set_sun_path(port, _NXGetOldUnixPath(OLD_UNIX_PATH), old_sockname.sun_path) != 0) { -#else - if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) { -#endif - PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - old_namelen = strlen (old_sockname.sun_path) + - sizeof (old_sockname.sun_family); -#endif - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if (ciptr->priv != NULL) - { - if (TRANS(SocketConnectConnInfo) (ciptr, host, port) != 0) - { - return TRANS_CONNECT_FAILED; - } - - goto SocketUNIXConnectPost; - } - -#endif - - /* - * Do the connect() - */ - - if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0) - { - int olderrno = errno; - int connected = 0; - -#if defined(hpux) && defined(X11_t) - if (olderrno == ENOENT) - { - if (connect (ciptr->fd, - (struct sockaddr *) &old_sockname, old_namelen) >= 0) - { - connected = 1; - } - else - olderrno = errno; - } -#endif - if (!connected) - { - errno = olderrno; - - /* - * If the error was ENOENT, the server may be starting up - * and we should try again. - * - * If the error was EWOULDBLOCK or EINPROGRESS then the socket - * was non-blocking and we should poll using select - * - * If the error was EINTR, the connect was interrupted and we - * should try again. - */ - - if (olderrno == ENOENT || olderrno == EINTR) - return TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS) - return TRANS_IN_PROGRESS; - else - { - PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n", - EGET(),0, 0); - - return TRANS_CONNECT_FAILED; - } - } - } - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - -SocketUNIXConnectPost: - -#endif - - /* - * Get the socket name and the peer name from the connect socket, - * since this is unix domain. - */ - - if ((ciptr->addr = (char *) xalloc(namelen)) == NULL || - (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL) - { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - - ciptr->family = AF_UNIX; - ciptr->addrlen = namelen; - ciptr->peeraddrlen = namelen; - memcpy (ciptr->addr, &sockname, ciptr->addrlen); - memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen); - - return 0; -} - -#endif /* UNIXCONN */ - -#endif /* TRANS_CLIENT */ - - -static int -TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) - -{ - PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n", - ciptr, ciptr->fd, pend); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if (ciptr->priv) - { - if (NXTransRunning(ciptr->fd) == 0) - { - /* - * Force the application to shut down the - * socket if the NX transport is gone. We - * may probably save this additional call. - */ - -#ifdef NX_TRANS_DEBUG - fprintf(stderr, "SocketBytesReadable: NX transport not running for descriptor [%d].\n", - ciptr->fd); -#endif - ESET(EPIPE); - - return -1; - } - else - { - /* - * Emulate BytesReadable. Some X applications may use the system - * select() in their main loop, instead of the _XSelect() that is - * replaced by NX. Still these applications use _XEventsQueued to - * poll events from the X connection, and _XEventsQueued uses the - * NX _XSelect(), so it is generally possible to let the client - * yield the control to NX and let it handle the I/O on the proxy - * descriptors even if the application is not explicitly designed - * to work as a NX agent. - */ - -#ifdef NX_TRANS_DEBUG - - int result; - - result = NXTransReadable(ciptr->fd, (int *) pend); - - fprintf(stderr, "SocketBytesReadable: Descriptor [%d] result [%d] readable [%ld].\n", - ciptr->fd, result, *pend); - - return result; -#else - return NXTransReadable(ciptr->fd, (int *) pend); -#endif - } - } - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - -#if defined(QNX4) - *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */ -#endif -#ifdef WIN32 - { - int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); - errno = WSAGetLastError(); - return ret; - } -#else -#if (defined(i386) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1) - return ioctl (ciptr->fd, I_NREAD, (char *) pend); -#else -#if defined(__UNIXOS2__) - return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int)); -#else - return ioctl (ciptr->fd, FIONREAD, (char *) pend); -#endif /* __UNIXOS2__ */ -#endif /* i386 && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */ -#endif /* WIN32 */ -} - - -static int -TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) - -{ - PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - /* - * If we have a valid priv pointer then this - * is an internal connection to the proxy. - * In this case we should emulate the read. - */ - - if (ciptr->priv) - { - int result; - - result = NXTransRead(ciptr->fd, buf, size); - -#ifdef NX_TRANS_DEBUG - if (result < 0 && EGET() == EAGAIN) - { - fprintf(stderr, "SocketRead: Read from descriptor [%d] would block.\n", - ciptr->fd); - } - else - { - fprintf(stderr, "SocketRead: Read [%d] bytes from descriptor [%d].\n", - result, ciptr->fd); - } -#endif - return result; - } - else - { - return read (ciptr->fd, buf, size); - } - -#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - -#if defined(WIN32) || defined(__UNIXOS2__) - { - int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - return ret; - } -#else - return read (ciptr->fd, buf, size); -#endif /* WIN32 */ - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ -} - - -static int -TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) - -{ - PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - /* - * If we have a valid priv pointer then this - * is an internal connection to the proxy. - * In this case we should emulate the write. - */ - - if (ciptr->priv) - { - int result; - - result = NXTransWrite(ciptr->fd, buf, size); - -#ifdef NX_TRANS_DEBUG - if (result < 0 && EGET() == EAGAIN) - { - fprintf(stderr, "SocketWrite: Write on descriptor [%d] would block.\n", - ciptr->fd); - } - else - { - fprintf(stderr, "SocketWrite: Written [%d] bytes on descriptor [%d].\n", - result, ciptr->fd); - } -#endif - return result; - } - else - { - return write (ciptr->fd, buf, size); - } - -#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - -#if defined(WIN32) || defined(__UNIXOS2__) - { - int ret = send ((SOCKET)ciptr->fd, buf, size, 0); -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - return ret; - } -#else - return write (ciptr->fd, buf, size); -#endif /* WIN32 */ - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ -} - - -static int -TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size) - -{ - PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - /* - * If we have a valid priv pointer then this - * is an internal connection to the proxy. - * In this case we should emulate the readv. - */ - - if (ciptr->priv) - { - return NXTransReadVector(ciptr->fd, buf, size); - } - else - { - return READV (ciptr, buf, size); - } - -#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - - return READV (ciptr, buf, size); - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ -} - - -static int -TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size) - -{ - PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - /* - * If we have a valid priv pointer then this - * is an internal connection to the proxy. - * In this case we should emulate the writev. - */ - - if (ciptr->priv) - { - return NXTransWriteVector(ciptr->fd, buf, size); - } - else - { - return WRITEV (ciptr, buf, size); - } - -#else /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ - - return WRITEV (ciptr, buf, size); - -#endif /* #if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) */ -} - - -static int -TRANS(SocketDisconnect) (XtransConnInfo ciptr) - -{ - PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0); - -#ifdef WIN32 - { - int ret = shutdown (ciptr->fd, 2); - errno = WSAGetLastError(); - return ret; - } -#else - return shutdown (ciptr->fd, 2); /* disallow further sends and receives */ -#endif -} - - -#ifdef TCPCONN -static int -TRANS(SocketINETClose) (XtransConnInfo ciptr) - -{ - PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0); - -#ifdef WIN32 - { - int ret = close (ciptr->fd); - errno = WSAGetLastError(); - return ret; - } -#else - return close (ciptr->fd); -#endif -} - -#endif /* TCPCONN */ - - -#ifdef UNIXCONN -static int -TRANS(SocketUNIXClose) (XtransConnInfo ciptr) - -{ - /* - * If this is the server side, then once the socket is closed, - * it must be unlinked to completely close it - */ - - struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr; - int ret; - - PRMSG (2,"SocketUNIXClose(%x,%d)\n", ciptr, ciptr->fd, 0); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if (ciptr->priv) - { - TRANS(SocketCloseConnInfo) (ciptr); - } - -#endif - - ret = close(ciptr->fd); - -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - fprintf(stderr, "SocketUNIXClose: Flags are [%d] for ciptr at [%p] check is [%d].\n", - ciptr->flags, (void *) ciptr, (ciptr->flags && sockname - && sockname->sun_family == AF_UNIX && sockname->sun_path[0])); -#endif - - if (ciptr->flags - && sockname - && sockname->sun_family == AF_UNIX - && sockname->sun_path[0]) - { -#if defined(NX_TRANS_SOCKET) && defined(NX_TRANS_TEST) - if (!(ciptr->flags & TRANS_NOUNLINK)) - { - fprintf(stderr, "SocketUNIXClose: Unlinking path [%s] for ciptr at [%p].\n", - sockname->sun_path, (void *) ciptr); - unlink (sockname->sun_path); - } -#else - if (!(ciptr->flags & TRANS_NOUNLINK)) - unlink (sockname->sun_path); -#endif - } - - return ret; -} - -static int -TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr) - -{ - /* - * Don't unlink path. - */ - - int ret; - - PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n", - ciptr, ciptr->fd, 0); - -#if defined(NX_TRANS_SOCKET) && defined(TRANS_CLIENT) - - if (ciptr->priv) - { - TRANS(SocketCloseConnInfo) (ciptr); - } - -#endif - - ret = close(ciptr->fd); - - return ret; -} - -#endif /* UNIXCONN */ - - -#ifdef TCPCONN -# ifdef TRANS_SERVER -static char* tcp_nolisten[] = { - "inet", -#if defined(IPv6) && defined(AF_INET6) - "inet6", -#endif - NULL -}; -# endif - -Xtransport TRANS(SocketTCPFuncs) = { - /* Socket Interface */ - "tcp", - TRANS_ALIAS, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - tcp_nolisten, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; - -Xtransport TRANS(SocketINETFuncs) = { - /* Socket Interface */ - "inet", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; - -#if defined(IPv6) && defined(AF_INET6) -Xtransport TRANS(SocketINET6Funcs) = { - /* Socket Interface */ - "inet6", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; -#endif /* IPv6 */ -#endif /* TCPCONN */ - -#ifdef UNIXCONN -#if !defined(LOCALCONN) -Xtransport TRANS(SocketLocalFuncs) = { - /* Socket Interface */ - "local", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketUNIXCreateListener), - TRANS(SocketUNIXResetListener), - TRANS(SocketUNIXAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketUNIXConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketUNIXClose), - TRANS(SocketUNIXCloseForCloning), - }; -#endif /* !LOCALCONN */ -# ifdef TRANS_SERVER -# if !defined(LOCALCONN) -static char* unix_nolisten[] = { "local" , NULL }; -# endif -# endif - -Xtransport TRANS(SocketUNIXFuncs) = { - /* Socket Interface */ - "unix", -#if !defined(LOCALCONN) - TRANS_ALIAS, -#else - 0, -#endif -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER -#if !defined(LOCALCONN) - unix_nolisten, -#else - NULL, -#endif - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketUNIXCreateListener), - TRANS(SocketUNIXResetListener), - TRANS(SocketUNIXAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketUNIXConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketUNIXClose), - TRANS(SocketUNIXCloseForCloning), - }; - -#endif /* UNIXCONN */ diff --git a/nx-X11/lib/xtrans/Xtranssock.c.X.original b/nx-X11/lib/xtrans/Xtranssock.c.X.original deleted file mode 100644 index 0f3c6b46a..000000000 --- a/nx-X11/lib/xtrans/Xtranssock.c.X.original +++ /dev/null @@ -1,2504 +0,0 @@ -/* $XdotOrg: xc/lib/xtrans/Xtranssock.c,v 1.11 2005/11/08 06:33:26 jkj Exp $ */ -/* $Xorg: Xtranssock.c,v 1.11 2001/02/09 02:04:06 xorgcvs Exp $ */ -/* - -Copyright 1993, 1994, 1998 The Open Group -Copyright 2002 Sun Microsystems, Inc. All rights reserved. - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of the copyright holders shall -not be used in advertising or otherwise to promote the sale, use or -other dealings in this Software without prior written authorization -from the copyright holders. - -*/ -/* $XFree86: xc/lib/xtrans/Xtranssock.c,v 3.68 2004/01/07 04:28:02 dawes Exp $ */ - -/* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA - * - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name NCR not be used in advertising - * or publicity pertaining to distribution of the software without specific, - * written prior permission. NCR makes no representations about the - * suitability of this software for any purpose. It is provided "as is" - * without express or implied warranty. - * - * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN - * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <ctype.h> -#ifdef XTHREADS -#include <X11/Xthreads.h> -#endif - -#ifndef WIN32 - -#if defined(TCPCONN) || defined(UNIXCONN) -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#endif - -#if defined(TCPCONN) || defined(UNIXCONN) -#define X_INCLUDE_NETDB_H -#define XOS_USE_NO_LOCKING -#include <X11/Xos_r.h> -#endif - -#ifdef UNIXCONN -#ifndef X_NO_SYS_UN -#ifndef Lynx -#include <sys/un.h> -#else -#include <un.h> -#endif -#endif -#include <sys/stat.h> -#endif - -#if defined(hpux) || (defined(MOTOROLA) && defined(SYSV)) -#define NO_TCP_H -#endif - -#ifndef NO_TCP_H -#if defined(__osf__) || defined(linux) || defined(__GLIBC__) || defined(AIXV5) -#include <sys/param.h> -#endif /* osf */ -#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) -#include <sys/param.h> -#include <machine/endian.h> -#endif /* __NetBSD__ || __OpenBSD__ || __FreeBSD__ || __DragonFly__ */ -#include <netinet/tcp.h> -#endif /* !NO_TCP_H */ - -#include <sys/ioctl.h> -#if defined(SVR4) && !defined(DGUX) && !defined(_SEQUENT_) -#include <sys/filio.h> -#endif - -#if (defined(i386) && defined(SYSV)) && !defined(SCO325) && !defined(sun) -#include <net/errno.h> -#endif - -#if (defined(i386) && defined(SYSV)) && (!defined(ISC) || !defined(I_NREAD) || defined(SCO325)) || defined(_SEQUENT_) -#include <sys/stropts.h> -#endif - -#else /* !WIN32 */ - -#include <X11/Xwinsock.h> -#include <X11/Xwindows.h> -#include <X11/Xw32defs.h> -#undef close -#define close closesocket -#define ECONNREFUSED WSAECONNREFUSED -#define EADDRINUSE WSAEADDRINUSE -#define EPROTOTYPE WSAEPROTOTYPE -#undef EWOULDBLOCK -#define EWOULDBLOCK WSAEWOULDBLOCK -#define EINPROGRESS WSAEINPROGRESS -#undef EINTR -#define EINTR WSAEINTR -#define X_INCLUDE_NETDB_H -#define XOS_USE_MTSAFE_NETDBAPI -#include <X11/Xos_r.h> -#endif /* WIN32 */ - -#if defined(SO_DONTLINGER) && defined(SO_LINGER) -#undef SO_DONTLINGER -#endif - -#if defined(__UNIXOS2__) -#if defined(NOT_EMX09A) -static int IBMsockInit = 0; -#define SocketInitOnce()\ - if (!IBMsockInit) {\ - sock_init();\ - IBMsockInit = 1;\ - } -#undef EINTR -#define EINTR SOCEINTR -#undef EINVAL -#define EINVAL SOCEINVAL -#undef errno -#define errno sock_errno() -#undef close -#define close soclose -#undef ioctl -#define ioctl sockioctl -#else -#define SocketInitOnce() /**/ -#endif -/* this is still not there */ -#define SOCKET int -#else -/* others don't need this */ -#define SocketInitOnce() /**/ -#endif - -#define MIN_BACKLOG 128 -#ifdef SOMAXCONN -#if SOMAXCONN > MIN_BACKLOG -#define BACKLOG SOMAXCONN -#endif -#endif -#ifndef BACKLOG -#define BACKLOG MIN_BACKLOG -#endif -/* - * This is the Socket implementation of the X Transport service layer - * - * This file contains the implementation for both the UNIX and INET domains, - * and can be built for either one, or both. - * - */ - -typedef struct _Sockettrans2dev { - char *transname; - int family; - int devcotsname; - int devcltsname; - int protocol; -} Sockettrans2dev; - -static Sockettrans2dev Sockettrans2devtab[] = { -#ifdef TCPCONN - {"inet",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, -#if !defined(IPv6) || !defined(AF_INET6) - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, -#else /* IPv6 */ - {"tcp",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, - {"tcp",AF_INET,SOCK_STREAM,SOCK_DGRAM,0}, /* fallback */ - {"inet6",AF_INET6,SOCK_STREAM,SOCK_DGRAM,0}, -#endif -#endif /* TCPCONN */ -#ifdef UNIXCONN - {"unix",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, -#if !defined(LOCALCONN) - {"local",AF_UNIX,SOCK_STREAM,SOCK_DGRAM,0}, -#endif /* !LOCALCONN */ -#endif /* UNIXCONN */ -}; - -#define NUMSOCKETFAMILIES (sizeof(Sockettrans2devtab)/sizeof(Sockettrans2dev)) - -#ifdef TCPCONN -static int TRANS(SocketINETClose) (XtransConnInfo ciptr); -#endif - -#ifdef UNIXCONN - -#ifdef hpux - -#if defined(X11_t) -#define UNIX_PATH "/usr/spool/sockets/X11/" -#define UNIX_DIR "/usr/spool/sockets/X11" -#define OLD_UNIX_PATH "/tmp/.X11-unix/X" -#endif /* X11_t */ -#if defined(XIM_t) -#define UNIX_PATH "/usr/spool/sockets/XIM/" -#define UNIX_DIR "/usr/spool/sockets/XIM" -#define OLD_UNIX_PATH "/tmp/.XIM-unix/XIM" -#endif /* XIM_t */ -#if defined(FS_t) || defined(FONT_t) -#define UNIX_PATH "/usr/spool/sockets/fontserv/" -#define UNIX_DIR "/usr/spool/sockets/fontserv" -#endif /* FS_t || FONT_t */ -#if defined(ICE_t) -#define UNIX_PATH "/usr/spool/sockets/ICE/" -#define UNIX_DIR "/usr/spool/sockets/ICE" -#endif /* ICE_t */ -#if defined(TEST_t) -#define UNIX_PATH "/usr/spool/sockets/xtrans_test/" -#define UNIX_DIR "/usr/spool/sockets/xtrans_test" -#endif -#if defined(LBXPROXY_t) -#define UNIX_PATH "/usr/spool/sockets/X11/" -#define UNIX_DIR "/usr/spool/sockets/X11" -#endif - -#else /* !hpux */ - -#if defined(X11_t) -#define UNIX_PATH "/tmp/.X11-unix/X" -#define UNIX_DIR "/tmp/.X11-unix" -#endif /* X11_t */ -#if defined(XIM_t) -#define UNIX_PATH "/tmp/.XIM-unix/XIM" -#define UNIX_DIR "/tmp/.XIM-unix" -#endif /* XIM_t */ -#if defined(FS_t) || defined(FONT_t) -#define UNIX_PATH "/tmp/.font-unix/fs" -#define UNIX_DIR "/tmp/.font-unix" -#endif /* FS_t || FONT_t */ -#if defined(ICE_t) -#define UNIX_PATH "/tmp/.ICE-unix/" -#define UNIX_DIR "/tmp/.ICE-unix" -#endif /* ICE_t */ -#if defined(TEST_t) -#define UNIX_PATH "/tmp/.Test-unix/test" -#define UNIX_DIR "/tmp/.Test-unix" -#endif -#if defined(LBXPROXY_t) -#define UNIX_PATH "/tmp/.X11-unix/X" -#define UNIX_DIR "/tmp/.X11-unix" -#endif - -#endif /* hpux */ - -#endif /* UNIXCONN */ - -#define PORTBUFSIZE 32 - -#ifndef MAXHOSTNAMELEN -#define MAXHOSTNAMELEN 255 -#endif - -/* - * This provides compatibility for apps linked against system libraries - * that don't have IPv6 support. - */ -#if defined(IPv6) && defined(AF_INET6) -static const struct in6_addr local_in6addr_any = IN6ADDR_ANY_INIT; -#pragma weak in6addr_any = local_in6addr_any -#ifndef __USLC__ -#pragma weak getaddrinfo -#endif -static int haveIPv6 = 1; -#endif - -/* - * These are some utility function used by the real interface function below. - */ - -static int -TRANS(SocketSelectFamily) (int first, char *family) - -{ - int i; - - PRMSG (3,"SocketSelectFamily(%s)\n", family, 0, 0); - - for (i = first + 1; i < NUMSOCKETFAMILIES;i++) - { - if (!strcmp (family, Sockettrans2devtab[i].transname)) - return i; - } - - return (first == -1 ? -2 : -1); -} - - -/* - * This function gets the local address of the socket and stores it in the - * XtransConnInfo structure for the connection. - */ - -static int -TRANS(SocketINETGetAddr) (XtransConnInfo ciptr) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage socknamev6; -#endif - struct sockaddr_in socknamev4; - void *socknamePtr; -#if defined(SVR4) || defined(__SCO__) - size_t namelen; -#else - int namelen; -#endif - - PRMSG (3,"SocketINETGetAddr(%p)\n", ciptr, 0, 0); - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - namelen = sizeof(socknamev6); - socknamePtr = &socknamev6; - } - else -#endif - { - namelen = sizeof(socknamev4); - socknamePtr = &socknamev4; - } - - if (getsockname (ciptr->fd,(struct sockaddr *) socknamePtr, - (void *)&namelen) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1,"SocketINETGetAddr: getsockname() failed: %d\n", - EGET(),0, 0); - return -1; - } - - /* - * Everything looks good: fill in the XtransConnInfo structure. - */ - - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketINETGetAddr: Can't allocate space for the addr\n", - 0, 0, 0); - return -1; - } - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) - { - ciptr->family = ((struct sockaddr *)socknamePtr)->sa_family; - } - else -#endif - { - ciptr->family = socknamev4.sin_family; - } - ciptr->addrlen = namelen; - memcpy (ciptr->addr, socknamePtr, ciptr->addrlen); - - return 0; -} - - -/* - * This function gets the remote address of the socket and stores it in the - * XtransConnInfo structure for the connection. - */ - -static int -TRANS(SocketINETGetPeerAddr) (XtransConnInfo ciptr) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage socknamev6; -#endif - struct sockaddr_in socknamev4; - void *socknamePtr; -#if defined(SVR4) || defined(__SCO__) - size_t namelen; -#else - int namelen; -#endif - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && ciptr->family == AF_INET6) - { - namelen = sizeof(socknamev6); - socknamePtr = &socknamev6; - } - else -#endif - { - namelen = sizeof(socknamev4); - socknamePtr = &socknamev4; - } - - PRMSG (3,"SocketINETGetPeerAddr(%p)\n", ciptr, 0, 0); - - if (getpeername (ciptr->fd, (struct sockaddr *) socknamePtr, - (void *)&namelen) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1,"SocketINETGetPeerAddr: getpeername() failed: %d\n", - EGET(), 0, 0); - return -1; - } - - /* - * Everything looks good: fill in the XtransConnInfo structure. - */ - - if ((ciptr->peeraddr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketINETGetPeerAddr: Can't allocate space for the addr\n", - 0, 0, 0); - return -1; - } - - ciptr->peeraddrlen = namelen; - memcpy (ciptr->peeraddr, socknamePtr, ciptr->peeraddrlen); - - return 0; -} - - -static XtransConnInfo -TRANS(SocketOpen) (int i, int type) - -{ - XtransConnInfo ciptr; - - PRMSG (3,"SocketOpen(%d,%d)\n", i, type, 0); - -#if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; - - if (!haveIPv6 && Sockettrans2devtab[i].family == AF_INET6) - return NULL; -#endif - - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketOpen: malloc failed\n", 0, 0, 0); - return NULL; - } - - if ((ciptr->fd = socket(Sockettrans2devtab[i].family, type, - Sockettrans2devtab[i].protocol)) < 0 -#ifndef WIN32 -#if (defined(X11_t) && !defined(USE_POLL)) || defined(FS_t) || defined(FONT_t) - || ciptr->fd >= TRANS_OPEN_MAX -#endif -#endif - ) { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (2, "SocketOpen: socket() failed for %s\n", - Sockettrans2devtab[i].transname, 0, 0); - - xfree ((char *) ciptr); - return NULL; - } - -#ifdef TCP_NODELAY - if (Sockettrans2devtab[i].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[i].family == AF_INET6 -#endif - ) - { - /* - * turn off TCP coalescence for INET sockets - */ - - int tmp = 1; - setsockopt (ciptr->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (int)); - } -#endif - - return ciptr; -} - - -#ifdef TRANS_REOPEN - -static XtransConnInfo -TRANS(SocketReopen) (int i, int type, int fd, char *port) - -{ - XtransConnInfo ciptr; - - PRMSG (3,"SocketReopen(%d,%d,%s)\n", type, fd, port); - - if ((ciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketReopen: malloc failed\n", 0, 0, 0); - return NULL; - } - - ciptr->fd = fd; - - return ciptr; -} - -#endif /* TRANS_REOPEN */ - - -/* - * These functions are the interface supplied in the Xtransport structure - */ - -#ifdef TRANS_CLIENT - -static XtransConnInfo -TRANS(SocketOpenCOTSClientBase) (char *transname, char *protocol, - char *host, char *port, int previndex) -{ - XtransConnInfo ciptr; - int i = previndex; - - PRMSG (2, "SocketOpenCOTSClient(%s,%s,%s)\n", - protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, transname)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCOTSClient: Unable to open socket for %s\n", - transname, 0, 0); - else - PRMSG (1,"SocketOpenCOTSClient: Unable to determine socket type for %s\n", - transname, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -static XtransConnInfo -TRANS(SocketOpenCOTSClient) (Xtransport *thistrans, char *protocol, - char *host, char *port) -{ - return TRANS(SocketOpenCOTSClientBase)( - thistrans->TransName, protocol, host, port, -1); -} - - -#endif /* TRANS_CLIENT */ - - -#ifdef TRANS_SERVER - -static XtransConnInfo -TRANS(SocketOpenCOTSServer) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCOTSServer(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* - * Using this prevents the bind() check for an existing server listening - * on the same port, but it is required for other reasons. - */ -#ifdef SO_REUSEADDR - - /* - * SO_REUSEADDR only applied to AF_INET && AF_INET6 - */ - - if (Sockettrans2devtab[i].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[i].family == AF_INET6 -#endif - ) - { - int one = 1; - setsockopt (ciptr->fd, SOL_SOCKET, SO_REUSEADDR, - (char *) &one, sizeof (int)); - } -#endif -#ifdef IPV6_V6ONLY - if (Sockettrans2devtab[i].family == AF_INET6) - { - int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); - } -#endif - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_CLIENT - -static XtransConnInfo -TRANS(SocketOpenCLTSClient) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCLTSClient(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCLTSClient: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCLTSClient: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_CLIENT */ - - -#ifdef TRANS_SERVER - -static XtransConnInfo -TRANS(SocketOpenCLTSServer) (Xtransport *thistrans, char *protocol, - char *host, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2,"SocketOpenCLTSServer(%s,%s,%s)\n", protocol, host, port); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketOpen) ( - i, Sockettrans2devtab[i].devcotsname)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketOpenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketOpenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - -#ifdef IPV6_V6ONLY - if (Sockettrans2devtab[i].family == AF_INET6) - { - int one = 1; - setsockopt(ciptr->fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(int)); - } -#endif - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_REOPEN - -static XtransConnInfo -TRANS(SocketReopenCOTSServer) (Xtransport *thistrans, int fd, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2, - "SocketReopenCOTSServer(%d, %s)\n", fd, port, 0); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketReopen) ( - i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketReopenCOTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketReopenCOTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -static XtransConnInfo -TRANS(SocketReopenCLTSServer) (Xtransport *thistrans, int fd, char *port) - -{ - XtransConnInfo ciptr; - int i = -1; - - PRMSG (2, - "SocketReopenCLTSServer(%d, %s)\n", fd, port, 0); - - SocketInitOnce(); - - while ((i = TRANS(SocketSelectFamily) (i, thistrans->TransName)) >= 0) { - if ((ciptr = TRANS(SocketReopen) ( - i, Sockettrans2devtab[i].devcotsname, fd, port)) != NULL) - break; - } - if (i < 0) { - if (i == -1) - PRMSG (1,"SocketReopenCLTSServer: Unable to open socket for %s\n", - thistrans->TransName, 0, 0); - else - PRMSG (1,"SocketReopenCLTSServer: Unable to determine socket type for %s\n", - thistrans->TransName, 0, 0); - return NULL; - } - - /* Save the index for later use */ - - ciptr->index = i; - - return ciptr; -} - -#endif /* TRANS_REOPEN */ - - -static int -TRANS(SocketSetOption) (XtransConnInfo ciptr, int option, int arg) - -{ - PRMSG (2,"SocketSetOption(%d,%d,%d)\n", ciptr->fd, option, arg); - - return -1; -} - -#ifdef UNIXCONN -static int -set_sun_path(const char *port, const char *upath, char *path) -{ - struct sockaddr_un s; - int maxlen = sizeof(s.sun_path) - 1; - - if (!port || !*port || !path) - return -1; - - if (*port == '/') { /* a full pathname */ - if (strlen(port) > maxlen) - return -1; - sprintf(path, "%s", port); - } else { - if (strlen(port) + strlen(upath) > maxlen) - return -1; - sprintf(path, "%s%s", upath, port); - } - return 0; -} -#endif - -#ifdef TRANS_SERVER - -static int -TRANS(SocketCreateListener) (XtransConnInfo ciptr, - struct sockaddr *sockname, - int socknamelen, unsigned int flags) - -{ - int namelen = socknamelen; - int fd = ciptr->fd; - int retry; - - PRMSG (3, "SocketCreateListener(%x,%p)\n", ciptr, fd, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[ciptr->index].family == AF_INET6 -#endif - ) - retry = 20; - else - retry = 0; - - while (bind (fd, (struct sockaddr *) sockname, namelen) < 0) - { - if (errno == EADDRINUSE) { - if (flags & ADDR_IN_USE_ALLOWED) - break; - else - return TRANS_ADDR_IN_USE; - } - - if (retry-- == 0) { - PRMSG (1, "SocketCreateListener: failed to bind listener\n", - 0, 0, 0); - close (fd); - return TRANS_CREATE_LISTENER_FAILED; - } -#ifdef SO_REUSEADDR - sleep (1); -#else - sleep (10); -#endif /* SO_REUSEDADDR */ - } - - if (Sockettrans2devtab[ciptr->index].family == AF_INET -#if defined(IPv6) && defined(AF_INET6) - || Sockettrans2devtab[ciptr->index].family == AF_INET6 -#endif - ) { -#ifdef SO_DONTLINGER - setsockopt (fd, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); -#else -#ifdef SO_LINGER - { - static int linger[2] = { 0, 0 }; - setsockopt (fd, SOL_SOCKET, SO_LINGER, - (char *) linger, sizeof (linger)); - } -#endif -#endif -} - - if (listen (fd, BACKLOG) < 0) - { - PRMSG (1, "SocketCreateListener: listen() failed\n", 0, 0, 0); - close (fd); - return TRANS_CREATE_LISTENER_FAILED; - } - - /* Set a flag to indicate that this connection is a listener */ - - ciptr->flags = 1 | (ciptr->flags & TRANS_KEEPFLAGS); - - return 0; -} - -#ifdef TCPCONN -static int -TRANS(SocketINETCreateListener) (XtransConnInfo ciptr, char *port, unsigned int flags) - -{ -#if defined(IPv6) && defined(AF_INET6) - struct sockaddr_storage sockname; -#else - struct sockaddr_in sockname; -#endif - unsigned short sport; - int namelen = sizeof(sockname); - int status; - long tmpport; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgetservbynameparams sparams; -#endif - struct servent *servp; - -#ifdef X11_t - char portbuf[PORTBUFSIZE]; -#endif - - PRMSG (2, "SocketINETCreateListener(%s)\n", port, 0, 0); - -#ifdef X11_t - /* - * X has a well known port, that is transport dependent. It is easier - * to handle it here, than try and come up with a transport independent - * representation that can be passed in and resolved the usual way. - * - * The port that is passed here is really a string containing the idisplay - * from ConnectDisplay(). - */ - - if (is_numeric (port)) - { - /* fixup the server port address */ - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf,"%lu", tmpport); - port = portbuf; - } -#endif - - if (port && *port) - { - /* Check to see if the port string is just a number (handles X11) */ - - if (!is_numeric (port)) - { - if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) - { - PRMSG (1, - "SocketINETCreateListener: Unable to get service for %s\n", - port, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - /* we trust getservbyname to return a valid number */ - sport = servp->s_port; - } - else - { - tmpport = strtol (port, (char**)NULL, 10); - /* - * check that somehow the port address isn't negative or in - * the range of reserved port addresses. This can happen and - * be very bad if the server is suid-root and the user does - * something (dumb) like `X :60049`. - */ - if (tmpport < 1024 || tmpport > USHRT_MAX) - return TRANS_CREATE_LISTENER_FAILED; - - sport = (unsigned short) tmpport; - } - } - else - sport = 0; - - bzero(&sockname, sizeof(sockname)); -#if defined(IPv6) && defined(AF_INET6) - if (Sockettrans2devtab[ciptr->index].family == AF_INET) { - namelen = sizeof (struct sockaddr_in); -#ifdef BSD44SOCKETS - ((struct sockaddr_in *)&sockname)->sin_len = namelen; -#endif - ((struct sockaddr_in *)&sockname)->sin_family = AF_INET; - ((struct sockaddr_in *)&sockname)->sin_port = htons(sport); - ((struct sockaddr_in *)&sockname)->sin_addr.s_addr = htonl(INADDR_ANY); - } else { - namelen = sizeof (struct sockaddr_in6); -#ifdef SIN6_LEN - ((struct sockaddr_in6 *)&sockname)->sin6_len = sizeof(sockname); -#endif - ((struct sockaddr_in6 *)&sockname)->sin6_family = AF_INET6; - ((struct sockaddr_in6 *)&sockname)->sin6_port = htons(sport); - ((struct sockaddr_in6 *)&sockname)->sin6_addr = in6addr_any; - } -#else -#ifdef BSD44SOCKETS - sockname.sin_len = sizeof (sockname); -#endif - sockname.sin_family = AF_INET; - sockname.sin_port = htons (sport); - sockname.sin_addr.s_addr = htonl (INADDR_ANY); -#endif - - if ((status = TRANS(SocketCreateListener) (ciptr, - (struct sockaddr *) &sockname, namelen, flags)) < 0) - { - PRMSG (1, - "SocketINETCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); - return status; - } - - if (TRANS(SocketINETGetAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETCreateListener: ...SocketINETGetAddr() failed\n", - 0, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - - return 0; -} - -#endif /* SOCKCONN */ - - -#ifdef UNIXCONN - -static int -TRANS(SocketUNIXCreateListener) (XtransConnInfo ciptr, char *port, - unsigned int flags) - -{ - struct sockaddr_un sockname; - int namelen; - int oldUmask; - int status; - unsigned int mode; - - PRMSG (2, "SocketUNIXCreateListener(%s)\n", - port ? port : "NULL", 0, 0); - - /* Make sure the directory is created */ - - oldUmask = umask (0); - -#ifdef UNIX_DIR -#ifdef HAS_STICKY_DIR_BIT - mode = 01777; -#else - mode = 0777; -#endif - if (trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXCreateListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); - (void) umask (oldUmask); - return TRANS_CREATE_LISTENER_FAILED; - } -#endif - - sockname.sun_family = AF_UNIX; - - if (port && *port) { - if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) { - PRMSG (1, "SocketUNIXCreateListener: path too long\n", 0, 0, 0); - return TRANS_CREATE_LISTENER_FAILED; - } - } else { - sprintf (sockname.sun_path, "%s%ld", UNIX_PATH, (long)getpid()); - } - -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx) - sockname.sun_len = strlen(sockname.sun_path); - namelen = SUN_LEN(&sockname); -#else - namelen = strlen(sockname.sun_path) + sizeof(sockname.sun_family); -#endif - - unlink (sockname.sun_path); - - if ((status = TRANS(SocketCreateListener) (ciptr, - (struct sockaddr *) &sockname, namelen, flags)) < 0) - { - PRMSG (1, - "SocketUNIXCreateListener: ...SocketCreateListener() failed\n", - 0, 0, 0); - (void) umask (oldUmask); - return status; - } - - /* - * Now that the listener is esablished, create the addr info for - * this connection. getpeername() doesn't work for UNIX Domain Sockets - * on some systems (hpux at least), so we will just do it manually, instead - * of calling something like TRANS(SocketUNIXGetAddr). - */ - - namelen = sizeof (sockname); /* this will always make it the same size */ - - if ((ciptr->addr = (char *) xalloc (namelen)) == NULL) - { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); - (void) umask (oldUmask); - return TRANS_CREATE_LISTENER_FAILED; - } - - ciptr->family = sockname.sun_family; - ciptr->addrlen = namelen; - memcpy (ciptr->addr, &sockname, ciptr->addrlen); - - (void) umask (oldUmask); - - return 0; -} - - -static int -TRANS(SocketUNIXResetListener) (XtransConnInfo ciptr) - -{ - /* - * See if the unix domain socket has disappeared. If it has, recreate it. - */ - - struct sockaddr_un *unsock = (struct sockaddr_un *) ciptr->addr; - struct stat statb; - int status = TRANS_RESET_NOOP; - unsigned int mode; - - PRMSG (3, "SocketUNIXResetListener(%p,%d)\n", ciptr, ciptr->fd, 0); - - if (stat (unsock->sun_path, &statb) == -1 || - ((statb.st_mode & S_IFMT) != -#if (defined (sun) && defined(SVR4)) || defined(NCR) || defined(SCO325) || !defined(S_IFSOCK) - S_IFIFO)) -#else - S_IFSOCK)) -#endif - { - int oldUmask = umask (0); - -#ifdef UNIX_DIR -#ifdef HAS_STICKY_DIR_BIT - mode = 01777; -#else - mode = 0777; -#endif - if (trans_mkdir(UNIX_DIR, mode) == -1) { - PRMSG (1, "SocketUNIXResetListener: mkdir(%s) failed, errno = %d\n", - UNIX_DIR, errno, 0); - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } -#endif - - close (ciptr->fd); - unlink (unsock->sun_path); - - if ((ciptr->fd = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - { - TRANS(FreeConnInfo) (ciptr); - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } - - if (bind (ciptr->fd, (struct sockaddr *) unsock, ciptr->addrlen) < 0) - { - close (ciptr->fd); - TRANS(FreeConnInfo) (ciptr); - return TRANS_RESET_FAILURE; - } - - if (listen (ciptr->fd, BACKLOG) < 0) - { - close (ciptr->fd); - TRANS(FreeConnInfo) (ciptr); - (void) umask (oldUmask); - return TRANS_RESET_FAILURE; - } - - umask (oldUmask); - - status = TRANS_RESET_NEW_FD; - } - - return status; -} - -#endif /* UNIXCONN */ - - -#ifdef TCPCONN - -static XtransConnInfo -TRANS(SocketINETAccept) (XtransConnInfo ciptr, int *status) - -{ - XtransConnInfo newciptr; - struct sockaddr_in sockname; - int namelen = sizeof(sockname); - - PRMSG (2, "SocketINETAccept(%p,%d)\n", ciptr, ciptr->fd, 0); - - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketINETAccept: malloc failed\n", 0, 0, 0); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - if ((newciptr->fd = accept (ciptr->fd, - (struct sockaddr *) &sockname, (void *)&namelen)) < 0) - { -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - PRMSG (1, "SocketINETAccept: accept() failed\n", 0, 0, 0); - xfree (newciptr); - *status = TRANS_ACCEPT_FAILED; - return NULL; - } - -#ifdef TCP_NODELAY - { - /* - * turn off TCP coalescence for INET sockets - */ - - int tmp = 1; - setsockopt (newciptr->fd, IPPROTO_TCP, TCP_NODELAY, - (char *) &tmp, sizeof (int)); - } -#endif - - /* - * Get this address again because the transport may give a more - * specific address now that a connection is established. - */ - - if (TRANS(SocketINETGetAddr) (newciptr) < 0) - { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); - close (newciptr->fd); - xfree (newciptr); - *status = TRANS_ACCEPT_MISC_ERROR; - return NULL; - } - - if (TRANS(SocketINETGetPeerAddr) (newciptr) < 0) - { - PRMSG (1, - "SocketINETAccept: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); - close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); - *status = TRANS_ACCEPT_MISC_ERROR; - return NULL; - } - - *status = 0; - - return newciptr; -} - -#endif /* TCPCONN */ - - -#ifdef UNIXCONN -static XtransConnInfo -TRANS(SocketUNIXAccept) (XtransConnInfo ciptr, int *status) - -{ - XtransConnInfo newciptr; - struct sockaddr_un sockname; -#if defined(SVR4) || defined(__SCO__) - size_t namelen = sizeof sockname; -#else - int namelen = sizeof sockname; -#endif - - PRMSG (2, "SocketUNIXAccept(%p,%d)\n", ciptr, ciptr->fd, 0); - - if ((newciptr = (XtransConnInfo) xcalloc ( - 1, sizeof(struct _XtransConnInfo))) == NULL) - { - PRMSG (1, "SocketUNIXAccept: malloc() failed\n", 0, 0, 0); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - if ((newciptr->fd = accept (ciptr->fd, - (struct sockaddr *) &sockname, (void *)&namelen)) < 0) - { - PRMSG (1, "SocketUNIXAccept: accept() failed\n", 0, 0, 0); - xfree (newciptr); - *status = TRANS_ACCEPT_FAILED; - return NULL; - } - - /* - * Get the socket name and the peer name from the listener socket, - * since this is unix domain. - */ - - if ((newciptr->addr = (char *) xalloc (ciptr->addrlen)) == NULL) - { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); - close (newciptr->fd); - xfree (newciptr); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - - newciptr->addrlen = ciptr->addrlen; - memcpy (newciptr->addr, ciptr->addr, newciptr->addrlen); - - if ((newciptr->peeraddr = (char *) xalloc (ciptr->addrlen)) == NULL) - { - PRMSG (1, - "SocketUNIXAccept: Can't allocate space for the addr\n", - 0, 0, 0); - close (newciptr->fd); - if (newciptr->addr) xfree (newciptr->addr); - xfree (newciptr); - *status = TRANS_ACCEPT_BAD_MALLOC; - return NULL; - } - - newciptr->peeraddrlen = ciptr->addrlen; - memcpy (newciptr->peeraddr, ciptr->addr, newciptr->addrlen); - - newciptr->family = AF_UNIX; - - *status = 0; - - return newciptr; -} - -#endif /* UNIXCONN */ - -#endif /* TRANS_SERVER */ - - -#ifdef TRANS_CLIENT - -#ifdef TCPCONN - -#if defined(IPv6) && defined(AF_INET6) -struct addrlist { - struct addrinfo * addr; - struct addrinfo * firstaddr; - char port[PORTBUFSIZE]; - char host[MAXHOSTNAMELEN]; -}; -static struct addrlist *addrlist = NULL; -#endif - - -static int -TRANS(SocketINETConnect) (XtransConnInfo ciptr, char *host, char *port) - -{ - struct sockaddr * socketaddr = NULL; - int socketaddrlen = 0; - int res; -#if defined(IPv6) && defined(AF_INET6) - struct addrinfo hints; - char ntopbuf[INET6_ADDRSTRLEN]; - int resetonce = 0; -#endif - struct sockaddr_in sockname; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; - _Xgetservbynameparams sparams; -#endif - struct hostent *hostp; - struct servent *servp; - unsigned long tmpaddr; -#ifdef X11_t - char portbuf[PORTBUFSIZE]; -#endif - - long tmpport; - char hostnamebuf[256]; /* tmp space */ - - PRMSG (2,"SocketINETConnect(%d,%s,%s)\n", ciptr->fd, host, port); - - if (!host) - { - hostnamebuf[0] = '\0'; - (void) TRANS(GetHostname) (hostnamebuf, sizeof hostnamebuf); - host = hostnamebuf; - } - -#ifdef X11_t - /* - * X has a well known port, that is transport dependent. It is easier - * to handle it here, than try and come up with a transport independent - * representation that can be passed in and resolved the usual way. - * - * The port that is passed here is really a string containing the idisplay - * from ConnectDisplay(). - */ - - if (is_numeric (port)) - { - tmpport = X_TCP_PORT + strtol (port, (char**)NULL, 10); - sprintf (portbuf, "%lu", tmpport); - port = portbuf; - } -#endif - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6) { - if (addrlist != NULL) { - if (strcmp(host,addrlist->host) || strcmp(port,addrlist->port)) { - if (addrlist->firstaddr) - freeaddrinfo(addrlist->firstaddr); - addrlist->firstaddr = NULL; - } - } else { - addrlist = malloc(sizeof(struct addrlist)); - addrlist->firstaddr = NULL; - } - - if (addrlist->firstaddr == NULL) { - strncpy(addrlist->port, port, sizeof(addrlist->port)); - addrlist->port[sizeof(addrlist->port) - 1] = '\0'; - strncpy(addrlist->host, host, sizeof(addrlist->host)); - addrlist->host[sizeof(addrlist->host) - 1] = '\0'; - - bzero(&hints,sizeof(hints)); - hints.ai_socktype = Sockettrans2devtab[ciptr->index].devcotsname; - - res = getaddrinfo(host,port,&hints,&addrlist->firstaddr); - if (res != 0) { - PRMSG (1, "SocketINETConnect() can't get address " - "for %s:%s: %s\n", host, port, gai_strerror(res)); - ESET(EINVAL); - return TRANS_CONNECT_FAILED; - } - for (res = 0, addrlist->addr = addrlist->firstaddr; - addrlist->addr ; res++) { - addrlist->addr = addrlist->addr->ai_next; - } - PRMSG(4,"Got New Address list with %d addresses\n", res, 0, 0); - res = 0; - addrlist->addr = NULL; - } - - while (socketaddr == NULL) { - if (addrlist->addr == NULL) { - if (resetonce) { - /* Already checked entire list - no usable addresses */ - PRMSG (1, "SocketINETConnect() no usable address " - "for %s:%s\n", host, port, 0); - return TRANS_CONNECT_FAILED; - } else { - /* Go back to beginning of list */ - resetonce = 1; - addrlist->addr = addrlist->firstaddr; - } - } - - socketaddr = addrlist->addr->ai_addr; - socketaddrlen = addrlist->addr->ai_addrlen; - - if (addrlist->addr->ai_family == AF_INET) { - struct sockaddr_in *sin = (struct sockaddr_in *) socketaddr; - - PRMSG (4,"SocketINETConnect() sockname.sin_addr = %s\n", - inet_ntop(addrlist->addr->ai_family,&sin->sin_addr, - ntopbuf,sizeof(ntopbuf)), 0, 0); - - PRMSG (4,"SocketINETConnect() sockname.sin_port = %d\n", - ntohs(sin->sin_port), 0, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET6) { - if (strcmp(Sockettrans2devtab[ciptr->index].transname, - "tcp") == 0) { - XtransConnInfo newciptr; - - /* - * Our socket is an IPv6 socket, but the address is - * IPv4. Close it and get an IPv4 socket. This is - * needed for IPv4 connections to work on platforms - * that don't allow IPv4 over IPv6 sockets. - */ - TRANS(SocketINETClose)(ciptr); - newciptr = TRANS(SocketOpenCOTSClientBase)( - "tcp", "tcp", host, port, ciptr->index); - if (newciptr) - ciptr->fd = newciptr->fd; - if (!newciptr || - Sockettrans2devtab[newciptr->index].family != - AF_INET) { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv4 " - " socketfor IPv4 address\n", 0,0,0); - } - if (newciptr) - xfree(newciptr); - } else { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect Skipping IPv4 address\n", - 0,0,0); - } - } - } else if (addrlist->addr->ai_family == AF_INET6) { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) socketaddr; - - PRMSG (4,"SocketINETConnect() sockname.sin6_addr = %s\n", - inet_ntop(addrlist->addr->ai_family, - &sin6->sin6_addr,ntopbuf,sizeof(ntopbuf)), - 0, 0); - PRMSG (4,"SocketINETConnect() sockname.sin6_port = %d\n", - ntohs(sin6->sin6_port), 0, 0); - - if (Sockettrans2devtab[ciptr->index].family == AF_INET) { - if (strcmp(Sockettrans2devtab[ciptr->index].transname, - "tcp") == 0) { - XtransConnInfo newciptr; - - /* - * Close the IPv4 socket and try to open an IPv6 socket. - */ - TRANS(SocketINETClose)(ciptr); - newciptr = TRANS(SocketOpenCOTSClientBase)( - "tcp", "tcp", host, port, -1); - if (newciptr) - ciptr->fd = newciptr->fd; - if (!newciptr || - Sockettrans2devtab[newciptr->index].family != - AF_INET6) { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Cannot get IPv6 " - "socket for IPv6 address\n", 0,0,0); - } - if (newciptr) - xfree(newciptr); - } - else - { - socketaddr = NULL; - PRMSG (4,"SocketINETConnect() Skipping IPv6 address\n", - 0,0,0); - } - } - } else { - socketaddr = NULL; /* Unsupported address type */ - } - if (socketaddr == NULL) { - addrlist->addr = addrlist->addr->ai_next; - } - } - } else -#endif - { - /* - * Build the socket name. - */ - -#ifdef BSD44SOCKETS - sockname.sin_len = sizeof (struct sockaddr_in); -#endif - sockname.sin_family = AF_INET; - - /* - * fill in sin_addr - */ - -#ifndef INADDR_NONE -#define INADDR_NONE ((in_addr_t) 0xffffffff) -#endif - - /* check for ww.xx.yy.zz host string */ - - if (isascii (host[0]) && isdigit (host[0])) { - tmpaddr = inet_addr (host); /* returns network byte order */ - } else { - tmpaddr = INADDR_NONE; - } - - PRMSG (4,"SocketINETConnect() inet_addr(%s) = %x\n", host, tmpaddr, 0); - - if (tmpaddr == INADDR_NONE) { - if ((hostp = _XGethostbyname(host,hparams)) == NULL) { - PRMSG (1,"SocketINETConnect: Can't get address for %s\n", - host, 0, 0); - ESET(EINVAL); - return TRANS_CONNECT_FAILED; - } - if (hostp->h_addrtype != AF_INET) { /* is IP host? */ - PRMSG (1,"SocketINETConnect: not INET host%s\n", host, 0, 0); - ESET(EPROTOTYPE); - return TRANS_CONNECT_FAILED; - } - -#if defined(CRAY) && defined(OLDTCP) - /* Only Cray UNICOS3 and UNICOS4 will define this */ - { - long t; - memcpy ((char *)&t, (char *) hostp->h_addr, sizeof (t)); - sockname.sin_addr = t; - } -#else - memcpy ((char *) &sockname.sin_addr, (char *) hostp->h_addr, - sizeof (sockname.sin_addr)); -#endif /* CRAY and OLDTCP */ - - } else { -#if defined(CRAY) && defined(OLDTCP) - /* Only Cray UNICOS3 and UNICOS4 will define this */ - sockname.sin_addr = tmpaddr; -#else - sockname.sin_addr.s_addr = tmpaddr; -#endif /* CRAY and OLDTCP */ - } - - /* - * fill in sin_port - */ - - /* Check for number in the port string */ - - if (!is_numeric (port)) { - if ((servp = _XGetservbyname (port,"tcp",sparams)) == NULL) { - PRMSG (1,"SocketINETConnect: can't get service for %s\n", - port, 0, 0); - return TRANS_CONNECT_FAILED; - } - sockname.sin_port = htons (servp->s_port); - } else { - tmpport = strtol (port, (char**)NULL, 10); - if (tmpport < 1024 || tmpport > USHRT_MAX) - return TRANS_CONNECT_FAILED; - sockname.sin_port = htons (((unsigned short) tmpport)); - } - - PRMSG (4,"SocketINETConnect: sockname.sin_port = %d\n", - ntohs(sockname.sin_port), 0, 0); - socketaddr = (struct sockaddr *) &sockname; - socketaddrlen = sizeof(sockname); - } - - /* - * Turn on socket keepalive so the client process will eventually - * be notified with a SIGPIPE signal if the display server fails - * to respond to a periodic transmission of messages - * on the connected socket. - * This is useful to avoid hung application processes when the - * processes are not spawned from the xdm session and - * the display server terminates abnormally. - * (Someone turned off the power switch.) - */ - - { - int tmp = 1; - setsockopt (ciptr->fd, SOL_SOCKET, SO_KEEPALIVE, - (char *) &tmp, sizeof (int)); - } - - /* - * Do the connect() - */ - - if (connect (ciptr->fd, socketaddr, socketaddrlen ) < 0) - { -#ifdef WIN32 - int olderrno = WSAGetLastError(); -#else - int olderrno = errno; -#endif - - /* - * If the error was ECONNREFUSED, the server may be overloaded - * and we should try again. - * - * If the error was EWOULDBLOCK or EINPROGRESS then the socket - * was non-blocking and we should poll using select - * - * If the error was EINTR, the connect was interrupted and we - * should try again. - * - * If multiple addresses are found for a host then we should - * try to connect again with a different address for a larger - * number of errors that made us quit before, since those - * could be caused by trying to use an IPv6 address to contact - * a machine with an IPv4-only server or other reasons that - * only affect one of a set of addresses. - */ - - if (olderrno == ECONNREFUSED || olderrno == EINTR -#if defined(IPv6) && defined(AF_INET6) - || (haveIPv6 && ((addrlist->addr->ai_next != NULL) || - (addrlist->addr != addrlist->firstaddr)) && - (olderrno == ENETUNREACH || olderrno == EAFNOSUPPORT || - olderrno == EADDRNOTAVAIL || olderrno == ETIMEDOUT -#if defined(EHOSTDOWN) - || olderrno == EHOSTDOWN -#endif - )) -#endif - ) - res = TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS) - res = TRANS_IN_PROGRESS; - else - { - PRMSG (2,"SocketINETConnect: Can't connect: errno = %d\n", - olderrno,0, 0); - - res = TRANS_CONNECT_FAILED; - } - } else { - res = 0; - - - /* - * Sync up the address fields of ciptr. - */ - - if (TRANS(SocketINETGetAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetAddr() failed:\n", - 0, 0, 0); - res = TRANS_CONNECT_FAILED; - } - - else if (TRANS(SocketINETGetPeerAddr) (ciptr) < 0) - { - PRMSG (1, - "SocketINETConnect: ...SocketINETGetPeerAddr() failed:\n", - 0, 0, 0); - res = TRANS_CONNECT_FAILED; - } - } - -#if defined(IPv6) && defined(AF_INET6) - if (haveIPv6 && res != 0) { - addrlist->addr = addrlist->addr->ai_next; - } -#endif - - return res; -} - -#endif /* TCPCONN */ - - - -#ifdef UNIXCONN - -/* - * Make sure 'host' is really local. - */ - -static int -UnixHostReallyLocal (char *host) - -{ - char hostnamebuf[256]; - -#if defined(IPv6) && defined(AF_INET6) - if (getaddrinfo == NULL) - haveIPv6 = 0; -#endif - - TRANS(GetHostname) (hostnamebuf, sizeof (hostnamebuf)); - - if (strcmp (hostnamebuf, host) == 0) - { - return (1); - } -#if defined(IPv6) && defined(AF_INET6) - else if (haveIPv6) - { - struct addrinfo *localhostaddr; - struct addrinfo *otherhostaddr; - struct addrinfo *i, *j; - int equiv = 0; - - if (getaddrinfo(hostnamebuf, NULL, NULL, &localhostaddr) != 0) - return 0; - if (getaddrinfo(host, NULL, NULL, &otherhostaddr) != 0) { - freeaddrinfo(localhostaddr); - return 0; - } - - for (i = localhostaddr; i != NULL && equiv == 0; i = i->ai_next) { - for (j = otherhostaddr; j != NULL && equiv == 0; j = j->ai_next) { - if (i->ai_family == j->ai_family) { - if (i->ai_family == AF_INET) { - struct sockaddr_in *sinA - = (struct sockaddr_in *) i->ai_addr; - struct sockaddr_in *sinB - = (struct sockaddr_in *) j->ai_addr; - struct in_addr *A = &sinA->sin_addr; - struct in_addr *B = &sinB->sin_addr; - - if (memcmp(A,B,sizeof(struct in_addr)) == 0) { - equiv = 1; - } - } else if (i->ai_family == AF_INET6) { - struct sockaddr_in6 *sinA - = (struct sockaddr_in6 *) i->ai_addr; - struct sockaddr_in6 *sinB - = (struct sockaddr_in6 *) j->ai_addr; - struct in6_addr *A = &sinA->sin6_addr; - struct in6_addr *B = &sinB->sin6_addr; - - if (memcmp(A,B,sizeof(struct in6_addr)) == 0) { - equiv = 1; - } - } - } - } - } - - freeaddrinfo(localhostaddr); - freeaddrinfo(otherhostaddr); - return equiv; - } -#endif - else - { - /* - * A host may have more than one network address. If any of the - * network addresses of 'host' (specified to the connect call) - * match any of the network addresses of 'hostname' (determined - * by TRANS(GetHostname)), then the two hostnames are equivalent, - * and we know that 'host' is really a local host. - */ - char specified_local_addr_list[10][4]; - int scount, equiv, i, j; -#ifdef XTHREADS_NEEDS_BYNAMEPARAMS - _Xgethostbynameparams hparams; -#endif - struct hostent *hostp; - - if ((hostp = _XGethostbyname (host,hparams)) == NULL) - return (0); - - scount = 0; - while (hostp->h_addr_list[scount] && scount <= 8) - { - /* - * The 2nd call to gethostname() overrides the data - * from the 1st call, so we must save the address list. - */ - - specified_local_addr_list[scount][0] = - hostp->h_addr_list[scount][0]; - specified_local_addr_list[scount][1] = - hostp->h_addr_list[scount][1]; - specified_local_addr_list[scount][2] = - hostp->h_addr_list[scount][2]; - specified_local_addr_list[scount][3] = - hostp->h_addr_list[scount][3]; - scount++; - } - if ((hostp = _XGethostbyname (hostnamebuf,hparams)) == NULL) - return (0); - - equiv = 0; - i = 0; - - while (i < scount && !equiv) - { - j = 0; - - while (hostp->h_addr_list[j]) - { - if ((specified_local_addr_list[i][0] == - hostp->h_addr_list[j][0]) && - (specified_local_addr_list[i][1] == - hostp->h_addr_list[j][1]) && - (specified_local_addr_list[i][2] == - hostp->h_addr_list[j][2]) && - (specified_local_addr_list[i][3] == - hostp->h_addr_list[j][3])) - { - /* They're equal, so we're done */ - - equiv = 1; - break; - } - - j++; - } - - i++; - } - return (equiv); - } -} - -static int -TRANS(SocketUNIXConnect) (XtransConnInfo ciptr, char *host, char *port) - -{ - struct sockaddr_un sockname; - int namelen; - -#if defined(hpux) && defined(X11_t) - struct sockaddr_un old_sockname; - int old_namelen; -#endif - - - PRMSG (2,"SocketUNIXConnect(%d,%s,%s)\n", ciptr->fd, host, port); - - /* - * Make sure 'host' is really local. If not, we return failure. - * The reason we make this check is because a process may advertise - * a "local" network ID for which it can accept connections, but if - * a process on a remote machine tries to connect to this network ID, - * we know for sure it will fail. - */ - - if (strcmp (host, "unix") != 0 && !UnixHostReallyLocal (host)) - { - PRMSG (1, - "SocketUNIXConnect: Cannot connect to non-local host %s\n", - host, 0, 0); - return TRANS_CONNECT_FAILED; - } - - - /* - * Check the port. - */ - - if (!port || !*port) - { - PRMSG (1,"SocketUNIXConnect: Missing port specification\n", - 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - - /* - * Build the socket name. - */ - - sockname.sun_family = AF_UNIX; - - if (set_sun_path(port, UNIX_PATH, sockname.sun_path) != 0) { - PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - -#if (defined(BSD44SOCKETS) || defined(__UNIXWARE__)) && !defined(Lynx) - sockname.sun_len = strlen (sockname.sun_path); - namelen = SUN_LEN (&sockname); -#else - namelen = strlen (sockname.sun_path) + sizeof (sockname.sun_family); -#endif - - -#if defined(hpux) && defined(X11_t) - /* - * This is gross, but it was in Xlib - */ - old_sockname.sun_family = AF_UNIX; - if (set_sun_path(port, OLD_UNIX_PATH, old_sockname.sun_path) != 0) { - PRMSG (1, "SocketUNIXConnect: path too long\n", 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - old_namelen = strlen (old_sockname.sun_path) + - sizeof (old_sockname.sun_family); -#endif - - - /* - * Do the connect() - */ - - if (connect (ciptr->fd, (struct sockaddr *) &sockname, namelen) < 0) - { - int olderrno = errno; - int connected = 0; - -#if defined(hpux) && defined(X11_t) - if (olderrno == ENOENT) - { - if (connect (ciptr->fd, - (struct sockaddr *) &old_sockname, old_namelen) >= 0) - { - connected = 1; - } - else - olderrno = errno; - } -#endif - if (!connected) - { - errno = olderrno; - - /* - * If the error was ENOENT, the server may be starting up - * and we should try again. - * - * If the error was EWOULDBLOCK or EINPROGRESS then the socket - * was non-blocking and we should poll using select - * - * If the error was EINTR, the connect was interrupted and we - * should try again. - */ - - if (olderrno == ENOENT || olderrno == EINTR) - return TRANS_TRY_CONNECT_AGAIN; - else if (olderrno == EWOULDBLOCK || olderrno == EINPROGRESS) - return TRANS_IN_PROGRESS; - else - { - PRMSG (2,"SocketUNIXConnect: Can't connect: errno = %d\n", - EGET(),0, 0); - - return TRANS_CONNECT_FAILED; - } - } - } - - /* - * Get the socket name and the peer name from the connect socket, - * since this is unix domain. - */ - - if ((ciptr->addr = (char *) xalloc(namelen)) == NULL || - (ciptr->peeraddr = (char *) xalloc(namelen)) == NULL) - { - PRMSG (1, - "SocketUNIXCreateListener: Can't allocate space for the addr\n", - 0, 0, 0); - return TRANS_CONNECT_FAILED; - } - - ciptr->family = AF_UNIX; - ciptr->addrlen = namelen; - ciptr->peeraddrlen = namelen; - memcpy (ciptr->addr, &sockname, ciptr->addrlen); - memcpy (ciptr->peeraddr, &sockname, ciptr->peeraddrlen); - - return 0; -} - -#endif /* UNIXCONN */ - -#endif /* TRANS_CLIENT */ - - -static int -TRANS(SocketBytesReadable) (XtransConnInfo ciptr, BytesReadable_t *pend) - -{ - PRMSG (2,"SocketBytesReadable(%p,%d,%p)\n", - ciptr, ciptr->fd, pend); -#if defined(QNX4) - *pend = 0L; /* FIONREAD only returns a short. Zero out upper bits */ -#endif -#ifdef WIN32 - { - int ret = ioctlsocket ((SOCKET) ciptr->fd, FIONREAD, (u_long *) pend); - errno = WSAGetLastError(); - return ret; - } -#else -#if (defined(i386) && defined(SYSV) && !defined(SCO325)) || (defined(_SEQUENT_) && _SOCKET_VERSION == 1) - return ioctl (ciptr->fd, I_NREAD, (char *) pend); -#else -#if defined(__UNIXOS2__) - return ioctl (ciptr->fd, FIONREAD, (char*) pend, sizeof(int)); -#else - return ioctl (ciptr->fd, FIONREAD, (char *) pend); -#endif /* __UNIXOS2__ */ -#endif /* i386 && SYSV || _SEQUENT_ && _SOCKET_VERSION == 1 */ -#endif /* WIN32 */ -} - - -static int -TRANS(SocketRead) (XtransConnInfo ciptr, char *buf, int size) - -{ - PRMSG (2,"SocketRead(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(WIN32) || defined(__UNIXOS2__) - { - int ret = recv ((SOCKET)ciptr->fd, buf, size, 0); -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - return ret; - } -#else - return read (ciptr->fd, buf, size); -#endif /* WIN32 */ -} - - -static int -TRANS(SocketWrite) (XtransConnInfo ciptr, char *buf, int size) - -{ - PRMSG (2,"SocketWrite(%d,%p,%d)\n", ciptr->fd, buf, size); - -#if defined(WIN32) || defined(__UNIXOS2__) - { - int ret = send ((SOCKET)ciptr->fd, buf, size, 0); -#ifdef WIN32 - errno = WSAGetLastError(); -#endif - return ret; - } -#else - return write (ciptr->fd, buf, size); -#endif /* WIN32 */ -} - - -static int -TRANS(SocketReadv) (XtransConnInfo ciptr, struct iovec *buf, int size) - -{ - PRMSG (2,"SocketReadv(%d,%p,%d)\n", ciptr->fd, buf, size); - - return READV (ciptr, buf, size); -} - - -static int -TRANS(SocketWritev) (XtransConnInfo ciptr, struct iovec *buf, int size) - -{ - PRMSG (2,"SocketWritev(%d,%p,%d)\n", ciptr->fd, buf, size); - - return WRITEV (ciptr, buf, size); -} - - -static int -TRANS(SocketDisconnect) (XtransConnInfo ciptr) - -{ - PRMSG (2,"SocketDisconnect(%p,%d)\n", ciptr, ciptr->fd, 0); - -#ifdef WIN32 - { - int ret = shutdown (ciptr->fd, 2); - errno = WSAGetLastError(); - return ret; - } -#else - return shutdown (ciptr->fd, 2); /* disallow further sends and receives */ -#endif -} - - -#ifdef TCPCONN -static int -TRANS(SocketINETClose) (XtransConnInfo ciptr) - -{ - PRMSG (2,"SocketINETClose(%p,%d)\n", ciptr, ciptr->fd, 0); - -#ifdef WIN32 - { - int ret = close (ciptr->fd); - errno = WSAGetLastError(); - return ret; - } -#else - return close (ciptr->fd); -#endif -} - -#endif /* TCPCONN */ - - -#ifdef UNIXCONN -static int -TRANS(SocketUNIXClose) (XtransConnInfo ciptr) - -{ - /* - * If this is the server side, then once the socket is closed, - * it must be unlinked to completely close it - */ - - struct sockaddr_un *sockname = (struct sockaddr_un *) ciptr->addr; - int ret; - - PRMSG (2,"SocketUNIXClose(%p,%d)\n", ciptr, ciptr->fd, 0); - - ret = close(ciptr->fd); - - if (ciptr->flags - && sockname - && sockname->sun_family == AF_UNIX - && sockname->sun_path[0]) - { - if (!(ciptr->flags & TRANS_NOUNLINK)) - unlink (sockname->sun_path); - } - - return ret; -} - -static int -TRANS(SocketUNIXCloseForCloning) (XtransConnInfo ciptr) - -{ - /* - * Don't unlink path. - */ - - int ret; - - PRMSG (2,"SocketUNIXCloseForCloning(%p,%d)\n", - ciptr, ciptr->fd, 0); - - ret = close(ciptr->fd); - - return ret; -} - -#endif /* UNIXCONN */ - - -#ifdef TCPCONN -# ifdef TRANS_SERVER -static char* tcp_nolisten[] = { - "inet", -#if defined(IPv6) && defined(AF_INET6) - "inet6", -#endif - NULL -}; -# endif - -Xtransport TRANS(SocketTCPFuncs) = { - /* Socket Interface */ - "tcp", - TRANS_ALIAS, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - tcp_nolisten, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; - -Xtransport TRANS(SocketINETFuncs) = { - /* Socket Interface */ - "inet", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; - -#if defined(IPv6) && defined(AF_INET6) -Xtransport TRANS(SocketINET6Funcs) = { - /* Socket Interface */ - "inet6", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketINETCreateListener), - NULL, /* ResetListener */ - TRANS(SocketINETAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketINETConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketINETClose), - TRANS(SocketINETClose), - }; -#endif /* IPv6 */ -#endif /* TCPCONN */ - -#ifdef UNIXCONN -#if !defined(LOCALCONN) -Xtransport TRANS(SocketLocalFuncs) = { - /* Socket Interface */ - "local", - 0, -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - NULL, - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketUNIXCreateListener), - TRANS(SocketUNIXResetListener), - TRANS(SocketUNIXAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketUNIXConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketUNIXClose), - TRANS(SocketUNIXCloseForCloning), - }; -#endif /* !LOCALCONN */ -# ifdef TRANS_SERVER -# if !defined(LOCALCONN) -static char* unix_nolisten[] = { "local" , NULL }; -# endif -# endif - -Xtransport TRANS(SocketUNIXFuncs) = { - /* Socket Interface */ - "unix", -#if !defined(LOCALCONN) - TRANS_ALIAS, -#else - 0, -#endif -#ifdef TRANS_CLIENT - TRANS(SocketOpenCOTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER -#if !defined(LOCALCONN) - unix_nolisten, -#else - NULL, -#endif - TRANS(SocketOpenCOTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketOpenCLTSClient), -#endif /* TRANS_CLIENT */ -#ifdef TRANS_SERVER - TRANS(SocketOpenCLTSServer), -#endif /* TRANS_SERVER */ -#ifdef TRANS_REOPEN - TRANS(SocketReopenCOTSServer), - TRANS(SocketReopenCLTSServer), -#endif - TRANS(SocketSetOption), -#ifdef TRANS_SERVER - TRANS(SocketUNIXCreateListener), - TRANS(SocketUNIXResetListener), - TRANS(SocketUNIXAccept), -#endif /* TRANS_SERVER */ -#ifdef TRANS_CLIENT - TRANS(SocketUNIXConnect), -#endif /* TRANS_CLIENT */ - TRANS(SocketBytesReadable), - TRANS(SocketRead), - TRANS(SocketWrite), - TRANS(SocketReadv), - TRANS(SocketWritev), - TRANS(SocketDisconnect), - TRANS(SocketUNIXClose), - TRANS(SocketUNIXCloseForCloning), - }; - -#endif /* UNIXCONN */ |