1450N/A * (c) Copyright 1993-1994 Adobe Systems Incorporated. 1450N/A * Permission to use, copy, modify, distribute, and sublicense this software 1450N/A * and its documentation for any purpose and without fee is hereby granted, 1450N/A * provided that the above copyright notices appear in all copies and that 1450N/A * both those copyright notices and this permission notice appear in 1450N/A * supporting documentation and that the name of Adobe Systems Incorporated 1450N/A * not be used in advertising or publicity pertaining to distribution of the 1450N/A * software without specific, written prior permission. No trademark license 1450N/A * to use the Adobe trademarks is hereby granted. If the Adobe trademark 1450N/A * "Display PostScript"(tm) is used to describe this software, its 1450N/A * functionality or for any other purpose, such use shall be limited to a 1450N/A * statement that this software works in conjunction with the Display 1450N/A * PostScript system. Proper trademark attribution to reflect Adobe's 1450N/A * ownership of the trademark shall be given whenever any such reference to 1450N/A * the Display PostScript system is made. 1450N/A * ADOBE MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THE SOFTWARE FOR 1450N/A * ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 1450N/A * ADOBE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL 1450N/A * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1450N/A * NON- INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ADOBE BE LIABLE 1450N/A * TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL, INDIRECT, OR CONSEQUENTIAL 1450N/A * DAMAGES OR ANY DAMAGES WHATSOEVER WHETHER IN AN ACTION OF CONTRACT, 1450N/A * NEGLIGENCE, STRICT LIABILITY OR ANY OTHER ACTION ARISING OUT OF OR IN 1450N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ADOBE WILL NOT 1450N/A * PROVIDE ANY TRAINING OR OTHER SUPPORT FOR THE SOFTWARE. 1450N/A * Adobe, PostScript, and Display PostScript are trademarks of Adobe Systems 1450N/A * Incorporated which may be registered in certain jurisdictions 1450N/A * Portions Copyright 1985, 1986, 1987 Massachusetts Institute of Technology 1450N/A * Permission to use, copy, modify, distribute, and sell this software and its 1450N/A * documentation for any purpose is hereby granted without fee, provided that 1450N/A * the above copyright notice appear in all copies and that both that 1450N/A * copyright notice and this permission notice appear in supporting 1450N/A * documentation, and that the name of M.I.T. not be used in advertising or 1450N/A * publicity pertaining to distribution of the software without specific, 1450N/A * written prior permission. M.I.T. makes no representations about the 1450N/A * suitability of this software for any purpose. It is provided "as is" 1450N/A * without express or implied warranty. 1450N/A * Author: Adobe Systems Incorporated and MIT X Consortium 1450N/A * interface library (Xlib) to the X Window System Protocol V11.0. 1450N/A/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX 1450N/A * systems are broken and return EWOULDBLOCK when they should return EAGAIN 1450N/A * The following routines are internal routines used by Xlib for protocol 1450N/A * packet transmission and reception. 1450N/A * XIOError(Display *) will be called if any sort of system call error occurs. 1450N/A * This is assumed to be a fatal condition, i.e., XIOError should not return. 1450N/A * XError(Display *, XErrorEvent *) will be called whenever an X_Error event is 1450N/A * received. This is not assumed to be a fatal condition, i.e., it is 1450N/A * acceptable for this procedure to return. However, XError should NOT 1450N/A * perform any operations (directly or indirectly) on the DISPLAY. 1450N/A * Routines declared with a return type of 'Status' return 0 on failure, 1450N/A * and non 0 on success. Routines with no declared return type don't 1450N/A * return anything. Whenever possible routines that create objects return 1450N/A * the object they have created. 1450N/A /* lookup table for adding padding bytes to data that is read from 1450N/A or written to the X socket. */ 1450N/A * N_XFlush - Flush the X request buffer. If the buffer is empty, no 1450N/A * action is taken. This routine correctly handles incremental writes. 1450N/A * This routine may have to be reworked if int < long. 1450N/A * While write has not written the entire buffer, keep looping 1450N/A * until the entire buffer is written. bufindex will be incremented 1450N/A * and size decremented as buffer is written out. 1450N/A /* errno set by write system call. */ 1450N/A /* This is a crock, required because FIONREAD or equivalent is 1450N/A * not guaranteed to detect a broken connection. 1450N/A /* we should not get zero, if we do, force a read */ 1450N/A#
endif /* XCONN_CHECK_FREQ */ 1450N/A /* Force a read if there is not enough data. Otherwise, 1450N/A * a select() loop at a higher-level will spin undesirably, 1450N/A * and we've seen at least one OS that appears to not update 1450N/A * the result from FIONREAD once it has returned nonzero. 1450N/A /* no space between comma and type or else macro will die */ 1450N/A else /* must be an event packet */ 1450N/A/* _XReadEvents - Flush the output queue, 1450N/A * then read as many events as possible (but at least 1) and enqueue them 1450N/A /* find out how much data can be read */ 1450N/A /* must read at least one xEvent; if none is pending, then 1450N/A we'll just flush and block waiting for it */ 1450N/A /* don't flush until we block the first time */ 1450N/A /* but we won't read more than the max buffer size */ 1450N/A /* round down to an integral number of XReps */ 1450N/A /* no space between comma and type or else macro will die */ 1450N/A else /* it's an event packet; enqueue it */ 1450N/A * N_XRead - Read bytes from the socket taking into account incomplete 1450N/A * reads. This routine may have to be reworked if int < long. 1450N/A /* Read failed because of end of file! */ 1450N/A else /* bytes_read is less than 0; presumably -1 */ {
1450N/A /* If it's a system call interrupt, it's not an error. */ 1450N/A * XXX This is a *really* stupid way of doing this.... 1450N/A * PACKBUFFERSIZE must be a multiple of 4. 1450N/A * _XRead32 - Read bytes from the socket unpacking each 32 bits 1450N/A * into a long (64 bits on a CRAY computer). 1450N/A * _XRead16 - Read bytes from the socket unpacking each 16 bits 1450N/A * into a long (64 bits on a CRAY computer). 1450N/A * N_XReadPad - Read bytes from the socket taking into account incomplete 1450N/A * reads. If the number of bytes is not 0 mod 32, read additional pad 1450N/A * bytes. This routine may have to be reworked if int < long. 1450N/A * The following hack is used to provide 32 bit long-word 1450N/A * aligned padding. The [1] vector is of length 0, 1, 2, or 3, 1450N/A /* Read failed because of end of file! */ 1450N/A else /* bytes_read is less than 0; presumably -1 */ {
1450N/A /* If it's a system call interrupt, it's not an error. */ 1450N/A * N_XSend - Flush the buffer and send the client data. 32 bit word aligned 1450N/A * transmission is used, if size is not 0 mod 4, extra bytes are transmitted. 1450N/A * This routine may have to be reworked if int < long; 1450N/A /* XText8 and XText16 require that the padding bytes be zero! */ 1450N/A * There are 3 pieces that may need to be written out: 1450N/A * o whatever is in the display buffer 1450N/A * o the data passed in by the user 1450N/A * o any padding needed to 32bit align the whole mess 1450N/A * This loop looks at all 3 pieces each time through. It uses skip 1450N/A * to figure out whether or not a given piece is needed. 1450N/A /* You could be very general here and have "in" and "out" iovecs 1450N/A * and write a loop without using a macro, but what the heck. This 1450N/A * how much of this piece is new? 1450N/A * if more new then we are trying this time, clamp 1450N/A * then bump down amount already written, for next piece 1450N/A * else put new stuff in iovec, will need all of next piece 1450N/A * Note that todo had better be at least 1 or else we'll end up 1450N/A * _XAllocID - normal resource ID allocation routine. A client 1450N/A * can roll his own and instatantiate it if he wants, but must 1450N/A "Xlib: resource ID allocation space exhausted!\n");
1450N/A * The hard part about this is that we only get 16 bits from a reply. Well, 1450N/A * then, we have three values that will march along, with the following 1450N/A * dpy->last_request_read <= rep->sequenceNumber <= dpy->request 1450N/A * The right choice for rep->sequenceNumber is the largest that 1450N/A * still meets these constraints. 1450N/A * KeymapNotify has no sequence number, but is always guaranteed 1450N/A * to immediately follow another event, except when generated via 1450N/A "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
1450N/A * N_XReply - Wait for a reply packet and copy its contents into the 1450N/A * specified rep. Mean while we must handle error and event packets that 1450N/A int extra,
/* number of 32-bit words expected after the reply */ 1450N/A /* Pull out the serial number now, so that (currently illegal) requests 1450N/A * generated by an error handler don't confuse us. 1450N/A /* Reply received. Fast update for synchronous replies, 1450N/A * but deal with multiple outstanding replies. 1450N/A /* unexpectedly long reply! */ 1450N/A * Read the extra data into storage immediately following 1450N/A * the GenericReply structure. 1450N/A /* Actual reply is longer than "extra" */ 1450N/A *if we get here, then extra > rep->generic.length--meaning we 1450N/A * read a reply that's shorter than we expected. This is an 1450N/A * error, but we still need to figure out how to handle it... 1450N/A * we better see if there is an extension who may 1450N/A * want to suppress the error. 1450N/A /* There should never be any events on this connection! */ 1450N/A/* Read and discard "n" 8-bit bytes of data */ 1450N/A/* Read and discard "n" 32-bit words. */ 1450N/A * _XEnq - Place event packets on the display's queue. 1450N/A * note that no squishing of move events in V11, since there 1450N/A * is pointer motion hints.... 1450N/A /* If _qfree is non-NULL do this, else malloc a new one. */ 1450N/A /* go call through display to find proper event reformatter */ 1450N/A /* ignored, or stashed away for many-to-one compression */ 1450N/A * EventToWire in separate file in that often not needed. 1450N/A * reformat a wire event into an XEvent structure of the right type. 1450N/A /* Ignore the leading bit of the event type since it is set when a 1450N/A client sends an event rather than the server. */ default:
/* XXX should never occur */ return (s ? s :
"no such error");
#
endif /* USL sharedlibs in don't define for SVR3.2 */ * _XDefaultIOError - Default fatal system error reporting routine. Called * when an X internal system error is encountered. "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
" after %lu requests (%lu known processed) with %d events remaining.\r\n",
" The connection was probably broken by a server shutdown or KillClient.\r\n");
char *
mtype =
"XlibMessage";
/* kludge, try to find the extension that caused it */ /* let extensions try to print the values */ * _XError - prepare to upcall user protocol error handler * X_Error packet encountered! We need to unpack the error before * _XIOError - call user connection error handler and exit * This routine can be used to (cheaply) get some memory within a single * Xlib routine for scratch space. It is reallocated from the same place * each time, unless the library needs a large scratch space. * Given a visual id, find the visual structure for this id on this display. /* if nvisuals == 0 then visuals will be NULL */ * 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. long mask16 =
0x000000000000ffff;
/* nwords is the number of 16 bit values to be packed, * the low order 16 bits of each word will be packed * 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. long mask32 =
0x00000000ffffffff;
/* nwords is the number of 32 bit values to be packed * the low order 32 bits of each word will be packed * _XFreeQ - free the queue of events, called by XCloseDisplay * 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). * N_XGetHostname - similar to gethostname but allows special processing. #
endif /* NEED_UTSNAME */ * _XScreenOfWindow - get the Screen of a given window int x, y;
/* dummy variables */ * This is a macro if MSKCNT <= 4 * Cray UniCOS does not have readv and writev so we emulate * SYSV/386 does not have readv so we emulate #
endif /* SYSV && i386 && !STREAMSCONN */ * Copyright 1988, 1989 AT&T, 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 AT&T not be used in advertising * or publicity pertaining to distribution of the software without specific, * written prior permission. AT&T makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * AT&T DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL AT&T * 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. Acc: 575557389 Mon Mar 28 08:03:09 1988 Mod: 575557397 Mon Mar 28 08:03:17 1988 Sta: 575557397 Mon Mar 28 08:03:17 1988 for (i = 0, p =
buf; i < n; ++i)
for (i = 0, p =
buf; i < n; ++i)