summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2001-06-08 00:32:52 +0000
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-05-04 18:13:07 -0700
commit062412a066cc62635c1d1eb99999ee774775ca6f (patch)
tree3a72f748e101900c292cf242055862ecce4bccb7
parent306057f2475b216fb73686bcb0003355cf88944a (diff)
downloadxscope-062412a066cc62635c1d1eb99999ee774775ca6f.tar.gz
Import xscope bits into keithp.com CVS
-rw-r--r--Imakefile64
-rw-r--r--Makefile69
-rw-r--r--Makefile.meta69
-rw-r--r--README91
-rw-r--r--audio.c480
-rw-r--r--bigreqscope.h17
-rw-r--r--common.c143
-rw-r--r--decode11.c603
-rw-r--r--decode_bigreq.c80
-rw-r--r--decode_lbx.c149
-rw-r--r--decode_pex.c786
-rw-r--r--decode_randr.c98
-rw-r--r--decode_render.c240
-rw-r--r--decode_shm.c116
-rw-r--r--decode_wcp.c130
-rw-r--r--decodenas.c465
-rw-r--r--fd.c276
-rw-r--r--fd.h18
-rw-r--r--imakefile5
-rw-r--r--lbxscope.h48
-rw-r--r--nas.h123
-rw-r--r--patchlevel.h2
-rw-r--r--pexOCNames.h134
-rw-r--r--pexOCTab.awk86
-rw-r--r--pexRNames.h134
-rw-r--r--pexRTab.awk81
-rw-r--r--pexscope.h62
-rw-r--r--print11.c691
-rw-r--r--print_bigreq.c53
-rw-r--r--print_lbx.c197
-rw-r--r--print_pex.c917
-rw-r--r--print_randr.c155
-rw-r--r--print_render.c480
-rw-r--r--print_shm.c171
-rw-r--r--print_wcp.c465
-rw-r--r--printnas.c950
-rw-r--r--prtype.c175
-rw-r--r--randrscope.h21
-rw-r--r--renderscope.h27
-rw-r--r--scope.c969
-rw-r--r--scope.h46
-rw-r--r--server.c209
-rw-r--r--shmscope.h16
-rw-r--r--table11.c121
-rw-r--r--tablenas.c29
-rw-r--r--wcpscope.h45
-rw-r--r--x11.h298
-rw-r--r--xscope.1107
-rw-r--r--xscope.man163
-rw-r--r--xstats.c114
50 files changed, 9646 insertions, 1342 deletions
diff --git a/Imakefile b/Imakefile
new file mode 100644
index 0000000..e0ecf64
--- /dev/null
+++ b/Imakefile
@@ -0,0 +1,64 @@
+##
+# $XConsortium: Imakefile,v 5.11 91/09/17 08:52:54 rws Exp $
+##
+##
+## Copyright 1990, 1991, 1990 by Sun Microsystems, Inc. and the X Consortium.
+##
+## All Rights Reserved
+##
+## Permission to use, copy, modify, and distribute this software and its
+## documentation for any purpose and without fee is hereby granted,
+## provided that the above copyright notice appear in all copies and that
+## both that copyright notice and this permission notice appear in
+## supporting documentation, and that the names of Sun Microsystems,
+## the X Consortium, and MIT not be used in advertising or publicity
+## pertaining to distribution of the software without specific, written
+## prior permission.
+##
+## SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+## INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+## EVENT SHALL SUN MICROSYSTEMS 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.
+
+ SYS_LIBRARIES = -lm
+#if BuildPEX
+ PEX_INCLUDE = $(INCDIR)/extensions
+ PEX_SRC = decode_pex.c print_pex.c
+ PEX_OBJ = decode_pex.o print_pex.o
+ PEX_DEFINES = -DPEX
+#endif
+ DEFINES = $(PEX_DEFINES)
+
+ SRCS = prtype.c print11.c table11.c decode11.c \
+ server.c fd.c common.c scope.c audio.c \
+ decode_lbx.c print_lbx.c printnas.c decodenas.c \
+ decode_wcp.c print_wcp.c decode_render.c print_render.c \
+ decode_randr.c print_randr.c \
+ $(PEX_SRC)
+ OBJS = scope.o common.o fd.o server.o decode11.o \
+ table11.o print11.o prtype.o audio.o \
+ decode_lbx.o print_lbx.o printnas.o decodenas.o \
+ decode_wcp.o print_wcp.o decode_render.o print_render.o \
+ decode_randr.o print_randr.o \
+ $(PEX_OBJ)
+
+ComplexProgramTarget(xscope)
+SpecialObjectRule(common.o,$(_NOOP_),$(SIGNAL_DEFINES))
+
+#if BuildPEX
+includes:: pexRNames.h pexOCNames.h
+
+pexOCNames.h: pexOCTab.awk $(PEX_INCLUDE)/PEX.h
+ $(RM) $@
+ awk -f pexOCTab.awk $(PEX_INCLUDE)/PEX.h > $@
+
+pexRNames.h: pexRTab.awk $(PEX_INCLUDE)/PEX.h
+ $(RM) $@
+ awk -f pexRTab.awk $(PEX_INCLUDE)/PEX.h > $@
+depend:: pexRNames.h pexOCNames.h
+
+clean:: pexRNames.h pexOCNames.h
+#endif
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 1e52d9c..0000000
--- a/Makefile
+++ /dev/null
@@ -1,69 +0,0 @@
-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
deleted file mode 100644
index c962af0..0000000
--- a/Makefile.meta
+++ /dev/null
@@ -1,69 +0,0 @@
-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/README b/README
new file mode 100644
index 0000000..39e78b1
--- /dev/null
+++ b/README
@@ -0,0 +1,91 @@
+
+ XSCOPE -- a program to monitor X11/Client conversations
+
+XSCOPE is a program to monitor the connections between the X11 window
+server and a client program. xscope runs as a separate process. By
+adjusting the host and/or display number that a X11 client attaches
+to, the client is attached to xscope instead of X11. xscope attaches
+to X11 as if it were the client. All bytes from the client are sent
+to xscope which passes them on to X11; All bytes from X11 are sent to
+xscope which sends them on to the client. xscope is transparent to
+the client and X11.
+
+In addition to passing characters back and forth, xscope will print
+information about this traffic on stdout, giving performance and
+debugging information for an X11 client and server.
+
+
+ -------------- -------------- --------------
+ | | | | | |
+ | | ------------> | | ----------> | |
+ | client | | xscope | | server |
+ | | | | | |
+ | | <----------- | | <---------- | |
+ | | | | | |
+ -------------- -------------- --------------
+ |
+ |
+ v
+ trace output to stdout
+
+
+When running with xscope, three processes are involved, potentially all
+on different machines:
+
+X11 -- the X11 window server will be running on machine "A" for Display "B".
+ ("A" is a machine name; "B" is a display number).
+
+xscope -- xscope must be told where the X11 window server is
+ (what machine and what display). The options for xscope are
+ -h<X11-host> and -d<display-number>. In our example, -hA and -dB.
+ Typically the display-number is not given. xscope will not try to
+ connect to X11 until the client connects to xscope.
+
+client -- the client should connect to xscope rather than X11. To avoid
+ changing the code for the client, xscope listens on the same port
+ as X11. If X11 and xscope are on different machines, this works
+ well. However, if X11 and xscope are on the same machine, this
+ creates a port conflict. To resolve this conflict, xscope can
+ be given a different input or output port number, as necessary
+ to avoid the port that X11 is listening to. The client must connect
+ to this offset port number. The input port for xscope is set by
+ -i<port-number>; the output port is set by -o<port-number>. The
+ default input port is 1; the default output port is 0. These ports
+ are offset by the X11 base (6000) and the display number. The client
+ attaches to xscope by changing its display number by the port offset.
+
+For example, with X11 running on "bagel", display 0 (the default), and
+xscope and the client running on "cleo", we would start xscope as
+"xscope -hbagel -i0". The client program could then connect to "X11" on
+"cleo:0", and would be attached to xscope, which would then attach to
+X11 on "bagel:0".
+
+If, however, all three processes were running on "cleo", we would
+start xscope by "xscope -i1". This would cause it to listen on
+port 6001 (which is display 1 for X11). The client would attach to
+X11 on "cleo:1", and xscope would connect through to X11 on "cleo:0".
+
+
+LIMITATIONS:
+
+xscope has been written and used on a Sun3. Additional code may be needed
+for byteswapping on different architectures.
+
+The command line arguments for specifying the real X server should probably
+ be changed to be more consistent with X11R3 applications.
+
+The Imakefile may be incorrect.
+
+The builtin atoms have been wired in directly; they should probably be
+picked up from a header file.
+
+No provision is included for extensions to the base protocol.
+
+There is no code yet to interpret typed commands from the keyboard.
+ It would be possible for a command language at the keyboard to create
+ artificial characters to be sent to X11 or the client as if they were
+ generated by the other, or to dynamically alter requests or replies.
+
+
+
+
diff --git a/audio.c b/audio.c
new file mode 100644
index 0000000..4bf2056
--- /dev/null
+++ b/audio.c
@@ -0,0 +1,480 @@
+/*
+ * $NCDOr: audio.c,v 1.1 1996/07/18 23:25:52 keithp Exp keithp $
+ *
+ * Copyright 1996 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#include "scope.h"
+#include "nas.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, ... */
+#ifdef SVR4
+#include <sys/filio.h>
+#endif
+#include <fcntl.h>
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <netinet/tcp.h>
+#include <netdb.h> /* struct servent * and struct hostent * */
+#include <errno.h> /* for EINTR, EADDRINUSE, ... */
+extern int errno;
+
+extern char ScopeEnabled;
+
+ReportFromAudioClient (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ if (NasVerbose) {
+ if (ScopeEnabled) {
+ PrintTime ();
+ fprintf(stdout, "NAS Client%s --> %4d %s\n",
+ ClientName(fd), n, (n == 1 ? "byte" : "bytes"));
+ }
+ }
+ ProcessBuffer (fd, buf, n);
+}
+
+ReportFromAudioServer(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ if (NasVerbose) {
+ if (ScopeEnabled) {
+ PrintTime();
+ fprintf(stdout, "\t\t\t\t\t%4d %s <-- NAS Server%s\n",
+ n, (n == 1 ? "byte" : "bytes"), ClientName(fd));
+ }
+ }
+ ProcessBuffer(fd, buf, n);
+}
+
+extern long StartAudioSetUpMessage ();
+extern long FinishAudioSetUpMessage ();
+extern long StartAudioRequest ();
+extern long FinishAudioRequest ();
+extern long StartAudioSetUpReply ();
+extern long FinishAudioSetUpReply ();
+extern long AudioServerPacket ();
+extern long FinishAudioReply ();
+extern long FlushFD ();
+
+StartAudioClientConnection(fd)
+ FD fd;
+{
+ enterprocedure("StartAudioClientConnection");
+ /* when a new connection is started, we have no saved bytes */
+ CS[fd].SavedBytes = NULL;
+ CS[fd].SizeofSavedBytes = 0;
+ CS[fd].NumberofSavedBytes = 0;
+ CS[fd].NumberofBytesProcessed = 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 = StartAudioSetUpMessage;
+ CS[fd].NumberofBytesNeeded = 12;
+}
+
+StopAudioClientConnection(fd)
+ FD fd;
+{
+ enterprocedure("StopAudioClientConnection");
+ /* when a new connection is stopped, discard the old buffer */
+
+ if (CS[fd].SizeofSavedBytes > 0)
+ Free((char*)CS[fd].SavedBytes);
+}
+
+long StartAudioSetUpMessage (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short namelength;
+ short datalength;
+ extern int littleEndian;
+
+ 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
+ */
+
+ CS[fd].littleEndian = (buf[0] == 'l');
+ CS[ServerHalf(fd)].littleEndian = CS[fd].littleEndian;
+ littleEndian = CS[fd].littleEndian;
+ namelength = IShort(&buf[6]);
+ datalength = IShort(&buf[8]);
+ CS[fd].ByteProcessing = FinishAudioSetUpMessage;
+ 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 FinishAudioSetUpMessage (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishSetUpMessage");
+ if (ScopeEnabled)
+ PrintAudioSetUpMessage(buf);
+
+ /* after a set-up message, we expect a string of requests */
+ CS[fd].ByteProcessing = StartAudioRequest;
+ CS[fd].NumberofBytesNeeded = 4;
+ return(n);
+}
+
+
+long StartAudioRequest (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ unsigned 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 = FinishAudioRequest;
+ CS[fd].NumberofBytesNeeded = 4 * requestlength;
+ debug(8,(stderr, "need %d more bytes to finish request\n",
+ CS[fd].NumberofBytesNeeded - n));
+ return(0);
+}
+
+
+long FinishAudioRequest (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishRequest");
+ CS[fd].ByteProcessing = StartAudioRequest;
+ CS[fd].NumberofBytesNeeded = 4;
+ if (ScopeEnabled)
+ DecodeAudioRequest(fd, buf, n);
+ return(n);
+}
+
+StartAudioServerConnection(fd)
+ FD fd;
+{
+ enterprocedure("StartAudioServerConnection");
+ /* when a new connection is started, we have no saved bytes */
+ CS[fd].SavedBytes = NULL;
+ CS[fd].SizeofSavedBytes = 0;
+ CS[fd].NumberofSavedBytes = 0;
+ CS[fd].NumberofBytesProcessed = 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 = StartAudioSetUpReply;
+ CS[fd].NumberofBytesNeeded = 8;
+}
+
+StopAudioServerConnection(fd)
+ FD fd;
+{
+ enterprocedure("StopAudioServerConnection");
+ /* when a new connection is stopped, discard the old buffer */
+
+ if (CS[fd].SizeofSavedBytes > 0)
+ Free((char *)CS[fd].SavedBytes);
+}
+
+long StartAudioSetUpReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short replylength;
+
+ enterprocedure("StartSetUpReply");
+ replylength = IShort(&buf[6]);
+ CS[fd].ByteProcessing = FinishAudioSetUpReply;
+ CS[fd].NumberofBytesNeeded = n + 4 * replylength;
+ debug(8,(stderr, "need %d bytes to finish startup reply\n",
+ CS[fd].NumberofBytesNeeded - n));
+ return(0);
+}
+
+long FinishAudioSetUpReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ enterprocedure("FinishSetUpReply");
+ if (ScopeEnabled)
+ PrintAudioSetUpReply(buf);
+ CS[fd].ByteProcessing = AudioServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ return(n);
+}
+
+/* ************************************************************ */
+
+long AudioErrorPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ CS[fd].ByteProcessing = AudioServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ DecodeAudioError(fd, buf, n);
+ return(n);
+}
+
+
+long AudioEventPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ CS[fd].ByteProcessing = AudioServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ if (ScopeEnabled)
+ DecodeAudioEvent(fd, buf, n);
+ return(n);
+}
+
+
+long AudioReplyPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ long 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 = FinishAudioReply;
+ CS[fd].NumberofBytesNeeded = n + 4 * replylength;
+ debug(8,(stderr, "need %d bytes to finish reply\n", (4 * replylength)));
+ return(0);
+}
+
+long FinishAudioReply (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ CS[fd].ByteProcessing = AudioServerPacket;
+ CS[fd].NumberofBytesNeeded = 32;
+ enterprocedure("FinishAudioReply");
+ if (ScopeEnabled)
+ DecodeAudioReply(fd, buf, n);
+ return(n);
+}
+
+long AudioServerPacket (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short PacketType;
+ enterprocedure("ServerPacket");
+
+ PacketType = IByte(&buf[0]);
+ if (PacketType == 0)
+ return(AudioErrorPacket(fd, buf, n));
+ if (PacketType == 1)
+ return(AudioReplyPacket(fd, buf, n));
+ return(AudioEventPacket(fd, buf, n));
+}
+
+CloseAudioConnection(fd)
+ FD fd;
+{
+ debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd)));
+ StopAudioClientConnection(ServerHalf(fd));
+ StopAudioServerConnection(ClientHalf(fd));
+
+ (void)close(fd);
+ NotUsingFD(fd);
+ (void)close(FDPair(fd));
+ NotUsingFD(FDPair(fd));
+}
+
+/* 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. */
+
+DataFromAudioClient(fd)
+ FD fd;
+{
+ long n;
+ FD ServerFD;
+
+ Verbose = NasVerbose;
+ enterprocedure("DataFromAudioClient");
+ ServerFD = FDPair(fd);
+ if (ServerFD < 0)
+ {
+ ServerFD = ConnectToServer(false);
+ if (ServerFD < 0)
+ {
+ CloseAudioConnection(fd);
+ return;
+ }
+ SetUpPair(fd, ServerFD);
+ }
+
+ n = read(fd, FDinfo[ServerFD].buffer, BUFFER_SIZE);
+ debug(4,(stderr, "read %d bytes from Client%s\n", n, ClientName(fd)));
+ if (n < 0)
+ {
+ PrintTime();
+ perror("Client --> read error:");
+ CloseAudioConnection(fd);
+ return;
+ }
+ if (n == 0)
+ {
+ PrintTime();
+ if (NasVerbose >= 0)
+ fprintf(stdout, "Client%s --> EOF\n", ClientName(fd));
+ CloseAudioConnection(fd);
+ return;
+ }
+
+ FDinfo[ServerFD].bufcount = n;
+ FDinfo[ServerFD].bufstart = 0;
+
+ FlushFD (ServerFD);
+ /* also report the bytes to standard out */
+ ReportFromAudioClient(fd, FDinfo[ServerFD].buffer, 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. */
+
+DataFromAudioServer(fd)
+ FD fd;
+{
+ long n;
+ FD ClientFD;
+
+ Verbose = NasVerbose;
+ ClientFD = FDPair(fd);
+ if (ClientFD < 0)
+ {
+ CloseAudioConnection(fd);
+ return;
+ }
+
+ enterprocedure("DataFromAudioServer");
+ n = read(fd, (char *)FDinfo[ClientFD].buffer, BUFFER_SIZE);
+ debug(4,(stderr, "read %d bytes from Server%s\n", n, ClientName(fd)));
+ if (n < 0)
+ {
+ PrintTime();
+ perror("read error <- Server");
+ CloseAudioConnection(fd);
+ return;
+ }
+ if (n == 0)
+ {
+ PrintTime();
+ if (NasVerbose >= 0)
+ fprintf(stdout, "EOF <-- Server%s\n", ClientName(fd));
+ CloseAudioConnection(fd);
+ return;
+ }
+
+ FDinfo[ClientFD].bufcount = n;
+ FDinfo[ClientFD].bufstart = 0;
+ FlushFD (ClientFD);
+
+ /* also report the bytes to standard out */
+ ReportFromAudioServer(fd, FDinfo[ClientFD].buffer, n);
+}
+
+FD ConnectToAudioClient(ConnectionSocket)
+ FD ConnectionSocket;
+{
+ FD ClientFD;
+ ClientFD = AcceptConnection(ConnectionSocket);
+ UsingFD(ClientFD, DataFromAudioClient, FlushFD);
+ StartAudioClientConnection(ClientFD);
+ return(ClientFD);
+}
+
+FD ConnectToAudioServer(report)
+ Boolean report;
+{
+ FD ServerFD;
+ if (!AudioServerHostName[0])
+ strcpy (AudioServerHostName, ServerHostName);
+ ServerFD = MakeConnection (AudioServerHostName, GetServerport () + 2000, report);
+ if (ServerFD >= 0)
+ {
+ UsingFD(ServerFD, DataFromAudioServer, FlushFD);
+ StartAudioServerConnection(ServerFD);
+ }
+ return(ServerFD);
+}
+
+NewAudio (fd)
+ FD fd;
+{
+ FD ServerFD = -1;
+ FD ClientFD = -1;
+
+ ClientFD = ConnectToAudioClient(fd);
+ ServerFD = ConnectToAudioServer(true);
+ SetUpPair(ClientFD, ServerFD);
+}
+
+InitializeAudio ()
+{
+ InitializeAudioDecode ();
+}
diff --git a/bigreqscope.h b/bigreqscope.h
new file mode 100644
index 0000000..80648f1
--- /dev/null
+++ b/bigreqscope.h
@@ -0,0 +1,17 @@
+#ifndef _BIGREQSCOPE_H_
+#define _BIGREQSCOPE_H_
+
+
+#define BIGREQREQUESTHEADER "BIGREQREQUEST"
+#define BIGREQREPLYHEADER "BIGREQREPLY"
+
+/*
+ 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)
+
+#endif
+
diff --git a/common.c b/common.c
index 7ce37a5..d8df033 100644
--- a/common.c
+++ b/common.c
@@ -26,6 +26,7 @@
\* *********************************************************** */
#include "scope.h"
+#include <fcntl.h>
/* ********************************************** */
/* */
@@ -86,84 +87,101 @@ Free(p)
/* */
/* ************************************************************ */
+#define __USE_BSD_SIGNAL
#include <signal.h>
-#ifdef SIGURG
-void SignalURG(int dummy)
+#ifdef SIGNALRETURNSINT
+#define SIGVAL int
+#else
+#define SIGVAL void
+#endif
+
+/* ARGSUSED */
+SIGVAL
+SignalURG(n)
+ int n;
{
debug(1,(stderr, "==> SIGURG received\n"));
}
-#endif /* #ifdef SIGURG */
-#ifdef SIGPIPE
-void SignalPIPE(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalPIPE(n)
+ int n;
{
+ signal (SIGPIPE, SignalPIPE);
debug(1,(stderr, "==> SIGPIPE received\n"));
}
-#endif /* #ifdef SIGPIPE */
-#ifdef SIGINT
-void SignalINT(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalINT(n)
+ int n;
{
+ signal (SIGINT, SignalINT);
debug(1,(stderr, "==> SIGINT received\n"));
- exit(1);
-#endif /* #ifdef SIGINT */
+ Interrupt = 1;
}
-#ifdef SIGQUIT
-void SignalQUIT(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalQUIT(n)
+ int n;
{
debug(1,(stderr, "==> SIGQUIT received\n"));
exit(1);
-#endif /* #ifdef SIGQUIT */
}
-#ifdef SIGTERM
-void SignalTERM(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalTERM(n)
+ int n;
{
debug(1,(stderr, "==> SIGTERM received\n"));
exit(1);
-#endif /* #ifdef SIGTERM */
}
-#ifdef SIGTSTP
-void SignalTSTP(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalTSTP(n)
+ int n;
{
debug(1,(stderr, "==> SIGTSTP received\n"));
}
-#endif /* #ifdef SIGTSTP */
-#ifdef SIGCONT
-void SignalCONT(int dummy)
+/* ARGSUSED */
+SIGVAL
+SignalCONT(n)
+ int n;
+{
+ debug(1,(stderr, "==> SIGCONT received\n"));
+}
+
+/* ARGSUSED */
+SIGVAL
+SignalUSR1(n)
+ int n;
{
+ extern char ScopeEnabled;
+
debug(1,(stderr, "==> SIGCONT received\n"));
+ ScopeEnabled = ! ScopeEnabled;
}
-#endif /* #ifdef SIGCONT */
SetSignalHandling()
{
+ extern char HandleSIGUSR1;
+
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 */
+ if (HandleSIGUSR1)
+ (void)signal(SIGUSR1, SignalUSR1);
}
@@ -174,28 +192,33 @@ SetSignalHandling()
/* */
/* ************************************************************ */
-#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, ... */
+#ifdef SVR4
+#include <sys/filio.h>
+#endif
#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
+#define BACKLOG 5
/* for use in the UsingFD call -- defined later */
extern int NewConnection ();
-SetUpConnectionSocket(port)
- int port;
+SetUpConnectionSocket(iport, connectionFunc)
+ int iport;
+ int (*connectionFunc)();
{
FD ConnectionSocket;
struct sockaddr_in sin;
-#ifndef SO_DONTLINGER
+ short port;
+ int one = 1;
+#ifndef SO_DONTLINGER
struct linger linger;
-#endif /* #ifndef SO_DONTLINGER */
+#endif /* SO_DONTLINGER */
enterprocedure("SetUpConnectionSocket");
@@ -206,17 +229,17 @@ SetUpConnectionSocket(port)
perror("socket");
exit(-1);
}
- (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0);
+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)&one, sizeof (int));
#ifdef SO_USELOOPBACK
(void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0);
-#endif /* #ifdef SO_USELOOPBACK */
-#ifdef SO_DONTLINGER
+#endif
+#ifdef SO_DONTLINGER
(void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0);
-#else /* #ifdef SO_DONTLINGER */
+#else /* 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 */
+#endif /* SO_DONTLINGER */
/* define the name and port to be used with the connection socket */
bzero((char *)&sin, sizeof(sin));
@@ -231,7 +254,7 @@ SetUpConnectionSocket(port)
struct hostent *hp;
(void) gethostname(MyHostName, sizeof(MyHostName));
- ScopeHost = (char *) Malloc((long)(1+strlen(MyHostName)));
+ ScopeHost = (char *) Malloc((long)strlen(MyHostName));
(void)strcpy(ScopeHost, MyHostName);
hp = gethostbyname(MyHostName);
if (hp == NULL)
@@ -243,7 +266,8 @@ SetUpConnectionSocket(port)
addresses. INADDR_ANY should work with all of them at once. */
sin.sin_addr.s_addr = INADDR_ANY;
- sin.sin_port = htons(port);
+ port = iport;
+ sin.sin_port = htons (port);
ScopePort = port;
/* bind the name and port number to the connection socket */
@@ -264,13 +288,22 @@ SetUpConnectionSocket(port)
};
/* a few more parameter settings */
-#ifdef FIOCLEX
+#ifdef FD_CLOEXEC
+ (void)fcntl(ConnectionSocket, F_SETFD, FD_CLOEXEC);
+#else
(void)ioctl(ConnectionSocket, FIOCLEX, 0);
-#endif /* #ifdef FIOCLEX */
- (void)ioctl(ConnectionSocket, FIONBIO, &ON);
+#endif
+ /* ultrix reads hang on Unix sockets, hpux reads fail */
+#if defined(O_NONBLOCK) && (!defined(ultrix) && !defined(hpux))
+ (void) fcntl (ConnectionSocket, F_SETFL, O_NONBLOCK);
+#else
+#ifdef FIOSNBIO
+ (void) ioctl (ConnectionSocket, FIOSNBIO, &ON);
+#else
+ (void) fcntl (ConnectionSocket, F_SETFL, FNDELAY);
+#endif
+#endif
debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket));
- UsingFD(ConnectionSocket, NewConnection);
+ UsingFD(ConnectionSocket, connectionFunc, 0);
}
-
-
diff --git a/decode11.c b/decode11.c
index eb2a12f..9f51214 100644
--- a/decode11.c
+++ b/decode11.c
@@ -26,7 +26,7 @@
* ************************************************************ */
#include "scope.h"
-#include "x11.h"
+#include "x11.h"
/*
There are 4 types of things in X11: requests, replies, errors, and events.
@@ -63,6 +63,7 @@ struct QueueEntry
struct QueueEntry *Next;
long SequenceNumber;
short Request;
+ short RequestMinor;
};
/* free space list of Q entries */
@@ -70,9 +71,10 @@ struct QueueEntry
static struct QueueEntry *FreeQEntries = NULL;
/* ************************************************************ */
-struct QueueEntry *NewQEntry (SequenceNumber, Request)
+struct QueueEntry *NewQEntry (SequenceNumber, Request, RequestMinor)
long SequenceNumber;
short Request;
+ short RequestMinor;
{
struct QueueEntry *p;
@@ -93,6 +95,7 @@ struct QueueEntry *NewQEntry (SequenceNumber, Request)
p->Next = NULL;
p->SequenceNumber = SequenceNumber;
p->Request = Request;
+ p->RequestMinor = RequestMinor;
return(p);
}
/* ************************************************************ */
@@ -129,12 +132,12 @@ FD fd;
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;
}
@@ -143,7 +146,7 @@ FD fd;
DumpReplyQ(fd)
FD fd;
{
- fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n",
+ fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n",
fd, ReplyQ[fd].Head, ReplyQ[fd].Tail);
{
struct QueueEntry *p;
@@ -160,17 +163,17 @@ DumpReplyQ(fd)
/* A reply is expected to the type of request given for the fd associated
with this one */
-SequencedReplyExpected(fd, SequenceNumber, RequestType)
+SequencedReplyExpected(fd, SequenceNumber, RequestType, RequestMinorType)
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));
+ debug(8,(stderr, "Reply expected: sequence %d and request type %d,%d for fd %d\n",
+ SequenceNumber, RequestType, RequestMinorType, fd));
/* create a new queue entry */
- p = NewQEntry(SequenceNumber, RequestType);
+ p = NewQEntry(SequenceNumber, RequestType, RequestMinorType);
/* find the server associated with this client */
fd = FDPair(fd);
@@ -183,45 +186,23 @@ SequencedReplyExpected(fd, SequenceNumber, RequestType)
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);
+ debug(8,(stderr, "Save sequence %d and request type %d,%d for fd %d\n",
+ p->SequenceNumber, p->Request, p->RequestMinor, fd));
}
static FD Lastfd;
static long LastSequenceNumber;
static short LastReplyType;
+static short LastReplyMinorType;
+/* search for the type of request that is associated with a reply
+ to the given sequence number for this fd */
-short ExtractReplyTable (fd, SequenceNumber)
+short CheckReplyTable (fd, SequenceNumber, minorp)
FD fd;
short SequenceNumber;
+ short *minorp;
{
struct QueueEntry *p;
struct QueueEntry *trailer;
@@ -238,6 +219,7 @@ short ExtractReplyTable (fd, SequenceNumber)
Lastfd = fd;
LastSequenceNumber = p->SequenceNumber;
LastReplyType = p->Request;
+ LastReplyMinorType = p->RequestMinor;
/* pull the queue entry out of the queue for this fd */
if (trailer == NULL)
@@ -251,8 +233,9 @@ short ExtractReplyTable (fd, SequenceNumber)
p->Next = FreeQEntries;
FreeQEntries = p;
- debug(8,(stderr, "Reply on fd %d for sequence %d is type %d\n",
- fd, SequenceNumber, LastReplyType));
+ debug(8,(stderr, "Reply on fd %d for sequence %d is type %d,%x\n",
+ fd, SequenceNumber, LastReplyType, LastReplyMinorType));
+ *minorp = LastReplyMinorType;
return(LastReplyType);
}
}
@@ -272,7 +255,15 @@ ReplyExpected(fd, Request)
FD fd;
short Request;
{
- SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request);
+ SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, 0);
+}
+
+ExtendedReplyExpected (fd, Request, RequestMinor)
+ FD fd;
+ short Request;
+ short RequestMinor;
+{
+ SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, RequestMinor);
}
/* ************************************************************ */
@@ -281,14 +272,58 @@ ReplyExpected(fd, Request)
KeepLastReplyExpected()
{
- SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType);
+ SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType,
+ LastReplyMinorType);
}
+#define DUMP_REQUEST 0
+#define DUMP_REPLY 1
+#define DUMP_EVENT 2
+#define DUMP_ERROR 3
+
+static char *simple_names[] = {
+ "REQUEST",
+ "REPLY ",
+ "EVENT ",
+ "ERROR ",
+};
+
+SimpleDump (type, fd, Major, Minor, bytes)
+{
+ PrintTime ();
+ fprintf (stdout, "@@%s %3d %3d %3d %7d\n",
+ simple_names[type],
+ ClientNumber(fd),
+ Major, Minor, bytes);
+}
+
/* ************************************************************ */
/* */
/* */
/* ************************************************************ */
+#ifdef PEX
+extern unsigned char LookForPEXFlag;
+extern unsigned char PEXCode;
+#endif
+
+extern unsigned char LookForLBXFlag;
+extern unsigned char LBXRequest;
+extern unsigned char LBXError;
+extern unsigned char LBXEvent;
+
+extern unsigned char LookForWCPFlag;
+extern unsigned char WCPRequest;
+extern unsigned char WCPError;
+
+extern unsigned char LookForRENDERFlag;
+extern unsigned char RENDERRequest;
+extern unsigned char RENDERError;
+#define RENDERNError 5
+
+extern unsigned char LookForRANDRFlag;
+extern unsigned char RANDRRequest;
+extern unsigned char RANDREvent;
DecodeRequest(fd, buf, n)
FD fd;
@@ -296,18 +331,53 @@ DecodeRequest(fd, buf, n)
long n;
{
short Request = IByte (&buf[0]);
+ short RequestMinor = Request >= 128 ? IByte (&buf[1]) : 0;
+ unsigned long seq;
+
CS[fd].SequenceNumber += 1;
- bcopy ((char *)&(CS[fd].SequenceNumber), (char *)SBf, sizeof(long));
+ seq = CS[fd].SequenceNumber;
+ if (CS[fd].littleEndian) {
+ SBf[0] = seq;
+ SBf[1] = seq >> 8;
+ SBf[2] = seq >> 16;
+ SBf[3] = seq >> 24;
+ } else {
+ SBf[0] = seq >> 24;
+ SBf[1] = seq >> 16;
+ SBf[2] = seq >> 8;
+ SBf[3] = seq;
+ }
SetIndentLevel(PRINTCLIENT);
+ if (Verbose < 0)
+ {
+ SimpleDump (DUMP_REQUEST, fd, Request, RequestMinor, n);
+ return;
+ }
+
if (Verbose > 3)
DumpItem("Request", fd, buf, n);
- if (Request <= 0 || 127 < Request)
+ if (Request < 0 || 127 < Request) {
+#ifdef PEX
+ if (Request == PEXCode) {
+ pex_decode_req(fd, buf);
+ } else
+#endif
+ if (Request == LBXRequest) {
+ lbx_decode_req(fd, buf);
+ } else
+ if (Request == WCPRequest) {
+ wcp_decode_req(fd, buf);
+ } else if (Request == RENDERRequest) {
+ render_decode_req(fd,buf);
+ } else if (Request == RANDRRequest) {
+ randr_decode_req(fd,buf);
+ } else
{
- warn("Extended request opcode");
- fprintf(stdout, "Extended request opcode: %d\n", Request);
+ ExtendedRequest(buf);
+ ReplyExpected(fd, Request);
}
- else switch (Request)
+ } else switch (Request)
{
case 1:
CreateWindow(buf);
@@ -631,6 +701,25 @@ DecodeRequest(fd, buf, n)
break;
case 98:
QueryExtension(buf);
+
+#ifdef PEX
+ /* PEX content */
+ if (strncmp("X3D-PEX",(char *)&buf[8],7) == 0)
+ LookForPEXFlag=1;
+#endif
+
+ if (strncmp("LBX",(char *)&buf[8],3) == 0)
+ LookForLBXFlag=1;
+
+ if (strncmp("NCD-WinCenterPro",(char *)&buf[8],16) == 0)
+ LookForWCPFlag=1;
+
+ if (strncmp("RENDER",(char *)&buf[8],6) == 0)
+ LookForRENDERFlag=1;
+
+ if (strncmp("RANDR",(char *)&buf[8],6) == 0)
+ LookForRANDRFlag=1;
+
ReplyExpected(fd, Request);
break;
case 99:
@@ -726,24 +815,41 @@ DecodeReply(fd, buf, n)
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;
- }
+ short RequestMinor;
+ short Request = CheckReplyTable (fd, SequenceNumber, &RequestMinor);
+
+ if (Verbose < 0)
+ {
+ SimpleDump (DUMP_REPLY, fd, Request, RequestMinor, n);
+ return;
+ }
+
SetIndentLevel(PRINTSERVER);
RBf[0] = Request /* for the PrintField in the Reply procedure */ ;
+ RBf[1] = RequestMinor;
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);
- }
+#ifdef PEX
+ if (Request == PEXCode)
+ pex_decode_reply(fd, buf);
+ else
+#endif
+ if (Request == LBXRequest)
+ lbx_decode_reply(fd, buf, RequestMinor);
+ else
+ if (Request == WCPRequest)
+ wcp_decode_reply(fd, buf, RequestMinor);
+ else if (Request == RENDERRequest)
+ render_decode_reply(fd, buf, RequestMinor);
+ else if (Request == RANDRRequest)
+ randr_decode_reply(fd, buf, RequestMinor);
+ else if (Request < 0 || 127 < Request)
+ warn("Extended reply opcode");
else switch (Request)
{
+ case 0:
+ UnknownReply(buf);
+ break;
case 3:
GetWindowAttributesReply(buf);
break;
@@ -880,69 +986,86 @@ DecodeError(fd, buf, n)
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)
+ short Error = IByte (&buf[1]);
+ short Request = 0;
+ short RequestMinor = 0;
+
+ Request = CheckReplyTable (fd, (short)IShort(&buf[2]), &RequestMinor);
+
+ if (Verbose < 0)
{
- 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;
+ SimpleDump (DUMP_ERROR, fd, Request, RequestMinor, n);
+ return;
+ }
+
+ SetIndentLevel(PRINTSERVER);
+ if (Verbose > 3)
+ DumpItem("Error", fd, buf, n);
+
+ if (Error == LBXError)
+ lbx_decode_error(fd, buf);
+ else if (Error == WCPError)
+ wcp_decode_error(fd, buf);
+ else if (Error >= RENDERError && Error < RENDERError + RENDERNError)
+ render_decode_error(fd,buf);
+ else 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;
}
}
@@ -956,121 +1079,133 @@ DecodeEvent(fd, buf, n)
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)
+ short Event = IByte (&buf[0]);
+ short EventMinor = Event == LBXEvent ? IByte (&buf[1]) : 0;
+
+ if (Verbose < 0)
{
- debug(8,(stderr, "SendEvent generated event 0x%x\n", Event));
- Event = Event & 0x7F;
+ SimpleDump (DUMP_EVENT, fd, Event, EventMinor, n);
+ return;
}
- if (Event < 2 || Event > 34)
- warn("Extended Event code");
- else switch (Event)
+
+ SetIndentLevel(PRINTSERVER);
+ if (Verbose > 3)
+ DumpItem("Event", fd, buf, n);
+ /* high-order bit means SendEvent generated */
+ if (Event & 0x80)
{
- 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;
+ debug(8,(stderr, "SendEvent generated event 0x%x\n", Event));
+ Event = Event & 0x7F;
+ }
+ if (Event == LBXEvent)
+ lbx_decode_event (fd, buf);
+ else if (Event == RANDREvent)
+ randr_decode_event (fd, buf);
+ else 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/decode_bigreq.c b/decode_bigreq.c
new file mode 100644
index 0000000..1a75265
--- /dev/null
+++ b/decode_bigreq.c
@@ -0,0 +1,80 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scope.h"
+#include "x11.h"
+#include "bigreqscope.h"
+
+unsigned char LookForBIGREQFlag;
+
+unsigned char BIGREQRequest;
+
+bigreq_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0:
+ CS[fd].bigreqEnabled = 1;
+ BigreqEnable (fd, buf);
+ ExtendedReplyExpected (fd, Major, Minor); break;
+ default:
+ break;
+ }
+}
+
+bigreq_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0: BigreqEnableReply (fd, buf); break;
+ }
+}
+
+InitializeBIGREQ(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ BIGREQRequest = (unsigned char)(buf[9]);
+ LookForBIGREQFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) BIGREQRequest, "BigreqRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) BIGREQRequest, "BigreqReply");
+
+ p = DefineType(BIGREQREQUEST, ENUMERATED, "BIGREQREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "BigreqEnable");
+
+ p = DefineType(BIGREQREPLY, ENUMERATED, "BIGREQREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "BigreqEnable");
+}
diff --git a/decode_lbx.c b/decode_lbx.c
new file mode 100644
index 0000000..5aced31
--- /dev/null
+++ b/decode_lbx.c
@@ -0,0 +1,149 @@
+/*
+ * $NCDId$
+ *
+ * Copyright 1992 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _XLBX_SERVER_
+#include "scope.h"
+#include "x11.h"
+#include "lbxscope.h"
+
+unsigned char LookForLBXFlag;
+
+unsigned char LBXRequest, LBXEvent, LBXError;
+
+lbx_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0:
+ LbxQueryVersion (fd, buf);
+ ExtendedReplyExpected (fd, Major, Minor);
+ break;
+ case 1:
+ LbxStartProxy (fd, buf);
+ break;
+ case 2:
+ LbxStopProxy (fd, buf);
+ break;
+ case 3:
+ LbxSwitch (fd, buf);
+ break;
+ case 4:
+ LbxNewClient(fd, buf);
+ break;
+ case 5:
+ LbxCloseClient (fd, buf);
+ break;
+ case 6:
+ LbxModifySequence (fd, buf);
+ break;
+ default:
+ break;
+ }
+}
+
+lbx_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0:
+ LbxQueryVersionReply (fd, buf);
+ break;
+ default:
+ break;
+ }
+}
+
+lbx_decode_error(fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ short error = IByte(&buf[1]) - LBXError;
+
+ switch (error) {
+ case 0:
+ break;
+ default:
+ break;
+ }
+}
+
+lbx_decode_event (fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ short event = IByte(&buf[0]) - LBXEvent;
+
+ switch (event) {
+ case 0:
+ LbxSwitchEvent (fd, buf);
+ break;
+ case 1:
+ LbxCloseEvent (fd, buf);
+ break;
+ default:
+ break;
+ }
+}
+
+InitializeLBX(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ LBXRequest = (unsigned char)(buf[9]);
+ LBXEvent = (unsigned char)(buf[10]);
+ LBXError = (unsigned char)(buf[11]);
+ LookForLBXFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) LBXRequest, "LbxRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) LBXRequest, "LbxReply");
+ DefineEValue (&TD[EVENT], (unsigned long) LBXEvent, "LbxEvent");
+ DefineEValue (&TD[ERROR], (unsigned long) LBXError, "LbxError");
+
+ p = DefineType(LBXREQUEST, ENUMERATED, "LBXREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "QueryVersion");
+ DefineEValue(p, 1L, "StartProxy");
+ DefineEValue(p, 2L, "StopProxy");
+ DefineEValue(p, 3L, "Switch");
+ DefineEValue(p, 4L, "NewClient");
+ DefineEValue(p, 5L, "CloseClient");
+ DefineEValue(p, 6L, "ModifySequence");
+
+ p = DefineType(LBXREPLY, ENUMERATED, "LBXREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "QueryVersion");
+
+ p = DefineType(LBXEVENT, ENUMERATED, "LBXEVENT", PrintENUMERATED);
+ DefineEValue (p, 0L, "SwitchEvent");
+ DefineEValue (p, 1L, "CloseEvent");
+}
diff --git a/decode_pex.c b/decode_pex.c
new file mode 100644
index 0000000..2a31d60
--- /dev/null
+++ b/decode_pex.c
@@ -0,0 +1,786 @@
+/* $XConsortium: decode_pex.c,v 5.3 91/02/17 12:34:53 rws Exp $ */
+
+/***********************************************************
+Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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>
+#include <X11/X.h>
+#include <X11/extensions/PEX.h>
+#include <X11/extensions/PEXproto.h>
+#include "scope.h"
+#include "pexRNames.h"
+#include "pexOCNames.h"
+#include "pexscope.h"
+
+unsigned char pex_last_req;
+
+BOOL LookForPEXFlag;
+
+CARD8 PEXCode;
+
+pex_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short req = IByte (&buf[0]);
+
+ if ((buf[1] < PEX_GetExtensionInfo) ||
+ (buf[1] > PEXMaxRequest)) {
+ return;
+ } else
+ pex_last_req =buf[1];
+
+ switch (buf[1]) {
+ case PEX_GetExtensionInfo:
+ GetExtensionInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetEnumeratedTypeInfo:
+ GetEnumeratedTypeInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetImpDepConstants:
+ GetImpDepConstants(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_CreateLookupTable:
+ CreateLookupTable(buf);
+ break;
+ case PEX_CopyLookupTable:
+ CopyLookupTable(buf);
+ break;
+ case PEX_FreeLookupTable:
+ FreeLookupTable(buf);
+ break;
+ case PEX_GetTableInfo:
+ GetTableInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetPredefinedEntries:
+ GetPredefinedEntries(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetDefinedIndices:
+ GetDefinedIndices(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetTableEntry:
+ GetTableEntry(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetTableEntries:
+ GetTableEntries(buf);
+ ReplyExpected(fd, buf);
+ break;
+ case PEX_SetTableEntries:
+ SetTableEntries(buf);
+ break;
+ case PEX_DeleteTableEntries:
+ DeleteTableEntries(buf);
+ break;
+ case PEX_CreatePipelineContext:
+ CreatePipelineContext(buf);
+ break;
+ case PEX_CopyPipelineContext:
+ CopyPipelineContext(buf);
+ break;
+ case PEX_FreePipelineContext:
+ FreePipelineContext(buf);
+ break;
+ case PEX_GetPipelineContext:
+ GetPipelineContext(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ChangePipelineContext:
+ ChangePipelineContext(buf);
+ break;
+ case PEX_CreateRenderer:
+ CreateRenderer(buf);
+ break;
+ case PEX_FreeRenderer:
+ FreeRenderer(buf);
+ break;
+ case PEX_ChangeRenderer:
+ ChangeRenderer(buf);
+ break;
+ case PEX_GetRendererAttributes:
+ GetRendererAttributes(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_BeginRendering:
+ BeginRendering(buf);
+ break;
+ case PEX_EndRendering:
+ EndRendering(buf);
+ break;
+ case PEX_BeginStructure:
+ BeginStructure(buf);
+ break;
+ case PEX_EndStructure:
+ EndStructure(buf);
+ break;
+ case PEX_RenderOutputCommands:
+ RenderOutputCommands(buf);
+ break;
+ case PEX_RenderNetwork:
+ RenderNetwork(buf);
+ break;
+ case PEX_CreateStructure:
+ CreateStructure(buf);
+ break;
+ case PEX_CopyStructure:
+ CopyStructure(buf);
+ break;
+ case PEX_GetRendererDynamics:
+ GetRendererDynamics(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_DestroyStructures:
+ DestroyStructures(buf);
+ break;
+ case PEX_GetStructureInfo:
+ GetStructureInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetElementInfo:
+ GetElementInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetStructuresInNetwork:
+ GetStructuresInNetwork(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetAncestors:
+ GetAncestors(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetDescendants:
+ GetDescendants(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_FetchElements:
+ FetchElements(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_SetEditingMode:
+ SetEditingMode(buf);
+ break;
+ case PEX_SetElementPointer:
+ SetElementPointer(buf);
+ break;
+ case PEX_SetElementPointerAtLabel:
+ SetElementPointerAtLabel(buf);
+ break;
+ case PEX_ElementSearch:
+ ElementSearch(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_StoreElements:
+ StoreElements(buf);
+ break;
+ case PEX_DeleteElements:
+ DeleteElements(buf);
+ break;
+ case PEX_DeleteElementsToLabel:
+ DeleteElementsToLabel(buf);
+ break;
+ case PEX_DeleteBetweenLabels:
+ DeleteBetweenLabels(buf);
+ break;
+ case PEX_CopyElements:
+ CopyElements(buf);
+ break;
+ case PEX_ChangeStructureRefs:
+ ChangeStructureRefs(buf);
+ break;
+ case PEX_CreateNameSet:
+ CreateNameSet(buf);
+ break;
+ case PEX_CopyNameSet:
+ CopyNameSet(buf);
+ break;
+ case PEX_FreeNameSet:
+ FreeNameSet(buf);
+ break;
+ case PEX_GetNameSet:
+ GetNameSet(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ChangeNameSet:
+ ChangeNameSet(buf);
+ break;
+ case PEX_CreateSearchContext:
+ CreateSearchContext(buf);
+ break;
+ case PEX_CopySearchContext:
+ CopySearchContext(buf);
+ break;
+ case PEX_FreeSearchContext:
+ FreeSearchContext(buf);
+ break;
+ case PEX_GetSearchContext:
+ GetSearchContext(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ChangeSearchContext:
+ ChangeSearchContext(buf);
+ break;
+ case PEX_SearchNetwork:
+ SearchNetwork(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_CreatePhigsWks:
+ CreatePhigsWks(buf);
+ break;
+ case PEX_FreePhigsWks:
+ FreePhigsWks(buf);
+ break;
+ case PEX_GetWksInfo:
+ GetWksInfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetDynamics:
+ GetDynamics(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetViewRep:
+ GetViewRep(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_RedrawAllStructures:
+ RedrawAllStructures(buf);
+ break;
+ case PEX_UpdateWorkstation:
+ UpdateWorkstation(buf);
+ break;
+ case PEX_ExecuteDeferredActions:
+ ExecuteDeferredActions(buf);
+ break;
+ case PEX_SetViewPriority:
+ SetViewPriority(buf);
+ break;
+ case PEX_SetDisplayUpdateMode:
+ SetDisplayUpdateMode(buf);
+ break;
+ case PEX_MapDCtoWC:
+ MapDCtoWC(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_MapWCtoDC:
+ MapWCtoDC(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_SetViewRep:
+ SetViewRep(buf);
+ break;
+ case PEX_SetWksWindow:
+ SetWksWindow(buf);
+ break;
+ case PEX_SetWksViewport:
+ SetWksViewport(buf);
+ break;
+ case PEX_SetHlhsrMode:
+ SetHlhsrMode(buf);
+ break;
+ case PEX_PostStructure:
+ PostStructure(buf);
+ break;
+ case PEX_UnpostStructure:
+ UnpostStructure(buf);
+ break;
+ case PEX_UnpostAllStructures:
+ UnpostAllStructures(buf);
+ break;
+ case PEX_GetWksPostings:
+ GetWksPostings(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_GetPickDevice:
+ GetPickDevice(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ChangePickDevice:
+ ChangePickDevice(buf);
+ break;
+ case PEX_CreatePickMeasure:
+ CreatePickMeasure(buf);
+ break;
+ case PEX_FreePickMeasure:
+ FreePickMeasure(buf);
+ break;
+ case PEX_GetPickMeasure:
+ GetPickMeasure(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_UpdatePickMeasure:
+ UpdatePickMeasure(buf);
+ break;
+ case PEX_OpenFont:
+ pexopenfont(buf);
+ break;
+ case PEX_CloseFont:
+ pexclosefont(buf);
+ break;
+ case PEX_QueryFont:
+ pexqueryfont(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ListFonts:
+ pexlistfonts(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_ListFontsWithInfo:
+ pexlistfontswithinfo(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_QueryTextExtents:
+ pexquerytextextents(buf);
+ ReplyExpected(fd, req);
+ break;
+ case PEX_RedrawClipRegion:
+ RedrawClipRegion(buf);
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ *
+ *
+ *
+ */
+pex_decode_elem(num_cmds, buf)
+CARD32 num_cmds;
+unsigned char *buf;
+{
+ register long i;
+ register pexElementInfo *el_info;
+
+ for (i = 0; i < num_cmds; i++) {
+ el_info = (pexElementInfo *) buf;
+ if ((el_info->elementType <= PEXOCAll) ||
+ (el_info->elementType >= PEXMaxOC) )
+ return;
+ fprintf(stdout, "\t\t\t %s\n",
+ pex_oc_name[el_info->elementType]);
+
+ fprintf(stdout, "\t\t\t length : %d\n",el_info->length);
+ buf += el_info->length * 4;
+
+#ifdef IGNORE
+ switch (el_info->elementType) {
+ case PEXOCMarkerType:
+ break;
+ case PEXOCMarkerScale:
+ break;
+ case PEXOCMarkerColourIndex:
+ break;
+ case PEXOCMarkerColour:
+ break;
+ case PEXOCMarkerBundleIndex:
+ break;
+ case PEXOCTextFontIndex:
+ break;
+ case PEXOCTextPrecision:
+ break;
+ case PEXOCCharExpansion:
+ break;
+ case PEXOCCharSpacing:
+ break;
+ case PEXOCTextColourIndex:
+ break;
+ case PEXOCTextColour:
+ break;
+ case PEXOCCharHeight:
+ break;
+ case PEXOCCharUpVector:
+ break;
+ case PEXOCTextPath:
+ break;
+ case PEXOCTextAlignment:
+ break;
+ case PEXOCAtextHeight:
+ break;
+ case PEXOCAtextUpVector:
+ break;
+ case PEXOCAtextPath:
+ break;
+ case PEXOCAtextAlignment:
+ break;
+ case PEXOCAtextStyle:
+ break;
+ case PEXOCTextBundleIndex:
+ break;
+ case PEXOCLineType:
+ break;
+ case PEXOCLineWidth:
+ break;
+ case PEXOCLineColourIndex:
+ break;
+ case PEXOCLineColour:
+ break;
+ case PEXOCCurveApproximation:
+ break;
+ case PEXOCPolylineInterp:
+ break;
+ case PEXOCLineBundleIndex:
+ break;
+ case PEXOCInteriorStyle:
+ break;
+ case PEXOCInteriorStyleIndex:
+ break;
+ case PEXOCSurfaceColourIndex:
+ break;
+ case PEXOCSurfaceColour:
+ break;
+ case PEXOCSurfaceReflAttr:
+ break;
+ case PEXOCSurfaceReflModel:
+ break;
+ case PEXOCSurfaceInterp:
+ break;
+ case PEXOCBfInteriorStyle:
+ break;
+ case PEXOCBfInteriorStyleIndex:
+ break;
+ case PEXOCBfSurfaceColourIndex:
+ break;
+ case PEXOCBfSurfaceColour:
+ break;
+ case PEXOCBfSurfaceReflAttr:
+ break;
+ case PEXOCBfSurfaceReflModel:
+ break;
+ case PEXOCBfSurfaceInterp:
+ break;
+ case PEXOCSurfaceApproximation:
+ break;
+ case PEXOCTCApproximation:
+ break;
+ case PEXOCCullingMode:
+ break;
+ case PEXOCDistinguishFlag:
+ break;
+ case PEXOCNormalFlip:
+ break;
+ case PEXOCPatternSize:
+ break;
+ case PEXOCPatternRefPt:
+ break;
+ case PEXOCPatternAttr:
+ break;
+ case PEXOCInteriorBundleIndex:
+ break;
+ case PEXOCSurfaceEdgeFlag:
+ break;
+ case PEXOCSurfaceEdgeType:
+ break;
+ case PEXOCSurfaceEdgeWidth:
+ break;
+ case PEXOCSurfaceEdgeColourIndex:
+ break;
+ case PEXOCSurfaceEdgeColour:
+ break;
+ case PEXOCEdgeBundleIndex:
+ break;
+ case PEXOCSetAsfValues:
+ break;
+ case PEXOCLocalTransform:
+ break;
+ case PEXOCLocalTransform2D:
+ break;
+ case PEXOCGlobalTransform:
+ break;
+ case PEXOCGlobalTransform2D:
+ break;
+ case PEXOCModelClip:
+ break;
+ case PEXOCModelClipVolume:
+ break;
+ case PEXOCModelClipVolume2D :
+ break;
+ case PEXOCRestoreModelClip:
+ break;
+ case PEXOCViewIndex:
+ break;
+ case PEXOCLightState:
+ break;
+ case PEXOCDepthCueIndex:
+ break;
+ case PEXOCPickId:
+ break;
+ case PEXOCHlhsrIdentifier:
+ break;
+ case PEXOCAddToNameSet:
+ break;
+ case PEXOCRemoveFromNameSet:
+ break;
+ case PEXOCExecuteStructure:
+ break;
+ case PEXOCLabel:
+ break;
+ case PEXOCApplicationData:
+ break;
+ case PEXOCGse:
+ break;
+ case PEXOCMarker:
+ break;
+ case PEXOCMarker2D:
+ break;
+ case PEXOCText:
+ break;
+ case PEXOCText2D:
+ break;
+ case PEXOCAnnotationText:
+ break;
+ case PEXOCAnnotationText2D:
+ break;
+ case PEXOCPolyline:
+ break;
+ case PEXOCPolyline2D:
+ break;
+ case PEXOCPolylineSet:
+ break;
+ case PEXOCNurbCurve:
+ break;
+ case PEXOCFillArea:
+ break;
+ case PEXOCFillArea2D:
+ break;
+ case PEXOCExtFillArea:
+ break;
+ case PEXOCFillAreaSet:
+ break;
+ case PEXOCFillAreaSet2D:
+ break;
+ case PEXOCExtFillAreaSet:
+ break;
+ case PEXOCTriangleStrip:
+ break;
+ case PEXOCQuadrilateralMesh:
+ break;
+ case PEXOCIndexedPolygons:
+ break;
+ case PEXOCNurbSurface:
+ break;
+ case PEXOCCellArray:
+ break;
+ case PEXOCCellArray2D:
+ break;
+ case PEXOCExtCellArray:
+ break;
+ case PEXOCGdp:
+ break;
+ case PEXOCGdp2D:
+ break;
+ case PEXOCColourApproxIndex:
+ break;
+ default:
+ break;
+ }
+#endif /* IGNORE */
+ }
+}
+
+/*
+ *
+ *
+ *
+ */
+pex_decode_reply(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ switch (pex_last_req) {
+ case PEX_GetExtensionInfo:
+ GetExtensionInfoReply(buf);
+ break;
+ case PEX_GetEnumeratedTypeInfo:
+ GetEnumeratedTypeInfoReply(buf);
+ break;
+ case PEX_GetImpDepConstants:
+ GetImpDepConstantsReply(buf);
+ break;
+ case PEX_GetTableInfo:
+ GetTableInfoReply(buf);
+ break;
+ case PEX_GetPredefinedEntries:
+ GetPredefinedEntriesReply(buf);
+ break;
+ case PEX_GetDefinedIndices:
+ GetDefinedIndicesReply(buf);
+ break;
+ case PEX_GetTableEntry:
+ GetTableEntryReply(buf);
+ break;
+ case PEX_GetTableEntries:
+ GetTableEntriesReply(buf);
+ break;
+ case PEX_GetPipelineContext:
+ GetPipelineContextReply(buf);
+ break;
+ case PEX_GetRendererAttributes:
+ GetRendererAttributesReply(buf);
+ break;
+ case PEX_GetRendererDynamics:
+ GetRendererDynamicsReply(buf);
+ break;
+ case PEX_GetStructureInfo:
+ GetStructureInfoReply(buf);
+ break;
+ case PEX_GetElementInfo:
+ GetElementInfoReply(buf);
+ break;
+ case PEX_GetStructuresInNetwork:
+ GetStructuresInNetworkReply(buf);
+ break;
+ case PEX_GetAncestors:
+ GetAncestorsReply(buf);
+ break;
+ case PEX_GetDescendants:
+ GetDescendantsReply(buf);
+ break;
+ case PEX_FetchElements:
+ FetchElementsReply(buf);
+ break;
+ case PEX_ElementSearch:
+ ElementSearchReply(buf);
+ break;
+ case PEX_GetNameSet:
+ GetNameSetReply(buf);
+ break;
+ case PEX_GetSearchContext:
+ GetSearchContextReply(buf);
+ break;
+ case PEX_SearchNetwork:
+ SearchNetworkReply(buf);
+ break;
+ case PEX_GetWksInfo:
+ GetWksInfoReply(buf);
+ break;
+ case PEX_GetDynamics:
+ GetDynamicsReply(buf);
+ break;
+ case PEX_GetViewRep:
+ GetViewRepReply(buf);
+ break;
+ case PEX_MapDCtoWC:
+ MapDCtoWCReply(buf);
+ break;
+ case PEX_MapWCtoDC:
+ MapWCtoDCReply(buf);
+ break;
+ case PEX_GetWksPostings:
+ GetWksPostingsReply(buf);
+ break;
+ case PEX_GetPickDevice:
+ GetPickDeviceReply(buf);
+ break;
+ case PEX_GetPickMeasure:
+ GetPickMeasureReply(buf);
+ break;
+ case PEX_QueryFont:
+ pexqueryfontreply(buf);
+ break;
+ case PEX_ListFonts:
+ pexlistfontsreply(buf);
+ break;
+ case PEX_ListFontsWithInfo:
+ pexlistfontswithinforeply(buf);
+ break;
+ case PEX_QueryTextExtents:
+ pexquerytextextentsreply(buf);
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ *
+ *
+ */
+
+pex_decode_error(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short error = IByte(&buf[1]);
+ switch (error) {
+ case PEXColourTypeError:
+ pexerror_colortype(buf);
+ break;
+ case PEXRendererStateError:
+ pexerror_rendererstate(buf);
+ break;
+ case PEXFloatingPointFormatError:
+ pexerror_floatingpointformat(buf);
+ break;
+ case PEXLabelError:
+ pexerror_label(buf);
+ break;
+ case PEXLookupTableError:
+ pexerror_lookuptable(buf);
+ break;
+ case PEXNameSetError:
+ pexerror_nameset(buf);
+ break;
+ case PEXPathError:
+ pexerror_path(buf);
+ break;
+ case PEXFontError:
+ pexerror_font(buf);
+ break;
+ case PEXPhigsWksError:
+ pexerror_phigswks(buf);
+ break;
+ case PEXPickMeasureError:
+ pexerror_pickmeasure(buf);
+ break;
+ case PEXPipelineContextError:
+ pexerror_pipelinecontext(buf);
+ break;
+ case PEXRendererError:
+ pexerror_renderer(buf);
+ break;
+ case PEXSearchContextError:
+ pexerror_searchcontext(buf);
+ break;
+ case PEXStructureError:
+ pexerror_structure(buf);
+ break;
+ case PEXOutputCommandError:
+ pexerror_outputcommand(buf);
+ break;
+ default:
+ break;
+ }
+}
+
+InitializePEX()
+{
+ LookForPEXFlag = 0;
+ PEXCode = 0;
+}
diff --git a/decode_randr.c b/decode_randr.c
new file mode 100644
index 0000000..dfe9a3d
--- /dev/null
+++ b/decode_randr.c
@@ -0,0 +1,98 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _RANDR_SERVER_
+#include "scope.h"
+#include "x11.h"
+#include "randrscope.h"
+
+unsigned char LookForRANDRFlag;
+
+unsigned char RANDRRequest, RANDRError, RANDREvent;
+
+randr_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0: RandrQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 1: RandrGetScreenInfo (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 2: RandrSetScreenConfig (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 3: RandrScreenChangeSelectInput (fd, buf);
+ default:
+ break;
+ }
+}
+
+randr_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0: RandrQueryVersionReply (fd, buf); break;
+ case 1: RandrGetScreenInfoReply (fd, buf); break;
+ case 2: RandrSetScreenConfigReply (fd, buf); break;
+ }
+}
+
+randr_decode_event (fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ RandrScreenChangeNotifyEvent (buf);
+}
+
+InitializeRANDR(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ RANDRRequest = (unsigned char)(buf[9]);
+ RANDREvent = (unsigned char)(buf[10]);
+ RANDRError = (unsigned char)(buf[11]);
+ LookForRANDRFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) RANDRRequest, "RandrRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) RANDRRequest, "RandrReply");
+ DefineEValue (&TD[EVENT], (unsigned long) RANDREvent, "RRScreenChangeNotify");
+
+ p = DefineType(RANDRREQUEST, ENUMERATED, "RANDRREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "RandrQueryVersion");
+ DefineEValue(p, 1L, "RandrGetScreenInfo");
+ DefineEValue(p, 2L, "RandrSetScreenConfig");
+ DefineEValue(p, 3L, "RandrScreenChangeSelectInput");
+
+ p = DefineType(RANDRREPLY, ENUMERATED, "RANDRREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "QueryVersion");
+ DefineEValue (p, 1L, "GetScreenInfo");
+ DefineEValue (p, 2L, "SetScreenConfig");
+}
diff --git a/decode_render.c b/decode_render.c
new file mode 100644
index 0000000..8f6252a
--- /dev/null
+++ b/decode_render.c
@@ -0,0 +1,240 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _RENDER_SERVER_
+#include "scope.h"
+#include "x11.h"
+#include "renderscope.h"
+
+unsigned char LookForRENDERFlag;
+
+unsigned char RENDERRequest, RENDERError;
+
+render_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0: RenderQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 1: RenderQueryPictFormats (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 2: RenderQueryPictIndexValues (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 3: RenderQueryDithers (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 4: RenderCreatePicture (fd, buf); break;
+ case 5: RenderChangePicture (fd, buf); break;
+ case 6: RenderSetPictureClipRectangles (fd, buf); break;
+ case 7: RenderFreePicture (fd, buf); break;
+ case 8: RenderComposite (fd, buf); break;
+ case 9: RenderScale (fd, buf); break;
+ case 10: RenderTrapezoids (fd, buf); break;
+ case 11: RenderTriangles (fd, buf); break;
+ case 12: RenderTriStrip (fd, buf); break;
+ case 13: RenderTriFan (fd, buf); break;
+ case 14: RenderColorTrapezoids (fd, buf); break;
+ case 15: RenderColorTriangles (fd, buf); break;
+ case 16: RenderTransform (fd, buf); break;
+ case 17: RenderCreateGlyphSet (fd, buf); break;
+ case 18: RenderReferenceGlyphSet (fd, buf); break;
+ case 19: RenderFreeGlyphSet (fd, buf); break;
+ case 20: RenderAddGlyphs (fd, buf); break;
+ case 21: RenderAddGlyphsFromPicture (fd, buf); break;
+ case 22: RenderFreeGlyphs (fd, buf); break;
+ case 23: RenderCompositeGlyphs8 (fd, buf); break;
+ case 24: RenderCompositeGlyphs16 (fd, buf); break;
+ case 25: RenderCompositeGlyphs32 (fd, buf); break;
+ case 26: RenderFillRectangles (fd, buf); break;
+ default:
+ break;
+ }
+}
+
+render_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0: RenderQueryVersionReply (fd, buf); break;
+ case 1: RenderQueryPictFormatsReply (fd, buf); break;
+ case 2: RenderQueryPictIndexValuesReply (fd, buf); break;
+ case 3: RenderQueryDithersReply (fd, buf); break;
+ }
+}
+
+render_decode_error(fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ short error = IByte(&buf[0]) - RENDERError;
+
+ switch (error) {
+ case 0: RenderPictFormatError (fd, buf); break;
+ case 1: RenderPictureError (fd, buf); break;
+ case 2: RenderPictOpError (fd, buf); break;
+ case 3: RenderGlyphSetError (fd, buf); break;
+ case 4: RenderGlyphError (fd, buf); break;
+ default:
+ break;
+ }
+}
+
+
+PrintPICTURE(buf)
+ unsigned char *buf;
+{
+ /* print a WINDOW -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "PICTURE %08x", n);
+ return(4);
+}
+
+PrintPICTFORMAT(buf)
+ unsigned char *buf;
+{
+ /* print a WINDOW -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "PICTFORMAT %08x", n);
+ return(4);
+}
+
+PrintGLYPHSET(buf)
+ unsigned char *buf;
+{
+ /* print a GLYPHSET -- CARD32 plus 0 = None */
+ long n = ILong (buf);
+ if (n == 0)
+ fprintf(stdout, "None");
+ else
+ fprintf(stdout, "GLYPHSET %08x", n);
+ return(4);
+}
+
+PrintRENDERCOLOR(buf)
+ unsigned char *buf;
+{
+ /* print a RENDERCOLOR */
+ unsigned short r, g, b, a;
+
+ r = IShort(buf);
+ g = IShort(buf+2);
+ b = IShort(buf+4);
+ a = IShort(buf+6);
+ fprintf(stdout, "COLOR r:%04x g:%04x b:%04x a:%04x", r, g, b, a);
+ return(8);
+}
+
+InitializeRENDER(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ RENDERRequest = (unsigned char)(buf[9]);
+ RENDERError = (unsigned char)(buf[11]);
+ LookForRENDERFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) RENDERRequest, "RenderRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) RENDERRequest, "RenderReply");
+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError, "RenderError");
+
+ p = DefineType(RENDERREQUEST, ENUMERATED, "RENDERREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "RenderQueryVersion");
+ DefineEValue(p, 1L, "RenderQueryPictFormats");
+ DefineEValue(p, 2L, "RenderQueryPictIndexValues");
+ DefineEValue(p, 3L, "RenderQueryDithers");
+ DefineEValue(p, 4L, "RenderCreatePicture");
+ DefineEValue(p, 5L, "RenderChangePicture");
+ DefineEValue(p, 6L, "RenderSetPictureClipRectangles");
+ DefineEValue(p, 7L, "RenderFreePicture");
+ DefineEValue(p, 8L, "RenderComposite");
+ DefineEValue(p, 9L, "RenderScale");
+ DefineEValue(p, 10L, "RenderTrapezoids");
+ DefineEValue(p, 11L, "RenderTriangles");
+ DefineEValue(p, 12L, "RenderTriStrip");
+ DefineEValue(p, 13L, "RenderTriFan");
+ DefineEValue(p, 14L, "RenderColorTrapezoids");
+ DefineEValue(p, 15L, "RenderColorTriangles");
+ DefineEValue(p, 16L, "RenderTransform");
+ DefineEValue(p, 17L, "RenderCreateGlyphSet");
+ DefineEValue(p, 18L, "RenderReferenceGlyphSet");
+ DefineEValue(p, 19L, "RenderFreeGlyphSet");
+ DefineEValue(p, 20L, "RenderAddGlyphs");
+ DefineEValue(p, 21L, "RenderAddGlyphsFromPicture");
+ DefineEValue(p, 22L, "RenderFreeGlyphs");
+ DefineEValue(p, 23L, "RenderCompositeGlyphs8");
+ DefineEValue(p, 24L, "RenderCompositeGlyphs16");
+ DefineEValue(p, 25L, "RenderCompositeGlyphs32");
+ DefineEValue(p, 26L, "RenderFillRectangles");
+
+ p = DefineType(RENDERREPLY, ENUMERATED, "RENDERREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "QueryVersion");
+
+ DefineType(PICTURE, BUILTIN, "PICTURE", PrintPICTURE);
+ DefineType(PICTFORMAT, BUILTIN, "PICTFORMAT", PrintPICTFORMAT);
+ DefineType(GLYPHSET, BUILTIN, "GLYPHSET", PrintGLYPHSET);
+ DefineType(RENDERCOLOR, BUILTIN, "RENDERCOLOR", PrintRENDERCOLOR);
+
+ p = DefineType(PICTURE_BITMASK, SET, "PICTURE_BITMASK", PrintSET);
+
+ DefineValues(p, 0x00000001L, 1, BOOL, "repeat");
+ DefineValues(p, 0x00000002L, 1, PICTURE, "alpha-map");
+ DefineValues(p, 0x00000004L, 1, INT16, "alpha-x-origin");
+ DefineValues(p, 0x00000008L, 1, INT16, "alpha-y-origin");
+ DefineValues(p, 0x00000010L, 1, INT16, "clip-x-origin");
+ DefineValues(p, 0x00000020L, 1, INT16, "clip-y-origin");
+ DefineValues(p, 0x00000040L, 1, PIXMAP, "clip-mask");
+ DefineValues(p, 0x00000080L, 1, BOOL, "graphics-exposures");
+ DefineValues(p, 0x00000100L, 1, SUBWINMODE, "repeat");
+ DefineValues(p, 0x00000200L, 1, BOOL, "poly-edge");
+ DefineValues(p, 0x00000400L, 1, BOOL, "poly-mode");
+ DefineValues(p, 0x00000800L, 1, ATOM, "dither");
+ DefineValues(p, 0x00001000L, 1, BOOL, "component-alpha");
+
+ p = DefineType(PICTOP, ENUMERATED, "PICTOP", PrintENUMERATED);
+ DefineEValue (p, 0L, "Clear");
+ DefineEValue (p, 1L, "Src");
+ DefineEValue (p, 2L, "Dst");
+ DefineEValue (p, 3L, "Over");
+ DefineEValue (p, 4L, "OverReverse");
+ DefineEValue (p, 5L, "In");
+ DefineEValue (p, 6L, "InReverse");
+ DefineEValue (p, 7L, "Out");
+ DefineEValue (p, 8L, "OutReverse");
+ DefineEValue (p, 9L, "Atop");
+ DefineEValue (p, 10L, "AtopReverse");
+ DefineEValue (p, 11L, "Xor");
+ DefineEValue (p, 12L, "Add");
+ DefineEValue (p, 13L, "Saturate");
+}
diff --git a/decode_shm.c b/decode_shm.c
new file mode 100644
index 0000000..da2b74c
--- /dev/null
+++ b/decode_shm.c
@@ -0,0 +1,116 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include "scope.h"
+#include "x11.h"
+#include "shmscope.h"
+
+unsigned char LookForMITSHMFlag;
+
+unsigned char MITSHMRequest, MITSHMError, MITSHMEvent;
+
+mitshm_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0: MitshmQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 1: MitshmAttach (fd, buf); break;
+ case 2: MitshmDetach (fd, buf); break;
+ case 3: MitshmPutImage (fd, buf); break;
+ case 4: MitshmGetImage (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break;
+ case 5: MitshmCreatePixmap (fd, buf); break;
+ default:
+ break;
+ }
+}
+
+mitshm_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0: MitshmQueryVersionReply (fd, buf); break;
+ case 4: MitshmGetImageReply (fd, buf); break;
+ }
+}
+
+mitshm_decode_event(fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+}
+
+mitshm_decode_error(fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ short error = IByte(&buf[0]) - MITSHMError;
+
+ switch (error) {
+ case 0: MitshmShmSegError (fd, buf); break;
+ default:
+ break;
+ }
+}
+
+
+InitializeMITSHM(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ MITSHMRequest = (unsigned char)(buf[9]);
+ MITSHMEvent = (unsigned char)(buf[10]);
+ MITSHMError = (unsigned char)(buf[11]);
+ LookForMITSHMFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) MITSHMRequest, "MitshmRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) MITSHMRequest, "MitshmReply");
+ DefineEValue (&TD[EVENT], (unsigned long) MITSHMEvent, "MitshmEvent");
+ DefineEValue (&TD[ERROR], (unsigned long) MITSHMError, "MitshmError");
+
+ p = DefineType(MITSHMREQUEST, ENUMERATED, "MITSHMREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "MitshmQueryVersion");
+ DefineEValue(p, 1L, "MitshmAttach");
+ DefineEValue(p, 2L, "MitshmDetach");
+ DefineEValue(p, 3L, "MitshmPutImage");
+ DefineEValue(p, 4L, "MitshmGetImage");
+ DefineEValue(p, 5L, "MitshmCreatePixmap");
+
+ p = DefineType(MITSHMREPLY, ENUMERATED, "MITSHMREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "QueryVersion");
+ DefineEValue (p, 4L, "GetImage");
+
+ p = DefineType(MITSHMEVENT, ENUMERATED, "MITSHMEVENT", PrintENUMERATED);
+ DefineEValue (p, 0L, "CompletionEvent");
+}
diff --git a/decode_wcp.c b/decode_wcp.c
new file mode 100644
index 0000000..f6529c2
--- /dev/null
+++ b/decode_wcp.c
@@ -0,0 +1,130 @@
+/*
+ * $NCDOr$
+ *
+ * Copyright 1996 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#include <stdio.h>
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#define _WCP_SERVER_
+#include "scope.h"
+#include "x11.h"
+#include "wcpscope.h"
+
+unsigned char LookForWCPFlag;
+
+unsigned char WCPRequest, WCPError;
+
+wcp_decode_req(fd, buf)
+FD fd;
+unsigned char *buf;
+{
+ short Major = IByte (&buf[0]);
+ short Minor = IByte (&buf[1]);
+
+ switch (Minor) {
+ case 0:
+ WcpQueryVersion (fd, buf);
+ ExtendedReplyExpected (fd, Major, Minor);
+ break;
+ case 1:
+ WcpPutImage (fd, buf);
+ break;
+ case 2:
+ WcpGetImage (fd, buf);
+ ExtendedReplyExpected (fd, Major, Minor);
+ break;
+ case 3:
+ WcpCreateColorCursor (fd, buf);
+ break;
+ case 4:
+ WcpCreateLut (fd, buf);
+ break;
+ case 5:
+ WcpFreeLut (fd, buf);
+ break;
+ case 6:
+ WcpCopyArea (fd, buf);
+ break;
+ default:
+ break;
+ }
+}
+
+wcp_decode_reply(fd, buf, RequestMinor)
+ FD fd;
+ unsigned char *buf;
+ short RequestMinor;
+{
+ switch (RequestMinor) {
+ case 0:
+ WcpQueryVersionReply (fd, buf);
+ break;
+ case 2:
+ WcpGetImageReply (fd, buf);
+ break;
+ default:
+ break;
+ }
+}
+
+wcp_decode_error(fd, buf)
+ FD fd;
+ unsigned char *buf;
+{
+ short error = IByte(&buf[1]) - WCPError;
+
+ switch (error) {
+ case 0:
+ break;
+ default:
+ break;
+ }
+}
+
+InitializeWCP(buf)
+ unsigned char *buf;
+{
+ TYPE p, DefineType ();
+
+ WCPRequest = (unsigned char)(buf[9]);
+ WCPError = (unsigned char)(buf[11]);
+ LookForWCPFlag = 0;
+
+ DefineEValue (&TD[REQUEST], (unsigned long) WCPRequest, "WcpRequest");
+ DefineEValue (&TD[REPLY], (unsigned long) WCPRequest, "WcpReply");
+ DefineEValue (&TD[ERROR], (unsigned long) WCPError, "WcpError");
+
+ p = DefineType(WCPREQUEST, ENUMERATED, "WCPREQUEST", PrintENUMERATED);
+ DefineEValue(p, 0L, "WcpQueryVersion");
+ DefineEValue(p, 1L, "WcpPutImage");
+ DefineEValue(p, 2L, "WcpGetImage");
+ DefineEValue(p, 3L, "WcpCreateColorCursor");
+ DefineEValue(p, 4L, "WcpCreateLut");
+ DefineEValue(p, 5L, "WcpFreeLut");
+ DefineEValue(p, 6L, "WcpCopyArea");
+
+ p = DefineType(WCPREPLY, ENUMERATED, "WCPREPLY", PrintENUMERATED);
+ DefineEValue (p, 0L, "QueryVersion");
+
+}
diff --git a/decodenas.c b/decodenas.c
new file mode 100644
index 0000000..687c344
--- /dev/null
+++ b/decodenas.c
@@ -0,0 +1,465 @@
+/* ************************************************************ *
+ * *
+ * Decoding and switching routines for the NAS protocol *
+ * *
+ * James Peterson, 1988 *
+ * (c) Copyright MCC, 1988 *
+ * *
+ * ************************************************************ */
+
+#include "scope.h"
+#include "nas.h"
+
+/*
+ There are 4 types of things in NAS: 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.
+*/
+
+#define DUMP_REQUEST 0
+#define DUMP_REPLY 1
+#define DUMP_EVENT 2
+#define DUMP_ERROR 3
+
+static char *simple_names[] = {
+ "REQUEST",
+ "REPLY ",
+ "EVENT ",
+ "ERROR ",
+};
+
+AudioSimpleDump (type, fd, Major, Minor, bytes)
+{
+ PrintTime ();
+ fprintf (stdout, "@@%s %3d %3d %3d %7d\n",
+ simple_names[type],
+ ClientNumber(fd),
+ Major, Minor, bytes);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeAudioRequest(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Request = IByte (&buf[0]);
+ short RequestMinor = Request >= 128 ? IByte (&buf[1]) : 0;
+ unsigned long seq;
+
+ CS[fd].SequenceNumber += 1;
+ seq = CS[fd].SequenceNumber;
+ if (CS[fd].littleEndian) {
+ SBf[0] = seq;
+ SBf[1] = seq >> 8;
+ SBf[2] = seq >> 16;
+ SBf[3] = seq >> 24;
+ } else {
+ SBf[0] = seq >> 24;
+ SBf[1] = seq >> 16;
+ SBf[2] = seq >> 8;
+ SBf[3] = seq;
+ }
+ SetIndentLevel(PRINTCLIENT);
+
+ if (NasVerbose == 0)
+ {
+ AudioSimpleDump (DUMP_REQUEST, fd, Request, RequestMinor, n);
+ return;
+ }
+
+ if (NasVerbose > 3)
+ DumpItem("Request", fd, buf, n);
+ switch (Request)
+ {
+ case 1:
+ AudioListDevices (buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 2:
+ AudioGetDeviceAttributes(buf);
+ ReplyExpected(fd, Request);
+ break;
+ case 3:
+ AudioSetDeviceAttributes (buf);
+ break;
+ case 4:
+ AudioCreateBucket (buf);
+ break;
+ case 5:
+ AudioDestroyBucket (buf);
+ break;
+ case 6:
+ AudioListBuckets (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 7:
+ AudioGetBucketAttributes (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 8:
+ AudioSetBucketAttributes (buf);
+ break;
+ case 9:
+ AudioCreateRadio (buf);
+ break;
+ case 10:
+ AudioDestroyRadio (buf);
+ break;
+ case 11:
+ AudioListRadios (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 12:
+ AudioGetRadioAttributes (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 13:
+ AudioSetRadioAttributes (buf);
+ break;
+ case 14:
+ AudioCreateFlow (buf);
+ break;
+ case 15:
+ AudioDestroyFlow (buf);
+ break;
+ case 16:
+ AudioGetFlowAttributes (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 17:
+ AudioSetFlowAttributes (buf);
+ break;
+ case 18:
+ AudioGetElements (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 19:
+ AudioSetElements (buf);
+ break;
+ case 20:
+ AudioGetElementStates (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 21:
+ AudioSetElementStates (buf);
+ break;
+ case 22:
+ AudioGetElementParameters (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 23:
+ AudioSetElementParameters (buf);
+ break;
+ case 24:
+ AudioWriteElement (buf);
+ break;
+ case 25:
+ AudioReadElement (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 26:
+ AudioGrabComponent (buf);
+ break;
+ case 27:
+ AudioUngrabComponent (buf);
+ break;
+ case 28:
+ AudioSendEvent (buf);
+ break;
+ case 29:
+ AudioGetAllowedUsers (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 30:
+ AudioSetAllowedUsers (buf);
+ break;
+ case 31:
+ AudioListExtensions (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 32:
+ AudioQueryExtension (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 33:
+ AudioGetCloseDownMode (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 34:
+ AudioSetCloseDownMode (buf);
+ break;
+ case 35:
+ AudioKillClient (buf);
+ break;
+ case 36:
+ AudioGetServerTime (buf);
+ ReplyExpected (fd, Request);
+ break;
+ case 37:
+ AudioNoOperation (buf);
+ break;
+ default:
+ warn("Unimplemented request opcode");
+ break;
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeAudioReply(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short SequenceNumber = IShort (&buf[2]);
+ short RequestMinor;
+ short Request = CheckReplyTable (fd, SequenceNumber, &RequestMinor);
+
+ if (NasVerbose == 0)
+ {
+ AudioSimpleDump (DUMP_REPLY, fd, Request, RequestMinor, n);
+ return;
+ }
+
+ SetIndentLevel(PRINTSERVER);
+ RBf[0] = Request /* for the PrintField in the Reply procedure */ ;
+ RBf[1] = RequestMinor;
+ if (NasVerbose > 3)
+ DumpItem("Reply", fd, buf, n);
+ switch (Request)
+ {
+ case 0:
+ UnknownAudioReply(buf);
+ break;
+ case 1:
+ AudioListDevicesReply (buf);
+ break;
+ case 2:
+ AudioGetDeviceAttributesReply (buf);
+ break;
+ case 6:
+ AudioListBucketsReply (buf);
+ break;
+ case 7:
+ AudioGetBucketAttributesReply (buf);
+ break;
+ case 11:
+ AudioListRadiosReply ();
+ break;
+ case 12:
+ AudioGetRadioAttributesReply (buf);
+ break;
+ case 16:
+ AudioGetFlowAttributesReply (buf);
+ break;
+ case 18:
+ AudioGetElementsReply (buf);
+ break;
+ case 20:
+ AudioGetElementStatesReply (buf);
+ break;
+ case 22:
+ AudioGetElementParametersReply (buf);
+ break;
+ case 25:
+ AudioReadElementReply (buf);
+ break;
+ case 29:
+ AudioGetAllowedUsersReply (buf);
+ break;
+ case 31:
+ AudioListExtensionsReply (buf);
+ break;
+ case 32:
+ AudioQueryExtensionReply (buf);
+ break;
+ case 33:
+ AudioGetCloseDownModeReply (buf);
+ break;
+ case 36:
+ AudioGetServerTimeReply (buf);
+ break;
+ default:
+ warn("Unimplemented reply opcode");
+ break;
+ }
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeAudioError(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Error = IByte (&buf[1]);
+ short Request = 0;
+ short RequestMinor = 0;
+
+ Request = CheckReplyTable (fd, (short)IShort(&buf[2]), &RequestMinor);
+
+ if (NasVerbose == 0)
+ {
+ AudioSimpleDump (DUMP_ERROR, fd, Request, RequestMinor, n);
+ return;
+ }
+
+ SetIndentLevel(PRINTSERVER);
+ if (NasVerbose > 3)
+ DumpItem("Error", fd, buf, n);
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+DecodeAudioEvent(fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ short Event = IByte (&buf[0]);
+ short EventMinor = 0;
+
+ if (NasVerbose == 0)
+ {
+ AudioSimpleDump (DUMP_EVENT, fd, Event, EventMinor, n);
+ return;
+ }
+
+ SetIndentLevel(PRINTSERVER);
+ if (NasVerbose > 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;
+ }
+ switch (Event)
+ {
+ case 2:
+ AudioElementNotify (buf);
+ break;
+ case 3:
+ AudioGrabNotify (buf);
+ break;
+ case 4:
+ AudioMonitorNotify (buf);
+ break;
+ case 5:
+ AudioBucketNotify (buf);
+ break;
+ case 6:
+ AudioDeviceNotify (buf);
+ break;
+ default:
+ warn("Unimplemented event code");
+ break;
+ }
+}
+
+InitializeAudioDecode ()
+{
+ TYPE p;
+ extern TYPE DefineType ();
+
+ p = DefineType (NASREQUEST, ENUMERATED, "NASREQUEST", PrintENUMERATED);
+ DefineEValue (p, 1L, "ListDevices");
+ DefineEValue (p, 2L, "GetDeviceAttributes");
+ DefineEValue (p, 3L, "SetDeviceAttributes");
+ DefineEValue (p, 4L, "CreateBucket");
+ DefineEValue (p, 5L, "DestroyBucket");
+ DefineEValue (p, 6L, "ListBuckets");
+ DefineEValue (p, 7L, "GetBucketAttributes");
+ DefineEValue (p, 8L, "SetBucketAttributes");
+ DefineEValue (p, 9L, "CreateRadio");
+ DefineEValue (p, 10L, "DestroyRadio");
+ DefineEValue (p, 11L, "ListRadios");
+ DefineEValue (p, 12L, "GetRadioAttributes");
+ DefineEValue (p, 13L, "SetRadioAttributes");
+ DefineEValue (p, 14L, "CreateFlow");
+ DefineEValue (p, 15L, "DestroyFlow");
+ DefineEValue (p, 16L, "GetFlowAttributes");
+ DefineEValue (p, 17L, "SetFlowAttributes");
+ DefineEValue (p, 18L, "GetElements");
+ DefineEValue (p, 19L, "SetElements");
+ DefineEValue (p, 20L, "GetElementStates");
+ DefineEValue (p, 21L, "SetElementStates");
+ DefineEValue (p, 22L, "GetElementParameters");
+ DefineEValue (p, 23L, "SetElementParameters");
+ DefineEValue (p, 24L, "WriteElement");
+ DefineEValue (p, 25L, "ReadElement");
+ DefineEValue (p, 26L, "GrabComponent");
+ DefineEValue (p, 27L, "UngrabComponent");
+ DefineEValue (p, 28L, "SendEvent");
+ DefineEValue (p, 29L, "GetAllowedUsers");
+ DefineEValue (p, 30L, "SetAllowedUsers");
+ DefineEValue (p, 31L, "ListExtensions");
+ DefineEValue (p, 32L, "QuerExtension");
+ DefineEValue (p, 33L, "GetCloseDownMode");
+ DefineEValue (p, 34L, "SetCloseDownMode");
+ DefineEValue (p, 35L, "KillClient");
+ DefineEValue (p, 36L, "GetServerTime");
+ DefineEValue (p, 37L, "NoOperation");
+ p = DefineType (NASREPLY, ENUMERATED, "NASREPLY", PrintENUMERATED);
+ DefineEValue (p, 1L, "ListDevices");
+ DefineEValue (p, 2L, "GetDeviceAttributes");
+ DefineEValue (p, 6L, "ListBuckets");
+ DefineEValue (p, 7L, "GetBucketAttributes");
+ DefineEValue (p, 11L, "ListRadios");
+ DefineEValue (p, 12L, "GetRadioAttributes");
+ DefineEValue (p, 16L, "GetFlowAttributes");
+ DefineEValue (p, 18L, "GetElements");
+ DefineEValue (p, 20L, "GetElementStates");
+ DefineEValue (p, 22L, "GetElementParameters");
+ DefineEValue (p, 25L, "ReadElement");
+ DefineEValue (p, 29L, "GetAllowedUsers");
+ DefineEValue (p, 31L, "ListExtensions");
+ DefineEValue (p, 32L, "QueryExtension");
+ DefineEValue (p, 33L, "GetCloseDownMode");
+ DefineEValue (p, 36L, "GetServerTime");
+ p = DefineType (NASEVENT, ENUMERATED, "NASEVENT", PrintENUMERATED);
+ DefineEValue(p, 2L, "ElementNotify");
+ DefineEValue(p, 3L, "GrabNotify");
+ DefineEValue(p, 4L, "MonitorNotify");
+ DefineEValue(p, 5L, "BucketNotify");
+ DefineEValue(p, 6L, "DeviceNotify");
+
+}
diff --git a/fd.c b/fd.c
index 629c7fb..087d769 100644
--- a/fd.c
+++ b/fd.c
@@ -27,6 +27,19 @@
#include "scope.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, ... */
+#ifdef SVR4
+#include <sys/filio.h>
+#endif
+#include <fcntl.h>
+#include <netinet/in.h> /* struct sockaddr_in */
+#include <netinet/tcp.h>
+#include <netdb.h> /* struct servent * and struct hostent * */
+#include <errno.h> /* for EINTR, EADDRINUSE, ... */
+extern int errno;
+
/*
All of this code is to support the handling of file descriptors (FD).
@@ -48,7 +61,11 @@ InitializeFD()
enterprocedure("InitializeFD");
/* get the number of file descriptors the system will let us use */
+#if defined(hpux) || defined(SVR4)
+ MaxFD = _NFILE - 1;
+#else
MaxFD = getdtablesize();
+#endif
if (MaxFD > StaticMaxFD)
{
fprintf(stderr, "Recompile with larger StaticMaxFD value %d\n", MaxFD);
@@ -73,19 +90,20 @@ InitializeFD()
MaxFD -= 4;
nFDsInUse = 0 /* stdin, stdout, stderr */ ;
- FD_ZERO(&ReadDescriptors);
+ ReadDescriptors = 0;
HighestFD = 0;
- UsingFD(fileno(stdin), (int (*)())NULL);
- UsingFD(fileno(stdout), (int (*)())NULL);
+ UsingFD(fileno(stdin), (int (*)())NULL, (int (*)())NULL);
+ UsingFD(fileno(stdout), (int (*)())NULL, (int (*)())NULL);
UsingFD(fileno(stderr), (int (*)())NULL);
}
/* ************************************************************ */
-UsingFD(fd, Handler)
+UsingFD(fd, Handler, FlushHandler)
FD fd;
int (*Handler)();
+ int (*FlushHandler)();
{
if (FDD[fd].Busy)
NotUsingFD(fd);
@@ -93,10 +111,11 @@ UsingFD(fd, Handler)
FDD[fd].Busy = true;
FDD[fd].InputHandler = Handler;
+ FDD[fd].FlushHandler = FlushHandler;
if (Handler == NULL)
- FD_CLR(fd, &ReadDescriptors);
+ ReadDescriptors &= ~(1 << fd) /* clear fd bit */ ;
else
- FD_SET(fd, &ReadDescriptors);
+ ReadDescriptors |= 1 << fd /* set fd bit */ ;
if (fd > HighestFD)
HighestFD = fd;
@@ -118,7 +137,7 @@ NotUsingFD(fd)
nFDsInUse -= 1;
FDD[fd].Busy = false;
- FD_CLR(fd, &ReadDescriptors);
+ ReadDescriptors &= ~(1 << fd) /* clear fd bit */ ;
while (!FDD[HighestFD].Busy && HighestFD > 0)
HighestFD -= 1;
@@ -137,20 +156,158 @@ EOFonFD(fd)
NotUsingFD(fd);
}
-Boolean ValidFD(fd)
- FD fd;
+FD
+AcceptConnection (ConnectionSocket)
+ FD ConnectionSocket;
{
- enterprocedure("ValidFD");
- return(FDD[fd].Busy);
+ FD ClientFD;
+ struct sockaddr_in from;
+ int len = sizeof (from);
+ int tmp = 1;
+
+ 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");
+ }
+
+#ifdef FD_CLOEXEC
+ (void)fcntl(ClientFD, F_SETFD, FD_CLOEXEC);
+#else
+ (void)ioctl(ClientFD, FIOCLEX, 0);
+#endif
+ /* ultrix reads hang on Unix sockets, hpux reads fail */
+#if defined(O_NONBLOCK) && (!defined(ultrix) && !defined(hpux))
+ (void) fcntl (ClientFD, F_SETFL, O_NONBLOCK);
+#else
+#ifdef FIOSNBIO
+ ioctl (ClientFD, FIOSNBIO, &ON);
+#else
+ (void) fcntl (ClientFD, F_SETFL, FNDELAY);
+#endif
+#endif
+ (void) setsockopt(ClientFD, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp, sizeof (int));
+ return(ClientFD);
}
+FD
+MakeConnection(server, port, report)
+ char *server;
+ short port;
+ int report;
+{
+ FD ServerFD;
+ char HostName[512];
+ struct sockaddr_in sin;
+ struct hostent *hp;
+ int tmp = 1;
+#ifndef SO_DONTLINGER
+ struct linger linger;
+#endif /* 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
+ (void) setsockopt(ServerFD, IPPROTO_TCP, TCP_NODELAY, (char *) &tmp, sizeof (int));
+#ifdef SO_DONTLINGER
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0);
+#else /* SO_DONTLINGER */
+ linger.l_onoff = 0;
+ linger.l_linger = 0;
+ (void) setsockopt(ServerFD, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger);
+#endif /* SO_DONTLINGER */
+
+ /* determine the host machine for this process */
+ if (*server == '\0')
+ {
+ (void) gethostname(HostName, sizeof (HostName));
+ server = HostName;
+ }
+ debug(4,(stderr, "try to connect on %s\n", server));
+
+ sin.sin_addr.s_addr = inet_addr (server);
+ if ((long) sin.sin_addr.s_addr == -1)
+ {
+ hp = gethostbyname(server);
+ if (hp == 0)
+ {
+ perror("gethostbyname failed");
+ debug(1,(stderr, "gethostbyname failed for %s\n", server));
+ panic("Can't open connection to Server");
+ }
+ bcopy((char *)hp->h_addr, (char *)&sin.sin_addr, hp->h_length);
+ }
+
+ sin.sin_family = AF_INET;
+
+ if (port == ScopePort
+ && strcmp(server, ScopeHost) == 0)
+ {
+ char error_message[100];
+ (void)sprintf(error_message, "Trying to attach to myself: %s,%d\n",
+ server, sin.sin_port);
+ panic(error_message);
+ }
+
+ sin.sin_port = htons (port);
+
+ /* ******************************************************** */
+ /* 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));
+ return(ServerFD);
+}
+
/* ************************************************************ */
/* */
/* 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;
@@ -161,16 +318,22 @@ MainLoop()
while (true)
{
- fd_set rfds, wfds, xfds;
+ int rfds, wfds, xfds;
short nfds;
short fd;
/* wait for something */
- rfds = ReadDescriptors;
- FD_ZERO(&wfds);
+ rfds = ReadDescriptors & ~BlockedReadDescriptors;
+ wfds = ReadDescriptors & WriteDescriptors;
xfds = rfds;
debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds));
+ if (Interrupt || (rfds == 0 && wfds == 0))
+ {
+ ReadCommands ();
+ Interrupt = 0;
+ continue;
+ }
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));
@@ -188,7 +351,15 @@ MainLoop()
continue;
}
- panic("Select returns error");
+ if (Interrupt)
+ {
+ ReadCommands ();
+ Interrupt = 0;
+ }
+ else
+ {
+ panic("Select returns error");
+ }
continue /* to end of while loop */ ;
}
@@ -199,65 +370,32 @@ MainLoop()
}
/* check each fd to see if it has input */
- for (fd = 0; 0 < nfds && fd <= HighestFD; fd++)
+ for (fd = 0; 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);
+ if (rfds & (1 << fd))
+ {
+ 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);
+ }
+ if (wfds & (1 << fd))
+ {
+ if (FDD[fd].FlushHandler == NULL)
+ {
+ panic("FD selected with no flush handler");
+ }
+ else
+ (FDD[fd].FlushHandler)(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
index 8836638..da48544 100644
--- a/fd.h
+++ b/fd.h
@@ -32,23 +32,21 @@
and if it is in use, by whom.
*/
-#include <sys/select.h>
-
typedef int FD;
struct FDDescriptor
{
Boolean Busy;
int (*InputHandler)();
+ int (*FlushHandler)();
};
-struct FDDescriptor *FDD /* array of FD descriptors */ ;
-short MaxFD /* maximum number of FD's possible */ ;
-
-short nFDsInUse /* number of FD's actually in use */ ;
+extern struct FDDescriptor *FDD /* array of FD descriptors */ ;
+extern short MaxFD /* maximum number of FD's possible */ ;
-fd_set ReadDescriptors /* bit map of FD's in use -- for select */ ;
-short HighestFD /* highest FD in use -- for select */ ;
+extern short nFDsInUse /* number of FD's actually in use */ ;
-Boolean ValidFD();
-Boolean InputAvailable();
+extern long ReadDescriptors /* bit map of FD's in use -- for select */ ;
+extern long WriteDescriptors /* bit map of write blocked FD's -- for select */;
+extern long BlockedReadDescriptors /* bit map of FD's blocked from reading */;
+extern short HighestFD /* highest FD in use -- for select */ ;
diff --git a/imakefile b/imakefile
deleted file mode 100644
index 5bc330d..0000000
--- a/imakefile
+++ /dev/null
@@ -1,5 +0,0 @@
-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/lbxscope.h b/lbxscope.h
new file mode 100644
index 0000000..fc04766
--- /dev/null
+++ b/lbxscope.h
@@ -0,0 +1,48 @@
+/* $XConsortium: pexscope.h,v 5.1 91/02/16 09:31:57 rws Exp $ */
+
+/***********************************************************
+Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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.
+
+******************************************************************/
+
+#ifndef _LBXSCOPE_H_
+#define _LBXSCOPE_H_
+
+#define LBXREQUEST 121
+#define LBXREPLY 122
+#define LBXEVENT 123
+#define LBXERROR 124
+
+#define LBXREQUESTHEADER "LBXREQUEST"
+#define LBXREPLYHEADER "LBXREPLY"
+#define LBXEVENTHEADER "LBXEVENT"
+
+/*
+ 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)
+
+#endif
+
diff --git a/nas.h b/nas.h
new file mode 100644
index 0000000..a30a862
--- /dev/null
+++ b/nas.h
@@ -0,0 +1,123 @@
+/* ************************************************************ *
+ * *
+ * Type definitions and Connection State for the NAS protocol *
+ * *
+ * James Peterson, 1988 *
+ * (c) Copyright MCC, 1988 *
+ * *
+ * ************************************************************ */
+
+
+#include "x11.h"
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/*
+ In general, we are called with a buffer of bytes and are supposed to
+ try to make sense of these bytes according to the NAS 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 NAS 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.
+*/
diff --git a/patchlevel.h b/patchlevel.h
new file mode 100644
index 0000000..0dad8d2
--- /dev/null
+++ b/patchlevel.h
@@ -0,0 +1,2 @@
+#define PATCHLEVEL 1
+
diff --git a/pexOCNames.h b/pexOCNames.h
new file mode 100644
index 0000000..9124aea
--- /dev/null
+++ b/pexOCNames.h
@@ -0,0 +1,134 @@
+/* Automatically generated OC table
+ */
+/******************************************************************
+Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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.
+
+******************************************************************/
+static char *pex_oc_name [] = {
+ "",
+ "MarkerType",
+ "MarkerScale",
+ "MarkerColourIndex",
+ "MarkerColour",
+ "MarkerBundleIndex",
+ "TextFontIndex",
+ "TextPrecision",
+ "CharExpansion",
+ "CharSpacing",
+ "TextColourIndex",
+ "TextColour",
+ "CharHeight",
+ "CharUpVector",
+ "TextPath",
+ "TextAlignment",
+ "AtextHeight",
+ "AtextUpVector",
+ "AtextPath",
+ "AtextAlignment",
+ "AtextStyle",
+ "TextBundleIndex",
+ "LineType",
+ "LineWidth",
+ "LineColourIndex",
+ "LineColour",
+ "CurveApproximation",
+ "PolylineInterp",
+ "LineBundleIndex",
+ "InteriorStyle",
+ "InteriorStyleIndex",
+ "SurfaceColourIndex",
+ "SurfaceColour",
+ "SurfaceReflAttr",
+ "SurfaceReflModel",
+ "SurfaceInterp",
+ "BfInteriorStyle",
+ "BfInteriorStyleIndex",
+ "BfSurfaceColourIndex",
+ "BfSurfaceColour",
+ "BfSurfaceReflAttr",
+ "BfSurfaceReflModel",
+ "BfSurfaceInterp",
+ "SurfaceApproximation",
+ "CullingMode",
+ "DistinguishFlag",
+ "PatternSize",
+ "PatternRefPt",
+ "PatternAttr",
+ "InteriorBundleIndex",
+ "SurfaceEdgeFlag",
+ "SurfaceEdgeType",
+ "SurfaceEdgeWidth",
+ "SurfaceEdgeColourIndex",
+ "SurfaceEdgeColour",
+ "EdgeBundleIndex",
+ "SetAsfValues",
+ "LocalTransform",
+ "LocalTransform2D",
+ "GlobalTransform",
+ "GlobalTransform2D",
+ "ModelClip",
+ "ModelClipVolume",
+ "ModelClipVolume2D",
+ "RestoreModelClip",
+ "ViewIndex",
+ "LightState",
+ "DepthCueIndex",
+ "PickId",
+ "HlhsrIdentifier",
+ "ColourApproxIndex",
+ "RenderingColourModel",
+ "ParaSurfCharacteristics",
+ "AddToNameSet",
+ "RemoveFromNameSet",
+ "ExecuteStructure",
+ "Label",
+ "ApplicationData",
+ "Gse",
+ "Marker",
+ "Marker2D",
+ "Text",
+ "Text2D",
+ "AnnotationText",
+ "AnnotationText2D",
+ "Polyline",
+ "Polyline2D",
+ "PolylineSet",
+ "NurbCurve",
+ "FillArea",
+ "FillArea2D",
+ "ExtFillArea",
+ "FillAreaSet",
+ "FillAreaSet2D",
+ "ExtFillAreaSet",
+ "TriangleStrip",
+ "QuadrilateralMesh",
+ "SOFAS",
+ "NurbSurface",
+ "CellArray",
+ "CellArray2D",
+ "ExtCellArray",
+ "Gdp",
+ "Gdp2D",
+ "Noop"
+};
+
+
diff --git a/pexOCTab.awk b/pexOCTab.awk
new file mode 100644
index 0000000..4794790
--- /dev/null
+++ b/pexOCTab.awk
@@ -0,0 +1,86 @@
+##
+# $XConsortium: pexOCTab.awk,v 5.1 91/02/16 09:32:13 rws Exp $
+###########################################################################
+## Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+##
+## All Rights Reserved
+##
+## Permission to use, copy, modify, and distribute this software and its
+## documentation for any purpose and without fee is hereby granted,
+## provided that the above copyright notice appear in all copies and that
+## both that copyright notice and this permission notice appear in
+## supporting documentation, and that the names of Sun Microsystems,
+## the X Consortium, and MIT not be used in advertising or publicity
+## pertaining to distribution of the software without specific, written
+## prior permission.
+##
+## SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+## INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+## SHALL SUN MICROSYSTEMS 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.
+##
+###########################################################################
+## Usage:
+## rm -f temp.dat
+## awk -f pex_oc_table.awk <pex-include-path>/PEX.h > <output_file>
+##
+BEGIN { num=0; i=0; gap_begin=0; val=0; gap=0; j=0
+ print "/* Automatically generated OC table"
+ print " */"
+ print "/******************************************************************"
+ print "Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium."
+ print ""
+ print " All Rights Reserved"
+ print ""
+ print "Permission to use, copy, modify, and distribute this software and its "
+ print "documentation for any purpose and without fee is hereby granted, "
+ print "provided that the above copyright notice appear in all copies and that"
+ print "both that copyright notice and this permission notice appear in "
+ print "supporting documentation, and that the names of Sun Microsystems,"
+ print "the X Consortium, and MIT not be used in advertising or publicity "
+ print "pertaining to distribution of the software without specific, written "
+ print "prior permission. "
+ print ""
+ print "SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, "
+ print "INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT "
+ print "SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL "
+ print "DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,"
+ print "WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,"
+ print "ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS"
+ print "SOFTWARE."
+ print ""
+ print "******************************************************************/"
+ }
+##
+## Look only for lines starting with PEXOC (in PEX.h).
+## Name (minus PEXOC) is saved in array for printing at the end
+## (signalled by reaching "PEXMaxOC"). This allows us to do the
+## extern declarations and the table in one pass.
+##
+ $1 == "#define" {
+ if ($2 == "PEXMaxOC") {
+ print "static char *pex_oc_name [] = {"
+ for (i=0; i<(num-1); i++) {
+ if (str[i] == "PEX_OC_GAP") {
+ for (j=0; j<gap; j++) print "\t\"\"," }
+ else print "\t\"" str[i] "\"," }
+ print "\t\"" str[i] "\""
+ print "};\n\n" }
+ else if (index($2,"PEXOC") == 1) {
+ str[num] = substr($2,6,(length($2)-5))
+ if (str[num] == "All") { str[num] = "" }
+ val = $3
+ if ((gap_begin != 0) && (gap == 0)) { gap = val - gap_begin - 1 }
+ num++ }
+ else if (num > 0) {
+ if ($2 == "PEX_OC_GAP") {
+ str[num] = "PEX_OC_GAP"
+ gap_begin = val
+ num++ } }
+ }
+##
+##
+END { }
diff --git a/pexRNames.h b/pexRNames.h
new file mode 100644
index 0000000..6fa1a7f
--- /dev/null
+++ b/pexRNames.h
@@ -0,0 +1,134 @@
+/* Automatically generated OC table
+ */
+/******************************************************************
+Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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.
+
+******************************************************************/
+static char *pex_req_name [] = {
+ "",
+ "GetExtensionInfo",
+ "GetEnumeratedTypeInfo",
+ "GetImpDepConstants",
+ "CreateLookupTable",
+ "CopyLookupTable",
+ "FreeLookupTable",
+ "GetTableInfo",
+ "GetPredefinedEntries",
+ "GetDefinedIndices",
+ "GetTableEntry",
+ "GetTableEntries",
+ "SetTableEntries",
+ "DeleteTableEntries",
+ "CreatePipelineContext",
+ "CopyPipelineContext",
+ "FreePipelineContext",
+ "GetPipelineContext",
+ "ChangePipelineContext",
+ "CreateRenderer",
+ "FreeRenderer",
+ "ChangeRenderer",
+ "GetRendererAttributes",
+ "GetRendererDynamics",
+ "BeginRendering",
+ "EndRendering",
+ "BeginStructure",
+ "EndStructure",
+ "RenderOutputCommands",
+ "RenderNetwork",
+ "CreateStructure",
+ "CopyStructure",
+ "DestroyStructures",
+ "GetStructureInfo",
+ "GetElementInfo",
+ "GetStructuresInNetwork",
+ "GetAncestors",
+ "GetDescendants",
+ "FetchElements",
+ "SetEditingMode",
+ "SetElementPointer",
+ "SetElementPointerAtLabel",
+ "ElementSearch",
+ "StoreElements",
+ "DeleteElements",
+ "DeleteElementsToLabel",
+ "DeleteBetweenLabels",
+ "CopyElements",
+ "ChangeStructureRefs",
+ "CreateNameSet",
+ "CopyNameSet",
+ "FreeNameSet",
+ "GetNameSet",
+ "ChangeNameSet",
+ "CreateSearchContext",
+ "CopySearchContext",
+ "FreeSearchContext",
+ "GetSearchContext",
+ "ChangeSearchContext",
+ "SearchNetwork",
+ "CreatePhigsWks",
+ "FreePhigsWks",
+ "GetWksInfo",
+ "GetDynamics",
+ "GetViewRep",
+ "RedrawAllStructures",
+ "UpdateWorkstation",
+ "RedrawClipRegion",
+ "ExecuteDeferredActions",
+ "SetViewPriority",
+ "SetDisplayUpdateMode",
+ "MapDCtoWC",
+ "MapWCtoDC",
+ "SetViewRep",
+ "SetWksWindow",
+ "SetWksViewport",
+ "SetHlhsrMode",
+ "SetWksBufferMode",
+ "PostStructure",
+ "UnpostStructure",
+ "UnpostAllStructures",
+ "GetWksPostings",
+ "GetPickDevice",
+ "ChangePickDevice",
+ "CreatePickMeasure",
+ "FreePickMeasure",
+ "GetPickMeasure",
+ "UpdatePickMeasure",
+ "OpenFont",
+ "CloseFont",
+ "QueryFont",
+ "ListFonts",
+ "ListFontsWithInfo",
+ "QueryTextExtents",
+ "MatchRendererTargets",
+ "Escape",
+ "EscapeWithReply",
+ "RenderElements",
+ "AccumulateState",
+ "BeginPickOne",
+ "EndPickOne",
+ "PickOne",
+ "BeginPickAll",
+ "EndPickAll",
+ "PickAll"
+};
+
+
diff --git a/pexRTab.awk b/pexRTab.awk
new file mode 100644
index 0000000..5ee8ad8
--- /dev/null
+++ b/pexRTab.awk
@@ -0,0 +1,81 @@
+##
+# $XConsortium: pexRTab.awk,v 5.1 91/02/16 09:32:10 rws Exp $
+###########################################################################
+## Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+##
+## All Rights Reserved
+##
+## Permission to use, copy, modify, and distribute this software and its
+## documentation for any purpose and without fee is hereby granted,
+## provided that the above copyright notice appear in all copies and that
+## both that copyright notice and this permission notice appear in
+## supporting documentation, and that the names of Sun Microsystems,
+## the X Consortium, and MIT not be used in advertising or publicity
+## pertaining to distribution of the software without specific, written
+## prior permission.
+##
+## SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+## INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+## SHALL SUN MICROSYSTEMS 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.
+##
+###########################################################################
+## Usage:
+## rm -f temp.dat
+## awk -f pex_oc_table.awk <pex-include-path>/PEX.h > <output_file>
+##
+BEGIN { num=0; i=0; gap_begin=0; val=0; gap=0; j=0
+ print "/* Automatically generated OC table"
+ print " */"
+ print "/******************************************************************"
+ print "Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium."
+ print ""
+ print " All Rights Reserved"
+ print ""
+ print "Permission to use, copy, modify, and distribute this software and its "
+ print "documentation for any purpose and without fee is hereby granted, "
+ print "provided that the above copyright notice appear in all copies and that"
+ print "both that copyright notice and this permission notice appear in "
+ print "supporting documentation, and that the names of Sun Microsystems,"
+ print "the X Consortium, and MIT not be used in advertising or publicity "
+ print "pertaining to distribution of the software without specific, written "
+ print "prior permission. "
+ print ""
+ print "SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, "
+ print "INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT "
+ print "SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL "
+ print "DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,"
+ print "WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,"
+ print "ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS"
+ print "SOFTWARE."
+ print ""
+ print "******************************************************************/"
+ }
+##
+## Look only for lines starting with PEXOC (in PEX.h).
+## Name (minus PEXOC) is saved in array for printing at the end
+## (signalled by reaching "PEXMaxOC"). This allows us to do the
+## extern declarations and the table in one pass.
+##
+ $2 == "PEX_GetExtensionInfo" {
+ str[num] = ""
+ num++ }
+ num > 0 {
+ if ($1 == "#define") {
+ if ($2 == "PEXMaxRequest") {
+ print "static char *pex_req_name [] = {"
+ for (i=0; i<(num-1); i++) { print "\t\"" str[i] "\"," }
+ print "\t\"" str[i] "\""
+ print "};\n\n" }
+ else if (index($2,"PEX_") == 1) {
+ str[num] = substr($2,5,(length($2)-4))
+ val = $3
+ if ((gap_begin != 0) && (gap == 0)) { gap = val - gap_begin - 1 }
+ num++ }
+ } }
+##
+##
+END { }
diff --git a/pexscope.h b/pexscope.h
new file mode 100644
index 0000000..3c42531
--- /dev/null
+++ b/pexscope.h
@@ -0,0 +1,62 @@
+/* $XConsortium: pexscope.h,v 5.1 91/02/16 09:31:57 rws Exp $ */
+
+/***********************************************************
+Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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.
+
+******************************************************************/
+
+#ifndef PEXSCOPE_H_INCLUDED
+#define PEXSCOPE_H_INCLUDED
+
+#ifdef __STDC__
+#define PEX_DECODE_REQUEST(_request_name,ptr) \
+ (void) fprintf(stderr,"\t........PEX_REQUEST: %s\n", \
+ pex_req_name[PEX_##_request_name]); \
+ (void) fprintf(stderr,"\t.............length: %d\n", \
+ ((pex##_request_name##Req *)ptr)->length)
+#else
+#define PEX_DECODE_REQUEST(_request_name,ptr) \
+ (void) fprintf(stderr,"\t........PEX_REQUEST: %s\n", \
+ pex_req_name[PEX_/**/_request_name]); \
+ (void) fprintf(stderr,"\t.............length: %d\n", \
+ ((pex/**/_request_name/**/Req *)ptr)->length)
+#endif
+
+#ifdef __STDC__
+#define PEX_DECODE_REPLY(_reply_name,ptr) \
+ (void) fprintf(stderr,"\t..........PEX_REPLY: %s\n", \
+ pex_req_name[PEX_##_reply_name]); \
+ (void) fprintf(stderr,"\t.............length: %d\n", \
+ ((pex##_reply_name##Reply *)ptr)->length)
+#else
+#define PEX_DECODE_REPLY(_reply_name,ptr) \
+ (void) fprintf(stderr,"\t..........PEX_REPLY: %s\n", \
+ pex_req_name[PEX_/**/_reply_name]); \
+ (void) fprintf(stderr,"\t.............length: %d\n", \
+ ((pex/**/_reply_name/**/Reply *)ptr)->length)
+#endif
+
+#define PEX_DECODE_ELEM(_opcode) \
+ (void) fprint(stderr,"\t..................... %s\n", \
+ pex_oc_name[_opcode])
+
+#endif /* PEXSCOPE_H_INCLUDED */
diff --git a/print11.c b/print11.c
index 2b8f609..938bf10 100644
--- a/print11.c
+++ b/print11.c
@@ -58,7 +58,6 @@
#define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e)
-
/* ************************************************************ */
/* */
/* */
@@ -75,7 +74,6 @@ PrintSetUpMessage(buf)
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");
@@ -153,10 +151,10 @@ PrintSuccessfulSetUpReply(buf)
/* */
/* ************************************************************ */
-static char *REQUESTHEADER = "............REQUEST";
-static char *EVENTHEADER = "..............EVENT";
-static char *ERRORHEADER = "..............ERROR";
-static char *REPLYHEADER = "..............REPLY";
+char *REQUESTHEADER = "............REQUEST";
+char *EVENTHEADER = "..............EVENT";
+char *ERRORHEADER = "..............ERROR";
+char *REPLYHEADER = "..............REPLY";
/* ************************************************************ */
@@ -172,7 +170,7 @@ RequestError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -183,7 +181,7 @@ ValueError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, INT32, "bad value");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -195,7 +193,7 @@ WindowError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Window */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -207,7 +205,7 @@ PixmapError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Pixmap */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -219,7 +217,7 @@ AtomError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Atom */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad atom id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -231,7 +229,7 @@ CursorError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Cursor */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -243,7 +241,7 @@ FontError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Font */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -255,7 +253,7 @@ MatchError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -266,7 +264,7 @@ DrawableError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Drawable */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -278,7 +276,7 @@ AccessError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -289,7 +287,7 @@ AllocError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -300,7 +298,7 @@ ColormapError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Colormap */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -312,7 +310,7 @@ GContextError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* GContext */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -324,7 +322,7 @@ IDChoiceError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, CARD32, "bad resource id");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
@@ -336,7 +334,7 @@ NameError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Name */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -347,7 +345,7 @@ LengthError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -358,7 +356,7 @@ ImplementationError(buf)
PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 8, 2, CARD16, "minor opcode");
PrintField(buf, 10, 1, CARD8, "major opcode");
}
@@ -377,7 +375,7 @@ KeyPressEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, KEYCODE, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -397,7 +395,7 @@ KeyReleaseEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, KEYCODE, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -417,7 +415,7 @@ ButtonPressEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, BUTTON, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -437,7 +435,7 @@ ButtonReleaseEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, BUTTON, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -457,7 +455,7 @@ MotionNotifyEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, MOTIONDETAIL, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -477,7 +475,7 @@ EnterNotifyEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, ENTERDETAIL, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -498,7 +496,7 @@ LeaveNotifyEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, ENTERDETAIL, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "event");
@@ -519,7 +517,7 @@ FocusInEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, ENTERDETAIL, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 1, BUTTONMODE, "mode");
}
@@ -531,7 +529,7 @@ FocusOutEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, ENTERDETAIL, "detail");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 1, BUTTONMODE, "mode");
}
@@ -551,7 +549,7 @@ ExposeEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* Expose */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 2, CARD16, "x");
PrintField(buf, 10, 2, CARD16, "y");
@@ -566,7 +564,7 @@ GraphicsExposureEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GraphicsExposure */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, DRAWABLE, "drawable");
PrintField(buf, 8, 2, CARD16, "x");
PrintField(buf, 10, 2, CARD16, "y");
@@ -583,7 +581,7 @@ NoExposureEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* NoExposure */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, DRAWABLE, "drawable");
PrintField(buf, 8, 2, CARD16, "minor-opcode");
PrintField(buf, 10, 1, CARD8, "major-opcode");
@@ -595,7 +593,7 @@ VisibilityNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* VisibilityNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 1, VISIBLE, "state");
}
@@ -606,7 +604,7 @@ CreateNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CreateNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "parent");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 2, INT16, "x");
@@ -623,7 +621,7 @@ DestroyNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* DestroyNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
}
@@ -634,7 +632,7 @@ UnmapNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* UnmapNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 1, BOOL, "from-configure");
@@ -646,7 +644,7 @@ MapNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 1, BOOL, "override-redirect");
@@ -658,7 +656,7 @@ MapRequestEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapRequest */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "parent");
PrintField(buf, 8, 4, WINDOW, "window");
}
@@ -669,7 +667,7 @@ ReparentNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ReparentNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 4, WINDOW, "parent");
@@ -684,7 +682,7 @@ ConfigureNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 4, WINDOW, "above-sibling");
@@ -703,7 +701,7 @@ ConfigureRequestEvent(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, STACKMODE, "stack-mode");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "parent");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 4, WINDOW, "sibling");
@@ -721,7 +719,7 @@ GravityNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GravityNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 2, INT16, "x");
@@ -734,7 +732,7 @@ ResizeRequestEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ResizeRequest */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 2, CARD16, "width");
PrintField(buf, 10, 2, CARD16, "height");
@@ -746,7 +744,7 @@ CirculateNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "event");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 12, 4, WINDOW, "parent");
@@ -759,7 +757,7 @@ CirculateRequestEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateRequest */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "parent");
PrintField(buf, 8, 4, WINDOW, "window");
PrintField(buf, 16, 1, CIRSTAT, "place");
@@ -771,7 +769,7 @@ PropertyNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* PropertyNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 4, ATOM, "atom");
PrintField(buf, 12, 4, TIMESTAMP, "time");
@@ -784,7 +782,7 @@ SelectionClearEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionClear */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "owner");
PrintField(buf, 12, 4, ATOM, "selection");
@@ -796,7 +794,7 @@ SelectionRequestEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionRequest */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "owner");
PrintField(buf, 12, 4, WINDOW, "requestor");
@@ -811,7 +809,7 @@ SelectionNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, TIMESTAMP, "time");
PrintField(buf, 8, 4, WINDOW, "requestor");
PrintField(buf, 12, 4, ATOM, "selection");
@@ -825,7 +823,7 @@ ColormapNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ColormapNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 4, COLORMAP, "colormap");
PrintField(buf, 12, 1, BOOL, "new");
@@ -837,13 +835,13 @@ ClientMessageEvent(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, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 4, WINDOW, "window");
PrintField(buf, 8, 4, ATOM, "type");
type = ILong(&buf[8]);
@@ -863,7 +861,7 @@ MappingNotifyEvent(buf)
PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MappingNotify */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
PrintField(buf, 4, 1, MAPOBJECT, "request");
PrintField(buf, 5, 1, KEYCODE, "first-keycode");
PrintField(buf, 6, 1, CARD8, "count");
@@ -876,6 +874,34 @@ MappingNotifyEvent(buf)
/* Request and Reply Printing procedures */
+ExtendedRequest(buf)
+ unsigned char *buf;
+{
+ short n;
+ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER);
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ PrintField(buf, 1, 1, CARD8, "minor opcode");
+ printfield (buf, 2, 2, DVALUE2(n-1), "request length");
+ n = IShort(&buf[2]) - 1;
+ (void) PrintList (&buf[4], n, CARD32, "data");
+}
+
+UnknownReply(buf)
+ unsigned char *buf;
+{
+ long n;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER);
+ PrintField(buf, 1, 1, CARD8, "data");
+ printfield (buf, 2, 2, CARD16, "sequence number");
+ printfield (buf, 4, 4, DVALUE4(n), "reply length");
+ n = ILong (&buf[4]) + 6;
+ (void) PrintList (&buf[8], n, CARD32, "data");
+}
+
CreateWindow(buf)
unsigned char *buf;
{
@@ -884,7 +910,7 @@ CreateWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, CARD8, "depth");
printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
@@ -909,7 +935,7 @@ ChangeWindowAttributes(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -925,7 +951,7 @@ GetWindowAttributes(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -938,7 +964,7 @@ GetWindowAttributesReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, BACKSTORE, "backing-store");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(3), "reply length");
PrintField(buf, 8, 4, VISUALID, "visual");
PrintField(buf, 12, 2, WINDOWCLASS, "class");
@@ -964,7 +990,7 @@ DestroyWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -978,7 +1004,7 @@ DestroySubwindows(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -992,7 +1018,7 @@ ChangeSaveSet(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, INS_DEL, "mode");
printfield(buf, 2, 2, CONST2(2), "request length");
@@ -1007,7 +1033,7 @@ ReparentWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1024,7 +1050,7 @@ MapWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1038,7 +1064,7 @@ MapSubwindows(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1052,7 +1078,7 @@ UnmapWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1066,7 +1092,7 @@ UnmapSubwindows(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1080,7 +1106,7 @@ ConfigureWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1096,7 +1122,7 @@ CirculateWindow(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, CIRMODE, "direction");
printfield(buf, 2, 2, CONST2(2), "request length");
@@ -1111,7 +1137,7 @@ GetGeometry(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, DRAWABLE, "drawable");
@@ -1124,7 +1150,7 @@ GetGeometryReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, CARD8, "depth");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 2, INT16, "x");
@@ -1142,7 +1168,7 @@ QueryTree(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1155,7 +1181,7 @@ QueryTreeReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTree */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n), "reply length");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "parent");
@@ -1173,7 +1199,7 @@ InternAtom(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "only-if-exists");
printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
@@ -1188,7 +1214,7 @@ InternAtomReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* InternAtom */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, ATOM, "atom");
}
@@ -1201,7 +1227,7 @@ GetAtomName(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, ATOM, "atom");
@@ -1214,7 +1240,7 @@ GetAtomNameReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetAtomName */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "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]);
@@ -1233,7 +1259,7 @@ ChangeProperty(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, CHANGEMODE, "mode");
printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length");
@@ -1263,7 +1289,7 @@ DeleteProperty(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(3), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1278,7 +1304,7 @@ GetProperty(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "delete");
printfield(buf, 2, 2, CONST2(6), "request length");
@@ -1301,7 +1327,7 @@ GetPropertyReply(buf)
return;
PrintField(buf, 1, 1, CARD8, "format");
format = IByte(&buf[1]);
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
PrintField(buf, 8, 4, ATOM, "type");
type = ILong(&buf[8]);
@@ -1326,7 +1352,7 @@ ListProperties(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1339,7 +1365,7 @@ ListPropertiesReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListProperties */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n), "reply length");
printfield(buf, 8, 2, DVALUE2(n), "number of atoms");
n = IShort(&buf[8]);
@@ -1354,7 +1380,7 @@ SetSelectionOwner(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, WINDOW, "owner");
@@ -1370,7 +1396,7 @@ GetSelectionOwner(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, ATOM, "selection");
@@ -1382,7 +1408,7 @@ GetSelectionOwnerReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetSelectionOwner */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, WINDOW, "owner");
}
@@ -1395,7 +1421,7 @@ ConvertSelection(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(6), "request length");
PrintField(buf, 4, 4, WINDOW, "requestor");
@@ -1413,7 +1439,7 @@ SendEvent(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "propagate");
printfield(buf, 2, 2, CONST2(11), "request length");
@@ -1430,7 +1456,7 @@ GrabPointer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "owner-events");
printfield(buf, 2, 2, CONST2(6), "request length");
@@ -1450,7 +1476,7 @@ GrabPointerReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, GRABSTAT, "status");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
}
@@ -1462,7 +1488,7 @@ UngrabPointer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, TIMESTAMP, "time");
@@ -1476,7 +1502,7 @@ GrabButton(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "owner-events");
printfield(buf, 2, 2, CONST2(6), "request length");
@@ -1498,7 +1524,7 @@ UngrabButton(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BUTTONA, "button");
printfield(buf, 2, 2, CONST2(3), "request length");
@@ -1514,7 +1540,7 @@ ChangeActivePointerGrab(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, CURSOR, "cursor");
@@ -1530,7 +1556,7 @@ GrabKeyboard(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "owner-events");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -1547,7 +1573,7 @@ GrabKeyboardReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, GRABSTAT, "status");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
}
@@ -1559,7 +1585,7 @@ UngrabKeyboard(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, TIMESTAMP, "time");
@@ -1573,7 +1599,7 @@ GrabKey(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "owner-events");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -1592,7 +1618,7 @@ UngrabKey(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, KEYCODEA, "key");
printfield(buf, 2, 2, CONST2(3), "request length");
@@ -1608,7 +1634,7 @@ AllowEvents(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, EVENTMODE, "mode");
printfield(buf, 2, 2, CONST2(2), "request length");
@@ -1623,7 +1649,7 @@ GrabServer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -1636,7 +1662,7 @@ UngrabServer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -1649,7 +1675,7 @@ QueryPointer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1662,7 +1688,7 @@ QueryPointerReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, BOOL, "same-screen");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, WINDOW, "root");
PrintField(buf, 12, 4, WINDOW, "child");
@@ -1681,7 +1707,7 @@ GetMotionEvents(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -1696,7 +1722,7 @@ GetMotionEventsReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetMotionEvents */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
printfield(buf, 8, 4, DVALUE4(n), "number of events");
n = ILong(&buf[8]);
@@ -1711,7 +1737,7 @@ TranslateCoordinates(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, WINDOW, "src-window");
@@ -1727,7 +1753,7 @@ TranslateCoordinatesReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, BOOL, "same-screen");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, WINDOW, "child");
PrintField(buf, 12, 2, INT16, "dst-x");
@@ -1742,7 +1768,7 @@ WarpPointer(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(6), "request length");
PrintField(buf, 4, 4, WINDOW, "src-window");
@@ -1763,7 +1789,7 @@ SetInputFocus(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
printfield(buf, 2, 2, CONST2(3), "request length");
@@ -1779,7 +1805,7 @@ GetInputFocus(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -1791,7 +1817,7 @@ GetInputFocusReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, FOCUSAGENT, "revert-to");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, WINDOWNR, "focus");
}
@@ -1804,7 +1830,7 @@ QueryKeymap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -1815,7 +1841,7 @@ QueryKeymapReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryKeymap */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(2), "reply length");
PrintBytes(&buf[8], 32L, "keys");
}
@@ -1830,7 +1856,7 @@ OpenFont(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
PrintField(buf, 4, 4, FONT, "font-id");
@@ -1847,7 +1873,7 @@ CloseFont(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, FONT, "font");
@@ -1861,7 +1887,7 @@ QueryFont(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, FONTABLE, "font");
@@ -1877,7 +1903,7 @@ QueryFontReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryFont */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "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");
@@ -1901,14 +1927,14 @@ QueryFontReply(buf)
QueryTextExtents(buf)
unsigned char *buf;
{
- short n;
+ int 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(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 1, 1, BOOL, "odd length?");
printfield(buf, 2, 2, DVALUE2(2 + (2*n + p) / 4), "request length");
@@ -1926,7 +1952,7 @@ QueryTextExtentsReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, DIRECT, "draw-direction");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, INT16, "font-ascent");
PrintField(buf, 10, 2, INT16, "font-descent");
@@ -1947,7 +1973,7 @@ ListFonts(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
PrintField(buf, 4, 2, CARD16, "max-names");
@@ -1964,7 +1990,7 @@ ListFontsReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListFonts */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
printfield(buf, 8, 2, CARD16, "number of names");
n = IShort(&buf[8]);
@@ -1981,7 +2007,7 @@ ListFontsWithInfo(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
PrintField(buf, 4, 2, CARD16, "max-names");
@@ -2014,7 +2040,7 @@ ListFontsWithInfoReply1(buf)
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, 2, 2, CARD16, "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");
@@ -2038,7 +2064,7 @@ ListFontsWithInfoReply2(buf)
unsigned char *buf;
{
PrintField(buf, 1, 1, CONST1(0), "last-reply indicator");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(7), "reply length");
}
@@ -2051,7 +2077,7 @@ SetFontPath(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
printfield(buf, 4, 2, CARD16, "number of paths");
@@ -2067,7 +2093,7 @@ GetFontPath(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 2, 2, CONST2(1), "request list");
}
@@ -2079,7 +2105,7 @@ GetFontPathReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetFontPath */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
printfield(buf, 8, 2, CARD16, "number of paths");
n = IShort(&buf[8]);
@@ -2094,7 +2120,7 @@ CreatePixmap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, CARD8, "depth");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -2112,21 +2138,50 @@ FreePixmap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, PIXMAP, "pixmap");
}
+unsigned long GCDefaults[] = {
+ 3, /* function GXcopy */
+ ~0, /* planemask */
+ 0, /* foreground */
+ 1, /* background */
+ 0, /* line width */
+ 0, /* line style Solid */
+ 1, /* cap style Butt */
+ 0, /* join style Miter */
+ 0, /* fill style Solid */
+ 0, /* fill rule EvenOdd */
+ 0, /* tile */
+ 0, /* stipple */
+ 0, /* ts org x */
+ 0, /* ts org y */
+ 0, /* font */
+ 0, /* sub window mode ClipByChildren */
+ 1, /* graphics expose True */
+ 0, /* clip x org */
+ 0, /* clip y org */
+ 0, /* clip mask */
+ 0, /* dash offset */
+ 4, /* dashes */
+ 1, /* arc mode PieSlice */
+};
+
CreateGC(buf)
unsigned char *buf;
{
+ CreateValueRec (ILong(buf+4), 23, GCDefaults);
+ SetValueRec (ILong(buf+4), &buf[12], 4, GC_BITMASK, &buf[16]);
+
/* 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(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(4 + n), "request length");
PrintField(buf, 4, 4, GCONTEXT, "graphic-context-id");
@@ -2138,12 +2193,14 @@ CreateGC(buf)
ChangeGC(buf)
unsigned char *buf;
{
+ SetValueRec (ILong(buf+4), &buf[8], 4, GC_BITMASK, &buf[12]);
+
/* 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(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
PrintField(buf, 4, 4, GCONTEXT, "gc");
@@ -2159,7 +2216,7 @@ CopyGC(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, GCONTEXT, "src-gc");
@@ -2176,7 +2233,7 @@ SetDashes(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
PrintField(buf, 4, 4, GCONTEXT, "gc");
@@ -2196,7 +2253,7 @@ SetClipRectangles(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, RECTORDER, "ordering");
printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length");
@@ -2210,12 +2267,14 @@ SetClipRectangles(buf)
FreeGC(buf)
unsigned char *buf;
{
+ DeleteValueRec (ILong (&buf[4]));
+
/* 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(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, GCONTEXT, "gc");
@@ -2229,7 +2288,7 @@ ClearArea(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "exposures");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -2248,12 +2307,18 @@ CopyArea(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[12]),
+ GC_function|
+ GC_plane_mask|
+ GC_graphics_exposures,
+ GC_BITMASK);
PrintField(buf, 16, 2, INT16, "src-x");
PrintField(buf, 18, 2, INT16, "src-y");
PrintField(buf, 20, 2, INT16, "dst-x");
@@ -2270,12 +2335,20 @@ CopyPlane(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[12]),
+ GC_function|
+ GC_plane_mask|
+ GC_foreground|
+ GC_background|
+ GC_graphics_exposures,
+ GC_BITMASK);
PrintField(buf, 16, 2, INT16, "src-x");
PrintField(buf, 18, 2, INT16, "src-y");
PrintField(buf, 20, 2, INT16, "dst-x");
@@ -2294,13 +2367,19 @@ PolyPoint(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_foreground,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, POINT, "points");
}
@@ -2313,13 +2392,27 @@ PolyLine(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_line_width|
+ GC_line_style|
+ GC_cap_style|
+ GC_join_style|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, POINT, "points");
}
@@ -2332,12 +2425,25 @@ PolySegment(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_line_width|
+ GC_line_style|
+ GC_cap_style|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, SEGMENT, "segments");
}
@@ -2350,12 +2456,26 @@ PolyRectangle(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_line_width|
+ GC_line_style|
+ GC_cap_style|
+ GC_join_style|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles");
}
@@ -2368,12 +2488,26 @@ PolyArc(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_line_width|
+ GC_line_style|
+ GC_cap_style|
+ GC_join_style|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, ARC, "arcs");
}
@@ -2386,12 +2520,23 @@ FillPoly(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong(buf+8),
+ GC_function|
+ GC_plane_mask|
+ GC_fill_style|
+ GC_fill_rule|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
PrintField(buf, 12, 1, POLYSHAPE, "shape");
PrintField(buf, 13, 1, COORMODE, "coordinate-mode");
(void)PrintList(&buf[16], (long)n, POINT, "points");
@@ -2406,12 +2551,22 @@ PolyFillRectangle(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong(buf+8),
+ GC_function|
+ GC_plane_mask|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles");
}
@@ -2424,25 +2579,36 @@ PolyFillArc(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_arc_mode|
+ GC_fill_style|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
(void)PrintList(&buf[12], (long)n, ARC, "arcs");
}
PutImage(buf)
unsigned char *buf;
{
- short n;
+ int 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(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, IMAGEMODE, "format");
printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length");
@@ -2462,13 +2628,21 @@ PutImage(buf)
n = (IShort(&buf[2]) - 6) * 4;
PrintField(buf, 4, 4, DRAWABLE, "drawable");
PrintField(buf, 8, 4, GCONTEXT, "gc");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_foreground|
+ GC_background,
+ GC_BITMASK);
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");
+ if (Verbose > 3)
+ PrintBytes(&buf[24], (long)n, "data");
}
GetImage(buf)
@@ -2479,7 +2653,7 @@ GetImage(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, IMAGEMODE, "format");
printfield(buf, 2, 2, CONST2(5), "request length");
@@ -2500,7 +2674,7 @@ GetImageReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, CARD8, "depth");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "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
@@ -2508,25 +2682,37 @@ GetImageReply(buf)
length from the length of the reply */
n = ILong(&buf[4]) * 4;
PrintField(buf, 8, 4, VISUALID, "visual");
- PrintBytes(&buf[32], n, "data");
+ if (Verbose > 3)
+ PrintBytes(&buf[32], n, "data");
}
PolyText8(buf)
unsigned char *buf;
{
- short n;
+ int 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(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_fill_style|
+ GC_font|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
PrintField(buf, 12, 2, INT16, "x");
PrintField(buf, 14, 2, INT16, "y");
PrintTextList8(&buf[16], n, "items");
@@ -2535,19 +2721,30 @@ PolyText8(buf)
PolyText16(buf)
unsigned char *buf;
{
- short n;
+ int 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(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_fill_style|
+ GC_font|
+ GC_foreground|
+ GC_background|
+ GC_tile|
+ GC_stipple,
+ GC_BITMASK);
PrintField(buf, 12, 2, INT16, "x");
PrintField(buf, 14, 2, INT16, "y");
PrintTextList16(&buf[16], n, "items");
@@ -2562,16 +2759,23 @@ ImageText8(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_plane_mask|
+ GC_font|
+ GC_foreground|
+ GC_background,
+ GC_BITMASK);
PrintField(buf, 12, 2, INT16, "x");
PrintField(buf, 14, 2, INT16, "y");
- PrintString8(&buf[16], (long)n, "string");
+ PrintTString8(&buf[16], (long)n, "string");
}
ImageText16(buf)
@@ -2583,16 +2787,23 @@ ImageText16(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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");
+ if (Verbose > 2)
+ PrintValueRec (ILong (&buf[8]),
+ GC_plane_mask|
+ GC_font|
+ GC_foreground|
+ GC_background,
+ GC_BITMASK);
PrintField(buf, 12, 2, INT16, "x");
PrintField(buf, 14, 2, INT16, "y");
- PrintString16(&buf[16], (long)n, "string");
+ PrintTString16(&buf[16], (long)n, "string");
}
CreateColormap(buf)
@@ -2603,7 +2814,7 @@ CreateColormap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, ALLORNONE, "alloc");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -2620,7 +2831,7 @@ FreeColormap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2634,7 +2845,7 @@ CopyColormapAndFree(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(3), "request length");
PrintField(buf, 4, 4, COLORMAP, "color-map-id");
@@ -2649,7 +2860,7 @@ InstallColormap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2663,7 +2874,7 @@ UninstallColormap(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2677,7 +2888,7 @@ ListInstalledColormaps(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -2690,7 +2901,7 @@ ListInstalledColormapsReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListInstalledColormaps */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n), "reply length");
printfield(buf, 8, 2, DVALUE2(n), "number of cmaps");
n = IShort(&buf[8]);
@@ -2705,7 +2916,7 @@ AllocColor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(4), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2720,7 +2931,7 @@ AllocColorReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColor */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, CARD16, "red");
PrintField(buf, 10, 2, CARD16, "green");
@@ -2737,7 +2948,7 @@ AllocNamedColor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2752,7 +2963,7 @@ AllocNamedColorReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocNamedColor */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 4, CARD32, "pixel");
PrintField(buf, 12, 2, CARD16, "exact-red");
@@ -2771,7 +2982,7 @@ AllocColorCells(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "contiguous");
printfield(buf, 2, 2, CONST2(3), "request length");
@@ -2789,7 +3000,7 @@ AllocColorCellsReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorCells */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n + m), "reply length");
printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
n = IShort(&buf[8]);
@@ -2807,7 +3018,7 @@ AllocColorPlanes(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, BOOL, "contiguous");
printfield(buf, 2, 2, CONST2(4), "request length");
@@ -2825,7 +3036,7 @@ AllocColorPlanesReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorPlanes */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n), "reply length");
printfield(buf, 8, 2, DVALUE2(n), "number of pixels");
n = IShort(&buf[8]);
@@ -2845,7 +3056,7 @@ FreeColors(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
n = IShort(&buf[2]) - 3;
@@ -2863,7 +3074,7 @@ StoreColors(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + 3*n), "request length");
n = (IShort(&buf[2]) - 2) / 3;
@@ -2880,7 +3091,7 @@ StoreNamedColor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, COLORMASK, "which colors?");
printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length");
@@ -2900,7 +3111,7 @@ QueryColors(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + n), "request length");
n = IShort(&buf[2]) - 2;
@@ -2915,7 +3126,7 @@ QueryColorsReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryColors */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
printfield(buf, 8, 2, DVALUE2(n), "number of colors");
n = IShort(&buf[8]);
@@ -2931,7 +3142,7 @@ LookupColor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length");
PrintField(buf, 4, 4, COLORMAP, "cmap");
@@ -2946,7 +3157,7 @@ LookupColorReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LookupColor */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, CARD16, "exact-red");
PrintField(buf, 10, 2, CARD16, "exact-green");
@@ -2964,7 +3175,7 @@ CreateCursor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(8), "request length");
PrintField(buf, 4, 4, CURSOR, "cursor-id");
@@ -2988,7 +3199,7 @@ CreateGlyphCursor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(8), "request length");
PrintField(buf, 4, 4, CURSOR, "cursor-id");
@@ -3012,7 +3223,7 @@ FreeCursor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, CURSOR, "cursor");
@@ -3026,7 +3237,7 @@ RecolorCursor(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(5), "request length");
PrintField(buf, 4, 4, CURSOR, "cursor");
@@ -3046,7 +3257,7 @@ QueryBestSize(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, OBJECTCLASS, "class");
printfield(buf, 2, 2, CONST2(3), "request length");
@@ -3061,7 +3272,7 @@ QueryBestSizeReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryBestSize */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, CARD16, "width");
PrintField(buf, 10, 2, CARD16, "height");
@@ -3076,26 +3287,56 @@ QueryExtension(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "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;
{
+ extern unsigned char LookForLBXFlag;
+ extern unsigned char LookForWCPFlag;
+ extern unsigned char LookForRENDERFlag;
+ extern unsigned char LookForRANDRFlag;
+#ifdef PEX
+ extern unsigned char LookForPEXFlag;
+ extern unsigned char PEXCode;
+
+ /* PEX content */
+ if (LookForPEXFlag) {
+ PEXCode = (unsigned char)(buf[9]);
+ LookForPEXFlag=0;
+ }
+#endif
+ if (LookForLBXFlag) {
+ InitializeLBX(buf);
+ LookForLBXFlag = 0;
+ }
+ if (LookForWCPFlag) {
+ InitializeWCP(buf);
+ }
+ if (LookForRENDERFlag) {
+ InitializeRENDER(buf);
+ }
+ if (LookForRANDRFlag) {
+ InitializeRANDR(buf);
+ }
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryExtension */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "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)
@@ -3106,7 +3347,7 @@ ListExtensions(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3121,7 +3362,7 @@ ListExtensionsReply(buf)
return;
printfield(buf, 1, 1, CARD8, "number names");
n = IByte(&buf[1]);
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
PrintListSTR(&buf[32], (long)n, "names");
}
@@ -3136,7 +3377,7 @@ ChangeKeyboardMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, DVALUE1(n), "keycode-count");
n = IByte(&buf[1]);
@@ -3155,7 +3396,7 @@ GetKeyboardMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 1, KEYCODE, "first-keycode");
@@ -3170,7 +3411,7 @@ GetKeyboardMappingReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, DVALUE1(n), "keysyms-per-keycode");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n*m), "reply length");
n = ILong(&buf[4]);
(void)PrintList(&buf[32], n, KEYSYM, "keysyms");
@@ -3184,7 +3425,7 @@ ChangeKeyboardControl(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(2 + n), "request length");
PrintField(buf, 4, 4, KEYBOARD_BITMASK, "value-mask");
@@ -3199,7 +3440,7 @@ GetKeyboardControl(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3211,7 +3452,7 @@ GetKeyboardControlReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, OFF_ON, "global-auto-repeat");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "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");
@@ -3229,7 +3470,7 @@ Bell(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, INT8, "percent");
printfield(buf, 2, 2, CONST2(1), "request length");
@@ -3243,7 +3484,7 @@ ChangePointerControl(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(3), "request length");
PrintField(buf, 4, 2, INT16, "acceleration-numerator");
@@ -3261,7 +3502,7 @@ GetPointerControl(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3272,7 +3513,7 @@ GetPointerControlReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerControl */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, CARD16, "acceleration-numerator");
PrintField(buf, 10, 2, CARD16, "acceleration-denominator");
@@ -3287,7 +3528,7 @@ SetScreenSaver(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(3), "request length");
PrintField(buf, 4, 2, INT16, "timeout");
@@ -3304,7 +3545,7 @@ GetScreenSaver(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3315,7 +3556,7 @@ GetScreenSaverReply(buf)
PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetScreenSaver */ ;
if (Verbose < 1)
return;
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
PrintField(buf, 8, 2, CARD16, "timeout");
PrintField(buf, 10, 2, CARD16, "interval");
@@ -3332,7 +3573,7 @@ ChangeHosts(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, INS_DEL, "mode");
printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length");
@@ -3350,7 +3591,7 @@ ListHosts(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3363,7 +3604,7 @@ ListHostsReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, DIS_EN, "mode");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(n / 4), "reply length");
printfield(buf, 8, 2, CARD16, "number of hosts");
n = IShort(&buf[8]);
@@ -3378,7 +3619,7 @@ SetAccessControl(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, DIS_EN, "mode");
printfield(buf, 2, 2, CONST2(1), "request length");
@@ -3392,7 +3633,7 @@ SetCloseDownMode(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, CLOSEMODE, "mode");
printfield(buf, 2, 2, CONST2(1), "request length");
@@ -3406,7 +3647,7 @@ KillClient(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(2), "request length");
PrintField(buf, 4, 4, RESOURCEID, "resource");
@@ -3421,7 +3662,7 @@ RotateProperties(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, DVALUE2(3 + n), "request length");
PrintField(buf, 4, 4, WINDOW, "window");
@@ -3439,7 +3680,7 @@ ForceScreenSaver(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, SAVEMODE, "mode");
printfield(buf, 2, 2, CONST2(1), "request length");
@@ -3454,7 +3695,7 @@ SetPointerMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 1, 1, DVALUE1(n), "length of map");
n = IByte(&buf[1]);
@@ -3469,7 +3710,7 @@ SetPointerMappingReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, RSTATUS, "status");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
}
@@ -3481,7 +3722,7 @@ GetPointerMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3495,7 +3736,7 @@ GetPointerMappingReply(buf)
return;
printfield(buf, 1, 1, DVALUE1(n), "length of map");
n = IByte(&buf[1]);
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
PrintBytes(&buf[32], (long)n,"map");
}
@@ -3509,7 +3750,7 @@ SetModifierMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
n = IByte(&buf[1]);
@@ -3531,7 +3772,7 @@ SetModifierMappingReply(buf)
if (Verbose < 1)
return;
PrintField(buf, 1, 1, RSTATUS, "status");
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, CONST4(0), "reply length");
}
@@ -3543,7 +3784,7 @@ GetModifierMapping(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
@@ -3557,7 +3798,7 @@ GetModifierMappingReply(buf)
return;
PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier");
n = IByte(&buf[1]);
- printfield(buf, 2, 2, INT16, "sequence number");
+ printfield(buf, 2, 2, CARD16, "sequence number");
printfield(buf, 4, 4, DVALUE4(2*n), "reply length");
(void)PrintList(&buf[32], (long)n, KEYCODE, "keycodes");
}
@@ -3570,7 +3811,7 @@ NoOperation(buf)
if (Verbose < 1)
return;
if (Verbose > 1)
- PrintField(SBf, 0, 4, INT32, "sequence number");
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
printfield(buf, 2, 2, CONST2(1), "request length");
}
diff --git a/print_bigreq.c b/print_bigreq.c
new file mode 100644
index 0000000..230cee4
--- /dev/null
+++ b/print_bigreq.c
@@ -0,0 +1,53 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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"
+#include "bigreqscope.h"
+
+BigreqEnable (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* BigreqRequest */ ;
+ PrintField (buf, 1, 1, BIGREQREQUEST, BIGREQREQUESTHEADER) /* BigreqSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+BigreqEnableReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* BigreqRequest reply */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 4, CARD32, "max-request-size");
+}
diff --git a/print_lbx.c b/print_lbx.c
new file mode 100644
index 0000000..d758dd9
--- /dev/null
+++ b/print_lbx.c
@@ -0,0 +1,197 @@
+/*
+ * $NCDId$
+ *
+ * Copyright 1992 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#include "scope.h"
+#include "x11.h"
+#include "lbxscope.h"
+
+static unsigned long sequences[256];
+static unsigned char starting_server[256];
+static unsigned char starting_client[256];
+static int client_client, server_client;
+
+LbxQueryVersion (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+LbxQueryVersionReply (fd, buf)
+register unsigned char *buf;
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LbxRequest reply */ ;
+ PrintField(RBf, 1, 1, LBXREPLY, LBXREPLYHEADER) /* LbxQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "major-version");
+ PrintField(buf, 10, 2, CARD16, "minor-version");
+}
+
+LbxStartProxy (fd, buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+LbxStopProxy (fd, buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+LbxNewClient (fd, buf)
+register unsigned char *buf;
+{
+ unsigned long c;
+
+ c = ILong(&buf[4]);
+ starting_client[c] = 1;
+ starting_server[c] = 1;
+ sequences[c] = 0;
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, CARD32, "new-client-id");
+}
+
+LbxCloseClient (fd, buf)
+ unsigned char *buf;
+{
+}
+
+long StartSetUpMessage ();
+long StartSetUpReply ();
+
+LbxSwitch (fd, buf)
+register unsigned char *buf;
+{
+ unsigned long c;
+ c = ILong(&buf[4]);
+ CS[fd].SequenceNumber--;
+ sequences[client_client] = CS[fd].SequenceNumber;
+ if (starting_client[c])
+ {
+ CS[fd].ByteProcessing = StartSetUpMessage;
+ CS[fd].NumberofBytesNeeded = 12;
+ starting_client[c] = 0;
+ }
+ CS[fd].SequenceNumber = sequences[c];
+ client_client = c;
+
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, CARD32, "client number");
+}
+
+LbxModifySequence (fd, buf)
+ unsigned char *buf;
+{
+ int mod;
+
+ mod = ILong(&buf[4]);
+ CS[fd].SequenceNumber += mod;
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ;
+ PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxModifySequence */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ printfield(buf, 4, 4, INT32, "adjustment");
+}
+
+LbxSwitchEvent (fd, buf)
+ unsigned char *buf;
+{
+ unsigned long c;
+
+ c = ILong(&buf[4]);
+ if (starting_server[c])
+ {
+ CS[fd].ByteProcessing = StartSetUpReply;
+ CS[fd].NumberofBytesNeeded = 8;
+ starting_server[c] = 0;
+ }
+
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LbxEvent */ ;
+ PrintField(buf, 1, 1, LBXEVENT, LBXEVENTHEADER) /* LbxSwitchEvent */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "client");
+}
+
+LbxCloseEvent (fd, buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LbxEvent */ ;
+ PrintField(buf, 1, 1, LBXEVENT, LBXEVENTHEADER) /* LbxSwitchEvent */ ;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "client");
+}
diff --git a/print_pex.c b/print_pex.c
new file mode 100644
index 0000000..8929d90
--- /dev/null
+++ b/print_pex.c
@@ -0,0 +1,917 @@
+/* $XConsortium: print_pex.c,v 5.4 91/02/17 12:34:48 rws Exp $ */
+
+/***********************************************************
+Copyright (c) 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the names of Sun Microsystems,
+the X Consortium, and MIT not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+SHALL SUN MICROSYSTEMS 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>
+#include <X11/X.h>
+#include <X11/extensions/PEX.h>
+#include <X11/extensions/PEXproto.h>
+#include "pexRNames.h"
+#include "pexOCNames.h"
+#include "pexscope.h"
+
+
+#define PEX_CARD8 0
+#define PEX_CARD16 1
+#define PEX_CARD32 2
+#define PEX_ENUM 3
+#define PEX_FP_FORMAT 4
+#define PEX_STRING 5
+#define PEX_DRAWABLE 6
+
+Nothing(buf)
+register unsigned char *buf;
+{
+}
+
+GetExtensionInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetExtensionInfo,buf);
+ pex_print(buf,4,2,PEX_CARD16," Protocol Major Version");
+ pex_print(buf,6,2,PEX_CARD16," Protocol Minor Version");
+}
+
+GetExtensionInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetExtensionInfo,buf);
+ pex_print(buf,8,2,PEX_CARD16," Protocol Major Version");
+ pex_print(buf,10,2,PEX_CARD16," Protocol Minor Version");
+ pex_print(buf,12,4,PEX_CARD32,"\t Release Number");
+ pex_print(buf,16,4,PEX_CARD32," Length of Vendor Name");
+ pex_print(buf,20,4,PEX_CARD32,"\t\tSubset info");
+}
+
+GetEnumeratedTypeInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetEnumeratedTypeInfo,buf);
+ pex_print(buf,4,4,PEX_DRAWABLE,"\t Drawable Id");
+}
+
+GetEnumeratedTypeInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetEnumeratedTypeInfo,buf);
+}
+
+GetImpDepConstants(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetImpDepConstants,buf);
+}
+
+GetImpDepConstantsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetImpDepConstants,buf);
+}
+
+CreateLookupTable(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreateLookupTable,buf);
+}
+
+CopyLookupTable(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopyLookupTable,buf);
+}
+
+FreeLookupTable(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreeLookupTable,buf);
+}
+
+GetTableInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetTableInfo,buf);
+}
+
+GetTableInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetTableInfo,buf);
+}
+
+GetPredefinedEntries(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetPredefinedEntries,buf);
+}
+
+GetPredefinedEntriesReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetPredefinedEntries,buf);
+}
+
+GetDefinedIndices(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetDefinedIndices,buf);
+}
+
+GetDefinedIndicesReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetDefinedIndices,buf);
+}
+
+GetTableEntry(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetTableEntry,buf);
+}
+
+GetTableEntryReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetTableEntry,buf);
+}
+
+GetTableEntries(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetTableEntries,buf);
+}
+
+GetTableEntriesReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetTableEntries,buf);
+}
+
+SetTableEntries(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetTableEntries,buf);
+}
+
+DeleteTableEntries(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(DeleteTableEntries,buf);
+}
+
+CreatePipelineContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreatePipelineContext,buf);
+}
+
+CopyPipelineContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopyPipelineContext,buf);
+}
+
+FreePipelineContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreePipelineContext,buf);
+}
+
+GetPipelineContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetPipelineContext,buf);
+}
+
+GetPipelineContextReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetPipelineContext,buf);
+}
+
+ChangePipelineContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangePipelineContext,buf);
+}
+
+CreateRenderer(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreateRenderer,buf);
+}
+
+FreeRenderer(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreeRenderer,buf);
+}
+
+ChangeRenderer(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangeRenderer,buf);
+}
+
+GetRendererAttributes(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetRendererAttributes,buf);
+}
+
+GetRendererAttributesReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetRendererAttributes,buf);
+}
+
+BeginRendering(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(BeginRendering,buf);
+}
+
+EndRendering(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(EndRendering,buf);
+}
+
+BeginStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(BeginStructure,buf);
+}
+
+EndStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(EndStructure,buf);
+}
+
+RenderOutputCommands(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(RenderOutputCommands,buf);
+}
+
+RenderNetwork(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(RenderNetwork,buf);
+}
+
+CreateStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreateStructure,buf);
+}
+
+CopyStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopyStructure,buf);
+}
+
+GetRendererDynamics(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetRendererDynamics,buf);
+}
+
+GetRendererDynamicsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetRendererDynamics,buf);
+}
+
+DestroyStructures(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(DestroyStructures,buf);
+}
+
+GetStructureInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetStructureInfo,buf);
+}
+
+GetStructureInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetStructureInfo,buf);
+}
+
+GetElementInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetElementInfo,buf);
+}
+
+GetElementInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetElementInfo,buf);
+}
+
+GetStructuresInNetwork(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetStructuresInNetwork,buf);
+}
+
+GetStructuresInNetworkReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetStructuresInNetwork,buf);
+}
+
+GetAncestors(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetAncestors,buf);
+}
+
+GetAncestorsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetAncestors,buf);
+}
+
+GetDescendants(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetDescendants,buf);
+}
+
+GetDescendantsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetDescendants,buf);
+}
+
+FetchElements(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FetchElements,buf);
+}
+
+FetchElementsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(FetchElements,buf);
+}
+
+SetEditingMode(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetEditingMode,buf);
+}
+
+SetElementPointer(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetElementPointer,buf);
+}
+
+SetElementPointerAtLabel(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetElementPointerAtLabel,buf);
+}
+
+ElementSearch(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ElementSearch,buf);
+}
+
+ElementSearchReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(ElementSearch,buf);
+}
+
+StoreElements(buf)
+unsigned char *buf;
+{
+ pexStoreElementsReq *req_ptr = (pexStoreElementsReq *)buf;
+ CARD32 num_cmds = req_ptr->numCommands;
+ PEX_DECODE_REQUEST(StoreElements,buf);
+ buf += sizeof(pexStoreElementsReq);
+ pex_decode_elem(num_cmds, (unsigned char *)(buf));
+}
+
+DeleteElements(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(DeleteElements,buf);
+}
+
+DeleteElementsToLabel(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(DeleteElementsToLabel,buf);
+}
+
+DeleteBetweenLabels(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(DeleteBetweenLabels,buf);
+}
+
+CopyElements(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopyElements,buf);
+}
+
+ChangeStructureRefs(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangeStructureRefs,buf);
+}
+
+CreateNameSet(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreateNameSet,buf);
+}
+
+CopyNameSet(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopyNameSet,buf);
+}
+
+FreeNameSet(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreeNameSet,buf);
+}
+
+GetNameSet(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetNameSet,buf);
+}
+
+GetNameSetReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetNameSet,buf);
+}
+
+ChangeNameSet(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangeNameSet,buf);
+}
+
+CreateSearchContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreateSearchContext,buf);
+}
+
+CopySearchContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CopySearchContext,buf);
+}
+
+FreeSearchContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreeSearchContext,buf);
+}
+
+GetSearchContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetSearchContext,buf);
+}
+
+GetSearchContextReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetSearchContext,buf);
+}
+
+ChangeSearchContext(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangeSearchContext,buf);
+}
+
+SearchNetwork(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SearchNetwork,buf);
+}
+
+SearchNetworkReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(SearchNetwork,buf);
+}
+
+CreatePhigsWks(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreatePhigsWks,buf);
+}
+
+FreePhigsWks(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreePhigsWks,buf);
+}
+
+GetWksInfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetWksInfo,buf);
+}
+
+GetWksInfoReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetWksInfo,buf);
+}
+
+GetDynamics(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetDynamics,buf);
+}
+
+GetDynamicsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetDynamics,buf);
+}
+
+GetViewRep(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetViewRep,buf);
+}
+
+GetViewRepReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetViewRep,buf);
+}
+
+RedrawAllStructures(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(RedrawAllStructures,buf);
+}
+
+UpdateWorkstation(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(UpdateWorkstation,buf);
+}
+
+ExecuteDeferredActions(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ExecuteDeferredActions,buf);
+}
+
+SetViewPriority(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetViewPriority,buf);
+}
+
+SetDisplayUpdateMode(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetDisplayUpdateMode,buf);
+}
+
+MapDCtoWC(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(MapDCtoWC,buf);
+}
+
+MapDCtoWCReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(MapDCtoWC,buf);
+}
+
+MapWCtoDC(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(MapWCtoDC,buf);
+}
+
+MapWCtoDCReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(MapWCtoDC,buf);
+}
+
+SetViewRep(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetViewRep,buf);
+}
+
+SetWksWindow(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetWksWindow,buf);
+}
+
+SetWksViewport(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetWksViewport,buf);
+}
+
+SetHlhsrMode(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(SetHlhsrMode,buf);
+}
+
+PostStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(PostStructure,buf);
+}
+
+UnpostStructure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(UnpostStructure,buf);
+}
+
+UnpostAllStructures(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(UnpostAllStructures,buf);
+}
+
+GetWksPostings(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetWksPostings,buf);
+}
+
+GetWksPostingsReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetWksPostings,buf);
+}
+
+GetPickDevice(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetPickDevice,buf);
+}
+
+GetPickDeviceReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetPickDevice,buf);
+}
+
+ChangePickDevice(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ChangePickDevice,buf);
+}
+
+CreatePickMeasure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CreatePickMeasure,buf);
+}
+
+FreePickMeasure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(FreePickMeasure,buf);
+}
+
+GetPickMeasure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(GetPickMeasure,buf);
+}
+
+GetPickMeasureReply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(GetPickMeasure,buf);
+}
+
+UpdatePickMeasure(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(UpdatePickMeasure,buf);
+}
+
+pexopenfont(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(OpenFont,buf);
+}
+
+pexclosefont(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(CloseFont,buf);
+}
+
+pexqueryfont(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(QueryFont,buf);
+}
+
+pexqueryfontreply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(QueryFont,buf);
+}
+
+pexlistfonts(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ListFonts,buf);
+}
+
+pexlistfontsreply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(ListFonts,buf);
+}
+
+pexlistfontswithinfo(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(ListFontsWithInfo,buf);
+}
+
+pexlistfontswithinforeply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(ListFontsWithInfo,buf);
+}
+
+pexquerytextextents(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(QueryTextExtents,buf);
+}
+
+pexquerytextextentsreply(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REPLY(QueryTextExtents,buf);
+}
+
+RedrawClipRegion(buf)
+register unsigned char *buf;
+{
+ PEX_DECODE_REQUEST(RedrawClipRegion,buf);
+}
+
+/*
+ * PEX Error Printing procedures
+ */
+pexerror_colortype(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_rendererstate(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_floatingpointformat(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_label(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_lookuptable(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_nameset(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_path(buf)
+register unsigned char *buf;
+{
+}
+pexerror_font(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_phigswks(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_pickmeasure(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_pipelinecontext(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_renderer(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_searchcontext(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_structure(buf)
+register unsigned char *buf;
+{
+}
+
+pexerror_outputcommand(buf)
+register unsigned char *buf;
+{
+}
+
+
+pex_print(buf, start, length, field_type, name)
+ unsigned char *buf;
+ short start;
+ short length;
+ short field_type;
+ char *name;
+{
+ switch (field_type) {
+ case PEX_CARD8:
+ break;
+ case PEX_CARD16:
+ fprintf(stderr,"%s: %d\n",name,*((CARD16*)&buf[start]));
+ break;
+ case PEX_CARD32:
+ fprintf(stderr,"%s: %d\n",name,*((CARD32*)&buf[start]));
+ break;
+ case PEX_DRAWABLE:
+ fprintf(stderr,"%s: %d\n",name,*((Drawable*)&buf[start]));
+ break;
+ case PEX_ENUM:
+ break;
+ case PEX_FP_FORMAT:
+ break;
+ case PEX_STRING:
+ break;
+ default:
+ break;
+ }
+}
diff --git a/print_randr.c b/print_randr.c
new file mode 100644
index 0000000..cc1b0c1
--- /dev/null
+++ b/print_randr.c
@@ -0,0 +1,155 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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"
+#include "randrscope.h"
+
+RandrQueryVersion (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ;
+ PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RandrQueryVersionReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ;
+ PrintField(RBf, 1, 1, RANDRREPLY, RANDRREPLYHEADER) /* RandrQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "major-version");
+ PrintField(buf, 10, 2, CARD16, "minor-version");
+}
+RandrGetScreenInfo (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ;
+ PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+}
+
+RandrGetScreenInfoReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ;
+ PrintField(RBf, 1, 1, RANDRREPLY, RANDRREPLYHEADER) /* RandrQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+}
+
+RandrSetScreenConfig (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ;
+ PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, TIMESTAMP, "timestamp");
+ PrintField(buf,12, 4, TIMESTAMP, "config-timestamp");
+ PrintField(buf,16, 2, CARD16, "size-id");
+ PrintField(buf,18, 2, CARD16, "rotation");
+ PrintField(buf,20, 2, CARD16, "visual-group-id");
+}
+
+RandrSetScreenConfigReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ;
+ PrintField(buf, 1, 1, BOOL, "success") /* RandrQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 4, TIMESTAMP, "new-timestamp");
+ PrintField(buf,12, 4, TIMESTAMP, "new-config-timestamp");
+ PrintField(buf,16, 4, WINDOW, "root");
+}
+
+RandrScreenChangeSelectInput (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ;
+ PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, WINDOW, "window");
+ PrintField(buf, 8, 1, BOOL, "enable");
+}
+
+RandrScreenSizes (buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 2, CARD16, "width-in-pixels");
+ PrintField(buf, 2, 2, CARD16, "height-in-pixels");
+ PrintField(buf, 4, 2, CARD16, "width-in-millimeters");
+ PrintField(buf, 6, 2, CARD16, "height-in-millimeters");
+ PrintField(buf, 8, 2, CARD16, "visual-group");
+}
+
+RandrScreenChangeNotifyEvent(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* RRScreenChangeNotify */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(buf, 1, 1, BOOL, "resident");
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "timestamp");
+ PrintField(buf, 8, 4, TIMESTAMP, "config-timestamp");
+ PrintField(buf,12, 4, WINDOW, "root");
+ PrintField(buf,16, 2, CARD16, "size id");
+ PrintField(buf,18, 2, CARD16, "rotation");
+ RandrScreenSizes (buf + 20);
+}
diff --git a/print_render.c b/print_render.c
new file mode 100644
index 0000000..f7cdab4
--- /dev/null
+++ b/print_render.c
@@ -0,0 +1,480 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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"
+#include "renderscope.h"
+
+RenderQueryVersion (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderQueryVersionReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ;
+ PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "major-version");
+ PrintField(buf, 10, 2, CARD16, "minor-version");
+}
+RenderQueryPictFormats (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderQueryPictFormatsReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ;
+ PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+}
+RenderQueryPictIndexValues (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderQueryPictIndexValuesReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ;
+ PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+}
+RenderQueryDithers (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderQueryDithersReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ;
+ PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+}
+RenderCreatePicture (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(5+n), "request length");
+ PrintField(buf, 4, 4, PICTURE, "picture");
+ PrintField(buf, 8, 4, DRAWABLE, "drawable");
+ PrintField(buf, 12, 4, PICTFORMAT, "format");
+ PrintField(buf, 16, 4, PICTURE_BITMASK, "value-mask");
+ PrintValues(&buf[16], 4, PICTURE_BITMASK, &buf[20], "value-list");
+}
+RenderChangePicture (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3+n), "request length");
+ PrintField(buf, 4, 4, PICTURE, "picture");
+ PrintField(buf, 8, 4, PICTURE_BITMASK, "value-mask");
+ PrintValues(&buf[8], 4, PICTURE_BITMASK, &buf[12], "value-list");
+}
+RenderSetPictureClipRectangles (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderFreePicture (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderComposite (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderScale (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderTrapezoids (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderTriangles (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderTriStrip (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderTriFan (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderColorTrapezoids (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderColorTriangles (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderTransform (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderCreateGlyphSet (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderReferenceGlyphSet (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderFreeGlyphSet (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderAddGlyphs (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderAddGlyphsFromPicture (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+RenderFreeGlyphs (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+extern char Leader[];
+
+void
+PrintGlyphList(unsigned char *buf, int length, char *name, int size)
+{
+ short n;
+
+ fprintf(stdout, "%s%20s:\n", Leader, name);
+ while (length >= 8)
+ {
+ n = IByte(&buf[0]);
+ if (n != 255)
+ {
+ printfield(buf, 0, 1, CARD8, "length");
+ PrintField(buf, 4, 2, INT16, "delta x");
+ PrintField(buf, 6, 2, INT16, "delta y");
+ switch (size) {
+ case 1:
+ PrintTString8(&buf[8], (long) n, "glyph item 8 string"); break;
+ case 2:
+ PrintTString16(&buf[8], (long) n, "glyph item 16 string"); break;
+ case 4:
+ break;
+ }
+ buf += n*size + 8;
+ length -= n*size+8;
+ }
+ else
+ {
+ PrintField(buf, 4, 4, GLYPHSET, "glyphset");
+ buf += 8;
+ length -= 8;
+ }
+ }
+}
+
+RenderCompositeGlyphs8 (FD fd, unsigned char *buf)
+{
+ int n;
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ n = (IShort(&buf[2]) - 7) * 4;
+ PrintField(buf, 4, 1, PICTOP, "op");
+ PrintField(buf, 8, 4, PICTURE, "source");
+ PrintField(buf, 12, 4, PICTURE, "dest");
+ PrintField(buf, 16, 4, PICTFORMAT, "mask format");
+ PrintField(buf, 20, 4, GLYPHSET, "glyphset");
+ PrintField(buf, 24, 2, INT16, "x-src");
+ PrintField(buf, 26, 2, INT16, "y-src");
+ PrintGlyphList(&buf[28], n, "items", 1);
+}
+
+RenderCompositeGlyphs16 (FD fd, unsigned char *buf)
+{
+ int n;
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ n = (IShort(&buf[2]) - 7) * 4;
+
+ PrintField(buf, 4, 1, PICTOP, "op");
+ PrintField(buf, 8, 4, PICTURE, "source");
+ PrintField(buf, 12, 4, PICTURE, "dest");
+ PrintField(buf, 16, 4, PICTFORMAT, "mask format");
+ PrintField(buf, 20, 4, GLYPHSET, "glyphset");
+ PrintField(buf, 24, 2, INT16, "x-src");
+ PrintField(buf, 26, 2, INT16, "y-src");
+ PrintGlyphList(&buf[28], n, "items", 2);
+}
+RenderCompositeGlyphs32 (FD fd, unsigned char *buf)
+{
+ int n;
+
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ n = (IShort(&buf[2]) - 7) * 4;
+ PrintField(buf, 4, 1, PICTOP, "op");
+ PrintField(buf, 8, 4, PICTURE, "source");
+ PrintField(buf, 12, 4, PICTURE, "dest");
+ PrintField(buf, 16, 4, PICTFORMAT, "mask format");
+ PrintField(buf, 20, 4, GLYPHSET, "glyphset");
+ PrintField(buf, 24, 2, INT16, "x-src");
+ PrintField(buf, 26, 2, INT16, "y-src");
+ PrintGlyphList(&buf[28], n, "items", 4);
+}
+RenderFillRectangles (FD fd, unsigned char *buf)
+{
+ int n;
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ;
+ PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ n = (IShort(&buf[2]) - 5) / 2;
+ PrintField(buf, 4, 1, PICTOP, "op");
+ PrintField(buf, 8, 4, PICTURE, "dest");
+ PrintField(buf, 12, 8, RENDERCOLOR, "color");
+ (void)PrintList(&buf[20], (long)n, RECTANGLE, "rectangles");
+}
+RenderPictFormatError (fd, buf)
+{
+}
+RenderPictureError (fd, buf)
+{
+}
+RenderPictOpError (fd, buf)
+{
+}
+RenderGlyphSetError (fd, buf)
+{
+}
+RenderGlyphError (fd, buf)
+{
+}
diff --git a/print_shm.c b/print_shm.c
new file mode 100644
index 0000000..e5a5b3e
--- /dev/null
+++ b/print_shm.c
@@ -0,0 +1,171 @@
+/*
+ * $XFree86$
+ *
+ * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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"
+#include "shmscope.h"
+
+MitshmQueryVersion (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+MitshmQueryVersionReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* MitshmRequest reply */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(RBf, 1, 1, BOOL, "shared-pixmaps") /* shared Pixmaps */;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "major-version");
+ PrintField(buf, 10, 2, CARD16, "minor-version");
+ PrintField(buf, 12, 2, CARD16, "uid");
+ PrintField(buf, 14, 2, CARD16, "gid");
+ PrintField(buf, 16, 1, CARD8, "pxiamp-fromat");
+}
+MitshmAttach (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, CARD32, "shmseg");
+ PrintField(buf, 8, 4, CARD32, "shmid");
+ PrintField(buf, 12, 1, BOOL, "read-only");
+}
+
+MitshmDetach (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField (buf, 4, 4, CARD32, "shmseg");
+}
+
+MitshmPutImage (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField (buf, 4, 4, DRAWABLE, "drawable");
+ PrintField (buf, 8, 4, GCONTEXT, "gc");
+ PrintField (buf, 12, 2, CARD16, "total-width");
+ PrintField (buf, 14, 2, CARD16, "total-width");
+ PrintField (buf, 16, 2, CARD16, "src-x");
+ PrintField (buf, 18, 2, CARD16, "src-y");
+ PrintField (buf, 20, 2, CARD16, "src-width");
+ PrintField (buf, 22, 2, CARD16, "src-height");
+ PrintField (buf, 24, 2, INT16, "dst-x");
+ PrintField (buf, 26, 2, INT16, "dst-y");
+ PrintField (buf, 28, 1, CARD8, "depth");
+ PrintField (buf, 29, 1, CARD8, "format");
+ PrintField (buf, 30, 1, BOOL, "send-event");
+ PrintField (buf, 31, 1, CARD8, "bpad");
+ PrintField (buf, 32, 4, CARD32, "shmseg");
+ PrintField (buf, 36, 4, CARD32, "offset");
+}
+
+MitshmGetImage (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(5+n), "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, "planemask");
+ PrintField (buf, 20, 1, CARD8, "format");
+ PrintField (buf, 24, 4, CARD32, "shmseg");
+ PrintField (buf, 28, 4, CARD32, "shmseg");
+}
+
+MitshmGetImageReply (FD fd, unsigned char *buf)
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* MitshmRequest reply */ ;
+ if (Verbose < 1)
+ return;
+ PrintField(RBf, 1, 1, CARD8, "depth") /* shared Pixmaps */;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 4, VISUALID, "visual");
+}
+
+MitshmCreatePixmap (FD fd, unsigned char *buf)
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ;
+ PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, DVALUE2(3+n), "request length");
+ PrintField(buf, 4, 4, PIXMAP, "pid");
+ PrintField(buf, 8, 4, DRAWABLE, "drawable");
+ PrintField(buf, 12, 2, CARD16, "width");
+ PrintField(buf, 14, 2, CARD16, "height");
+ PrintField(buf, 16, 1, CARD8, "depth");
+ PrintField(buf, 20, 4, CARD32, "shmseg");
+ PrintField(buf, 24, 4, CARD32, "offset");
+}
+MitshmShmSegError (fd, buf)
+{
+}
diff --git a/print_wcp.c b/print_wcp.c
new file mode 100644
index 0000000..e86158f
--- /dev/null
+++ b/print_wcp.c
@@ -0,0 +1,465 @@
+/*
+ * $NCDOr: print_wcp.c,v 1.1 1996/07/18 23:26:38 keithp Exp keithp $
+ *
+ * Copyright 1996 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#include "scope.h"
+#include "x11.h"
+#include "wcpscope.h"
+
+WcpQueryVersion (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+WcpQueryVersionReply (fd, buf)
+register unsigned char *buf;
+{
+ short n;
+ long m;
+ long k;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* WcpRequest reply */ ;
+ PrintField(RBf, 1, 1, WCPREPLY, WCPREPLYHEADER) /* WcpQueryVersion reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(0), "reply length");
+ PrintField(buf, 8, 2, CARD16, "major-version");
+ PrintField(buf, 10, 2, CARD16, "minor-version");
+}
+
+#define NextByte(dst) if (!len--) { error = "Out of data"; break; } dst = *data++;
+
+extern char Leader[];
+
+WcpAnalyzeImage1RLL (buf, len, width, height)
+ char *buf;
+ int len;
+ int width;
+ int height;
+{
+ unsigned char byte;
+ unsigned char *data = (unsigned char *) buf;
+ int x, y;
+ char *error = 0;
+ int bytewidth;
+ int i;
+ int w;
+
+ y = 0;
+ bytewidth = (width + 7) >> 3;
+ while (!error && height--)
+ {
+ x = 0;
+ if (Verbose > 2)
+ fprintf (stdout, "%s %9d %9d:", Leader, y, (char *) data - buf);
+ NextByte (byte);
+ if (Verbose > 2)
+ fprintf (stdout, " %2x", byte);
+ switch (byte) {
+ case 0xff:
+ for (i = 0; i < bytewidth; i++)
+ {
+ NextByte(byte);
+ }
+ break;
+ default:
+ w = width;
+ while (w)
+ {
+ NextByte(byte);
+ if (Verbose > 2)
+ fprintf (stdout, " %3d", byte);
+ if (byte > w)
+ {
+ error = "bad run";
+ break;
+ }
+ x += byte;
+ w -= byte;
+ }
+ break;
+ }
+ if (Verbose > 2)
+ fprintf (stdout, "\n");
+ y++;
+ }
+ if (error)
+ fprintf (stdout, "%s%20s: %d, %d %d\n", Leader, error,
+ x, y - 1, (char *) data - buf);
+}
+
+WcpAnalyzeImageNRLL (buf, len, width, height, bytes)
+ char *buf;
+ int len;
+ int width;
+ int height;
+ int bytes;
+{
+}
+
+#define MAX_LRU_SHORT 0xe
+#define LRU_LONG 0xf
+#define MAX_LRU_RUN (MAX_LRU_SHORT + 0xff)
+
+#define LRU_CACHE 0xf
+#define LRU_MISS 0xf
+
+typedef unsigned long PIXEL;
+
+static void
+init_cache (cache, BPP)
+ PIXEL cache[LRU_CACHE];
+ int BPP;
+{
+ int e;
+
+ /*
+ * initialize cache values
+ */
+ for (e = 0; e < 8; e++)
+ {
+ cache[e] = e;
+ cache[LRU_CACHE-e-1] = ((1 << BPP) - 1) - e;
+ }
+}
+
+static void
+push (cache, pixel)
+ PIXEL cache[LRU_CACHE];
+ PIXEL pixel;
+{
+ int e;
+
+ e = LRU_CACHE - 1;
+ while (--e >= 0)
+ cache[e+1] = cache[e];
+ cache[0] = pixel;
+}
+
+static PIXEL
+use (cache, e)
+ PIXEL cache[LRU_CACHE];
+ int e;
+{
+ PIXEL tmp;
+
+ tmp = cache[e];
+ if (e)
+ {
+ while (--e >= 0)
+ cache[e+1] = cache[e];
+ cache[0] = tmp;
+ }
+ return tmp;
+}
+
+static int
+match (cache, pixel)
+ PIXEL cache[LRU_CACHE];
+ PIXEL pixel;
+{
+ int e;
+
+ for (e = 0; e < LRU_CACHE; e++)
+ if (cache[e] == pixel)
+ {
+ use (cache, e);
+ return e;
+ }
+ push (cache, pixel);
+ return LRU_MISS;
+}
+
+WcpAnalyzeImageNLRU (buf, len, width, height, bytes)
+ char *buf;
+ int len;
+ int width;
+ int height;
+ int bytes;
+{
+ unsigned char *data = (unsigned char *) buf;
+ unsigned char byte;
+ int x, y;
+ int w;
+ int i;
+ int bytewidth;
+ int cache;
+ unsigned long run;
+ PIXEL lru[LRU_CACHE];
+ PIXEL pix;
+ char *error = 0;
+
+ y = 0;
+ bytewidth = width * bytes;
+ while (!error && height--)
+ {
+ x = 0;
+ if (Verbose > 2)
+ fprintf (stdout, "%s %9d %9d:", Leader, y, (char *) data - buf);
+ NextByte (byte);
+ if (Verbose > 2)
+ fprintf (stdout, " %2x", byte);
+ switch (byte) {
+ case 0xff:
+ for (i = 0; i < bytewidth; i++)
+ {
+ NextByte (byte);
+ }
+ break;
+ default:
+ init_cache (lru, bytes * 8);
+ w = width;
+ while (w)
+ {
+ NextByte (byte);
+ run = byte >> 4;
+ cache = byte & 0xf;
+ if (run == LRU_LONG)
+ {
+ NextByte (byte);
+ run = (int) byte + MAX_LRU_SHORT;
+ }
+ run++;
+ if (cache == LRU_MISS)
+ {
+ pix = 0;
+ for (i = 0; i < bytes; i++)
+ {
+ pix = pix << 8;
+ NextByte (byte);
+ pix |= byte;
+ }
+ push (lru, pix);
+ }
+ else
+ {
+ pix = use (lru, cache);
+ }
+ w -= run;
+ if (w < 0)
+ {
+ error = "bad run";
+ break;
+ }
+ x += run;
+ fprintf (stdout, " %3d:%0*x", run, bytes * 2, pix);
+ }
+ break;
+ }
+ if (Verbose > 2)
+ fprintf (stdout, "\n");
+ y++;
+ }
+ if (error)
+ fprintf (stdout, "%s%20s: %d, %d %d\n", Leader, error,
+ x, y - 1, (char *) data - buf);
+}
+
+WcpAnalyzeImage (buf, len, depth, encoding, width, height)
+ char *buf;
+ int len;
+ int depth;
+ int encoding;
+ int width;
+ int height;
+{
+ int bytes;
+
+ bytes = depth / 8;
+ switch (depth) {
+ case 1:
+ switch (encoding) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ WcpAnalyzeImage1RLL (buf, len, width, height);
+ return;
+ default:
+ break;
+ }
+ break;
+ case 4:
+ switch (encoding) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ default:
+ break;
+ }
+ break;
+ case 8:
+ case 16:
+ case 24:
+ switch (encoding) {
+ case 1:
+ case 2:
+ case 3:
+ WcpAnalyzeImageNRLL (buf, len, width, height, bytes);
+ return;
+ case 4:
+ WcpAnalyzeImageNLRU (buf, len, width, height, bytes);
+ return;
+ default:
+ break;
+ }
+ break;
+ }
+ fprintf (stdout, "%s%20s: ", Leader, "invalid");
+ fprintf (stdout, "encoding %d depth %d\n", encoding, depth);
+}
+
+WcpPutImage (fd, buf)
+ unsigned char *buf;
+{
+ int n;
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ n = (IShort(&buf[2]) - 7) * 4;
+ printfield(buf, 2, 2, DVALUE2(7 + (n + p) / 4), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, GCONTEXT, "gc");
+ if (Verbose > 2)
+ PrintValueRec (ILong(&buf[8]),
+ GC_function|
+ GC_plane_mask|
+ GC_foreground|
+ GC_background,
+ GC_BITMASK);
+ PrintField(buf, 12, 4, CARD32, "lut");
+ PrintField(buf, 16, 2, INT16, "dst-x");
+ PrintField(buf, 18, 2, INT16, "dst-y");
+ PrintField(buf, 20, 2, CARD16, "width");
+ PrintField(buf, 22, 2, CARD16, "height");
+ PrintField(buf, 24, 1, CARD8, "depth");
+ PrintField(buf, 25, 1, CARD8, "encoding");
+ PrintField(buf, 26, 1, CARD8, "left-pad");
+ WcpAnalyzeImage (&buf[28], (long) n, buf[24], buf[25],
+ IShort(&buf[20]) + buf[26],
+ IShort(&buf[22]));
+ PrintBytes(&buf[28], (long)n, "data");
+}
+
+WcpGetImage (fd, buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+ PrintField(buf, 4, 4, DRAWABLE, "drawable");
+ PrintField(buf, 8, 4, CARD32, "lut");
+ 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, 1, CARD8, "encoding");
+}
+
+WcpGetImageReply (fd, buf)
+register unsigned char *buf;
+{
+ long n;
+
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* WcpRequest reply */ ;
+ PrintField(RBf, 1, 1, WCPREPLY, WCPREPLYHEADER) /* WcpGetImage reply */;
+ if (Verbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4(n), "reply length");
+ PrintField(buf, 8, 4, CARD32, "visual");
+ n = ILong (&buf[4]) * 4;
+ PrintBytes (&buf[32], n, "data");
+}
+
+WcpCreateColorCursor (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+WcpCreateLut (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+WcpFreeLut (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
+
+WcpCopyArea (fd, buf)
+register unsigned char *buf;
+{
+ PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ;
+ PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ;
+ if (Verbose < 1)
+ return;
+ if (Verbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+
+ printfield(buf, 2, 2, CONST2(2), "request length");
+}
diff --git a/printnas.c b/printnas.c
new file mode 100644
index 0000000..4ee29cc
--- /dev/null
+++ b/printnas.c
@@ -0,0 +1,950 @@
+/* ************************************************** *
+ * *
+ * Request, Reply, Event, Error Printing *
+ * *
+ * James Peterson, 1988 *
+ * (c) Copyright MCC, 1988 *
+ * *
+ * ************************************************** */
+
+#include "scope.h"
+#include "nas.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.
+
+ NasVerbose = 0 == Headers only, time and request/reply/... names.
+
+ NasVerbose = 1 == Very useful content fields.
+
+ NasVerbose = 2 == Almost everything.
+
+ NasVerbose = 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 (NasVerbose > 1) PrintField(a,b,c,d,e)
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+PrintAudioSetUpMessage(buf)
+ unsigned char *buf;
+{
+ short n;
+ short d;
+
+ enterprocedure("PrintSetUpMessage");
+ if (NasVerbose < 1)
+ return;
+ SetIndentLevel(PRINTCLIENT);
+ PrintField(buf, 0, 1, BYTEMODE, "byte-order");
+ 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");
+}
+
+PrintAudioSetUpReply(buf)
+ unsigned char *buf;
+{
+ enterprocedure("PrintSetUpReply");
+ SetIndentLevel(PRINTSERVER);
+ if (IByte(&buf[0]))
+ PrintSuccessfulAudioSetUpReply(buf);
+ else
+ PrintFailedAudioSetUpReply(buf);
+}
+
+PrintFailedAudioSetUpReply(buf)
+ unsigned char *buf;
+{
+ short n;
+
+ PrintField(buf, 0, 1, 0, "SetUp Failed");
+ if (NasVerbose < 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");
+}
+
+PrintSuccessfulAudioSetUpReply(buf)
+ unsigned char *buf;
+{
+ short v;
+ short n;
+ short m;
+
+ if (NasVerbose < 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, 2, CARD16, "min-sample-rate");
+ PrintField(buf, 22, 2, CARD16, "max-sample-rate");
+ 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, "max-tracks");
+ m = IByte(&buf[28]);
+ printfield(buf, 29, 1, DVALUE1(n), "number of audio formats");
+ n = IByte(&buf[29]);
+ PrintField(buf, 30, 1, CARD8, "number of element-types");
+ PrintField(buf, 31, 1, CARD8, "number of wave-forms");
+ PrintField(buf, 32, 1, CARD8, "number of actions");
+ PrintField(buf, 33, 1, CARD8, "number of devices");
+ PrintField(buf, 34, 1, CARD8, "number of buckets");
+ PrintField(buf, 35, 1, CARD8, "number of radios");
+ PrintString8(&buf[36], (long)v, "vendor");
+}
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+extern char *REQUESTHEADER;
+extern char *EVENTHEADER;
+extern char *ERRORHEADER;
+extern char *REPLYHEADER;
+
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Error Printing procedures */
+
+AudioRequestError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioValueError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, INT32, "bad value");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioMatchError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioAccessError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioAllocError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioIDChoiceError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, CARD32, "bad resource id");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioLengthError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+AudioImplementationError(buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 8, 2, CARD16, "minor opcode");
+ PrintField(buf, 10, 1, CARD8, "major opcode");
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Event Printing procedures */
+
+AudioElementNotify (buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, NASEVENT, EVENTHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 1, 1, CARD8, "detail");
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, CARD32, "flow");
+ printfield(buf, 12, 2, CARD16, "element num");
+ printfield(buf, 14, 2, CARD16, "kind");
+ printfield(buf, 16, 2, CARD16, "prev state");
+ printfield(buf, 18, 2, CARD16, "cur state");
+ printfield(buf, 20, 2, CARD16, "reason");
+ printfield(buf, 24, 4, CARD32, "num bytes");
+}
+
+AudioGrabNotify (buf)
+ unsigned char *buf;
+{
+}
+
+AudioMonitorNotify (buf)
+ unsigned char *buf;
+{
+ PrintField(buf, 0, 1, NASEVENT, EVENTHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 1, 1, CARD8, "detail");
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ PrintField(buf, 4, 4, TIMESTAMP, "time");
+ PrintField(buf, 8, 4, CARD32, "flow");
+ printfield(buf, 12, 2, CARD16, "element num");
+ printfield(buf, 14, 1, CARD8, "format");
+ printfield(buf, 15, 1, CARD8, "num tracks");
+ printfield(buf, 16, 2, CARD16, "count");
+ printfield(buf, 18, 2, CARD16, "num fields");
+ PrintField(buf, 20, 4, CARD32, "data");
+ PrintField(buf, 24, 4, CARD32, "date1");
+ PrintField(buf, 28, 4, CARD32, "data2");
+}
+
+AudioBucketNotify (buf)
+ unsigned char *buf;
+{
+}
+
+AudioDeviceNotify (buf)
+ unsigned char *buf;
+{
+}
+
+/* ************************************************************ */
+/* */
+/* */
+/* ************************************************************ */
+
+/* Request and Reply Printing procedures */
+
+UnknownAudioReply(buf)
+ unsigned char *buf;
+{
+ long n;
+
+ PrintField(RBf, 0, 1, NASREPLY, REPLYHEADER);
+ PrintField(buf, 1, 1, CARD8, "data");
+ printfield (buf, 2, 2, CARD16, "sequence number");
+ printfield (buf, 4, 4, DVALUE4(n), "reply length");
+ n = ILong (&buf[4]) + 6;
+ (void) PrintList (&buf[8], n, CARD32, "data");
+}
+
+AudioListDevices (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER) /* ListDevices */;
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListDevicesReply(buf)
+ unsigned char *buf;
+{
+ long n;
+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetWindowAttributes */ ;
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, CARD32, "reply length");
+ printfield(buf, 8, 4, CARD32, "num devices");
+ n = ILong(&buf[8]);
+}
+
+static
+AuString (buf)
+ unsigned char *buf;
+{
+ long n;
+
+ printfield(buf, 0, 1, CARD8, "type");
+ printfield(buf, 4, 4, CARD32, "length");
+ n = ILong(&buf[8]);
+ PrintString8(&buf[8], n, "string");
+ return 8 + pad(n);
+}
+
+static
+AuDeviceAttributes (buf)
+ unsigned char *buf;
+{
+ int l;
+ printfield(buf, 0, 4, CARD32, "value mask");
+ printfield(buf, 4, 4, CARD32, "changable mask");
+ printfield(buf, 8, 4, CARD32, "id");
+ printfield(buf, 12, 1, CARD8, "kind");
+ printfield(buf, 13, 1, CARD8, "use");
+ printfield(buf, 14, 1, CARD8, "format");
+ printfield(buf, 15, 1, CARD8, "num tracks");
+ printfield(buf, 16, 4, CARD32, "access");
+ l = 20 + AuString(&buf[20]);
+}
+
+AudioGetDeviceAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetDeviceAttributesReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ AuDeviceAttributes (&buf[32]);
+}
+
+AudioSetDeviceAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+ printfield(buf, 4, 4, CARD32, "device");
+ AuDeviceAttributes (&buf[8]);
+}
+
+AudioCreateBucket (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioDestroyBucket (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListBuckets (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListBucketsReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioGetBucketAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetBucketAttributesReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetBucketAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioCreateRadio (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioDestroyRadio (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListRadios (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListRadiosReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioGetRadioAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetRadioAttributesReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetRadioAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioCreateFlow (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioDestroyFlow (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetFlowAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetFlowAttributesReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetFlowAttributes (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetElements (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetElementsReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetElements (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetElementStates (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioElementState (buf)
+ unsigned char *buf;
+{
+ printfield(buf, 0, 4, CARD32, "flow");
+ printfield(buf, 4, 1, CARD8, "element number");
+ printfield(buf, 5, 1, CARD8, "state");
+}
+
+AudioGetElementStatesReply (buf)
+ unsigned char *buf;
+{
+ int n, i;
+ int o;
+
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+ n = ILong(&buf[8]);
+ o = 32;
+ for (i = 0; i < n; i++)
+ {
+ AudioElementState (buf+o);
+ o += 8;
+ }
+}
+
+AudioSetElementStates (buf)
+ unsigned char *buf;
+{
+ int nstates, i;
+ int o;
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+ printfield(buf, 4, 4, CARD32, "number states");
+ nstates = ILong(&buf[4]);
+ o = 8;
+ for (i = 0; i < nstates; i++)
+ {
+ AudioElementState (buf+o);
+ o += 8;
+ }
+}
+
+AudioGetElementParameters (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetElementParametersReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetElementParameters (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioWriteElement (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+ printfield(buf, 4, 4, CARD32, "flow");
+ printfield(buf, 8, 4, CARD32, "num bytes");
+ printfield(buf, 12, 1, CARD8, "state");
+}
+
+AudioReadElement (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioReadElementReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioGrabComponent (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioUngrabComponent (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioSendEvent (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetAllowedUsers (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetAllowedUsersReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetAllowedUsers (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListExtensions (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioListExtensionsReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioQueryExtension (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioQueryExtensionReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioGetCloseDownMode (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetCloseDownModeReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioSetCloseDownMode (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioKillClient (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetServerTime (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
+
+AudioGetServerTimeReply (buf)
+ unsigned char *buf;
+{
+ PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER);
+ if (NasVerbose < 1)
+ return;
+ printfield(buf, 2, 2, CARD16, "sequence number");
+ printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length");
+}
+
+AudioNoOperation (buf)
+ unsigned char *buf;
+{
+ PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER);
+ if (NasVerbose < 1)
+ return;
+ if (NasVerbose > 1)
+ PrintField(SBf, 0, 4, CARD32, "sequence number");
+ printfield(buf, 2, 2, DVALUE2(8 + n), "request length");
+}
diff --git a/prtype.c b/prtype.c
index 685943a..7b6064e 100644
--- a/prtype.c
+++ b/prtype.c
@@ -28,6 +28,8 @@
#include "scope.h"
#include "x11.h"
+extern int littleEndian;
+
/*
For each of the types we need a way to print that type.
Types are of varieties:
@@ -103,7 +105,7 @@ char *printrep (c)
*/
#define MaxIndent 10
-static char Leader[MaxIndent + 1];
+char Leader[MaxIndent + 1];
static short CurrentLevel = 0;
SetIndentLevel(which)
@@ -170,9 +172,9 @@ PrintINT8(buf)
/* print a INT8 -- 8-bit signed integer */
short n = IByte (buf);
if (n > 127)
- n = n - 256;
+ n = 256 - n;
fprintf(stdout, "%d", n);
- return(1);
+ return 1;
}
PrintINT16(buf)
@@ -181,9 +183,9 @@ PrintINT16(buf)
/* print a INT16 -- 16-bit signed integer */
long n = IShort (buf);
if (n > 32767)
- n = n - 65536;
+ n = 65536 - n;
fprintf(stdout, "%d", n);
- return(2);
+ return 2;
}
PrintINT32(buf)
@@ -192,7 +194,7 @@ PrintINT32(buf)
/* print a INT32 -- 32-bit signed integer */
long n = ILong (buf);
fprintf(stdout, "%d", n);
- return(4);
+ return 4;
}
/* ************************************************************ */
@@ -203,7 +205,7 @@ PrintCARD8(buf)
/* print a CARD8 -- 8-bit unsigned integer */
short n = IByte (buf);
fprintf(stdout, "%02x", (unsigned)(n & 0xff));
- return(1);
+ return 1;
}
PrintCARD16(buf)
@@ -212,7 +214,7 @@ PrintCARD16(buf)
/* print a CARD16 -- 16-bit unsigned integer */
unsigned long n = IShort (buf);
fprintf(stdout, "%04x", (unsigned)(n & 0xffff));
- return(2);
+ return 1;
}
PrintCARD32(buf)
@@ -252,7 +254,7 @@ PrintSTRING16(buf)
/* print a CHAR2B -- 16-bit character which is never byte-swapped */
unsigned short n = IChar2B (buf);
fprintf(stdout, "%s", printrep(n));
- return(1);
+ return 2 + n;
}
PrintSTR(buf)
@@ -293,7 +295,7 @@ PrintWINDOWD(buf)
fprintf(stdout, "InputFocus");
else
(void)PrintWINDOW(buf);
- return(4);
+ return 4;
}
PrintWINDOWNR(buf)
@@ -307,7 +309,7 @@ PrintWINDOWNR(buf)
fprintf(stdout, "PointerRoot");
else
(void)PrintWINDOW(buf);
- return(4);
+ return 4;
}
@@ -320,7 +322,7 @@ PrintPIXMAP(buf)
fprintf(stdout, "None");
else
fprintf(stdout, "PXM %08x", n);
- return(4);
+ return 4;
}
PrintPIXMAPNPR(buf)
@@ -334,7 +336,7 @@ PrintPIXMAPNPR(buf)
fprintf(stdout, "ParentRelative");
else
PrintPIXMAP(buf);
- return(4);
+ return 4;
}
PrintPIXMAPC(buf)
@@ -346,7 +348,7 @@ PrintPIXMAPC(buf)
fprintf(stdout, "CopyFromParent");
else
PrintPIXMAP(buf);
- return(4);
+ return 4;
}
@@ -359,7 +361,7 @@ PrintCURSOR(buf)
fprintf(stdout, "None");
else
fprintf(stdout, "CUR %08x", n);
- return(4);
+ return 4;
}
@@ -372,7 +374,7 @@ PrintFONT(buf)
fprintf(stdout, "None");
else
fprintf(stdout, "FNT %08x", n);
- return(4);
+ return 4;
}
@@ -382,7 +384,7 @@ PrintGCONTEXT(buf)
/* print a GCONTEXT -- CARD32 */
long n = ILong (buf);
fprintf(stdout, "GXC %08x", n);
- return(4);
+ return 4;
}
@@ -407,7 +409,7 @@ PrintCOLORMAPC(buf)
fprintf(stdout, "CopyFromParent");
else
(void)PrintCOLORMAP(buf);
- return(4);
+ return 4;
}
@@ -417,7 +419,7 @@ PrintDRAWABLE(buf)
/* print a DRAWABLE -- CARD32 */
long n = ILong (buf);
fprintf(stdout, "DWB %08x", n);
- return(4);
+ return 4;
}
PrintFONTABLE(buf)
@@ -426,7 +428,7 @@ PrintFONTABLE(buf)
/* print a FONTABLE -- CARD32 */
long n = ILong (buf);
fprintf(stdout, "FTB %08x", n);
- return(4);
+ return 4;
}
/* ************************************************************ */
@@ -476,7 +478,7 @@ PrintATOMT(buf)
fprintf(stdout, "AnyPropertyType");
else
(void)PrintATOM(buf);
- return(4);
+ return 4;
}
@@ -489,7 +491,7 @@ PrintVISUALID(buf)
fprintf(stdout, "None");
else
fprintf(stdout, "VIS %08x", n);
- return(4);
+ return 4;
}
PrintVISUALIDC(buf)
@@ -501,7 +503,7 @@ PrintVISUALIDC(buf)
fprintf(stdout, "CopyFromParent");
else
PrintVISUALID(buf);
- return(4);
+ return 4;
}
@@ -514,7 +516,7 @@ PrintTIMESTAMP(buf)
fprintf(stdout, "CurrentTime");
else
fprintf(stdout, "TIM %08x", n);
- return(4);
+ return 4;
}
@@ -527,7 +529,7 @@ PrintRESOURCEID(buf)
fprintf(stdout, "AllTemporary");
else
fprintf(stdout, "RID %08x", n);
- return(4);
+ return 4;
}
@@ -558,7 +560,7 @@ PrintKEYCODEA(buf)
fprintf(stdout, "AnyKey");
else
(void)PrintKEYCODE(buf);
- return(1);
+ return 1;
}
@@ -568,7 +570,7 @@ PrintBUTTON(buf)
/* print a BUTTON -- CARD8 */
unsigned short n = IByte (buf);
fprintf(stdout, "%d (%s)", n, printrep(n));
- return(1);
+ return 1;
}
PrintBUTTONA(buf)
@@ -580,7 +582,7 @@ PrintBUTTONA(buf)
fprintf(stdout, "AnyButton");
else
PrintBUTTON(buf);
- return(1);
+ return 1;
}
@@ -591,6 +593,7 @@ PrintEVENTFORM(buf)
{
/* print an EVENT_FORM -- event format */
DecodeEvent(-1, buf, (long)-1);
+ return 32;
}
/* ************************************************************ */
@@ -618,7 +621,6 @@ PrintENUMERATED(buf, length, ValueList)
fprintf(stdout, "%s", p->Name);
else
fprintf(stdout, "**INVALID** (%d)", n);
- return(length);
}
/* ************************************************************ */
@@ -668,7 +670,6 @@ PrintSET(buf, length, ValueList)
fprintf(stdout, "<ALL>");
else if (!FoundOne)
fprintf(stdout, "0");
- return(length);
}
@@ -684,6 +685,9 @@ PrintField(buf, start, length, FieldType, name)
short FieldType;
char *name;
{
+ if (Verbose == 0)
+ return;
+
if (length == 0)
return;
@@ -881,21 +885,69 @@ PrintString16(buf, number, name)
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)
+ for (i = 0; i < number; i += 2)
{
- c = IChar2B(&buf[j]);
+ c = IChar2B(&buf[i]);
fprintf(stdout, "%s", printrep(c));
}
fprintf(stdout, "\"\n");
}
+extern long TranslateText;
+
+PrintTString8(buf, number, name)
+ unsigned char buf[];
+ long number;
+ char *name;
+{
+ long i;
+ int off;
+
+ if (number == 0)
+ return;
+
+ off = 0;
+ if (TranslateText)
+ off = 0x20;
+ fprintf(stdout, "%s%20s: \"", Leader, name);
+ for (i = 0; i < number; i++)
+ fprintf(stdout, "%s", printrep(buf[i] + off));
+ fprintf(stdout, "\"\n");
+}
+
+
+/* print a String of CHAR2B -- 16-bit characters */
+
+PrintTString16(buf, number, name)
+ unsigned char buf[];
+ long number;
+ char *name;
+{
+ long i;
+ unsigned short c;
+ int off;
+
+ if (number == 0)
+ return;
+
+ off = 0;
+ if (TranslateText)
+ off = 0x20;
+ fprintf(stdout, "%s%20s: \"", Leader, name);
+ for (i = 0; i < number; i += 2)
+ {
+ c = IChar2B(&buf[i]);
+ fprintf(stdout, "%s", printrep(c + off));
+ }
+ fprintf(stdout, "\"\n");
+}
+
/* ************************************************************ */
/* */
/* */
@@ -939,7 +991,11 @@ PrintValues(control, clength, ctype, values, name)
{
if ((p->Value & cmask) != 0)
{
- short m = 4 - p->Length;
+ short m;
+ if (littleEndian)
+ m=0;
+ else
+ m = 4 - p->Length;
PrintField(values, m, p->Length, p->Type, p->Name);
values += 4;
}
@@ -970,15 +1026,15 @@ PrintTextList8(buf, length, name)
if (n != 255)
{
PrintField(buf, 1, 1, INT8, "delta");
- PrintString8(&buf[2], (long)n, "text item 8 string");
+ PrintTString8(&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;
+ buf += 4;
+ length -= 4;
}
}
}
@@ -997,15 +1053,15 @@ PrintTextList16(buf, length, name)
if (n != 255)
{
PrintField(buf, 1, 1, INT8, "delta");
- PrintString16(&buf[2], (long)n, "text item 16 string");
+ PrintTString16(&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;
+ buf += 4;
+ length -= 4;
}
}
}
@@ -1022,7 +1078,7 @@ DumpHexBuffer(buf, n)
unsigned char *buf;
long n;
{
- short i;
+ long i;
short column;
char h[6] /* one hex or octal character */ ;
@@ -1043,3 +1099,40 @@ DumpHexBuffer(buf, n)
column += 3;
}
}
+
+PrintValueRec (key, cmask, ctype)
+ unsigned long key;
+ unsigned long cmask;
+ short ctype;
+{
+ unsigned char *values;
+ struct ValueListEntry *p;
+ ValuePtr value;
+
+ value = GetValueRec (key);
+ if (!value)
+ return;
+ values = (unsigned char *) value->values;
+
+ /* 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 */
+ ModifyIndentLevel(1);
+ for (p = TD[ctype].ValueList; p != NULL; p = p->Next)
+ {
+ if ((p->Value & cmask) != 0)
+ {
+ short m;
+ if (littleEndian)
+ m=0;
+ else
+ m = 4 - p->Length;
+ PrintField(values, m, p->Length, p->Type, p->Name);
+ }
+ values += 4;
+ }
+ ModifyIndentLevel(-1);
+}
diff --git a/randrscope.h b/randrscope.h
new file mode 100644
index 0000000..58b5e0c
--- /dev/null
+++ b/randrscope.h
@@ -0,0 +1,21 @@
+#ifndef _RANDRSCOPE_H_
+#define _RANDRSCOPE_H_
+
+#define RANDRREQUEST 141
+#define RANDRREPLY 142
+#define RANDRERROR 143
+
+
+#define RANDRREQUESTHEADER "RANDRREQUEST"
+#define RANDRREPLYHEADER "RANDRREPLY"
+
+/*
+ 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)
+
+#endif
+
diff --git a/renderscope.h b/renderscope.h
new file mode 100644
index 0000000..8a7fb3b
--- /dev/null
+++ b/renderscope.h
@@ -0,0 +1,27 @@
+#ifndef _RENDERSCOPE_H_
+#define _RENDERSCOPE_H_
+
+#define RENDERREQUEST 132
+#define RENDERREPLY 133
+#define RENDERERROR 134
+
+#define PICTURE 135
+#define PICTFORMAT 136
+#define PICTURE_BITMASK 137
+#define PICTOP 138
+#define GLYPHSET 139
+#define RENDERCOLOR 140
+
+#define RENDERREQUESTHEADER "RENDERREQUEST"
+#define RENDERREPLYHEADER "RENDERREPLY"
+
+/*
+ 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)
+
+#endif
+
diff --git a/scope.c b/scope.c
index 9511f5a..52eadee 100644
--- a/scope.c
+++ b/scope.c
@@ -27,15 +27,20 @@
#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, ... */
+#ifdef SVR4
+#include <sys/filio.h>
+#endif
+#include <fcntl.h>
#include <netinet/in.h> /* struct sockaddr_in */
+#include <netinet/tcp.h>
#include <netdb.h> /* struct servent * and struct hostent * */
#include <errno.h> /* for EINTR, EADDRINUSE, ... */
extern int errno;
+extern InitializePEX();
/* ********************************************** */
/* */
/* ********************************************** */
@@ -43,11 +48,558 @@ extern int errno;
#define DefaultPort 6000
char ServerHostName[255];
+char AudioServerHostName[255];
long ServerBasePort = DefaultPort;
long ServerInPort = 1;
long ServerOutPort = 0;
long ServerDisplay = 0;
+long TranslateText = 0;
+char ScopeEnabled = 1;
+char HandleSIGUSR1 = 0;
+char DoAudio = 0;
+char TerminateClose = 0;
+int Interrupt = 0;
+
+struct FDDescriptor *FDD = 0;
+short MaxFD = 0;
+short nFDsInUse = 0;
+long ReadDescriptors = 0;
+long WriteDescriptors = 0;
+long BlockedReadDescriptors;
+short HighestFD;
+
+short debuglevel = 0;
+short Verbose = 0;
+short XVerbose = 0;
+short NasVerbose = 0;
+int ScopePort = 0;
+char *ScopeHost = 0;
+
+
+typedef struct _BreakPoint {
+ struct _BreakPoint *next;
+ int number;
+ unsigned char request;
+ Boolean enabled;
+} BP;
+
+typedef enum _CMDResult { CMDProceed, CMDDebug, CMDSyntax, CMDError } CMDResult;
+
+CMDResult CMDStep ();
+CMDResult CMDCont ();
+CMDResult CMDBreak ();
+CMDResult CMDDelete ();
+CMDResult CMDDisable ();
+CMDResult CMDEnable ();
+CMDResult CMDLevel ();
+CMDResult CMDAudio ();
+CMDResult CMDQuit ();
+CMDResult CMDHelp ();
+
+typedef struct _CMDFunc {
+ char *name;
+ char *alias;
+ CMDResult (*func)();
+ char *usage;
+ char *help;
+} CMDFuncRec, *CMDFuncPtr;
+
+CMDFuncRec CMDFuncs[] = {
+ "audio", "a", CMDAudio, "[a]udio",
+ "Set audio output level\n",
+ "break", "b", CMDBreak, "[b]reak",
+ "Create breakpoints\n",
+ "cont", "c", CMDCont, "[c]ont",
+ "Continue scoping\n",
+ "delete", "del", CMDDelete, "[del]ete",
+ "Delete breakpoints\n",
+ "disable","d", CMDDisable, "[d]isable",
+ "Disable breakpoints\n",
+ "enable", "e", CMDEnable, "[e]nable",
+ "Enable breakpoints\n",
+ "help", "?", CMDHelp, "help",
+ "Print this list\n",
+ "level", "l", CMDLevel, "[l]evel",
+ "Set output level\n",
+ "quit", "q", CMDQuit, "[q]uit",
+ "Quit Xscope\n",
+ "step", "s", CMDStep, "[s]tep",
+ "Step trace one request\n",
+};
+
+#define NumCMDFuncs (sizeof CMDFuncs / sizeof CMDFuncs[0])
+
+#ifndef FALSE
+#define FALSE 0
+#define TRUE 1
+#endif
+
+static int
+CMDStringToInt(s, v)
+ char *s;
+ int *v;
+{
+ int sign = 1;
+
+ switch (*s) {
+ case '-':
+ sign = -1;
+ s++;
+ break;
+ case '+':
+ s++;
+ break;
+ }
+
+ if (!strncmp (s, "0x", 2))
+ {
+ sscanf (s + 2, "%x", v);
+ }
+ else if (*s == '0')
+ {
+ sscanf (s, "%o", v);
+ }
+ else if (isdigit (*s))
+ {
+ sscanf (s, "%d", v);
+ }
+ else if (*s == '\'')
+ {
+ s++;
+ if (*s == '\\') {
+ s++;
+ switch (*s) {
+ case 'n':
+ *v = '\n';
+ break;
+ case 't':
+ *v = '\t';
+ break;
+ default:
+ *v = (int) *s;
+ break;
+ }
+ } else
+ *v = (int) *s;
+ s++;
+ if (*s != '\'')
+ return FALSE;
+ }
+ else
+ return FALSE;
+ *v *= sign;
+ return TRUE;
+}
+
+static CMDFuncPtr
+CMDStringToFunc (name)
+ char *name;
+{
+ int i;
+ for (i = 0; i < NumCMDFuncs; i++)
+ {
+ if (!strcmp (name, CMDFuncs[i].name) ||
+ !strcmp (name, CMDFuncs[i].alias))
+ {
+ return &CMDFuncs[i];
+ }
+ }
+ return 0;
+}
+
+static int
+CMDSplitIntoWords(line, argv)
+ char *line;
+ char **argv;
+{
+ char quotechar;
+ int argc;
+
+ argc = 0;
+ while (*line) {
+ while (isspace(*line))
+ line++;
+ if (!*line)
+ break;
+ if (*line == '"')
+ {
+ quotechar = *line++;
+ *argv++ = line;
+ argc++;
+ while (*line && *line != quotechar)
+ line++;
+ if (*line)
+ *line++ = '\0';
+ }
+ else
+ {
+ *argv++ = line;
+ argc++;
+ while (*line && !isspace(*line))
+ line++;
+ if (*line)
+ *line++ = '\0';
+ }
+ }
+ *argv = 0;
+ return argc;
+}
+
+CMDResult
+CMDHelp(argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+ CMDFuncPtr func;
+
+ if (argc == 1)
+ {
+ for (i = 0; i < NumCMDFuncs; i++)
+ printf("%-10s%s\n", CMDFuncs[i].name, CMDFuncs[i].usage);
+ }
+ else
+ {
+ for (i = 1; i < argc; i++)
+ {
+ func = CMDStringToFunc (argv[i]);
+ if (!func)
+ {
+ printf ("%-10s unknown command\n", argv[i]);
+ return CMDSyntax;
+ }
+ printf ("%-10s %s\n%s", func->name, func->usage, func->help);
+ }
+ }
+ return CMDDebug;
+}
+
+static void
+CMDSyntaxError(argc, argv)
+ int argc;
+ char **argv;
+{
+ printf("Syntax error in:");
+ while (*argv)
+ printf(" %s", *argv++);
+ printf("\n");
+}
+
+void
+ReadCommands ()
+{
+ int argc;
+ char line[1024];
+ char *argv[20];
+ CMDResult result;
+ CMDFuncPtr func;
+ static int here;
+
+ if (here)
+ return;
+ here = 1;
+ for (;;) {
+ printf ("> ");
+ if (!fgets (line, sizeof line, stdin))
+ break;
+ argc = CMDSplitIntoWords(line, argv);
+ if (argc > 0) {
+ func = CMDStringToFunc (argv[0]);
+ if (!func)
+ CMDSyntaxError (argc, argv);
+ else
+ {
+ result = (*func->func)(argc, argv);
+ switch (result) {
+ case CMDSyntax:
+ CMDSyntaxError(argc, argv);
+ break;
+ case CMDError:
+ printf ("Error\n");
+ break;
+ case CMDProceed:
+ here = 0;
+ return;
+ default:
+ break;
+ }
+ }
+ }
+ }
+ printf("...\n");
+ here = 0;
+}
+
+int SingleStep;
+int BreakPoint;
+BP *breakPoints;
+int breakPointNumber;
+
+void
+TestBreakPoints (buf, n)
+ unsigned char *buf;
+ long n;
+{
+ BP *bp;
+
+ for (bp = breakPoints; bp; bp = bp->next)
+ {
+ if (bp->request == buf[0])
+ {
+ break;
+ }
+ }
+ if (bp)
+ {
+ printf ("Breakpoint on request %d\n", bp->request);
+ ReadCommands ();
+ }
+}
+
+void
+setBreakPoint ()
+{
+ Boolean b = false;
+ BP *bp;
+ FD fd;
+
+ if (SingleStep)
+ b = true;
+ else
+ {
+ for (bp = breakPoints; bp; bp = bp->next)
+ {
+ if (bp->enabled)
+ {
+ b = true;
+ break;
+ }
+ }
+ }
+ if (b != BreakPoint)
+ {
+ BreakPoint = b;
+ for (fd = 0; fd < HighestFD; fd++)
+ {
+ extern DataFromClient();
+
+ if (FDD[fd].Busy && FDD[fd].InputHandler == DataFromClient)
+ {
+ if (BreakPoint)
+ SetBufLimit (fd);
+ else
+ ClearBufLimit (fd);
+ }
+ }
+ }
+}
+CMDResult
+CMDBreak (argc, argv)
+ int argc;
+ char **argv;
+{
+ BP *bp, **prev;
+ int request;
+
+ if (argc == 1)
+ {
+ for (bp = breakPoints; bp; bp = bp->next)
+ {
+ printf ("%3d: %3d %s\n", bp->number, bp->request,
+ bp->enabled ? "enabled" : "disabled");
+ }
+ }
+ else
+ {
+ for (prev = &breakPoints; *prev; prev = &(*prev)->next);
+ while (*++argv) {
+ request = GetXRequestFromName (*argv);
+ if (request < 0 && !CMDStringToInt (*argv, &request))
+ return CMDSyntax;
+ bp = (BP *) malloc (sizeof (BP));
+ bp->request = request;
+ bp->number = ++breakPointNumber;
+ bp->enabled = true;
+ bp->next = 0;
+ *prev = bp;
+ prev = &bp->next;
+ }
+ }
+ setBreakPoint ();
+ return CMDDebug;
+}
+
+CMDResult
+CMDCont (argc, argv)
+ int argc;
+ char **argv;
+{
+ SingleStep = 0;
+ return CMDProceed;
+}
+
+CMDResult
+CMDDisable (argc, argv)
+ int argc;
+ char **argv;
+{
+ BP *bp;
+ int number;
+
+ if (argc == 1)
+ {
+ printf ("Disabling all breakpoints...\n");
+ for (bp = breakPoints; bp; bp = bp->next)
+ bp->enabled = false;
+ }
+ else
+ {
+ while (*++argv) {
+ if (!CMDStringToInt (*argv, &number))
+ return CMDSyntax;
+ for (bp = breakPoints; bp; bp = bp->next)
+ if (bp->number == number)
+ {
+ bp->enabled = false;
+ break;
+ }
+ if (!bp)
+ {
+ printf ("No such breakpoint %s\n", *argv);
+ }
+ }
+ }
+ setBreakPoint ();
+ return CMDDebug;
+}
+
+CMDResult
+CMDDelete (argc, argv)
+ int argc;
+ char **argv;
+{
+ BP *bp, **prev;
+ int number;
+
+ if (argc == 1)
+ {
+ printf ("Deleting all breakpoints...\n");
+ while (bp = breakPoints)
+ {
+ breakPoints = bp->next;
+ free (bp);
+ }
+ }
+ else
+ {
+ while (*++argv) {
+ if (!CMDStringToInt (*argv, &number))
+ return CMDSyntax;
+ for (prev = &breakPoints; bp = *prev; prev = &bp->next)
+ {
+ if (bp->number == number)
+ {
+ *prev = bp->next;
+ free (bp);
+ break;
+ }
+ }
+ if (!bp)
+ {
+ printf ("No such breakpoint %s\n", *argv);
+ }
+ }
+ }
+ setBreakPoint ();
+ return CMDDebug;
+}
+
+CMDResult
+CMDEnable (argc, argv)
+ int argc;
+ char **argv;
+{
+ BP *bp;
+ int number;
+
+ if (argc == 1)
+ {
+ printf ("Enablingg all breakpoints...\n");
+ for (bp = breakPoints; bp; bp = bp->next)
+ bp->enabled = true;
+ }
+ else
+ {
+ while (*++argv) {
+ if (!CMDStringToInt (*argv, &number))
+ return CMDSyntax;
+ for (bp = breakPoints; bp; bp = bp->next)
+ if (bp->number == number)
+ {
+ bp->enabled = true;
+ break;
+ }
+ if (!bp)
+ {
+ printf ("No such breakpoint %s\n", *argv);
+ }
+ }
+ }
+ setBreakPoint ();
+ return CMDDebug;
+}
+
+CMDResult
+CMDStep (argc, argv)
+ int argc;
+ char **argv;
+{
+ SingleStep = 1;
+ setBreakPoint ();
+ return CMDProceed;
+}
+
+CMDResult
+CMDQuit (argc, argv)
+ int argc;
+ char **argv;
+{
+ printf ("exiting...\n");
+ exit (0);
+}
+
+CMDResult
+CMDLevel (argc, argv)
+ int argc;
+ char **argv;
+{
+ int level;
+
+ if (argc == 1)
+ printf ("Level: %d\n", XVerbose);
+ else if (argc == 2 && CMDStringToInt (argv[1], &level))
+ XVerbose = level;
+ else
+ return CMDSyntax;
+ return CMDDebug;
+}
+
+CMDResult
+CMDAudio (argc, argv)
+ int argc;
+ char **argv;
+{
+ int level;
+
+ if (argc == 1)
+ printf ("Audio Level: %d\n", NasVerbose);
+ else if (argc == 2 && CMDStringToInt (argv[1], &level))
+ NasVerbose = level;
+ else
+ return CMDSyntax;
+ return CMDDebug;
+}
/* ********************************************** */
/* */
@@ -88,8 +640,11 @@ Usage()
fprintf(stderr, " [-o<out-port>]\n");
fprintf(stderr, " [-d<display-number>]\n");
fprintf(stderr, " [-v<n>] -- verbose output\n");
+ fprintf(stderr, " [-a<n>] -- audio verbose output\n");
fprintf(stderr, " [-q] -- quiet output\n");
fprintf(stderr, " [-D<debug-level>]\n");
+ fprintf(stderr, " [-S<n>] -- start/stop on SIGUSR1\n");
+ fprintf(stderr, " [-t] -- terminate when all clients close\n");
exit(1);
}
@@ -100,9 +655,8 @@ 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 */;
+ XVerbose = 1 /* default verbose-ness level */;
+ NasVerbose = 1;
/* Scan argument list */
while (--argc > 0)
@@ -124,27 +678,26 @@ ScanArgs(argc, argv)
debuglevel = atoi(++*argv);
if (debuglevel == 0)
debuglevel = 255;
- debuglevel |= 1;
- Verbose = 7;
+ XVerbose = 7;
debug(1,(stderr, "debuglevel = %d\n", debuglevel));
break;
- case 'q': /* quiet mode */
- Verbose = 0;
- debug(1,(stderr, "Verbose = %d\n", Verbose));
+ case 'S':
+ HandleSIGUSR1 = 1;
+ ScopeEnabled = atoi(++*argv);
break;
- case 'v': /* verbose mode */
- Verbose = atoi(++*argv);
- debug(1,(stderr, "Verbose = %d\n", Verbose));
+ case 'q': /* quiet mode */
+ XVerbose = 0;
+ debug(1,(stderr, "Verbose = %d\n", XVerbose));
break;
- case 's': /* synchronous mode */
- RequestSync = true;
- debug(1,(stderr, "RequestSync true\n"));
+ case 'v': /* verbose mode */
+ XVerbose = atoi(++*argv);
+ debug(1,(stderr, "Verbose = %d\n", XVerbose));
break;
- case 'o': /* output port */
+ case 'o':
ServerOutPort = atoi(++*argv);
if (ServerOutPort <= 0)
ServerOutPort = 0;
@@ -171,9 +724,26 @@ ScanArgs(argc, argv)
debug(1,(stderr, "ServerHostName=%s\n", ServerHostName));
break;
- case 'x':
- NoExtensions = true;
- debug(1,(stderr, "NoExtensions\n"));
+ case 'T':
+ TranslateText = 1;
+ break;
+
+ case 'A':
+ DoAudio = 1;
+ break;
+
+ case 'a': /* verbose mode */
+ NasVerbose = atoi(++*argv);
+ debug(1,(stderr, "NasVerbose = %d\n", NasVerbose));
+ break;
+
+ case 'n': /* NAS server host */
+ if (++*argv != NULL && **argv != '\0')
+ (void)strcpy(AudioServerHostName, OfficialName(*argv));
+ debug(1,(stderr, "AudioServerHostName=%s\n", AudioServerHostName));
+ break;
+ case 't':
+ TerminateClose = 1;
break;
default:
@@ -205,6 +775,9 @@ ScanArgs(argc, argv)
/* */
/* ********************************************** */
+int NewConnection ();
+int NewAudio ();
+
main(argc, argv)
int argc;
char **argv;
@@ -212,12 +785,18 @@ main(argc, argv)
ScanArgs(argc, argv);
InitializeFD();
InitializeX11();
+ if (DoAudio)
+ InitializeAudio();
+#ifdef PEX
+ InitializePEX();
+#endif
SetUpStdin();
- SetUpConnectionSocket(GetScopePort());
+ SetUpConnectionSocket(GetScopePort(), NewConnection);
+ if (DoAudio)
+ SetUpConnectionSocket (GetScopePort() + 2000, NewAudio);
SetSignalHandling();
MainLoop();
- exit(0);
}
TimerExpired()
@@ -255,7 +834,7 @@ ReadStdin(fd)
SetUpStdin()
{
enterprocedure("SetUpStdin");
- /* UsingFD(fileno(stdin), ReadStdin); */
+ UsingFD(fileno(stdin), ReadStdin, (int (*)()) NULL);
}
/* ************************************************************ */
@@ -272,14 +851,7 @@ SetUpStdin()
we get input from one, we can write it to the other.
*/
-struct fdinfo
-{
- Boolean Server;
- long ClientNumber;
- FD pair;
-};
-
-static long ClientNumber = 0;
+static long clientNumber = 0;
struct fdinfo FDinfo[StaticMaxFD];
SetUpPair(client, server)
@@ -288,15 +860,21 @@ SetUpPair(client, server)
{
if (client >= 0)
{
- ClientNumber += 1;
+ clientNumber += 1;
FDinfo[client].Server = false;
FDinfo[client].pair = server;
- FDinfo[client].ClientNumber = ClientNumber;
+ FDinfo[client].ClientNumber = clientNumber;
+ FDinfo[client].bufcount = 0;
+ FDinfo[client].buflimit = -1;
+ FDinfo[client].bufdelivered = 0;
if (server >= 0)
{
FDinfo[server].Server = true;
FDinfo[server].pair = client;
FDinfo[server].ClientNumber = FDinfo[client].ClientNumber;
+ FDinfo[server].bufcount = 0;
+ FDinfo[server].buflimit = -1;
+ FDinfo[server].bufdelivered = 0;
}
}
else if (server >= 0)
@@ -307,10 +885,29 @@ SetUpPair(client, server)
}
+ResetPair (client, server)
+ FD client;
+ FD server;
+{
+ if (client >= 0)
+ {
+ FDinfo[client].bufcount = 0;
+ FDinfo[client].buflimit = -1;
+ FDinfo[client].bufdelivered = 0;
+ }
+ if (server >= 0)
+ {
+ FDinfo[server].bufcount = 0;
+ FDinfo[server].buflimit = -1;
+ FDinfo[server].bufdelivered = 0;
+ }
+}
+
CloseConnection(fd)
FD fd;
{
debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd)));
+ ResetPair (ClientHalf(fd), ServerHalf(fd));
StopClientConnection(ServerHalf(fd));
StopServerConnection(ClientHalf(fd));
@@ -318,6 +915,8 @@ CloseConnection(fd)
NotUsingFD(fd);
(void)close(FDPair(fd));
NotUsingFD(FDPair(fd));
+ if (TerminateClose)
+ exit (0);
}
/* ************************************************************ */
@@ -347,19 +946,79 @@ FD ServerHalf(fd)
char *ClientName (fd)
FD fd;
{
- static char name[20];
+ static char name[12];
- (void)sprintf(name, " %s %d",
- (FDinfo[fd].Server ? "Server" : "Client"),
- FDinfo[fd].ClientNumber);
+ (void)sprintf(name, " %d", FDinfo[fd].ClientNumber);
return(name);
}
+int ClientNumber (fd)
+ FD fd;
+{
+ return FDinfo[fd].ClientNumber;
+}
/* ********************************************** */
/* */
/* ********************************************** */
+/*
+ * Write as much of the queued data as the receiver will accept
+ * Block reads from the sender until the receiver gets all of the
+ * data
+ */
+FlushFD (fd)
+ FD fd;
+{
+ long BytesToWrite = FDinfo[fd].bufcount - FDinfo[fd].bufstart;
+ char *p = FDinfo[fd].buffer + FDinfo[fd].bufstart;
+ int PeerFD;
+
+ PeerFD = FDPair (fd);
+ if (FDinfo[fd].buflimit >= 0)
+ {
+ if (FDinfo[fd].bufdelivered + BytesToWrite > FDinfo[fd].buflimit)
+ BytesToWrite = FDinfo[fd].buflimit - FDinfo[fd].bufdelivered;
+ }
+ while (BytesToWrite > 0)
+ {
+ int n1 = write (fd, (char *)p, (int)BytesToWrite);
+ debug(4,(stderr, "write %d bytes\n", n1));
+ if (n1 < 0)
+ {
+ if (errno != EWOULDBLOCK && errno != EAGAIN)
+ {
+ perror("Error on write");
+ if (PeerFD >= 0)
+ CloseConnection(PeerFD);
+ BytesToWrite = 0;
+ }
+ break;
+ }
+ else
+ {
+ FDinfo[fd].bufstart += n1;
+ FDinfo[fd].bufdelivered += n1;
+ BytesToWrite -= n1;
+ p += n1;
+ }
+ }
+ if (FDinfo[fd].bufstart == FDinfo[fd].bufcount)
+ {
+ if (PeerFD >= 0)
+ BlockedReadDescriptors &= ~ (1 << PeerFD);
+ WriteDescriptors &= ~(1 << fd);
+ FDinfo[fd].bufcount = FDinfo[fd].bufstart = 0;
+ }
+ else
+ {
+ if (PeerFD >= 0)
+ BlockedReadDescriptors |= 1 << PeerFD;
+ if (FDinfo[fd].buflimit != FDinfo[fd].bufdelivered)
+ WriteDescriptors |= 1 << fd;
+ }
+}
+
/* 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. */
@@ -367,13 +1026,25 @@ char *ClientName (fd)
DataFromClient(fd)
FD fd;
{
- unsigned char buf[2048];
long n;
FD ServerFD;
+ Verbose = XVerbose;
enterprocedure("DataFromClient");
- n = read(fd, (char *)buf, 2048);
- debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd)));
+ ServerFD = FDPair(fd);
+ if (ServerFD < 0)
+ {
+ ServerFD = ConnectToServer(false);
+ if (ServerFD < 0)
+ {
+ CloseConnection(fd);
+ return;
+ }
+ SetUpPair(fd, ServerFD);
+ }
+
+ n = read(fd, FDinfo[ServerFD].buffer, BUFFER_SIZE);
+ debug(4,(stderr, "read %d bytes from Client%s\n", n, ClientName(fd)));
if (n < 0)
{
PrintTime();
@@ -384,30 +1055,18 @@ DataFromClient(fd)
if (n == 0)
{
PrintTime();
- fprintf(stdout, "%s --> EOF\n", ClientName(fd));
+ if (Verbose >= 0)
+ fprintf(stdout, "Client%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);
+ FDinfo[ServerFD].bufcount = n;
+ FDinfo[ServerFD].bufstart = 0;
+ FlushFD (ServerFD);
/* also report the bytes to standard out */
- ReportFromClient(fd, buf, n);
+ ReportFromClient(fd, FDinfo[ServerFD].buffer, n);
}
/* ********************************************** */
@@ -420,13 +1079,20 @@ DataFromClient(fd)
DataFromServer(fd)
FD fd;
{
- unsigned char buf[2048];
long n;
FD ClientFD;
+ Verbose = XVerbose;
+ ClientFD = FDPair(fd);
+ if (ClientFD < 0)
+ {
+ CloseConnection(fd);
+ return;
+ }
+
enterprocedure("DataFromServer");
- n = read(fd, (char *)buf, 2048);
- debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd)));
+ n = read(fd, (char *)FDinfo[ClientFD].buffer, BUFFER_SIZE);
+ debug(4,(stderr, "read %d bytes from Server%s\n", n, ClientName(fd)));
if (n < 0)
{
PrintTime();
@@ -437,85 +1103,24 @@ DataFromServer(fd)
if (n == 0)
{
PrintTime();
- fprintf(stdout, "EOF <-- %s\n", ClientName(fd));
+ if (Verbose >= 0)
+ fprintf(stdout, "EOF <-- Server%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);
+ FDinfo[ClientFD].bufcount = n;
+ FDinfo[ClientFD].bufstart = 0;
+ FlushFD (ClientFD);
/* also report the bytes to standard out */
- ReportFromServer(fd, buf, n);
+ ReportFromServer(fd, FDinfo[ClientFD].buffer, 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 */
/* */
/* ************************************************************ */
@@ -540,29 +1145,8 @@ 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);
+ ClientFD = AcceptConnection(ConnectionSocket);
+ UsingFD(ClientFD, DataFromClient, FlushFD);
StartClientConnection(ClientFD);
return(ClientFD);
}
@@ -580,91 +1164,10 @@ 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));
+ ServerFD = MakeConnection (ServerHostName, GetServerport (), report);
if (ServerFD >= 0)
{
- UsingFD(ServerFD, DataFromServer);
+ UsingFD(ServerFD, DataFromServer, FlushFD);
StartServerConnection(ServerFD);
}
return(ServerFD);
diff --git a/scope.h b/scope.h
index 62b3189..a64bac5 100644
--- a/scope.h
+++ b/scope.h
@@ -25,43 +25,67 @@
* *
********************************************** */
+#include <X11/Xos.h>
+#include <X11/Xfuncs.h>
#include <stdio.h>
-
#define Boolean short
#define true 1
#define false 0
+#include "fd.h"
+
/* ********************************************** */
/* */
/* ********************************************** */
#define Assert(b) (b)
#define debug(n,f) (void)((debuglevel & n) ? (fprintf f,fflush(stderr)) : 0)
-short debuglevel;
+extern short debuglevel;
/* ********************************************** */
/* */
/* ********************************************** */
-Boolean NoExtensions /* Should we deny extensions exist ? */ ;
-short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ;
-Boolean RequestSync;
+extern short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ;
+extern short XVerbose;
+extern short NasVerbose;
+
+
+extern int ScopePort;
+extern char *ScopeHost;
-int ScopePort;
-char *ScopeHost;
+extern int Interrupt, SingleStep, BreakPoint;
+
+extern void ReadCommands ();
+
+extern char ServerHostName[255];
+extern char AudioServerHostName[255];
/* external function type declarations */
extern char *Malloc ();
-extern char *strcpy();
-char *ClientName ();
+extern char *ClientName ();
/* ********************************************** */
/* */
/* ********************************************** */
/* need to change the MaxFD to allow larger number of fd's */
-#define StaticMaxFD 32
+#define StaticMaxFD 1024
+#define BUFFER_SIZE (1024 * 32)
-#include "fd.h"
+struct fdinfo
+{
+ Boolean Server;
+ long ClientNumber;
+ FD pair;
+ char buffer[BUFFER_SIZE];
+ int bufcount;
+ int bufstart;
+ int buflimit; /* limited writes */
+ int bufdelivered; /* total bytes delivered */
+ Boolean writeblocked;
+};
+
+extern struct fdinfo FDinfo[StaticMaxFD];
diff --git a/server.c b/server.c
index ba8b7cb..a67090d 100644
--- a/server.c
+++ b/server.c
@@ -28,6 +28,13 @@
#include "scope.h"
#include "x11.h"
+struct TypeDef TD[MaxTypes];
+unsigned char RBf[2];
+unsigned char SBf[4];
+struct ConnState CS[StaticMaxFD];
+
+extern char ScopeEnabled;
+
/* ************************************************************ */
/* */
/* */
@@ -38,10 +45,15 @@ ReportFromClient(fd, buf, n)
unsigned char *buf;
long n;
{
- PrintTime();
- fprintf(stdout, "%s --> %4d %s\n",
- ClientName(fd), n, (n == 1 ? "byte" : "bytes"));
- ProcessBuffer(fd, buf, n);
+ if (Verbose > 0)
+ {
+ if (ScopeEnabled) {
+ PrintTime();
+ fprintf(stdout, "Client%s --> %4d %s\n",
+ ClientName(fd), n, (n == 1 ? "byte" : "bytes"));
+ }
+ }
+ ProcessBuffer(fd, buf, n);
}
ReportFromServer(fd, buf, n)
@@ -49,10 +61,14 @@ ReportFromServer(fd, buf, n)
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);
+ if (Verbose > 0) {
+ if (ScopeEnabled) {
+ PrintTime();
+ fprintf(stdout, "\t\t\t\t\t%4d %s <-- X11 Server%s\n",
+ n, (n == 1 ? "byte" : "bytes"), ClientName(fd));
+ }
+ }
+ ProcessBuffer(fd, buf, n);
}
@@ -61,7 +77,6 @@ ReportFromServer(fd, buf, n)
/* */
/* ************************************************************ */
-#include <sys/time.h> /* for struct timeval * */
static long ZeroTime1 = -1;
static long ZeroTime2 = -1;
static struct timeval tp;
@@ -108,45 +123,24 @@ long pad (n)
return((n + 3) & ~0x3);
}
-
-static Boolean byteswap = false;
-void SetByteSwapping(int how)
-{
- byteswap = (how == 0x6c);
-}
+extern int littleEndian;
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);
+ if (littleEndian)
+ return((((((buf[3] << 8) | buf[2]) << 8) | buf[1]) << 8) | buf[0]);
+ return((((((buf[0] << 8) | buf[1]) << 8) | buf[2]) << 8) | buf[3]);
}
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);
+ if (littleEndian)
+ return (buf[1] << 8) | buf[0];
+ return((buf[0] << 8) | buf[1]);
}
unsigned short IChar2B (buf)
@@ -255,6 +249,8 @@ long FinishReply ();
/* */
/* ************************************************************ */
+int littleEndian;
+
ProcessBuffer(fd, buf, n)
FD fd;
unsigned char *buf;
@@ -265,6 +261,11 @@ ProcessBuffer(fd, buf, n)
/* as long as we have enough bytes to do anything -- do it */
+ if (Verbose > 4)
+ {
+ fprintf (stdout, "\nRead from fd %d\n", fd);
+ DumpHexBuffer (buf, n);
+ }
while (CS[fd].NumberofSavedBytes + n >= CS[fd].NumberofBytesNeeded)
{
/*
@@ -314,6 +315,7 @@ ProcessBuffer(fd, buf, n)
the state we are in. The processing routine should return the
number of bytes that it actually used.
*/
+ littleEndian = CS[fd].littleEndian;
NumberofUsedBytes = (*CS[fd].ByteProcessing)
(fd, BytesToProcess, CS[fd].NumberofBytesNeeded);
@@ -324,6 +326,7 @@ ProcessBuffer(fd, buf, n)
if (NumberofUsedBytes > 0)
{
+ CS[fd].NumberofBytesProcessed += NumberofUsedBytes;
if (CS[fd].NumberofSavedBytes > 0)
RemoveSavedBytes(fd, NumberofUsedBytes);
else
@@ -336,9 +339,15 @@ ProcessBuffer(fd, buf, n)
}
} /* end of while (NumberofSavedBytes + n >= NumberofBytesNeeded) */
+ if (Verbose > 3)
+ fprintf (stdout, "Have %d need %d\n",
+ CS[fd].NumberofSavedBytes + n,
+ CS[fd].NumberofBytesNeeded);
/* not enough bytes -- just save the new bytes for more later */
if (n > 0)
+ {
SaveBytes(fd, buf, n);
+ }
return;
}
@@ -353,6 +362,54 @@ ProcessBuffer(fd, buf, n)
and ByteProcessing. It probably needs to do some computation first.
*/
+SetBufLimit (fd)
+ FD fd;
+{
+ int ServerFD = FDPair (fd);
+ FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed +
+ CS[fd].NumberofBytesNeeded);
+}
+
+ClearBufLimit (fd)
+ FD fd;
+{
+ int ServerFD = FDPair (fd);
+ FDinfo[ServerFD].buflimit = -1;
+}
+
+StartStuff (fd)
+ FD fd;
+{
+ if (BreakPoint)
+ {
+ int ServerFD = FDPair (fd);
+ FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed +
+ CS[fd].NumberofBytesNeeded);
+ FlushFD (ServerFD);
+ }
+}
+
+FinishStuff (fd, buf, n)
+ FD fd;
+ unsigned char *buf;
+ long n;
+{
+ if (BreakPoint)
+ {
+ int ServerFD = FDPair (fd);
+
+ FlushFD (ServerFD);
+ if (SingleStep)
+ ReadCommands ();
+ else if (BreakPoint)
+ TestBreakPoints (buf, n);
+ if (!BreakPoint)
+ {
+ FDinfo[ServerFD].buflimit = -1;
+ FlushFD (ServerFD);
+ }
+ }
+}
StartClientConnection(fd)
FD fd;
@@ -362,6 +419,7 @@ StartClientConnection(fd)
CS[fd].SavedBytes = NULL;
CS[fd].SizeofSavedBytes = 0;
CS[fd].NumberofSavedBytes = 0;
+ CS[fd].NumberofBytesProcessed = 0;
/* when a new connection is started, we have no reply Queue */
FlushReplyQ(fd);
@@ -372,6 +430,7 @@ StartClientConnection(fd)
/* we need 12 bytes to start a SetUp message */
CS[fd].ByteProcessing = StartSetUpMessage;
CS[fd].NumberofBytesNeeded = 12;
+ StartStuff (fd);
}
StopClientConnection(fd)
@@ -399,7 +458,10 @@ long StartSetUpMessage (fd, buf, n)
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
*/
-
+ CS[fd].littleEndian = (buf[0] == 'l');
+ CS[ServerHalf(fd)].littleEndian = CS[fd].littleEndian;
+ littleEndian = CS[fd].littleEndian;
+
namelength = IShort(&buf[6]);
datalength = IShort(&buf[8]);
CS[fd].ByteProcessing = FinishSetUpMessage;
@@ -407,6 +469,7 @@ long StartSetUpMessage (fd, buf, n)
+ pad((long)namelength) + pad((long)datalength);
debug(8,(stderr, "need %d bytes to finish startup\n",
CS[fd].NumberofBytesNeeded - n));
+ StartStuff (fd);
return(0);
}
@@ -416,12 +479,13 @@ long FinishSetUpMessage (fd, buf, n)
long n;
{
enterprocedure("FinishSetUpMessage");
- PrintSetUpMessage(buf);
- if (RequestSync) SendToServer(fd,buf,n);
+ if (ScopeEnabled)
+ PrintSetUpMessage(buf);
/* after a set-up message, we expect a string of requests */
CS[fd].ByteProcessing = StartRequest;
CS[fd].NumberofBytesNeeded = 4;
+ FinishStuff (fd, buf, n);
return(n);
}
@@ -431,7 +495,7 @@ long StartRequest (fd, buf, n)
unsigned char *buf;
long n;
{
- short requestlength;
+ unsigned short requestlength;
enterprocedure("StartRequest");
/* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */
@@ -440,6 +504,7 @@ long StartRequest (fd, buf, n)
CS[fd].NumberofBytesNeeded = 4 * requestlength;
debug(8,(stderr, "need %d more bytes to finish request\n",
CS[fd].NumberofBytesNeeded - n));
+ StartStuff (fd);
return(0);
}
@@ -450,11 +515,11 @@ long FinishRequest (fd, buf, n)
long n;
{
enterprocedure("FinishRequest");
- DecodeRequest(fd, buf, n);
- if (RequestSync) SendToServer(fd,buf,n);
-
CS[fd].ByteProcessing = StartRequest;
CS[fd].NumberofBytesNeeded = 4;
+ if (ScopeEnabled)
+ DecodeRequest(fd, buf, n);
+ FinishStuff (fd, buf, n);
return(n);
}
@@ -463,39 +528,6 @@ long FinishRequest (fd, buf, 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;
{
@@ -504,6 +536,7 @@ StartServerConnection(fd)
CS[fd].SavedBytes = NULL;
CS[fd].SizeofSavedBytes = 0;
CS[fd].NumberofSavedBytes = 0;
+ CS[fd].NumberofBytesProcessed = 0;
/* when a new connection is started, we have no reply Queue */
FlushReplyQ(fd);
@@ -545,7 +578,8 @@ long FinishSetUpReply (fd, buf, n)
long n;
{
enterprocedure("FinishSetUpReply");
- PrintSetUpReply(buf);
+ if (ScopeEnabled)
+ PrintSetUpReply(buf);
CS[fd].ByteProcessing = ServerPacket;
CS[fd].NumberofBytesNeeded = 32;
return(n);
@@ -558,10 +592,9 @@ long ErrorPacket (fd, buf, n)
unsigned char *buf;
long n;
{
- fprintf(stdout, "Error: ");
- DecodeError(fd, buf, n);
CS[fd].ByteProcessing = ServerPacket;
CS[fd].NumberofBytesNeeded = 32;
+ DecodeError(fd, buf, n);
return(n);
}
@@ -571,9 +604,10 @@ long EventPacket (fd, buf, n)
unsigned char *buf;
long n;
{
- DecodeEvent(fd, buf, n);
CS[fd].ByteProcessing = ServerPacket;
CS[fd].NumberofBytesNeeded = 32;
+ if (ScopeEnabled)
+ DecodeEvent(fd, buf, n);
return(n);
}
@@ -583,7 +617,7 @@ long ReplyPacket (fd, buf, n)
unsigned char *buf;
long n;
{
- short replylength;
+ long replylength;
replylength = ILong(&buf[4]);
@@ -624,9 +658,16 @@ long FinishReply (fd, buf, n)
unsigned char *buf;
long n;
{
- enterprocedure("FinishReply");
- DecodeReply(fd, buf, n);
CS[fd].ByteProcessing = ServerPacket;
CS[fd].NumberofBytesNeeded = 32;
+ enterprocedure("FinishReply");
+ if (ScopeEnabled)
+ DecodeReply(fd, buf, n);
return(n);
}
+
+long GetXRequestFromName (name)
+ char *name;
+{
+ return GetEValue (REQUEST, name);
+}
diff --git a/shmscope.h b/shmscope.h
new file mode 100644
index 0000000..d898326
--- /dev/null
+++ b/shmscope.h
@@ -0,0 +1,16 @@
+#ifndef _MITSHMSCOPE_H_
+#define _MITSHMSCOPE_H_
+
+#define MITSHMREQUESTHEADER "MITSHMREQUEST"
+#define MITSHMREPLYHEADER "MITSHMREPLY"
+
+/*
+ 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)
+
+#endif
+
diff --git a/table11.c b/table11.c
index c527424..d3e08ed 100644
--- a/table11.c
+++ b/table11.c
@@ -59,7 +59,6 @@
InitializeX11()
{
- enterprocedure("InitializeX11");
InitReplyQ();
InitBuiltInTypes();
@@ -69,6 +68,102 @@ InitializeX11()
InitRecordTypes();
}
+#define HASH_SIZE 997
+
+ValuePtr buckets[HASH_SIZE];
+
+#define HASH(key) ((key) % HASH_SIZE)
+
+ValuePtr
+GetValueRec (key)
+ unsigned long key;
+{
+ ValuePtr *bucket, value;
+
+ bucket = &buckets[HASH(key)];
+ for (value = *bucket; value; value = value->next)
+ {
+ if (value->key == key)
+ return value;
+ }
+ return 0;
+}
+
+CreateValueRec (key, size, def)
+ unsigned long key;
+ int size;
+ unsigned long *def;
+{
+ ValuePtr *bucket, value;
+ int i;
+
+ bucket = &buckets[HASH(key)];
+ value = (ValuePtr) malloc (sizeof (ValueRec) + size * sizeof (unsigned long));
+ if (!value)
+ return 0;
+ value->values = (unsigned long *) (value + 1);
+ for (i = 0; i < size; i++)
+ value->values[i] = ILong((char *) (def + i));
+ value->size = size;
+ value->key = key;
+ value->next = *bucket;
+ *bucket = value;
+}
+
+DeleteValueRec (key)
+ unsigned long key;
+{
+ ValuePtr *bucket, value;
+
+ for (bucket = &buckets[HASH(key)]; value = *bucket; bucket = &value->next)
+ {
+ if (value->key == key)
+ {
+ *bucket = value->next;
+ free (value);
+ return;
+ }
+ }
+}
+
+SetValueRec (key, control, clength, ctype, values)
+ unsigned long key;
+ unsigned char *control;
+ short clength;
+ short ctype;
+ unsigned char *values;
+{
+ long cmask;
+ struct ValueListEntry *p;
+ ValuePtr value;
+ int i;
+
+ value = GetValueRec (key);
+ if (!value)
+ return;
+ /* 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 */
+ for (p = TD[ctype].ValueList, i = 0; p != NULL; p = p->Next, i++)
+ {
+ if ((p->Value & cmask) != 0)
+ {
+ memcpy (&value->values[i], values, sizeof (unsigned long));
+ values += 4;
+ }
+ }
+}
+
/* ************************************************************ */
/* */
/* */
@@ -122,6 +217,25 @@ DefineEValue(type, value, name)
}
}
+long
+GetEValue (typeid, name)
+ short typeid;
+ char *name;
+{
+ TYPE p;
+ struct ValueListEntry *v;
+
+ if (typeid < 0 || MaxTypes <= typeid)
+ return -1;
+ p = &TD[typeid];
+ if (!p)
+ return -2;
+ for (v = p->ValueList; v; v = v->Next)
+ if (!strcmp (name, v->Name))
+ return v->Value;
+ return -3;
+}
+
/* ************************************************************ */
/* 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 */
@@ -167,7 +281,6 @@ DefineValues(type, value, length, ctype, name)
InitBuiltInTypes()
{
- enterprocedure("InitBuiltInTypes");
(void) DefineType(INT8, BUILTIN, "INT8", PrintINT8);
(void) DefineType(INT16, BUILTIN, "INT16", PrintINT16);
(void) DefineType(INT32, BUILTIN, "INT32", PrintINT32);
@@ -214,7 +327,6 @@ InitEnumeratedTypes()
{
TYPE p;
- enterprocedure("InitEnumeratedTypes");
p = DefineType(REQUEST, ENUMERATED, "REQUEST", PrintENUMERATED);
DefineEValue(p, 1L, "CreateWindow");
DefineEValue(p, 2L, "ChangeWindowAttributes");
@@ -745,7 +857,6 @@ InitSetTypes()
{
TYPE p;
- enterprocedure("InitSetTypes");
p = DefineType(SETofEVENT, SET, "SETofEVENT", PrintSET);
DefineEValue(p, 0x00000001L, "KeyPress");
DefineEValue(p, 0x00000002L, "KeyRelease");
@@ -1018,7 +1129,6 @@ PrintVISUALTYPE(buf)
InitRecordTypes()
{
- enterprocedure("InitRecordTypes");
(void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B);
(void) DefineType(POINT, RECORD, "POINT", PrintPOINT);
(void) DefineType(RECTANGLE, RECORD, "RECTANGLE", PrintRECTANGLE);
@@ -1047,7 +1157,6 @@ InitValuesTypes()
{
TYPE p;
- enterprocedure("InitValueTypes");
p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK", PrintSET);
DefineValues(p, 0x00000001L, 4, PIXMAPNPR, "background-pixmap");
diff --git a/tablenas.c b/tablenas.c
new file mode 100644
index 0000000..c6d354d
--- /dev/null
+++ b/tablenas.c
@@ -0,0 +1,29 @@
+/*
+ * $NCDOr$
+ *
+ * Copyright 1996 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+InitializeAudio ()
+{
+ ;
+}
diff --git a/wcpscope.h b/wcpscope.h
new file mode 100644
index 0000000..79ad9ad
--- /dev/null
+++ b/wcpscope.h
@@ -0,0 +1,45 @@
+/*
+ * $NCDOr$
+ *
+ * Copyright 1996 Network Computing Devices
+ *
+ * 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 NCD. not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. NCD. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD.
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, Network Computing Devices
+ */
+
+#ifndef _WCPSCOPE_H_
+#define _WCPSCOPE_H_
+
+#define WCPREQUEST 129
+#define WCPREPLY 130
+#define WCPERROR 131
+
+#define WCPREQUESTHEADER "WCPREQUEST"
+#define WCPREPLYHEADER "WCPREPLY"
+
+/*
+ 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)
+
+#endif
+
diff --git a/x11.h b/x11.h
index 059b159..3b2ab00 100644
--- a/x11.h
+++ b/x11.h
@@ -64,7 +64,7 @@
#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 PIXMAPNPR 16 /* CARD32 plus 0 = None, 1 = ParentRelative
*/
#define PIXMAPC 17 /* CARD32 plus 0 = CopyFromParent */
@@ -108,72 +108,72 @@
/* 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 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
@@ -187,7 +187,19 @@
#define ERROR 119
#define EVENT 120
-#define MaxTypes 128
+#define LBXREQUEST 121
+#define LBXREPLY 122
+#define LBXEVENT 123
+#define LBXERROR 124
+
+#define NASREQUEST 125
+#define NASREPLY 126
+#define NASEVENT 127
+#define NASERROR 128
+
+#define MaxTypes 256
+
+extern char ScopeEnabled;
/* ************************************************************ */
/* */
@@ -196,45 +208,45 @@
/* 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();
+extern int PrintINT8();
+extern int PrintINT16();
+extern int PrintINT32();
+extern int PrintCARD8();
+extern int PrintCARD16();
+extern int PrintCARD32();
+extern int PrintBYTE();
+extern int PrintCHAR8();
+extern int PrintSTRING16();
+extern int PrintTEXTITEM8();
+extern int PrintTEXTITEM16();
+extern int PrintSTR();
+extern int PrintWINDOW();
+extern int PrintWINDOWD();
+extern int PrintWINDOWNR();
+extern int PrintPIXMAP();
+extern int PrintPIXMAPNPR();
+extern int PrintPIXMAPC();
+extern int PrintCURSOR();
+extern int PrintFONT();
+extern int PrintGCONTEXT();
+extern int PrintCOLORMAP();
+extern int PrintCOLORMAPC();
+extern int PrintDRAWABLE();
+extern int PrintFONTABLE();
+extern int PrintATOM();
+extern int PrintATOMT();
+extern int PrintVISUALID();
+extern int PrintVISUALIDC();
+extern int PrintTIMESTAMP();
+extern int PrintRESOURCEID();
+extern int PrintKEYSYM();
+extern int PrintKEYCODE();
+extern int PrintKEYCODEA();
+extern int PrintBUTTON();
+extern int PrintBUTTONA();
+extern int PrintEVENTFORM();
+extern int PrintENUMERATED();
+extern int PrintSET();
/* ************************************************************ */
/* */
@@ -244,7 +256,7 @@ 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
+ 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
@@ -280,7 +292,7 @@ struct TypeDef
typedef struct TypeDef *TYPE;
-struct TypeDef TD[MaxTypes];
+extern struct TypeDef TD[MaxTypes];
/* ************************************************************ */
/* */
@@ -290,13 +302,13 @@ 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];
+extern 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
+ request: Set by DecodeReply and used in a PrintField of
the Request procedure */
-unsigned char SBf[4];
+extern unsigned char SBf[4];
#define PRINTSERVER 5 /* indent output as if it comes from server */
@@ -307,7 +319,7 @@ unsigned char SBf[4];
/* */
/* ************************************************************ */
-/*
+/*
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
@@ -324,7 +336,7 @@ unsigned char SBf[4];
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
+ 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
@@ -338,7 +350,7 @@ unsigned char SBf[4];
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.
+ requests.
Our overall flow is then:
@@ -347,7 +359,7 @@ unsigned char SBf[4];
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.
@@ -388,19 +400,19 @@ unsigned char SBf[4];
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
+
+ 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.
+ 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
@@ -417,19 +429,31 @@ unsigned char SBf[4];
struct ConnState
{
unsigned char *SavedBytes;
+ int littleEndian;
long SizeofSavedBytes;
long NumberofSavedBytes;
long NumberofBytesNeeded;
+ long NumberofBytesProcessed;
long (*ByteProcessing)();
long SequenceNumber;
};
-struct ConnState CS[StaticMaxFD];
-
+extern struct ConnState CS[StaticMaxFD];
+typedef struct _Value {
+ struct _Value *next;
+ unsigned long key;
+ int size;
+ unsigned long *values;
+} ValueRec, *ValuePtr;
+extern ValuePtr GetValueRec ();
+extern CreateValueRec ();
+extern DeleteValueRec ();
+extern SetValueRec ();
+extern PrintValueRec ();
/* ************************************************************ */
/* */
@@ -444,9 +468,35 @@ extern unsigned short IChar2B();
extern unsigned short IByte();
extern Boolean IBool();
-extern PrintString8();
-extern PrintString16();
+extern PrintString8(), PrintTString8 ();
+extern PrintString16(), PrintTString16 ();
extern PrintListSTR();
extern long PrintList();
extern long pad();
+
+extern char *REQUESTHEADER, *EVENTHEADER, *ERRORHEADER, *REPLYHEADER;
+
+#define GC_function 0x00000001L
+#define GC_plane_mask 0x00000002L
+#define GC_foreground 0x00000004L
+#define GC_background 0x00000008L
+#define GC_line_width 0x00000010L
+#define GC_line_style 0x00000020L
+#define GC_cap_style 0x00000040L
+#define GC_join_style 0x00000080L
+#define GC_fill_style 0x00000100L
+#define GC_fill_rule 0x00000200L
+#define GC_tile 0x00000400L
+#define GC_stipple 0x00000800L
+#define GC_tile_stipple_x_origin 0x00001000L
+#define GC_tile_stipple_y_origin 0x00002000L
+#define GC_font 0x00004000L
+#define GC_subwindow_mode 0x00008000L
+#define GC_graphics_exposures 0x00010000L
+#define GC_clip_x_origin 0x00020000L
+#define GC_clip_y_origin 0x00040000L
+#define GC_clip_mask 0x00080000L
+#define GC_dash_offset 0x00100000L
+#define GC_dashes 0x00200000L
+#define GC_arc_mode 0x00400000L
diff --git a/xscope.1 b/xscope.1
deleted file mode 100644
index 50f9b34..0000000
--- a/xscope.1
+++ /dev/null
@@ -1,107 +0,0 @@
-.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.
diff --git a/xscope.man b/xscope.man
new file mode 100644
index 0000000..91a194b
--- /dev/null
+++ b/xscope.man
@@ -0,0 +1,163 @@
+.TH XSCOPE 1 "8 Aug 1991" "X Version 11"
+.SH NAME
+xscope - X Window System Protocol Monitor
+.SH SYNOPSIS
+.B xscope
+[ options ] ...
+.SH DESCRIPTION
+.I xscope
+is a program that monitors connections between an X server and a client.
+\fIxscope\fP prints to stdout the contents of each request, reply, error,
+or event that is communicated between the server and client.
+This information can be useful in debugging and performance tuning
+of X servers and clients.
+.PP
+\fIxscope\fP attaches to the X server as if it were a client.
+By adjusting the host and/or display number, the client can be made to
+attach to \fIxscope\fP instead of the X server.
+.PP
+ server <-----> xscope <-----> client
+.PP
+All bytes from the server are sent to \fIxscope\fP which sends them on to
+the client.
+All bytes from the client are sent to \fIxscope\fP which passes them on
+to the server.
+\fIxscope\fP is transparent to both the server and the client.
+.SH OPTIONS
+.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 \-h<host>
+Determines the host that \fIxscope\fP will use to find the server.
+.PP
+.TP 10
+.B \-i<input-port>
+Specify the port that \fIxscope\fP will use to take requests from clients
+(defaults is 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 the server
+(defaults is 0).
+For X11, this port is automatically biased by 6000.
+.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 verbosity 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 X 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 OPERATION
+When running with \fIxscope\fP, three processes are involved, potentially
+all on different machines:
+.PP
+.TP 5
+\fIX server\fP
+The X server will run on machine (or host) "A", display "B".
+("A" is a machine name; "B" is a display number).
+.PP
+.TP 5
+\fIxscope\fP
+\fIxscope\fP must be told where the X server is (what machine and
+what display), and, in addition, the \fIport-number\fP on which to listen
+for X clients.
+The options for \fIxscope\fP are "-h<Xserver-host>" and "-d<display-number>".
+In this example, -hA and -dB.
+Typically the \fIdisplay-number\fP is not given.
+\fIxscope\fP will not try to connect to the server until the client
+connects to \fIxscope\fP.
+.PP
+.TP 5
+\fIX client\fP
+The client should connect to \fIxscope\fP rather than to the server.
+To avoid changing the code for the client, \fIxscope\fP listens on
+the same port as the server for connecting clients.
+If the server and \fIxscope\fP are on different machines, this works well.
+However, if the server and \fIxscope\fP are on the same machine, this
+creates a port conflict.
+To resolve this conflict, \fIxscope\fP can be given a different
+input or output port number, as necessary, to avoid the port that
+the server is listening to.
+The client must connect to this offset port number.
+The input port for \fIxscope\fP is set by \fI-i<port-number>\fP;
+the output port is set by \fI-o<port-number>.\fP
+The default input port is 1; the default output port is 0.
+These ports are offset by the X11 base (6000) and the display number.
+The client attaches to \fIxscope\fP by changing its display number by the
+port offset.
+.SH EXAMPLES
+.LP
+.B "xscope -hbagel -i0"
+.PP
+The X server would run on "bagel", display 0 (the default).
+\fIxscope\fP and the client would both be on "cleo".
+The client program would connect to "X" on "cleo:0",
+and would be attached to \fIxscope\fP, which would then attach to
+the server on "bagel:0".
+.PP
+ server (bagel:0) <-----> xscope -hbagel -i0 <-----> client -d cleo:0
+.LP
+.B "xscope -i1"
+.PP
+Here is a case where all three processes would run on "cleo".
+\fIxscope\fP would listen on port 6001 (which is display 1 for X11).
+The client would attach to the server on "cleo:1", and \fIxscope\fP
+would connect through to the server on "cleo:0".
+.PP
+ server (cleo:0) <-----> xscope -i1 <-----> client -d cleo:1
+.LP
+.B "xscope -hcleo -d0 -o0 -i1 -v4"
+.PP
+This example is similar to the previous one, and would have \fIxscope\fP
+communicate with an X server on host ``cleo'', display 0.
+\fIxscope\fP itself would be available on the current host as display 1
+(display of 0 plus the 1 of -i1).
+Verbose level 4.
+.PP
+ server (cleo:0) <-----> xscope -hcleo -d0 -o0 -i1 -v4 <-----> client -d cleo:1
+.LP
+.B "xscope -d1 -o1 -i3 -q"
+.PP
+The X server for the current host, display 2 (1 for -d1 plus 1 for -o1)
+would be used by \fIxscope\fP, which would run as display 4 (1 for -d1 plus
+3 for -i3).
+Quiet mode (verbose level 0).
+.PP
+ server (unix:1) <-----> xscope -d1 -o1 -i3 -q <-----> client -d unix:4
+.SH LIMITATIONS
+The X Version 11 and PEX Version 5 Protocols are the only protocols recognized.
+.PP
+The command line arguments for specifying the real X server should be
+changed to be more consistent with the style since X11R3.
+.PP
+The Imakefile may be incorrect.
+.PP
+The builtin atoms have been wired in directly.
+A better solution is to pick them up from a header file.
+.PP
+There is no code yet to interpret typed commands from the keyboard.
+It would be possible for a command language at the keyboard to create
+artificial characters to be sent to the server or the client as if they were
+generated by the opposite side, or to dynamically alter requests or replies.
+.SH SEE ALSO
+X(1), X11 and PEX Protocol documents
+.SH AUTHOR
+.PP
+James L. Peterson (MCC)
+.PP
+Copyright 1988, MCC
diff --git a/xstats.c b/xstats.c
new file mode 100644
index 0000000..33ec4c7
--- /dev/null
+++ b/xstats.c
@@ -0,0 +1,114 @@
+#define REQUEST 0
+#define REPLY 1
+#define ERROR 2
+#define EVENT 3
+
+string_to_action (s)
+ char *s;
+{
+ if (!strcmp (s, "@@REQUEST")) return REQUEST;
+ if (!strcmp (s, "@@REPLY")) return REPLY;
+ if (!strcmp (s, "@@ERROR")) return ERROR;
+ if (!strcmp (s, "@@EVENT")) return EVENT;
+}
+
+typedef struct {
+ double time;
+ int action;
+ int client;
+ int major;
+ int minor;
+ int len;
+} ActionRec, *ActionPtr;
+
+unsigned long requestCount[256][256];
+unsigned long replyCount[256][256];
+unsigned long eventCount[256][256];
+unsigned long errorCount[256][256];
+
+unsigned long requestBytes[256][256];
+unsigned long replyBytes[256][256];
+unsigned long eventBytes[256][256];
+unsigned long errorBytes[256][256];
+
+unsigned long tRequestBytes;
+unsigned long tReplyBytes;
+unsigned long tEventBytes;
+unsigned long tErrorBytes;
+
+unsigned long tRequestCount;
+unsigned long tReplyCount;
+unsigned long tEventCount;
+unsigned long tErrorCount;
+
+dump (c, b)
+ unsigned long c[256][256];
+ unsigned long b[256][256];
+{
+ int i, j;
+ unsigned long count, bytes;
+
+ for (i = 0; i < 256; i++)
+ {
+ for (j = 0; j < 256; j++)
+ {
+ if (count = c[i][j])
+ {
+ bytes = b[i][j];
+ printf ("%3d %3d count %5d bytes %7d\n", i, j, count, bytes);
+ }
+ }
+ }
+}
+
+main ()
+{
+ ActionRec a;
+ char aname[128];
+ int i, j;
+
+ while (scanf ("%lf: %s %d %d %d %d\n",
+ &a.time, aname, &a.client, &a.major, &a.minor, &a.len) == 6)
+ {
+ a.action = string_to_action (aname);
+ switch (a.action) {
+ case REQUEST:
+ requestCount[a.major][a.minor]++;
+ requestBytes[a.major][a.minor] += a.len;
+ tRequestCount++;
+ tRequestBytes += a.len;
+ break;
+ case REPLY:
+ replyCount[a.major][a.minor]++;
+ replyBytes[a.major][a.minor] += a.len;
+ tReplyCount++;
+ tReplyBytes += a.len;
+ break;
+ case EVENT:
+ eventCount[a.major][a.minor]++;
+ eventBytes[a.major][a.minor] += a.len;
+ tEventCount++;
+ tEventBytes += a.len;
+ break;
+ case ERROR:
+ errorCount[a.major][a.minor]++;
+ errorBytes[a.major][a.minor] += a.len;
+ tErrorCount++;
+ tErrorBytes += a.len;
+ break;
+ }
+ }
+ printf ("requests:\n");
+ dump (requestCount, requestBytes);
+ printf ("replies:\n");
+ dump (replyCount, replyBytes);
+ printf ("events:\n");
+ dump (eventCount, eventBytes);
+ printf ("errors:\n");
+ dump (errorCount, errorBytes);
+ printf ("send count %5d bytes %7d\n",
+ tRequestCount, tRequestBytes);
+ printf ("recv count %5d bytes %7d\n",
+ tEventCount + tErrorCount + tReplyCount,
+ tEventBytes + tErrorBytes + tReplyBytes);
+}