summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile69
-rw-r--r--Makefile.meta69
-rw-r--r--common.c276
-rw-r--r--decode11.c1076
-rw-r--r--fd.c263
-rw-r--r--fd.h54
-rw-r--r--imakefile5
-rw-r--r--print11.c3576
-rw-r--r--prtype.c1045
-rw-r--r--scope.c692
-rw-r--r--scope.h67
-rw-r--r--server.c632
-rw-r--r--table11.c1112
-rw-r--r--x11.h452
-rw-r--r--xscope.1107
15 files changed, 9495 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1e52d9c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,69 @@
+InstallRoot = /home/peterson
+SHELL=/bin/sh
+INSTALL = install
+DFLAG = -g
+
+##################################################################
+#
+# xscope -- spy on characters to and from an X11 server
+#
+# Author: JLPeterson, MCC
+#
+# Installs bin/xscope
+#
+##################################################################
+
+CFLAGS = ${DFLAG} ${IFLAGS}
+
+all: xscope
+
+SRCS = scope.c common.c fd.c server.c decode11.c table11.c print11.c prtype.c
+OBJS = scope.o common.o fd.o server.o decode11.o table11.o print11.o prtype.o
+
+xscope: ${OBJS}
+ ${CC} ${CFLAGS} ${OBJS} -o xscope
+
+
+##################################################################
+
+install: all
+ ${INSTALL} xscope /home/peterson/bin/xscope
+ ${INSTALL} xscope.1 /home/peterson/man/xscope.1
+
+
+##################################################################
+#
+# configuration
+#
+config:
+ sed 's|$$<\InstallRoot>|'"${InstallRoot}|g" < Makefile.meta > Makefile
+
+
+##################################################################
+#
+# lint
+#
+lint:
+ lint -bux ${IFLAGS} ${SRCS}
+
+##################################################################
+#
+# clean
+#
+clean:
+ rm -f *.o xscope
+ rm -f core load.map *~ \#*
+
+##################################################################
+#
+# dependencies
+#
+scope.o: scope.c scope.h
+common.o: common.c scope.h
+fd.o: fd.c fd.h scope.h
+server.o: server.c scope.h x11.h
+decode11.o: decode11.c scope.h x11.h
+table11.o: table11.c scope.h x11.h
+print11.o: print11.c scope.h x11.h
+prtype.o: prtype.c scope.h x11.h
+scope.h: fd.h
diff --git a/Makefile.meta b/Makefile.meta
new file mode 100644
index 0000000..c962af0
--- /dev/null
+++ b/Makefile.meta
@@ -0,0 +1,69 @@
+InstallRoot = $<InstallRoot>
+SHELL=/bin/sh
+INSTALL = install
+DFLAG = -g
+
+##################################################################
+#
+# xscope -- spy on characters to and from an X11 server
+#
+# Author: JLPeterson, MCC
+#
+# Installs bin/xscope
+#
+##################################################################
+
+CFLAGS = ${DFLAG} ${IFLAGS}
+
+all: xscope
+
+SRCS = scope.c common.c fd.c server.c decode11.c table11.c print11.c prtype.c
+OBJS = scope.o common.o fd.o server.o decode11.o table11.o print11.o prtype.o
+
+xscope: ${OBJS}
+ ${CC} ${CFLAGS} ${OBJS} -o xscope
+
+
+##################################################################
+
+install: all
+ ${INSTALL} xscope $<InstallRoot>/bin/xscope
+ ${INSTALL} xscope.1 $<InstallRoot>/man/xscope.1
+
+
+##################################################################
+#
+# configuration
+#
+config:
+ sed 's|$$<\InstallRoot>|'"${InstallRoot}|g" < Makefile.meta > Makefile
+
+
+##################################################################
+#
+# lint
+#
+lint:
+ lint -bux ${IFLAGS} ${SRCS}
+
+##################################################################
+#
+# clean
+#
+clean:
+ rm -f *.o xscope
+ rm -f core load.map *~ \#*
+
+##################################################################
+#
+# dependencies
+#
+scope.o: scope.c scope.h
+common.o: common.c scope.h
+fd.o: fd.c fd.h scope.h
+server.o: server.c scope.h x11.h
+decode11.o: decode11.c scope.h x11.h
+table11.o: table11.c scope.h x11.h
+print11.o: print11.c scope.h x11.h
+prtype.o: prtype.c scope.h x11.h
+scope.h: fd.h
diff --git a/common.c b/common.c
new file mode 100644
index 0000000..7ce37a5
--- /dev/null
+++ b/common.c
@@ -0,0 +1,276 @@
+/* ************************************************************ *\
+ * *
+ * Common support routines for sockets *
+ * *
+ * James L. Peterson *
+ * Copyright (C) 1987 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+
+/* ********************************************** */
+/* */
+/* Debugging support routines */
+/* */
+/* ********************************************** */
+
+enterprocedure(s)
+ char *s;
+{
+ debug(2,(stderr, "-> %s\n", s));
+}
+
+warn(s)
+ char *s;
+{
+ fprintf(stderr, "####### %s\n", s);
+}
+
+panic(s)
+ char *s;
+{
+ fprintf(stderr, "%s\n", s);
+ exit(1);
+}
+
+/* ********************************************** */
+/* */
+/* Debugging forms of memory management */
+/* */
+/* ********************************************** */
+
+extern char *malloc();
+
+char *Malloc (n)
+ long n;
+{
+ char *p;
+ p = (char *)malloc((unsigned int)n);
+ debug(64,(stderr, "%x = malloc(%d)\n", p, n));
+ if (p == NULL)
+ panic("no more malloc space");
+ return(p);
+}
+
+Free(p)
+ char *p;
+{
+ debug(64,(stderr, "%x = free\n", p));
+ free(p);
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* Signal Handling support */
+/* */
+/* ************************************************************ */
+
+#include <signal.h>
+
+#ifdef SIGURG
+void SignalURG(int dummy)
+{
+ debug(1,(stderr, "==> SIGURG received\n"));
+}
+#endif /* #ifdef SIGURG */
+
+#ifdef SIGPIPE
+void SignalPIPE(int dummy)
+{
+ debug(1,(stderr, "==> SIGPIPE received\n"));
+}
+#endif /* #ifdef SIGPIPE */
+
+#ifdef SIGINT
+void SignalINT(int dummy)
+{
+ debug(1,(stderr, "==> SIGINT received\n"));
+ exit(1);
+#endif /* #ifdef SIGINT */
+}
+
+#ifdef SIGQUIT
+void SignalQUIT(int dummy)
+{
+ debug(1,(stderr, "==> SIGQUIT received\n"));
+ exit(1);
+#endif /* #ifdef SIGQUIT */
+}
+
+#ifdef SIGTERM
+void SignalTERM(int dummy)
+{
+ debug(1,(stderr, "==> SIGTERM received\n"));
+ exit(1);
+#endif /* #ifdef SIGTERM */
+}
+
+#ifdef SIGTSTP
+void SignalTSTP(int dummy)
+{
+ debug(1,(stderr, "==> SIGTSTP received\n"));
+}
+#endif /* #ifdef SIGTSTP */
+
+#ifdef SIGCONT
+void SignalCONT(int dummy)
+{
+ debug(1,(stderr, "==> SIGCONT received\n"));
+}
+#endif /* #ifdef SIGCONT */
+
+SetSignalHandling()
+{
+ enterprocedure("SetSignalHandling");
+#ifdef SIGURG
+ (void)signal(SIGURG, SignalURG);
+#endif /* #ifdef SIGURG */
+#ifdef SIGPIPE
+ (void)signal(SIGPIPE, SignalPIPE);
+#endif /* #ifdef SIGPIPE */
+#ifdef SIGINT
+ (void)signal(SIGINT, SignalINT);
+#endif /* #ifdef SIGINT */
+#ifdef SIGQUIT
+ (void)signal(SIGQUIT, SignalQUIT);
+#endif /* #ifdef SIGQUIT */
+#ifdef SIGTERM
+ (void)signal(SIGTERM, SignalTERM);
+#endif /* #ifdef SIGTERM */
+#ifdef SIGTSTP
+ (void)signal(SIGTSTP, SignalTSTP);
+#endif /* #ifdef SIGTSTP */
+#ifdef SIGCONT
+ (void)signal(SIGCONT, SignalCONT);
+#endif /* #ifdef SIGCONT */
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* Create a socket for a service to listen for clients */
+/* */
+/* ************************************************************ */
+
+#include <sys/types.h> /* needed by sys/socket.h and netinet/in.h */
+#include <sys/uio.h> /* for struct iovec, used by socket.h */
+#include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */
+#include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <netdb.h> /* struct servent * and struct hostent * */
+
+static int ON = 1 /* used in ioctl */ ;
+#define BACKLOG 5
+
+/* for use in the UsingFD call -- defined later */
+extern int NewConnection ();
+
+
+SetUpConnectionSocket(port)
+ int port;
+{
+ FD ConnectionSocket;
+ struct sockaddr_in sin;
+#ifndef SO_DONTLINGER
+ struct linger linger;
+#endif /* #ifndef SO_DONTLINGER */
+
+ enterprocedure("SetUpConnectionSocket");
+
+ /* create the connection socket and set its parameters of use */
+ ConnectionSocket = socket(AF_INET, SOCK_STREAM, 0);
+ if (ConnectionSocket < 0)
+ {
+ perror("socket");
+ exit(-1);
+ }
+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0);
+#ifdef SO_USELOOPBACK
+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0);
+#endif /* #ifdef SO_USELOOPBACK */
+#ifdef SO_DONTLINGER
+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0);
+#else /* #ifdef SO_DONTLINGER */
+ linger.l_onoff = 0;
+ linger.l_linger = 0;
+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger);
+#endif /* #ifdef SO_DONTLINGER */
+
+ /* define the name and port to be used with the connection socket */
+ bzero((char *)&sin, sizeof(sin));
+ sin.sin_family = AF_INET;
+
+ /* the address of the socket is composed of two parts: the host machine and
+ the port number. We need the host machine address for the current host
+ */
+ {
+ /* define the host part of the address */
+ char MyHostName[256];
+ struct hostent *hp;
+
+ (void) gethostname(MyHostName, sizeof(MyHostName));
+ ScopeHost = (char *) Malloc((long)(1+strlen(MyHostName)));
+ (void)strcpy(ScopeHost, MyHostName);
+ hp = gethostbyname(MyHostName);
+ if (hp == NULL)
+ panic("No address for our host");
+ bcopy((char *)hp->h_addr, (char*)&sin.sin_addr, hp->h_length);
+ }
+ /* new code -- INADDR_ANY should be better than using the name of the
+ host machine. The host machine may have several different network
+ addresses. INADDR_ANY should work with all of them at once. */
+ sin.sin_addr.s_addr = INADDR_ANY;
+
+ sin.sin_port = htons(port);
+ ScopePort = port;
+
+ /* bind the name and port number to the connection socket */
+ if (bind(ConnectionSocket, (struct sockaddr *)&sin, sizeof(sin)) < 0)
+ {
+ perror("bind");
+ exit(-1);
+ }
+
+ debug(4,(stderr, "Socket is FD %d for %s,%d\n",
+ ConnectionSocket, ScopeHost, ScopePort));
+
+ /* now activate the named connection socket to get messages */
+ if (listen(ConnectionSocket, BACKLOG) < 0)
+ {
+ perror("listen");
+ exit(-1);
+ };
+
+ /* a few more parameter settings */
+#ifdef FIOCLEX
+ (void)ioctl(ConnectionSocket, FIOCLEX, 0);
+#endif /* #ifdef FIOCLEX */
+ (void)ioctl(ConnectionSocket, FIONBIO, &ON);
+
+ debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket));
+ UsingFD(ConnectionSocket, NewConnection);
+}
+
+
diff --git a/decode11.c b/decode11.c
new file mode 100644
index 0000000..eb2a12f
--- /dev/null
+++ b/decode11.c
@@ -0,0 +1,1076 @@
+/* ************************************************************ *
+ * *
+ * Decoding and switching routines for the X11 protocol *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+#include "x11.h"
+
+/*
+ There are 4 types of things in X11: requests, replies, errors, and events.
+
+ Each of them has a format defined by a small integer that defines
+ the type of the thing.
+
+ Requests have an opcode in the first byte.
+ Events have a code in the first byte.
+ Errors have a code in the second byte (the first byte is 0)
+ Replies ...
+
+ Replies have a sequence number in bytes 2 and 3. The sequence
+ number should be used to identify the request that was sent, and
+ from that request we can determine the type of the reply.
+*/
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+/*
+ We need to keep the sequence number for a request to match it with
+ an expected reply. The sequence number is associated only with the
+ particular connection that we have. We would expect these replies
+ to be handled as a FIFO queue.
+*/
+
+struct QueueEntry
+{
+ struct QueueEntry *Next;
+ long SequenceNumber;
+ short Request;
+};
+
+/* free space list of Q entries */
+
+static struct QueueEntry *FreeQEntries = NULL;
+
+/* ************************************************************ */
+struct QueueEntry *NewQEntry (SequenceNumber, Request)
+ long SequenceNumber;
+ short Request;
+{
+ struct QueueEntry *p;
+
+ /* Get a Queue Entry */
+ if (FreeQEntries == NULL)
+ {
+ /* create new queue entry */
+ p = (struct QueueEntry *) Malloc ((long)(sizeof (*p)));
+ }
+ else
+ {
+ /* reuse an old queue entry */
+ p = FreeQEntries;
+ FreeQEntries = FreeQEntries->Next;
+ }
+
+ /* fill in its values */
+ p->Next = NULL;
+ p->SequenceNumber = SequenceNumber;
+ p->Request = Request;
+ return(p);
+}
+/* ************************************************************ */
+
+/* define a queue of entries for each FD */
+
+struct QueueHeader
+{
+ struct QueueEntry *Head;
+ struct QueueEntry *Tail;
+};
+
+struct QueueHeader ReplyQ[StaticMaxFD];
+
+/* ************************************************************ */
+
+InitReplyQ()
+{
+ short i;
+ for (i = 0; i < StaticMaxFD; i++)
+ {
+ ReplyQ[i].Head = NULL;
+ ReplyQ[i].Tail = NULL;
+ }
+}
+
+FlushReplyQ(fd)
+FD fd;
+{
+ struct QueueEntry *p;
+ struct QueueEntry *NextQEntry;
+
+ /* go down the reply queue and free all entries */
+ for (p = ReplyQ[fd].Head; p != NULL; p = NextQEntry)
+ {
+ NextQEntry = p->Next;
+
+ /* put freed entry on list of free entries (for later reuse) */
+ p->Next = FreeQEntries;
+ FreeQEntries = p;
+ }
+
+ ReplyQ[fd].Head = NULL;
+ ReplyQ[fd].Tail = NULL;
+}
+
+
+DumpReplyQ(fd)
+ FD fd;
+{
+ fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n",
+ fd, ReplyQ[fd].Head, ReplyQ[fd].Tail);
+ {
+ struct QueueEntry *p;
+ for (p = ReplyQ[fd].Head; p != NULL; p = p->Next)
+ fprintf(stderr, "0x%x = { Next 0x%x; SequenceNumber %d; Request %d }\n",
+ p, p->Next, p->SequenceNumber, p->Request);
+ }
+}
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* A reply is expected to the type of request given for the fd associated
+ with this one */
+
+SequencedReplyExpected(fd, SequenceNumber, RequestType)
+ FD fd;
+ long SequenceNumber;
+ short RequestType;
+{
+ struct QueueEntry *p;
+
+ debug(8,(stderr, "Reply expected: sequence %d and request type %d for fd %d\n",
+ SequenceNumber, RequestType, fd));
+ /* create a new queue entry */
+ p = NewQEntry(SequenceNumber, RequestType);
+
+ /* find the server associated with this client */
+ fd = FDPair(fd);
+ if (fd < 0 || fd >= StaticMaxFD) return;
+
+ /* attach the new queue entry to the end of the queue for the Server */
+ if (ReplyQ[fd].Tail != NULL)
+ (ReplyQ[fd].Tail)->Next = p;
+ else
+ ReplyQ[fd].Head = p;
+ ReplyQ[fd].Tail = p;
+
+ debug(8,(stderr, "Save sequence %d and request type %d for fd %d\n",
+ p->SequenceNumber, p->Request, fd));
+}
+
+
+/* search for the type of request that is associated with a reply
+ to the given sequence number for this fd */
+
+short CheckReplyTable (fd, SequenceNumber)
+ FD fd;
+ short SequenceNumber;
+{
+ struct QueueEntry *p;
+
+ if (debuglevel & 128) DumpReplyQ(fd);
+ for (p = ReplyQ[fd].Head;
+ p != NULL;
+ p = p->Next)
+ {
+ /* look for matching sequence number in queue of this fd */
+ if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber)))
+ {
+ return(p->Request);
+ }
+ }
+
+ /* not expecting a reply for that sequence number */
+ return(0);
+}
+
+
+static FD Lastfd;
+static long LastSequenceNumber;
+static short LastReplyType;
+
+
+short ExtractReplyTable (fd, SequenceNumber)
+ FD fd;
+ short SequenceNumber;
+{
+ struct QueueEntry *p;
+ struct QueueEntry *trailer;
+
+ if (debuglevel & 128) DumpReplyQ(fd);
+ for (trailer = NULL, p = ReplyQ[fd].Head;
+ p != NULL;
+ trailer = p, p = p->Next)
+ {
+ /* look for matching sequence number in queue of this fd */
+ if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber)))
+ {
+ /* save the Request type */
+ Lastfd = fd;
+ LastSequenceNumber = p->SequenceNumber;
+ LastReplyType = p->Request;
+
+ /* pull the queue entry out of the queue for this fd */
+ if (trailer == NULL)
+ ReplyQ[fd].Head = p->Next;
+ else
+ trailer->Next = p->Next;
+ if (ReplyQ[fd].Tail == p) ReplyQ[fd].Tail = trailer;
+
+
+ /* put freed entry on list of free entries (for later reuse) */
+ p->Next = FreeQEntries;
+ FreeQEntries = p;
+
+ debug(8,(stderr, "Reply on fd %d for sequence %d is type %d\n",
+ fd, SequenceNumber, LastReplyType));
+ return(LastReplyType);
+ }
+ }
+
+ /* not expecting a reply for that sequence number */
+ debug(8,(stderr, "Reply on fd %d for sequence %d is not found\n",
+ fd, SequenceNumber));
+ return(0);
+}
+
+
+/* ************************************************************ */
+/* A reply is expected to the type of request given for the
+ sequence number associated with this fd */
+
+ReplyExpected(fd, Request)
+ FD fd;
+ short Request;
+{
+ SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request);
+}
+
+/* ************************************************************ */
+/* another reply is expected for the same reply as we just had */
+/* This is only used with ListFontsWithInfo */
+
+KeepLastReplyExpected()
+{
+ SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+DecodeRequest(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Request = IByte (&buf[0]);
+ CS[fd].SequenceNumber += 1;
+ bcopy ((char *)&(CS[fd].SequenceNumber), (char *)SBf, sizeof(long));
+ SetIndentLevel(PRINTCLIENT);
+
+ if (Verbose > 3)
+ DumpItem("Request", fd, buf, n);
+ if (Request <= 0 || 127 < Request)
+ {
+ warn("Extended request opcode");
+ fprintf(stdout, "Extended request opcode: %d\n", Request);
+ }
+ else switch (Request)
+ {
+ case 1:
+ CreateWindow(buf);
+ break;
+ case 2:
+ ChangeWindowAttributes(buf);
+ break;
+ case 3:
+ GetWindowAttributes(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 4:
+ DestroyWindow(buf);
+ break;
+ case 5:
+ DestroySubwindows(buf);
+ break;
+ case 6:
+ ChangeSaveSet(buf);
+ break;
+ case 7:
+ ReparentWindow(buf);
+ break;
+ case 8:
+ MapWindow(buf);
+ break;
+ case 9:
+ MapSubwindows(buf);
+ break;
+ case 10:
+ UnmapWindow(buf);
+ break;
+ case 11:
+ UnmapSubwindows(buf);
+ break;
+ case 12:
+ ConfigureWindow(buf);
+ break;
+ case 13:
+ CirculateWindow(buf);
+ break;
+ case 14:
+ GetGeometry(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 15:
+ QueryTree(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 16:
+ InternAtom(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 17:
+ GetAtomName(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 18:
+ ChangeProperty(buf);
+ break;
+ case 19:
+ DeleteProperty(buf);
+ break;
+ case 20:
+ GetProperty(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 21:
+ ListProperties(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 22:
+ SetSelectionOwner(buf);
+ break;
+ case 23:
+ GetSelectionOwner(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 24:
+ ConvertSelection(buf);
+ break;
+ case 25:
+ SendEvent(buf);
+ break;
+ case 26:
+ GrabPointer(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 27:
+ UngrabPointer(buf);
+ break;
+ case 28:
+ GrabButton(buf);
+ break;
+ case 29:
+ UngrabButton(buf);
+ break;
+ case 30:
+ ChangeActivePointerGrab(buf);
+ break;
+ case 31:
+ GrabKeyboard(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 32:
+ UngrabKeyboard(buf);
+ break;
+ case 33:
+ GrabKey(buf);
+ break;
+ case 34:
+ UngrabKey(buf);
+ break;
+ case 35:
+ AllowEvents(buf);
+ break;
+ case 36:
+ GrabServer(buf);
+ break;
+ case 37:
+ UngrabServer(buf);
+ break;
+ case 38:
+ QueryPointer(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 39:
+ GetMotionEvents(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 40:
+ TranslateCoordinates(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 41:
+ WarpPointer(buf);
+ break;
+ case 42:
+ SetInputFocus(buf);
+ break;
+ case 43:
+ GetInputFocus(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 44:
+ QueryKeymap(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 45:
+ OpenFont(buf);
+ break;
+ case 46:
+ CloseFont(buf);
+ break;
+ case 47:
+ QueryFont(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 48:
+ QueryTextExtents(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 49:
+ ListFonts(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 50:
+ ListFontsWithInfo(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 51:
+ SetFontPath(buf);
+ break;
+ case 52:
+ GetFontPath(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 53:
+ CreatePixmap(buf);
+ break;
+ case 54:
+ FreePixmap(buf);
+ break;
+ case 55:
+ CreateGC(buf);
+ break;
+ case 56:
+ ChangeGC(buf);
+ break;
+ case 57:
+ CopyGC(buf);
+ break;
+ case 58:
+ SetDashes(buf);
+ break;
+ case 59:
+ SetClipRectangles(buf);
+ break;
+ case 60:
+ FreeGC(buf);
+ break;
+ case 61:
+ ClearArea(buf);
+ break;
+ case 62:
+ CopyArea(buf);
+ break;
+ case 63:
+ CopyPlane(buf);
+ break;
+ case 64:
+ PolyPoint(buf);
+ break;
+ case 65:
+ PolyLine(buf);
+ break;
+ case 66:
+ PolySegment(buf);
+ break;
+ case 67:
+ PolyRectangle(buf);
+ break;
+ case 68:
+ PolyArc(buf);
+ break;
+ case 69:
+ FillPoly(buf);
+ break;
+ case 70:
+ PolyFillRectangle(buf);
+ break;
+ case 71:
+ PolyFillArc(buf);
+ break;
+ case 72:
+ PutImage(buf);
+ break;
+ case 73:
+ GetImage(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 74:
+ PolyText8(buf);
+ break;
+ case 75:
+ PolyText16(buf);
+ break;
+ case 76:
+ ImageText8(buf);
+ break;
+ case 77:
+ ImageText16(buf);
+ break;
+ case 78:
+ CreateColormap(buf);
+ break;
+ case 79:
+ FreeColormap(buf);
+ break;
+ case 80:
+ CopyColormapAndFree(buf);
+ break;
+ case 81:
+ InstallColormap(buf);
+ break;
+ case 82:
+ UninstallColormap(buf);
+ break;
+ case 83:
+ ListInstalledColormaps(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 84:
+ AllocColor(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 85:
+ AllocNamedColor(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 86:
+ AllocColorCells(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 87:
+ AllocColorPlanes(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 88:
+ FreeColors(buf);
+ break;
+ case 89:
+ StoreColors(buf);
+ break;
+ case 90:
+ StoreNamedColor(buf);
+ break;
+ case 91:
+ QueryColors(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 92:
+ LookupColor(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 93:
+ CreateCursor(buf);
+ break;
+ case 94:
+ CreateGlyphCursor(buf);
+ break;
+ case 95:
+ FreeCursor(buf);
+ break;
+ case 96:
+ RecolorCursor(buf);
+ break;
+ case 97:
+ QueryBestSize(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 98:
+ QueryExtension(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 99:
+ ListExtensions(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 100:
+ ChangeKeyboardMapping(buf);
+ break;
+ case 101:
+ GetKeyboardMapping(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 102:
+ ChangeKeyboardControl(buf);
+ break;
+ case 103:
+ GetKeyboardControl(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 104:
+ Bell(buf);
+ break;
+ case 105:
+ ChangePointerControl(buf);
+ break;
+ case 106:
+ GetPointerControl(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 107:
+ SetScreenSaver(buf);
+ break;
+ case 108:
+ GetScreenSaver(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 109:
+ ChangeHosts(buf);
+ break;
+ case 110:
+ ListHosts(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 111:
+ SetAccessControl(buf);
+ break;
+ case 112:
+ SetCloseDownMode(buf);
+ break;
+ case 113:
+ KillClient(buf);
+ break;
+ case 114:
+ RotateProperties(buf);
+ break;
+ case 115:
+ ForceScreenSaver(buf);
+ break;
+ case 116:
+ SetPointerMapping(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 117:
+ GetPointerMapping(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 118:
+ SetModifierMapping(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 119:
+ GetModifierMapping(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 127:
+ NoOperation(buf);
+ break;
+ default:
+ warn("Unimplemented request opcode");
+ break;
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeReply(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short SequenceNumber = IShort (&buf[2]);
+ short Request = ExtractReplyTable (fd, SequenceNumber);
+ if (Request == 0)
+ {
+ warn("Unexpected reply");
+ fprintf(stdout, "Unexpected reply: %d\n", SequenceNumber);
+ return;
+ }
+ SetIndentLevel(PRINTSERVER);
+ RBf[0] = Request /* for the PrintField in the Reply procedure */ ;
+ if (Verbose > 3)
+ DumpItem("Reply", fd, buf, n);
+ if (Request <= 0 || 127 < Request)
+ {
+ warn("Extended reply opcode");
+ fprintf(stdout, "Extended reply opcode: %d\n", Request);
+ }
+ else switch (Request)
+ {
+ case 3:
+ GetWindowAttributesReply(buf);
+ break;
+ case 14:
+ GetGeometryReply(buf);
+ break;
+ case 15:
+ QueryTreeReply(buf);
+ break;
+ case 16:
+ InternAtomReply(buf);
+ break;
+ case 17:
+ GetAtomNameReply(buf);
+ break;
+ case 20:
+ GetPropertyReply(buf);
+ break;
+ case 21:
+ ListPropertiesReply(buf);
+ break;
+ case 23:
+ GetSelectionOwnerReply(buf);
+ break;
+ case 26:
+ GrabPointerReply(buf);
+ break;
+ case 31:
+ GrabKeyboardReply(buf);
+ break;
+ case 38:
+ QueryPointerReply(buf);
+ break;
+ case 39:
+ GetMotionEventsReply(buf);
+ break;
+ case 40:
+ TranslateCoordinatesReply(buf);
+ break;
+ case 43:
+ GetInputFocusReply(buf);
+ break;
+ case 44:
+ QueryKeymapReply(buf);
+ break;
+ case 47:
+ QueryFontReply(buf);
+ break;
+ case 48:
+ QueryTextExtentsReply(buf);
+ break;
+ case 49:
+ ListFontsReply(buf);
+ break;
+ case 50:
+ ListFontsWithInfoReply(buf);
+ break;
+ case 52:
+ GetFontPathReply(buf);
+ break;
+ case 73:
+ GetImageReply(buf);
+ break;
+ case 83:
+ ListInstalledColormapsReply(buf);
+ break;
+ case 84:
+ AllocColorReply(buf);
+ break;
+ case 85:
+ AllocNamedColorReply(buf);
+ break;
+ case 86:
+ AllocColorCellsReply(buf);
+ break;
+ case 87:
+ AllocColorPlanesReply(buf);
+ break;
+ case 91:
+ QueryColorsReply(buf);
+ break;
+ case 92:
+ LookupColorReply(buf);
+ break;
+ case 97:
+ QueryBestSizeReply(buf);
+ break;
+ case 98:
+ QueryExtensionReply(buf);
+ break;
+ case 99:
+ ListExtensionsReply(buf);
+ break;
+ case 101:
+ GetKeyboardMappingReply(buf);
+ break;
+ case 103:
+ GetKeyboardControlReply(buf);
+ break;
+ case 106:
+ GetPointerControlReply(buf);
+ break;
+ case 108:
+ GetScreenSaverReply(buf);
+ break;
+ case 110:
+ ListHostsReply(buf);
+ break;
+ case 116:
+ SetPointerMappingReply(buf);
+ break;
+ case 117:
+ GetPointerMappingReply(buf);
+ break;
+ case 118:
+ SetModifierMappingReply(buf);
+ break;
+ case 119:
+ GetModifierMappingReply(buf);
+ break;
+ default:
+ warn("Unimplemented reply opcode");
+ break;
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeError(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Error = IByte (&buf[1]);
+ SetIndentLevel(PRINTSERVER);
+ if (Verbose > 3)
+ DumpItem("Error", fd, buf, n);
+ (void)ExtractReplyTable (fd, (short)IShort(&buf[2]));
+ if (Error < 1 || Error > 17)
+ warn("Extended Error code");
+ else switch (Error)
+ {
+ case 1:
+ RequestError(buf);
+ break;
+ case 2:
+ ValueError(buf);
+ break;
+ case 3:
+ WindowError(buf);
+ break;
+ case 4:
+ PixmapError(buf);
+ break;
+ case 5:
+ AtomError(buf);
+ break;
+ case 6:
+ CursorError(buf);
+ break;
+ case 7:
+ FontError(buf);
+ break;
+ case 8:
+ MatchError(buf);
+ break;
+ case 9:
+ DrawableError(buf);
+ break;
+ case 10:
+ AccessError(buf);
+ break;
+ case 11:
+ AllocError(buf);
+ break;
+ case 12:
+ ColormapError(buf);
+ break;
+ case 13:
+ GContextError(buf);
+ break;
+ case 14:
+ IDChoiceError(buf);
+ break;
+ case 15:
+ NameError(buf);
+ break;
+ case 16:
+ LengthError(buf);
+ break;
+ case 17:
+ ImplementationError(buf);
+ break;
+ default:
+ warn("Unimplemented error code");
+ break;
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeEvent(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Event = IByte (&buf[0]);
+ SetIndentLevel(PRINTSERVER);
+ if (Verbose > 3)
+ DumpItem("Event", fd, buf, n);
+ /* high-order bit means SendEvent generated */
+ if (Event & 0x80)
+ {
+ debug(8,(stderr, "SendEvent generated event 0x%x\n", Event));
+ Event = Event & 0x7F;
+ }
+ if (Event < 2 || Event > 34)
+ warn("Extended Event code");
+ else switch (Event)
+ {
+ case 2:
+ KeyPressEvent(buf);
+ break;
+ case 3:
+ KeyReleaseEvent(buf);
+ break;
+ case 4:
+ ButtonPressEvent(buf);
+ break;
+ case 5:
+ ButtonReleaseEvent(buf);
+ break;
+ case 6:
+ MotionNotifyEvent(buf);
+ break;
+ case 7:
+ EnterNotifyEvent(buf);
+ break;
+ case 8:
+ LeaveNotifyEvent(buf);
+ break;
+ case 9:
+ FocusInEvent(buf);
+ break;
+ case 10:
+ FocusOutEvent(buf);
+ break;
+ case 11:
+ KeymapNotifyEvent(buf);
+ break;
+ case 12:
+ ExposeEvent(buf);
+ break;
+ case 13:
+ GraphicsExposureEvent(buf);
+ break;
+ case 14:
+ NoExposureEvent(buf);
+ break;
+ case 15:
+ VisibilityNotifyEvent(buf);
+ break;
+ case 16:
+ CreateNotifyEvent(buf);
+ break;
+ case 17:
+ DestroyNotifyEvent(buf);
+ break;
+ case 18:
+ UnmapNotifyEvent(buf);
+ break;
+ case 19:
+ MapNotifyEvent(buf);
+ break;
+ case 20:
+ MapRequestEvent(buf);
+ break;
+ case 21:
+ ReparentNotifyEvent(buf);
+ break;
+ case 22:
+ ConfigureNotifyEvent(buf);
+ break;
+ case 23:
+ ConfigureRequestEvent(buf);
+ break;
+ case 24:
+ GravityNotifyEvent(buf);
+ break;
+ case 25:
+ ResizeRequestEvent(buf);
+ break;
+ case 26:
+ CirculateNotifyEvent(buf);
+ break;
+ case 27:
+ CirculateRequestEvent(buf);
+ break;
+ case 28:
+ PropertyNotifyEvent(buf);
+ break;
+ case 29:
+ SelectionClearEvent(buf);
+ break;
+ case 30:
+ SelectionRequestEvent(buf);
+ break;
+ case 31:
+ SelectionNotifyEvent(buf);
+ break;
+ case 32:
+ ColormapNotifyEvent(buf);
+ break;
+ case 33:
+ ClientMessageEvent(buf);
+ break;
+ case 34:
+ MappingNotifyEvent(buf);
+ break;
+ default:
+ warn("Unimplemented event code");
+ break;
+ }
+}
diff --git a/fd.c b/fd.c
new file mode 100644
index 0000000..629c7fb
--- /dev/null
+++ b/fd.c
@@ -0,0 +1,263 @@
+/* ************************************************************ *\
+ * *
+ * Support routines for file descriptors (FD) *
+ * *
+ * James Peterson, 1987 *
+ * Copyright (C) 1987 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+
+
+/*
+ All of this code is to support the handling of file descriptors (FD).
+ The idea is to keep a table of the FDs that are in use and why.
+ For each FD that is open for input, we keep the name of a procedure
+ to call if input arrives for that FD. When an FD is created
+ (by an open, pipe, socket, ...) declare that by calling UsingFD.
+ When it is no longer in use (close ...), call NotUsingFD.
+*/
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+InitializeFD()
+{
+ register short i;
+
+ enterprocedure("InitializeFD");
+ /* get the number of file descriptors the system will let us use */
+ MaxFD = getdtablesize();
+ if (MaxFD > StaticMaxFD)
+ {
+ fprintf(stderr, "Recompile with larger StaticMaxFD value %d\n", MaxFD);
+ MaxFD = StaticMaxFD;
+ }
+
+ /* allocate space for a File Descriptor (FD) Table */
+ FDD = (struct FDDescriptor *)
+ Malloc ((long)(MaxFD * sizeof (struct FDDescriptor)));
+
+ /* be sure all fd's are closed and marked not busy */
+ for (i = 0; i < MaxFD; i++)
+ {
+ /* 0, 1, 2 are special (stdin, stdout, stderr) */
+ if (i > 2)
+ (void)close(i);
+ FDD[i].Busy = false;
+ }
+
+ /* save one FD for single file input or output like debugging */
+ /* also the getservbyname call is currently using an FD */
+ MaxFD -= 4;
+
+ nFDsInUse = 0 /* stdin, stdout, stderr */ ;
+ FD_ZERO(&ReadDescriptors);
+ HighestFD = 0;
+
+ UsingFD(fileno(stdin), (int (*)())NULL);
+ UsingFD(fileno(stdout), (int (*)())NULL);
+ UsingFD(fileno(stderr), (int (*)())NULL);
+}
+
+/* ************************************************************ */
+
+UsingFD(fd, Handler)
+ FD fd;
+ int (*Handler)();
+{
+ if (FDD[fd].Busy)
+ NotUsingFD(fd);
+ nFDsInUse += 1;
+
+ FDD[fd].Busy = true;
+ FDD[fd].InputHandler = Handler;
+ if (Handler == NULL)
+ FD_CLR(fd, &ReadDescriptors);
+ else
+ FD_SET(fd, &ReadDescriptors);
+
+ if (fd > HighestFD)
+ HighestFD = fd;
+
+ if (nFDsInUse >= MaxFD)
+ panic("no more FDs");
+
+ debug(128,(stderr, "Using FD %d, %d of %d in use\n", fd, nFDsInUse, MaxFD));
+}
+
+/* ************************************************************ */
+
+NotUsingFD(fd)
+ FD fd;
+{
+ debug(128,(stderr, "Not Using FD %d\n", fd));
+
+ if (FDD[fd].Busy)
+ nFDsInUse -= 1;
+
+ FDD[fd].Busy = false;
+ FD_CLR(fd, &ReadDescriptors);
+
+ while (!FDD[HighestFD].Busy && HighestFD > 0)
+ HighestFD -= 1;
+
+ debug(128,(stderr, "Highest FD %d, in use %d\n", HighestFD, nFDsInUse));
+}
+
+/* ************************************************************ */
+
+EOFonFD(fd)
+ FD fd;
+{
+ enterprocedure("EOFonFD");
+ debug(128,(stderr, "EOF on %d\n", fd));
+ (void)close(fd);
+ NotUsingFD(fd);
+}
+
+Boolean ValidFD(fd)
+ FD fd;
+{
+ enterprocedure("ValidFD");
+ return(FDD[fd].Busy);
+}
+
+/* ************************************************************ */
+/* */
+/* Main Loop -- wait for input from any source and Process */
+/* */
+/* ************************************************************ */
+
+#include <sys/time.h> /* for struct timeval * */
+#include <errno.h> /* for EINTR, EADDRINUSE, ... */
+extern int errno;
+
+
+MainLoop()
+{
+ enterprocedure("MainLoop");
+
+ while (true)
+ {
+ fd_set rfds, wfds, xfds;
+ short nfds;
+ short fd;
+
+ /* wait for something */
+ rfds = ReadDescriptors;
+ FD_ZERO(&wfds);
+ xfds = rfds;
+
+ debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds));
+ nfds = select(HighestFD + 1, &rfds, &wfds, &xfds, (struct timeval *)NULL);
+ debug(128,(stderr, "select nfds = 0%o, rfds = 0%o, 0%o, xfds 0%o\n",
+ nfds, rfds, wfds, xfds));
+
+ if (nfds < 0)
+ {
+ if (errno == EINTR)
+ continue /* to end of while loop */ ;
+ debug(1,(stderr, "Bad select - errno = %d\n", errno));
+ if (errno == EBADF)
+ {
+ /* one of the bits in rfds is invalid, close down
+ files until it goes away */
+ EOFonFD(HighestFD);
+ continue;
+ }
+
+ panic("Select returns error");
+ continue /* to end of while loop */ ;
+ }
+
+ if (nfds == 0)
+ {
+ TimerExpired();
+ continue;
+ }
+
+ /* check each fd to see if it has input */
+ for (fd = 0; 0 < nfds && fd <= HighestFD; fd++)
+ {
+ /*
+ check all returned fd's; this prevents
+ starvation of later clients by earlier clients
+ */
+
+ if (!FD_ISSET(fd,&rfds))
+ continue;
+
+ nfds -= 1;
+
+ HandleInput(fd);
+ }
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+Boolean InputAvailable(fd)
+FD fd;
+{
+ fd_set rfds;
+ int nfds;
+ struct timeval timeout;
+
+ enterprocedure("InputAvailable");
+ FD_ZERO(&rfds);
+ FD_SET(fd,&rfds);
+
+ /* use zero-valued time out */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 0;
+
+ debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds));
+ nfds = select(HighestFD + 1, &rfds, (fd_set *)NULL, (fd_set *)NULL, &timeout);
+ debug(128,(stderr, "select nfds = 0%o, rfds = 0%o\n", nfds, rfds));
+
+ if (nfds <= 0 || !FD_ISSET(fd,&rfds))
+ return(false);
+
+ if (FD_ISSET(fd,&rfds))
+ return(true);
+
+ return(false);
+}
+
+HandleInput(fd)
+FD fd;
+{
+ enterprocedure("HandleInput");
+ if (FDD[fd].InputHandler == NULL)
+ {
+ panic("FD selected with no handler");
+ debug(1,(stderr, "FD %d has NULL handler\n", fd));
+ }
+ else
+ (FDD[fd].InputHandler)(fd);
+}
diff --git a/fd.h b/fd.h
new file mode 100644
index 0000000..8836638
--- /dev/null
+++ b/fd.h
@@ -0,0 +1,54 @@
+/* **********************************************
+ * *
+ * header file file descriptor (FD) code *
+ * *
+ * James Peterson, 1987 *
+ * Copyright (C) 1987 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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.
+ * *
+ ********************************************** */
+
+
+/*
+ the following structure remembers for each file descriptor its
+ state. In particular, we need to know if it is busy or free
+ and if it is in use, by whom.
+*/
+
+#include <sys/select.h>
+
+typedef int FD;
+
+struct FDDescriptor
+{
+ Boolean Busy;
+ int (*InputHandler)();
+};
+
+struct FDDescriptor *FDD /* array of FD descriptors */ ;
+short MaxFD /* maximum number of FD's possible */ ;
+
+short nFDsInUse /* number of FD's actually in use */ ;
+
+fd_set ReadDescriptors /* bit map of FD's in use -- for select */ ;
+short HighestFD /* highest FD in use -- for select */ ;
+
+Boolean ValidFD();
+Boolean InputAvailable();
diff --git a/imakefile b/imakefile
new file mode 100644
index 0000000..5bc330d
--- /dev/null
+++ b/imakefile
@@ -0,0 +1,5 @@
+LOCAL_LIBRARIES =
+SRCS = prtype.c print11.c table11.c decode11.c server.c fd.c common.c scope.c
+OBJS = scope.o common.o fd.o server.o decode11.o table11.o print11.o prtype.o
+
+ComplexProgramTarget(xscope)
diff --git a/print11.c b/print11.c
new file mode 100644
index 0000000..2b8f609
--- /dev/null
+++ b/print11.c
@@ -0,0 +1,3576 @@
+/* ************************************************** *
+ * *
+ * Request, Reply, Event, Error Printing *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+#include "x11.h"
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ In printing the contents of the fields of the X11 packets, some
+ fields are of obvious value, and others are of lesser value. To
+ control the amount of output, we generate our output according
+ to the level of Verbose-ness that was selected by the user.
+
+ Verbose = 0 == Headers only, time and request/reply/... names.
+
+ Verbose = 1 == Very useful content fields.
+
+ Verbose = 2 == Almost everything.
+
+ Verbose = 3 == Every single bit and byte.
+
+*/
+
+/*
+ To aid in making the choice between level 1 and level 2, we
+ define the following define, which does not print relatively
+ unimportant fields.
+*/
+
+#define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e)
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+PrintSetUpMessage(buf)
+ unsigned char *buf;
+{
+ short n;
+ short d;
+
+ enterprocedure("PrintSetUpMessage");
+ if (Verbose < 1)
+ return;
+ SetIndentLevel(PRINTCLIENT);
+ PrintField(buf, 0, 1, BYTEMODE, "byte-order");
+ SetByteSwapping(IByte(&buf[0]));
+ PrintField(buf, 2, 2, CARD16, "major-version");
+ PrintField(buf, 4, 2, CARD16, "minor-version");
+ printfield(buf, 6, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[6]);
+ printfield(buf, 8, 2, DVALUE2(d), "length of data");
+ d = IShort(&buf[8]);
+ PrintString8(&buf[12], (long)n, "authorization-protocol-name");
+ PrintString8(&buf[pad((long)(12+n))], (long)d, "authorization-protocol-data");
+}
+
+PrintSetUpReply(buf)
+ unsigned char *buf;
+{
+ enterprocedure("PrintSetUpReply");
+ SetIndentLevel(PRINTSERVER);
+ if (IByte(&buf[0]))
+ PrintSuccessfulSetUpReply(buf);
+ else
+ PrintFailedSetUpReply(buf);
+}
+
+PrintFailedSetUpReply(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ PrintField(buf, 0, 1, 0, "SetUp Failed");
+ if (Verbose < 1)
+ return;
+ printfield(buf, 1, 1, DVALUE1(n), "length of reason in bytes");
+ n = IByte(&buf[1]);
+ PrintField(buf, 2, 2, CARD16, "major-version");
+ PrintField(buf, 4, 2, CARD16, "minor-version");
+ printfield(buf, 6, 2, DVALUE2((n + p) / 4), "length of data");
+ PrintString8(&buf[8], (long)n, "reason");
+}
+
+PrintSuccessfulSetUpReply(buf)
+ unsigned char *buf;
+{
+ short v;
+ short n;
+ short m;
+
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 2, 2, CARD16, "protocol-major-version");
+ PrintField(buf, 4, 2, CARD16, "protocol-minor-version");
+ printfield(buf, 6, 2, DVALUE2(8 + 2*n + (v + p + m) / 4), "length of data");
+ PrintField(buf, 8, 4, CARD32, "release-number");
+ PrintField(buf, 12, 4, CARD32, "resource-id-base");
+ PrintField(buf, 16, 4, CARD32, "resource-id-mask");
+ PrintField(buf, 20, 4, CARD32, "motion-buffer-size");
+ printfield(buf, 24, 2, DVALUE2(v), "length of vendor");
+ v = IShort(&buf[24]);
+ printfield(buf, 26, 2, CARD16, "maximum-request-length");
+ printfield(buf, 28, 1, CARD8, "number of roots");
+ m = IByte(&buf[28]);
+ printfield(buf, 29, 1, DVALUE1(n), "number of pixmap-formats");
+ n = IByte(&buf[29]);
+ PrintField(buf, 30, 1, BYTEORDER, "image-byte-order");
+ PrintField(buf, 31, 1, BYTEORDER, "bitmap-format-bit-order");
+ PrintField(buf, 32, 1, CARD8, "bitmap-format-scanline-unit");
+ PrintField(buf, 33, 1, CARD8, "bitmap-format-scanline-pad");
+ PrintField(buf, 34, 1, KEYCODE, "min-keycode");
+ PrintField(buf, 35, 1, KEYCODE, "max-keycode");
+ PrintString8(&buf[40], (long)v, "vendor");
+ (void)PrintList(&buf[pad((long)(40+v))], (long)n, FORMAT, "pixmap-formats");
+ (void)PrintList(&buf[pad((long)(40+v) + 8 * n)], (long)m, SCREEN, "roots");
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+static char *REQUESTHEADER = "............REQUEST";
+static char *EVENTHEADER = "..............EVENT";
+static char *ERRORHEADER = "..............ERROR";
+static char *REPLYHEADER = "..............REPLY";
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Error Printing procedures */
+
+RequestError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+ValueError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, INT32, "bad value");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+WindowError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Window */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+PixmapError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Pixmap */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AtomError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Atom */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad atom id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+CursorError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Cursor */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+FontError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Font */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+MatchError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+DrawableError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Drawable */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AccessError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AllocError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+ColormapError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Colormap */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+GContextError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* GContext */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+IDChoiceError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+NameError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Name */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+LengthError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+ImplementationError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Event Printing procedures */
+
+KeyPressEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeyPress */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, KEYCODE, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BOOL, "same-screen");
+}
+
+KeyReleaseEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeyRelease */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, KEYCODE, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BOOL, "same-screen");
+}
+
+ButtonPressEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ButtonPress */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BUTTON, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BOOL, "same-screen");
+}
+
+ButtonReleaseEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ButtonRelease */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BUTTON, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BOOL, "same-screen");
+}
+
+MotionNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MotionNotify */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, MOTIONDETAIL, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BOOL, "same-screen");
+}
+
+EnterNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* EnterNotify */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, ENTERDETAIL, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BUTTONMODE, "mode");
+ PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus");
+}
+
+LeaveNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LeaveNotify */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, ENTERDETAIL, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "event");
+ PrintField(buf, 16, 4, WINDOW, "child");
+ PrintField(buf, 20, 2, INT16, "root-x");
+ PrintField(buf, 22, 2, INT16, "root-y");
+ PrintField(buf, 24, 2, INT16, "event-x");
+ PrintField(buf, 26, 2, INT16, "event-y");
+ PrintField(buf, 28, 2, SETofKEYBUTMASK, "state");
+ PrintField(buf, 30, 1, BUTTONMODE, "mode");
+ PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus");
+}
+
+FocusInEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* FocusIn */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, ENTERDETAIL, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 1, BUTTONMODE, "mode");
+}
+
+FocusOutEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* FocusOut */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, ENTERDETAIL, "detail");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 1, BUTTONMODE, "mode");
+}
+
+KeymapNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeymapNotify */ ;
+ if (Verbose < 1)
+ return;
+ PrintBytes(&buf[1], (long)31,"keys");
+}
+
+ExposeEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* Expose */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 2, CARD16, "x");
+ PrintField(buf, 10, 2, CARD16, "y");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+ PrintField(buf, 16, 2, CARD16, "count");
+}
+
+GraphicsExposureEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GraphicsExposure */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 2, CARD16, "x");
+ PrintField(buf, 10, 2, CARD16, "y");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+ PrintField(buf, 16, 2, CARD16, "minor-opcode");
+ PrintField(buf, 18, 2, CARD16, "count");
+ PrintField(buf, 20, 1, CARD8, "major-opcode");
+}
+
+NoExposureEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* NoExposure */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 2, CARD16, "minor-opcode");
+ PrintField(buf, 10, 1, CARD8, "major-opcode");
+}
+
+VisibilityNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* VisibilityNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 1, VISIBLE, "state");
+}
+
+CreateNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CreateNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "parent");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintField(buf, 16, 2, CARD16, "width");
+ PrintField(buf, 18, 2, CARD16, "height");
+ PrintField(buf, 20, 2, CARD16, "border-width");
+ PrintField(buf, 22, 1, BOOL, "override-redirect");
+}
+
+DestroyNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* DestroyNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+}
+
+UnmapNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* UnmapNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 1, BOOL, "from-configure");
+}
+
+MapNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 1, BOOL, "override-redirect");
+}
+
+MapRequestEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapRequest */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "parent");
+ PrintField(buf, 8, 4, WINDOW, "window");
+}
+
+ReparentNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ReparentNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 4, WINDOW, "parent");
+ PrintField(buf, 16, 2, INT16, "x");
+ PrintField(buf, 18, 2, INT16, "y");
+ PrintField(buf, 20, 1, BOOL, "override-redirect");
+}
+
+ConfigureNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 4, WINDOW, "above-sibling");
+ PrintField(buf, 16, 2, INT16, "x");
+ PrintField(buf, 18, 2, INT16, "y");
+ PrintField(buf, 20, 2, CARD16, "width");
+ PrintField(buf, 22, 2, CARD16, "height");
+ PrintField(buf, 24, 2, CARD16, "border-width");
+ PrintField(buf, 26, 1, BOOL, "override-redirect");
+}
+
+ConfigureRequestEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureRequest */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, STACKMODE, "stack-mode");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "parent");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 4, WINDOW, "sibling");
+ PrintField(buf, 16, 2, INT16, "x");
+ PrintField(buf, 18, 2, INT16, "y");
+ PrintField(buf, 20, 2, CARD16, "width");
+ PrintField(buf, 22, 2, CARD16, "height");
+ PrintField(buf, 24, 2, CARD16, "border-width");
+ PrintField(buf, 26, 2, CONFIGURE_BITMASK, "value-mask");
+}
+
+GravityNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GravityNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+}
+
+ResizeRequestEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ResizeRequest */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 2, CARD16, "width");
+ PrintField(buf, 10, 2, CARD16, "height");
+}
+
+CirculateNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "event");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 4, WINDOW, "parent");
+ PrintField(buf, 16, 1, CIRSTAT, "place");
+}
+
+CirculateRequestEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateRequest */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "parent");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 16, 1, CIRSTAT, "place");
+}
+
+PropertyNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* PropertyNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, ATOM, "atom");
+ PrintField(buf, 12, 4, TIMESTAMP, "time");
+ PrintField(buf, 16, 1, PROPCHANGE, "state");
+}
+
+SelectionClearEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionClear */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "owner");
+ PrintField(buf, 12, 4, ATOM, "selection");
+}
+
+SelectionRequestEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionRequest */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "owner");
+ PrintField(buf, 12, 4, WINDOW, "requestor");
+ PrintField(buf, 16, 4, ATOM, "selection");
+ PrintField(buf, 20, 4, ATOM, "target");
+ PrintField(buf, 24, 4, ATOM, "property");
+}
+
+SelectionNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, WINDOW, "requestor");
+ PrintField(buf, 12, 4, ATOM, "selection");
+ PrintField(buf, 16, 4, ATOM, "target");
+ PrintField(buf, 20, 4, ATOM, "property");
+}
+
+ColormapNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ColormapNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, COLORMAP, "colormap");
+ PrintField(buf, 12, 1, BOOL, "new");
+ PrintField(buf, 13, 1, CMAPCHANGE, "state");
+}
+
+ClientMessageEvent(buf)
+ unsigned char *buf;
+{
+ short format;
+ long type;
+
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ClientMessage */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, CARD8, "format");
+ format = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, ATOM, "type");
+ type = ILong(&buf[8]);
+ if (type == 31 /* string */)
+ PrintString8(&buf[12], 20L, "data");
+ else if (format == 16)
+ (void)PrintList(&buf[12], 10L, INT16, "data");
+ else if (format == 32)
+ (void)PrintList(&buf[12], 5L, INT32, "data");
+ else
+ PrintBytes(&buf[12], 20L, "data");
+}
+
+MappingNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MappingNotify */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ PrintField(buf, 4, 1, MAPOBJECT, "request");
+ PrintField(buf, 5, 1, KEYCODE, "first-keycode");
+ PrintField(buf, 6, 1, CARD8, "count");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Request and Reply Printing procedures */
+
+CreateWindow(buf)
+ unsigned char *buf;
+{
+ /* Request CreateWindow is opcode 1 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, CARD8, "depth");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+ PrintField(buf, 4, 4, WINDOW, "wid");
+ PrintField(buf, 8, 4, WINDOW, "parent");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintField(buf, 16, 2, CARD16, "width");
+ PrintField(buf, 18, 2, CARD16, "height");
+ PrintField(buf, 20, 2, CARD16, "border-width");
+ PrintField(buf, 22, 2, WINDOWCLASS, "class");
+ PrintField(buf, 24, 4, VISUALIDC, "visual");
+ PrintField(buf, 28, 4, WINDOW_BITMASK, "value-mask");
+ PrintValues(&buf[28], 4, WINDOW_BITMASK, &buf[32], "value-list");
+}
+
+ChangeWindowAttributes(buf)
+ unsigned char *buf;
+{
+ /* Request ChangeWindowAttributes is opcode 2 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeWindowAttributes */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, WINDOW_BITMASK, "value-mask");
+ PrintValues(&buf[8], 4, WINDOW_BITMASK, &buf[12], "value-list");
+}
+
+GetWindowAttributes(buf)
+ unsigned char *buf;
+{
+ /* Request GetWindowAttributes is opcode 3 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetWindowAttributes */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+GetWindowAttributesReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetWindowAttributes */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BACKSTORE, "backing-store");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(3), "reply length");
+ PrintField(buf, 8, 4, VISUALID, "visual");
+ PrintField(buf, 12, 2, WINDOWCLASS, "class");
+ PrintField(buf, 14, 1, BITGRAVITY, "bit-gravity");
+ PrintField(buf, 15, 1, WINGRAVITY, "win-gravity");
+ PrintField(buf, 16, 4, CARD32, "backing-planes");
+ PrintField(buf, 20, 4, CARD32, "backing-pixel");
+ PrintField(buf, 24, 1, BOOL, "save-under");
+ PrintField(buf, 25, 1, BOOL, "map-is-installed");
+ PrintField(buf, 26, 1, MAPSTATE, "map-state");
+ PrintField(buf, 27, 1, BOOL, "override-redirect");
+ PrintField(buf, 28, 4, COLORMAP, "colormap");
+ PrintField(buf, 32, 4, SETofEVENT, "all-event-masks");
+ PrintField(buf, 36, 4, SETofEVENT, "your-event-mask");
+ PrintField(buf, 40, 2, SETofDEVICEEVENT, "do-not-propagate-mask");
+}
+
+DestroyWindow(buf)
+ unsigned char *buf;
+{
+ /* Request DestroyWindow is opcode 4 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DestroyWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+DestroySubwindows(buf)
+ unsigned char *buf;
+{
+ /* Request DestroySubwindows is opcode 5 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DestroySubwindows */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+ChangeSaveSet(buf)
+ unsigned char *buf;
+{
+ /* Request ChangeSaveSet is opcode 6 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeSaveSet */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, INS_DEL, "mode");
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+ReparentWindow(buf)
+ unsigned char *buf;
+{
+ /* Request ReparentWindow is opcode 7 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ReparentWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, WINDOW, "parent");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+}
+
+MapWindow(buf)
+ unsigned char *buf;
+{
+ /* Request MapWindow is opcode 8 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* MapWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+MapSubwindows(buf)
+ unsigned char *buf;
+{
+ /* Request MapSubwindows is opcode 9 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* MapSubwindows */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+UnmapWindow(buf)
+ unsigned char *buf;
+{
+ /* Request UnmapWindow is opcode 10 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UnmapWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+UnmapSubwindows(buf)
+ unsigned char *buf;
+{
+ /* Request UnmapSubwindows is opcode 11 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UnmapSubwindows */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+ConfigureWindow(buf)
+ unsigned char *buf;
+{
+ /* Request ConfigureWindow is opcode 12 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ConfigureWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 2, CONFIGURE_BITMASK, "value-mask");
+ PrintValues(&buf[8], 2, CONFIGURE_BITMASK, &buf[12], "value-list");
+}
+
+CirculateWindow(buf)
+ unsigned char *buf;
+{
+ /* Request CirculateWindow is opcode 13 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CirculateWindow */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, CIRMODE, "direction");
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+GetGeometry(buf)
+ unsigned char *buf;
+{
+ /* Request GetGeometry is opcode 14 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetGeometry */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+}
+
+GetGeometryReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetGeometry */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, CARD8, "depth");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintField(buf, 16, 2, CARD16, "width");
+ PrintField(buf, 18, 2, CARD16, "height");
+ PrintField(buf, 20, 2, CARD16, "border-width");
+}
+
+QueryTree(buf)
+ unsigned char *buf;
+{
+ /* Request QueryTree is opcode 15 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryTree */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+QueryTreeReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTree */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n), "reply length");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "parent");
+ printfield(buf, 16, 2, DVALUE2(n), "number of children");
+ n = IShort(&buf[16]);
+ (void)PrintList(&buf[32], (long)n, WINDOW, "children");
+}
+
+InternAtom(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request InternAtom is opcode 16 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* InternAtom */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "only-if-exists");
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ printfield(buf, 4, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[4]);
+ PrintString8(&buf[8], (long)n, "name");
+}
+
+InternAtomReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* InternAtom */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, ATOM, "atom");
+}
+
+GetAtomName(buf)
+ unsigned char *buf;
+{
+ /* Request GetAtomName is opcode 17 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetAtomName */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, ATOM, "atom");
+}
+
+GetAtomNameReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetAtomName */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[8]);
+ PrintString8(&buf[32], (long)n, "name");
+}
+
+ChangeProperty(buf)
+ unsigned char *buf;
+{
+ long n;
+ short format;
+ long type;
+
+ /* Request ChangeProperty is opcode 18 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeProperty */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, CHANGEMODE, "mode");
+ printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, ATOM, "property");
+ PrintField(buf, 12, 4, ATOM, "type");
+ type = ILong(&buf[12]);
+ PrintField(buf, 16, 1, CARD8, "format");
+ format = IByte(&buf[16]);
+ printfield(buf, 20, 4, CARD32, "length of data");
+ n = ILong(&buf[20]);
+ if (type == 31 /* string */)
+ PrintString8(&buf[24], n * format/8, "data");
+ else if (format == 16)
+ (void)PrintList(&buf[24], n, INT16, "data");
+ else if (format == 32)
+ (void)PrintList(&buf[24], n, INT32, "data");
+ else
+ PrintBytes(&buf[24], n * format/8, "data");
+}
+
+DeleteProperty(buf)
+ unsigned char *buf;
+{
+ /* Request DeleteProperty is opcode 19 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DeleteProperty */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, ATOM, "property");
+}
+
+GetProperty(buf)
+ unsigned char *buf;
+{
+ /* Request GetProperty is opcode 20 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetProperty */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "delete");
+ printfield(buf, 2, 2, CONST2(6), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, ATOM, "property");
+ PrintField(buf, 12, 4, ATOMT, "type");
+ PrintField(buf, 16, 4, CARD32, "long-offset");
+ printfield(buf, 20, 4, CARD32, "long-length");
+}
+
+GetPropertyReply(buf)
+ unsigned char *buf;
+{
+ long n;
+ short format;
+ long type;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetProperty */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, CARD8, "format");
+ format = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ PrintField(buf, 8, 4, ATOM, "type");
+ type = ILong(&buf[8]);
+ PrintField(buf, 12, 4, CARD32, "bytes-after");
+ printfield(buf, 16, 4, CARD32, "length of value");
+ n = ILong(&buf[16]);
+ if (type == 31 /* string */)
+ PrintString8(&buf[32], n * format/8, "value");
+ else if (format == 16)
+ (void)PrintList(&buf[32], n, INT16, "value");
+ else if (format == 32)
+ (void)PrintList(&buf[32], n, INT32, "value");
+ else
+ PrintBytes(&buf[32], n * format/8, "value");
+}
+
+ListProperties(buf)
+ unsigned char *buf;
+{
+ /* Request ListProperties is opcode 21 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListProperties */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+ListPropertiesReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListProperties */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "number of atoms");
+ n = IShort(&buf[8]);
+ (void)PrintList(&buf[32], (long)n, ATOM, "atoms");
+}
+
+SetSelectionOwner(buf)
+ unsigned char *buf;
+{
+ /* Request SetSelectionOwner is opcode 22 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetSelectionOwner */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "owner");
+ PrintField(buf, 8, 4, ATOM, "selection");
+ PrintField(buf, 12, 4, TIMESTAMP, "time");
+}
+
+GetSelectionOwner(buf)
+ unsigned char *buf;
+{
+ /* Request GetSelectionOwner is opcode 23 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetSelectionOwner */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, ATOM, "selection");
+}
+
+GetSelectionOwnerReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetSelectionOwner */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, WINDOW, "owner");
+}
+
+ConvertSelection(buf)
+ unsigned char *buf;
+{
+ /* Request ConvertSelection is opcode 24 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ConvertSelection */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(6), "request length");
+ PrintField(buf, 4, 4, WINDOW, "requestor");
+ PrintField(buf, 8, 4, ATOM, "selection");
+ PrintField(buf, 12, 4, ATOM, "target");
+ PrintField(buf, 16, 4, ATOM, "property");
+ PrintField(buf, 20, 4, TIMESTAMP, "time");
+}
+
+SendEvent(buf)
+ unsigned char *buf;
+{
+ /* Request SendEvent is opcode 25 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SendEvent */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "propagate");
+ printfield(buf, 2, 2, CONST2(11), "request length");
+ PrintField(buf, 4, 4, WINDOWD, "destination");
+ PrintField(buf, 8, 4, SETofEVENT, "event-mask");
+ PrintField(buf, 12, 32, EVENTFORM, "event");
+}
+
+GrabPointer(buf)
+ unsigned char *buf;
+{
+ /* Request GrabPointer is opcode 26 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabPointer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "owner-events");
+ printfield(buf, 2, 2, CONST2(6), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask");
+ PrintField(buf, 10, 1, PK_MODE, "pointer-mode");
+ PrintField(buf, 11, 1, PK_MODE, "keyboard-mode");
+ PrintField(buf, 12, 4, WINDOW, "confine-to");
+ PrintField(buf, 16, 4, CURSOR, "cursor");
+ PrintField(buf, 20, 4, TIMESTAMP, "time");
+}
+
+GrabPointerReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GrabPointer */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, GRABSTAT, "status");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+}
+
+UngrabPointer(buf)
+ unsigned char *buf;
+{
+ /* Request UngrabPointer is opcode 27 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabPointer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+}
+
+GrabButton(buf)
+ unsigned char *buf;
+{
+ /* Request GrabButton is opcode 28 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabButton */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "owner-events");
+ printfield(buf, 2, 2, CONST2(6), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask");
+ PrintField(buf, 10, 1, PK_MODE, "pointer-mode");
+ PrintField(buf, 11, 1, PK_MODE, "keyboard-mode");
+ PrintField(buf, 12, 4, WINDOW, "confine-to");
+ PrintField(buf, 16, 4, CURSOR, "cursor");
+ PrintField(buf, 20, 1, BUTTONA, "button");
+ PrintField(buf, 22, 2, SETofKEYMASK, "modifiers");
+}
+
+UngrabButton(buf)
+ unsigned char *buf;
+{
+ /* Request UngrabButton is opcode 29 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabButton */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BUTTONA, "button");
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
+}
+
+ChangeActivePointerGrab(buf)
+ unsigned char *buf;
+{
+ /* Request ChangeActivePointerGrab is opcode 30 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeActivePointerGrab */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, CURSOR, "cursor");
+ PrintField(buf, 8, 4, TIMESTAMP, "time");
+ PrintField(buf, 12, 2, SETofPOINTEREVENT, "event-mask");
+}
+
+GrabKeyboard(buf)
+ unsigned char *buf;
+{
+ /* Request GrabKeyboard is opcode 31 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabKeyboard */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "owner-events");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 4, TIMESTAMP, "time");
+ PrintField(buf, 12, 1, PK_MODE, "pointer-mode");
+ PrintField(buf, 13, 1, PK_MODE, "keyboard-mode");
+}
+
+GrabKeyboardReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GrabKeyboard */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, GRABSTAT, "status");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+}
+
+UngrabKeyboard(buf)
+ unsigned char *buf;
+{
+ /* Request UngrabKeyboard is opcode 32 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabKeyboard */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+}
+
+GrabKey(buf)
+ unsigned char *buf;
+{
+ /* Request GrabKey is opcode 33 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabKey */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "owner-events");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
+ PrintField(buf, 10, 1, KEYCODEA, "key");
+ PrintField(buf, 11, 1, PK_MODE, "pointer-mode");
+ PrintField(buf, 12, 1, PK_MODE, "keyboard-mode");
+}
+
+UngrabKey(buf)
+ unsigned char *buf;
+{
+ /* Request UngrabKey is opcode 34 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabKey */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, KEYCODEA, "key");
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, WINDOW, "grab-window");
+ PrintField(buf, 8, 2, SETofKEYMASK, "modifiers");
+}
+
+AllowEvents(buf)
+ unsigned char *buf;
+{
+ /* Request AllowEvents is opcode 35 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllowEvents */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, EVENTMODE, "mode");
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+}
+
+GrabServer(buf)
+ unsigned char *buf;
+{
+ /* Request GrabServer is opcode 36 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabServer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+UngrabServer(buf)
+ unsigned char *buf;
+{
+ /* Request UngrabServer is opcode 37 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabServer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+QueryPointer(buf)
+ unsigned char *buf;
+{
+ /* Request QueryPointer is opcode 38 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryPointer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+QueryPointerReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryPointer */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BOOL, "same-screen");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, WINDOW, "root");
+ PrintField(buf, 12, 4, WINDOW, "child");
+ PrintField(buf, 16, 2, INT16, "root-x");
+ PrintField(buf, 18, 2, INT16, "root-y");
+ PrintField(buf, 20, 2, INT16, "win-x");
+ PrintField(buf, 22, 2, INT16, "win-y");
+ PrintField(buf, 24, 2, SETofKEYBUTMASK, "mask");
+}
+
+GetMotionEvents(buf)
+ unsigned char *buf;
+{
+ /* Request GetMotionEvents is opcode 39 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetMotionEvents */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 4, TIMESTAMP, "start");
+ PrintField(buf, 12, 4, TIMESTAMP, "stop");
+}
+
+GetMotionEventsReply(buf)
+ unsigned char *buf;
+{
+ long n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetMotionEvents */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
+ printfield(buf, 8, 4, DVALUE4(n), "number of events");
+ n = ILong(&buf[8]);
+ (void)PrintList(&buf[32], n, TIMECOORD, "events");
+}
+
+TranslateCoordinates(buf)
+ unsigned char *buf;
+{
+ /* Request TranslateCoordinates is opcode 40 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* TranslateCoordinates */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "src-window");
+ PrintField(buf, 8, 4, WINDOW, "dst-window");
+ PrintField(buf, 12, 2, INT16, "src-x");
+ PrintField(buf, 14, 2, INT16, "src-y");
+}
+
+TranslateCoordinatesReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* TranslateCoordinates */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BOOL, "same-screen");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, WINDOW, "child");
+ PrintField(buf, 12, 2, INT16, "dst-x");
+ PrintField(buf, 14, 2, INT16, "dst-y");
+}
+
+WarpPointer(buf)
+ unsigned char *buf;
+{
+ /* Request WarpPointer is opcode 41 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* WarpPointer */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(6), "request length");
+ PrintField(buf, 4, 4, WINDOW, "src-window");
+ PrintField(buf, 8, 4, WINDOW, "dst-window");
+ PrintField(buf, 12, 2, INT16, "src-x");
+ PrintField(buf, 14, 2, INT16, "src-y");
+ PrintField(buf, 16, 2, CARD16, "src-width");
+ PrintField(buf, 18, 2, CARD16, "src-height");
+ PrintField(buf, 20, 2, INT16, "dst-x");
+ PrintField(buf, 22, 2, INT16, "dst-y");
+}
+
+SetInputFocus(buf)
+ unsigned char *buf;
+{
+ /* Request SetInputFocus is opcode 42 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetInputFocus */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, WINDOWNR, "focus");
+ PrintField(buf, 8, 4, TIMESTAMP, "time");
+}
+
+GetInputFocus(buf)
+ unsigned char *buf;
+{
+ /* Request GetInputFocus is opcode 43 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetInputFocus */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetInputFocusReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetInputFocus */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, WINDOWNR, "focus");
+}
+
+QueryKeymap(buf)
+ unsigned char *buf;
+{
+ /* Request QueryKeymap is opcode 44 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryKeymap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+QueryKeymapReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryKeymap */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(2), "reply length");
+ PrintBytes(&buf[8], 32L, "keys");
+}
+
+OpenFont(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request OpenFont is opcode 45 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* OpenFont */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, FONT, "font-id");
+ printfield(buf, 8, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[8]);
+ PrintString8(&buf[12], (long)n, "name");
+}
+
+CloseFont(buf)
+ unsigned char *buf;
+{
+ /* Request CloseFont is opcode 46 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CloseFont */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, FONT, "font");
+}
+
+QueryFont(buf)
+ unsigned char *buf;
+{
+ /* Request QueryFont is opcode 47 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryFont */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, FONTABLE, "font");
+}
+
+QueryFontReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryFont */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(7 + 2*n + 3*m), "reply length");
+ PrintField(buf, 8, 12, CHARINFO, "min-bounds");
+ PrintField(buf, 24, 12, CHARINFO, "max-bounds");
+ PrintField(buf, 40, 2, CARD16, "min-char-or-byte2");
+ PrintField(buf, 42, 2, CARD16, "max-char-or-byte2");
+ PrintField(buf, 44, 2, CARD16, "default-char");
+ printfield(buf, 46, 2, DVALUE2(n), "number of FONTPROPs");
+ n = IShort(&buf[46]);
+ PrintField(buf, 48, 1, DIRECT, "draw-direction");
+ PrintField(buf, 49, 1, CARD8, "min-byte1");
+ PrintField(buf, 50, 1, CARD8, "max-byte1");
+ PrintField(buf, 51, 1, BOOL, "all-chars-exist");
+ PrintField(buf, 52, 2, INT16, "font-ascent");
+ PrintField(buf, 54, 2, INT16, "font-descent");
+ printfield(buf, 56, 4, DVALUE4(m), "number of CHARINFOs");
+ m = ILong(&buf[56]);
+ k = PrintList(&buf[60], (long)n, FONTPROP, "properties");
+ (void)PrintList(&buf[60 + k], (long)m, CHARINFO, "char-infos");
+}
+
+QueryTextExtents(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request QueryTextExtents is opcode 48 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryTextExtents */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 1, 1, BOOL, "odd length?");
+ printfield(buf, 2, 2, DVALUE2(2 + (2*n + p) / 4), "request length");
+ n = (IShort(&buf[2]) - 2) * 4 / 2;
+ if (IBool(&buf[1]))
+ n -= 1;
+ PrintField(buf, 4, 4, FONTABLE, "font");
+ PrintString16(&buf[8], (long)n, "string");
+}
+
+QueryTextExtentsReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTextExtents */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, DIRECT, "draw-direction");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, INT16, "font-ascent");
+ PrintField(buf, 10, 2, INT16, "font-descent");
+ PrintField(buf, 12, 2, INT16, "overall-ascent");
+ PrintField(buf, 14, 2, INT16, "overall-descent");
+ PrintField(buf, 16, 4, INT32, "overall-width");
+ PrintField(buf, 20, 4, INT32, "overall-left");
+ PrintField(buf, 24, 4, INT32, "overall-right");
+}
+
+ListFonts(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request ListFonts is opcode 49 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListFonts */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 2, CARD16, "max-names");
+ printfield(buf, 6, 2, DVALUE2(n), "length of pattern");
+ n = IShort(&buf[6]);
+ PrintString8(&buf[8], (long)n, "pattern");
+}
+
+ListFontsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListFonts */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ printfield(buf, 8, 2, CARD16, "number of names");
+ n = IShort(&buf[8]);
+ PrintListSTR(&buf[32], (long)n, "names");
+}
+
+ListFontsWithInfo(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request ListFontsWithInfo is opcode 50 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListFontsWithInfo */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 2, CARD16, "max-names");
+ printfield(buf, 6, 2, DVALUE2(n), "length of pattern");
+ n = IShort(&buf[6]);
+ PrintString8(&buf[8], (long)n, "pattern");
+}
+
+ListFontsWithInfoReply(buf)
+ unsigned char *buf;
+{
+ short which;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListFontsWithInfo */ ;
+ if (Verbose < 1) return;
+ which = IByte(&buf[1]);
+ if (which != 0)
+ {
+ ListFontsWithInfoReply1(buf);
+ KeepLastReplyExpected();
+ }
+ else
+ ListFontsWithInfoReply2(buf);
+}
+
+ListFontsWithInfoReply1(buf)
+ unsigned char *buf;
+{
+ short n;
+ short m;
+ printfield(buf, 1, 1, DVALUE1(n), "length of name in bytes");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(7 + 2*m + (n + p) / 4), "reply length");
+ PrintField(buf, 8, 12, CHARINFO, "min-bounds");
+ PrintField(buf, 24, 12, CHARINFO, "max-bounds");
+ PrintField(buf, 40, 2, CARD16, "min-char-or-byte2");
+ PrintField(buf, 42, 2, CARD16, "max-char-or-byte2");
+ PrintField(buf, 44, 2, CARD16, "default-char");
+ printfield(buf, 46, 2, DVALUE2(m), "number of FONTPROPs");
+ m = IShort(&buf[46]);
+ PrintField(buf, 48, 1, DIRECT, "draw-direction");
+ PrintField(buf, 49, 1, CARD8, "min-byte1");
+ PrintField(buf, 50, 1, CARD8, "max-byte1");
+ PrintField(buf, 51, 1, BOOL, "all-chars-exist");
+ PrintField(buf, 52, 2, INT16, "font-ascent");
+ PrintField(buf, 54, 2, INT16, "font-descent");
+ PrintField(buf, 56, 4, CARD32, "replies-hint");
+ (void)PrintList(&buf[60], (long)m, FONTPROP, "properties");
+ PrintString8(&buf[60 + 8 * m], (long)n, "name");
+}
+
+ListFontsWithInfoReply2(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, CONST1(0), "last-reply indicator");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(7), "reply length");
+}
+
+SetFontPath(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request SetFontPath is opcode 51 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetFontPath */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ printfield(buf, 4, 2, CARD16, "number of paths");
+ n = IShort(&buf[4]);
+ PrintListSTR(&buf[8], (long)n, "paths");
+}
+
+GetFontPath(buf)
+ unsigned char *buf;
+{
+ /* Request GetFontPath is opcode 52 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetFontPath */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 2, 2, CONST2(1), "request list");
+}
+
+GetFontPathReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetFontPath */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ printfield(buf, 8, 2, CARD16, "number of paths");
+ n = IShort(&buf[8]);
+ PrintListSTR(&buf[32], (long)n, "paths");
+}
+
+CreatePixmap(buf)
+ unsigned char *buf;
+{
+ /* Request CreatePixmap is opcode 53 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreatePixmap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, CARD8, "depth");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, PIXMAP, "pixmap-id");
+ PrintField(buf, 8, 4, DRAWABLE, "drawable");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+}
+
+FreePixmap(buf)
+ unsigned char *buf;
+{
+ /* Request FreePixmap is opcode 54 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreePixmap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, PIXMAP, "pixmap");
+}
+
+CreateGC(buf)
+ unsigned char *buf;
+{
+ /* Request CreateGC is opcode 55 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateGC */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(4 + n), "request length");
+ PrintField(buf, 4, 4, GCONTEXT, "graphic-context-id");
+ PrintField(buf, 8, 4, DRAWABLE, "drawable");
+ PrintField(buf, 12, 4, GC_BITMASK, "value-mask");
+ PrintValues(&buf[12], 4, GC_BITMASK, &buf[16], "value-list");
+}
+
+ChangeGC(buf)
+ unsigned char *buf;
+{
+ /* Request ChangeGC is opcode 56 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeGC */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ PrintField(buf, 4, 4, GCONTEXT, "gc");
+ PrintField(buf, 8, 4, GC_BITMASK, "value-mask");
+ PrintValues(&buf[8], 4, GC_BITMASK, &buf[12], "value-list");
+}
+
+CopyGC(buf)
+ unsigned char *buf;
+{
+ /* Request CopyGC is opcode 57 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyGC */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, GCONTEXT, "src-gc");
+ PrintField(buf, 8, 4, GCONTEXT, "dst-gc");
+ PrintField(buf, 12, 4, GC_BITMASK, "value-mask");
+}
+
+SetDashes(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request SetDashes is opcode 58 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetDashes */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, GCONTEXT, "gc");
+ PrintField(buf, 8, 2, CARD16, "dash-offset");
+ printfield(buf, 10, 2, DVALUE2(n), "length of dashes");
+ n = IShort(&buf[10]);
+ PrintBytes(&buf[12], (long)n, "dashes");
+}
+
+SetClipRectangles(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request SetClipRectangles is opcode 59 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetClipRectangles */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, RECTORDER, "ordering");
+ printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 2;
+ PrintField(buf, 4, 4, GCONTEXT, "gc");
+ PrintField(buf, 8, 2, INT16, "clip-x-origin");
+ PrintField(buf, 10, 2, INT16, "clip-y-origin");
+ (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles");
+}
+
+FreeGC(buf)
+ unsigned char *buf;
+{
+ /* Request FreeGC is opcode 60 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeGC */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, GCONTEXT, "gc");
+}
+
+ClearArea(buf)
+ unsigned char *buf;
+{
+ /* Request ClearArea is opcode 61 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ClearArea */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "exposures");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 2, INT16, "x");
+ PrintField(buf, 10, 2, INT16, "y");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+}
+
+CopyArea(buf)
+ unsigned char *buf;
+{
+ /* Request CopyArea is opcode 62 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyArea */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(7), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "src-drawable");
+ PrintField(buf, 8, 4, DRAWABLE, "dst-drawable");
+ PrintField(buf, 12, 4, GCONTEXT, "gc");
+ PrintField(buf, 16, 2, INT16, "src-x");
+ PrintField(buf, 18, 2, INT16, "src-y");
+ PrintField(buf, 20, 2, INT16, "dst-x");
+ PrintField(buf, 22, 2, INT16, "dst-y");
+ PrintField(buf, 24, 2, CARD16, "width");
+ PrintField(buf, 26, 2, CARD16, "height");
+}
+
+CopyPlane(buf)
+ unsigned char *buf;
+{
+ /* Request CopyPlane is opcode 63 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyPlane */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(8), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "src-drawable");
+ PrintField(buf, 8, 4, DRAWABLE, "dst-drawable");
+ PrintField(buf, 12, 4, GCONTEXT, "gc");
+ PrintField(buf, 16, 2, INT16, "src-x");
+ PrintField(buf, 18, 2, INT16, "src-y");
+ PrintField(buf, 20, 2, INT16, "dst-x");
+ PrintField(buf, 22, 2, INT16, "dst-y");
+ PrintField(buf, 24, 2, CARD16, "width");
+ PrintField(buf, 26, 2, CARD16, "height");
+ PrintField(buf, 28, 4, CARD32, "bit-plane");
+}
+
+PolyPoint(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyPoint is opcode 64 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyPoint */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, COORMODE, "coordinate-mode");
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ n = (IShort(&buf[2]) - 3);
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, POINT, "points");
+}
+
+PolyLine(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyLine is opcode 65 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyLine */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, COORMODE, "coordinate-mode");
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ n = (IShort(&buf[2]) - 3);
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, POINT, "points");
+}
+
+PolySegment(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolySegment is opcode 66 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolySegment */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 2;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, SEGMENT, "segments");
+}
+
+PolyRectangle(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyRectangle is opcode 67 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyRectangle */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 2;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles");
+}
+
+PolyArc(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyArc is opcode 68 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyArc */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + 3*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 3;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, ARC, "arcs");
+}
+
+FillPoly(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request FillPoly is opcode 69 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FillPoly */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(4 + n), "request length");
+ n = (IShort(&buf[2]) - 4);
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 1, POLYSHAPE, "shape");
+ PrintField(buf, 13, 1, COORMODE, "coordinate-mode");
+ (void)PrintList(&buf[16], (long)n, POINT, "points");
+}
+
+PolyFillRectangle(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyFillRectangle is opcode 70 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyFillRectangle */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 2;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles");
+}
+
+PolyFillArc(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PolyFillArc is opcode 71 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyFillArc */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + 3*n), "request length");
+ n = (IShort(&buf[2]) - 3) / 3;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ (void)PrintList(&buf[12], (long)n, ARC, "arcs");
+}
+
+PutImage(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request PutImage is opcode 72 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PutImage */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, IMAGEMODE, "format");
+ printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length");
+
+ /* the size of the Image is overestimated by the following computation of n,
+ because we ignore that padding of the request to a multiple of 4 bytes.
+ The image may not be a multiple of 4 bytes. The actual size of the image
+ is determined as follows: for format = Bitmap or format = XYPixmap, the
+ size is (left-pad + width) [ pad to multiple of bitmap-scanline-pad from
+ SetUpReply ] divide by 8 to get bytes times height times depth for format
+ = ZPixmap, take the depth and use it to find the bits-per-pixel and
+ scanline-pad given in one of the SetUpReply DEPTH records. width *
+ bits-per-pixel pad to multiple of scanline-pad divide by 8 to get bytes
+ times height times depth For simplicity, we ignore all this and just use
+ the request length to (over)estimate the size of the image */
+
+ n = (IShort(&buf[2]) - 6) * 4;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+ PrintField(buf, 16, 2, INT16, "dst-x");
+ PrintField(buf, 18, 2, INT16, "dst-y");
+ PrintField(buf, 20, 1, CARD8, "left-pad");
+ PrintField(buf, 21, 1, CARD8, "depth");
+ PrintBytes(&buf[24], (long)n, "data");
+}
+
+GetImage(buf)
+ unsigned char *buf;
+{
+ /* Request GetImage is opcode 73 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetImage */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, IMAGEMODE, "format");
+ printfield(buf, 2, 2, CONST2(5), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 2, INT16, "x");
+ PrintField(buf, 10, 2, INT16, "y");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+ PrintField(buf, 16, 4, CARD32, "plane-mask");
+}
+
+GetImageReply(buf)
+ unsigned char *buf;
+{
+ long n;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetImage */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, CARD8, "depth");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+
+ /* to properly compute the actual size of the image, we have to remember the
+ width and height values from the request. Again, we (over)estimate its
+ length from the length of the reply */
+ n = ILong(&buf[4]) * 4;
+ PrintField(buf, 8, 4, VISUALID, "visual");
+ PrintBytes(&buf[32], n, "data");
+}
+
+PolyText8(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request PolyText8 is opcode 74 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyText8 */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length");
+ n = (IShort(&buf[2]) - 4) * 4;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintTextList8(&buf[16], n, "items");
+}
+
+PolyText16(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request PolyText16 is opcode 75 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyText16 */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length");
+ n = (IShort(&buf[2]) - 4) * 4;
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintTextList16(&buf[16], n, "items");
+}
+
+ImageText8(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request ImageText8 is opcode 76 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ImageText8 */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 1, 1, DVALUE1(n), "length of string");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintString8(&buf[16], (long)n, "string");
+}
+
+ImageText16(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request ImageText16 is opcode 77 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ImageText16 */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 1, 1, DVALUE1(n), "length of string");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, DVALUE2(4 + (2*n + p) / 4), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ PrintField(buf, 12, 2, INT16, "x");
+ PrintField(buf, 14, 2, INT16, "y");
+ PrintString16(&buf[16], (long)n, "string");
+}
+
+CreateColormap(buf)
+ unsigned char *buf;
+{
+ /* Request CreateColormap is opcode 78 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateColormap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, ALLORNONE, "alloc");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "color-map-id");
+ PrintField(buf, 8, 4, WINDOW, "window");
+ PrintField(buf, 12, 4, VISUALID, "visual");
+}
+
+FreeColormap(buf)
+ unsigned char *buf;
+{
+ /* Request FreeColormap is opcode 79 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeColormap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+}
+
+CopyColormapAndFree(buf)
+ unsigned char *buf;
+{
+ /* Request CopyColormapAndFree is opcode 80 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyColormapAndFree */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "color-map-id");
+ PrintField(buf, 8, 4, COLORMAP, "src-cmap");
+}
+
+InstallColormap(buf)
+ unsigned char *buf;
+{
+ /* Request InstallColormap is opcode 81 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* InstallColormap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+}
+
+UninstallColormap(buf)
+ unsigned char *buf;
+{
+ /* Request UninstallColormap is opcode 82 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UninstallColormap */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+}
+
+ListInstalledColormaps(buf)
+ unsigned char *buf;
+{
+ /* Request ListInstalledColormaps is opcode 83 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListInstalledColormaps */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+ListInstalledColormapsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListInstalledColormaps */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "number of cmaps");
+ n = IShort(&buf[8]);
+ (void)PrintList(&buf[32], (long)n, COLORMAP, "cmaps");
+}
+
+AllocColor(buf)
+ unsigned char *buf;
+{
+ /* Request AllocColor is opcode 84 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ PrintField(buf, 8, 2, CARD16, "red");
+ PrintField(buf, 10, 2, CARD16, "green");
+ PrintField(buf, 12, 2, CARD16, "blue");
+}
+
+AllocColorReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColor */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "red");
+ PrintField(buf, 10, 2, CARD16, "green");
+ PrintField(buf, 12, 2, CARD16, "blue");
+ PrintField(buf, 16, 4, CARD32, "pixel");
+}
+
+AllocNamedColor(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request AllocNamedColor is opcode 85 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocNamedColor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ printfield(buf, 8, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[8]);
+ PrintString8(&buf[12], (long)n, "name");
+}
+
+AllocNamedColorReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocNamedColor */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 4, CARD32, "pixel");
+ PrintField(buf, 12, 2, CARD16, "exact-red");
+ PrintField(buf, 14, 2, CARD16, "exact-green");
+ PrintField(buf, 16, 2, CARD16, "exact-blue");
+ PrintField(buf, 18, 2, CARD16, "visual-red");
+ PrintField(buf, 20, 2, CARD16, "visual-green");
+ PrintField(buf, 22, 2, CARD16, "visual-blue");
+}
+
+AllocColorCells(buf)
+ unsigned char *buf;
+{
+ /* Request AllocColorCells is opcode 86 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColorCells */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "contiguous");
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ PrintField(buf, 8, 2, CARD16, "colors");
+ PrintField(buf, 10, 2, CARD16, "planes");
+}
+
+AllocColorCellsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ short m;
+ short k;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorCells */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n + m), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
+ n = IShort(&buf[8]);
+ printfield(buf, 10, 2, DVALUE2(m), "number of masks");
+ m = IShort(&buf[10]);
+ k = PrintList(&buf[32], (long)n, CARD32, "pixels");
+ (void)PrintList(&buf[32 + k], (long)m, CARD32, "masks");
+}
+
+AllocColorPlanes(buf)
+ unsigned char *buf;
+{
+ /* Request AllocColorPlanes is opcode 87 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColorPlanes */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, BOOL, "contiguous");
+ printfield(buf, 2, 2, CONST2(4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ PrintField(buf, 8, 2, CARD16, "colors");
+ PrintField(buf, 10, 2, CARD16, "reds");
+ PrintField(buf, 12, 2, CARD16, "greens");
+ PrintField(buf, 14, 2, CARD16, "blues");
+}
+
+AllocColorPlanesReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorPlanes */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
+ n = IShort(&buf[8]);
+ PrintField(buf, 12, 4, CARD32, "red-mask");
+ PrintField(buf, 16, 4, CARD32, "green-mask");
+ PrintField(buf, 20, 4, CARD32, "blue-mask");
+ (void)PrintList(&buf[32], (long)n, CARD32, "pixels");
+}
+
+FreeColors(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ /* Request FreeColors is opcode 88 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeColors */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ n = IShort(&buf[2]) - 3;
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ PrintField(buf, 8, 4, CARD32, "plane-mask");
+ (void)PrintList(&buf[12], (long)n, CARD32, "pixels");
+}
+
+StoreColors(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request StoreColors is opcode 89 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* StoreColors */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + 3*n), "request length");
+ n = (IShort(&buf[2]) - 2) / 3;
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ (void)PrintList(&buf[8], (long)n, COLORITEM, "items");
+}
+
+StoreNamedColor(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request StoreNamedColor is opcode 90 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* StoreNamedColor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, COLORMASK, "which colors?");
+ printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ PrintField(buf, 8, 4, CARD32, "pixel");
+ printfield(buf, 12, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[12]);
+ PrintString8(&buf[16], (long)n, "name");
+}
+
+QueryColors(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request QueryColors is opcode 91 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryColors */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + n), "request length");
+ n = IShort(&buf[2]) - 2;
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ (void)PrintList(&buf[8], (long)n, CARD32, "pixels");
+}
+
+QueryColorsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryColors */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
+ printfield(buf, 8, 2, DVALUE2(n), "number of colors");
+ n = IShort(&buf[8]);
+ (void)PrintList(&buf[32], (long)n, RGB, "colors");
+}
+
+LookupColor(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request LookupColor is opcode 92 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* LookupColor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, COLORMAP, "cmap");
+ printfield(buf, 8, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[8]);
+ PrintString8(&buf[12], (long)n, "name");
+}
+
+LookupColorReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LookupColor */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "exact-red");
+ PrintField(buf, 10, 2, CARD16, "exact-green");
+ PrintField(buf, 12, 2, CARD16, "exact-blue");
+ PrintField(buf, 14, 2, CARD16, "visual-red");
+ PrintField(buf, 16, 2, CARD16, "visual-green");
+ PrintField(buf, 18, 2, CARD16, "visual-blue");
+}
+
+CreateCursor(buf)
+ unsigned char *buf;
+{
+ /* Request CreateCursor is opcode 93 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateCursor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(8), "request length");
+ PrintField(buf, 4, 4, CURSOR, "cursor-id");
+ PrintField(buf, 8, 4, PIXMAP, "source");
+ PrintField(buf, 12, 4, PIXMAP, "mask");
+ PrintField(buf, 16, 2, CARD16, "fore-red");
+ PrintField(buf, 18, 2, CARD16, "fore-green");
+ PrintField(buf, 20, 2, CARD16, "fore-blue");
+ PrintField(buf, 22, 2, CARD16, "back-red");
+ PrintField(buf, 24, 2, CARD16, "back-green");
+ PrintField(buf, 26, 2, CARD16, "back-blue");
+ PrintField(buf, 28, 2, CARD16, "x");
+ PrintField(buf, 30, 2, CARD16, "y");
+}
+
+CreateGlyphCursor(buf)
+ unsigned char *buf;
+{
+ /* Request CreateGlyphCursor is opcode 94 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateGlyphCursor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(8), "request length");
+ PrintField(buf, 4, 4, CURSOR, "cursor-id");
+ PrintField(buf, 8, 4, FONT, "source-font");
+ PrintField(buf, 12, 4, FONT, "mask-font");
+ PrintField(buf, 16, 2, CARD16, "source-char");
+ PrintField(buf, 18, 2, CARD16, "mask-char");
+ PrintField(buf, 20, 2, CARD16, "fore-red");
+ PrintField(buf, 22, 2, CARD16, "fore-green");
+ PrintField(buf, 24, 2, CARD16, "fore-blue");
+ PrintField(buf, 26, 2, CARD16, "back-red");
+ PrintField(buf, 28, 2, CARD16, "back-green");
+ PrintField(buf, 30, 2, CARD16, "back-blue");
+}
+
+FreeCursor(buf)
+ unsigned char *buf;
+{
+ /* Request FreeCursor is opcode 95 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeCursor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, CURSOR, "cursor");
+}
+
+RecolorCursor(buf)
+ unsigned char *buf;
+{
+ /* Request RecolorCursor is opcode 96 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* RecolorCursor */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(5), "request length");
+ PrintField(buf, 4, 4, CURSOR, "cursor");
+ PrintField(buf, 8, 2, CARD16, "fore-red");
+ PrintField(buf, 10, 2, CARD16, "fore-green");
+ PrintField(buf, 12, 2, CARD16, "fore-blue");
+ PrintField(buf, 14, 2, CARD16, "back-red");
+ PrintField(buf, 16, 2, CARD16, "back-green");
+ PrintField(buf, 18, 2, CARD16, "back-blue");
+}
+
+QueryBestSize(buf)
+ unsigned char *buf;
+{
+ /* Request QueryBestSize is opcode 97 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryBestSize */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, OBJECTCLASS, "class");
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 2, CARD16, "width");
+ PrintField(buf, 10, 2, CARD16, "height");
+}
+
+QueryBestSizeReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryBestSize */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "width");
+ PrintField(buf, 10, 2, CARD16, "height");
+}
+
+QueryExtension(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request QueryExtension is opcode 98 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryExtension */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ printfield(buf, 4, 2, DVALUE2(n), "length of name");
+ n = IShort(&buf[4]);
+ PrintString8(&buf[8], (long)n, "name");
+}
+
+QueryExtensionReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryExtension */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 1, BOOL, "present");
+ PrintField(buf, 9, 1, CARD8, "major-opcode");
+ PrintField(buf, 10, 1, CARD8, "first-event");
+ PrintField(buf, 11, 1, CARD8, "first-error");
+}
+
+ListExtensions(buf)
+ unsigned char *buf;
+{
+ /* Request ListExtensions is opcode 99 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListExtensions */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+ListExtensionsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListExtensions */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 1, 1, CARD8, "number names");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ PrintListSTR(&buf[32], (long)n, "names");
+}
+
+ChangeKeyboardMapping(buf)
+ unsigned char *buf;
+{
+ short n;
+ short m;
+ /* Request ChangeKeyboardMapping is opcode 100 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeKeyboardMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, DVALUE1(n), "keycode-count");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, DVALUE2(2 + nm), "request length");
+ PrintField(buf, 4, 1, KEYCODE, "first-keycode");
+ PrintField(buf, 5, 1, DVALUE1(m), "keysyms-per-keycode");
+ m = IByte(&buf[5]);
+ (void)PrintList(&buf[8], (long)(n * m), KEYSYM, "keysyms");
+}
+
+GetKeyboardMapping(buf)
+ unsigned char *buf;
+{
+ /* Request GetKeyboardMapping is opcode 101 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetKeyboardMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 1, KEYCODE, "first-keycode");
+ PrintField(buf, 5, 1, CARD8, "count");
+}
+
+GetKeyboardMappingReply(buf)
+ unsigned char *buf;
+{
+ long n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetKeyboardMapping */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, DVALUE1(n), "keysyms-per-keycode");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n*m), "reply length");
+ n = ILong(&buf[4]);
+ (void)PrintList(&buf[32], n, KEYSYM, "keysyms");
+}
+
+ChangeKeyboardControl(buf)
+ unsigned char *buf;
+{
+ /* Request ChangeKeyboardControl is opcode 102 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeKeyboardControl */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(2 + n), "request length");
+ PrintField(buf, 4, 4, KEYBOARD_BITMASK, "value-mask");
+ PrintValues(&buf[4], 4, KEYBOARD_BITMASK, &buf[8], "value-list");
+}
+
+GetKeyboardControl(buf)
+ unsigned char *buf;
+{
+ /* Request GetKeyboardControl is opcode 103 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetKeyboardControl */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetKeyboardControlReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetKeyboardControl */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, OFF_ON, "global-auto-repeat");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(5), "reply length");
+ PrintField(buf, 8, 4, CARD32, "led-mask");
+ PrintField(buf, 12, 1, CARD8, "key-click-percent");
+ PrintField(buf, 13, 1, CARD8, "bell-percent");
+ PrintField(buf, 14, 2, CARD16, "bell-pitch");
+ PrintField(buf, 16, 2, CARD16, "bell-duration");
+ PrintBytes(&buf[20], 32L, "auto-repeats");
+}
+
+Bell(buf)
+ unsigned char *buf;
+{
+ /* Request Bell is opcode 104 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* Bell */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, INT8, "percent");
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+ChangePointerControl(buf)
+ unsigned char *buf;
+{
+ /* Request ChangePointerControl is opcode 105 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangePointerControl */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 2, INT16, "acceleration-numerator");
+ PrintField(buf, 6, 2, INT16, "acceleration-denominator");
+ PrintField(buf, 8, 2, INT16, "threshold");
+ PrintField(buf, 10, 1, BOOL, "do-acceleration");
+ PrintField(buf, 11, 1, BOOL, "do-threshold");
+}
+
+GetPointerControl(buf)
+ unsigned char *buf;
+{
+ /* Request GetPointerControl is opcode 106 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetPointerControl */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetPointerControlReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerControl */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "acceleration-numerator");
+ PrintField(buf, 10, 2, CARD16, "acceleration-denominator");
+ PrintField(buf, 12, 2, CARD16, "threshold");
+}
+
+SetScreenSaver(buf)
+ unsigned char *buf;
+{
+ /* Request SetScreenSaver is opcode 107 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetScreenSaver */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(3), "request length");
+ PrintField(buf, 4, 2, INT16, "timeout");
+ PrintField(buf, 6, 2, INT16, "interval");
+ PrintField(buf, 8, 1, NO_YES, "prefer-blanking");
+ PrintField(buf, 9, 1, NO_YES, "allow-exposures");
+}
+
+GetScreenSaver(buf)
+ unsigned char *buf;
+{
+ /* Request GetScreenSaver is opcode 108 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetScreenSaver */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetScreenSaverReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetScreenSaver */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "timeout");
+ PrintField(buf, 10, 2, CARD16, "interval");
+ PrintField(buf, 12, 1, NO_YES, "prefer-blanking");
+ PrintField(buf, 13, 1, NO_YES, "allow-exposures");
+}
+
+ChangeHosts(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request ChangeHosts is opcode 109 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeHosts */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, INS_DEL, "mode");
+ printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 1, HOSTFAMILY, "family");
+ printfield(buf, 6, 2, CARD16, "length of address");
+ n = IShort(&buf[6]);
+ PrintBytes(&buf[8], (long)n, "address");
+}
+
+ListHosts(buf)
+ unsigned char *buf;
+{
+ /* Request ListHosts is opcode 110 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListHosts */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+ListHostsReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListHosts */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, DIS_EN, "mode");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n / 4), "reply length");
+ printfield(buf, 8, 2, CARD16, "number of hosts");
+ n = IShort(&buf[8]);
+ (void)PrintList(&buf[32], (long)n, HOST, "hosts");
+}
+
+SetAccessControl(buf)
+ unsigned char *buf;
+{
+ /* Request SetAccessControl is opcode 111 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetAccessControl */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, DIS_EN, "mode");
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+SetCloseDownMode(buf)
+ unsigned char *buf;
+{
+ /* Request SetCloseDownMode is opcode 112 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetCloseDownMode */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, CLOSEMODE, "mode");
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+KillClient(buf)
+ unsigned char *buf;
+{
+ /* Request KillClient is opcode 113 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* KillClient */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, RESOURCEID, "resource");
+}
+
+RotateProperties(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request RotateProperties is opcode 114 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* RotateProperties */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ printfield(buf, 8, 2, DVALUE2(n), "number of properties");
+ n = IShort(&buf[8]);
+ PrintField(buf, 10, 2, INT16, "delta");
+ (void)PrintList(&buf[12], (long)n, ATOM, "properties");
+}
+
+ForceScreenSaver(buf)
+ unsigned char *buf;
+{
+ /* Request ForceScreenSaver is opcode 115 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ForceScreenSaver */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, SAVEMODE, "mode");
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+SetPointerMapping(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request SetPointerMapping is opcode 116 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetPointerMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 1, 1, DVALUE1(n), "length of map");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, DVALUE2(1 + (n + p) / 4), "request length");
+ PrintBytes(&buf[4], (long)n,"map");
+}
+
+SetPointerMappingReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* SetPointerMapping */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, RSTATUS, "status");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+}
+
+GetPointerMapping(buf)
+ unsigned char *buf;
+{
+ /* Request GetPointerMapping is opcode 117 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetPointerMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetPointerMappingReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerMapping */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 1, 1, DVALUE1(n), "length of map");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ PrintBytes(&buf[32], (long)n,"map");
+}
+
+SetModifierMapping(buf)
+ unsigned char *buf;
+{
+ short n;
+ /* Request SetModifierMapping is opcode 118 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetModifierMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, DVALUE2(1 + 2*n), "request length");
+ PrintBytes(&buf[4 + 0 * n], (long)n,"Shift keycodes");
+ PrintBytes(&buf[4 + 1 * n], (long)n,"Lock keycodes");
+ PrintBytes(&buf[4 + 2 * n], (long)n,"Control keycodes");
+ PrintBytes(&buf[4 + 3 * n], (long)n,"Mod1 keycodes");
+ PrintBytes(&buf[4 + 4 * n], (long)n,"Mod2 keycodes");
+ PrintBytes(&buf[4 + 5 * n], (long)n,"Mod3 keycodes");
+ PrintBytes(&buf[4 + 6 * n], (long)n,"Mod4 keycodes");
+ PrintBytes(&buf[4 + 7 * n], (long)n,"Mod5 keycodes");
+}
+
+SetModifierMappingReply(buf)
+ unsigned char *buf;
+{
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* SetModifierMapping */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, RSTATUS, "status");
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, CONST4(0), "reply length");
+}
+
+GetModifierMapping(buf)
+ unsigned char *buf;
+{
+ /* Request GetModifierMapping is opcode 119 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetModifierMapping */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
+
+GetModifierMappingReply(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetModifierMapping */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
+ n = IByte(&buf[1]);
+ printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
+ (void)PrintList(&buf[32], (long)n, KEYCODE, "keycodes");
+}
+
+NoOperation(buf)
+ unsigned char *buf;
+{
+ /* Request NoOperation is opcode 127 */
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* NoOperation */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, INT32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(1), "request length");
+}
diff --git a/prtype.c b/prtype.c
new file mode 100644
index 0000000..685943a
--- /dev/null
+++ b/prtype.c
@@ -0,0 +1,1045 @@
+/* ************************************************** *
+ * *
+ * Type Printing for X11 protocol *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+#include "x11.h"
+
+/*
+ For each of the types we need a way to print that type.
+ Types are of varieties:
+
+ (1) BUILTIN -- we have a separate routine to interpret and print
+ each built-in type.
+ (2) ENUMERATED, SET -- we have one routine which prints, given the
+ data and the list of values.
+ (3) RECORDS -- a separate routine for each to print each field.
+
+*/
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+/* print representation of a character for debugging */
+char *printrep (c)
+ unsigned short c;
+{
+ static char pr[8];
+
+ if (c < 32)
+ {
+ /* control characters */
+ pr[0] = '^';
+ pr[1] = c + 64;
+ pr[2] = '\0';
+ }
+ else if (c < 127)
+ {
+ /* printing characters */
+ pr[0] = c;
+ pr[1] = '\0';
+ }
+ else if (c == 127)
+ return("<del>");
+ else if (c <= 0377)
+ {
+ /* upper 128 codes from 128 to 255; print as \ooo - octal */
+ pr[0] = '\\';
+ pr[3] = '0' + (c & 7);
+ c = c >> 3;
+ pr[2] = '0' + (c & 7);
+ c = c >> 3;
+ pr[1] = '0' + (c & 3);
+ pr[4] = '\0';
+ }
+ else
+ {
+ /* very large number -- print as 0xffff - 4 digit hex */
+ (void)sprintf(pr, "0x%04x", c);
+ }
+ return(pr);
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ we use indentation for two purposes:
+
+ (1) To show substructure of records inside records ...
+ (2) To separate the bytes from the client (on the left) from
+ those from the server (on the right).
+
+ Each indention level is one tab (8 spaces).
+*/
+
+#define MaxIndent 10
+static char Leader[MaxIndent + 1];
+static short CurrentLevel = 0;
+
+SetIndentLevel(which)
+ short which;
+{
+ short i;
+
+ if (which > MaxIndent)
+ which = MaxIndent;
+ if (which < 0)
+ which = 0;
+ if (which == CurrentLevel)
+ return;
+
+ /* set the indent level to <which> */
+ /* -> set the Print Leader to <which> tabs */
+ for (i = 0; i < which; i++)
+ Leader[i] = '\t';
+ Leader[which] = '\0';
+ CurrentLevel = which;
+}
+
+ModifyIndentLevel(amount)
+ short amount;
+{
+ SetIndentLevel(CurrentLevel + amount);
+}
+
+short SizeofLeader ()
+{
+ return (CurrentLevel * 8);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* if we want verbose enough output, we will dump the buffer in hex */
+
+DumpItem(name, fd, buf, n)
+ char *name;
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ if (n == 0)
+ return;
+
+ fprintf(stdout, "%s%20s (fd %d): ", Leader, name, fd);
+
+ DumpHexBuffer(buf, n);
+ fprintf(stdout, "\n");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+PrintINT8(buf)
+ unsigned char *buf;
+{
+ /* print a INT8 -- 8-bit signed integer */
+ short n = IByte (buf);
+ if (n > 127)
+ n = n - 256;
+ fprintf(stdout, "%d", n);
+ return(1);
+}
+
+PrintINT16(buf)
+ unsigned char *buf;
+{
+ /* print a INT16 -- 16-bit signed integer */
+ long n = IShort (buf);
+ if (n > 32767)
+ n = n - 65536;
+ fprintf(stdout, "%d", n);
+ return(2);
+}
+
+PrintINT32(buf)
+ unsigned char *buf;
+{
+ /* print a INT32 -- 32-bit signed integer */
+ long n = ILong (buf);
+ fprintf(stdout, "%d", n);
+ return(4);
+}
+
+/* ************************************************************ */
+
+PrintCARD8(buf)
+ unsigned char *buf;
+{
+ /* print a CARD8 -- 8-bit unsigned integer */
+ short n = IByte (buf);
+ fprintf(stdout, "%02x", (unsigned)(n & 0xff));
+ return(1);
+}
+
+PrintCARD16(buf)
+ unsigned char *buf;
+{
+ /* print a CARD16 -- 16-bit unsigned integer */
+ unsigned long n = IShort (buf);
+ fprintf(stdout, "%04x", (unsigned)(n & 0xffff));
+ return(2);
+}
+
+PrintCARD32(buf)
+ unsigned char *buf;
+{
+ /* print a CARD32 -- 32-bit unsigned integer */
+ unsigned long n = ILong (buf);
+ fprintf(stdout, "%08x", n);
+ return(4);
+}
+
+/* ************************************************************ */
+
+PrintBYTE(buf)
+ unsigned char *buf;
+{
+ /* print a BYTE -- 8-bit value */
+ short n = IByte (buf);
+ fprintf(stdout, "%02x", n);
+ return(1);
+}
+
+
+PrintCHAR8(buf)
+ unsigned char *buf;
+{
+ /* print a CHAR8 -- 8-bit character */
+ unsigned short n = IByte (buf);
+ fprintf(stdout, "%s", printrep(n));
+ return(1);
+}
+
+
+PrintSTRING16(buf)
+ unsigned char *buf;
+{
+ /* print a CHAR2B -- 16-bit character which is never byte-swapped */
+ unsigned short n = IChar2B (buf);
+ fprintf(stdout, "%s", printrep(n));
+ return(1);
+}
+
+PrintSTR(buf)
+ unsigned char *buf;
+{
+ /* STR have the length (1 byte) then a string of CHAR8 */
+ short n;
+ short i;
+
+ n = IByte(buf++);
+ for (i = 0; i < n; i++)
+ fprintf(stdout, "%s", printrep(buf[i]));
+ return(n+1);
+}
+
+/* ************************************************************ */
+
+PrintWINDOW(buf)
+ unsigned char *buf;
+{
+ /* print a WINDOW -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "WIN %08x", n);
+ return(4);
+}
+
+PrintWINDOWD(buf)
+ unsigned char *buf;
+{
+ /* print a WINDOWD -- CARD32 plus 0 = PointerWindow, 1 = InputFocus */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "PointerWindow");
+ else if (n == 1)
+ fprintf(stdout, "InputFocus");
+ else
+ (void)PrintWINDOW(buf);
+ return(4);
+}
+
+PrintWINDOWNR(buf)
+ unsigned char *buf;
+{
+ /* print a WINDOWNR -- CARD32 plus 0 = None, 1 = PointerRoot */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else if (n == 1)
+ fprintf(stdout, "PointerRoot");
+ else
+ (void)PrintWINDOW(buf);
+ return(4);
+}
+
+
+PrintPIXMAP(buf)
+ unsigned char *buf;
+{
+ /* print a PIXMAP -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "PXM %08x", n);
+ return(4);
+}
+
+PrintPIXMAPNPR(buf)
+ unsigned char *buf;
+{
+ /* print a PIXMAPNPR -- CARD32 plus 0 = None, 1 = ParentRelative */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else if (n == 1)
+ fprintf(stdout, "ParentRelative");
+ else
+ PrintPIXMAP(buf);
+ return(4);
+}
+
+PrintPIXMAPC(buf)
+ unsigned char *buf;
+{
+ /* print a PIXMAPC -- CARD32 plus 0 = CopyFromParent */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "CopyFromParent");
+ else
+ PrintPIXMAP(buf);
+ return(4);
+}
+
+
+PrintCURSOR(buf)
+ unsigned char *buf;
+{
+ /* print a CURSOR -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "CUR %08x", n);
+ return(4);
+}
+
+
+PrintFONT(buf)
+ unsigned char *buf;
+{
+ /* print a FONT -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "FNT %08x", n);
+ return(4);
+}
+
+
+PrintGCONTEXT(buf)
+ unsigned char *buf;
+{
+ /* print a GCONTEXT -- CARD32 */
+ long n = ILong (buf);
+ fprintf(stdout, "GXC %08x", n);
+ return(4);
+}
+
+
+PrintCOLORMAP(buf)
+ unsigned char *buf;
+{
+ /* print a COLORMAP -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "CMP %08x", n);
+ return(4);
+}
+
+PrintCOLORMAPC(buf)
+ unsigned char *buf;
+{
+ /* print a COLORMAPC -- CARD32 plus 0 = CopyFromParent */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "CopyFromParent");
+ else
+ (void)PrintCOLORMAP(buf);
+ return(4);
+}
+
+
+PrintDRAWABLE(buf)
+ unsigned char *buf;
+{
+ /* print a DRAWABLE -- CARD32 */
+ long n = ILong (buf);
+ fprintf(stdout, "DWB %08x", n);
+ return(4);
+}
+
+PrintFONTABLE(buf)
+ unsigned char *buf;
+{
+ /* print a FONTABLE -- CARD32 */
+ long n = ILong (buf);
+ fprintf(stdout, "FTB %08x", n);
+ return(4);
+}
+
+/* ************************************************************ */
+
+#define NumberofAtoms 68
+
+char *AtomTable[NumberofAtoms + 1] =
+{
+ "NONE", "PRIMARY", "SECONDARY", "ARC", "ATOM", "BITMAP", "CARDINAL",
+ "COLORMAP", "CURSOR", "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2",
+ "CUT_BUFFER3", "CUT_BUFFER4", "CUT_BUFFER5", "CUT_BUFFER6",
+ "CUT_BUFFER7", "DRAWABLE", "FONT", "INTEGER", "PIXMAP", "POINT",
+ "RECTANGLE", "RESOURCE_MANAGER", "RGB_COLOR_MAP", "RGB_BEST_MAP",
+ "RGB_BLUE_MAP", "RGB_DEFAULT_MAP", "RGB_GRAY_MAP", "RGB_GREEN_MAP",
+ "RGB_RED_MAP", "STRING", "VISUALID", "WINDOW", "WM_COMMAND",
+ "WM_HINTS", "WM_CLIENT_MACHINE", "WM_ICON_NAME", "WM_ICON_SIZE",
+ "WM_NAME", "WM_NORMAL_HINTS", "WM_SIZE_HINTS", "WM_ZOOM_HINTS",
+ "MIN_SPACE", "NORM_SPACE", "MAX_SPACE", "END_SPACE", "SUPERSCRIPT_X",
+ "SUPERSCRIPT_Y", "SUBSCRIPT_X", "SUBSCRIPT_Y", "UNDERLINE_POSITION",
+ "UNDERLINE_THICKNESS", "STRIKEOUT_ASCENT", "STRIKEOUT_DESCENT",
+ "ITALIC_ANGLE", "X_HEIGHT", "QUAD_WIDTH", "WEIGHT", "POINT_SIZE",
+ "RESOLUTION", "COPYRIGHT", "NOTICE", "FONT_NAME", "FAMILY_NAME",
+ "FULL_NAME", "CAP_HEIGHT", "WM_CLASS", "WM_TRANSIENT_FOR"
+ };
+
+/* for atoms, we print the built-in atoms. We could expand to printing
+ the user defined ones, too. */
+
+PrintATOM(buf)
+ unsigned char *buf;
+{
+ /* print a ATOM -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (0 <= n && n <= NumberofAtoms)
+ fprintf(stdout, "<%s>", AtomTable[n]);
+ else
+ fprintf(stdout, "ATM %08x", n);
+ return(4);
+}
+
+PrintATOMT(buf)
+ unsigned char *buf;
+{
+ /* print a ATOMT -- CARD32 plus 0 = AnyPropertyType */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "AnyPropertyType");
+ else
+ (void)PrintATOM(buf);
+ return(4);
+}
+
+
+PrintVISUALID(buf)
+ unsigned char *buf;
+{
+ /* print a VISUALID -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "VIS %08x", n);
+ return(4);
+}
+
+PrintVISUALIDC(buf)
+ unsigned char *buf;
+{
+ /* print a VISUALIDC -- CARD32 plus 0 = CopyFromParent */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "CopyFromParent");
+ else
+ PrintVISUALID(buf);
+ return(4);
+}
+
+
+PrintTIMESTAMP(buf)
+ unsigned char *buf;
+{
+ /* print a TIMESTAMP -- CARD32 plus 0 as the current time */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "CurrentTime");
+ else
+ fprintf(stdout, "TIM %08x", n);
+ return(4);
+}
+
+
+PrintRESOURCEID(buf)
+ unsigned char *buf;
+{
+ /* print a RESOURCEID -- CARD32 plus 0 = AllTemporary */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "AllTemporary");
+ else
+ fprintf(stdout, "RID %08x", n);
+ return(4);
+}
+
+
+PrintKEYSYM(buf)
+ unsigned char *buf;
+{
+ /* print a KEYSYM -- CARD32 */
+ long n = ILong (buf);
+ fprintf(stdout, "KYS %08x", n);
+ return(4);
+}
+
+PrintKEYCODE(buf)
+ unsigned char *buf;
+{
+ /* print a KEYCODE -- CARD8 */
+ unsigned short n = IByte (buf);
+ fprintf(stdout, "%d (%s)", n, printrep(n));
+ return(1);
+}
+
+PrintKEYCODEA(buf)
+ unsigned char *buf;
+{
+ /* print a KEYCODEA -- CARD8 plus 0 = AnyKey */
+ long n = IByte (buf);
+ if (n == 0)
+ fprintf(stdout, "AnyKey");
+ else
+ (void)PrintKEYCODE(buf);
+ return(1);
+}
+
+
+PrintBUTTON(buf)
+ unsigned char *buf;
+{
+ /* print a BUTTON -- CARD8 */
+ unsigned short n = IByte (buf);
+ fprintf(stdout, "%d (%s)", n, printrep(n));
+ return(1);
+}
+
+PrintBUTTONA(buf)
+ unsigned char *buf;
+{
+ /* print a BUTTONA -- CARD8 plus 0 = AnyButton */
+ long n = IByte (buf);
+ if (n == 0)
+ fprintf(stdout, "AnyButton");
+ else
+ PrintBUTTON(buf);
+ return(1);
+}
+
+
+/* this is an interesting cheat -- we call DecodeEvent to print an event */
+/* should work, but its never been tried */
+PrintEVENTFORM(buf)
+ unsigned char *buf;
+{
+ /* print an EVENT_FORM -- event format */
+ DecodeEvent(-1, buf, (long)-1);
+}
+
+/* ************************************************************ */
+
+PrintENUMERATED(buf, length, ValueList)
+ unsigned char *buf;
+ short length;
+ struct ValueListEntry *ValueList;
+{
+ long n;
+ struct ValueListEntry *p;
+
+ if (length == 1)
+ n = IByte(buf);
+ else if (length == 2)
+ n = IShort(buf);
+ else
+ n = ILong(buf);
+
+ p = ValueList;
+ while (p != NULL && p->Value != n)
+ p = p->Next;
+
+ if (p != NULL)
+ fprintf(stdout, "%s", p->Name);
+ else
+ fprintf(stdout, "**INVALID** (%d)", n);
+ return(length);
+}
+
+/* ************************************************************ */
+
+PrintSET(buf, length, ValueList)
+ unsigned char *buf;
+ short length;
+ struct ValueListEntry *ValueList;
+{
+ unsigned long n;
+ struct ValueListEntry *p;
+ Boolean MatchesAll = false;
+ Boolean FoundOne = false;
+
+ if (length == 1)
+ n = IByte(buf);
+ else if (length == 2)
+ n = IShort(buf);
+ else
+ n = ILong(buf);
+
+ if (n != 0)
+ {
+ /* first check if the value matches ALL of the bits. */
+ MatchesAll = true;
+ for (p = ValueList; MatchesAll && (p != NULL); p = p->Next)
+ {
+ if ((p->Value & n) == 0)
+ MatchesAll = false;
+ }
+
+ if (!MatchesAll)
+ /* if it matches some, but not all, print only those it matches */
+ for (p = ValueList; p != NULL; p = p->Next)
+ {
+ if ((p->Value & n) != 0)
+ {
+ if (FoundOne)
+ fprintf(stdout, " | ");
+ fprintf(stdout, "%s", p->Name);
+ FoundOne = true;
+ }
+ }
+ }
+
+ if (MatchesAll)
+ fprintf(stdout, "<ALL>");
+ else if (!FoundOne)
+ fprintf(stdout, "0");
+ return(length);
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+PrintField(buf, start, length, FieldType, name)
+ unsigned char *buf;
+ short start;
+ short length;
+ short FieldType;
+ char *name;
+{
+ if (length == 0)
+ return;
+
+ fprintf(stdout, "%s%20s: ", Leader, name);
+
+ if (debuglevel & 8)
+ DumpHexBuffer(&(buf[start]), (long)length);
+
+ switch (TD[FieldType].Type)
+ {
+ case BUILTIN:
+ (*TD[FieldType].PrintProc)(&buf[start]);
+ break;
+
+ case ENUMERATED:
+ PrintENUMERATED(&buf[start], length, TD[FieldType].ValueList);
+ break;
+
+ case SET:
+ PrintSET(&buf[start], length, TD[FieldType].ValueList);
+ break;
+
+ case RECORD:
+ ModifyIndentLevel(1);
+ fprintf(stdout, "\n");
+ if (Verbose < 3)
+ return;
+ (*TD[FieldType].PrintProc)(&buf[start]);
+ ModifyIndentLevel(-1);
+ break;
+ }
+ fprintf(stdout, "\n");
+ (void)fflush(stdout);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* print a list of things. The things are of type <ListType>.
+ They start at <buf>. There are <number> things in the list */
+
+long PrintList(buf, number, ListType, name)
+ unsigned char *buf;
+ long number;
+ short ListType;
+ char *name;
+{
+ long n;
+ long i;
+ long sum;
+
+ if (number == 0)
+ return(0);
+
+ fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number);
+ if (Verbose < 2)
+ return(0);
+
+ ModifyIndentLevel(1);
+ sum = 0;
+ for (i = 0; i < number; i++)
+ {
+ switch (TD[ListType].Type)
+ {
+ case BUILTIN:
+ n = (*TD[ListType].PrintProc)(buf);
+ break;
+ case RECORD:
+ n = (*TD[ListType].PrintProc)(buf);
+ break;
+ default:
+ fprintf(stdout, "**INVALID**");
+ n = 0;
+ break;
+ }
+ buf = buf + n;
+ sum = sum + n;
+ fprintf(stdout, "%s---\n", Leader);
+ }
+
+ ModifyIndentLevel(-1);
+ return(sum);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* print a list of STRs. Similar to PrintList
+ They start at <buf>. There are <number> things in the list */
+
+PrintListSTR(buf, number, name)
+ unsigned char *buf;
+ long number;
+ char *name;
+{
+ long n;
+ long i;
+ long sum;
+
+ if (number == 0)
+ return;
+
+ fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number);
+ if (Verbose < 2)
+ return;
+
+ ModifyIndentLevel(1);
+ sum = 0;
+ for (i = 0; i < number; i++)
+ {
+ fprintf(stdout, "%s", Leader);
+ n = PrintSTR(buf);
+ buf = buf + n;
+ sum = sum + n;
+ fprintf(stdout, "\n");
+ }
+
+ ModifyIndentLevel(-1);
+ return;
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+PrintBytes(buf, number, name)
+ unsigned char buf[];
+ long number;
+ char *name;
+{
+ /* print a list of BYTE -- 8-bit character */
+ long i;
+ short column;
+
+ if (number == 0)
+ return;
+
+ fprintf(stdout, "%s%20s: ", Leader, name);
+ column = SizeofLeader() + 25;
+ for (i = 0; i < number; i++)
+ {
+ if (column > 80)
+ {
+ if (Verbose < 2)
+ break;
+ fprintf(stdout, "\n%s%20s: ", Leader, "");
+ column = SizeofLeader() + 25;
+ }
+ fprintf(stdout, "%02x ",((unsigned int) buf[i]));
+ column += 3;
+ }
+ fprintf(stdout, "\n");
+
+ return;
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+/* print a String of CHAR8 -- 8-bit characters */
+
+PrintString8(buf, number, name)
+ unsigned char buf[];
+ long number;
+ char *name;
+{
+ long i;
+
+ if (number == 0)
+ return;
+
+ fprintf(stdout, "%s%20s: \"", Leader, name);
+ for (i = 0; i < number; i++)
+ fprintf(stdout, "%s", printrep(buf[i]));
+ fprintf(stdout, "\"\n");
+}
+
+
+/* print a String of CHAR2B -- 16-bit characters */
+
+PrintString16(buf, number, name)
+ unsigned char buf[];
+ long number;
+ char *name;
+{
+ long i;
+ long j;
+ unsigned short c;
+
+ if (number == 0)
+ return;
+
+ fprintf(stdout, "%s%20s: \"", Leader, name);
+ for (i = 0, j = 0; i < number; i += 1, j += 2)
+ {
+ c = IChar2B(&buf[j]);
+ fprintf(stdout, "%s", printrep(c));
+ }
+ fprintf(stdout, "\"\n");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ A Value List is two things:
+
+ (1) A controlling bitmask. For each one bit in the control,
+ a value is in the list.
+ (2) A list of values.
+*/
+
+PrintValues(control, clength, ctype, values, name)
+ unsigned char *control;
+ short clength;
+ short ctype;
+ unsigned char *values;
+ char *name;
+{
+ long cmask;
+ struct ValueListEntry *p;
+
+ /* first get the control mask */
+ if (clength == 1)
+ cmask = IByte(control);
+ else if (clength == 2)
+ cmask = IShort(control);
+ else
+ cmask = ILong(control);
+
+ /* now if it is zero, ignore and return */
+ if (cmask == 0)
+ return;
+
+ /* there are bits in the controlling bitmask, figure out which */
+ /* the ctype is a set type, so this code is similar to PrintSET */
+ fprintf(stdout, "%s%20s:\n", Leader, name);
+ ModifyIndentLevel(1);
+ for (p = TD[ctype].ValueList; p != NULL; p = p->Next)
+ {
+ if ((p->Value & cmask) != 0)
+ {
+ short m = 4 - p->Length;
+ PrintField(values, m, p->Length, p->Type, p->Name);
+ values += 4;
+ }
+ }
+ ModifyIndentLevel(-1);
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* PolyText8 and PolyText16 take lists of characters with possible
+ font changes in them. */
+
+PrintTextList8(buf, length, name)
+ unsigned char *buf;
+ short length;
+ char *name;
+{
+ short n;
+
+ fprintf(stdout, "%s%20s:\n", Leader, name);
+ while (length > 1)
+ {
+ n = IByte(&buf[0]);
+ if (n != 255)
+ {
+ PrintField(buf, 1, 1, INT8, "delta");
+ PrintString8(&buf[2], (long)n, "text item 8 string");
+ buf += n + 2;
+ length -= n + 2;
+ }
+ else
+ {
+ PrintField(buf, 1, 4, FONT, "font-shift-id");
+ buf += 5;
+ length -= 5;
+ }
+ }
+}
+
+PrintTextList16(buf, length, name)
+ unsigned char *buf;
+ short length;
+ char *name;
+{
+ short n;
+
+ fprintf(stdout, "%s%20s:\n", Leader, name);
+ while (length > 1)
+ {
+ n = IByte(&buf[0]);
+ if (n != 255)
+ {
+ PrintField(buf, 1, 1, INT8, "delta");
+ PrintString16(&buf[2], (long)n, "text item 16 string");
+ buf += n + 2;
+ length -= n + 2;
+ }
+ else
+ {
+ PrintField(buf, 1, 4, FONT, "font-shift-id");
+ buf += 5;
+ length -= 5;
+ }
+ }
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+#define MAXline 78
+
+DumpHexBuffer(buf, n)
+ unsigned char *buf;
+ long n;
+{
+ short i;
+ short column;
+ char h[6] /* one hex or octal character */ ;
+
+ column = 27 + SizeofLeader();
+ for (i = 0; i < n; i++)
+ {
+ /* get the hex representations */
+ (void)sprintf(h, "%02x",(0xff & buf[i]));
+
+ /* check if these characters will fit on this line */
+ if ((column + strlen(h) + 1) > MAXline)
+ {
+ /* line will be too long -- print it */
+ fprintf(stdout, "\n");
+ column = 0;
+ }
+ fprintf(stdout, "%s ", h);
+ column += 3;
+ }
+}
diff --git a/scope.c b/scope.c
new file mode 100644
index 0000000..9511f5a
--- /dev/null
+++ b/scope.c
@@ -0,0 +1,692 @@
+/* ******************************************************
+ * *
+ * A spy program to reveal X11 traffic *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+
+#include <sys/types.h> /* needed by sys/socket.h and netinet/in.h */
+#include <sys/uio.h> /* for struct iovec, used by socket.h */
+#include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */
+#include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <netdb.h> /* struct servent * and struct hostent * */
+#include <errno.h> /* for EINTR, EADDRINUSE, ... */
+extern int errno;
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+#define DefaultPort 6000
+
+char ServerHostName[255];
+long ServerBasePort = DefaultPort;
+long ServerInPort = 1;
+long ServerOutPort = 0;
+long ServerDisplay = 0;
+
+
+/* ********************************************** */
+/* */
+/* */
+/* ********************************************** */
+
+short GetServerport ()
+{
+ short port;
+
+ enterprocedure("GetServerport");
+
+ port = ServerBasePort + ServerOutPort + ServerDisplay;
+ debug(4,(stderr, "Server service is on port %d\n", port));
+ return(port);
+}
+
+short GetScopePort ()
+{
+ short port;
+
+ enterprocedure("GetScopePort");
+
+ port = ServerBasePort + ServerInPort + ServerDisplay;
+ debug(4,(stderr, "scope service is on port %d\n", port));
+ return(port);
+}
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+Usage()
+{
+ fprintf(stderr, "Usage: xscope\n");
+ fprintf(stderr, " [-h<server-host>]\n");
+ fprintf(stderr, " [-i<in-port>]\n");
+ fprintf(stderr, " [-o<out-port>]\n");
+ fprintf(stderr, " [-d<display-number>]\n");
+ fprintf(stderr, " [-v<n>] -- verbose output\n");
+ fprintf(stderr, " [-q] -- quiet output\n");
+ fprintf(stderr, " [-D<debug-level>]\n");
+ exit(1);
+}
+
+
+char *OfficialName(); /* forward type declaration */
+
+ScanArgs(argc, argv)
+ int argc;
+ char **argv;
+{
+ NoExtensions = false /* default is to allow extensions */;
+ Verbose = 1 /* default verbose-ness level */;
+ RequestSync = false /* default is to just copy blocks */;
+
+ /* Scan argument list */
+ while (--argc > 0)
+ {
+ ++argv;
+ if (**argv == '-')
+ switch (*++*argv)
+ {
+ /*
+ debug levels:
+ 2 - trace each procedure entry
+ 4 - I/O, connections
+ 8 - Scope internals
+ 16 - Message protocol
+ 32 - 64 - malloc
+ 128 - 256 - really low level
+ */
+ case 'D':
+ debuglevel = atoi(++*argv);
+ if (debuglevel == 0)
+ debuglevel = 255;
+ debuglevel |= 1;
+ Verbose = 7;
+ debug(1,(stderr, "debuglevel = %d\n", debuglevel));
+ break;
+
+ case 'q': /* quiet mode */
+ Verbose = 0;
+ debug(1,(stderr, "Verbose = %d\n", Verbose));
+ break;
+
+ case 'v': /* verbose mode */
+ Verbose = atoi(++*argv);
+ debug(1,(stderr, "Verbose = %d\n", Verbose));
+ break;
+
+ case 's': /* synchronous mode */
+ RequestSync = true;
+ debug(1,(stderr, "RequestSync true\n"));
+ break;
+
+ case 'o': /* output port */
+ ServerOutPort = atoi(++*argv);
+ if (ServerOutPort <= 0)
+ ServerOutPort = 0;
+ debug(1,(stderr, "ServerOutPort = %d\n", ServerOutPort));
+ break;
+
+ case 'd':
+ ServerDisplay = atoi(++*argv);
+ if (ServerDisplay <= 0)
+ ServerDisplay = 0;
+ debug(1,(stderr, "ServerDisplay=%d\n", ServerDisplay));
+ break;
+
+ case 'i':
+ ServerInPort = atoi(++*argv);
+ if (ServerInPort <= 0)
+ ServerInPort = 0;
+ debug(1,(stderr, "ServerInPort = %d\n", ServerInPort));
+ break;
+
+ case 'h':
+ if (++*argv != NULL && **argv != '\0')
+ (void)strcpy(ServerHostName, OfficialName(*argv));
+ debug(1,(stderr, "ServerHostName=%s\n", ServerHostName));
+ break;
+
+ case 'x':
+ NoExtensions = true;
+ debug(1,(stderr, "NoExtensions\n"));
+ break;
+
+ default:
+ fprintf(stderr, "Unknown option %c\n", **argv);
+ Usage();
+ break;
+
+ }
+ else
+ {
+ /* file argument to scope -- error */
+ Usage();
+ }
+ }
+
+ /* check for different port numbers or different machines */
+ if (ServerInPort == ServerOutPort)
+ if (ServerHostName[0] == '\0')
+ {
+ fprintf(stderr, "Can't have xscope on same port as server (%d)\n",
+ ServerInPort);
+ Usage();
+ }
+
+}
+
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ ScanArgs(argc, argv);
+ InitializeFD();
+ InitializeX11();
+ SetUpStdin();
+ SetUpConnectionSocket(GetScopePort());
+ SetSignalHandling();
+
+ MainLoop();
+ exit(0);
+}
+
+TimerExpired()
+{
+ debug(16,(stderr, "Timer tick\n"));
+}
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+/*
+ here is where we would add code to allow control from
+ the keyboard. We would want to read a command and
+ interpret it. Possibilties:
+
+ (a) verbose level setting
+ (b) reset time
+ (c) save X requests to a file.
+ (d) replay X requests from a file.
+ (e) allow fake events, errors to be generated.
+*/
+
+ReadStdin(fd)
+ FD fd;
+{
+ char buf[2048];
+ long n;
+
+ enterprocedure("ReadStdin");
+ n = read(fd, buf, 2048);
+ debug(4,(stderr, "read %d bytes from stdin\n", n));
+}
+
+SetUpStdin()
+{
+ enterprocedure("SetUpStdin");
+ /* UsingFD(fileno(stdin), ReadStdin); */
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ xscope is really meant to look at one client at a time. However,
+ it can easily handle multiple clients and servers. To do so,
+ we need to have a pair of FDs: one for the client and one for the
+ server for that client. If either goes away, so does the other.
+ We need to be able to identify the other FD of a pair, so that if
+ we get input from one, we can write it to the other.
+*/
+
+struct fdinfo
+{
+ Boolean Server;
+ long ClientNumber;
+ FD pair;
+};
+
+static long ClientNumber = 0;
+struct fdinfo FDinfo[StaticMaxFD];
+
+SetUpPair(client, server)
+ FD client;
+ FD server;
+{
+ if (client >= 0)
+ {
+ ClientNumber += 1;
+ FDinfo[client].Server = false;
+ FDinfo[client].pair = server;
+ FDinfo[client].ClientNumber = ClientNumber;
+ if (server >= 0)
+ {
+ FDinfo[server].Server = true;
+ FDinfo[server].pair = client;
+ FDinfo[server].ClientNumber = FDinfo[client].ClientNumber;
+ }
+ }
+ else if (server >= 0)
+ {
+ (void)close(server);
+ NotUsingFD(server);
+ }
+}
+
+
+CloseConnection(fd)
+ FD fd;
+{
+ debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd)));
+ StopClientConnection(ServerHalf(fd));
+ StopServerConnection(ClientHalf(fd));
+
+ (void)close(fd);
+ NotUsingFD(fd);
+ (void)close(FDPair(fd));
+ NotUsingFD(FDPair(fd));
+}
+
+/* ************************************************************ */
+
+FD FDPair(fd)
+ FD fd;
+{
+ return(FDinfo[fd].pair);
+}
+
+FD ClientHalf(fd)
+ FD fd;
+{
+ if (FDinfo[fd].Server)
+ return(FDinfo[fd].pair);
+ return(fd);
+}
+
+FD ServerHalf(fd)
+ FD fd;
+{
+ if (FDinfo[fd].Server)
+ return(fd);
+ return(FDinfo[fd].pair);
+}
+
+char *ClientName (fd)
+ FD fd;
+{
+ static char name[20];
+
+ (void)sprintf(name, " %s %d",
+ (FDinfo[fd].Server ? "Server" : "Client"),
+ FDinfo[fd].ClientNumber);
+ return(name);
+}
+
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+/* when we get data from a client, we read it in, copy it to the
+ server for this client, then dump it to the client. Note, we don't
+ have to have a server, if there isn't one. */
+
+DataFromClient(fd)
+ FD fd;
+{
+ unsigned char buf[2048];
+ long n;
+ FD ServerFD;
+
+ enterprocedure("DataFromClient");
+ n = read(fd, (char *)buf, 2048);
+ debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd)));
+ if (n < 0)
+ {
+ PrintTime();
+ perror("Client --> read error:");
+ CloseConnection(fd);
+ return;
+ }
+ if (n == 0)
+ {
+ PrintTime();
+ fprintf(stdout, "%s --> EOF\n", ClientName(fd));
+ CloseConnection(fd);
+ return;
+ }
+ if (debuglevel > 4)
+ {
+ fflush(stdout); fflush(stderr);
+ DumpHexBuffer(buf, n);
+ fprintf(stdout,"\n");
+ fflush(stdout); fflush(stderr);
+ }
+
+ ServerFD = FDPair(fd);
+ if (ServerFD < 0)
+ {
+ ServerFD = ConnectToServer(false);
+ SetUpPair(fd, ServerFD);
+ }
+
+ /* write bytes from client to server, allow for server to fail */
+ if (!RequestSync) WriteBytes(ServerFD, buf, n);
+
+ /* also report the bytes to standard out */
+ ReportFromClient(fd, buf, n);
+}
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+/* similar situation for the server, but note that if there is no client,
+ we close the connection down -- don't need a server with no client. */
+
+DataFromServer(fd)
+ FD fd;
+{
+ unsigned char buf[2048];
+ long n;
+ FD ClientFD;
+
+ enterprocedure("DataFromServer");
+ n = read(fd, (char *)buf, 2048);
+ debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd)));
+ if (n < 0)
+ {
+ PrintTime();
+ perror("read error <- Server");
+ CloseConnection(fd);
+ return;
+ }
+ if (n == 0)
+ {
+ PrintTime();
+ fprintf(stdout, "EOF <-- %s\n", ClientName(fd));
+ CloseConnection(fd);
+ return;
+ }
+ if (debuglevel > 4)
+ {
+ fflush(stdout); fflush(stderr);
+ DumpHexBuffer(buf, n);
+ fprintf(stdout,"\n");
+ fflush(stdout); fflush(stderr);
+ }
+
+ ClientFD = FDPair(fd);
+ if (ClientFD < 0)
+ {
+ CloseConnection(fd);
+ return;
+ }
+
+ if (NoExtensions)
+ {
+ if (buf[0] == 1) /* reply code */
+ {
+ short SequenceNumber = IShort (&buf[2]);
+ short Request = CheckReplyTable (fd, SequenceNumber);
+ if (Request == 98) /* Query Extension */
+ if (buf[8] == 1)
+ buf[8] = 0;
+ }
+ }
+
+ /* write bytes from server to client, allow for client to fail */
+ WriteBytes(ClientFD, buf, n);
+
+ /* also report the bytes to standard out */
+ ReportFromServer(fd, buf, n);
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+WriteBytes(fd, buf, n)
+FD fd;
+unsigned char *buf;
+long n;
+{
+ long BytesToWrite = n;
+ unsigned char *p = buf;
+
+ if (fd < 0) return;
+ if (!ValidFD(fd)) return;
+
+ while (BytesToWrite > 0)
+ {
+ int n1 = write (fd, (char *)p, (int)BytesToWrite);
+ debug(4,(stderr, "write %d bytes to %s\n", n1, ClientName(fd)));
+ if (n1 > 0)
+ {
+ BytesToWrite -= n1;
+ p += n1;
+ }
+ else
+ {
+ char message[255];
+ sprintf(message,"Error on write to %s", ClientName(fd));
+ perror(message);
+ CloseConnection(fd);
+ BytesToWrite = 0;
+ }
+ }
+}
+
+
+/* ************************************************************ */
+/* */
+/* Create New Connection to a client program and to Server */
+/* */
+/* ************************************************************ */
+
+static int ON = 1 /* used in ioctl */ ;
+
+NewConnection(fd)
+ FD fd;
+{
+ FD ServerFD = -1;
+ FD ClientFD = -1;
+
+ ClientFD = ConnectToClient(fd);
+ ServerFD = ConnectToServer(true);
+ SetUpPair(ClientFD, ServerFD);
+}
+
+
+/* ************************************************************ */
+
+FD ConnectToClient(ConnectionSocket)
+ FD ConnectionSocket;
+{
+ FD ClientFD;
+ struct sockaddr_in from;
+ size_t len = sizeof (from);
+
+ enterprocedure("ConnectToClient");
+
+ ClientFD = accept(ConnectionSocket, (struct sockaddr *)&from, &len);
+ debug(4,(stderr, "Connect To Client: FD %d\n", ClientFD));
+ if (ClientFD < 0 && errno == EWOULDBLOCK)
+ {
+ debug(4,(stderr, "Almost blocked accepting FD %d\n", ClientFD));
+ panic("Can't connect to Client");
+ }
+ if (ClientFD < 0)
+ {
+ debug(4,(stderr, "NewConnection: error %d\n", errno));
+ panic("Can't connect to Client");
+ }
+
+ UsingFD(ClientFD, DataFromClient);
+#ifdef FIOCLEX
+ (void)ioctl(ClientFD, FIOCLEX, 0);
+#endif /* #ifdef FIOCLEX */
+ (void)ioctl(ClientFD, FIONBIO, &ON);
+ StartClientConnection(ClientFD);
+ return(ClientFD);
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+
+FD ConnectToServer(report)
+ Boolean report;
+{
+ FD ServerFD;
+ struct sockaddr_in sin;
+ struct hostent *hp;
+#ifndef SO_DONTLINGER
+ struct linger linger;
+#endif /* #ifndef SO_DONTLINGER */
+
+ enterprocedure("ConnectToServer");
+
+ /* establish a socket to the name server for this host */
+ bzero((char *)&sin, sizeof(sin));
+ ServerFD = socket(AF_INET, SOCK_STREAM, 0);
+ if (ServerFD < 0)
+ {
+ perror("socket() to Server failed");
+ debug(1,(stderr, "socket failed\n"));
+ panic("Can't open connection to Server");
+ }
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_REUSEADDR, (char *) NULL, 0);
+#ifdef SO_USELOOPBACK
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0);
+#endif /* #ifdef SO_USELOOPBACK */
+#ifdef SO_DONTLINGER
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else /* #ifdef SO_DONTLINGER */
+ linger.l_onoff = 0;
+ linger.l_linger = 0;
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger);
+#endif /* #ifdef SO_DONTLINGER */
+
+ /* determine the host machine for this process */
+ if (ServerHostName[0] == '\0')
+ (void) gethostname(ServerHostName, sizeof (ServerHostName));
+ debug(4,(stderr, "try to connect on %s\n", ServerHostName));
+
+ hp = gethostbyname(ServerHostName);
+ if (hp == 0)
+ {
+ perror("gethostbyname failed");
+ debug(1,(stderr, "gethostbyname failed for %s\n", ServerHostName));
+ panic("Can't open connection to Server");
+ }
+
+ sin.sin_family = AF_INET;
+ bcopy((char *)hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
+ sin.sin_port = htons(GetServerport());
+
+ if ((sin.sin_port == ScopePort)
+ && strcmp(ServerHostName, ScopeHost) == 0)
+ {
+ char error_message[100];
+ (void)sprintf(error_message, "Trying to attach to myself: %s,%d\n",
+ ServerHostName, sin.sin_port);
+ panic(error_message);
+ }
+
+ /* ******************************************************** */
+ /* try to connect to Server */
+
+ if (connect(ServerFD, (struct sockaddr *)&sin, sizeof(sin)) < 0)
+ {
+ debug(4,(stderr, "connect returns errno of %d\n", errno));
+ if (errno != 0)
+ if (report)
+ perror("connect");
+ switch (errno)
+ {
+ case ECONNREFUSED:
+ /* experience says this is because there is no Server
+ to connect to */
+ (void)close(ServerFD);
+ debug(1,(stderr, "No Server\n"));
+ if (report)
+ warn("Can't open connection to Server");
+ return(-1);
+
+ default:
+ (void)close(ServerFD);
+ panic("Can't open connection to Server");
+ }
+ }
+
+ debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD));
+ if (ServerFD >= 0)
+ {
+ UsingFD(ServerFD, DataFromServer);
+ StartServerConnection(ServerFD);
+ }
+ return(ServerFD);
+}
+
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+char *OfficialName(name)
+char *name;
+{
+ struct hostent *HostEntry;
+
+ HostEntry = gethostbyname(name);
+ if (HostEntry == NULL)
+ {
+ perror("gethostbyname");
+ exit(-1);
+ }
+ debug(4,(stderr, "Official name of %s is %s\n", name, HostEntry->h_name));
+ return(HostEntry->h_name);
+}
+
diff --git a/scope.h b/scope.h
new file mode 100644
index 0000000..62b3189
--- /dev/null
+++ b/scope.h
@@ -0,0 +1,67 @@
+/* **********************************************
+ * *
+ * header file for the Server spy scope *
+ * *
+ * James Peterson, 1987 *
+ * Copyright (C) 1987 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 <stdio.h>
+
+#define Boolean short
+#define true 1
+#define false 0
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+#define Assert(b) (b)
+#define debug(n,f) (void)((debuglevel & n) ? (fprintf f,fflush(stderr)) : 0)
+short debuglevel;
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+Boolean NoExtensions /* Should we deny extensions exist ? */ ;
+short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ;
+Boolean RequestSync;
+
+int ScopePort;
+char *ScopeHost;
+
+/* external function type declarations */
+
+extern char *Malloc ();
+extern char *strcpy();
+char *ClientName ();
+
+/* ********************************************** */
+/* */
+/* ********************************************** */
+
+/* need to change the MaxFD to allow larger number of fd's */
+#define StaticMaxFD 32
+
+
+#include "fd.h"
diff --git a/server.c b/server.c
new file mode 100644
index 0000000..ba8b7cb
--- /dev/null
+++ b/server.c
@@ -0,0 +1,632 @@
+/* ************************************************** *
+ * *
+ * Code to decode and print X11 protocol *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+#include "x11.h"
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+ReportFromClient(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ PrintTime();
+ fprintf(stdout, "%s --> %4d %s\n",
+ ClientName(fd), n, (n == 1 ? "byte" : "bytes"));
+ ProcessBuffer(fd, buf, n);
+}
+
+ReportFromServer(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ PrintTime();
+ fprintf(stdout, "\t\t\t\t\t%4d %s <-- X11 %s\n",
+ n, (n == 1 ? "byte" : "bytes"), ClientName(fd));
+ ProcessBuffer(fd, buf, n);
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+#include <sys/time.h> /* for struct timeval * */
+static long ZeroTime1 = -1;
+static long ZeroTime2 = -1;
+static struct timeval tp;
+
+/* print the time since we started in hundredths (1/100) of seconds */
+
+PrintTime()
+{
+ static long lastsec = 0;
+ long sec /* seconds */ ;
+ long hsec /* hundredths of a second */ ;
+
+ (void)gettimeofday(&tp, (struct timezone *)NULL);
+ if (ZeroTime1 == -1 || (tp.tv_sec - lastsec) >= 1000)
+ {
+ ZeroTime1 = tp.tv_sec;
+ ZeroTime2 = tp.tv_usec / 10000;
+ }
+
+ lastsec = tp.tv_sec;
+ sec = tp.tv_sec - ZeroTime1;
+ hsec = tp.tv_usec / 10000 - ZeroTime2;
+ if (hsec < 0)
+ {
+ hsec += 100;
+ sec -= 1;
+ }
+ fprintf(stdout, "%2d.%02ld: ", sec, hsec);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* we will need to be able to interpret the values stored in the
+ requests as various built-in types. The following routines
+ support the types built into X11 */
+
+long pad (n)
+ long n;
+{
+ /* round up to next multiple of 4 */
+ return((n + 3) & ~0x3);
+}
+
+
+static Boolean byteswap = false;
+void SetByteSwapping(int how)
+{
+ byteswap = (how == 0x6c);
+}
+
+unsigned long ILong (buf)
+ unsigned char buf[];
+{
+ unsigned short a,b,c,d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ /* check for byte-swapping */
+
+ if (byteswap)
+ return((((((d << 8) | c) << 8) | b) << 8) | a);
+ else
+ return((((((a << 8) | b) << 8) | c) << 8) | d);
+}
+
+unsigned short IShort (buf)
+unsigned char buf[];
+{
+ unsigned short a,b,c,d;
+
+ a = buf[0];
+ b = buf[1];
+
+ /* check for byte-swapping */
+
+ if (byteswap)
+ return((b << 8) | a);
+ else
+ return((a << 8) | b);
+}
+
+unsigned short IChar2B (buf)
+unsigned char buf[];
+{
+ /* CHAR2B is like an IShort, but not byte-swapped */
+ return((buf[0] << 8) | buf[1]);
+}
+
+unsigned short IByte (buf)
+unsigned char buf[];
+{
+ return(buf[0]);
+}
+
+Boolean IBool(buf)
+ unsigned char buf[];
+{
+ if (buf[0] != 0)
+ return(true);
+ else
+ return(false);
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* we will need to save bytes until we get a complete request to
+ interpret. The following procedures provide this ability */
+
+SaveBytes(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ /* check if there is enough space to hold the bytes we want */
+ if (CS[fd].NumberofSavedBytes + n > CS[fd].SizeofSavedBytes)
+ {
+ /* not enough room so far; malloc more space and copy */
+ long SizeofNewBytes = (CS[fd].NumberofSavedBytes + n + 1);
+ unsigned char *NewBytes = (unsigned char *)Malloc (SizeofNewBytes);
+ if (CS[fd].NumberofSavedBytes > 0)
+ {
+ bcopy(/* from */(char *)CS[fd].SavedBytes,
+ /* to */(char *)NewBytes,
+ /* count */(int)CS[fd].NumberofSavedBytes);
+ Free((char *)CS[fd].SavedBytes);
+ }
+ CS[fd].SavedBytes = NewBytes;
+ CS[fd].SizeofSavedBytes = SizeofNewBytes;
+ }
+
+ /* now copy the new bytes onto the end of the old bytes */
+ bcopy(/* from */(char *)buf,
+ /* to */(char *)(CS[fd].SavedBytes + CS[fd].NumberofSavedBytes),
+ /* count */(int)n);
+ CS[fd].NumberofSavedBytes += n;
+}
+
+RemoveSavedBytes(fd, n)
+ FD fd;
+ long n;
+{
+ /* check if all bytes are being removed -- easiest case */
+ if (CS[fd].NumberofSavedBytes <= n)
+ CS[fd].NumberofSavedBytes = 0;
+ else if (n == 0)
+ return;
+ else
+ {
+ /* not all bytes are being removed -- shift the remaining ones down */
+ register unsigned char *p = CS[fd].SavedBytes;
+ register unsigned char *q = CS[fd].SavedBytes + n;
+ register long i = CS[fd].NumberofSavedBytes - n;
+ while (i-- > 0)
+ *p++ = *q++;
+ CS[fd].NumberofSavedBytes -= n;
+ }
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+
+/* following are the possible values for ByteProcessing */
+/* forward declarations */
+long StartSetUpMessage ();
+long FinishSetUpMessage ();
+long StartRequest ();
+long FinishRequest ();
+
+long StartSetUpReply ();
+long FinishSetUpReply ();
+long ServerPacket ();
+long FinishReply ();
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+ProcessBuffer(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ unsigned char *BytesToProcess;
+ long NumberofUsedBytes;
+
+ /* as long as we have enough bytes to do anything -- do it */
+
+ while (CS[fd].NumberofSavedBytes + n >= CS[fd].NumberofBytesNeeded)
+ {
+ /*
+ we have enough bytes to do something. We want the bytes to be
+ grouped together into one contiguous block of bytes. We have three
+ cases:
+
+ (1) NumberofSavedBytes = 0; so all needed bytes are in the
+ read buffer, buf.
+
+ (2) NumberofSavedBytes >= NumberofBytesNeeded; in this case we
+ will not need to copy any extra bytes into the save buffer.
+
+ (3) 0 < NumberofSavedBytes < NumberofBytesNeeded; so
+ some bytes are in the save buffer and others are in the read
+ buffer. In this case we need to copy some of the bytes from the
+ read buffer to the save buffer to get as many bytes as we need,
+ then use these bytes.
+ */
+
+ if (CS[fd].NumberofSavedBytes == 0)
+ {
+ /* no saved bytes, so just process the first bytes in the
+ read buffer */
+ BytesToProcess = buf /* address of request bytes */;
+ }
+ else
+ {
+ if (CS[fd].NumberofSavedBytes < CS[fd].NumberofBytesNeeded)
+ {
+ /* first determine the number of bytes we need to
+ transfer; then transfer them and remove them from
+ the read buffer. (there may be additional requests
+ in the read buffer) */
+ long m;
+ m = CS[fd].NumberofBytesNeeded - CS[fd].NumberofSavedBytes;
+ SaveBytes(fd, buf, m);
+ buf += m;
+ n -= m;
+ }
+ BytesToProcess = CS[fd].SavedBytes /* address of request bytes */;
+ }
+
+ /*
+ BytesToProcess points to a contiguous block of NumberofBytesNeeded
+ bytes that we should process. The type of processing depends upon
+ the state we are in. The processing routine should return the
+ number of bytes that it actually used.
+ */
+ NumberofUsedBytes = (*CS[fd].ByteProcessing)
+ (fd, BytesToProcess, CS[fd].NumberofBytesNeeded);
+
+ /* the number of bytes that were actually used is normally (but not
+ always) the number of bytes needed. Discard the bytes that were
+ actually used, not the bytes that were needed. The number of used
+ bytes must be less than or equal to the number of needed bytes. */
+
+ if (NumberofUsedBytes > 0)
+ {
+ if (CS[fd].NumberofSavedBytes > 0)
+ RemoveSavedBytes(fd, NumberofUsedBytes);
+ else
+ {
+ /* there are no saved bytes, so the bytes that were
+ used must have been in the read buffer */
+ buf += NumberofUsedBytes;
+ n -= NumberofUsedBytes;
+ }
+ }
+ } /* end of while (NumberofSavedBytes + n >= NumberofBytesNeeded) */
+
+ /* not enough bytes -- just save the new bytes for more later */
+ if (n > 0)
+ SaveBytes(fd, buf, n);
+ return;
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+/*
+ Byte Processing Routines. Each routine MUST set NumberofBytesNeeded
+ and ByteProcessing. It probably needs to do some computation first.
+*/
+
+
+StartClientConnection(fd)
+ FD fd;
+{
+ enterprocedure("StartClientConnection");
+ /* when a new connection is started, we have no saved bytes */
+ CS[fd].SavedBytes = NULL;
+ CS[fd].SizeofSavedBytes = 0;
+ CS[fd].NumberofSavedBytes = 0;
+
+ /* when a new connection is started, we have no reply Queue */
+ FlushReplyQ(fd);
+
+ /* each new connection gets a request sequence number */
+ CS[fd].SequenceNumber = 0;
+
+ /* we need 12 bytes to start a SetUp message */
+ CS[fd].ByteProcessing = StartSetUpMessage;
+ CS[fd].NumberofBytesNeeded = 12;
+}
+
+StopClientConnection(fd)
+ FD fd;
+{
+ enterprocedure("StopClientConnection");
+ /* when a new connection is stopped, discard the old buffer */
+
+ if (CS[fd].SizeofSavedBytes > 0)
+ Free((char*)CS[fd].SavedBytes);
+}
+
+long StartSetUpMessage (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short namelength;
+ short datalength;
+
+ enterprocedure("StartSetUpMessage");
+ /*
+ we need the first 12 bytes to be able to determine if, and how many,
+ additional bytes we need for name and data authorization. However, we
+ can't process the first 12 bytes until we get all of them, so
+ return zero bytes used, and increase the number of bytes needed
+ */
+
+ namelength = IShort(&buf[6]);
+ datalength = IShort(&buf[8]);
+ CS[fd].ByteProcessing = FinishSetUpMessage;
+ CS[fd].NumberofBytesNeeded = n
+ + pad((long)namelength) + pad((long)datalength);
+ debug(8,(stderr, "need %d bytes to finish startup\n",
+ CS[fd].NumberofBytesNeeded - n));
+ return(0);
+}
+
+long FinishSetUpMessage (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishSetUpMessage");
+ PrintSetUpMessage(buf);
+ if (RequestSync) SendToServer(fd,buf,n);
+
+ /* after a set-up message, we expect a string of requests */
+ CS[fd].ByteProcessing = StartRequest;
+ CS[fd].NumberofBytesNeeded = 4;
+ return(n);
+}
+
+
+long StartRequest (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short requestlength;
+ enterprocedure("StartRequest");
+
+ /* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */
+ requestlength = IShort(&buf[2]);
+ CS[fd].ByteProcessing = FinishRequest;
+ CS[fd].NumberofBytesNeeded = 4 * requestlength;
+ debug(8,(stderr, "need %d more bytes to finish request\n",
+ CS[fd].NumberofBytesNeeded - n));
+ return(0);
+}
+
+
+long FinishRequest (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishRequest");
+ DecodeRequest(fd, buf, n);
+ if (RequestSync) SendToServer(fd,buf,n);
+
+ CS[fd].ByteProcessing = StartRequest;
+ CS[fd].NumberofBytesNeeded = 4;
+ return(n);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+SendToServer (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ FD Server;
+
+ enterprocedure("SendToServer");
+ /*
+ We are in RequestSync mode. These means that each request is
+ separately sent to the server and we wait until it is done before
+ proceeding to the next request. This is useful when a client
+ request causes the server to crash. In this case, if we batch
+ up 100 requests and send them to the server all at once, we will
+ have no idea which was the last one processed, and hence which
+ was the one that caused the server to crash.
+
+ We first write the buffer to the server, then flush it. Then we
+ check if the server has input available, and if so process it
+ before returning to finish the rest of the client buffer.
+ */
+
+ Server = ServerHalf(fd);
+ WriteBytes(Server, buf, n);
+
+ if (InputAvailable(Server))
+ HandleInput(Server);
+}
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+StartServerConnection(fd)
+ FD fd;
+{
+ enterprocedure("StartServerConnection");
+ /* when a new connection is started, we have no saved bytes */
+ CS[fd].SavedBytes = NULL;
+ CS[fd].SizeofSavedBytes = 0;
+ CS[fd].NumberofSavedBytes = 0;
+
+ /* when a new connection is started, we have no reply Queue */
+ FlushReplyQ(fd);
+
+ /* we need 8 bytes to start a SetUp reply */
+ CS[fd].ByteProcessing = StartSetUpReply;
+ CS[fd].NumberofBytesNeeded = 8;
+}
+
+StopServerConnection(fd)
+ FD fd;
+{
+ enterprocedure("StopServerConnection");
+ /* when a new connection is stopped, discard the old buffer */
+
+ if (CS[fd].SizeofSavedBytes > 0)
+ Free((char *)CS[fd].SavedBytes);
+}
+
+long StartSetUpReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short replylength;
+
+ enterprocedure("StartSetUpReply");
+ replylength = IShort(&buf[6]);
+ CS[fd].ByteProcessing = FinishSetUpReply;
+ CS[fd].NumberofBytesNeeded = n + 4 * replylength;
+ debug(8,(stderr, "need %d bytes to finish startup reply\n",
+ CS[fd].NumberofBytesNeeded - n));
+ return(0);
+}
+
+long FinishSetUpReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishSetUpReply");
+ PrintSetUpReply(buf);
+ CS[fd].ByteProcessing = ServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ return(n);
+}
+
+/* ************************************************************ */
+
+long ErrorPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ fprintf(stdout, "Error: ");
+ DecodeError(fd, buf, n);
+ CS[fd].ByteProcessing = ServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ return(n);
+}
+
+
+long EventPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ DecodeEvent(fd, buf, n);
+ CS[fd].ByteProcessing = ServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ return(n);
+}
+
+
+long ReplyPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short replylength;
+
+ replylength = ILong(&buf[4]);
+
+ /*
+ Replies may need more bytes, so we compute how many more
+ bytes are needed and ask for them, not using any of the bytes
+ we were given (return(0) to say that no bytes were used).
+ If the replylength is zero (we don't need any more bytes), the
+ number of bytes needed will be the same as what we have, and
+ so the top-level loop will call the next routine immediately
+ with the same buffer of bytes that we were given.
+ */
+
+ CS[fd].ByteProcessing = FinishReply;
+ CS[fd].NumberofBytesNeeded = n + 4 * replylength;
+ debug(8,(stderr, "need %d bytes to finish reply\n", (4 * replylength)));
+ return(0);
+}
+
+long ServerPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short PacketType;
+ enterprocedure("ServerPacket");
+
+ PacketType = IByte(&buf[0]);
+ if (PacketType == 0)
+ return(ErrorPacket(fd, buf, n));
+ if (PacketType == 1)
+ return(ReplyPacket(fd, buf, n));
+ return(EventPacket(fd, buf, n));
+}
+
+long FinishReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishReply");
+ DecodeReply(fd, buf, n);
+ CS[fd].ByteProcessing = ServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ return(n);
+}
diff --git a/table11.c b/table11.c
new file mode 100644
index 0000000..c527424
--- /dev/null
+++ b/table11.c
@@ -0,0 +1,1112 @@
+/* ************************************************** *
+ * *
+ * Table initialization for X11 protocol *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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 "scope.h"
+#include "x11.h"
+
+/*
+ To initialize for the X11 protocol, we need to create data structures
+ describing the data types used by X11.
+*/
+
+/*
+ There are about 100-128 data types for X11. This start with the simple
+ INT8, INT16, INT32 (byte, short, long), and the CARD8, CARD16, CARD32
+ (unsigned) and extend to records like RGB (a resource id, 3 color
+ values and a bitmask to select a subset of the 3 color values). Each
+ data type has an assigned type index. The type index identifies the
+ type (with a #define in x11.h) and is used to access an entry in an
+ array of type descriptors (TD). Each type descriptor has the type name,
+ the kind of type, and a procedure to print an object of that type.
+ The print procedure for a type <foo> is named Print<foo>. The kind of
+ type is
+
+ BUILTIN: one of the primitive types.
+ ENUMERATED: value should be one of a small set of values. This type
+ needs a list of allowed values (and their print names).
+ SET: value is a bitmask of a small set of values. Each value
+ is a one-bit mask (and its print name).
+ RECORD: value is a record of fields of other types.
+
+ The Type Descriptor array allows us to print a value if we know its type
+ (index) and the bytes in memory that are its value.
+*/
+
+
+InitializeX11()
+{
+ enterprocedure("InitializeX11");
+ InitReplyQ();
+
+ InitBuiltInTypes();
+ InitEnumeratedTypes();
+ InitSetTypes();
+ InitValuesTypes();
+ InitRecordTypes();
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* define the various types */
+
+TYPE DefineType(typeid, class, name, printproc)
+ short typeid;
+ short class;
+ char *name;
+ int (*printproc)();
+{
+ TD[typeid].Name = name;
+ TD[typeid].Type = class;
+ TD[typeid].ValueList = NULL;
+ TD[typeid].PrintProc = printproc;
+ return(&TD[typeid]);
+}
+
+/* ************************************************************ */
+/* define an Enumerated Value (or a Set Value) */
+
+DefineEValue(type, value, name)
+ TYPE type;
+ long value;
+ char *name;
+{
+ struct ValueListEntry *p;
+
+ /* define the new value */
+ p = (struct ValueListEntry *)
+ Malloc ((long)(sizeof (struct ValueListEntry)));
+ p->Name = name;
+ p->Value = value;
+
+ /* add an new value to the list. */
+ if (type->ValueList == NULL || type->ValueList->Value > p->Value)
+ {
+ p->Next = type->ValueList;
+ type->ValueList = p;
+ }
+ else
+ {
+ /* keep the list sorted, smallest to largest */
+ struct ValueListEntry *q = type->ValueList;
+ while (q->Next != NULL && q->Next->Value < p->Value)
+ q = q->Next;
+ p->Next = q->Next;
+ q->Next = p;
+ }
+}
+
+/* ************************************************************ */
+/* a Values list is like an enumerated Value, but has a type and length
+ in addition to a value and name. It is used to print a Values List */
+
+/* A Values List is a bitmask (like a set), but if the bit is set on, then
+ we have an associated value. We need to know the length and type of the
+ associated value for each bit */
+
+DefineValues(type, value, length, ctype, name)
+ TYPE type;
+ long value;
+ char *name;
+{
+ struct ValueListEntry *p;
+
+ p = (struct ValueListEntry *)
+ Malloc ((long)(sizeof (struct ValueListEntry)));
+ p->Name = name;
+ p->Type = ctype;
+ p->Length = length;
+ p->Value = value;
+
+ /* add an new value to the list. */
+ if (type->ValueList == NULL || type->ValueList->Value > p->Value)
+ {
+ p->Next = type->ValueList;
+ type->ValueList = p;
+ }
+ else
+ {
+ /* keep the list sorted, smallest to largest */
+ struct ValueListEntry *q = type->ValueList;
+ while (q->Next != NULL && q->Next->Value < p->Value)
+ q = q->Next;
+ p->Next = q->Next;
+ q->Next = p;
+ }
+}
+
+
+
+/* ************************************************************ */
+
+InitBuiltInTypes()
+{
+ enterprocedure("InitBuiltInTypes");
+ (void) DefineType(INT8, BUILTIN, "INT8", PrintINT8);
+ (void) DefineType(INT16, BUILTIN, "INT16", PrintINT16);
+ (void) DefineType(INT32, BUILTIN, "INT32", PrintINT32);
+ (void) DefineType(CARD8, BUILTIN, "CARD8", PrintCARD8);
+ (void) DefineType(CARD16, BUILTIN, "CARD16", PrintCARD16);
+ (void) DefineType(CARD32, BUILTIN, "CARD32", PrintCARD32);
+ (void) DefineType(BYTE, BUILTIN, "BYTE", PrintBYTE);
+ (void) DefineType(CHAR8, BUILTIN, "CHAR8", PrintCHAR8);
+ (void) DefineType(STRING16, BUILTIN, "STRING16", PrintSTRING16);
+ (void) DefineType(STR, BUILTIN, "STR", PrintSTR);
+ (void) DefineType(WINDOW, BUILTIN, "WINDOW", PrintWINDOW);
+ (void) DefineType(WINDOWD, BUILTIN, "WINDOWD", PrintWINDOWD);
+ (void) DefineType(WINDOWNR, BUILTIN, "WINDOWNR", PrintWINDOWNR);
+ (void) DefineType(PIXMAP, BUILTIN, "PIXMAP", PrintPIXMAP);
+ (void) DefineType(PIXMAPNPR, BUILTIN, "PIXMAPNPR", PrintPIXMAPNPR);
+ (void) DefineType(PIXMAPC, BUILTIN, "PIXMAPC", PrintPIXMAPC);
+ (void) DefineType(CURSOR, BUILTIN, "CURSOR", PrintCURSOR);
+ (void) DefineType(FONT, BUILTIN, "FONT", PrintFONT);
+ (void) DefineType(GCONTEXT, BUILTIN, "GCONTEXT", PrintGCONTEXT);
+ (void) DefineType(COLORMAP, BUILTIN, "COLORMAP", PrintCOLORMAP);
+ (void) DefineType(COLORMAPC, BUILTIN, "COLORMAPC", PrintCOLORMAPC);
+ (void) DefineType(DRAWABLE, BUILTIN, "DRAWABLE", PrintDRAWABLE);
+ (void) DefineType(FONTABLE, BUILTIN, "FONTABLE", PrintFONTABLE);
+ (void) DefineType(ATOM, BUILTIN, "ATOM", PrintATOM);
+ (void) DefineType(ATOMT, BUILTIN, "ATOMT", PrintATOMT);
+ (void) DefineType(VISUALID, BUILTIN, "VISUALID", PrintVISUALID);
+ (void) DefineType(VISUALIDC, BUILTIN, "VISUALIDC", PrintVISUALIDC);
+ (void) DefineType(TIMESTAMP, BUILTIN, "TIMESTAMP", PrintTIMESTAMP);
+ (void) DefineType(RESOURCEID, BUILTIN, "RESOURCEID", PrintRESOURCEID);
+ (void) DefineType(KEYSYM, BUILTIN, "KEYSYM", PrintKEYSYM);
+ (void) DefineType(KEYCODE, BUILTIN, "KEYCODE", PrintKEYCODE);
+ (void) DefineType(KEYCODEA, BUILTIN, "KEYCODEA", PrintKEYCODEA);
+ (void) DefineType(BUTTON, BUILTIN, "BUTTON", PrintBUTTON);
+ (void) DefineType(BUTTONA, BUILTIN, "BUTTONA", PrintBUTTONA);
+ (void) DefineType(EVENTFORM, BUILTIN, "EVENTFORM", PrintEVENTFORM);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+InitEnumeratedTypes()
+{
+ TYPE p;
+
+ enterprocedure("InitEnumeratedTypes");
+ p = DefineType(REQUEST, ENUMERATED, "REQUEST", PrintENUMERATED);
+ DefineEValue(p, 1L, "CreateWindow");
+ DefineEValue(p, 2L, "ChangeWindowAttributes");
+ DefineEValue(p, 3L, "GetWindowAttributes");
+ DefineEValue(p, 4L, "DestroyWindow");
+ DefineEValue(p, 5L, "DestroySubwindows");
+ DefineEValue(p, 6L, "ChangeSaveSet");
+ DefineEValue(p, 7L, "ReparentWindow");
+ DefineEValue(p, 8L, "MapWindow");
+ DefineEValue(p, 9L, "MapSubwindows");
+ DefineEValue(p, 10L, "UnmapWindow");
+ DefineEValue(p, 11L, "UnmapSubwindows");
+ DefineEValue(p, 12L, "ConfigureWindow");
+ DefineEValue(p, 13L, "CirculateWindow");
+ DefineEValue(p, 14L, "GetGeometry");
+ DefineEValue(p, 15L, "QueryTree");
+ DefineEValue(p, 16L, "InternAtom");
+ DefineEValue(p, 17L, "GetAtomName");
+ DefineEValue(p, 18L, "ChangeProperty");
+ DefineEValue(p, 19L, "DeleteProperty");
+ DefineEValue(p, 20L, "GetProperty");
+ DefineEValue(p, 21L, "ListProperties");
+ DefineEValue(p, 22L, "SetSelectionOwner");
+ DefineEValue(p, 23L, "GetSelectionOwner");
+ DefineEValue(p, 24L, "ConvertSelection");
+ DefineEValue(p, 25L, "SendEvent");
+ DefineEValue(p, 26L, "GrabPointer");
+ DefineEValue(p, 27L, "UngrabPointer");
+ DefineEValue(p, 28L, "GrabButton");
+ DefineEValue(p, 29L, "UngrabButton");
+ DefineEValue(p, 30L, "ChangeActivePointerGrab");
+ DefineEValue(p, 31L, "GrabKeyboard");
+ DefineEValue(p, 32L, "UngrabKeyboard");
+ DefineEValue(p, 33L, "GrabKey");
+ DefineEValue(p, 34L, "UngrabKey");
+ DefineEValue(p, 35L, "AllowEvents");
+ DefineEValue(p, 36L, "GrabServer");
+ DefineEValue(p, 37L, "UngrabServer");
+ DefineEValue(p, 38L, "QueryPointer");
+ DefineEValue(p, 39L, "GetMotionEvents");
+ DefineEValue(p, 40L, "TranslateCoordinates");
+ DefineEValue(p, 41L, "WarpPointer");
+ DefineEValue(p, 42L, "SetInputFocus");
+ DefineEValue(p, 43L, "GetInputFocus");
+ DefineEValue(p, 44L, "QueryKeymap");
+ DefineEValue(p, 45L, "OpenFont");
+ DefineEValue(p, 46L, "CloseFont");
+ DefineEValue(p, 47L, "QueryFont");
+ DefineEValue(p, 48L, "QueryTextExtents");
+ DefineEValue(p, 49L, "ListFonts");
+ DefineEValue(p, 50L, "ListFontsWithInfo");
+ DefineEValue(p, 51L, "SetFontPath");
+ DefineEValue(p, 52L, "GetFontPath");
+ DefineEValue(p, 53L, "CreatePixmap");
+ DefineEValue(p, 54L, "FreePixmap");
+ DefineEValue(p, 55L, "CreateGC");
+ DefineEValue(p, 56L, "ChangeGC");
+ DefineEValue(p, 57L, "CopyGC");
+ DefineEValue(p, 58L, "SetDashes");
+ DefineEValue(p, 59L, "SetClipRectangles");
+ DefineEValue(p, 60L, "FreeGC");
+ DefineEValue(p, 61L, "ClearArea");
+ DefineEValue(p, 62L, "CopyArea");
+ DefineEValue(p, 63L, "CopyPlane");
+ DefineEValue(p, 64L, "PolyPoint");
+ DefineEValue(p, 65L, "PolyLine");
+ DefineEValue(p, 66L, "PolySegment");
+ DefineEValue(p, 67L, "PolyRectangle");
+ DefineEValue(p, 68L, "PolyArc");
+ DefineEValue(p, 69L, "FillPoly");
+ DefineEValue(p, 70L, "PolyFillRectangle");
+ DefineEValue(p, 71L, "PolyFillArc");
+ DefineEValue(p, 72L, "PutImage");
+ DefineEValue(p, 73L, "GetImage");
+ DefineEValue(p, 74L, "PolyText8");
+ DefineEValue(p, 75L, "PolyText16");
+ DefineEValue(p, 76L, "ImageText8");
+ DefineEValue(p, 77L, "ImageText16");
+ DefineEValue(p, 78L, "CreateColormap");
+ DefineEValue(p, 79L, "FreeColormap");
+ DefineEValue(p, 80L, "CopyColormapAndFree");
+ DefineEValue(p, 81L, "InstallColormap");
+ DefineEValue(p, 82L, "UninstallColormap");
+ DefineEValue(p, 83L, "ListInstalledColormaps");
+ DefineEValue(p, 84L, "AllocColor");
+ DefineEValue(p, 85L, "AllocNamedColor");
+ DefineEValue(p, 86L, "AllocColorCells");
+ DefineEValue(p, 87L, "AllocColorPlanes");
+ DefineEValue(p, 88L, "FreeColors");
+ DefineEValue(p, 89L, "StoreColors");
+ DefineEValue(p, 90L, "StoreNamedColor");
+ DefineEValue(p, 91L, "QueryColors");
+ DefineEValue(p, 92L, "LookupColor");
+ DefineEValue(p, 93L, "CreateCursor");
+ DefineEValue(p, 94L, "CreateGlyphCursor");
+ DefineEValue(p, 95L, "FreeCursor");
+ DefineEValue(p, 96L, "RecolorCursor");
+ DefineEValue(p, 97L, "QueryBestSize");
+ DefineEValue(p, 98L, "QueryExtension");
+ DefineEValue(p, 99L, "ListExtensions");
+ DefineEValue(p, 100L, "ChangeKeyboardMapping");
+ DefineEValue(p, 101L, "GetKeyboardMapping");
+ DefineEValue(p, 102L, "ChangeKeyboardControl");
+ DefineEValue(p, 103L, "GetKeyboardControl");
+ DefineEValue(p, 104L, "Bell");
+ DefineEValue(p, 105L, "ChangePointerControl");
+ DefineEValue(p, 106L, "GetPointerControl");
+ DefineEValue(p, 107L, "SetScreenSaver");
+ DefineEValue(p, 108L, "GetScreenSaver");
+ DefineEValue(p, 109L, "ChangeHosts");
+ DefineEValue(p, 110L, "ListHosts");
+ DefineEValue(p, 111L, "SetAccessControl");
+ DefineEValue(p, 112L, "SetCloseDownMode");
+ DefineEValue(p, 113L, "KillClient");
+ DefineEValue(p, 114L, "RotateProperties");
+ DefineEValue(p, 115L, "ForceScreenSaver");
+ DefineEValue(p, 116L, "SetPointerMapping");
+ DefineEValue(p, 117L, "GetPointerMapping");
+ DefineEValue(p, 118L, "SetModifierMapping");
+ DefineEValue(p, 119L, "GetModifierMapping");
+ DefineEValue(p, 127L, "NoOperation");
+
+ p = DefineType(REPLY, ENUMERATED, "REPLY", PrintENUMERATED);
+ DefineEValue(p, 3L, "GetWindowAttributes");
+ DefineEValue(p, 14L, "GetGeometry");
+ DefineEValue(p, 15L, "QueryTree");
+ DefineEValue(p, 16L, "InternAtom");
+ DefineEValue(p, 17L, "GetAtomName");
+ DefineEValue(p, 20L, "GetProperty");
+ DefineEValue(p, 21L, "ListProperties");
+ DefineEValue(p, 23L, "GetSelectionOwner");
+ DefineEValue(p, 26L, "GrabPointer");
+ DefineEValue(p, 31L, "GrabKeyboard");
+ DefineEValue(p, 38L, "QueryPointer");
+ DefineEValue(p, 39L, "GetMotionEvents");
+ DefineEValue(p, 40L, "TranslateCoordinates");
+ DefineEValue(p, 43L, "GetInputFocus");
+ DefineEValue(p, 44L, "QueryKeymap");
+ DefineEValue(p, 47L, "QueryFont");
+ DefineEValue(p, 48L, "QueryTextExtents");
+ DefineEValue(p, 49L, "ListFonts");
+ DefineEValue(p, 50L, "ListFontsWithInfo");
+ DefineEValue(p, 52L, "GetFontPath");
+ DefineEValue(p, 73L, "GetImage");
+ DefineEValue(p, 83L, "ListInstalledColormaps");
+ DefineEValue(p, 84L, "AllocColor");
+ DefineEValue(p, 85L, "AllocNamedColor");
+ DefineEValue(p, 86L, "AllocColorCells");
+ DefineEValue(p, 87L, "AllocColorPlanes");
+ DefineEValue(p, 91L, "QueryColors");
+ DefineEValue(p, 92L, "LookupColor");
+ DefineEValue(p, 97L, "QueryBestSize");
+ DefineEValue(p, 98L, "QueryExtension");
+ DefineEValue(p, 99L, "ListExtensions");
+ DefineEValue(p, 101L, "GetKeyboardMapping");
+ DefineEValue(p, 103L, "GetKeyboardControl");
+ DefineEValue(p, 106L, "GetPointerControl");
+ DefineEValue(p, 108L, "GetScreenSaver");
+ DefineEValue(p, 110L, "ListHosts");
+ DefineEValue(p, 116L, "SetPointerMapping");
+ DefineEValue(p, 117L, "GetPointerMapping");
+ DefineEValue(p, 118L, "SetModifierMapping");
+ DefineEValue(p, 119L, "GetModifierMapping");
+
+ p = DefineType(ERROR, ENUMERATED, "ERROR", PrintENUMERATED);
+ DefineEValue(p, 1L, "Request");
+ DefineEValue(p, 2L, "Value");
+ DefineEValue(p, 3L, "Window");
+ DefineEValue(p, 4L, "Pixmap");
+ DefineEValue(p, 5L, "Atom");
+ DefineEValue(p, 6L, "Cursor");
+ DefineEValue(p, 7L, "Font");
+ DefineEValue(p, 8L, "Match");
+ DefineEValue(p, 9L, "Drawable");
+ DefineEValue(p, 10L, "Access");
+ DefineEValue(p, 11L, "Alloc");
+ DefineEValue(p, 12L, "Colormap");
+ DefineEValue(p, 13L, "GContext");
+ DefineEValue(p, 14L, "IDChoice");
+ DefineEValue(p, 15L, "Name");
+ DefineEValue(p, 16L, "Length");
+ DefineEValue(p, 17L, "Implementation");
+
+ p = DefineType(EVENT, ENUMERATED, "EVENT", PrintENUMERATED);
+ DefineEValue(p, 2L, "KeyPress");
+ DefineEValue(p, 3L, "KeyRelease");
+ DefineEValue(p, 4L, "ButtonPress");
+ DefineEValue(p, 5L, "ButtonRelease");
+ DefineEValue(p, 6L, "MotionNotify");
+ DefineEValue(p, 7L, "EnterNotify");
+ DefineEValue(p, 8L, "LeaveNotify");
+ DefineEValue(p, 9L, "FocusIn");
+ DefineEValue(p, 10L, "FocusOut");
+ DefineEValue(p, 11L, "KeymapNotify");
+ DefineEValue(p, 12L, "Expose");
+ DefineEValue(p, 13L, "GraphicsExposure");
+ DefineEValue(p, 14L, "NoExposure");
+ DefineEValue(p, 15L, "VisibilityNotify");
+ DefineEValue(p, 16L, "CreateNotify");
+ DefineEValue(p, 17L, "DestroyNotify");
+ DefineEValue(p, 18L, "UnmapNotify");
+ DefineEValue(p, 19L, "MapNotify");
+ DefineEValue(p, 20L, "MapRequest");
+ DefineEValue(p, 21L, "ReparentNotify");
+ DefineEValue(p, 22L, "ConfigureNotify");
+ DefineEValue(p, 23L, "ConfigureRequest");
+ DefineEValue(p, 24L, "GravityNotify");
+ DefineEValue(p, 25L, "ResizeRequest");
+ DefineEValue(p, 26L, "CirculateNotify");
+ DefineEValue(p, 27L, "CirculateRequest");
+ DefineEValue(p, 28L, "PropertyNotify");
+ DefineEValue(p, 29L, "SelectionClear");
+ DefineEValue(p, 30L, "SelectionRequest");
+ DefineEValue(p, 31L, "SelectionNotify");
+ DefineEValue(p, 32L, "ColormapNotify");
+ DefineEValue(p, 33L, "ClientMessage");
+ DefineEValue(p, 34L, "MappingNotify");
+
+ DefineEValue(p, 0x80L | 2L, "KeyPress (from SendEvent)");
+ DefineEValue(p, 0x80L | 3L, "KeyRelease (from SendEvent)");
+ DefineEValue(p, 0x80L | 4L, "ButtonPress (from SendEvent)");
+ DefineEValue(p, 0x80L | 5L, "ButtonRelease (from SendEvent)");
+ DefineEValue(p, 0x80L | 6L, "MotionNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 7L, "EnterNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 8L, "LeaveNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 9L, "FocusIn (from SendEvent)");
+ DefineEValue(p, 0x80L | 10L, "FocusOut (from SendEvent)");
+ DefineEValue(p, 0x80L | 11L, "KeymapNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 12L, "Expose (from SendEvent)");
+ DefineEValue(p, 0x80L | 13L, "GraphicsExposure (from SendEvent)");
+ DefineEValue(p, 0x80L | 14L, "NoExposure (from SendEvent)");
+ DefineEValue(p, 0x80L | 15L, "VisibilityNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 16L, "CreateNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 17L, "DestroyNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 18L, "UnmapNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 19L, "MapNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 20L, "MapRequest (from SendEvent)");
+ DefineEValue(p, 0x80L | 21L, "ReparentNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 22L, "ConfigureNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 23L, "ConfigureRequest (from SendEvent)");
+ DefineEValue(p, 0x80L | 24L, "GravityNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 25L, "ResizeRequest (from SendEvent)");
+ DefineEValue(p, 0x80L | 26L, "CirculateNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 27L, "CirculateRequest (from SendEvent)");
+ DefineEValue(p, 0x80L | 28L, "PropertyNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 29L, "SelectionClear (from SendEvent)");
+ DefineEValue(p, 0x80L | 30L, "SelectionRequest (from SendEvent)");
+ DefineEValue(p, 0x80L | 31L, "SelectionNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 32L, "ColormapNotify (from SendEvent)");
+ DefineEValue(p, 0x80L | 33L, "ClientMessage (from SendEvent)");
+ DefineEValue(p, 0x80L | 34L, "MappingNotify (from SendEvent)");
+
+
+ p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY", PrintENUMERATED);
+ DefineEValue(p, 0L, "Forget");
+ DefineEValue(p, 1L, "NorthWest");
+ DefineEValue(p, 2L, "North");
+ DefineEValue(p, 3L, "NorthEast");
+ DefineEValue(p, 4L, "West");
+ DefineEValue(p, 5L, "Center");
+ DefineEValue(p, 6L, "East");
+ DefineEValue(p, 7L, "SouthWest");
+ DefineEValue(p, 8L, "South");
+ DefineEValue(p, 9L, "SouthEast");
+ DefineEValue(p, 10L, "Static");
+
+ p = DefineType(WINGRAVITY, ENUMERATED, "WINGRAVITY", PrintENUMERATED);
+ DefineEValue(p, 0L, "Unmap");
+ DefineEValue(p, 1L, "NorthWest");
+ DefineEValue(p, 2L, "North");
+ DefineEValue(p, 3L, "NorthEast");
+ DefineEValue(p, 4L, "West");
+ DefineEValue(p, 5L, "Center");
+ DefineEValue(p, 6L, "East");
+ DefineEValue(p, 7L, "SouthWest");
+ DefineEValue(p, 8L, "South");
+ DefineEValue(p, 9L, "SouthEast");
+ DefineEValue(p, 10L, "Static");
+
+ p = DefineType(BOOL, ENUMERATED, "BOOL", PrintENUMERATED);
+ DefineEValue(p, 0L, "False");
+ DefineEValue(p, 1L, "True");
+
+ p = DefineType(HOSTFAMILY, ENUMERATED, "HOSTFAMILY", PrintENUMERATED);
+ DefineEValue(p, 0L, "Internet");
+ DefineEValue(p, 1L, "DECnet");
+ DefineEValue(p, 2L, "Chaos");
+
+ p = DefineType(PK_MODE, ENUMERATED, "PK_MODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Synchronous");
+ DefineEValue(p, 1L, "Asynchronous");
+
+ p = DefineType(NO_YES, ENUMERATED, "NO_YES", PrintENUMERATED);
+ DefineEValue(p, 0L, "No");
+ DefineEValue(p, 1L, "Yes");
+ DefineEValue(p, 2L, "Default");
+
+ p = DefineType(WINDOWCLASS, ENUMERATED, "WINDOWCLASS", PrintENUMERATED);
+ DefineEValue(p, 0L, "CopyFromParent");
+ DefineEValue(p, 1L, "InputOutput");
+ DefineEValue(p, 2L, "InputOnly");
+
+ p = DefineType(BACKSTORE, ENUMERATED, "BACKSTORE", PrintENUMERATED);
+ DefineEValue(p, 0L, "NotUseful");
+ DefineEValue(p, 1L, "WhenMapped");
+ DefineEValue(p, 2L, "Always");
+
+ p = DefineType(MAPSTATE, ENUMERATED, "MAPSTATE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Unmapped");
+ DefineEValue(p, 1L, "Unviewable");
+ DefineEValue(p, 2L, "Viewable");
+
+ p = DefineType(STACKMODE, ENUMERATED, "STACKMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Above");
+ DefineEValue(p, 1L, "Below");
+ DefineEValue(p, 2L, "TopIf");
+ DefineEValue(p, 3L, "BottomIf");
+ DefineEValue(p, 4L, "Opposite");
+
+ p = DefineType(CIRMODE, ENUMERATED, "CIRMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "RaiseLowest");
+ DefineEValue(p, 1L, "LowerHighest");
+
+ p = DefineType(CHANGEMODE, ENUMERATED, "CHANGEMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Replace");
+ DefineEValue(p, 1L, "Prepend");
+ DefineEValue(p, 2L, "Append");
+
+ p = DefineType(GRABSTAT, ENUMERATED, "GRABSTAT", PrintENUMERATED);
+ DefineEValue(p, 0L, "Success");
+ DefineEValue(p, 1L, "AlreadyGrabbed");
+ DefineEValue(p, 2L, "InvalidTime");
+ DefineEValue(p, 3L, "NotViewable");
+ DefineEValue(p, 4L, "Frozen");
+
+ p = DefineType(EVENTMODE, ENUMERATED, "EVENTMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "AsyncPointer");
+ DefineEValue(p, 1L, "SyncPointer");
+ DefineEValue(p, 2L, "ReplayPointer");
+ DefineEValue(p, 3L, "AsyncKeyboard");
+ DefineEValue(p, 4L, "SyncKeyboard");
+ DefineEValue(p, 5L, "ReplayKeyboard");
+ DefineEValue(p, 6L, "AsyncBoth");
+ DefineEValue(p, 7L, "SyncBoth");
+
+ p = DefineType(FOCUSAGENT, ENUMERATED, "FOCUSAGENT", PrintENUMERATED);
+ DefineEValue(p, 0L, "None");
+ DefineEValue(p, 1L, "PointerRoot");
+ DefineEValue(p, 2L, "Parent");
+
+ p = DefineType(DIRECT, ENUMERATED, "DIRECT", PrintENUMERATED);
+ DefineEValue(p, 0L, "LeftToRight");
+ DefineEValue(p, 1L, "RightToLeft");
+
+ p = DefineType(GCFUNC, ENUMERATED, "GCFUNC", PrintENUMERATED);
+ DefineEValue(p, 0L, "Clear");
+ DefineEValue(p, 1L, "And");
+ DefineEValue(p, 2L, "AndReverse");
+ DefineEValue(p, 3L, "Copy");
+ DefineEValue(p, 4L, "AndInverted");
+ DefineEValue(p, 5L, "Noop");
+ DefineEValue(p, 6L, "Xor");
+ DefineEValue(p, 7L, "Or");
+ DefineEValue(p, 8L, "Nor");
+ DefineEValue(p, 9L, "Equiv");
+ DefineEValue(p, 10L, "Invert");
+ DefineEValue(p, 11L, "OrReverse");
+ DefineEValue(p, 12L, "CopyInverted");
+ DefineEValue(p, 13L, "OrInverted");
+ DefineEValue(p, 14L, "Nand");
+ DefineEValue(p, 15L, "Set");
+
+ p = DefineType(LINESTYLE, ENUMERATED, "LINESTYLE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Solid");
+ DefineEValue(p, 1L, "OnOffDash");
+ DefineEValue(p, 2L, "DoubleDash");
+
+ p = DefineType(CAPSTYLE, ENUMERATED, "CAPSTYLE", PrintENUMERATED);
+ DefineEValue(p, 0L, "NotLast");
+ DefineEValue(p, 1L, "Butt");
+ DefineEValue(p, 2L, "Round");
+ DefineEValue(p, 3L, "Projecting");
+
+ p = DefineType(JOINSTYLE, ENUMERATED, "JOINSTYLE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Miter");
+ DefineEValue(p, 1L, "Round");
+ DefineEValue(p, 2L, "Bevel");
+
+ p = DefineType(FILLSTYLE, ENUMERATED, "FILLSTYLE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Solid");
+ DefineEValue(p, 1L, "Tiled");
+ DefineEValue(p, 2L, "Stippled");
+ DefineEValue(p, 3L, "OpaqueStippled");
+
+ p = DefineType(FILLRULE, ENUMERATED, "FILLRULE", PrintENUMERATED);
+ DefineEValue(p, 0L, "EvenOdd");
+ DefineEValue(p, 1L, "Winding");
+
+ p = DefineType(SUBWINMODE, ENUMERATED, "SUBWINMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "ClipByChildren");
+ DefineEValue(p, 1L, "IncludeInferiors");
+
+ p = DefineType(ARCMODE, ENUMERATED, "ARCMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Chord");
+ DefineEValue(p, 1L, "PieSlice");
+
+ p = DefineType(RECTORDER, ENUMERATED, "RECTORDER", PrintENUMERATED);
+ DefineEValue(p, 0L, "UnSorted");
+ DefineEValue(p, 1L, "YSorted");
+ DefineEValue(p, 2L, "YXSorted");
+ DefineEValue(p, 3L, "YXBanded");
+
+ p = DefineType(COORMODE, ENUMERATED, "COORMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Origin");
+ DefineEValue(p, 1L, "Previous");
+
+ p = DefineType(POLYSHAPE, ENUMERATED, "POLYSHAPE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Complex");
+ DefineEValue(p, 1L, "Nonconvex");
+ DefineEValue(p, 2L, "Convex");
+
+ p = DefineType(IMAGEMODE, ENUMERATED, "IMAGEMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Bitmap");
+ DefineEValue(p, 1L, "XYPixmap");
+ DefineEValue(p, 2L, "ZPixmap");
+
+ p = DefineType(ALLORNONE, ENUMERATED, "ALLORNONE", PrintENUMERATED);
+ DefineEValue(p, 0L, "None");
+ DefineEValue(p, 1L, "All");
+
+ p = DefineType(OBJECTCLASS, ENUMERATED, "OBJECTCLASS", PrintENUMERATED);
+ DefineEValue(p, 0L, "Cursor");
+ DefineEValue(p, 1L, "Tile");
+ DefineEValue(p, 2L, "Stipple");
+
+ p = DefineType(OFF_ON, ENUMERATED, "OFF_ON", PrintENUMERATED);
+ DefineEValue(p, 0L, "Off");
+ DefineEValue(p, 1L, "On");
+ DefineEValue(p, 2L, "Default");
+
+ p = DefineType(INS_DEL, ENUMERATED, "INS_DEL", PrintENUMERATED);
+ DefineEValue(p, 0L, "Insert");
+ DefineEValue(p, 1L, "Delete");
+
+ p = DefineType(DIS_EN, ENUMERATED, "DIS_EN", PrintENUMERATED);
+ DefineEValue(p, 0L, "Disabled");
+ DefineEValue(p, 1L, "Enabled");
+
+ p = DefineType(CLOSEMODE, ENUMERATED, "CLOSEMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Destroy");
+ DefineEValue(p, 1L, "RetainPermanent");
+ DefineEValue(p, 2L, "RetainTemporary");
+
+ p = DefineType(SAVEMODE, ENUMERATED, "SAVEMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Reset");
+ DefineEValue(p, 1L, "Activate");
+
+ p = DefineType(RSTATUS, ENUMERATED, "RSTATUS", PrintENUMERATED);
+ DefineEValue(p, 0L, "Success");
+ DefineEValue(p, 1L, "Busy");
+ DefineEValue(p, 2L, "Failed");
+
+ p = DefineType(MOTIONDETAIL, ENUMERATED, "MOTIONDETAIL", PrintENUMERATED);
+ DefineEValue(p, 0L, "Normal");
+ DefineEValue(p, 1L, "Hint");
+
+ p = DefineType(ENTERDETAIL, ENUMERATED, "ENTERDETAIL", PrintENUMERATED);
+ DefineEValue(p, 0L, "Ancestor");
+ DefineEValue(p, 1L, "Virtual");
+ DefineEValue(p, 2L, "Inferior");
+ DefineEValue(p, 3L, "Nonlinear");
+ DefineEValue(p, 4L, "NonlinearVirtual");
+ DefineEValue(p, 5L, "Pointer");
+ DefineEValue(p, 6L, "PointerRoot");
+ DefineEValue(p, 7L, "None");
+
+ p = DefineType(BUTTONMODE, ENUMERATED, "BUTTONMODE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Normal");
+ DefineEValue(p, 1L, "Grab");
+ DefineEValue(p, 2L, "Ungrab");
+ DefineEValue(p, 3L, "WhileGrabbed");
+
+ p = DefineType(VISIBLE, ENUMERATED, "VISIBLE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Unobscured");
+ DefineEValue(p, 1L, "PartiallyObscured");
+ DefineEValue(p, 2L, "FullyObscured");
+
+ p = DefineType(CIRSTAT, ENUMERATED, "CIRSTAT", PrintENUMERATED);
+ DefineEValue(p, 0L, "Top");
+ DefineEValue(p, 1L, "Bottom");
+
+ p = DefineType(PROPCHANGE, ENUMERATED, "PROPCHANGE", PrintENUMERATED);
+ DefineEValue(p, 0L, "NewValue");
+ DefineEValue(p, 1L, "Deleted");
+
+ p = DefineType(CMAPCHANGE, ENUMERATED, "CMAPCHANGE", PrintENUMERATED);
+ DefineEValue(p, 0L, "Uninstalled");
+ DefineEValue(p, 1L, "Installed");
+
+ p = DefineType(MAPOBJECT, ENUMERATED, "MAPOBJECT", PrintENUMERATED);
+ DefineEValue(p, 0L, "Modifier");
+ DefineEValue(p, 1L, "Keyboard");
+ DefineEValue(p, 2L, "Pointer");
+
+ p = DefineType(BYTEMODE, ENUMERATED, "BYTEMODE", PrintENUMERATED);
+ DefineEValue(p, 0x42L, "MSB first");
+ DefineEValue(p, 0x6CL, "LSB first");
+
+ p = DefineType(BYTEORDER, ENUMERATED, "BYTEORDER", PrintENUMERATED);
+ DefineEValue(p, 0L, "LSB first");
+ DefineEValue(p, 1L, "MSB first");
+
+ p = DefineType(COLORCLASS, ENUMERATED, "COLORCLASS", PrintENUMERATED);
+ DefineEValue(p, 0L, "StaticGray");
+ DefineEValue(p, 1L, "GrayScale");
+ DefineEValue(p, 2L, "StaticColor");
+ DefineEValue(p, 3L, "PseudoColor");
+ DefineEValue(p, 4L, "TrueColor");
+ DefineEValue(p, 5L, "DirectColor");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+InitSetTypes()
+{
+ TYPE p;
+
+ enterprocedure("InitSetTypes");
+ p = DefineType(SETofEVENT, SET, "SETofEVENT", PrintSET);
+ DefineEValue(p, 0x00000001L, "KeyPress");
+ DefineEValue(p, 0x00000002L, "KeyRelease");
+ DefineEValue(p, 0x00000004L, "ButtonPress");
+ DefineEValue(p, 0x00000008L, "ButtonRelease");
+ DefineEValue(p, 0x00000010L, "EnterWindow");
+ DefineEValue(p, 0x00000020L, "LeaveWindow");
+ DefineEValue(p, 0x00000040L, "PointerMotion");
+ DefineEValue(p, 0x00000080L, "PointerMotionHint");
+ DefineEValue(p, 0x00000100L, "Button1Motion");
+ DefineEValue(p, 0x00000200L, "Button2Motion");
+ DefineEValue(p, 0x00000400L, "Button3Motion");
+ DefineEValue(p, 0x00000800L, "Button4Motion");
+ DefineEValue(p, 0x00001000L, "Button5Motion");
+ DefineEValue(p, 0x00002000L, "ButtonMotion");
+ DefineEValue(p, 0x00004000L, "KeymapState");
+ DefineEValue(p, 0x00008000L, "Exposure");
+ DefineEValue(p, 0x00010000L, "VisibilityChange");
+ DefineEValue(p, 0x00020000L, "StructureNotify");
+ DefineEValue(p, 0x00040000L, "ResizeRedirect");
+ DefineEValue(p, 0x00080000L, "SubstructureNotify");
+ DefineEValue(p, 0x00100000L, "SubstructureRedirect");
+ DefineEValue(p, 0x00200000L, "FocusChange");
+ DefineEValue(p, 0x00400000L, "PropertyChange");
+ DefineEValue(p, 0x00800000L, "ColormapChange");
+ DefineEValue(p, 0x01000000L, "OwnerGrabButton");
+
+ p = DefineType(SETofPOINTEREVENT, SET, "SETofPOINTEREVENT", PrintSET);
+ DefineEValue(p, 0x00000004L, "ButtonPress");
+ DefineEValue(p, 0x00000008L, "ButtonRelease");
+ DefineEValue(p, 0x00000010L, "EnterWindow");
+ DefineEValue(p, 0x00000020L, "LeaveWindow");
+ DefineEValue(p, 0x00000040L, "PointerMotion");
+ DefineEValue(p, 0x00000080L, "PointerMotionHint");
+ DefineEValue(p, 0x00000100L, "Button1Motion");
+ DefineEValue(p, 0x00000200L, "Button2Motion");
+ DefineEValue(p, 0x00000400L, "Button3Motion");
+ DefineEValue(p, 0x00000800L, "Button4Motion");
+ DefineEValue(p, 0x00001000L, "Button5Motion");
+ DefineEValue(p, 0x00002000L, "ButtonMotion");
+ DefineEValue(p, 0x00004000L, "KeymapState");
+
+ p = DefineType(SETofDEVICEEVENT, SET, "SETofDEVICEEVENT", PrintSET);
+ DefineEValue(p, 0x00000001L, "KeyPress");
+ DefineEValue(p, 0x00000002L, "KeyRelease");
+ DefineEValue(p, 0x00000004L, "ButtonPress");
+ DefineEValue(p, 0x00000008L, "ButtonRelease");
+ DefineEValue(p, 0x00000040L, "PointerMotion");
+ DefineEValue(p, 0x00000100L, "Button1Motion");
+ DefineEValue(p, 0x00000200L, "Button2Motion");
+ DefineEValue(p, 0x00000400L, "Button3Motion");
+ DefineEValue(p, 0x00000800L, "Button4Motion");
+ DefineEValue(p, 0x00001000L, "Button5Motion");
+ DefineEValue(p, 0x00002000L, "ButtonMotion");
+
+ p = DefineType(SETofKEYBUTMASK, SET, "SETofKEYBUTMASK", PrintSET);
+ DefineEValue(p, 0x0001L, "Shift");
+ DefineEValue(p, 0x0002L, "Lock");
+ DefineEValue(p, 0x0004L, "Control");
+ DefineEValue(p, 0x0008L, "Mod1");
+ DefineEValue(p, 0x0010L, "Mod2");
+ DefineEValue(p, 0x0020L, "Mod3");
+ DefineEValue(p, 0x0040L, "Mod4");
+ DefineEValue(p, 0x0080L, "Mod5");
+ DefineEValue(p, 0x0100L, "Button1");
+ DefineEValue(p, 0x0200L, "Button2");
+ DefineEValue(p, 0x0400L, "Button3");
+ DefineEValue(p, 0x0800L, "Button4");
+ DefineEValue(p, 0x1000L, "Button5");
+
+ p = DefineType(SETofKEYMASK, SET, "SETofKEYMASK", PrintSET);
+ DefineEValue(p, 0x0001L, "Shift");
+ DefineEValue(p, 0x0002L, "Lock");
+ DefineEValue(p, 0x0004L, "Control");
+ DefineEValue(p, 0x0008L, "Mod1");
+ DefineEValue(p, 0x0010L, "Mod2");
+ DefineEValue(p, 0x0020L, "Mod3");
+ DefineEValue(p, 0x0040L, "Mod4");
+ DefineEValue(p, 0x0080L, "Mod5");
+ DefineEValue(p, 0x8000L, "AnyModifier");
+
+ p = DefineType(COLORMASK, SET, "COLORMASK", PrintSET);
+ DefineEValue(p, 0x01L, "do-red");
+ DefineEValue(p, 0x02L, "do-green");
+ DefineEValue(p, 0x04L, "do-blue");
+
+ p = DefineType(SCREENFOCUS, SET, "SCREENFOCUS", PrintSET);
+ DefineEValue(p, 0x01L, "focus");
+ DefineEValue(p, 0x02L, "same-screen");
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Print Routines for builtin record types */
+
+PrintCHAR2B(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, CARD8, "byte1");
+ PrintField(buf, 1, 1, CARD8, "byte2");
+}
+
+PrintPOINT(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, INT16, "x");
+ PrintField(buf, 2, 2, INT16, "y");
+ return(4);
+}
+
+PrintRECTANGLE(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, INT16, "x");
+ PrintField(buf, 2, 2, INT16, "y");
+ PrintField(buf, 4, 2, CARD16, "width");
+ PrintField(buf, 6, 2, CARD16, "height");
+ return(8);
+}
+
+PrintARC(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, INT16, "x");
+ PrintField(buf, 2, 2, INT16, "y");
+ PrintField(buf, 4, 2, CARD16, "width");
+ PrintField(buf, 6, 2, CARD16, "height");
+ PrintField(buf, 8, 2, INT16, "angle1");
+ PrintField(buf, 10, 2, INT16, "angle2");
+ return(12);
+}
+
+PrintHOST(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(buf, 0, 1, HOSTFAMILY, "family");
+ PrintField(buf, 2, 2, DVALUE2(n), "length of address");
+ n = IShort(&buf[2]);
+ (void)PrintList(&buf[4], (long)n, BYTE, "address");
+ return(pad((long)(4 + n)));
+}
+
+PrintTIMECOORD(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 4, TIMESTAMP, "time");
+ PrintField(buf, 4, 2, CARD16, "x");
+ PrintField(buf, 6, 2, CARD16, "y");
+ return(8);
+}
+
+PrintFONTPROP(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 4, ATOM, "name");
+ PrintField(buf, 4, 4, INT32, "value");
+ return(8);
+}
+
+PrintCHARINFO(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, INT16, "left-side-bearing");
+ PrintField(buf, 2, 2, INT16, "right-side-bearing");
+ PrintField(buf, 4, 2, INT16, "character-width");
+ PrintField(buf, 6, 2, INT16, "ascent");
+ PrintField(buf, 8, 2, INT16, "descent");
+ PrintField(buf, 10, 2, CARD16, "attributes");
+ return(12);
+}
+
+PrintSEGMENT(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, INT16, "x1");
+ PrintField(buf, 2, 2, INT16, "y1");
+ PrintField(buf, 4, 2, INT16, "x2");
+ PrintField(buf, 6, 2, INT16, "y2");
+ return(8);
+}
+
+PrintCOLORITEM(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 4, CARD32, "pixel");
+ PrintField(buf, 4, 2, CARD16, "red");
+ PrintField(buf, 6, 2, CARD16, "green");
+ PrintField(buf, 8, 2, CARD16, "blue");
+ PrintField(buf, 10, 1, COLORMASK, "component selector");
+ return(12);
+}
+
+PrintRGB(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, CARD16, "red");
+ PrintField(buf, 2, 2, CARD16, "green");
+ PrintField(buf, 4, 2, CARD16, "blue");
+ return(8);
+}
+
+PrintFORMAT(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, CARD8, "depth");
+ PrintField(buf, 1, 1, CARD8, "bits-per-pixel");
+ PrintField(buf, 2, 1, CARD8, "scanline-pad");
+ return(8);
+}
+
+PrintSCREEN(buf)
+ unsigned char *buf;
+{
+ short n /* number of elements in List of DEPTH */ ;
+ long m /* length (in bytes) of List of DEPTH */ ;
+
+ PrintField(buf, 0, 4, WINDOW, "root");
+ PrintField(buf, 4, 4, COLORMAP, "default-colormap");
+ PrintField(buf, 8, 4, CARD32, "white-pixel");
+ PrintField(buf, 12, 4, CARD32, "black-pixel");
+ PrintField(buf, 16, 4, SETofEVENT, "current-input-masks");
+ PrintField(buf, 20, 2, CARD16, "width-in-pixels");
+ PrintField(buf, 22, 2, CARD16, "height-in-pixels");
+ PrintField(buf, 24, 2, CARD16, "width-in-millimeters");
+ PrintField(buf, 26, 2, CARD16, "height-in-millimeters");
+ PrintField(buf, 28, 2, CARD16, "min-installed-maps");
+ PrintField(buf, 30, 2, CARD16, "max-installed-maps");
+ PrintField(buf, 32, 4, VISUALID, "root-visual");
+ PrintField(buf, 36, 1, BACKSTORE, "backing-stores");
+ PrintField(buf, 37, 1, BOOL, "save-unders");
+ PrintField(buf, 38, 1, CARD8, "root-depth");
+ PrintField(buf, 39, 1, CARD8, "number of allowed-depths");
+ n = IByte(&buf[39]);
+ m = PrintList(&buf[40], (long)n, DEPTH, "allowed-depths");
+ return(40 + m);
+}
+
+PrintDEPTH(buf)
+ unsigned char *buf;
+{
+ short n /* number of elements in List of VISUALTYPE */ ;
+ short m /* length (in bytes) of List of VISUALTYPE */ ;
+
+ PrintField(buf, 0, 1, CARD8, "depth");
+ PrintField(buf, 2, 2, DVALUE2(n), "number of visuals");
+ n = IShort(&buf[2]);
+ m = PrintList(&buf[8], (long)n, VISUALTYPE, "visuals");
+ return(8 + m);
+}
+
+PrintVISUALTYPE(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 4, VISUALID, "visual-id");
+ PrintField(buf, 4, 1, COLORCLASS, "class");
+ PrintField(buf, 5, 1, CARD8, "bits-per-rgb-value");
+ PrintField(buf, 6, 2, CARD16, "colormap-entries");
+ PrintField(buf, 8, 4, CARD32, "red-mask");
+ PrintField(buf, 12, 4, CARD32, "green-mask");
+ PrintField(buf, 16, 4, CARD32, "blue-mask");
+ return(24);
+}
+
+/* ************************************************************ */
+
+InitRecordTypes()
+{
+ enterprocedure("InitRecordTypes");
+ (void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B);
+ (void) DefineType(POINT, RECORD, "POINT", PrintPOINT);
+ (void) DefineType(RECTANGLE, RECORD, "RECTANGLE", PrintRECTANGLE);
+ (void) DefineType(ARC, RECORD, "ARC", PrintARC);
+ (void) DefineType(HOST, RECORD, "HOST", PrintHOST);
+ (void) DefineType(TIMECOORD, RECORD, "TIMECOORD", PrintTIMECOORD);
+ (void) DefineType(FONTPROP, RECORD, "FONTPROP", PrintFONTPROP);
+ (void) DefineType(CHARINFO, RECORD, "CHARINFO", PrintCHARINFO);
+ (void) DefineType(SEGMENT, RECORD, "SEGMENT", PrintSEGMENT);
+ (void) DefineType(COLORITEM, RECORD, "COLORITEM", PrintCOLORITEM);
+ (void) DefineType(RGB, RECORD, "RGB", PrintRGB);
+ (void) DefineType(FORMAT, RECORD, "FORMAT", PrintFORMAT);
+ (void) DefineType(SCREEN, RECORD, "SCREEN", PrintSCREEN);
+ (void) DefineType(DEPTH, RECORD, "DEPTH", PrintDEPTH);
+ (void) DefineType(VISUALTYPE, RECORD, "VISUALTYPE", PrintVISUALTYPE);
+}
+
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+InitValuesTypes()
+{
+ TYPE p;
+
+ enterprocedure("InitValueTypes");
+ p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK", PrintSET);
+
+ DefineValues(p, 0x00000001L, 4, PIXMAPNPR, "background-pixmap");
+ DefineValues(p, 0x00000002L, 4, CARD32, "background-pixel");
+ DefineValues(p, 0x00000004L, 4, PIXMAPC, "border-pixmap");
+ DefineValues(p, 0x00000008L, 4, CARD32, "border-pixel");
+ DefineValues(p, 0x00000010L, 1, BITGRAVITY, "bit-gravity");
+ DefineValues(p, 0x00000020L, 1, WINGRAVITY, "win-gravity");
+ DefineValues(p, 0x00000040L, 1, BACKSTORE, "backing-store");
+ DefineValues(p, 0x00000080L, 4, CARD32, "backing-planes");
+ DefineValues(p, 0x00000100L, 4, CARD32, "backing-pixel");
+ DefineValues(p, 0x00000200L, 1, BOOL, "override-redirect");
+ DefineValues(p, 0x00000400L, 1, BOOL, "save-under");
+ DefineValues(p, 0x00000800L, 4, SETofEVENT, "event-mask");
+ DefineValues(p, 0x00001000L, 4, SETofDEVICEEVENT, "do-not-propagate-mask");
+ DefineValues(p, 0x00002000L, 4, COLORMAPC, "colormap");
+ DefineValues(p, 0x00004000L, 4, CURSOR, "cursor");
+
+ p = DefineType(CONFIGURE_BITMASK, SET, "CONFIGURE_BITMASK", PrintSET);
+ DefineValues(p, 0x0001L, 2, INT16, "x");
+ DefineValues(p, 0x0002L, 2, INT16, "y");
+ DefineValues(p, 0x0004L, 2, CARD16, "width");
+ DefineValues(p, 0x0008L, 2, CARD16, "height");
+ DefineValues(p, 0x0010L, 2, CARD16, "border-width");
+ DefineValues(p, 0x0020L, 4, WINDOW, "sibling");
+ DefineValues(p, 0x0040L, 1, STACKMODE, "stack-mode");
+
+ p = DefineType(GC_BITMASK, SET, "GC_BITMASK", PrintSET);
+ DefineValues(p, 0x00000001L, 1, GCFUNC, "function");
+ DefineValues(p, 0x00000002L, 4, CARD32, "plane-mask");
+ DefineValues(p, 0x00000004L, 4, CARD32, "foreground");
+ DefineValues(p, 0x00000008L, 4, CARD32, "background");
+ DefineValues(p, 0x00000010L, 2, CARD16, "line-width");
+ DefineValues(p, 0x00000020L, 1, LINESTYLE, "line-style");
+ DefineValues(p, 0x00000040L, 1, CAPSTYLE, "cap-style");
+ DefineValues(p, 0x00000080L, 1, JOINSTYLE, "join-style");
+ DefineValues(p, 0x00000100L, 1, FILLSTYLE, "fill-style");
+ DefineValues(p, 0x00000200L, 1, FILLRULE, "fill-rule");
+ DefineValues(p, 0x00000400L, 4, PIXMAP, "tile");
+ DefineValues(p, 0x00000800L, 4, PIXMAP, "stipple");
+ DefineValues(p, 0x00001000L, 2, INT16, "tile-stipple-x-origin");
+ DefineValues(p, 0x00002000L, 2, INT16, "tile-stipple-y-origin");
+ DefineValues(p, 0x00004000L, 4, FONT, "font");
+ DefineValues(p, 0x00008000L, 1, SUBWINMODE, "subwindow-mode");
+ DefineValues(p, 0x00010000L, 1, BOOL, "graphics-exposures");
+ DefineValues(p, 0x00020000L, 2, INT16, "clip-x-origin");
+ DefineValues(p, 0x00040000L, 2, INT16, "clip-y-origin");
+ DefineValues(p, 0x00080000L, 4, PIXMAP, "clip-mask");
+ DefineValues(p, 0x00100000L, 2, CARD16, "dash-offset");
+ DefineValues(p, 0x00200000L, 1, CARD8, "dashes");
+ DefineValues(p, 0x00400000L, 1, ARCMODE, "arc-mode");
+
+ p = DefineType(KEYBOARD_BITMASK, SET, "KEYBOARD_BITMASK", PrintSET);
+ DefineValues(p, 0x0001L, 1, INT8, "key-click-percent");
+ DefineValues(p, 0x0002L, 1, INT8, "bell-percent");
+ DefineValues(p, 0x0004L, 2, INT16, "bell-pitch");
+ DefineValues(p, 0x0008L, 2, INT16, "bell-duration");
+ DefineValues(p, 0x0010L, 1, CARD8, "led");
+ DefineValues(p, 0x0020L, 1, OFF_ON, "led-mode");
+ DefineValues(p, 0x0040L, 1, KEYCODE, "key");
+ DefineValues(p, 0x0080L, 1, OFF_ON, "auto-repeat-mode");
+}
diff --git a/x11.h b/x11.h
new file mode 100644
index 0000000..059b159
--- /dev/null
+++ b/x11.h
@@ -0,0 +1,452 @@
+/* ************************************************************ *
+ * *
+ * Type definitions and Connection State for the X11 protocol *
+ * *
+ * James Peterson, 1988 *
+ * Copyright (C) 1988 MCC
+ *
+ * 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 MCC not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. MCC makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL MCC 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.
+ * *
+ * ************************************************************ */
+
+
+/* Some field contents are constants, not just types */
+
+#define CONST1(n) CARD8
+#define CONST2(n) CARD16
+#define CONST4(n) CARD32
+
+/* Some field contents define the components of an expression */
+
+#define DVALUE1(expression) CARD8
+#define DVALUE2(expression) CARD16
+#define DVALUE4(expression) CARD32
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Built-in Types */
+
+#define BYTE 1 /* 8-bit value */
+#define INT8 2 /* 8-bit signed integer */
+#define INT16 3 /* 16-bit signed integer */
+#define INT32 4 /* 32-bit signed integer */
+#define CARD8 5 /* 8-bit unsigned integer */
+#define CARD16 6 /* 16-bit unsigned integer */
+#define CARD32 7 /* 32-bit unsigned integer */
+#define STRING8 8 /* List of CARD8 */
+#define STRING16 9 /* List of CHAR2B */
+#define TEXTITEM8 10 /* STRING8 or Font shift */
+#define TEXTITEM16 11 /* STRING16 or Font shift */
+
+#define WINDOW 12 /* CARD32 plus 0 = None */
+#define WINDOWD 13 /* CARD32 plus 0 = PointerWindow, 1 =
+ InputFocus */
+#define WINDOWNR 14 /* CARD32 plus 0 = None, 1 = PointerRoot */
+
+#define PIXMAP 15 /* CARD32 plus 0 = None */
+#define PIXMAPNPR 16 /* CARD32 plus 0 = None, 1 = ParentRelative
+ */
+#define PIXMAPC 17 /* CARD32 plus 0 = CopyFromParent */
+
+#define CURSOR 18 /* CARD32 plus 0 = None */
+
+#define FONT 19 /* CARD32 plus 0 = None */
+
+#define GCONTEXT 20 /* CARD32 */
+
+#define COLORMAP 21 /* CARD32 plus 0 = None */
+#define COLORMAPC 22 /* CARD32 plus 0 = CopyFromParent */
+
+#define DRAWABLE 23 /* CARD32 */
+#define FONTABLE 24 /* CARD32 */
+
+#define ATOM 25 /* CARD32 plus 0 = None */
+#define ATOMT 26 /* CARD32 plus 0 = AnyPropertyType */
+
+#define VISUALID 27 /* CARD32 plus 0 = None */
+#define VISUALIDC 28 /* CARD32 plus 0 = CopyFromParent */
+
+#define TIMESTAMP 29 /* CARD32 plus 0 as the current time */
+
+#define RESOURCEID 30 /* CARD32 plus 0 = AllTemporary */
+
+#define KEYSYM 31 /* CARD32 */
+#define KEYCODE 32 /* CARD8 */
+#define KEYCODEA 33 /* CARD8 plus 0 = AnyKey */
+
+#define BUTTON 34 /* CARD8 */
+#define BUTTONA 35 /* CARD8 plus 0 = AnyButton */
+
+#define EVENTFORM 36 /* event format */
+#define CHAR8 37 /* CARD8 interpreted as a character */
+#define STR 38 /* String of CHAR8 with preceding length */
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Defined types */
+
+#define BITGRAVITY 40
+#define WINGRAVITY 41
+#define BOOL 42
+#define HOSTFAMILY 43
+#define PK_MODE 44
+#define NO_YES 45
+#define WINDOWCLASS 46
+#define BACKSTORE 47
+#define MAPSTATE 48
+#define STACKMODE 49
+#define CIRMODE 50
+#define CHANGEMODE 51
+#define GRABSTAT 52
+#define EVENTMODE 53
+#define FOCUSAGENT 54
+#define DIRECT 55
+#define GCFUNC 56
+#define LINESTYLE 57
+#define CAPSTYLE 58
+#define JOINSTYLE 59
+#define FILLSTYLE 60
+#define FILLRULE 61
+#define SUBWINMODE 62
+#define ARCMODE 63
+#define RECTORDER 64
+#define COORMODE 65
+#define POLYSHAPE 66
+#define IMAGEMODE 67
+#define ALLORNONE 68
+#define OBJECTCLASS 69
+#define OFF_ON 70
+#define INS_DEL 71
+#define DIS_EN 72
+#define CLOSEMODE 73
+#define SAVEMODE 74
+#define RSTATUS 75
+#define MOTIONDETAIL 76
+#define ENTERDETAIL 77
+#define BUTTONMODE 78
+#define SCREENFOCUS 79
+#define VISIBLE 80
+#define CIRSTAT 81
+#define PROPCHANGE 82
+#define CMAPCHANGE 83
+#define MAPOBJECT 84
+#define SETofEVENT 85
+#define SETofPOINTEREVENT 86
+#define SETofDEVICEEVENT 87
+#define SETofKEYBUTMASK 88
+#define SETofKEYMASK 89
+#define WINDOW_BITMASK 90
+#define CONFIGURE_BITMASK 91
+#define GC_BITMASK 92
+#define KEYBOARD_BITMASK 93
+#define COLORMASK 94
+#define CHAR2B 95
+#define POINT 96
+#define RECTANGLE 97
+#define ARC 98
+#define HOST 99
+#define TIMECOORD 100
+#define FONTPROP 101
+#define CHARINFO 102
+#define SEGMENT 103
+#define COLORITEM 104
+#define RGB 105
+#define BYTEMODE 110
+#define BYTEORDER 111
+#define COLORCLASS 112
+#define FORMAT 113
+#define SCREEN 114
+#define DEPTH 115
+#define VISUALTYPE 116
+
+#define REQUEST 117
+#define REPLY 118
+#define ERROR 119
+#define EVENT 120
+
+#define MaxTypes 128
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* declaration of the existance of print routines for the basic types */
+
+extern PrintINT8();
+extern PrintINT16();
+extern PrintINT32();
+extern PrintCARD8();
+extern PrintCARD16();
+extern PrintCARD32();
+extern PrintBYTE();
+extern PrintCHAR8();
+extern PrintSTRING16();
+extern PrintTEXTITEM8();
+extern PrintTEXTITEM16();
+extern PrintSTR();
+extern PrintWINDOW();
+extern PrintWINDOWD();
+extern PrintWINDOWNR();
+extern PrintPIXMAP();
+extern PrintPIXMAPNPR();
+extern PrintPIXMAPC();
+extern PrintCURSOR();
+extern PrintFONT();
+extern PrintGCONTEXT();
+extern PrintCOLORMAP();
+extern PrintCOLORMAPC();
+extern PrintDRAWABLE();
+extern PrintFONTABLE();
+extern PrintATOM();
+extern PrintATOMT();
+extern PrintVISUALID();
+extern PrintVISUALIDC();
+extern PrintTIMESTAMP();
+extern PrintRESOURCEID();
+extern PrintKEYSYM();
+extern PrintKEYCODE();
+extern PrintKEYCODEA();
+extern PrintBUTTON();
+extern PrintBUTTONA();
+extern PrintEVENTFORM();
+extern PrintENUMERATED();
+extern PrintSET();
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Type Definition Table
+
+ Each item in the X11 Protocol has a type. There are about 120
+ different types. We need to be able to print each item in a
+ format and interpretation which is appropriate for the type of
+ that item. To do so, we build a table describing each type.
+ Each type has a name, possibly a list of named values and a
+ procedure which knows how to print that type.
+*/
+
+/* Types of Types */
+
+#define BUILTIN 1
+#define ENUMERATED 2
+#define SET 3
+#define RECORD 5
+
+
+/* Enumerated and Set types need a list of Named Values */
+
+struct ValueListEntry
+{
+ struct ValueListEntry *Next;
+ char *Name;
+ short Type;
+ short Length;
+ long Value;
+};
+
+struct TypeDef
+{
+ char *Name;
+ short Type /* BUILTIN, ENUMERATED, SET, or RECORD */ ;
+ struct ValueListEntry *ValueList;
+ int (*PrintProc)();
+};
+
+typedef struct TypeDef *TYPE;
+
+struct TypeDef TD[MaxTypes];
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Reply Buffer: Pseudo-buffer used to provide the opcode for the
+ request to which this is a reply: Set by DecodeReply
+ and used in the PrintField of the Reply procedure */
+unsigned char RBf[2];
+
+
+/* Sequence Buffer: Pseudo-buffer used to provide the sequence number for a
+ request: Set by DecodeReply and used in a PrintField of
+ the Request procedure */
+unsigned char SBf[4];
+
+
+#define PRINTSERVER 5 /* indent output as if it comes from server */
+#define PRINTCLIENT 1 /* indent output as if it comes from client */
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ In general, we are called with a buffer of bytes and are supposed to
+ try to make sense of these bytes according to the X11 protocol. There
+ are two different types of communication: requests from the client to
+ the server and replies/errors/events from the server to the client.
+ We must interpret these two differently.
+
+ Also, we must consider that the bytes on the communication socket may
+ be sent asynchronously in any amount. This means that we must be prepared
+ to read in and save some bytes until we get enough to do something with
+ them. For example, suppose that we get a buffer from a client. We would
+ expect it to be a request. The request may be 24 bytes long. We may find,
+ however, that only 16 bytes have actually arrived -- the other 8 are stuck
+ in a buffer somewhere. We must be prepared to simply hold the 16 bytes we
+ have until more bytes arrive.
+
+ In general, we do two things: we wait for some number of bytes, and
+ then we interpret this set of bytes. To interpret this data we use
+ a modified state machine. We keep two pieces of information:
+
+ (1) the number of bytes that we need
+ (2) what to do with those bytes.
+
+ This last piece of information is the "state" of the interpretation.
+ We keep the state as a pointer to the procedure that is to be executed.
+
+
+ CLIENTS:
+
+ The data going from the client to the x11 server consists of a
+ set-up message followed by an infinite stream of variable length
+ requests.
+
+ Our overall flow is then:
+
+ (a) Wait for 12 bytes.
+ (b) Interpret these first 12 bytes of the set-up message to get the
+ length of the rest of the message.
+ (c) Wait for the rest of the set-up message.
+ (d) Interpret and print the set-up message.
+
+ *** end of set-up phase -- start normal request loop ***
+
+ (e) Wait for 4 bytes.
+ (f) Interpret these 4 bytes to get the length of the rest of the command.
+ (g) Wait for the rest of the command.
+ (h) Interpret and print the command.
+ (i) Go back to step (e).
+
+ SERVERS:
+
+ Again, we have a set-up reply followed by an infinite stream of variable
+ length replies/errors/events.
+
+ Our overall flow is then:
+
+ (a) Wait for 8 bytes.
+ (b) Interpret the 8 bytes to get the length of the rest of the set-up reply.
+ (c) Wait for the rest of the set-up reply.
+ (d) Interpret and print the set-up reply.
+
+ *** end of set-up phase -- start normal reply/error/event loop ***
+
+ We have the following properties of X11 replies, errors, and events:
+
+ Replies: 32 bytes plus a variable amount. Byte 0 is 1.
+ Bytes 2-3 are a sequence number; bytes 4-7 are length (n). The
+ complete length of the reply is 32 + 4 * n.
+
+ Errors: 32 bytes. Byte 0 is 0.
+ Byte 1 is an error code; bytes 2-3 are a sequence number.
+ Bytes 8-9 are a major opcode; byte 10 is a minor opcode.
+
+ Events: 32 bytes. Byte 0 is 2, 3, 4, ....
+
+ Looking at this we have two choices: wait for one byte and then separately
+ wait for replies, errors, and events, or wait for 32 bytes, then separately
+ process each type. We may have to wait for more, in the event of a reply.
+ This latter seems more effective. It appears reply/error/event formats
+ were selected to allow waiting for 32 bytes, and it will allow short packets
+ which are only 32 bytes long, to be processed completely in one step.
+
+ Thus, For normal reply/error/event processing we have
+
+ (e) Wait for 32 bytes.
+ (f) Interpret these 32 bytes. If possible, go back to step (e).
+ (g) If the packet is a reply with bytes 4-7 non-zero, wait for the
+ remainder of the the reply.
+ (h) Interpret and print the longer reply. Go back to step (e).
+
+
+ The similarity in approach to how both the client and server are handled
+ suggests we can use the same control structure to drive the interpretation
+ of both types of communication client->server and server->client.
+ Accordingly, we package up the relevant variables in a ConnState
+ record. The ConnState record contains the buffer of saved bytes (if any),
+ the size and length of this buffer, the number of bytes we are waiting for
+ and what to do when we get them. A separate ConnState record is kept
+ for the client and server.
+
+ In addition, we may have several different client or server connections.
+ Thus we need an array of all the necessary state for each client or server.
+ A client/server is identified with a file descriptor (fd), so we use the
+ fd to identify the client/server and use it as an index into an array of
+ state variables.
+*/
+
+struct ConnState
+{
+ unsigned char *SavedBytes;
+ long SizeofSavedBytes;
+ long NumberofSavedBytes;
+
+ long NumberofBytesNeeded;
+ long (*ByteProcessing)();
+
+ long SequenceNumber;
+};
+
+struct ConnState CS[StaticMaxFD];
+
+
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* declaraction of the types of some common functions */
+
+extern unsigned long ILong();
+extern unsigned short IShort();
+extern unsigned short IChar2B();
+extern unsigned short IByte();
+extern Boolean IBool();
+
+extern PrintString8();
+extern PrintString16();
+extern PrintListSTR();
+
+extern long PrintList();
+extern long pad();
diff --git a/xscope.1 b/xscope.1
new file mode 100644
index 0000000..50f9b34
--- /dev/null
+++ b/xscope.1
@@ -0,0 +1,107 @@
+.TH XSCOPE 1 "8 Sept 1988" "X Version 11"
+.SH NAME
+xscope - X Window Protocol Viewer
+.SH SYNOPSIS
+.B xscope
+[ option ] ...
+.SH DESCRIPTION
+.I Xscope
+sits in-between an X11 client and an X11 server and prints the contents
+of each request, reply, error, or event that is communicated between them.
+This information can be useful in debugging and performance
+tuning of X11 servers and clients.
+.PP
+To operate, \fIxscope\fP must know the host, port, and display to use
+to connect to the X11 server. In addition, it must know the port on
+which it should listen for X11 clients. Two cases are common:
+.PP
+.TP 5
+(1) The X11 server is on the same host as \fIxscope\fP.
+In this case, the input port for \fIxscope\fP should be selected as an
+X11 server on a different display, and the client DISPLAY argument
+adjusted to select \fIxscope\fP . For example, if the X11 server is
+on port 6000, display 1, then \fIxscope\fP can use port 6002 as its
+input port. The client can use display 1 for direct access to X11 or
+display 2 for access to \fIxscope\fP.
+.PP
+.TP 5
+(2) The X11 server is on a different host than \fIxscope\fP.
+In this case the same input and output ports can be used, and the host
+component of the DISPLAY is used to select \fIxscope\fP or X11.
+.SH ARGUMENTS
+.PP
+.TP 10
+.B \-i<input-port>
+Specify the port that \fIxscope\fP will use to take requests from clients
+(defaults to 1).
+For X11, this port is automatically biased by 6000.
+.PP
+.TP 10
+.B \-o<output-port>
+Determines the port that
+\fIxscope\fP will use to connect to X11 (defaults to 0).
+For X11, this port is automatically biased by 6000.
+.PP
+.TP 10
+.B \-h<host>
+Determines the host that \fIxscope\fP will use to find its X11 server.
+.PP
+.TP 10
+.B \-d<display>
+Defines the display number. The display number is added to the input
+and output port to give the actual ports which are used by \fIxscope\fP.
+.PP
+.TP 10
+.B \-q
+Quiet output mode. Gives only the names of requests, replies, errors, and
+events, but does not indicate contents.
+.PP
+.TP 10
+.B \-v<print-level>
+Determines the level of printing which \fIxscope\fP will provide. The
+print-level can be 0 (same as quiet mode), 1, 2, 3, 4. The larger
+numbers give more and more output. For example, a successful setup
+returns a string which is the name of the vendor of the X11 server.
+At level 1, the explicit field giving the length of the string is
+suppressed since it can be inferred from the string. At level 2 and
+above the length is explicitly printed.
+.SH EXAMPLES
+.LP
+xscope -v4 -hcleo -d0 -o0 -i1
+.PP
+This command would have xscope communicate with an X11 server on host
+``cleo'', display 0; xscope itself would be available on the current
+host as display 1 (display of 0 plus the 1 of -i1). Verbose level 4.
+.LP
+xscope -q -d1 -o1 -o3
+.PP
+The X11 server for the current host, display 2 (1 for -d1 plus 1 for -o1)
+would be used by xscope which would run as display 4 (1 for -d1 plus 3 for
+-o3). Quite mode (verbose level 0).
+.SH SEE ALSO
+X(1), X11 Protocol document (doc/Protocol/X11.protocol)
+.SH AUTHOR
+.PP
+James L. Peterson (MCC)
+.PP
+Copyright (C) 1988 MCC
+.PP
+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 MCC not be used in
+advertising or publicity pertaining to distribution of the software without
+specific, written prior permission. MCC makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+.PP
+MCC DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL MCC 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.
+.SH BUGS
+Code has only been tested on Sun3's.