diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 7677556..0000000 --- a/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -xscope-1.1.tar.bz2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f45c711 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +xscope-1.2.tar.bz2 +/xscope-1.3.tar.bz2 +/xscope-1.3.1.tar.bz2 +/xscope-1.3.99.901.tar.bz2 +/xscope-1.4.tar.bz2 +/xscope-1.4.1.tar.bz2 +/xscope-1.4.2.tar.xz +/xscope-1.4.3.tar.xz +/xscope-1.4.4.tar.xz +/xscope-1.4.5.tar.xz diff --git a/Makefile b/Makefile deleted file mode 100644 index e8403f5..0000000 --- a/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Makefile for source rpm: xscope -# $Id$ -NAME := xscope -SPECFILE = $(firstword $(wildcard *.spec)) - -define find-makefile-common -for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done -endef - -MAKEFILE_COMMON := $(shell $(find-makefile-common)) - -ifeq ($(MAKEFILE_COMMON),) -# attept a checkout -define checkout-makefile-common -test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 -endef - -MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) -endif - -include $(MAKEFILE_COMMON) diff --git a/import.log b/import.log deleted file mode 100644 index 4779ee5..0000000 --- a/import.log +++ /dev/null @@ -1 +0,0 @@ -xscope-1_1-3_gitfccbbd6_fc12:HEAD:xscope-1.1-3.gitfccbbd6.fc12.src.rpm:1246424870 diff --git a/sources b/sources index 6e3b841..264e26c 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -c37ec177b56d5909584c1672b6beabd5 xscope-1.1.tar.bz2 +SHA512 (xscope-1.4.5.tar.xz) = f880d25e92ebebaa41fd08e801c8766d0452d57cc6e807df83c45e5fc9dc51c2dd82efe14f2f8c011ddce3172a0130caac939953d519ef516ea6e09e1bf1f2e9 diff --git a/xscope-1.1-diff_to_git.patch b/xscope-1.1-diff_to_git.patch deleted file mode 100644 index eb936d5..0000000 --- a/xscope-1.1-diff_to_git.patch +++ /dev/null @@ -1,16684 +0,0 @@ -diff --git a/AUTHORS b/AUTHORS -index 3dd770c..b3bbcec 100644 ---- a/AUTHORS -+++ b/AUTHORS -@@ -1 +1,2 @@ - James Peterson, MCC -+Keith Packard -diff --git a/Makefile.am b/Makefile.am -index 89928cf..7bbf2e6 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -1,5 +1,5 @@ - # --# Copyright 2008 Sun Microsystems, Inc. All rights reserved. -+# Copyright 2008-2009 Sun Microsystems, Inc. All rights reserved. - # Use subject to license terms. - # - # Permission is hereby granted, free of charge, to any person obtaining a -@@ -30,28 +30,51 @@ - - bin_PROGRAMS = xscope - --AM_CFLAGS = $(XSCOPE_CFLAGS) -+AM_CFLAGS = $(CWARNFLAGS) $(XSCOPE_CFLAGS) - xscope_LDADD = $(XSCOPE_LIBS) - - xscope_SOURCES = \ -+ audio.c \ -+ bigreqscope.h \ - common.c \ - decode11.c \ -+ decode_bigreq.c \ -+ decode_lbx.c \ -+ decode_randr.c \ -+ decode_render.c \ -+ decode_shm.c \ -+ decode_wcp.c \ -+ decodenas.c \ -+ extensions.c \ -+ extensions.h \ - fd.c \ - fd.h \ -+ lbxscope.h \ -+ nas.h \ - print11.c \ -+ print_bigreq.c \ -+ print_lbx.c \ -+ print_randr.c \ -+ print_render.c \ -+ print_shm.c \ -+ print_wcp.c \ -+ printnas.c \ - proto.h \ - prtype.c \ -+ randrscope.h \ -+ renderscope.h \ -+ scope-transport.c \ - scope.c \ - scope.h \ - server.c \ -+ shmscope.h \ - table11.c \ -- x11.h \ -- scope-transport.c -+ wcpscope.h \ -+ x11.h - - appman_PRE = \ - xscope.man - -- - appmandir = $(APP_MAN_DIR) - - appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@) -@@ -63,7 +86,7 @@ MAINTAINERCLEANFILES = ChangeLog - .PHONY: ChangeLog - - ChangeLog: -- (GIT_DIR=$(top_srcdir)/.git git-log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f .changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing possibly empty changelog.' >&2) -+ $(CHANGELOG_CMD) - - dist-hook: ChangeLog - -@@ -90,3 +113,16 @@ SUFFIXES = .$(APP_MAN_SUFFIX) .man - - .man.$(APP_MAN_SUFFIX): - sed $(MAN_SUBSTS) < $< > $@ -+ -+if LINT -+# Check source code with tools like lint & sparse -+ -+ALL_LINT_FLAGS=$(LINT_FLAGS) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) -+ -+lint: $(BUILT_SOURCES) -+ @for f in $(xscope_SOURCES) ; do \ -+ case $$f in *.c) \ -+ $(LINT) $(ALL_LINT_FLAGS) $(srcdir)/$$f ;; esac ; \ -+ done -+endif LINT -diff --git a/README b/README -index e69de29..39e78b1 100644 ---- a/README -+++ 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 and -d. 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; the output port is set by -o. 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..94fd08a ---- /dev/null -+++ b/audio.c -@@ -0,0 +1,500 @@ -+/* -+ * $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 /* for struct iovec, used by socket.h */ -+#include /* for AF_INET, SOCK_STREAM, ... */ -+#include /* for FIONCLEX, FIONBIO, ... */ -+#ifdef SVR4 -+#include -+#endif -+#include -+#include /* struct sockaddr_in */ -+#include -+#include /* struct servent * and struct hostent * */ -+#include /* for EINTR, EADDRINUSE, ... */ -+ -+static void -+ReportFromAudioClient ( -+ FD fd, -+ unsigned char *buf, -+ long n) -+{ -+ if (NasVerbose) { -+ if (ScopeEnabled) { -+ PrintTime (); -+ fprintf(stdout, "NAS Client%s --> %4ld %s\n", -+ ClientName(fd), n, (n == 1 ? "byte" : "bytes")); -+ } -+ } -+ ProcessBuffer (fd, buf, n); -+} -+ -+static void -+ReportFromAudioServer( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ if (NasVerbose) { -+ if (ScopeEnabled) { -+ PrintTime(); -+ fprintf(stdout, "\t\t\t\t\t%4ld %s <-- NAS Server%s\n", -+ n, (n == 1 ? "byte" : "bytes"), ClientName(fd)); -+ } -+ } -+ ProcessBuffer(fd, buf, n); -+} -+ -+static long StartAudioSetUpMessage (FD fd, const unsigned char *buf, long n); -+static long FinishAudioSetUpMessage (FD fd, const unsigned char *buf, long n); -+static long StartAudioRequest (FD fd, const unsigned char *buf, long n); -+static long FinishAudioRequest (FD fd, const unsigned char *buf, long n); -+static long StartAudioSetUpReply (FD fd, const unsigned char *buf, long n); -+static long FinishAudioSetUpReply (FD fd, const unsigned char *buf, long n); -+static long FinishAudioReply (FD fd, const unsigned char *buf, long n); -+static long AudioServerPacket (FD fd, const unsigned char *buf, long n); -+ -+static void -+StartAudioClientConnection( -+ 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; -+} -+ -+static void -+StopAudioClientConnection( -+ FD fd) -+{ -+ enterprocedure("StopAudioClientConnection"); -+ /* when a new connection is stopped, discard the old buffer */ -+ -+ if (CS[fd].SizeofSavedBytes > 0) -+ Free((char*)CS[fd].SavedBytes); -+} -+ -+static long -+StartAudioSetUpMessage ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ short namelength; -+ short datalength; -+ -+ enterprocedure("StartSetUpMessage"); -+ /* -+ we need the first 12 bytes to be able to determine if, and how many, -+ additional bytes we need for name and data authorization. However, we -+ can't process the first 12 bytes until we get all of them, so -+ return zero bytes used, and increase the number of bytes needed -+ */ -+ -+ 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 %ld bytes to finish startup\n", -+ CS[fd].NumberofBytesNeeded - n)); -+ return(0); -+} -+ -+static long -+FinishAudioSetUpMessage ( -+ FD fd, -+ const 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); -+} -+ -+ -+static long -+StartAudioRequest ( -+ FD fd, -+ const 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 %ld more bytes to finish request\n", -+ CS[fd].NumberofBytesNeeded - n)); -+ return(0); -+} -+ -+ -+static long -+FinishAudioRequest ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ enterprocedure("FinishRequest"); -+ CS[fd].ByteProcessing = StartAudioRequest; -+ CS[fd].NumberofBytesNeeded = 4; -+ if (ScopeEnabled) -+ DecodeAudioRequest(fd, buf, n); -+ return(n); -+} -+ -+static void -+StartAudioServerConnection( -+ 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; -+} -+ -+static void -+StopAudioServerConnection( -+ FD fd) -+{ -+ enterprocedure("StopAudioServerConnection"); -+ /* when a new connection is stopped, discard the old buffer */ -+ -+ if (CS[fd].SizeofSavedBytes > 0) -+ Free((char *)CS[fd].SavedBytes); -+} -+ -+static long -+StartAudioSetUpReply ( -+ FD fd, -+ const 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 %ld bytes to finish startup reply\n", -+ CS[fd].NumberofBytesNeeded - n)); -+ return(0); -+} -+ -+static long -+FinishAudioSetUpReply ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ enterprocedure("FinishSetUpReply"); -+ if (ScopeEnabled) -+ PrintAudioSetUpReply(buf); -+ CS[fd].ByteProcessing = AudioServerPacket; -+ CS[fd].NumberofBytesNeeded = 32; -+ return(n); -+} -+ -+/* ************************************************************ */ -+ -+static long -+AudioErrorPacket ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ CS[fd].ByteProcessing = AudioServerPacket; -+ CS[fd].NumberofBytesNeeded = 32; -+ DecodeAudioError(fd, buf, n); -+ return(n); -+} -+ -+ -+static long -+AudioEventPacket ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ CS[fd].ByteProcessing = AudioServerPacket; -+ CS[fd].NumberofBytesNeeded = 32; -+ if (ScopeEnabled) -+ DecodeAudioEvent(fd, buf, n); -+ return(n); -+} -+ -+ -+static long -+AudioReplyPacket ( -+ FD fd, -+ const 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 %ld bytes to finish reply\n", (4 * replylength))); -+ return(0); -+} -+ -+static long -+FinishAudioReply ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ CS[fd].ByteProcessing = AudioServerPacket; -+ CS[fd].NumberofBytesNeeded = 32; -+ enterprocedure("FinishAudioReply"); -+ if (ScopeEnabled) -+ DecodeAudioReply(fd, buf, n); -+ return(n); -+} -+ -+static long -+AudioServerPacket ( -+ FD fd, -+ const 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)); -+} -+ -+static void -+CloseAudioConnection( -+ 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. */ -+ -+static void -+DataFromAudioClient( -+ 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 %ld 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. */ -+ -+static void -+DataFromAudioServer( -+ 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 %ld 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); -+} -+ -+static FD -+ConnectToAudioClient( -+ FD ConnectionSocket) -+{ -+ FD ClientFD; -+ ClientFD = AcceptConnection(ConnectionSocket); -+ UsingFD(ClientFD, DataFromAudioClient, FlushFD, NULL); -+ StartAudioClientConnection(ClientFD); -+ return(ClientFD); -+} -+ -+static FD ConnectToAudioServer( -+ Boolean report) -+{ -+ FD ServerFD; -+ XtransConnInfo trans_conn = NULL; /* transport connection object */ -+ -+ if (!AudioServerHostName[0]) -+ strcpy (AudioServerHostName, ServerHostName); -+ ServerFD = MakeConnection (AudioServerHostName, GetServerport () + 2000, report, &trans_conn); -+ if (ServerFD >= 0) -+ { -+ UsingFD(ServerFD, DataFromAudioServer, FlushFD, trans_conn); -+ StartAudioServerConnection(ServerFD); -+ } -+ return(ServerFD); -+} -+ -+void -+NewAudio ( -+ FD fd) -+{ -+ FD ServerFD = -1; -+ FD ClientFD = -1; -+ -+ ClientFD = ConnectToAudioClient(fd); -+ ServerFD = ConnectToAudioServer(true); -+ SetUpPair(ClientFD, ServerFD); -+} -+ -+void -+InitializeAudio (void) -+{ -+ InitializeAudioDecode (); -+} -diff --git a/bigreqscope.h b/bigreqscope.h -new file mode 100644 -index 0000000..0b182c0 ---- /dev/null -+++ b/bigreqscope.h -@@ -0,0 +1,22 @@ -+#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) -+ -+extern unsigned char BIGREQRequest; -+ -+extern void BigreqEnable (FD fd, const unsigned char *buf); -+extern void BigreqEnableReply (FD fd, const unsigned char *buf); -+ -+#endif -+ -diff --git a/common.c b/common.c -index 028578b..8d16e6d 100644 ---- a/common.c -+++ b/common.c -@@ -54,6 +54,7 @@ - \* *********************************************************** */ - - #include "scope.h" -+#include - - #ifdef SYSV - #define bzero(s,l) memset(s, 0, l) -@@ -69,22 +70,19 @@ - /* ********************************************** */ - - void --enterprocedure(s) -- char *s; -+enterprocedure (char *s) - { - debug(2,(stderr, "-> %s\n", s)); - } - - void --warn(s) -- char *s; -+warn (char *s) - { - fprintf(stderr, "####### %s\n", s); - } - - void --panic(s) -- char *s; -+panic (char *s) - { - fprintf(stderr, "%s\n", s); - exit(1); -@@ -96,11 +94,12 @@ panic(s) - /* */ - /* ********************************************** */ - --void *Malloc (long n) -+void * -+Malloc (long n) - { - void *p; - p = malloc(n); -- debug(64,(stderr, "%x = malloc(%d)\n", p, n)); -+ debug(64,(stderr, "%lx = malloc(%ld)\n", (unsigned long) p, n)); - if (p == NULL) - panic("no more malloc space"); - return(p); -@@ -109,7 +108,7 @@ void *Malloc (long n) - void - Free(void *p) - { -- debug(64,(stderr, "%x = free\n", p)); -+ debug(64,(stderr, "%lx = free\n", (unsigned long) p)); - free(p); - } - -@@ -121,6 +120,7 @@ Free(void *p) - /* */ - /* ************************************************************ */ - -+#define __USE_BSD_SIGNAL - #include - - static void SignalURG(int sig) -@@ -130,13 +130,15 @@ static void SignalURG(int sig) - - static void SignalPIPE(int sig) - { -+ signal (SIGPIPE, SignalPIPE); - debug(1,(stderr, "==> SIGPIPE received\n")); - } - - static void SignalINT(int sig) - { -+ signal (SIGINT, SignalINT); - debug(1,(stderr, "==> SIGINT received\n")); -- exit(1); -+ Interrupt = 1; - } - - static void SignalQUIT(int sig) -@@ -161,17 +163,25 @@ static void SignalCONT(int sig) - debug(1,(stderr, "==> SIGCONT received\n")); - } - -+static void SignalUSR1(int sig) -+{ -+ debug(1,(stderr, "==> SIGCONT received\n")); -+ ScopeEnabled = ! ScopeEnabled; -+} -+ - void --SetSignalHandling() -+SetSignalHandling(void) - { - enterprocedure("SetSignalHandling"); -- signal(SIGURG, SignalURG); -- signal(SIGPIPE, SignalPIPE); -- signal(SIGINT, SignalINT); -- signal(SIGQUIT, SignalQUIT); -- signal(SIGTERM, SignalTERM); -- signal(SIGTSTP, SignalTSTP); -- signal(SIGCONT, SignalCONT); -+ (void)signal(SIGURG, SignalURG); -+ (void)signal(SIGPIPE, SignalPIPE); -+ (void)signal(SIGINT, SignalINT); -+ (void)signal(SIGQUIT, SignalQUIT); -+ (void)signal(SIGTERM, SignalTERM); -+ (void)signal(SIGTSTP, SignalTSTP); -+ (void)signal(SIGCONT, SignalCONT); -+ if (HandleSIGUSR1) -+ (void)signal(SIGUSR1, SignalUSR1); - } - - -@@ -199,36 +209,34 @@ static int ListenTransCount; - #include /* for AF_INET, SOCK_STREAM, ... */ - #include /* for FIONCLEX, FIONBIO, ... */ - #include /* for FIONCLEX, FIONBIO, ... */ -+#ifdef SVR4 -+#include -+#endif -+ - #include /* struct sockaddr_in */ - #include /* struct servent * and struct hostent * */ - --#ifdef DNETCONN --#include --#endif --#ifdef DNETSVR4 --#include --#include --struct hostent *(*dnet_gethostbyname)(); --int (*dnet_gethostname)(); --short initialize_libdni(); --#endif - static int ON = 1 /* used in ioctl */ ; - #define BACKLOG 5 - #endif - - void --SetUpConnectionSocket(iport) -- int iport; -+SetUpConnectionSocket( -+ int iport, -+ void (*connectionFunc)(int)) - { - #ifdef USE_XTRANS - char port[20]; - int partial; - int i; -- extern long ServerBasePort; - #else - FD ConnectionSocket; - struct sockaddr_in sin; -- short port; -+ short port; -+ int one = 1; -+#ifndef SO_DONTLINGER -+ struct linger linger; -+#endif /* SO_DONTLINGER */ - #endif - - enterprocedure("SetUpConnectionSocket"); -@@ -251,7 +259,7 @@ SetUpConnectionSocket(iport) - - ListenTransFds[i] = fd; - debug(4,(stderr, "Listening on FD %d\n", fd)); -- UsingFD(fd, NewConnection, ListenTransConns[i]); -+ UsingFD(fd, NewConnection, NULL, ListenTransConns[i]); - } - } else { - panic("Could not open any listening connections"); -@@ -265,11 +273,17 @@ SetUpConnectionSocket(iport) - 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); --#ifdef SO_DONTLINGER -- (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0); - #endif -+#ifdef SO_DONTLINGER -+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0); -+#else /* SO_DONTLINGER */ -+ linger.l_onoff = 0; -+ linger.l_linger = 0; -+ (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger); -+#endif /* SO_DONTLINGER */ - - /* define the name and port to be used with the connection socket */ - bzero((char *)&sin, sizeof(sin)); -@@ -318,129 +332,24 @@ SetUpConnectionSocket(iport) - }; - - /* a few more parameter settings */ -- ioctl(ConnectionSocket, FIOCLEX, 0); -- ioctl(ConnectionSocket, FIONBIO, &ON); -- -- debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket)); -- UsingFD(ConnectionSocket, NewConnection); -+#ifdef FD_CLOEXEC -+ (void)fcntl(ConnectionSocket, F_SETFD, FD_CLOEXEC); -+#else -+ (void)ioctl(ConnectionSocket, FIOCLEX, 0); - #endif -- --} -- --#ifndef USE_XTRANS --#ifdef DNETSVR4 --SetUpDECnetConnection(display) --int display; --{ -- struct sockaddr_dn *sdn,sdnn; /* DECnet socket */ -- struct hostent *hp; -- int sock; -- char hostname[6]; -- -- if (!initialize_libdni()) { -- fprintf(stderr,"Unable to open libdni.so\n"); -- exit(0); -- } -- sdn = &sdnn; -- if (!(dnet_gethostname)(hostname)) { -- fprintf(stderr,"Can't get DECnet local host name\n"); -- exit(0); -- } -- if ((hp = (struct hostent *)(dnet_gethostbyname)(hostname)) == NULL) { -- fprintf(stderr,"xhost: can't get name %s\n",hostname); -- exit(0); -- } -- sdn->sdn_family = AF_DECnet; -- sdn->sdn_format = DNADDR_FMT1; -- sdn->sdn_port = 0; -- sprintf ((char *)sdn->sdn_name, "X$X%d", display); -- sdn->sdn_namelen = strlen((char *)sdn->sdn_name); -- sdn->sdn_addr = *(u_short *)hp->h_addr_list[0]; -- -- if ((sock = socket (AF_DECnet, SOCK_STREAM, 0)) < 0) { -- perror("socket"); -- exit(0); -- } -- (void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0); -- (void)setsockopt(sock, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0); -- -- if (bind(sock, (struct sockaddr_dn *)sdn, -- sizeof(struct sockaddr_dn)) < 0) { -- perror("DNI Bind"); -- exit(0); -- } -- if (listen(sock, 100) < 0) { -- perror("DNI Listen"); -- exit(0); -- } -- -- UsingFD(sock, NewConnection); --} -+ /* 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 -- --#ifdef DNETCONN --SetUpDECnetConnection(display) --int display; --{ -- struct ses_io_type sesopts; -- char objname[6]; -- FD fd; -- -- enterprocedure("SetUpDECnetConnection"); -- sprintf (objname, "X$X%d", display); -- if ((fd = open("/dev/dni", O_RDWR)) < 0) { -- fprintf(stderr,"xscope: dni: open failed\n"); -- exit(-1); -- } -- if (ioctl(fd, SES_GET_LINK, 0)) { -- fprintf(stderr,"xscope: dni: can't get link\n"); -- exit(-1); -- } -- /* set nonblocking here since dni ignores fcntls */ -- /* set asyncronous to avoid blocking on SES_GET_AI */ -- sesopts.io_flags = SES_IO_NBIO + SES_IO_ASYNCH_MODE; -- sesopts.io_io_signal = SIGIO; -- sesopts.io_int_signal = 0; -- -- if (ioctl(fd, SES_IO_TYPE, &sesopts) < 0) { -- fprintf(stderr,"xscope: dni: ioctl failed\n"); -- exit(-1); -- } -- -- /* register as server */ -- if (ioctl(fd, SES_NAME_SERVER, objname) < 0) { -- fprintf(stderr,"xscope: dni: ioctl failed\n"); -- exit(-1); -- } -- debug(4,(stderr, "Listening on DECnet FD %d\n", fd)); -- UsingFD(fd, NewConnection); --} - #endif - --#ifdef DNETSVR4 --short --initialize_libdni() --{ -- void *handle; -- char *home; -- char *path; -- -- if (dnet_gethostname && dnet_gethostbyname) -- return(1); -- if (!(handle = dlopen("/etc/openwin/lib/libdni.so",RTLD_NOW))) { -- if ((home = (char *)getenv("DNI_X_ENABLE")) == NULL) -- return(0); -- path = (char *)malloc(strlen(home) + 12); -- sprintf(path, "%s%s",home, "/libdni.so"); -- if (!(handle = dlopen(path,RTLD_NOW))) -- return(0); -- free(path); -- } -- if (!(dnet_gethostbyname = (struct hostent *(*)())dlsym(handle,"dni_gethostbyname"))) -- return(0); -- if (!(dnet_gethostname = (int (*)())dlsym(handle,"dni_gethostname"))) -- return(0); -- return(1); --} -+ debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket)); -+ UsingFD(ConnectionSocket, connectionFunc, NULL, NULL); - #endif --#endif /* USE_XTRANS */ -+} -+ -diff --git a/configure.ac b/configure.ac -index fd86a54..9f1a922 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -37,7 +37,12 @@ AM_MAINTAINER_MODE - - AM_CONFIG_HEADER(config.h) - -+# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG, XORG_WITH_LINT -+m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) -+XORG_MACROS_VERSION(1.2) -+ - AC_PROG_CC -+XORG_CWARNFLAGS - AC_PROG_INSTALL - - dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro -@@ -60,5 +65,9 @@ AC_SUBST(XSCOPE_LIBS) - - XORG_MANPAGE_SECTIONS - XORG_RELEASE_VERSION -+XORG_CHANGELOG -+ -+dnl Allow checking code with lint, sparse, etc. -+XORG_WITH_LINT - - AC_OUTPUT([Makefile]) -diff --git a/decode11.c b/decode11.c -index c3f5a15..1cd9d30 100644 ---- a/decode11.c -+++ b/decode11.c -@@ -55,6 +55,8 @@ - - #include "scope.h" - #include "x11.h" -+#include "extensions.h" -+#include "lbxscope.h" - - #ifdef SYSV - #define bzero(s,l) memset(s, 0, l) -@@ -96,6 +98,7 @@ struct QueueEntry - struct QueueEntry *Next; - long SequenceNumber; - short Request; -+ short RequestMinor; - }; - - /* free space list of Q entries */ -@@ -103,9 +106,11 @@ struct QueueEntry - static struct QueueEntry *FreeQEntries = NULL; - - /* ************************************************************ */ --static struct QueueEntry *NewQEntry (SequenceNumber, Request) -- long SequenceNumber; -- short Request; -+static struct QueueEntry * -+NewQEntry ( -+ long SequenceNumber, -+ short Request, -+ short RequestMinor) - { - struct QueueEntry *p; - -@@ -126,6 +131,7 @@ static struct QueueEntry *NewQEntry (SequenceNumber, Request) - p->Next = NULL; - p->SequenceNumber = SequenceNumber; - p->Request = Request; -+ p->RequestMinor = RequestMinor; - return(p); - } - /* ************************************************************ */ -@@ -143,7 +149,7 @@ static struct QueueHeader ReplyQ[StaticMaxFD]; - /* ************************************************************ */ - - void --InitReplyQ() -+InitReplyQ (void) - { - short i; - for (i = 0; i < StaticMaxFD; i++) -@@ -154,8 +160,8 @@ InitReplyQ() - } - - void --FlushReplyQ(fd) --FD fd; -+FlushReplyQ ( -+ FD fd) - { - struct QueueEntry *p; - struct QueueEntry *NextQEntry; -@@ -175,16 +181,18 @@ FD fd; - } - - static void --DumpReplyQ(fd) -- FD fd; -+DumpReplyQ ( -+ FD fd) - { -- fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n", -- fd, ReplyQ[fd].Head, ReplyQ[fd].Tail); -+ fprintf(stderr, "ReplyQ[%d] = { Head 0x%lx; Tail 0x%lx }\n", -+ fd, (unsigned long)ReplyQ[fd].Head, (unsigned long)ReplyQ[fd].Tail); - { - struct QueueEntry *p; - for (p = ReplyQ[fd].Head; p != NULL; p = p->Next) -- fprintf(stderr, "0x%x = { Next 0x%x; SequenceNumber %d; Request %d }\n", -- p, p->Next, p->SequenceNumber, p->Request); -+ fprintf(stderr, -+ "0x%lx = { Next 0x%lx; SequenceNumber %ld; Request %d }\n", -+ (unsigned long) p, (unsigned long) p->Next, -+ (unsigned long) p->SequenceNumber, p->Request); - } - } - /* ************************************************************ */ -@@ -196,17 +204,19 @@ DumpReplyQ(fd) - with this one */ - - static void --SequencedReplyExpected(fd, SequenceNumber, RequestType) -- FD fd; -- long SequenceNumber; -- short RequestType; -+SequencedReplyExpected ( -+ FD fd, -+ long SequenceNumber, -+ short RequestType, -+ short RequestMinorType) - { - 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 %ld 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); -@@ -219,21 +229,24 @@ 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)); -+ debug(8,(stderr, "Save sequence %ld 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 */ - --static short CheckReplyTable (fd, SequenceNumber) -- FD fd; -- short SequenceNumber; -+short -+CheckReplyTable ( -+ FD fd, -+ short SequenceNumber, -+ short *minorp) - { - struct QueueEntry *p; - struct QueueEntry *trailer; -@@ -250,6 +263,7 @@ static short CheckReplyTable (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) -@@ -263,8 +277,9 @@ static short CheckReplyTable (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); - } - } -@@ -280,12 +295,21 @@ static short CheckReplyTable (fd, SequenceNumber) - /* A reply is expected to the type of request given for the - sequence number associated with this fd */ - --static void --ReplyExpected(fd, Request) -- FD fd; -- short Request; -+void -+ReplyExpected ( -+ FD fd, -+ short Request) -+{ -+ SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, 0); -+} -+ -+void -+ExtendedReplyExpected ( -+ FD fd, -+ short Request, -+ short RequestMinor) - { -- SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request); -+ SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, RequestMinor); - } - - /* ************************************************************ */ -@@ -293,432 +317,484 @@ ReplyExpected(fd, Request) - /* This is only used with ListFontsWithInfo */ - - void --KeepLastReplyExpected() -+KeepLastReplyExpected (void) - { -- 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 const char * const simple_names[] = { -+ "REQUEST", -+ "REPLY ", -+ "EVENT ", -+ "ERROR ", -+}; -+ -+static void -+SimpleDump (int type, FD fd, short Major, short Minor, long bytes) -+{ -+ PrintTime (); -+ fprintf (stdout, "@@%s %3d %3d %3d %7ld\n", -+ simple_names[type], -+ ClientNumber(fd), -+ Major, Minor, bytes); -+} -+ - /* ************************************************************ */ - /* */ - /* */ - /* ************************************************************ */ - - void --DecodeRequest(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+DecodeRequest ( -+ FD fd, -+ const 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; -- 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); - -+ /* Special handling of QueryExtension to save extension names */ -+ if (Request == 98) -+ { -+ ProcessQueryExtensionRequest(seq, buf); -+ } -+ -+ if (Verbose < 0) -+ { -+ SimpleDump (DUMP_REQUEST, fd, Request, RequestMinor, n); -+ return; -+ } -+ - if (Raw || (Verbose > 3)) - DumpItem("Request", fd, buf, n); -- if (Request <= 0 || 127 < Request) -- warn("Extended request opcode"); -+ -+ if (Request < 0 || 127 < Request) -+ { -+ ExtensionRequest(fd, buf, Request); -+ } - else switch (Request) -- { -+ { - case 1: -- CreateWindow(buf); -+ CreateWindow(fd, buf); - break; - case 2: -- ChangeWindowAttributes(buf); -+ ChangeWindowAttributes(fd, buf); - break; - case 3: -- GetWindowAttributes(buf); -+ GetWindowAttributes(fd, buf); - ReplyExpected(fd, Request); - break; - case 4: -- DestroyWindow(buf); -+ DestroyWindow(fd, buf); - break; - case 5: -- DestroySubwindows(buf); -+ DestroySubwindows(fd, buf); - break; - case 6: -- ChangeSaveSet(buf); -+ ChangeSaveSet(fd, buf); - break; - case 7: -- ReparentWindow(buf); -+ ReparentWindow(fd, buf); - break; - case 8: -- MapWindow(buf); -+ MapWindow(fd, buf); - break; - case 9: -- MapSubwindows(buf); -+ MapSubwindows(fd, buf); - break; - case 10: -- UnmapWindow(buf); -+ UnmapWindow(fd, buf); - break; - case 11: -- UnmapSubwindows(buf); -+ UnmapSubwindows(fd, buf); - break; - case 12: -- ConfigureWindow(buf); -+ ConfigureWindow(fd, buf); - break; - case 13: -- CirculateWindow(buf); -+ CirculateWindow(fd, buf); - break; - case 14: -- GetGeometry(buf); -+ GetGeometry(fd, buf); - ReplyExpected(fd, Request); - break; - case 15: -- QueryTree(buf); -+ QueryTree(fd, buf); - ReplyExpected(fd, Request); - break; - case 16: -- InternAtom(buf); -+ InternAtom(fd, buf); - ReplyExpected(fd, Request); - break; - case 17: -- GetAtomName(buf); -+ GetAtomName(fd, buf); - ReplyExpected(fd, Request); - break; - case 18: -- ChangeProperty(buf); -+ ChangeProperty(fd, buf); - break; - case 19: -- DeleteProperty(buf); -+ DeleteProperty(fd, buf); - break; - case 20: -- GetProperty(buf); -+ GetProperty(fd, buf); - ReplyExpected(fd, Request); - break; - case 21: -- ListProperties(buf); -+ ListProperties(fd, buf); - ReplyExpected(fd, Request); - break; - case 22: -- SetSelectionOwner(buf); -+ SetSelectionOwner(fd, buf); - break; - case 23: -- GetSelectionOwner(buf); -+ GetSelectionOwner(fd, buf); - ReplyExpected(fd, Request); - break; - case 24: -- ConvertSelection(buf); -+ ConvertSelection(fd, buf); - break; - case 25: -- SendEvent(buf); -+ SendEvent(fd, buf); - break; - case 26: -- GrabPointer(buf); -+ GrabPointer(fd, buf); - ReplyExpected(fd, Request); - break; - case 27: -- UngrabPointer(buf); -+ UngrabPointer(fd, buf); - break; - case 28: -- GrabButton(buf); -+ GrabButton(fd, buf); - break; - case 29: -- UngrabButton(buf); -+ UngrabButton(fd, buf); - break; - case 30: -- ChangeActivePointerGrab(buf); -+ ChangeActivePointerGrab(fd, buf); - break; - case 31: -- GrabKeyboard(buf); -+ GrabKeyboard(fd, buf); - ReplyExpected(fd, Request); - break; - case 32: -- UngrabKeyboard(buf); -+ UngrabKeyboard(fd, buf); - break; - case 33: -- GrabKey(buf); -+ GrabKey(fd, buf); - break; - case 34: -- UngrabKey(buf); -+ UngrabKey(fd, buf); - break; - case 35: -- AllowEvents(buf); -+ AllowEvents(fd, buf); - break; - case 36: -- GrabServer(buf); -+ GrabServer(fd, buf); - break; - case 37: -- UngrabServer(buf); -+ UngrabServer(fd, buf); - break; - case 38: -- QueryPointer(buf); -+ QueryPointer(fd, buf); - ReplyExpected(fd, Request); - break; - case 39: -- GetMotionEvents(buf); -+ GetMotionEvents(fd, buf); - ReplyExpected(fd, Request); - break; - case 40: -- TranslateCoordinates(buf); -+ TranslateCoordinates(fd, buf); - ReplyExpected(fd, Request); - break; - case 41: -- WarpPointer(buf); -+ WarpPointer(fd, buf); - break; - case 42: -- SetInputFocus(buf); -+ SetInputFocus(fd, buf); - break; - case 43: -- GetInputFocus(buf); -+ GetInputFocus(fd, buf); - ReplyExpected(fd, Request); - break; - case 44: -- QueryKeymap(buf); -+ QueryKeymap(fd, buf); - ReplyExpected(fd, Request); - break; - case 45: -- OpenFont(buf); -+ OpenFont(fd, buf); - break; - case 46: -- CloseFont(buf); -+ CloseFont(fd, buf); - break; - case 47: -- QueryFont(buf); -+ QueryFont(fd, buf); - ReplyExpected(fd, Request); - break; - case 48: -- QueryTextExtents(buf); -+ QueryTextExtents(fd, buf); - ReplyExpected(fd, Request); - break; - case 49: -- ListFonts(buf); -+ ListFonts(fd, buf); - ReplyExpected(fd, Request); - break; - case 50: -- ListFontsWithInfo(buf); -+ ListFontsWithInfo(fd, buf); - ReplyExpected(fd, Request); - break; - case 51: -- SetFontPath(buf); -+ SetFontPath(fd, buf); - break; - case 52: -- GetFontPath(buf); -+ GetFontPath(fd, buf); - ReplyExpected(fd, Request); - break; - case 53: -- CreatePixmap(buf); -+ CreatePixmap(fd, buf); - break; - case 54: -- FreePixmap(buf); -+ FreePixmap(fd, buf); - break; - case 55: -- CreateGC(buf); -+ CreateGC(fd, buf); - break; - case 56: -- ChangeGC(buf); -+ ChangeGC(fd, buf); - break; - case 57: -- CopyGC(buf); -+ CopyGC(fd, buf); - break; - case 58: -- SetDashes(buf); -+ SetDashes(fd, buf); - break; - case 59: -- SetClipRectangles(buf); -+ SetClipRectangles(fd, buf); - break; - case 60: -- FreeGC(buf); -+ FreeGC(fd, buf); - break; - case 61: -- ClearArea(buf); -+ ClearArea(fd, buf); - break; - case 62: -- CopyArea(buf); -+ CopyArea(fd, buf); - break; - case 63: -- CopyPlane(buf); -+ CopyPlane(fd, buf); - break; - case 64: -- PolyPoint(buf); -+ PolyPoint(fd, buf); - break; - case 65: -- PolyLine(buf); -+ PolyLine(fd, buf); - break; - case 66: -- PolySegment(buf); -+ PolySegment(fd, buf); - break; - case 67: -- PolyRectangle(buf); -+ PolyRectangle(fd, buf); - break; - case 68: -- PolyArc(buf); -+ PolyArc(fd, buf); - break; - case 69: -- FillPoly(buf); -+ FillPoly(fd, buf); - break; - case 70: -- PolyFillRectangle(buf); -+ PolyFillRectangle(fd, buf); - break; - case 71: -- PolyFillArc(buf); -+ PolyFillArc(fd, buf); - break; - case 72: -- PutImage(buf); -+ PutImage(fd, buf); - break; - case 73: -- GetImage(buf); -+ GetImage(fd, buf); - ReplyExpected(fd, Request); - break; - case 74: -- PolyText8(buf); -+ PolyText8(fd, buf); - break; - case 75: -- PolyText16(buf); -+ PolyText16(fd, buf); - break; - case 76: -- ImageText8(buf); -+ ImageText8(fd, buf); - break; - case 77: -- ImageText16(buf); -+ ImageText16(fd, buf); - break; - case 78: -- CreateColormap(buf); -+ CreateColormap(fd, buf); - break; - case 79: -- FreeColormap(buf); -+ FreeColormap(fd, buf); - break; - case 80: -- CopyColormapAndFree(buf); -+ CopyColormapAndFree(fd, buf); - break; - case 81: -- InstallColormap(buf); -+ InstallColormap(fd, buf); - break; - case 82: -- UninstallColormap(buf); -+ UninstallColormap(fd, buf); - break; - case 83: -- ListInstalledColormaps(buf); -+ ListInstalledColormaps(fd, buf); - ReplyExpected(fd, Request); - break; - case 84: -- AllocColor(buf); -+ AllocColor(fd, buf); - ReplyExpected(fd, Request); - break; - case 85: -- AllocNamedColor(buf); -+ AllocNamedColor(fd, buf); - ReplyExpected(fd, Request); - break; - case 86: -- AllocColorCells(buf); -+ AllocColorCells(fd, buf); - ReplyExpected(fd, Request); - break; - case 87: -- AllocColorPlanes(buf); -+ AllocColorPlanes(fd, buf); - ReplyExpected(fd, Request); - break; - case 88: -- FreeColors(buf); -+ FreeColors(fd, buf); - break; - case 89: -- StoreColors(buf); -+ StoreColors(fd, buf); - break; - case 90: -- StoreNamedColor(buf); -+ StoreNamedColor(fd, buf); - break; - case 91: -- QueryColors(buf); -+ QueryColors(fd, buf); - ReplyExpected(fd, Request); - break; - case 92: -- LookupColor(buf); -+ LookupColor(fd, buf); - ReplyExpected(fd, Request); - break; - case 93: -- CreateCursor(buf); -+ CreateCursor(fd, buf); - break; - case 94: -- CreateGlyphCursor(buf); -+ CreateGlyphCursor(fd, buf); - break; - case 95: -- FreeCursor(buf); -+ FreeCursor(fd, buf); - break; - case 96: -- RecolorCursor(buf); -+ RecolorCursor(fd, buf); - break; - case 97: -- QueryBestSize(buf); -+ QueryBestSize(fd, buf); - ReplyExpected(fd, Request); - break; - case 98: -- QueryExtension(buf); -+ QueryExtension(fd, buf); - ReplyExpected(fd, Request); - break; - case 99: -- ListExtensions(buf); -+ ListExtensions(fd, buf); - ReplyExpected(fd, Request); - break; - case 100: -- ChangeKeyboardMapping(buf); -+ ChangeKeyboardMapping(fd, buf); - break; - case 101: -- GetKeyboardMapping(buf); -+ GetKeyboardMapping(fd, buf); - ReplyExpected(fd, Request); - break; - case 102: -- ChangeKeyboardControl(buf); -+ ChangeKeyboardControl(fd, buf); - break; - case 103: -- GetKeyboardControl(buf); -+ GetKeyboardControl(fd, buf); - ReplyExpected(fd, Request); - break; - case 104: -- Bell(buf); -+ Bell(fd, buf); - break; - case 105: -- ChangePointerControl(buf); -+ ChangePointerControl(fd, buf); - break; - case 106: -- GetPointerControl(buf); -+ GetPointerControl(fd, buf); - ReplyExpected(fd, Request); - break; - case 107: -- SetScreenSaver(buf); -+ SetScreenSaver(fd, buf); - break; - case 108: -- GetScreenSaver(buf); -+ GetScreenSaver(fd, buf); - ReplyExpected(fd, Request); - break; - case 109: -- ChangeHosts(buf); -+ ChangeHosts(fd, buf); - break; - case 110: -- ListHosts(buf); -+ ListHosts(fd, buf); - ReplyExpected(fd, Request); - break; - case 111: -- SetAccessControl(buf); -+ SetAccessControl(fd, buf); - break; - case 112: -- SetCloseDownMode(buf); -+ SetCloseDownMode(fd, buf); - break; - case 113: -- KillClient(buf); -+ KillClient(fd, buf); - break; - case 114: -- RotateProperties(buf); -+ RotateProperties(fd, buf); - break; - case 115: -- ForceScreenSaver(buf); -+ ForceScreenSaver(fd, buf); - break; - case 116: -- SetPointerMapping(buf); -+ SetPointerMapping(fd, buf); - ReplyExpected(fd, Request); - break; - case 117: -- GetPointerMapping(buf); -+ GetPointerMapping(fd, buf); - ReplyExpected(fd, Request); - break; - case 118: -- SetModifierMapping(buf); -+ SetModifierMapping(fd, buf); - ReplyExpected(fd, Request); - break; - case 119: -- GetModifierMapping(buf); -+ GetModifierMapping(fd, buf); - ReplyExpected(fd, Request); - break; - case 127: -- NoOperation(buf); -+ NoOperation(fd, buf); - break; - default: - warn("Unimplemented request opcode"); -@@ -732,26 +808,41 @@ DecodeRequest(fd, buf, n) - /* ************************************************************ */ - - void --DecodeReply(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+DecodeReply ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - short SequenceNumber = IShort (&buf[2]); -- short Request = CheckReplyTable (fd, SequenceNumber); -- if (Request == 0) -- { -- warn("Unexpected reply"); -- return; -- } -+ short RequestMinor; -+ short Request = CheckReplyTable (fd, SequenceNumber, &RequestMinor); -+ -+ /* Special handling of QueryExtension to save extension names */ -+ if (Request == 98) -+ { -+ ProcessQueryExtensionReply(SequenceNumber, buf); -+ } -+ -+ 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 (Raw || (Verbose > 3)) - DumpItem("Reply", fd, buf, n); -- if (Request <= 0 || 127 < Request) -- warn("Extended reply opcode"); -+ if (Request < 0 || 127 < Request) -+ { -+ ExtensionReply(fd, buf, Request, RequestMinor); -+ } - else switch (Request) - { -+ case 0: -+ UnknownReply(buf); -+ break; - case 3: - GetWindowAttributesReply(buf); - break; -@@ -884,74 +975,87 @@ DecodeReply(fd, buf, n) - /* ************************************************************ */ - - void --DecodeError(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+DecodeError ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- short Error = IByte (&buf[1]); -- SetIndentLevel(PRINTSERVER); -- if (Raw || (Verbose > 3)) -- DumpItem("Error", fd, buf, n); -- (void)CheckReplyTable (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 (Raw || (Verbose > 3)) -+ DumpItem("Error", fd, buf, n); -+ -+ if (Error < 1 || Error > 17) -+ { -+ ExtensionError(fd, buf, Error); -+ } -+ 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; - } - } - -@@ -961,120 +1065,137 @@ DecodeError(fd, buf, n) - /* ************************************************************ */ - - void --DecodeEvent(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+DecodeEvent ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- short Event = IByte (&buf[0]); -- SetIndentLevel(PRINTSERVER); -- if (Raw || (Verbose > 3)) -- DumpItem("Event", fd, buf, n); -- if (Event < 2 || Event > 34) -- warn("Extended Event code"); -- else switch (Event) -+ short Event = IByte (&buf[0]); -+ short EventMinor = Event == LBXEvent ? IByte (&buf[1]) : 0; -+ -+ if (Verbose < 0) - { -- 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; -+ SimpleDump (DUMP_EVENT, fd, Event, EventMinor, n); -+ return; -+ } -+ -+ SetIndentLevel(PRINTSERVER); -+ if (Raw || (Verbose > 3)) -+ DumpItem("Event", fd, buf, n); -+ /* high-order bit means SendEvent generated */ -+ if (Event & 0x80) -+ { -+ debug(8,(stderr, "SendEvent generated event 0x%x\n", Event)); -+ Event = Event & 0x7F; -+ } -+ -+ if (Event < 2 || Event > 34) -+ { -+ ExtensionEvent(fd, buf, Event); -+ } -+ 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..be0d597 ---- /dev/null -+++ b/decode_bigreq.c -@@ -0,0 +1,81 @@ -+/* -+ * $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 -+#include -+#include -+#include "scope.h" -+#include "x11.h" -+#include "bigreqscope.h" -+#include "extensions.h" -+ -+unsigned char BIGREQRequest; -+ -+void -+bigreq_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+bigreq_decode_reply ( -+ FD fd, -+ const unsigned char *buf, -+ short RequestMinor) -+{ -+ switch (RequestMinor) { -+ case 0: BigreqEnableReply (fd, buf); break; -+ } -+} -+ -+void -+InitializeBIGREQ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ BIGREQRequest = (unsigned char)(buf[9]); -+ -+ DefineEValue (&TD[REQUEST], (unsigned long) BIGREQRequest, "BigreqRequest"); -+ DefineEValue (&TD[REPLY], (unsigned long) BIGREQRequest, "BigreqReply"); -+ -+ p = DefineType(BIGREQREQUEST, ENUMERATED, "BIGREQREQUEST", (PrintProcType) PrintENUMERATED); -+ DefineEValue(p, 0L, "BigreqEnable"); -+ -+ p = DefineType(BIGREQREPLY, ENUMERATED, "BIGREQREPLY", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "BigreqEnable"); -+} -diff --git a/decode_lbx.c b/decode_lbx.c -new file mode 100644 -index 0000000..dd74657 ---- /dev/null -+++ b/decode_lbx.c -@@ -0,0 +1,152 @@ -+/* -+ * $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 -+#include -+#include -+#define _XLBX_SERVER_ -+#include "scope.h" -+#include "x11.h" -+#include "lbxscope.h" -+#include "extensions.h" -+ -+unsigned char LBXRequest, LBXEvent, LBXError; -+ -+void -+lbx_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+lbx_decode_reply ( -+ FD fd, -+ const unsigned char *buf, -+ short RequestMinor) -+{ -+ switch (RequestMinor) { -+ case 0: -+ LbxQueryVersionReply (fd, buf); -+ break; -+ default: -+ break; -+ } -+} -+ -+void -+lbx_decode_error ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ short error = IByte(&buf[1]) - LBXError; -+ -+ switch (error) { -+ case 0: -+ break; -+ default: -+ break; -+ } -+} -+ -+void -+lbx_decode_event ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+InitializeLBX ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ LBXRequest = (unsigned char)(buf[9]); -+ LBXEvent = (unsigned char)(buf[10]); -+ LBXError = (unsigned char)(buf[11]); -+ -+ 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", (PrintProcType) 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "QueryVersion"); -+ -+ p = DefineType(LBXEVENT, ENUMERATED, "LBXEVENT", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "SwitchEvent"); -+ DefineEValue (p, 1L, "CloseEvent"); -+} -diff --git a/decode_randr.c b/decode_randr.c -new file mode 100644 -index 0000000..b6a1ce3 ---- /dev/null -+++ b/decode_randr.c -@@ -0,0 +1,100 @@ -+/* -+ * $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 -+#include -+#include -+#define _RANDR_SERVER_ -+#include "scope.h" -+#include "x11.h" -+#include "randrscope.h" -+#include "extensions.h" -+ -+unsigned char RANDRRequest, RANDRError, RANDREvent; -+ -+void -+randr_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+randr_decode_reply ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+randr_decode_event ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ RandrScreenChangeNotifyEvent (buf); -+} -+ -+void -+InitializeRANDR ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ RANDRRequest = (unsigned char)(buf[9]); -+ RANDREvent = (unsigned char)(buf[10]); -+ RANDRError = (unsigned char)(buf[11]); -+ -+ 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue(p, 0L, "RandrQueryVersion"); -+ DefineEValue(p, 1L, "RandrGetScreenInfo"); -+ DefineEValue(p, 2L, "RandrSetScreenConfig"); -+ DefineEValue(p, 3L, "RandrScreenChangeSelectInput"); -+ -+ p = DefineType(RANDRREPLY, ENUMERATED, "RANDRREPLY", (PrintProcType) 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..e1f5c05 ---- /dev/null -+++ b/decode_render.c -@@ -0,0 +1,328 @@ -+/* -+ * $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 -+#include -+#include -+#define _RENDER_SERVER_ -+#include "scope.h" -+#include "x11.h" -+#include "renderscope.h" -+#include "extensions.h" -+ -+unsigned char RENDERRequest, RENDERError; -+ -+void -+render_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+render_decode_reply ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+render_decode_error ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ short error = IByte(&buf[1]) - 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; -+ } -+} -+ -+static int -+PrintPICTURE ( -+ const unsigned char *buf) -+{ -+ /* print a WINDOW -- CARD32 plus 0 = None */ -+ long n = ILong (buf); -+ if (n == 0) -+ fprintf(stdout, "None"); -+ else -+ fprintf(stdout, "PICTURE %08lx", n); -+ return(4); -+} -+ -+static int -+PrintPICTFORMAT ( -+ const unsigned char *buf) -+{ -+ /* print a WINDOW -- CARD32 plus 0 = None */ -+ long n = ILong (buf); -+ if (n == 0) -+ fprintf(stdout, "None"); -+ else -+ fprintf(stdout, "PICTFORMAT %08lx", n); -+ return(4); -+} -+ -+static int -+PrintPICTFORMINFO ( -+ const unsigned char *buf) -+{ -+ /* print a PictFormInfo */ -+ long n = ILong(buf); -+ short t = IByte(buf+4); -+ short d = IByte(buf+5); -+ -+ fprintf (stdout, "PICTFORMINFO %08lx %s %d ", -+ n, t == 0 ? "Indexed" : "Direct", d); -+ if (t == 0) { -+ long c = ILong(buf+20); -+ fprintf (stdout, "cmap %08lx", c); -+ } else { -+ short r = IShort(buf+8); -+ short g = IShort(buf+12); -+ short b = IShort(buf+16); -+ short a = IShort(buf+20); -+ fprintf (stdout, "%d %d %d %d", a, r, g, b); -+ } -+ return(28); -+} -+ -+static int -+PrintGLYPHSET ( -+ const unsigned char *buf) -+{ -+ /* print a GLYPHSET -- CARD32 plus 0 = None */ -+ long n = ILong (buf); -+ if (n == 0) -+ fprintf(stdout, "None"); -+ else -+ fprintf(stdout, "GLYPHSET %08lx", n); -+ return(4); -+} -+ -+static int -+PrintRENDERCOLOR ( -+ const 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); -+} -+ -+static int -+PrintFIXED ( -+ const unsigned char *buf) -+{ -+ /* print a PICTURE */ -+ long n = ILong (buf); -+ fprintf (stdout, "FIXED %7.2f", n / 65536.0); -+ return 4; -+} -+ -+static int -+PrintPOINTFIXED ( -+ const unsigned char *buf) -+{ -+ long x = ILong (buf); -+ long y = ILong (buf+4); -+ fprintf (stdout, "POINT %7.2f, %7.2f", x / 65536.0, y / 65536.0); -+ return 8; -+} -+ -+static int -+PrintTRAPEZOID ( -+ const unsigned char *buf) -+{ -+ /* print a TRAPEZOID */ -+ PrintField (buf, 0, 4, FIXED, "top"); -+ PrintField (buf, 4, 4, FIXED, "bottom"); -+ PrintField (buf, 8, 8, POINTFIXED, "left top"); -+ PrintField (buf, 16, 8, POINTFIXED, "left bottom"); -+ PrintField (buf, 24, 8, POINTFIXED, "right top"); -+ PrintField (buf, 32, 8, POINTFIXED, "right bottom"); -+ return 40; -+} -+ -+static int -+PrintTRIANGLE ( -+ const unsigned char *buf) -+{ -+ /* print a TRIANGLE */ -+ PrintField (buf, 0, 8, POINTFIXED, "p1"); -+ PrintField (buf, 8, 8, POINTFIXED, "p2"); -+ PrintField (buf,16, 8, POINTFIXED, "p3"); -+ return 24; -+} -+ -+void -+InitializeRENDER ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ RENDERRequest = (unsigned char)(buf[9]); -+ RENDERError = (unsigned char)(buf[11]); -+ -+ DefineEValue (&TD[REQUEST], (unsigned long) RENDERRequest, "RenderRequest"); -+ DefineEValue (&TD[REPLY], (unsigned long) RENDERRequest, "RenderReply"); -+ -+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 0, "BadPictFormat"); -+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 1, "BadPicture"); -+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 2, "BadPictOp"); -+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 3, "BadGlyphSet"); -+ DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 4, "BadGlyph"); -+ -+ p = DefineType(RENDERREQUEST, ENUMERATED, "RENDERREQUEST", (PrintProcType) 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "QueryVersion"); -+ DefineEValue (p, 1L, "QueryPictFormats"); -+ DefineEValue (p, 2L, "QueryPictIndexValues"); -+ DefineEValue (p, 3L, "QueryDithers"); -+ -+ DefineType(PICTURE, BUILTIN, "PICTURE", PrintPICTURE); -+ DefineType(PICTFORMAT, BUILTIN, "PICTFORMAT", PrintPICTFORMAT); -+ DefineType(GLYPHSET, BUILTIN, "GLYPHSET", PrintGLYPHSET); -+ DefineType(RENDERCOLOR, BUILTIN, "RENDERCOLOR", PrintRENDERCOLOR); -+ DefineType(PICTFORMINFO, BUILTIN, "PICTFORMINFO", PrintPICTFORMINFO); -+ -+ p = DefineType(PICTURE_BITMASK, SET, "PICTURE_BITMASK", (PrintProcType) 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", (PrintProcType) 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"); -+ -+ DefineType(FIXED, BUILTIN, "FIXED", PrintFIXED); -+ DefineType(POINTFIXED, BUILTIN, "POINTFIXED", PrintPOINTFIXED); -+ DefineType(TRIANGLE, RECORD, "TRIANGLE", PrintTRIANGLE); -+ DefineType(TRAPEZOID, RECORD, "TRAPEZOID", PrintTRAPEZOID); -+} -diff --git a/decode_shm.c b/decode_shm.c -new file mode 100644 -index 0000000..938c770 ---- /dev/null -+++ b/decode_shm.c -@@ -0,0 +1,119 @@ -+/* -+ * $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 -+#include -+#include -+#include "scope.h" -+#include "x11.h" -+#include "shmscope.h" -+#include "extensions.h" -+ -+unsigned char MITSHMRequest, MITSHMError, MITSHMEvent; -+ -+void -+mitshm_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+mitshm_decode_reply ( -+ FD fd, -+ const unsigned char *buf, -+ short RequestMinor) -+{ -+ switch (RequestMinor) { -+ case 0: MitshmQueryVersionReply (fd, buf); break; -+ case 4: MitshmGetImageReply (fd, buf); break; -+ } -+} -+ -+void -+mitshm_decode_event ( -+ FD fd, -+ const unsigned char *buf) -+{ -+} -+ -+void -+mitshm_decode_error ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ short error = IByte(&buf[0]) - MITSHMError; -+ -+ switch (error) { -+ case 0: MitshmShmSegError (fd, buf); break; -+ default: -+ break; -+ } -+} -+ -+ -+void -+InitializeMITSHM ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ MITSHMRequest = (unsigned char)(buf[9]); -+ MITSHMEvent = (unsigned char)(buf[10]); -+ MITSHMError = (unsigned char)(buf[11]); -+ -+ 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", (PrintProcType) 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "QueryVersion"); -+ DefineEValue (p, 4L, "GetImage"); -+ -+ p = DefineType(MITSHMEVENT, ENUMERATED, "MITSHMEVENT", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "CompletionEvent"); -+} -diff --git a/decode_wcp.c b/decode_wcp.c -new file mode 100644 -index 0000000..fdb7664 ---- /dev/null -+++ b/decode_wcp.c -@@ -0,0 +1,132 @@ -+/* -+ * $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 -+#include -+#include -+#define _WCP_SERVER_ -+#include "scope.h" -+#include "x11.h" -+#include "wcpscope.h" -+#include "extensions.h" -+ -+unsigned char WCPRequest, WCPError; -+ -+void -+wcp_decode_req ( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+wcp_decode_reply ( -+ FD fd, -+ const unsigned char *buf, -+ short RequestMinor) -+{ -+ switch (RequestMinor) { -+ case 0: -+ WcpQueryVersionReply (fd, buf); -+ break; -+ case 2: -+ WcpGetImageReply (fd, buf); -+ break; -+ default: -+ break; -+ } -+} -+ -+void -+wcp_decode_error ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ short error = IByte(&buf[1]) - WCPError; -+ -+ switch (error) { -+ case 0: -+ break; -+ default: -+ break; -+ } -+} -+ -+void -+InitializeWCP ( -+ const unsigned char *buf) -+{ -+ TYPE p; -+ -+ WCPRequest = (unsigned char)(buf[9]); -+ WCPError = (unsigned char)(buf[11]); -+ -+ 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", (PrintProcType) 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue (p, 0L, "QueryVersion"); -+ -+} -diff --git a/decodenas.c b/decodenas.c -new file mode 100644 -index 0000000..befa2eb ---- /dev/null -+++ b/decodenas.c -@@ -0,0 +1,470 @@ -+/* ************************************************************ * -+ * * -+ * 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 const char * const simple_names[] = { -+ "REQUEST", -+ "REPLY ", -+ "EVENT ", -+ "ERROR ", -+}; -+ -+static void -+AudioSimpleDump (int type, FD fd, short Major, short Minor, long bytes) -+{ -+ PrintTime (); -+ fprintf (stdout, "@@%s %3d %3d %3d %7ld\n", -+ simple_names[type], -+ ClientNumber(fd), -+ Major, Minor, bytes); -+} -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+void -+DecodeAudioRequest( -+ FD fd, -+ const 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; -+ } -+} -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+void -+DecodeAudioReply( -+ FD fd, -+ const 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 (buf); -+ 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; -+ } -+} -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+void -+DecodeAudioError( -+ FD fd, -+ const 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); -+} -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+void -+DecodeAudioEvent( -+ FD fd, -+ const 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; -+ } -+} -+ -+void -+InitializeAudioDecode (void) -+{ -+ TYPE p; -+ -+ p = DefineType (NASREQUEST, ENUMERATED, "NASREQUEST", (PrintProcType) 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", (PrintProcType) 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", (PrintProcType) PrintENUMERATED); -+ DefineEValue(p, 2L, "ElementNotify"); -+ DefineEValue(p, 3L, "GrabNotify"); -+ DefineEValue(p, 4L, "MonitorNotify"); -+ DefineEValue(p, 5L, "BucketNotify"); -+ DefineEValue(p, 6L, "DeviceNotify"); -+ -+} -diff --git a/extensions.c b/extensions.c -new file mode 100644 -index 0000000..d053c06 ---- /dev/null -+++ b/extensions.c -@@ -0,0 +1,233 @@ -+/* -+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, and/or sell copies of the Software, and to permit persons -+ * to whom the Software is furnished to do so, provided that the above -+ * copyright notice(s) and this permission notice appear in all copies of -+ * the Software and that both the above copyright notice(s) and this -+ * permission notice appear in supporting documentation. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. -+ * -+ * Except as contained in this notice, the name of a copyright holder -+ * shall not be used in advertising or otherwise to promote the sale, use -+ * or other dealings in this Software without prior written authorization -+ * of the copyright holder. -+ */ -+ -+#include "extensions.h" -+#include "bigreqscope.h" -+#include "lbxscope.h" -+#include "randrscope.h" -+#include "renderscope.h" -+#include "shmscope.h" -+#include "wcpscope.h" -+ -+/* Extensions we know how to decode */ -+struct extension_decoders { -+ const char *name; -+ void (*init_func)(const unsigned char *buf); -+}; -+ -+static const struct extension_decoders decodable_extensions[] = { -+ { "BIG-REQUESTS", InitializeBIGREQ }, -+ { "LBX", InitializeLBX }, -+ { "MITSHM", InitializeMITSHM }, -+ { "NCD-WinCenterPro", InitializeWCP }, -+ { "RANDR", InitializeRANDR }, -+ { "RENDER", InitializeRENDER }, -+ { NULL, NULL } /* List terminator - keep last */ -+}; -+ -+/* all extensions we know about */ -+struct extension_info { -+ const char *name; -+ unsigned char request; -+ unsigned char event; -+ unsigned char error; -+ long query_seq; /* sequence id of QueryExtension request */ -+ struct extension_info *next; -+}; -+ -+struct extension_info *query_list; -+ -+struct extension_info *ext_by_request[NUM_EXTENSIONS]; -+ -+static void -+DefineExtNameValue(int type, unsigned char value, const char *extname) -+{ -+ int namelen = strlen(extname) + 1; -+ const char *typename = NULL; -+ char *exttypename; -+ -+ switch (type) { -+ case REQUEST: -+ typename = "-Request"; -+ break; -+ case REPLY: -+ typename = "-Reply"; -+ break; -+ case EVENT: -+ typename = "-Event"; -+ break; -+ case ERROR: -+ typename = "-Error"; -+ break; -+ default: -+ panic("Impossible argument to DefineExtNameValue"); -+ } -+ namelen += strlen(typename); -+ exttypename = Malloc(namelen); -+ snprintf(exttypename, namelen, "%s%s", extname, typename); -+ DefineEValue(&TD[type], (unsigned long) value, exttypename); -+} -+ -+void -+ProcessQueryExtensionRequest(long seq, const unsigned char *buf) -+{ -+ int namelen = IShort(&buf[4]); -+ char *extname = Malloc(namelen + 1); -+ struct extension_info *qe; -+ -+ memcpy(extname, &buf[8], namelen); -+ extname[namelen] = '\0'; -+ -+ for (qe = query_list; qe != NULL; qe = qe->next) { -+ if (strcmp(extname, qe->name) == 0) { -+ /* already in list, no need to add */ -+ Free(extname); -+ return; -+ } -+ } -+ -+ /* add to list */ -+ qe = Malloc(sizeof(struct extension_info)); -+ qe->name = extname; -+ qe->request = 0; -+ qe->event = 0; -+ qe->error = 0; -+ qe->query_seq = seq; -+ qe->next = query_list; -+ query_list = qe; -+} -+ -+void -+ProcessQueryExtensionReply(long seq, const unsigned char *buf) -+{ -+ struct extension_info *qe; -+ int i; -+ -+ for (qe = query_list; qe != NULL; qe = qe->next) { -+ if (qe->query_seq == seq) { -+ qe->request = buf[9]; -+ qe->event = buf[10]; -+ qe->error = buf[11]; -+ -+ ext_by_request[qe->request - EXTENSION_MIN] = qe; -+ -+ for (i = 0; decodable_extensions[i].name != NULL ; i++) { -+ if (strcmp(qe->name, decodable_extensions[i].name) == 0) { -+ decodable_extensions[i].init_func(buf); -+ break; -+ } -+ } -+ if (decodable_extensions[i].name == NULL) { -+ /* Not found - initialize values as best we can generically */ -+ DefineExtNameValue(REQUEST, qe->request, qe->name); -+ DefineExtNameValue(REPLY, qe->request, qe->name); -+ if (qe->event != 0) { -+ DefineExtNameValue(EVENT, qe->event, qe->name); -+ } -+ if (qe->error != 0) { -+ DefineExtNameValue(ERROR, qe->error, qe->name); -+ } -+ } -+ -+ return; -+ } -+ } -+} -+ -+void -+ExtensionRequest (FD fd, const unsigned char *buf, short Request) -+{ -+ 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 if (Request == MITSHMRequest) { -+ mitshm_decode_req(fd,buf); -+ } else if (Request == BIGREQRequest) { -+ bigreq_decode_req(fd,buf); -+ } else { -+ ExtendedRequest(fd, buf); -+ ReplyExpected(fd, Request); -+ } -+} -+ -+void -+ExtensionReply (FD fd, const unsigned char *buf, -+ short Request, short RequestMinor) -+{ -+ 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 == MITSHMRequest) { -+ mitshm_decode_reply(fd, buf, RequestMinor); -+ } else if (Request == BIGREQRequest) { -+ bigreq_decode_reply(fd, buf, RequestMinor); -+ } else { -+ warn("Extended reply opcode"); -+ } -+} -+ -+void -+ExtensionError (FD fd, const unsigned char *buf, short Error) -+{ -+ 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 == MITSHMError) { -+ mitshm_decode_error(fd, buf); -+ } else { -+ warn("Extended Error code"); -+ } -+} -+ -+void -+ExtensionEvent (FD fd, const unsigned char *buf, short Event) -+{ -+ if (Event == LBXEvent) { -+ lbx_decode_event (fd, buf); -+ } else if (Event == RANDREvent) { -+ randr_decode_event (fd, buf); -+ } else if (Event == MITSHMEvent) { -+ mitshm_decode_event (fd, buf); -+ } else { -+ warn("Extended Event code"); -+ } -+} -diff --git a/extensions.h b/extensions.h -new file mode 100644 -index 0000000..18107e8 ---- /dev/null -+++ b/extensions.h -@@ -0,0 +1,72 @@ -+/* -+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the -+ * "Software"), to deal in the Software without restriction, including -+ * without limitation the rights to use, copy, modify, merge, publish, -+ * distribute, and/or sell copies of the Software, and to permit persons -+ * to whom the Software is furnished to do so, provided that the above -+ * copyright notice(s) and this permission notice appear in all copies of -+ * the Software and that both the above copyright notice(s) and this -+ * permission notice appear in supporting documentation. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR -+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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. -+ * -+ * Except as contained in this notice, the name of a copyright holder -+ * shall not be used in advertising or otherwise to promote the sale, use -+ * or other dealings in this Software without prior written authorization -+ * of the copyright holder. -+ */ -+ -+#ifndef XSCOPE_EXTENSIONS_H -+#define XSCOPE_EXTENSIONS_H -+ -+#include "scope.h" -+ -+#define EXTENSION_MIN 128 /* lowest possible extension request code */ -+#define EXTENSION_MAX 255 /* highest possible extension request code */ -+#define NUM_EXTENSIONS 128 /* maximum possible number of extensions */ -+ -+/* special processing in extensions.c to capture extension info */ -+extern void ProcessQueryExtensionRequest(long seq, const unsigned char *buf); -+extern void ProcessQueryExtensionReply(long seq, const unsigned char *buf); -+ -+extern void ExtensionRequest(FD fd, const unsigned char *buf, short Request); -+extern void ExtensionReply(FD fd, const unsigned char *buf, -+ short Request, short RequestMinor); -+extern void ExtensionError(FD fd, const unsigned char *buf, short Error); -+extern void ExtensionEvent(FD fd, const unsigned char *buf, short Event); -+ -+ -+/* X11 Extension decoders in decode_*.c */ -+#define extension_decode_prototypes(ext) \ -+ extern void ext##_decode_req (FD fd, const unsigned char *buf); \ -+ extern void ext##_decode_reply (FD fd, const unsigned char *buf, \ -+ short RequestMinor); \ -+ extern void ext##_decode_error (FD fd, const unsigned char *buf); \ -+ extern void ext##_decode_event (FD fd, const unsigned char *buf) -+ -+extension_decode_prototypes(bigreq); -+extension_decode_prototypes(lbx); -+extension_decode_prototypes(mitshm); -+extension_decode_prototypes(randr); -+extension_decode_prototypes(render); -+extension_decode_prototypes(wcp); -+ -+extern void InitializeBIGREQ (const unsigned char *buf); -+extern void InitializeLBX (const unsigned char *buf); -+extern void InitializeMITSHM (const unsigned char *buf); -+extern void InitializeRANDR (const unsigned char *buf); -+extern void InitializeRENDER (const unsigned char *buf); -+extern void InitializeWCP (const unsigned char *buf); -+ -+#endif /* XSCOPE_EXTENSIONS_H */ -diff --git a/fd.c b/fd.c -index 616dc9c..69a00ee 100644 ---- a/fd.c -+++ b/fd.c -@@ -53,6 +53,9 @@ - * - \* *********************************************************** */ - -+#include /* for XFD_* macros - must come before -+ scope.h include to avoid INT32 clash */ -+ - #include "scope.h" - - #ifdef SYSV -@@ -62,6 +65,20 @@ - #define bcopy(s,d,l) memmove(d,s,l) - #endif - -+#include /* for struct iovec, used by socket.h */ -+#include /* for AF_INET, SOCK_STREAM, ... */ -+#include /* for FIONCLEX, FIONBIO, ... */ -+#ifdef SVR4 -+#include -+#endif -+#include -+#include /* struct sockaddr_in */ -+#include /* struct sockaddr_un */ -+#include -+#include /* struct servent * and struct hostent * */ -+#include /* for EINTR, EADDRINUSE, ... */ -+ -+ - /* - All of this code is to support the handling of file descriptors (FD). - The idea is to keep a table of the FDs that are in use and why. -@@ -77,16 +94,25 @@ - /* ************************************************************ */ - - void --InitializeFD() -+InitializeFD(void) - { - register short i; - - 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(); - if (MaxFD > FD_SETSIZE) { - MaxFD = FD_SETSIZE; - } -+#endif -+ if (MaxFD > StaticMaxFD) -+ { -+ fprintf(stderr, "Recompile with larger StaticMaxFD value %d\n", MaxFD); -+ MaxFD = StaticMaxFD; -+ } - - /* allocate space for a File Descriptor (FD) Table */ - FDD = (struct FDDescriptor *) -@@ -113,18 +139,19 @@ InitializeFD() - FD_ZERO(&ReadDescriptors); - HighestFD = 0; - -- UsingFD(fileno(stdin), (void (*)(int))NULL, NULL); -- UsingFD(fileno(stdout), (void (*)(int))NULL, NULL); -- UsingFD(fileno(stderr), (void (*)(int))NULL, NULL); -+ UsingFD(fileno(stdin), NULL, NULL, NULL); -+ UsingFD(fileno(stdout), NULL, NULL, NULL); -+ UsingFD(fileno(stderr), NULL, NULL, NULL); - } - - /* ************************************************************ */ - - void --UsingFD(fd, Handler, trans_conn) -- FD fd; -- void (*Handler)(int); -- XtransConnInfo trans_conn; -+UsingFD( -+ FD fd, -+ void (*Handler)(int), -+ void (*FlushHandler)(int), -+ XtransConnInfo trans_conn) - { - if (FDD[fd].Busy) - NotUsingFD(fd); -@@ -132,6 +159,7 @@ UsingFD(fd, Handler, trans_conn) - - FDD[fd].Busy = true; - FDD[fd].InputHandler = Handler; -+ FDD[fd].FlushHandler = FlushHandler; - #ifdef USE_XTRANS - FDD[fd].trans_conn = trans_conn; - #endif -@@ -152,8 +180,8 @@ UsingFD(fd, Handler, trans_conn) - /* ************************************************************ */ - - void --NotUsingFD(fd) -- FD fd; -+NotUsingFD( -+ FD fd) - { - debug(128,(stderr, "Not Using FD %d\n", fd)); - -@@ -181,8 +209,8 @@ XtransConnInfo GetXTransConnInfo(FD fd) - /* ************************************************************ */ - - static void --EOFonFD(fd) -- FD fd; -+EOFonFD ( -+ FD fd) - { - enterprocedure("EOFonFD"); - debug(128,(stderr, "EOF on %d\n", fd)); -@@ -195,16 +223,189 @@ EOFonFD(fd) - NotUsingFD(fd); - } - -+FD -+AcceptConnection ( -+ FD ConnectionSocket) -+{ -+ 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( -+ char *server, -+ short port, -+ int report, -+ XtransConnInfo *trans_conn /* transport connection object */ -+ ) -+{ -+ FD ServerFD; -+#ifdef USE_XTRANS -+ char address[256]; -+ int connect_stat; -+ -+ snprintf (address, sizeof(address), "%s:%ld", server, port - ServerBasePort); -+ if ( (*trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) { -+ debug(1,(stderr, "OpenCOTSClient failed\n")); -+ panic("Can't open connection to Server"); -+ } -+ if ((connect_stat = _X11TransConnect(*trans_conn,address)) < 0 ) { -+ _X11TransClose(*trans_conn); -+ *trans_conn = NULL; -+ debug(1,(stderr, "TransConnect failed\n")); -+ panic("Can't open connection to Server"); -+ } - -+ ServerFD = _X11TransGetConnectionNumber(*trans_conn); -+#else /* !USE_XTRANS */ -+ char HostName[512]; -+ struct sockaddr_in sin; -+ struct sockaddr_un sun; -+ struct sockaddr *saddr; -+ int salen; -+ 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 */ -+ /* determine the host machine for this process */ -+ if (*server == '\0') -+ { -+ sun.sun_family = AF_UNIX; -+ sprintf (sun.sun_path, "/tmp/.X11-unix/X%d", port - 6000); -+ salen = sizeof (sun.sun_family) + strlen (sun.sun_path) + 1; -+ saddr = (struct sockaddr *) &sun; -+ } -+ else -+ { -+ debug(4,(stderr, "try to connect on %s\n", server)); -+ -+ bzero((char *)&sin, sizeof(sin)); -+ 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); -+ salen = sizeof (sin); -+ saddr = (struct sockaddr *) &sin; -+ } -+ -+ ServerFD = socket(saddr->sa_family, 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 */ -+ -+ /* ******************************************************** */ -+ /* try to connect to Server */ -+ -+ if (connect(ServerFD, saddr, salen) < 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"); -+ } -+ } -+#endif /* USE_XTRANS */ -+ -+ debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); -+ return(ServerFD); -+} -+ - /* ************************************************************ */ - /* */ - /* Main Loop -- wait for input from any source and Process */ - /* */ - /* ************************************************************ */ - --#include /* for EINTR, EADDRINUSE, ... */ --extern int errno; -- - int - MainLoop(void) - { -@@ -212,19 +413,33 @@ MainLoop(void) - - while (true) - { -- fd_set rfds, xfds; -+ fd_set rfds, wfds, xfds; - short nfds; - short fd; - - /* wait for something */ -+ -+ /* rfds = ReadDescriptors & ~BlockedReadDescriptors; */ - rfds = ReadDescriptors; -+ XFD_UNSET(&rfds, &BlockedReadDescriptors); -+ - xfds = rfds; - -+ /* wfds = ReadDescriptors & WriteDescriptors; */ -+ XFD_ANDSET(&wfds, &ReadDescriptors, &WriteDescriptors); -+ -+ - debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds)); -- nfds = select(HighestFD + 1, (struct fd_set *) &rfds, -- (struct fd_set *) NULL, (struct fd_set *) &xfds, NULL); -- debug(128,(stderr, "select nfds = 0%o, rfds = 0%o, xfds 0%o\n", -- nfds, rfds, xfds)); -+ if (Interrupt || (!XFD_ANYSET(&rfds) && !XFD_ANYSET(&wfds))) -+ { -+ ReadCommands (); -+ Interrupt = 0; -+ continue; -+ } -+ nfds = select(HighestFD + 1, &rfds, &wfds, &xfds, (struct timeval *)NULL); -+ debug(128,(stderr, -+ "select nfds = 0%o, rfds = 0%o, wfds = 0%o, xfds = 0%o\n", -+ nfds, rfds, wfds, xfds)); - - if (nfds < 0) - { -@@ -239,7 +454,15 @@ MainLoop(void) - continue; - } - -- panic("Select returns error"); -+ if (Interrupt) -+ { -+ ReadCommands (); -+ Interrupt = 0; -+ } -+ else -+ { -+ panic("Select returns error"); -+ } - continue /* to end of while loop */ ; - } - -@@ -250,25 +473,32 @@ MainLoop(void) - } - - /* 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) == 0) -- continue; -- -- nfds -= 1; -- -- if (FDD[fd].InputHandler == NULL) -+ if (FD_ISSET(fd,&rfds)) -+ { -+ 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 (FD_ISSET(fd,&wfds)) -+ { -+ if (FDD[fd].FlushHandler == NULL) - { -- panic("FD selected with no handler"); -- debug(1,(stderr, "FD %d has NULL handler\n", fd)); -+ panic("FD selected with no flush handler"); - } -- else -- (FDD[fd].InputHandler)(fd); -+ else -+ (FDD[fd].FlushHandler)(fd); -+ } - } - } - return 0; -diff --git a/fd.h b/fd.h -index 51caf68..bd4f262 100644 ---- a/fd.h -+++ b/fd.h -@@ -53,6 +53,8 @@ - * - ********************************************** */ - -+#ifndef XSCOPE_FD_H -+#define XSCOPE_FD_H - - /* - the following structure remembers for each file descriptor its -@@ -74,25 +76,39 @@ typedef int FD; - struct FDDescriptor - { - Boolean Busy; -- void (*InputHandler)(int); -+ void (*InputHandler)(int); -+ void (*FlushHandler)(int); - #ifdef USE_XTRANS - XtransConnInfo trans_conn; - #endif - }; - --struct FDDescriptor *FDD /* array of FD descriptors */ ; --int MaxFD /* maximum number of FD's possible */ ; --int nFDsInUse /* number of FD's actually in use */ ; --fd_set ReadDescriptors /* bit map of FD's in use -- for select */ ; --int HighestFD /* highest FD in use -- for select */ ; -+extern struct FDDescriptor *FDD /* array of FD descriptors */ ; -+extern short MaxFD /* maximum number of FD's possible */ ; -+ -+extern short nFDsInUse /* number of FD's actually in use */ ; -+ -+extern fd_set ReadDescriptors /* bit map of FD's in use -- for select */ ; -+extern fd_set WriteDescriptors /* bit map of write blocked FD's -- for select */; -+extern fd_set BlockedReadDescriptors /* bit map of FD's blocked from reading */; -+extern short HighestFD /* highest FD in use -- for select */ ; - - /* need to change the MaxFD to allow larger number of fd's */ - #define StaticMaxFD FD_SETSIZE - - extern void InitializeFD(void); --extern void UsingFD(FD fd, void (*Handler)(int), XtransConnInfo trans_conn); -+extern void UsingFD(FD fd, void (*Handler)(int), void (*FlushHandler)(int), -+ XtransConnInfo trans_conn); - extern void NotUsingFD(FD fd); -+ -+extern FD AcceptConnection (FD ConnectionSocket); -+extern FD MakeConnection (char *server, short port, int report, -+ XtransConnInfo *trans_conn); -+ - extern int MainLoop(void); -+ - #ifdef USE_XTRANS - extern XtransConnInfo GetXTransConnInfo(FD fd); - #endif -+ -+#endif /* XSCOPE_FD_H */ -diff --git a/lbxscope.h b/lbxscope.h -new file mode 100644 -index 0000000..cf2d5e2 ---- /dev/null -+++ b/lbxscope.h -@@ -0,0 +1,58 @@ -+/* $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 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) -+ -+extern unsigned char LBXRequest; -+extern unsigned char LBXError; -+extern unsigned char LBXEvent; -+ -+extern void LbxQueryVersion (FD fd, const unsigned char *buf); -+extern void LbxQueryVersionReply (FD fd, const unsigned char *buf); -+extern void LbxStartProxy (FD fd, const unsigned char *buf); -+extern void LbxStopProxy (FD fd, const unsigned char *buf); -+extern void LbxNewClient (FD fd, const unsigned char *buf); -+extern void LbxCloseClient (FD fd, const unsigned char *buf); -+extern void LbxSwitch (FD fd, const unsigned char *buf); -+extern void LbxModifySequence (FD fd, const unsigned char *buf); -+extern void LbxSwitchEvent (FD fd, const unsigned char *buf); -+extern void LbxCloseEvent (FD fd, const unsigned char *buf); -+ -+#endif -+ -diff --git a/nas.h b/nas.h -new file mode 100644 -index 0000000..04d169f ---- /dev/null -+++ b/nas.h -@@ -0,0 +1,199 @@ -+/* ************************************************************ * -+ * * -+ * 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. -+*/ -+ -+/* audio.c */ -+extern void NewAudio (FD fd); -+extern void InitializeAudio (void); -+ -+/* decodenas.c */ -+extern void DecodeAudioRequest (FD fd, const unsigned char *buf, long n); -+extern void DecodeAudioReply (FD fd, const unsigned char *buf, long n); -+extern void DecodeAudioEvent (FD fd, const unsigned char *buf, long n); -+extern void DecodeAudioError (FD fd, const unsigned char *buf, long n); -+ -+extern void InitializeAudioDecode (void); -+ -+/* printnas.c */ -+extern void PrintAudioSetUpMessage (const unsigned char *buf); -+extern void PrintAudioSetUpReply (const unsigned char *buf); -+extern void AudioElementNotify (const unsigned char *buf); -+extern void AudioGrabNotify (const unsigned char *buf); -+extern void AudioMonitorNotify (const unsigned char *buf); -+extern void AudioBucketNotify (const unsigned char *buf); -+extern void AudioDeviceNotify (const unsigned char *buf); -+extern void UnknownAudioReply (const unsigned char *buf); -+extern void AudioListDevices (const unsigned char *buf); -+extern void AudioListDevicesReply (const unsigned char *buf); -+extern void AudioGetDeviceAttributes (const unsigned char *buf); -+extern void AudioGetDeviceAttributesReply (const unsigned char *buf); -+extern void AudioSetDeviceAttributes (const unsigned char *buf); -+extern void AudioCreateBucket (const unsigned char *buf); -+extern void AudioDestroyBucket (const unsigned char *buf); -+extern void AudioListBuckets (const unsigned char *buf); -+extern void AudioListBucketsReply (const unsigned char *buf); -+extern void AudioGetBucketAttributes (const unsigned char *buf); -+extern void AudioGetBucketAttributesReply (const unsigned char *buf); -+extern void AudioSetBucketAttributes (const unsigned char *buf); -+extern void AudioCreateRadio (const unsigned char *buf); -+extern void AudioDestroyRadio (const unsigned char *buf); -+extern void AudioListRadios (const unsigned char *buf); -+extern void AudioListRadiosReply (const unsigned char *buf); -+extern void AudioGetRadioAttributes (const unsigned char *buf); -+extern void AudioGetRadioAttributesReply (const unsigned char *buf); -+extern void AudioSetRadioAttributes (const unsigned char *buf); -+extern void AudioCreateFlow (const unsigned char *buf); -+extern void AudioDestroyFlow (const unsigned char *buf); -+extern void AudioGetFlowAttributes (const unsigned char *buf); -+extern void AudioGetFlowAttributesReply (const unsigned char *buf); -+extern void AudioSetFlowAttributes (const unsigned char *buf); -+extern void AudioGetElements (const unsigned char *buf); -+extern void AudioGetElementsReply (const unsigned char *buf); -+extern void AudioSetElements (const unsigned char *buf); -+extern void AudioGetElementStates (const unsigned char *buf); -+extern void AudioElementState (const unsigned char *buf); -+extern void AudioGetElementStatesReply (const unsigned char *buf); -+extern void AudioSetElementStates (const unsigned char *buf); -+extern void AudioGetElementParameters (const unsigned char *buf); -+extern void AudioGetElementParametersReply (const unsigned char *buf); -+extern void AudioSetElementParameters (const unsigned char *buf); -+extern void AudioWriteElement (const unsigned char *buf); -+extern void AudioReadElement (const unsigned char *buf); -+extern void AudioReadElementReply (const unsigned char *buf); -+extern void AudioGrabComponent (const unsigned char *buf); -+extern void AudioUngrabComponent (const unsigned char *buf); -+extern void AudioSendEvent (const unsigned char *buf); -+extern void AudioGetAllowedUsers (const unsigned char *buf); -+extern void AudioGetAllowedUsersReply (const unsigned char *buf); -+extern void AudioSetAllowedUsers (const unsigned char *buf); -+extern void AudioListExtensions (const unsigned char *buf); -+extern void AudioListExtensionsReply (const unsigned char *buf); -+extern void AudioQueryExtension (const unsigned char *buf); -+extern void AudioQueryExtensionReply (const unsigned char *buf); -+extern void AudioGetCloseDownMode (const unsigned char *buf); -+extern void AudioGetCloseDownModeReply (const unsigned char *buf); -+extern void AudioSetCloseDownMode (const unsigned char *buf); -+extern void AudioKillClient (const unsigned char *buf); -+extern void AudioGetServerTime (const unsigned char *buf); -+extern void AudioGetServerTimeReply (const unsigned char *buf); -+extern void AudioNoOperation (const unsigned char *buf); -diff --git a/print11.c b/print11.c -index 687bf6c..3d7984a 100644 ---- a/print11.c -+++ b/print11.c -@@ -23,7 +23,7 @@ - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * * -- * Copyright 2002 Sun Microsystems, Inc. All rights reserved. -+ * Copyright 2002, 2009 Sun Microsystems, Inc. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the -@@ -55,10 +55,10 @@ - #include "scope.h" - #include "x11.h" - --static void PrintFailedSetUpReply(unsigned char *buf); --static void PrintSuccessfulSetUpReply(unsigned char *buf); --static void ListFontsWithInfoReply1(unsigned char *buf); --static void ListFontsWithInfoReply2(unsigned char *buf); -+static void PrintFailedSetUpReply(const unsigned char *buf); -+static void PrintSuccessfulSetUpReply(const unsigned char *buf); -+static void ListFontsWithInfoReply1(const unsigned char *buf); -+static void ListFontsWithInfoReply2(const unsigned char *buf); - - - /* ************************************************************ */ -@@ -90,15 +90,14 @@ static void ListFontsWithInfoReply2(unsigned char *buf); - - #define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e) - -- - /* ************************************************************ */ - /* */ - /* */ - /* ************************************************************ */ - - void --PrintSetUpMessage(buf) -- unsigned char *buf; -+PrintSetUpMessage ( -+ const unsigned char *buf) - { - short n; - short d; -@@ -119,8 +118,8 @@ PrintSetUpMessage(buf) - } - - void --PrintSetUpReply(buf) -- unsigned char *buf; -+PrintSetUpReply ( -+ const unsigned char *buf) - { - enterprocedure("PrintSetUpReply"); - SetIndentLevel(PRINTSERVER); -@@ -131,8 +130,8 @@ PrintSetUpReply(buf) - } - - static void --PrintFailedSetUpReply(buf) -- unsigned char *buf; -+PrintFailedSetUpReply ( -+ const unsigned char *buf) - { - short n; - -@@ -148,8 +147,8 @@ PrintFailedSetUpReply(buf) - } - - static void --PrintSuccessfulSetUpReply(buf) -- unsigned char *buf; -+PrintSuccessfulSetUpReply ( -+ const unsigned char *buf) - { - short v; - short n; -@@ -187,10 +186,10 @@ PrintSuccessfulSetUpReply(buf) - /* */ - /* ************************************************************ */ - --static char *REQUESTHEADER = "............REQUEST"; --static char *EVENTHEADER = "..............EVENT"; --static char *ERRORHEADER = "..............ERROR"; --static char *REPLYHEADER = "..............REPLY"; -+const char REQUESTHEADER[] = "............REQUEST"; -+const char EVENTHEADER[] = "..............EVENT"; -+const char ERRORHEADER[] = "..............ERROR"; -+const char REPLYHEADER[] = "..............REPLY"; - - - /* ************************************************************ */ -@@ -201,8 +200,8 @@ static char *REPLYHEADER = "..............REPLY"; - /* Error Printing procedures */ - - void --RequestError(buf) -- unsigned char *buf; -+RequestError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; - if (Verbose < 1) -@@ -213,8 +212,8 @@ RequestError(buf) - } - - void --ValueError(buf) -- unsigned char *buf; -+ValueError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ; - if (Verbose < 1) -@@ -226,8 +225,8 @@ ValueError(buf) - } - - void --WindowError(buf) -- unsigned char *buf; -+WindowError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Window */ ; - if (Verbose < 1) -@@ -239,8 +238,8 @@ WindowError(buf) - } - - void --PixmapError(buf) -- unsigned char *buf; -+PixmapError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Pixmap */ ; - if (Verbose < 1) -@@ -252,8 +251,8 @@ PixmapError(buf) - } - - void --AtomError(buf) -- unsigned char *buf; -+AtomError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Atom */ ; - if (Verbose < 1) -@@ -265,8 +264,8 @@ AtomError(buf) - } - - void --CursorError(buf) -- unsigned char *buf; -+CursorError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Cursor */ ; - if (Verbose < 1) -@@ -278,8 +277,8 @@ CursorError(buf) - } - - void --FontError(buf) -- unsigned char *buf; -+FontError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Font */ ; - if (Verbose < 1) -@@ -291,8 +290,8 @@ FontError(buf) - } - - void --MatchError(buf) -- unsigned char *buf; -+MatchError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ; - if (Verbose < 1) -@@ -303,8 +302,8 @@ MatchError(buf) - } - - void --DrawableError(buf) -- unsigned char *buf; -+DrawableError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Drawable */ ; - if (Verbose < 1) -@@ -316,8 +315,8 @@ DrawableError(buf) - } - - void --AccessError(buf) -- unsigned char *buf; -+AccessError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ; - if (Verbose < 1) -@@ -328,8 +327,8 @@ AccessError(buf) - } - - void --AllocError(buf) -- unsigned char *buf; -+AllocError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ; - if (Verbose < 1) -@@ -340,8 +339,8 @@ AllocError(buf) - } - - void --ColormapError(buf) -- unsigned char *buf; -+ColormapError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Colormap */ ; - if (Verbose < 1) -@@ -353,8 +352,8 @@ ColormapError(buf) - } - - void --GContextError(buf) -- unsigned char *buf; -+GContextError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* GContext */ ; - if (Verbose < 1) -@@ -366,8 +365,8 @@ GContextError(buf) - } - - void --IDChoiceError(buf) -- unsigned char *buf; -+IDChoiceError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ; - if (Verbose < 1) -@@ -379,8 +378,8 @@ IDChoiceError(buf) - } - - void --NameError(buf) -- unsigned char *buf; -+NameError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Name */ ; - if (Verbose < 1) -@@ -391,8 +390,8 @@ NameError(buf) - } - - void --LengthError(buf) -- unsigned char *buf; -+LengthError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ; - if (Verbose < 1) -@@ -403,8 +402,8 @@ LengthError(buf) - } - - void --ImplementationError(buf) -- unsigned char *buf; -+ImplementationError ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ; - if (Verbose < 1) -@@ -422,8 +421,8 @@ ImplementationError(buf) - /* Event Printing procedures */ - - void --KeyPressEvent(buf) -- unsigned char *buf; -+KeyPressEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeyPress */ ; - if (Verbose < 1) -@@ -443,8 +442,8 @@ KeyPressEvent(buf) - } - - void --KeyReleaseEvent(buf) -- unsigned char *buf; -+KeyReleaseEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeyRelease */ ; - if (Verbose < 1) -@@ -464,8 +463,8 @@ KeyReleaseEvent(buf) - } - - void --ButtonPressEvent(buf) -- unsigned char *buf; -+ButtonPressEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ButtonPress */ ; - if (Verbose < 1) -@@ -485,8 +484,8 @@ ButtonPressEvent(buf) - } - - void --ButtonReleaseEvent(buf) -- unsigned char *buf; -+ButtonReleaseEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ButtonRelease */ ; - if (Verbose < 1) -@@ -506,8 +505,8 @@ ButtonReleaseEvent(buf) - } - - void --MotionNotifyEvent(buf) -- unsigned char *buf; -+MotionNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MotionNotify */ ; - if (Verbose < 1) -@@ -527,8 +526,8 @@ MotionNotifyEvent(buf) - } - - void --EnterNotifyEvent(buf) -- unsigned char *buf; -+EnterNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* EnterNotify */ ; - if (Verbose < 1) -@@ -549,8 +548,8 @@ EnterNotifyEvent(buf) - } - - void --LeaveNotifyEvent(buf) -- unsigned char *buf; -+LeaveNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LeaveNotify */ ; - if (Verbose < 1) -@@ -571,8 +570,8 @@ LeaveNotifyEvent(buf) - } - - void --FocusInEvent(buf) -- unsigned char *buf; -+FocusInEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* FocusIn */ ; - if (Verbose < 1) -@@ -584,8 +583,8 @@ FocusInEvent(buf) - } - - void --FocusOutEvent(buf) -- unsigned char *buf; -+FocusOutEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* FocusOut */ ; - if (Verbose < 1) -@@ -597,8 +596,8 @@ FocusOutEvent(buf) - } - - void --KeymapNotifyEvent(buf) -- unsigned char *buf; -+KeymapNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* KeymapNotify */ ; - if (Verbose < 1) -@@ -607,8 +606,8 @@ KeymapNotifyEvent(buf) - } - - void --ExposeEvent(buf) -- unsigned char *buf; -+ExposeEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* Expose */ ; - if (Verbose < 1) -@@ -623,8 +622,8 @@ ExposeEvent(buf) - } - - void --GraphicsExposureEvent(buf) -- unsigned char *buf; -+GraphicsExposureEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GraphicsExposure */ ; - if (Verbose < 1) -@@ -641,8 +640,8 @@ GraphicsExposureEvent(buf) - } - - void --NoExposureEvent(buf) -- unsigned char *buf; -+NoExposureEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* NoExposure */ ; - if (Verbose < 1) -@@ -654,8 +653,8 @@ NoExposureEvent(buf) - } - - void --VisibilityNotifyEvent(buf) -- unsigned char *buf; -+VisibilityNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* VisibilityNotify */ ; - if (Verbose < 1) -@@ -666,8 +665,8 @@ VisibilityNotifyEvent(buf) - } - - void --CreateNotifyEvent(buf) -- unsigned char *buf; -+CreateNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CreateNotify */ ; - if (Verbose < 1) -@@ -684,8 +683,8 @@ CreateNotifyEvent(buf) - } - - void --DestroyNotifyEvent(buf) -- unsigned char *buf; -+DestroyNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* DestroyNotify */ ; - if (Verbose < 1) -@@ -696,8 +695,8 @@ DestroyNotifyEvent(buf) - } - - void --UnmapNotifyEvent(buf) -- unsigned char *buf; -+UnmapNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* UnmapNotify */ ; - if (Verbose < 1) -@@ -709,8 +708,8 @@ UnmapNotifyEvent(buf) - } - - void --MapNotifyEvent(buf) -- unsigned char *buf; -+MapNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapNotify */ ; - if (Verbose < 1) -@@ -722,8 +721,8 @@ MapNotifyEvent(buf) - } - - void --MapRequestEvent(buf) -- unsigned char *buf; -+MapRequestEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapRequest */ ; - if (Verbose < 1) -@@ -734,8 +733,8 @@ MapRequestEvent(buf) - } - - void --ReparentNotifyEvent(buf) -- unsigned char *buf; -+ReparentNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ReparentNotify */ ; - if (Verbose < 1) -@@ -750,8 +749,8 @@ ReparentNotifyEvent(buf) - } - - void --ConfigureNotifyEvent(buf) -- unsigned char *buf; -+ConfigureNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureNotify */ ; - if (Verbose < 1) -@@ -769,8 +768,8 @@ ConfigureNotifyEvent(buf) - } - - void --ConfigureRequestEvent(buf) -- unsigned char *buf; -+ConfigureRequestEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureRequest */ ; - if (Verbose < 1) -@@ -789,8 +788,8 @@ ConfigureRequestEvent(buf) - } - - void --GravityNotifyEvent(buf) -- unsigned char *buf; -+GravityNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GravityNotify */ ; - if (Verbose < 1) -@@ -803,8 +802,8 @@ GravityNotifyEvent(buf) - } - - void --ResizeRequestEvent(buf) -- unsigned char *buf; -+ResizeRequestEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ResizeRequest */ ; - if (Verbose < 1) -@@ -816,8 +815,8 @@ ResizeRequestEvent(buf) - } - - void --CirculateNotifyEvent(buf) -- unsigned char *buf; -+CirculateNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateNotify */ ; - if (Verbose < 1) -@@ -830,8 +829,8 @@ CirculateNotifyEvent(buf) - } - - void --CirculateRequestEvent(buf) -- unsigned char *buf; -+CirculateRequestEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateRequest */ ; - if (Verbose < 1) -@@ -843,8 +842,8 @@ CirculateRequestEvent(buf) - } - - void --PropertyNotifyEvent(buf) -- unsigned char *buf; -+PropertyNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* PropertyNotify */ ; - if (Verbose < 1) -@@ -857,8 +856,8 @@ PropertyNotifyEvent(buf) - } - - void --SelectionClearEvent(buf) -- unsigned char *buf; -+SelectionClearEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionClear */ ; - if (Verbose < 1) -@@ -870,8 +869,8 @@ SelectionClearEvent(buf) - } - - void --SelectionRequestEvent(buf) -- unsigned char *buf; -+SelectionRequestEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionRequest */ ; - if (Verbose < 1) -@@ -886,8 +885,8 @@ SelectionRequestEvent(buf) - } - - void --SelectionNotifyEvent(buf) -- unsigned char *buf; -+SelectionNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionNotify */ ; - if (Verbose < 1) -@@ -901,8 +900,8 @@ SelectionNotifyEvent(buf) - } - - void --ColormapNotifyEvent(buf) -- unsigned char *buf; -+ColormapNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ColormapNotify */ ; - if (Verbose < 1) -@@ -915,8 +914,8 @@ ColormapNotifyEvent(buf) - } - - void --ClientMessageEvent(buf) -- unsigned char *buf; -+ClientMessageEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ClientMessage */ ; - if (Verbose < 1) -@@ -929,8 +928,8 @@ ClientMessageEvent(buf) - } - - void --MappingNotifyEvent(buf) -- unsigned char *buf; -+MappingNotifyEvent ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MappingNotify */ ; - if (Verbose < 1) -@@ -949,18 +948,51 @@ MappingNotifyEvent(buf) - /* Request and Reply Printing procedures */ - - void --CreateWindow(buf) -- unsigned char *buf; -+ExtendedRequest ( -+ int fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(n-1)); -+ -+ n = CS[fd].requestLen - 1; -+ (void) PrintList (&buf[4], n, CARD32, "data"); -+} -+ -+void -+UnknownReply ( -+ const 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"); -+} -+ -+void -+CreateWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CreateWindow is opcode 1 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, CARD8, "depth"); -- printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); -+ printreqlen(buf, fd, DVALUE2(8 + n)); - PrintField(buf, 4, 4, WINDOW, "wid"); - PrintField(buf, 8, 4, WINDOW, "parent"); - PrintField(buf, 12, 2, INT16, "x"); -@@ -975,40 +1007,42 @@ CreateWindow(buf) - } - - void --ChangeWindowAttributes(buf) -- unsigned char *buf; -+ChangeWindowAttributes ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ChangeWindowAttributes is opcode 2 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeWindowAttributes */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, WINDOW_BITMASK, "value-mask"); - PrintValues(&buf[8], 4, WINDOW_BITMASK, &buf[12], "value-list"); - } - - void --GetWindowAttributes(buf) -- unsigned char *buf; -+GetWindowAttributes ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetWindowAttributes is opcode 3 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetWindowAttributes */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --GetWindowAttributesReply(buf) -- unsigned char *buf; -+GetWindowAttributesReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetWindowAttributes */ ; - if (Verbose < 1) -@@ -1033,63 +1067,67 @@ GetWindowAttributesReply(buf) - } - - void --DestroyWindow(buf) -- unsigned char *buf; -+DestroyWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request DestroyWindow is opcode 4 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DestroyWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --DestroySubwindows(buf) -- unsigned char *buf; -+DestroySubwindows ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request DestroySubwindows is opcode 5 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DestroySubwindows */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --ChangeSaveSet(buf) -- unsigned char *buf; -+ChangeSaveSet ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ChangeSaveSet is opcode 6 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeSaveSet */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, INS_DEL, "mode"); -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --ReparentWindow(buf) -- unsigned char *buf; -+ReparentWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ReparentWindow is opcode 7 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ReparentWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, WINDOW, "parent"); - PrintField(buf, 12, 2, INT16, "x"); -@@ -1097,116 +1135,123 @@ ReparentWindow(buf) - } - - void --MapWindow(buf) -- unsigned char *buf; -+MapWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request MapWindow is opcode 8 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* MapWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --MapSubwindows(buf) -- unsigned char *buf; -+MapSubwindows ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request MapSubwindows is opcode 9 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* MapSubwindows */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --UnmapWindow(buf) -- unsigned char *buf; -+UnmapWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UnmapWindow is opcode 10 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UnmapWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --UnmapSubwindows(buf) -- unsigned char *buf; -+UnmapSubwindows ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UnmapSubwindows is opcode 11 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UnmapSubwindows */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --ConfigureWindow(buf) -- unsigned char *buf; -+ConfigureWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ConfigureWindow is opcode 12 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ConfigureWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 2, CONFIGURE_BITMASK, "value-mask"); - PrintValues(&buf[8], 2, CONFIGURE_BITMASK, &buf[12], "value-list"); - } - - void --CirculateWindow(buf) -- unsigned char *buf; -+CirculateWindow ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CirculateWindow is opcode 13 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CirculateWindow */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, CIRMODE, "direction"); -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --GetGeometry(buf) -- unsigned char *buf; -+GetGeometry ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetGeometry is opcode 14 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetGeometry */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - } - - void --GetGeometryReply(buf) -- unsigned char *buf; -+GetGeometryReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetGeometry */ ; - if (Verbose < 1) -@@ -1223,23 +1268,24 @@ GetGeometryReply(buf) - } - - void --QueryTree(buf) -- unsigned char *buf; -+QueryTree ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request QueryTree is opcode 15 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryTree */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --QueryTreeReply(buf) -- unsigned char *buf; -+QueryTreeReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTree */ ; -@@ -1255,8 +1301,9 @@ QueryTreeReply(buf) - } - - void --InternAtom(buf) -- unsigned char *buf; -+InternAtom ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request InternAtom is opcode 16 */ -@@ -1264,18 +1311,18 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - printfield(buf, 4, 2, DVALUE2(n), "length of name"); - n = IShort(&buf[4]); - PrintString8(&buf[8], n, "name"); - } - - void --InternAtomReply(buf) -- unsigned char *buf; -+InternAtomReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* InternAtom */ ; - if (Verbose < 1) -@@ -1286,23 +1333,24 @@ InternAtomReply(buf) - } - - void --GetAtomName(buf) -- unsigned char *buf; -+GetAtomName ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetAtomName is opcode 17 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetAtomName */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, ATOM, "atom"); - } - - void --GetAtomNameReply(buf) -- unsigned char *buf; -+GetAtomNameReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetAtomName */ ; -@@ -1316,8 +1364,9 @@ GetAtomNameReply(buf) - } - - void --ChangeProperty(buf) -- unsigned char *buf; -+ChangeProperty ( -+ FD fd, -+ const unsigned char *buf) - { - long n; - short unit; -@@ -1328,10 +1377,10 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(6 + (n + p) / 4)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, ATOM, "property"); - PrintField(buf, 12, 4, ATOM, "type"); -@@ -1347,34 +1396,36 @@ ChangeProperty(buf) - } - - void --DeleteProperty(buf) -- unsigned char *buf; -+DeleteProperty ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request DeleteProperty is opcode 19 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* DeleteProperty */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, ATOM, "property"); - } - - void --GetProperty(buf) -- unsigned char *buf; -+GetProperty ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetProperty is opcode 20 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetProperty */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "delete"); -- printfield(buf, 2, 2, CONST2(6), "request length"); -+ printreqlen(buf, fd, CONST2(6)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, ATOM, "property"); - PrintField(buf, 12, 4, ATOMT, "type"); -@@ -1383,8 +1434,8 @@ GetProperty(buf) - } - - void --GetPropertyReply(buf) -- unsigned char *buf; -+GetPropertyReply ( -+ const unsigned char *buf) - { - long n; - short unit; -@@ -1409,23 +1460,24 @@ GetPropertyReply(buf) - } - - void --ListProperties(buf) -- unsigned char *buf; -+ListProperties ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ListProperties is opcode 21 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListProperties */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --ListPropertiesReply(buf) -- unsigned char *buf; -+ListPropertiesReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListProperties */ ; -@@ -1439,40 +1491,42 @@ ListPropertiesReply(buf) - } - - void --SetSelectionOwner(buf) -- unsigned char *buf; -+SetSelectionOwner ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SetSelectionOwner is opcode 22 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetSelectionOwner */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "owner"); - PrintField(buf, 8, 4, ATOM, "selection"); - PrintField(buf, 12, 4, TIMESTAMP, "time"); - } - - void --GetSelectionOwner(buf) -- unsigned char *buf; -+GetSelectionOwner ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetSelectionOwner is opcode 23 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetSelectionOwner */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, ATOM, "selection"); - } - - void --GetSelectionOwnerReply(buf) -- unsigned char *buf; -+GetSelectionOwnerReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetSelectionOwner */ ; - if (Verbose < 1) -@@ -1483,17 +1537,18 @@ GetSelectionOwnerReply(buf) - } - - void --ConvertSelection(buf) -- unsigned char *buf; -+ConvertSelection ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ConvertSelection is opcode 24 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ConvertSelection */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(6), "request length"); -+ printreqlen(buf, fd, CONST2(6)); - PrintField(buf, 4, 4, WINDOW, "requestor"); - PrintField(buf, 8, 4, ATOM, "selection"); - PrintField(buf, 12, 4, ATOM, "target"); -@@ -1502,36 +1557,38 @@ ConvertSelection(buf) - } - - void --SendEvent(buf) -- unsigned char *buf; -+SendEvent ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SendEvent is opcode 25 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SendEvent */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "propagate"); -- printfield(buf, 2, 2, CONST2(11), "request length"); -+ printreqlen(buf, fd, CONST2(11)); - PrintField(buf, 4, 4, WINDOWD, "destination"); - PrintField(buf, 8, 4, SETofEVENT, "event-mask"); - PrintField(buf, 12, 32, EVENTFORM, "event"); - } - - void --GrabPointer(buf) -- unsigned char *buf; -+GrabPointer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GrabPointer is opcode 26 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabPointer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "owner-events"); -- printfield(buf, 2, 2, CONST2(6), "request length"); -+ printreqlen(buf, fd, CONST2(6)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask"); - PrintField(buf, 10, 1, PK_MODE, "pointer-mode"); -@@ -1542,8 +1599,8 @@ GrabPointer(buf) - } - - void --GrabPointerReply(buf) -- unsigned char *buf; -+GrabPointerReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GrabPointer */ ; - if (Verbose < 1) -@@ -1554,33 +1611,35 @@ GrabPointerReply(buf) - } - - void --UngrabPointer(buf) -- unsigned char *buf; -+UngrabPointer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UngrabPointer is opcode 27 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabPointer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, TIMESTAMP, "time"); - } - - void --GrabButton(buf) -- unsigned char *buf; -+GrabButton ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GrabButton is opcode 28 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabButton */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "owner-events"); -- printfield(buf, 2, 2, CONST2(6), "request length"); -+ printreqlen(buf, fd, CONST2(6)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 2, SETofPOINTEREVENT, "event-mask"); - PrintField(buf, 10, 1, PK_MODE, "pointer-mode"); -@@ -1592,52 +1651,55 @@ GrabButton(buf) - } - - void --UngrabButton(buf) -- unsigned char *buf; -+UngrabButton ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UngrabButton is opcode 29 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabButton */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BUTTONA, "button"); -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 2, SETofKEYMASK, "modifiers"); - } - - void --ChangeActivePointerGrab(buf) -- unsigned char *buf; -+ChangeActivePointerGrab ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ChangeActivePointerGrab is opcode 30 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeActivePointerGrab */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, CURSOR, "cursor"); - PrintField(buf, 8, 4, TIMESTAMP, "time"); - PrintField(buf, 12, 2, SETofPOINTEREVENT, "event-mask"); - } - - void --GrabKeyboard(buf) -- unsigned char *buf; -+GrabKeyboard ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GrabKeyboard is opcode 31 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabKeyboard */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "owner-events"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 4, TIMESTAMP, "time"); - PrintField(buf, 12, 1, PK_MODE, "pointer-mode"); -@@ -1645,8 +1707,8 @@ GrabKeyboard(buf) - } - - void --GrabKeyboardReply(buf) -- unsigned char *buf; -+GrabKeyboardReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GrabKeyboard */ ; - if (Verbose < 1) -@@ -1657,33 +1719,35 @@ GrabKeyboardReply(buf) - } - - void --UngrabKeyboard(buf) -- unsigned char *buf; -+UngrabKeyboard ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UngrabKeyboard is opcode 32 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabKeyboard */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, TIMESTAMP, "time"); - } - - void --GrabKey(buf) -- unsigned char *buf; -+GrabKey ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GrabKey is opcode 33 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabKey */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "owner-events"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 2, SETofKEYMASK, "modifiers"); - PrintField(buf, 10, 1, KEYCODEA, "key"); -@@ -1692,84 +1756,89 @@ GrabKey(buf) - } - - void --UngrabKey(buf) -- unsigned char *buf; -+UngrabKey ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UngrabKey is opcode 34 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabKey */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, KEYCODEA, "key"); -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, WINDOW, "grab-window"); - PrintField(buf, 8, 2, SETofKEYMASK, "modifiers"); - } - - void --AllowEvents(buf) -- unsigned char *buf; -+AllowEvents ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request AllowEvents is opcode 35 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllowEvents */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, EVENTMODE, "mode"); -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, TIMESTAMP, "time"); - } - - void --GrabServer(buf) -- unsigned char *buf; -+GrabServer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GrabServer is opcode 36 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GrabServer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --UngrabServer(buf) -- unsigned char *buf; -+UngrabServer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UngrabServer is opcode 37 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UngrabServer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --QueryPointer(buf) -- unsigned char *buf; -+QueryPointer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request QueryPointer is opcode 38 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryPointer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --QueryPointerReply(buf) -- unsigned char *buf; -+QueryPointerReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryPointer */ ; - if (Verbose < 1) -@@ -1787,25 +1856,26 @@ QueryPointerReply(buf) - } - - void --GetMotionEvents(buf) -- unsigned char *buf; -+GetMotionEvents ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetMotionEvents is opcode 39 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetMotionEvents */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 4, TIMESTAMP, "start"); - PrintField(buf, 12, 4, TIMESTAMP, "stop"); - } - - void --GetMotionEventsReply(buf) -- unsigned char *buf; -+GetMotionEventsReply ( -+ const unsigned char *buf) - { - long n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetMotionEvents */ ; -@@ -1819,17 +1889,18 @@ GetMotionEventsReply(buf) - } - - void --TranslateCoordinates(buf) -- unsigned char *buf; -+TranslateCoordinates ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request TranslateCoordinates is opcode 40 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* TranslateCoordinates */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "src-window"); - PrintField(buf, 8, 4, WINDOW, "dst-window"); - PrintField(buf, 12, 2, INT16, "src-x"); -@@ -1837,8 +1908,8 @@ TranslateCoordinates(buf) - } - - void --TranslateCoordinatesReply(buf) -- unsigned char *buf; -+TranslateCoordinatesReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* TranslateCoordinates */ ; - if (Verbose < 1) -@@ -1852,17 +1923,18 @@ TranslateCoordinatesReply(buf) - } - - void --WarpPointer(buf) -- unsigned char *buf; -+WarpPointer ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request WarpPointer is opcode 41 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* WarpPointer */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(6), "request length"); -+ printreqlen(buf, fd, CONST2(6)); - PrintField(buf, 4, 4, WINDOW, "src-window"); - PrintField(buf, 8, 4, WINDOW, "dst-window"); - PrintField(buf, 12, 2, INT16, "src-x"); -@@ -1874,39 +1946,41 @@ WarpPointer(buf) - } - - void --SetInputFocus(buf) -- unsigned char *buf; -+SetInputFocus ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SetInputFocus is opcode 42 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetInputFocus */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, FOCUSAGENT, "revert-to"); -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, WINDOWNR, "focus"); - PrintField(buf, 8, 4, TIMESTAMP, "time"); - } - - void --GetInputFocus(buf) -- unsigned char *buf; -+GetInputFocus ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetInputFocus is opcode 43 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetInputFocus */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetInputFocusReply(buf) -- unsigned char *buf; -+GetInputFocusReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetInputFocus */ ; - if (Verbose < 1) -@@ -1918,22 +1992,23 @@ GetInputFocusReply(buf) - } - - void --QueryKeymap(buf) -- unsigned char *buf; -+QueryKeymap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request QueryKeymap is opcode 44 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryKeymap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --QueryKeymapReply(buf) -- unsigned char *buf; -+QueryKeymapReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryKeymap */ ; - if (Verbose < 1) -@@ -1944,8 +2019,9 @@ QueryKeymapReply(buf) - } - - void --OpenFont(buf) -- unsigned char *buf; -+OpenFont ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request OpenFont is opcode 45 */ -@@ -1953,9 +2029,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4)); - PrintField(buf, 4, 4, FONT, "font-id"); - printfield(buf, 8, 2, DVALUE2(n), "length of name"); - n = IShort(&buf[8]); -@@ -1963,38 +2039,40 @@ OpenFont(buf) - } - - void --CloseFont(buf) -- unsigned char *buf; -+CloseFont ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CloseFont is opcode 46 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CloseFont */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, FONT, "font"); - } - - void --QueryFont(buf) -- unsigned char *buf; -+QueryFont ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request QueryFont is opcode 47 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryFont */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, FONTABLE, "font"); - } - - void --QueryFontReply(buf) -- unsigned char *buf; -+QueryFontReply ( -+ const unsigned char *buf) - { - short n; - long m; -@@ -2025,20 +2103,21 @@ QueryFontReply(buf) - } - - void --QueryTextExtents(buf) -- unsigned char *buf; -+QueryTextExtents ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (2*n + p) / 4)); - n = (IShort(&buf[2]) - 2) * 4 / 2; - if (IBool(&buf[1])) - n -= 1; -@@ -2047,8 +2126,8 @@ QueryTextExtents(buf) - } - - void --QueryTextExtentsReply(buf) -- unsigned char *buf; -+QueryTextExtentsReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTextExtents */ ; - if (Verbose < 1) -@@ -2066,8 +2145,9 @@ QueryTextExtentsReply(buf) - } - - void --ListFonts(buf) -- unsigned char *buf; -+ListFonts ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request ListFonts is opcode 49 */ -@@ -2075,9 +2155,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - PrintField(buf, 4, 2, CARD16, "max-names"); - printfield(buf, 6, 2, DVALUE2(n), "length of pattern"); - n = IShort(&buf[6]); -@@ -2085,8 +2165,8 @@ ListFonts(buf) - } - - void --ListFontsReply(buf) -- unsigned char *buf; -+ListFontsReply ( -+ const unsigned char *buf) - { - short n; - -@@ -2101,8 +2181,9 @@ ListFontsReply(buf) - } - - void --ListFontsWithInfo(buf) -- unsigned char *buf; -+ListFontsWithInfo ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request ListFontsWithInfo is opcode 50 */ -@@ -2110,9 +2191,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - PrintField(buf, 4, 2, CARD16, "max-names"); - printfield(buf, 6, 2, DVALUE2(n), "length of pattern"); - n = IShort(&buf[6]); -@@ -2120,8 +2201,8 @@ ListFontsWithInfo(buf) - } - - void --ListFontsWithInfoReply(buf) -- unsigned char *buf; -+ListFontsWithInfoReply ( -+ const unsigned char *buf) - { - short which; - -@@ -2139,8 +2220,8 @@ ListFontsWithInfoReply(buf) - } - - static void --ListFontsWithInfoReply1(buf) -- unsigned char *buf; -+ListFontsWithInfoReply1 ( -+ const unsigned char *buf) - { - short n; - short m; -@@ -2167,8 +2248,8 @@ ListFontsWithInfoReply1(buf) - } - - static void --ListFontsWithInfoReply2(buf) -- unsigned char *buf; -+ListFontsWithInfoReply2 ( -+ const unsigned char *buf) - { - PrintField(buf, 1, 1, CONST1(0), "last-reply indicator"); - printfield(buf, 2, 2, CARD16, "sequence number"); -@@ -2176,8 +2257,9 @@ ListFontsWithInfoReply2(buf) - } - - void --SetFontPath(buf) -- unsigned char *buf; -+SetFontPath ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request SetFontPath is opcode 51 */ -@@ -2185,31 +2267,32 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - printfield(buf, 4, 2, CARD16, "number of paths"); - n = IShort(&buf[4]); - PrintListSTR(&buf[8], (long)n, "paths"); - } - - void --GetFontPath(buf) -- unsigned char *buf; -+GetFontPath ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetFontPath is opcode 52 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetFontPath */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 2, 2, CONST2(1), "request list"); - } - - void --GetFontPathReply(buf) -- unsigned char *buf; -+GetFontPathReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetFontPath */ ; -@@ -2223,18 +2306,19 @@ GetFontPathReply(buf) - } - - void --CreatePixmap(buf) -- unsigned char *buf; -+CreatePixmap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CreatePixmap is opcode 53 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreatePixmap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, CARD8, "depth"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, PIXMAP, "pixmap-id"); - PrintField(buf, 8, 4, DRAWABLE, "drawable"); - PrintField(buf, 12, 2, CARD16, "width"); -@@ -2242,32 +2326,63 @@ CreatePixmap(buf) - } - - void --FreePixmap(buf) -- unsigned char *buf; -+FreePixmap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request FreePixmap is opcode 54 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreePixmap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, PIXMAP, "pixmap"); - } - --void --CreateGC(buf) -- unsigned char *buf; --{ -+static const 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 */ -+}; -+ -+void -+CreateGC ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(4 + n)); - PrintField(buf, 4, 4, GCONTEXT, "graphic-context-id"); - PrintField(buf, 8, 4, DRAWABLE, "drawable"); - PrintField(buf, 12, 4, GC_BITMASK, "value-mask"); -@@ -2275,42 +2390,47 @@ CreateGC(buf) - } - - void --ChangeGC(buf) -- unsigned char *buf; -+ChangeGC ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - PrintField(buf, 4, 4, GCONTEXT, "gc"); - PrintField(buf, 8, 4, GC_BITMASK, "value-mask"); - PrintValues(&buf[8], 4, GC_BITMASK, &buf[12], "value-list"); - } - - void --CopyGC(buf) -- unsigned char *buf; -+CopyGC ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CopyGC is opcode 57 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyGC */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, GCONTEXT, "src-gc"); - PrintField(buf, 8, 4, GCONTEXT, "dst-gc"); - PrintField(buf, 12, 4, GC_BITMASK, "value-mask"); - } - - void --SetDashes(buf) -- unsigned char *buf; -+SetDashes ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request SetDashes is opcode 58 */ -@@ -2318,9 +2438,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4)); - PrintField(buf, 4, 4, GCONTEXT, "gc"); - PrintField(buf, 8, 2, CARD16, "dash-offset"); - printfield(buf, 10, 2, DVALUE2(n), "length of dashes"); -@@ -2329,8 +2449,9 @@ SetDashes(buf) - } - - void --SetClipRectangles(buf) -- unsigned char *buf; -+SetClipRectangles ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - -@@ -2339,10 +2460,10 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 2*n)); - n = (IShort(&buf[2]) - 3) / 2; - PrintField(buf, 4, 4, GCONTEXT, "gc"); - PrintField(buf, 8, 2, INT16, "clip-x-origin"); -@@ -2351,33 +2472,37 @@ SetClipRectangles(buf) - } - - void --FreeGC(buf) -- unsigned char *buf; -+FreeGC ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, GCONTEXT, "gc"); - } - - void --ClearArea(buf) -- unsigned char *buf; -+ClearArea ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ClearArea is opcode 61 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ClearArea */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "exposures"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, WINDOW, "window"); - PrintField(buf, 8, 2, INT16, "x"); - PrintField(buf, 10, 2, INT16, "y"); -@@ -2386,20 +2511,27 @@ ClearArea(buf) - } - - void --CopyArea(buf) -- unsigned char *buf; -+CopyArea ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CopyArea is opcode 62 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyArea */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(7), "request length"); -+ printreqlen(buf, fd, CONST2(7)); - 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"); -@@ -2409,20 +2541,29 @@ CopyArea(buf) - } - - void --CopyPlane(buf) -- unsigned char *buf; -+CopyPlane ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CopyPlane is opcode 63 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyPlane */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(8), "request length"); -+ printreqlen(buf, fd, CONST2(8)); - 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"); -@@ -2433,8 +2574,9 @@ CopyPlane(buf) - } - - void --PolyPoint(buf) -- unsigned char *buf; -+PolyPoint ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyPoint is opcode 64 */ -@@ -2442,19 +2584,26 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - n = (IShort(&buf[2]) - 3); - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, POINT, "points"); -+ if (Verbose > 2) -+ PrintValueRec (ILong (&buf[8]), -+ GC_function| -+ GC_plane_mask| -+ GC_foreground, -+ GC_BITMASK); -+ (void)PrintList(&buf[12], (long)n, POINT, "points"); - } - - void --PolyLine(buf) -- unsigned char *buf; -+PolyLine ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyLine is opcode 65 */ -@@ -2462,19 +2611,34 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - n = (IShort(&buf[2]) - 3); - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, POINT, "points"); --} -- --void --PolySegment(buf) -- unsigned char *buf; -+ 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"); -+} -+ -+void -+PolySegment ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolySegment is opcode 66 */ -@@ -2482,18 +2646,32 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 2*n)); - n = (IShort(&buf[2]) - 3) / 2; - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, SEGMENT, "segments"); --} -- --void --PolyRectangle(buf) -- unsigned char *buf; -+ 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"); -+} -+ -+void -+PolyRectangle ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyRectangle is opcode 67 */ -@@ -2501,18 +2679,33 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 2*n)); - n = (IShort(&buf[2]) - 3) / 2; - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); --} -- --void --PolyArc(buf) -- unsigned char *buf; -+ 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"); -+} -+ -+void -+PolyArc ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyArc is opcode 68 */ -@@ -2520,18 +2713,33 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 3*n)); - n = (IShort(&buf[2]) - 3) / 3; - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, ARC, "arcs"); --} -- --void --FillPoly(buf) -- unsigned char *buf; -+ 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"); -+} -+ -+void -+FillPoly ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request FillPoly is opcode 69 */ -@@ -2539,20 +2747,32 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(4 + n)); - 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"); - PrintList(&buf[16], (long)n, POINT, "points"); - } - - void --PolyFillRectangle(buf) -- unsigned char *buf; -+PolyFillRectangle ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyFillRectangle is opcode 70 */ -@@ -2560,18 +2780,29 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 2*n)); - n = (IShort(&buf[2]) - 3) / 2; - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); -+ 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"); - } - - void --PolyFillArc(buf) -- unsigned char *buf; -+PolyFillArc ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request PolyFillArc is opcode 71 */ -@@ -2579,29 +2810,41 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + 3*n)); - n = (IShort(&buf[2]) - 3) / 3; - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 4, GCONTEXT, "gc"); -- PrintList(&buf[12], (long)n, ARC, "arcs"); --} -- --void --PutImage(buf) -- unsigned char *buf; --{ -- short n; -+ 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"); -+} -+ -+void -+PutImage ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ 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"); -+ printreqlen(buf, fd, DVALUE2(6 + (n + p) / 4)); - - /* the size of the Image is overestimated by the following computation of n, - because we ignore that padding of the request to a multiple of 4 bytes. -@@ -2618,28 +2861,37 @@ 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"); - } - - void --GetImage(buf) -- unsigned char *buf; -+GetImage ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetImage is opcode 73 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetImage */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, IMAGEMODE, "format"); -- printfield(buf, 2, 2, CONST2(5), "request length"); -+ printreqlen(buf, fd, CONST2(5)); - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 2, INT16, "x"); - PrintField(buf, 10, 2, INT16, "y"); -@@ -2649,8 +2901,8 @@ GetImage(buf) - } - - void --GetImageReply(buf) -- unsigned char *buf; -+GetImageReply ( -+ const unsigned char *buf) - { - long n; - -@@ -2666,56 +2918,82 @@ 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"); - } - - void --PolyText8(buf) -- unsigned char *buf; -+PolyText8 ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4)); - 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"); - } - - void --PolyText16(buf) -- unsigned char *buf; -+PolyText16 ( -+ FD fd, -+ const 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"); -+ printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4)); - 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"); - } - - void --ImageText8(buf) -- unsigned char *buf; -+ImageText8 ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request ImageText8 is opcode 76 */ -@@ -2723,21 +3001,29 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4)); - 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], n, "string"); -+ PrintTString8(&buf[16], (long)n, "string"); - } - - void --ImageText16(buf) -- unsigned char *buf; -+ImageText16 ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request ImageText16 is opcode 77 */ -@@ -2745,115 +3031,128 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(4 + (2*n + p) / 4)); - 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], n, "string"); -+ PrintTString16(&buf[16], (long)n, "string"); - } - - void --CreateColormap(buf) -- unsigned char *buf; -+CreateColormap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CreateColormap is opcode 78 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateColormap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, ALLORNONE, "alloc"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, COLORMAP, "color-map-id"); - PrintField(buf, 8, 4, WINDOW, "window"); - PrintField(buf, 12, 4, VISUALID, "visual"); - } - - void --FreeColormap(buf) -- unsigned char *buf; -+FreeColormap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request FreeColormap is opcode 79 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeColormap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - } - - void --CopyColormapAndFree(buf) -- unsigned char *buf; -+CopyColormapAndFree ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CopyColormapAndFree is opcode 80 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CopyColormapAndFree */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, COLORMAP, "color-map-id"); - PrintField(buf, 8, 4, COLORMAP, "src-cmap"); - } - - void --InstallColormap(buf) -- unsigned char *buf; -+InstallColormap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request InstallColormap is opcode 81 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* InstallColormap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - } - - void --UninstallColormap(buf) -- unsigned char *buf; -+UninstallColormap ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request UninstallColormap is opcode 82 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* UninstallColormap */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - } - - void --ListInstalledColormaps(buf) -- unsigned char *buf; -+ListInstalledColormaps ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ListInstalledColormaps is opcode 83 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListInstalledColormaps */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, WINDOW, "window"); - } - - void --ListInstalledColormapsReply(buf) -- unsigned char *buf; -+ListInstalledColormapsReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListInstalledColormaps */ ; -@@ -2867,17 +3166,18 @@ ListInstalledColormapsReply(buf) - } - - void --AllocColor(buf) -- unsigned char *buf; -+AllocColor ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request AllocColor is opcode 84 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColor */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintField(buf, 8, 2, CARD16, "red"); - PrintField(buf, 10, 2, CARD16, "green"); -@@ -2885,8 +3185,8 @@ AllocColor(buf) - } - - void --AllocColorReply(buf) -- unsigned char *buf; -+AllocColorReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColor */ ; - if (Verbose < 1) -@@ -2900,8 +3200,9 @@ AllocColorReply(buf) - } - - void --AllocNamedColor(buf) -- unsigned char *buf; -+AllocNamedColor ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request AllocNamedColor is opcode 85 */ -@@ -2909,9 +3210,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - printfield(buf, 8, 2, DVALUE2(n), "length of name"); - n = IShort(&buf[8]); -@@ -2919,8 +3220,8 @@ AllocNamedColor(buf) - } - - void --AllocNamedColorReply(buf) -- unsigned char *buf; -+AllocNamedColorReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocNamedColor */ ; - if (Verbose < 1) -@@ -2937,26 +3238,27 @@ AllocNamedColorReply(buf) - } - - void --AllocColorCells(buf) -- unsigned char *buf; -+AllocColorCells ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request AllocColorCells is opcode 86 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColorCells */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "contiguous"); -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintField(buf, 8, 2, CARD16, "colors"); - PrintField(buf, 10, 2, CARD16, "planes"); - } - - void --AllocColorCellsReply(buf) -- unsigned char *buf; -+AllocColorCellsReply ( -+ const unsigned char *buf) - { - short n; - short m; -@@ -2975,18 +3277,19 @@ AllocColorCellsReply(buf) - } - - void --AllocColorPlanes(buf) -- unsigned char *buf; -+AllocColorPlanes ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request AllocColorPlanes is opcode 87 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* AllocColorPlanes */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, BOOL, "contiguous"); -- printfield(buf, 2, 2, CONST2(4), "request length"); -+ printreqlen(buf, fd, CONST2(4)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintField(buf, 8, 2, CARD16, "colors"); - PrintField(buf, 10, 2, CARD16, "reds"); -@@ -2995,8 +3298,8 @@ AllocColorPlanes(buf) - } - - void --AllocColorPlanesReply(buf) -- unsigned char *buf; -+AllocColorPlanesReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorPlanes */ ; -@@ -3013,8 +3316,9 @@ AllocColorPlanesReply(buf) - } - - void --FreeColors(buf) -- unsigned char *buf; -+FreeColors ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - -@@ -3023,9 +3327,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - n = IShort(&buf[2]) - 3; - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintField(buf, 8, 4, CARD32, "plane-mask"); -@@ -3033,8 +3337,9 @@ FreeColors(buf) - } - - void --StoreColors(buf) -- unsigned char *buf; -+StoreColors ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request StoreColors is opcode 89 */ -@@ -3042,17 +3347,18 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + 3*n)); - n = (IShort(&buf[2]) - 2) / 3; - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintList(&buf[8], (long)n, COLORITEM, "items"); - } - - void --StoreNamedColor(buf) -- unsigned char *buf; -+StoreNamedColor ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request StoreNamedColor is opcode 90 */ -@@ -3060,10 +3366,10 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(4 + (n + p) / 4)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintField(buf, 8, 4, CARD32, "pixel"); - printfield(buf, 12, 2, DVALUE2(n), "length of name"); -@@ -3072,8 +3378,9 @@ StoreNamedColor(buf) - } - - void --QueryColors(buf) -- unsigned char *buf; -+QueryColors ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request QueryColors is opcode 91 */ -@@ -3081,17 +3388,17 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + n)); - n = IShort(&buf[2]) - 2; - PrintField(buf, 4, 4, COLORMAP, "cmap"); - PrintList(&buf[8], (long)n, CARD32, "pixels"); - } - - void --QueryColorsReply(buf) -- unsigned char *buf; -+QueryColorsReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryColors */ ; -@@ -3105,8 +3412,9 @@ QueryColorsReply(buf) - } - - void --LookupColor(buf) -- unsigned char *buf; -+LookupColor ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request LookupColor is opcode 92 */ -@@ -3114,9 +3422,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + (n + p) / 4)); - PrintField(buf, 4, 4, COLORMAP, "cmap"); - printfield(buf, 8, 2, DVALUE2(n), "length of name"); - n = IShort(&buf[8]); -@@ -3124,8 +3432,8 @@ LookupColor(buf) - } - - void --LookupColorReply(buf) -- unsigned char *buf; -+LookupColorReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LookupColor */ ; - if (Verbose < 1) -@@ -3141,17 +3449,18 @@ LookupColorReply(buf) - } - - void --CreateCursor(buf) -- unsigned char *buf; -+CreateCursor ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CreateCursor is opcode 93 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateCursor */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(8), "request length"); -+ printreqlen(buf, fd, CONST2(8)); - PrintField(buf, 4, 4, CURSOR, "cursor-id"); - PrintField(buf, 8, 4, PIXMAP, "source"); - PrintField(buf, 12, 4, PIXMAP, "mask"); -@@ -3166,17 +3475,18 @@ CreateCursor(buf) - } - - void --CreateGlyphCursor(buf) -- unsigned char *buf; -+CreateGlyphCursor ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request CreateGlyphCursor is opcode 94 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateGlyphCursor */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(8), "request length"); -+ printreqlen(buf, fd, CONST2(8)); - PrintField(buf, 4, 4, CURSOR, "cursor-id"); - PrintField(buf, 8, 4, FONT, "source-font"); - PrintField(buf, 12, 4, FONT, "mask-font"); -@@ -3191,32 +3501,34 @@ CreateGlyphCursor(buf) - } - - void --FreeCursor(buf) -- unsigned char *buf; -+FreeCursor ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request FreeCursor is opcode 95 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeCursor */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, CURSOR, "cursor"); - } - - void --RecolorCursor(buf) -- unsigned char *buf; -+RecolorCursor ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request RecolorCursor is opcode 96 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* RecolorCursor */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(5), "request length"); -+ printreqlen(buf, fd, CONST2(5)); - PrintField(buf, 4, 4, CURSOR, "cursor"); - PrintField(buf, 8, 2, CARD16, "fore-red"); - PrintField(buf, 10, 2, CARD16, "fore-green"); -@@ -3227,26 +3539,27 @@ RecolorCursor(buf) - } - - void --QueryBestSize(buf) -- unsigned char *buf; -+QueryBestSize ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request QueryBestSize is opcode 97 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryBestSize */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, OBJECTCLASS, "class"); -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 4, DRAWABLE, "drawable"); - PrintField(buf, 8, 2, CARD16, "width"); - PrintField(buf, 10, 2, CARD16, "height"); - } - - void --QueryBestSizeReply(buf) -- unsigned char *buf; -+QueryBestSizeReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryBestSize */ ; - if (Verbose < 1) -@@ -3258,8 +3571,9 @@ QueryBestSizeReply(buf) - } - - void --QueryExtension(buf) -- unsigned char *buf; -+QueryExtension ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request QueryExtension is opcode 98 */ -@@ -3267,17 +3581,17 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - printfield(buf, 4, 2, DVALUE2(n), "length of name"); - n = IShort(&buf[4]); -- PrintString8(&buf[8], n, "name"); -+ PrintString8(&buf[8], (long)n, "name"); - } - - void --QueryExtensionReply(buf) -- unsigned char *buf; -+QueryExtensionReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryExtension */ ; - if (Verbose < 1) -@@ -3291,22 +3605,23 @@ QueryExtensionReply(buf) - } - - void --ListExtensions(buf) -- unsigned char *buf; -+ListExtensions ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ListExtensions is opcode 99 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListExtensions */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --ListExtensionsReply(buf) -- unsigned char *buf; -+ListExtensionsReply ( -+ const unsigned char *buf) - { - short n; - -@@ -3321,8 +3636,9 @@ ListExtensionsReply(buf) - } - - void --ChangeKeyboardMapping(buf) -- unsigned char *buf; -+ChangeKeyboardMapping ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - short m; -@@ -3331,11 +3647,11 @@ 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]); -- printfield(buf, 2, 2, DVALUE2(2 + nm), "request length"); -+ printreqlen(buf, fd, DVALUE2(2 + nm)); - PrintField(buf, 4, 1, KEYCODE, "first-keycode"); - PrintField(buf, 5, 1, DVALUE1(m), "keysyms-per-keycode"); - m = IByte(&buf[5]); -@@ -3343,24 +3659,25 @@ ChangeKeyboardMapping(buf) - } - - void --GetKeyboardMapping(buf) -- unsigned char *buf; -+GetKeyboardMapping ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetKeyboardMapping is opcode 101 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetKeyboardMapping */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 1, KEYCODE, "first-keycode"); - PrintField(buf, 5, 1, CARD8, "count"); - } - - void --GetKeyboardMappingReply(buf) -- unsigned char *buf; -+GetKeyboardMappingReply ( -+ const unsigned char *buf) - { - long n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetKeyboardMapping */ ; -@@ -3374,38 +3691,40 @@ GetKeyboardMappingReply(buf) - } - - void --ChangeKeyboardControl(buf) -- unsigned char *buf; -+ChangeKeyboardControl ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ChangeKeyboardControl is opcode 102 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeKeyboardControl */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, DVALUE2(2 + n), "request length"); -+ printreqlen(buf, fd, DVALUE2(2 + n)); - PrintField(buf, 4, 4, KEYBOARD_BITMASK, "value-mask"); - PrintValues(&buf[4], 4, KEYBOARD_BITMASK, &buf[8], "value-list"); - } - - void --GetKeyboardControl(buf) -- unsigned char *buf; -+GetKeyboardControl ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetKeyboardControl is opcode 103 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetKeyboardControl */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetKeyboardControlReply(buf) -- unsigned char *buf; -+GetKeyboardControlReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetKeyboardControl */ ; - if (Verbose < 1) -@@ -3422,32 +3741,34 @@ GetKeyboardControlReply(buf) - } - - void --Bell(buf) -- unsigned char *buf; -+Bell ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request Bell is opcode 104 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* Bell */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, INT8, "percent"); -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --ChangePointerControl(buf) -- unsigned char *buf; -+ChangePointerControl ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ChangePointerControl is opcode 105 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangePointerControl */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 2, INT16, "acceleration-numerator"); - PrintField(buf, 6, 2, INT16, "acceleration-denominator"); - PrintField(buf, 8, 2, INT16, "threshold"); -@@ -3456,22 +3777,23 @@ ChangePointerControl(buf) - } - - void --GetPointerControl(buf) -- unsigned char *buf; -+GetPointerControl ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetPointerControl is opcode 106 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetPointerControl */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetPointerControlReply(buf) -- unsigned char *buf; -+GetPointerControlReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerControl */ ; - if (Verbose < 1) -@@ -3484,17 +3806,18 @@ GetPointerControlReply(buf) - } - - void --SetScreenSaver(buf) -- unsigned char *buf; -+SetScreenSaver ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SetScreenSaver is opcode 107 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetScreenSaver */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(3), "request length"); -+ printreqlen(buf, fd, CONST2(3)); - PrintField(buf, 4, 2, INT16, "timeout"); - PrintField(buf, 6, 2, INT16, "interval"); - PrintField(buf, 8, 1, NO_YES, "prefer-blanking"); -@@ -3502,22 +3825,23 @@ SetScreenSaver(buf) - } - - void --GetScreenSaver(buf) -- unsigned char *buf; -+GetScreenSaver ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetScreenSaver is opcode 108 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetScreenSaver */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetScreenSaverReply(buf) -- unsigned char *buf; -+GetScreenSaverReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetScreenSaver */ ; - if (Verbose < 1) -@@ -3531,8 +3855,9 @@ GetScreenSaverReply(buf) - } - - void --ChangeHosts(buf) -- unsigned char *buf; -+ChangeHosts ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request ChangeHosts is opcode 109 */ -@@ -3540,10 +3865,10 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(2 + (n + p) / 4)); - n = IShort(&buf[6]); - #if 0 - PrintField(buf, 4, 1, HOSTFAMILY, "family"); -@@ -3555,22 +3880,23 @@ ChangeHosts(buf) - } - - void --ListHosts(buf) -- unsigned char *buf; -+ListHosts ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ListHosts is opcode 110 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListHosts */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --ListHostsReply(buf) -- unsigned char *buf; -+ListHostsReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListHosts */ ; -@@ -3585,53 +3911,57 @@ ListHostsReply(buf) - } - - void --SetAccessControl(buf) -- unsigned char *buf; -+SetAccessControl ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SetAccessControl is opcode 111 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetAccessControl */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, DIS_EN, "mode"); -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --SetCloseDownMode(buf) -- unsigned char *buf; -+SetCloseDownMode ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request SetCloseDownMode is opcode 112 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* SetCloseDownMode */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, CLOSEMODE, "mode"); -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --KillClient(buf) -- unsigned char *buf; -+KillClient ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request KillClient is opcode 113 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* KillClient */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(2), "request length"); -+ printreqlen(buf, fd, CONST2(2)); - PrintField(buf, 4, 4, RESOURCEID, "resource"); - } - - void --RotateProperties(buf) -- unsigned char *buf; -+RotateProperties ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request RotateProperties is opcode 114 */ -@@ -3639,9 +3969,9 @@ 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"); -+ printreqlen(buf, fd, DVALUE2(3 + n)); - PrintField(buf, 4, 4, WINDOW, "window"); - printfield(buf, 8, 2, DVALUE2(n), "number of properties"); - n = IShort(&buf[8]); -@@ -3650,23 +3980,25 @@ RotateProperties(buf) - } - - void --ForceScreenSaver(buf) -- unsigned char *buf; -+ForceScreenSaver ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request ForceScreenSaver is opcode 115 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ForceScreenSaver */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - - PrintField(buf, 1, 1, SAVEMODE, "mode"); -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --SetPointerMapping(buf) -- unsigned char *buf; -+SetPointerMapping ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request SetPointerMapping is opcode 116 */ -@@ -3674,17 +4006,17 @@ 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]); -- printfield(buf, 2, 2, DVALUE2(1 + (n + p) / 4), "request length"); -+ printreqlen(buf, fd, DVALUE2(1 + (n + p) / 4)); - PrintBytes(&buf[4], (long)n,"map"); - } - - void --SetPointerMappingReply(buf) -- unsigned char *buf; -+SetPointerMappingReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* SetPointerMapping */ ; - if (Verbose < 1) -@@ -3695,22 +4027,23 @@ SetPointerMappingReply(buf) - } - - void --GetPointerMapping(buf) -- unsigned char *buf; -+GetPointerMapping ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetPointerMapping is opcode 117 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetPointerMapping */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetPointerMappingReply(buf) -- unsigned char *buf; -+GetPointerMappingReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerMapping */ ; -@@ -3724,8 +4057,9 @@ GetPointerMappingReply(buf) - } - - void --SetModifierMapping(buf) -- unsigned char *buf; -+SetModifierMapping ( -+ FD fd, -+ const unsigned char *buf) - { - short n; - /* Request SetModifierMapping is opcode 118 */ -@@ -3733,11 +4067,11 @@ 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]); -- printfield(buf, 2, 2, DVALUE2(1 + 2*n), "request length"); -+ printreqlen(buf, fd, DVALUE2(1 + 2*n)); - PrintBytes(&buf[4 + 0 * n], (long)n,"Shift keycodes"); - PrintBytes(&buf[4 + 1 * n], (long)n,"Lock keycodes"); - PrintBytes(&buf[4 + 2 * n], (long)n,"Control keycodes"); -@@ -3749,8 +4083,8 @@ SetModifierMapping(buf) - } - - void --SetModifierMappingReply(buf) -- unsigned char *buf; -+SetModifierMappingReply ( -+ const unsigned char *buf) - { - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* SetModifierMapping */ ; - if (Verbose < 1) -@@ -3761,22 +4095,23 @@ SetModifierMappingReply(buf) - } - - void --GetModifierMapping(buf) -- unsigned char *buf; -+GetModifierMapping ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request GetModifierMapping is opcode 119 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* GetModifierMapping */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } - - void --GetModifierMappingReply(buf) -- unsigned char *buf; -+GetModifierMappingReply ( -+ const unsigned char *buf) - { - short n; - PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetModifierMapping */ ; -@@ -3790,15 +4125,16 @@ GetModifierMappingReply(buf) - } - - void --NoOperation(buf) -- unsigned char *buf; -+NoOperation ( -+ FD fd, -+ const unsigned char *buf) - { - /* Request NoOperation is opcode 127 */ - PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* NoOperation */ ; - if (Verbose < 1) - return; - if (Verbose > 1) -- PrintField(SBf, 0, 4, INT32, "sequence number"); -+ PrintField(SBf, 0, 4, CARD32, "sequence number"); - -- printfield(buf, 2, 2, CONST2(1), "request length"); -+ printreqlen(buf, fd, CONST2(1)); - } -diff --git a/print_bigreq.c b/print_bigreq.c -new file mode 100644 -index 0000000..7871826 ---- /dev/null -+++ b/print_bigreq.c -@@ -0,0 +1,51 @@ -+/* -+ * $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" -+ -+void -+BigreqEnable (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+BigreqEnableReply (FD fd, const unsigned char *buf) -+{ -+ 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..2ec880c ---- /dev/null -+++ b/print_lbx.c -@@ -0,0 +1,210 @@ -+/* -+ * $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; -+ -+void -+LbxQueryVersion ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+LbxQueryVersionReply ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+LbxStartProxy ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+LbxStopProxy ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+LbxNewClient ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, CARD32, "new-client-id"); -+} -+ -+void -+LbxCloseClient ( -+ FD fd, -+ const unsigned char *buf) -+{ -+} -+ -+void -+LbxSwitch ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, CARD32, "client number"); -+} -+ -+void -+LbxModifySequence ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ printfield(buf, 4, 4, INT32, "adjustment"); -+} -+ -+void -+LbxSwitchEvent ( -+ FD fd, -+ const 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"); -+} -+ -+void -+LbxCloseEvent ( -+ FD fd, -+ const 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_randr.c b/print_randr.c -new file mode 100644 -index 0000000..f987ebc ---- /dev/null -+++ b/print_randr.c -@@ -0,0 +1,168 @@ -+/* -+ * $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" -+ -+void -+RandrQueryVersion (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RandrQueryVersionReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+RandrGetScreenInfo (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, WINDOW, "window"); -+} -+ -+void -+RandrGetScreenInfoReply (FD fd, const unsigned char *buf) -+{ -+ unsigned short nsize; -+ unsigned short nvg; -+ unsigned short ngvg; -+ -+ PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ; -+ if (Verbose < 1) -+ return; -+ PrintField(buf, 1, 1, CARD8, "set-of-rotations"); -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ printfield(buf, 4, 4, DVALUE4(0), "reply length"); -+ PrintField(buf, 8, 4, WINDOW, "root"); -+ PrintField(buf,12, 4, TIMESTAMP, "timestamp"); -+ PrintField(buf,16, 4, TIMESTAMP, "config-timestamp"); -+ PrintField(buf,20, 2, CARD16, "num-visual-groups"); -+ nvg = IShort (&buf[20]); -+ PrintField(buf,22, 2, CARD16, "num-groups-of-visual-groups"); -+ ngvg = IShort (&buf[22]); -+ PrintField(buf,24, 2, CARD16, "num-sizes"); -+ nsize = IShort (&buf[24]); -+ PrintField(buf,26, 2, CARD16, "size-id"); -+ PrintField(buf,28, 2, CARD16, "visual-group-id"); -+ PrintField(buf,30, 2, CARD16, "rotation"); -+} -+ -+void -+RandrSetScreenConfig (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ 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"); -+} -+ -+void -+RandrSetScreenConfigReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+RandrScreenChangeSelectInput (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, WINDOW, "window"); -+ PrintField(buf, 8, 1, BOOL, "enable"); -+} -+ -+void -+RandrScreenSizes (const 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"); -+} -+ -+void -+RandrScreenChangeNotifyEvent (const 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..212fc27 ---- /dev/null -+++ b/print_render.c -@@ -0,0 +1,631 @@ -+/* -+ * $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" -+ -+void -+RenderQueryVersion (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderQueryVersionReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+RenderQueryPictFormats (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderQueryPictFormatsReply (FD fd, const unsigned char *buf) -+{ -+ long n; -+ long f; -+ long s; -+ long d; -+ long v; -+ -+ 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"); -+ n = ILong (&buf[4]); -+ f = ILong (&buf[8]); -+ s = ILong (&buf[12]); -+ d = ILong (&buf[16]); -+ v = ILong (&buf[20]); -+ PrintList (&buf[32], (long) f, PICTFORMINFO, "pict-formats"); -+} -+ -+void -+RenderQueryPictIndexValues (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderQueryPictIndexValuesReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+RenderQueryDithers (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderQueryDithersReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+RenderCreatePicture (FD fd, const 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"); -+ -+ printreqlen(buf, fd, DVALUE2(5+n)); -+ 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"); -+} -+ -+void -+RenderChangePicture (FD fd, const 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"); -+ -+ printreqlen(buf, fd, DVALUE2(3+n)); -+ PrintField(buf, 4, 4, PICTURE, "picture"); -+ PrintField(buf, 8, 4, PICTURE_BITMASK, "value-mask"); -+ PrintValues(&buf[8], 4, PICTURE_BITMASK, &buf[12], "value-list"); -+} -+ -+void -+RenderSetPictureClipRectangles (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderFreePicture (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderComposite (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderScale (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderTrapezoids (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ 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, 2, CARD16, "source x"); -+ PrintField(buf, 22, 2, CARD16, "source y"); -+ n = (CS[fd].requestLen - 6) / 10; -+ PrintList(&buf[24], (long)n, TRAPEZOID, "trapezoids"); -+} -+ -+void -+RenderTriangles (FD fd, const unsigned char *buf) -+{ -+ long 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ 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, 2, CARD16, "source x"); -+ PrintField(buf, 22, 2, CARD16, "source y"); -+ n = (CS[fd].requestLen - 6) / 6; -+ PrintList(&buf[24], (long)n, TRIANGLE, "triangles"); -+} -+ -+void -+RenderTriStrip (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderTriFan (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderColorTrapezoids (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderColorTriangles (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderTransform (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderCreateGlyphSet (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, GLYPHSET, "glyphset"); -+ PrintField(buf, 8, 4, PICTFORMAT, "format"); -+} -+ -+void -+RenderReferenceGlyphSet (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+RenderFreeGlyphSet (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, GLYPHSET, "glyphset"); -+} -+ -+static void -+PrintGlyphs(const unsigned char *buf, int n, char *name) -+{ -+ const unsigned char *gids; -+ const unsigned char *glyphs; -+ int i; -+ -+ fprintf(stdout, "%s%20s:\n", Leader, name); -+ gids = buf; -+ glyphs = gids + 4 * n; -+ for (i = 0; i < n; i++) -+ { -+ PrintField(gids, 0, 4, CARD32, "glyphid"); -+ PrintField(glyphs, 0, 2, CARD16, "width"); -+ PrintField(glyphs, 2, 2, CARD16, "height"); -+ PrintField(glyphs, 4, 2, INT16, "x"); -+ PrintField(glyphs, 6, 2, INT16, "y"); -+ PrintField(glyphs, 8, 2, INT16, "xOff"); -+ PrintField(glyphs, 10, 2, INT16, "yOff"); -+ glyphs += 12; -+ } -+} -+ -+void -+RenderAddGlyphs (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, GLYPHSET, "glyphset"); -+ PrintField(buf, 8, 4, CARD32, "nglyphs"); -+ PrintGlyphs(&buf[12], ILong(&buf[8]), "glyphs"); -+} -+ -+void -+RenderAddGlyphsFromPicture (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ -+} -+ -+void -+RenderFreeGlyphs (FD fd, const unsigned char *buf) -+{ -+ unsigned short 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, GLYPHSET, "glyphset"); -+ n = (IShort(&buf[2]) - 2); -+ (void)PrintList(&buf[8], (long)n, CARD32, "glyphs"); -+} -+ -+static void -+PrintGlyphList(const 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; -+ } -+ n = ((n * size + 8) + 3) & ~3; -+ buf += n; -+ length -= n; -+ } -+ else -+ { -+ PrintField(buf, 8, 4, GLYPHSET, "glyphset"); -+ buf += 12; -+ length -= 12; -+ } -+ } -+} -+ -+void -+RenderCompositeGlyphs8 (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ n = (CS[fd].requestLen - 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); -+} -+ -+void -+RenderCompositeGlyphs16 (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ n = (CS[fd].requestLen - 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); -+} -+ -+void -+RenderCompositeGlyphs32 (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ n = (CS[fd].requestLen - 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); -+} -+ -+void -+RenderFillRectangles (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ n = (CS[fd].requestLen - 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"); -+} -+ -+void -+RenderPictFormatError (FD fd, const unsigned char *buf) -+{ -+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; -+ if (Verbose < 1) -+ return; -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ PrintField(buf, 4, 4, PICTFORMAT, "format"); -+ PrintField(buf, 8, 2, CARD16, "minor opcode"); -+ PrintField(buf, 10, 1, CARD8, "major opcode"); -+} -+ -+void -+RenderPictureError (FD fd, const unsigned char *buf) -+{ -+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; -+ if (Verbose < 1) -+ return; -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ PrintField(buf, 4, 4, PICTURE, "picture"); -+ PrintField(buf, 8, 2, CARD16, "minor opcode"); -+ PrintField(buf, 10, 1, CARD8, "major opcode"); -+} -+ -+void -+RenderPictOpError (FD fd, const unsigned char *buf) -+{ -+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; -+ if (Verbose < 1) -+ return; -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ PrintField(buf, 4, 4, PICTOP, "pictop"); -+ PrintField(buf, 8, 2, CARD16, "minor opcode"); -+ PrintField(buf, 10, 1, CARD8, "major opcode"); -+} -+ -+void -+RenderGlyphSetError (FD fd, const unsigned char *buf) -+{ -+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; -+ if (Verbose < 1) -+ return; -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ PrintField(buf, 4, 4, GLYPHSET, "glyphset"); -+ PrintField(buf, 8, 2, CARD16, "minor opcode"); -+ PrintField(buf, 10, 1, CARD8, "major opcode"); -+} -+ -+void -+RenderGlyphError (FD fd, const unsigned char *buf) -+{ -+ PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; -+ if (Verbose < 1) -+ return; -+ printfield(buf, 2, 2, CARD16, "sequence number"); -+ PrintField(buf, 4, 4, CARD32, "glyph"); -+ PrintField(buf, 8, 2, CARD16, "minor opcode"); -+ PrintField(buf, 10, 1, CARD8, "major opcode"); -+} -diff --git a/print_shm.c b/print_shm.c -new file mode 100644 -index 0000000..02a30d9 ---- /dev/null -+++ b/print_shm.c -@@ -0,0 +1,174 @@ -+/* -+ * $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" -+ -+void -+MitshmQueryVersion (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+MitshmQueryVersionReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+MitshmAttach (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField(buf, 4, 4, CARD32, "shmseg"); -+ PrintField(buf, 8, 4, CARD32, "shmid"); -+ PrintField(buf, 12, 1, BOOL, "read-only"); -+} -+ -+void -+MitshmDetach (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ PrintField (buf, 4, 4, CARD32, "shmseg"); -+} -+ -+void -+MitshmPutImage (FD fd, const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ 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"); -+} -+ -+void -+MitshmGetImage (FD fd, const 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"); -+ -+ printreqlen(buf, fd, DVALUE2(5+n)); -+ 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"); -+} -+ -+void -+MitshmGetImageReply (FD fd, const unsigned char *buf) -+{ -+ 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"); -+} -+ -+void -+MitshmCreatePixmap (FD fd, const 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"); -+ -+ printreqlen(buf, fd, DVALUE2(3+n)); -+ 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"); -+} -+ -+void -+MitshmShmSegError (FD fd, const unsigned char *buf) -+{ -+} -diff --git a/print_wcp.c b/print_wcp.c -new file mode 100644 -index 0000000..b9bbbc3 ---- /dev/null -+++ b/print_wcp.c -@@ -0,0 +1,464 @@ -+/* -+ * $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" -+ -+void -+WcpQueryVersion ( -+ FD fd, -+ register const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+WcpQueryVersionReply ( -+ FD fd, -+ const unsigned char *buf) -+{ -+ 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++; -+ -+static void -+WcpAnalyzeImage1RLL ( -+ const char *buf, -+ int len, -+ int width, -+ int height) -+{ -+ unsigned char byte; -+ unsigned char *data = (unsigned char *) buf; -+ int x, y; -+ const char *error = NULL; -+ 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); -+} -+ -+static void -+WcpAnalyzeImageNRLL ( -+ const 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 ( -+ 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 ( -+ 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 ( -+ 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 void -+WcpAnalyzeImageNLRU ( -+ const 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; -+ const char *error = NULL; -+ -+ 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, " %3ld:%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); -+} -+ -+static void -+WcpAnalyzeImage ( -+ const 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); -+} -+ -+void -+WcpPutImage ( -+ FD fd, -+ const 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; -+ printreqlen(buf, fd, DVALUE2(7 + (n + p) / 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, 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 ((const char *) &buf[28], (long) n, buf[24], buf[25], -+ IShort(&buf[20]) + buf[26], -+ IShort(&buf[22])); -+ PrintBytes(&buf[28], (long)n, "data"); -+} -+ -+void -+WcpGetImage ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+ 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"); -+} -+ -+void -+WcpGetImageReply ( -+ FD fd, -+ const 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"); -+} -+ -+void -+WcpCreateColorCursor ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+WcpCreateLut ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+WcpFreeLut ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -+ -+void -+WcpCopyArea ( -+ FD fd, -+ const 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"); -+ -+ printreqlen(buf, fd, CONST2(2)); -+} -diff --git a/printnas.c b/printnas.c -new file mode 100644 -index 0000000..64d8dad ---- /dev/null -+++ b/printnas.c -@@ -0,0 +1,1012 @@ -+/* ************************************************** * -+ * * -+ * 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) -+ -+static void PrintFailedAudioSetUpReply (const unsigned char *buf); -+static void PrintSuccessfulAudioSetUpReply (const unsigned char *buf); -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+void -+PrintAudioSetUpMessage( -+ const 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"); -+} -+ -+void -+PrintAudioSetUpReply(const unsigned char *buf) -+{ -+ enterprocedure("PrintSetUpReply"); -+ SetIndentLevel(PRINTSERVER); -+ if (IByte(&buf[0])) -+ PrintSuccessfulAudioSetUpReply(buf); -+ else -+ PrintFailedAudioSetUpReply(buf); -+} -+ -+static void -+PrintFailedAudioSetUpReply(const 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"); -+} -+ -+static void -+PrintSuccessfulAudioSetUpReply( -+ const 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"); -+} -+ -+ -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+/* Error Printing procedures */ -+ -+static void -+AudioRequestError( -+ const 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"); -+} -+ -+static void -+AudioValueError( -+ const 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"); -+} -+ -+static void -+AudioMatchError( -+ const 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"); -+} -+ -+static void -+AudioAccessError( -+ const 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"); -+} -+ -+static void -+AudioAllocError( -+ const 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"); -+} -+ -+static void -+AudioIDChoiceError( -+ const 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"); -+} -+ -+static void -+AudioLengthError( -+ const 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"); -+} -+ -+static void -+AudioImplementationError( -+ const 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 */ -+ -+void -+AudioElementNotify ( -+ const 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"); -+} -+ -+void -+AudioGrabNotify ( -+ const unsigned char *buf) -+{ -+} -+ -+void -+AudioMonitorNotify ( -+ const 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"); -+} -+ -+void -+AudioBucketNotify ( -+ const unsigned char *buf) -+{ -+} -+ -+void -+AudioDeviceNotify ( -+ const unsigned char *buf) -+{ -+} -+ -+/* ************************************************************ */ -+/* */ -+/* */ -+/* ************************************************************ */ -+ -+/* Request and Reply Printing procedures */ -+ -+void -+UnknownAudioReply( -+ const 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"); -+} -+ -+void -+AudioListDevices ( -+ const 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"); -+} -+ -+void -+AudioListDevicesReply( -+ const 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 long -+AuString ( -+ const 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 void -+AuDeviceAttributes ( -+ const 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]); -+} -+ -+void -+AudioGetDeviceAttributes ( -+ const 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"); -+} -+ -+void -+AudioGetDeviceAttributesReply ( -+ const 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]); -+} -+ -+void -+AudioSetDeviceAttributes ( -+ const 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]); -+} -+ -+void -+AudioCreateBucket ( -+ const 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"); -+} -+ -+void -+AudioDestroyBucket ( -+ const 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"); -+} -+ -+void -+AudioListBuckets ( -+ const 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"); -+} -+ -+void -+AudioListBucketsReply ( -+ const 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"); -+} -+ -+void -+AudioGetBucketAttributes ( -+ const 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"); -+} -+ -+void -+AudioGetBucketAttributesReply ( -+ const 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"); -+} -+ -+void -+AudioSetBucketAttributes ( -+ const 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"); -+} -+ -+void -+AudioCreateRadio ( -+ const 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"); -+} -+ -+void -+AudioDestroyRadio ( -+ const 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"); -+} -+ -+void -+AudioListRadios ( -+ const 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"); -+} -+ -+void -+AudioListRadiosReply ( -+ const 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"); -+} -+ -+void -+AudioGetRadioAttributes ( -+ const 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"); -+} -+ -+void -+AudioGetRadioAttributesReply ( -+ const 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"); -+} -+ -+void -+AudioSetRadioAttributes ( -+ const 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"); -+} -+ -+void -+AudioCreateFlow ( -+ const 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"); -+} -+ -+void -+AudioDestroyFlow ( -+ const 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"); -+} -+ -+void -+AudioGetFlowAttributes ( -+ const 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"); -+} -+ -+void -+AudioGetFlowAttributesReply ( -+ const 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"); -+} -+ -+void -+AudioSetFlowAttributes ( -+ const 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"); -+} -+ -+void -+AudioGetElements ( -+ const 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"); -+} -+ -+void -+AudioGetElementsReply ( -+ const 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"); -+} -+ -+void -+AudioSetElements ( -+ const 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"); -+} -+ -+void -+AudioGetElementStates ( -+ const 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"); -+} -+ -+void -+AudioElementState ( -+ const unsigned char *buf) -+{ -+ printfield(buf, 0, 4, CARD32, "flow"); -+ printfield(buf, 4, 1, CARD8, "element number"); -+ printfield(buf, 5, 1, CARD8, "state"); -+} -+ -+void -+AudioGetElementStatesReply ( -+ const 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; -+ } -+} -+ -+void -+AudioSetElementStates ( -+ const 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; -+ } -+} -+ -+void -+AudioGetElementParameters ( -+ const 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"); -+} -+ -+void -+AudioGetElementParametersReply ( -+ const 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"); -+} -+ -+void -+AudioSetElementParameters ( -+ const 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"); -+} -+ -+void -+AudioWriteElement ( -+ const 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"); -+} -+ -+void -+AudioReadElement ( -+ const 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"); -+} -+ -+void -+AudioReadElementReply ( -+ const 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"); -+} -+ -+void -+AudioGrabComponent ( -+ const 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"); -+} -+ -+void -+AudioUngrabComponent ( -+ const 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"); -+} -+ -+void -+AudioSendEvent ( -+ const 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"); -+} -+ -+void -+AudioGetAllowedUsers ( -+ const 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"); -+} -+ -+void -+AudioGetAllowedUsersReply ( -+ const 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"); -+} -+ -+void -+AudioSetAllowedUsers ( -+ const 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"); -+} -+ -+void -+AudioListExtensions ( -+ const 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"); -+} -+ -+void -+AudioListExtensionsReply ( -+ const 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"); -+} -+ -+void -+AudioQueryExtension ( -+ const 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"); -+} -+ -+void -+AudioQueryExtensionReply ( -+ const 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"); -+} -+ -+void -+AudioGetCloseDownMode ( -+ const 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"); -+} -+ -+void -+AudioGetCloseDownModeReply ( -+ const 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"); -+} -+ -+void -+AudioSetCloseDownMode ( -+ const 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"); -+} -+ -+void -+AudioKillClient ( -+ const 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"); -+} -+ -+void -+AudioGetServerTime ( -+ const 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"); -+} -+ -+void -+AudioGetServerTimeReply ( -+ const 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"); -+} -+ -+void -+AudioNoOperation ( -+ const 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/proto.h b/proto.h -index 397cb6b..ce30e56 100644 ---- a/proto.h -+++ b/proto.h -@@ -1,266 +1,299 @@ - #include "x11.h" - - /* common.c */ --void enterprocedure(char *s); --void warn(char *s); --void panic(char *s); --void *Malloc(long n); --void Free(void *p); --void SetSignalHandling(void); --void SetUpConnectionSocket(int iport); -+extern void enterprocedure (char *s); -+extern void warn (char *s); -+extern void panic (char *s); -+extern void *Malloc (long n); -+extern void Free (void *p); -+extern void SetSignalHandling (void); -+extern void SetUpConnectionSocket (int iport, void (*connectionFunc) (int)); -+ - /* decode11.c */ --void InitReplyQ(void); --void FlushReplyQ(FD fd); --void KeepLastReplyExpected(void); --void DecodeRequest(FD fd, unsigned char *buf, long n); --void DecodeReply(FD fd, unsigned char *buf, long n); --void DecodeError(FD fd, unsigned char *buf, long n); --void DecodeEvent(FD fd, unsigned char *buf, long n); -+extern void InitReplyQ (void); -+extern void FlushReplyQ (FD fd); -+extern short CheckReplyTable (FD fd, short SequenceNumber, short *minorp); -+extern void ReplyExpected (FD fd, short Request); -+extern void ExtendedReplyExpected (FD fd, short Request, short RequestMinor); -+extern void KeepLastReplyExpected (void); -+ -+extern void DecodeRequest (FD fd, const unsigned char *buf, long n); -+extern void DecodeReply (FD fd, const unsigned char *buf, long n); -+extern void DecodeError (FD fd, const unsigned char *buf, long n); -+extern void DecodeEvent (FD fd, const unsigned char *buf, long n); -+ - /* print11.c */ --void PrintSetUpMessage(unsigned char *buf); --void PrintSetUpReply(unsigned char *buf); --void RequestError(unsigned char *buf); --void ValueError(unsigned char *buf); --void WindowError(unsigned char *buf); --void PixmapError(unsigned char *buf); --void AtomError(unsigned char *buf); --void CursorError(unsigned char *buf); --void FontError(unsigned char *buf); --void MatchError(unsigned char *buf); --void DrawableError(unsigned char *buf); --void AccessError(unsigned char *buf); --void AllocError(unsigned char *buf); --void ColormapError(unsigned char *buf); --void GContextError(unsigned char *buf); --void IDChoiceError(unsigned char *buf); --void NameError(unsigned char *buf); --void LengthError(unsigned char *buf); --void ImplementationError(unsigned char *buf); --void KeyPressEvent(unsigned char *buf); --void KeyReleaseEvent(unsigned char *buf); --void ButtonPressEvent(unsigned char *buf); --void ButtonReleaseEvent(unsigned char *buf); --void MotionNotifyEvent(unsigned char *buf); --void EnterNotifyEvent(unsigned char *buf); --void LeaveNotifyEvent(unsigned char *buf); --void FocusInEvent(unsigned char *buf); --void FocusOutEvent(unsigned char *buf); --void KeymapNotifyEvent(unsigned char *buf); --void ExposeEvent(unsigned char *buf); --void GraphicsExposureEvent(unsigned char *buf); --void NoExposureEvent(unsigned char *buf); --void VisibilityNotifyEvent(unsigned char *buf); --void CreateNotifyEvent(unsigned char *buf); --void DestroyNotifyEvent(unsigned char *buf); --void UnmapNotifyEvent(unsigned char *buf); --void MapNotifyEvent(unsigned char *buf); --void MapRequestEvent(unsigned char *buf); --void ReparentNotifyEvent(unsigned char *buf); --void ConfigureNotifyEvent(unsigned char *buf); --void ConfigureRequestEvent(unsigned char *buf); --void GravityNotifyEvent(unsigned char *buf); --void ResizeRequestEvent(unsigned char *buf); --void CirculateNotifyEvent(unsigned char *buf); --void CirculateRequestEvent(unsigned char *buf); --void PropertyNotifyEvent(unsigned char *buf); --void SelectionClearEvent(unsigned char *buf); --void SelectionRequestEvent(unsigned char *buf); --void SelectionNotifyEvent(unsigned char *buf); --void ColormapNotifyEvent(unsigned char *buf); --void ClientMessageEvent(unsigned char *buf); --void MappingNotifyEvent(unsigned char *buf); --void CreateWindow(unsigned char *buf); --void ChangeWindowAttributes(unsigned char *buf); --void GetWindowAttributes(unsigned char *buf); --void GetWindowAttributesReply(unsigned char *buf); --void DestroyWindow(unsigned char *buf); --void DestroySubwindows(unsigned char *buf); --void ChangeSaveSet(unsigned char *buf); --void ReparentWindow(unsigned char *buf); --void MapWindow(unsigned char *buf); --void MapSubwindows(unsigned char *buf); --void UnmapWindow(unsigned char *buf); --void UnmapSubwindows(unsigned char *buf); --void ConfigureWindow(unsigned char *buf); --void CirculateWindow(unsigned char *buf); --void GetGeometry(unsigned char *buf); --void GetGeometryReply(unsigned char *buf); --void QueryTree(unsigned char *buf); --void QueryTreeReply(unsigned char *buf); --void InternAtom(unsigned char *buf); --void InternAtomReply(unsigned char *buf); --void GetAtomName(unsigned char *buf); --void GetAtomNameReply(unsigned char *buf); --void ChangeProperty(unsigned char *buf); --void DeleteProperty(unsigned char *buf); --void GetProperty(unsigned char *buf); --void GetPropertyReply(unsigned char *buf); --void ListProperties(unsigned char *buf); --void ListPropertiesReply(unsigned char *buf); --void SetSelectionOwner(unsigned char *buf); --void GetSelectionOwner(unsigned char *buf); --void GetSelectionOwnerReply(unsigned char *buf); --void ConvertSelection(unsigned char *buf); --void SendEvent(unsigned char *buf); --void GrabPointer(unsigned char *buf); --void GrabPointerReply(unsigned char *buf); --void UngrabPointer(unsigned char *buf); --void GrabButton(unsigned char *buf); --void UngrabButton(unsigned char *buf); --void ChangeActivePointerGrab(unsigned char *buf); --void GrabKeyboard(unsigned char *buf); --void GrabKeyboardReply(unsigned char *buf); --void UngrabKeyboard(unsigned char *buf); --void GrabKey(unsigned char *buf); --void UngrabKey(unsigned char *buf); --void AllowEvents(unsigned char *buf); --void GrabServer(unsigned char *buf); --void UngrabServer(unsigned char *buf); --void QueryPointer(unsigned char *buf); --void QueryPointerReply(unsigned char *buf); --void GetMotionEvents(unsigned char *buf); --void GetMotionEventsReply(unsigned char *buf); --void TranslateCoordinates(unsigned char *buf); --void TranslateCoordinatesReply(unsigned char *buf); --void WarpPointer(unsigned char *buf); --void SetInputFocus(unsigned char *buf); --void GetInputFocus(unsigned char *buf); --void GetInputFocusReply(unsigned char *buf); --void QueryKeymap(unsigned char *buf); --void QueryKeymapReply(unsigned char *buf); --void OpenFont(unsigned char *buf); --void CloseFont(unsigned char *buf); --void QueryFont(unsigned char *buf); --void QueryFontReply(unsigned char *buf); --void QueryTextExtents(unsigned char *buf); --void QueryTextExtentsReply(unsigned char *buf); --void ListFonts(unsigned char *buf); --void ListFontsReply(unsigned char *buf); --void ListFontsWithInfo(unsigned char *buf); --void ListFontsWithInfoReply(unsigned char *buf); --void SetFontPath(unsigned char *buf); --void GetFontPath(unsigned char *buf); --void GetFontPathReply(unsigned char *buf); --void CreatePixmap(unsigned char *buf); --void FreePixmap(unsigned char *buf); --void CreateGC(unsigned char *buf); --void ChangeGC(unsigned char *buf); --void CopyGC(unsigned char *buf); --void SetDashes(unsigned char *buf); --void SetClipRectangles(unsigned char *buf); --void FreeGC(unsigned char *buf); --void ClearArea(unsigned char *buf); --void CopyArea(unsigned char *buf); --void CopyPlane(unsigned char *buf); --void PolyPoint(unsigned char *buf); --void PolyLine(unsigned char *buf); --void PolySegment(unsigned char *buf); --void PolyRectangle(unsigned char *buf); --void PolyArc(unsigned char *buf); --void FillPoly(unsigned char *buf); --void PolyFillRectangle(unsigned char *buf); --void PolyFillArc(unsigned char *buf); --void PutImage(unsigned char *buf); --void GetImage(unsigned char *buf); --void GetImageReply(unsigned char *buf); --void PolyText8(unsigned char *buf); --void PolyText16(unsigned char *buf); --void ImageText8(unsigned char *buf); --void ImageText16(unsigned char *buf); --void CreateColormap(unsigned char *buf); --void FreeColormap(unsigned char *buf); --void CopyColormapAndFree(unsigned char *buf); --void InstallColormap(unsigned char *buf); --void UninstallColormap(unsigned char *buf); --void ListInstalledColormaps(unsigned char *buf); --void ListInstalledColormapsReply(unsigned char *buf); --void AllocColor(unsigned char *buf); --void AllocColorReply(unsigned char *buf); --void AllocNamedColor(unsigned char *buf); --void AllocNamedColorReply(unsigned char *buf); --void AllocColorCells(unsigned char *buf); --void AllocColorCellsReply(unsigned char *buf); --void AllocColorPlanes(unsigned char *buf); --void AllocColorPlanesReply(unsigned char *buf); --void FreeColors(unsigned char *buf); --void StoreColors(unsigned char *buf); --void StoreNamedColor(unsigned char *buf); --void QueryColors(unsigned char *buf); --void QueryColorsReply(unsigned char *buf); --void LookupColor(unsigned char *buf); --void LookupColorReply(unsigned char *buf); --void CreateCursor(unsigned char *buf); --void CreateGlyphCursor(unsigned char *buf); --void FreeCursor(unsigned char *buf); --void RecolorCursor(unsigned char *buf); --void QueryBestSize(unsigned char *buf); --void QueryBestSizeReply(unsigned char *buf); --void QueryExtension(unsigned char *buf); --void QueryExtensionReply(unsigned char *buf); --void ListExtensions(unsigned char *buf); --void ListExtensionsReply(unsigned char *buf); --void ChangeKeyboardMapping(unsigned char *buf); --void GetKeyboardMapping(unsigned char *buf); --void GetKeyboardMappingReply(unsigned char *buf); --void ChangeKeyboardControl(unsigned char *buf); --void GetKeyboardControl(unsigned char *buf); --void GetKeyboardControlReply(unsigned char *buf); --void Bell(unsigned char *buf); --void ChangePointerControl(unsigned char *buf); --void GetPointerControl(unsigned char *buf); --void GetPointerControlReply(unsigned char *buf); --void SetScreenSaver(unsigned char *buf); --void GetScreenSaver(unsigned char *buf); --void GetScreenSaverReply(unsigned char *buf); --void ChangeHosts(unsigned char *buf); --void ListHosts(unsigned char *buf); --void ListHostsReply(unsigned char *buf); --void SetAccessControl(unsigned char *buf); --void SetCloseDownMode(unsigned char *buf); --void KillClient(unsigned char *buf); --void RotateProperties(unsigned char *buf); --void ForceScreenSaver(unsigned char *buf); --void SetPointerMapping(unsigned char *buf); --void SetPointerMappingReply(unsigned char *buf); --void GetPointerMapping(unsigned char *buf); --void GetPointerMappingReply(unsigned char *buf); --void SetModifierMapping(unsigned char *buf); --void SetModifierMappingReply(unsigned char *buf); --void GetModifierMapping(unsigned char *buf); --void GetModifierMappingReply(unsigned char *buf); --void NoOperation(unsigned char *buf); -+extern void PrintSetUpMessage (const unsigned char *buf); -+extern void PrintSetUpReply (const unsigned char *buf); -+ -+extern void RequestError (const unsigned char *buf); -+extern void ValueError (const unsigned char *buf); -+extern void WindowError (const unsigned char *buf); -+extern void PixmapError (const unsigned char *buf); -+extern void AtomError (const unsigned char *buf); -+extern void CursorError (const unsigned char *buf); -+extern void FontError (const unsigned char *buf); -+extern void MatchError (const unsigned char *buf); -+extern void DrawableError (const unsigned char *buf); -+extern void AccessError (const unsigned char *buf); -+extern void AllocError (const unsigned char *buf); -+extern void ColormapError (const unsigned char *buf); -+extern void GContextError (const unsigned char *buf); -+extern void IDChoiceError (const unsigned char *buf); -+extern void NameError (const unsigned char *buf); -+extern void LengthError (const unsigned char *buf); -+extern void ImplementationError (const unsigned char *buf); -+ -+extern void KeyPressEvent (const unsigned char *buf); -+extern void KeyReleaseEvent (const unsigned char *buf); -+extern void ButtonPressEvent (const unsigned char *buf); -+extern void ButtonReleaseEvent (const unsigned char *buf); -+extern void MotionNotifyEvent (const unsigned char *buf); -+extern void EnterNotifyEvent (const unsigned char *buf); -+extern void LeaveNotifyEvent (const unsigned char *buf); -+extern void FocusInEvent (const unsigned char *buf); -+extern void FocusOutEvent (const unsigned char *buf); -+extern void KeymapNotifyEvent (const unsigned char *buf); -+extern void ExposeEvent (const unsigned char *buf); -+extern void GraphicsExposureEvent (const unsigned char *buf); -+extern void NoExposureEvent (const unsigned char *buf); -+extern void VisibilityNotifyEvent (const unsigned char *buf); -+extern void CreateNotifyEvent (const unsigned char *buf); -+extern void DestroyNotifyEvent (const unsigned char *buf); -+extern void UnmapNotifyEvent (const unsigned char *buf); -+extern void MapNotifyEvent (const unsigned char *buf); -+extern void MapRequestEvent (const unsigned char *buf); -+extern void ReparentNotifyEvent (const unsigned char *buf); -+extern void ConfigureNotifyEvent (const unsigned char *buf); -+extern void ConfigureRequestEvent (const unsigned char *buf); -+extern void GravityNotifyEvent (const unsigned char *buf); -+extern void ResizeRequestEvent (const unsigned char *buf); -+extern void CirculateNotifyEvent (const unsigned char *buf); -+extern void CirculateRequestEvent (const unsigned char *buf); -+extern void PropertyNotifyEvent (const unsigned char *buf); -+extern void SelectionClearEvent (const unsigned char *buf); -+extern void SelectionRequestEvent (const unsigned char *buf); -+extern void SelectionNotifyEvent (const unsigned char *buf); -+extern void ColormapNotifyEvent (const unsigned char *buf); -+extern void ClientMessageEvent (const unsigned char *buf); -+extern void MappingNotifyEvent (const unsigned char *buf); -+ -+extern void ExtendedRequest (int fd, const unsigned char *buf); -+extern void UnknownReply (const unsigned char *buf); -+ -+extern void CreateWindow (FD fd, const unsigned char *buf); -+extern void ChangeWindowAttributes (FD fd, const unsigned char *buf); -+extern void GetWindowAttributes (FD fd, const unsigned char *buf); -+extern void GetWindowAttributesReply (const unsigned char *buf); -+extern void DestroyWindow (FD fd, const unsigned char *buf); -+extern void DestroySubwindows (FD fd, const unsigned char *buf); -+extern void ChangeSaveSet (FD fd, const unsigned char *buf); -+extern void ReparentWindow (FD fd, const unsigned char *buf); -+extern void MapWindow (FD fd, const unsigned char *buf); -+extern void MapSubwindows (FD fd, const unsigned char *buf); -+extern void UnmapWindow (FD fd, const unsigned char *buf); -+extern void UnmapSubwindows (FD fd, const unsigned char *buf); -+extern void ConfigureWindow (FD fd, const unsigned char *buf); -+extern void CirculateWindow (FD fd, const unsigned char *buf); -+extern void GetGeometry (FD fd, const unsigned char *buf); -+extern void GetGeometryReply (const unsigned char *buf); -+extern void QueryTree (FD fd, const unsigned char *buf); -+extern void QueryTreeReply (const unsigned char *buf); -+extern void InternAtom (FD fd, const unsigned char *buf); -+extern void InternAtomReply (const unsigned char *buf); -+extern void GetAtomName (FD fd, const unsigned char *buf); -+extern void GetAtomNameReply (const unsigned char *buf); -+extern void ChangeProperty (FD fd, const unsigned char *buf); -+extern void DeleteProperty (FD fd, const unsigned char *buf); -+extern void GetProperty (FD fd, const unsigned char *buf); -+extern void GetPropertyReply (const unsigned char *buf); -+extern void ListProperties (FD fd, const unsigned char *buf); -+extern void ListPropertiesReply (const unsigned char *buf); -+extern void SetSelectionOwner (FD fd, const unsigned char *buf); -+extern void GetSelectionOwner (FD fd, const unsigned char *buf); -+extern void GetSelectionOwnerReply (const unsigned char *buf); -+extern void ConvertSelection (FD fd, const unsigned char *buf); -+extern void SendEvent (FD fd, const unsigned char *buf); -+extern void GrabPointer (FD fd, const unsigned char *buf); -+extern void GrabPointerReply (const unsigned char *buf); -+extern void UngrabPointer (FD fd, const unsigned char *buf); -+extern void GrabButton (FD fd, const unsigned char *buf); -+extern void UngrabButton (FD fd, const unsigned char *buf); -+extern void ChangeActivePointerGrab (FD fd, const unsigned char *buf); -+extern void GrabKeyboard (FD fd, const unsigned char *buf); -+extern void GrabKeyboardReply (const unsigned char *buf); -+extern void UngrabKeyboard (FD fd, const unsigned char *buf); -+extern void GrabKey (FD fd, const unsigned char *buf); -+extern void UngrabKey (FD fd, const unsigned char *buf); -+extern void AllowEvents (FD fd, const unsigned char *buf); -+extern void GrabServer (FD fd, const unsigned char *buf); -+extern void UngrabServer (FD fd, const unsigned char *buf); -+extern void QueryPointer (FD fd, const unsigned char *buf); -+extern void QueryPointerReply (const unsigned char *buf); -+extern void GetMotionEvents (FD fd, const unsigned char *buf); -+extern void GetMotionEventsReply (const unsigned char *buf); -+extern void TranslateCoordinates (FD fd, const unsigned char *buf); -+extern void TranslateCoordinatesReply (const unsigned char *buf); -+extern void WarpPointer (FD fd, const unsigned char *buf); -+extern void SetInputFocus (FD fd, const unsigned char *buf); -+extern void GetInputFocus (FD fd, const unsigned char *buf); -+extern void GetInputFocusReply (const unsigned char *buf); -+extern void QueryKeymap (FD fd, const unsigned char *buf); -+extern void QueryKeymapReply (const unsigned char *buf); -+extern void OpenFont (FD fd, const unsigned char *buf); -+extern void CloseFont (FD fd, const unsigned char *buf); -+extern void QueryFont (FD fd, const unsigned char *buf); -+extern void QueryFontReply (const unsigned char *buf); -+extern void QueryTextExtents (FD fd, const unsigned char *buf); -+extern void QueryTextExtentsReply (const unsigned char *buf); -+extern void ListFonts (FD fd, const unsigned char *buf); -+extern void ListFontsReply (const unsigned char *buf); -+extern void ListFontsWithInfo (FD fd, const unsigned char *buf); -+extern void ListFontsWithInfoReply (const unsigned char *buf); -+extern void SetFontPath (FD fd, const unsigned char *buf); -+extern void GetFontPath (FD fd, const unsigned char *buf); -+extern void GetFontPathReply (const unsigned char *buf); -+extern void CreatePixmap (FD fd, const unsigned char *buf); -+extern void FreePixmap (FD fd, const unsigned char *buf); -+extern void CreateGC (FD fd, const unsigned char *buf); -+extern void ChangeGC (FD fd, const unsigned char *buf); -+extern void CopyGC (FD fd, const unsigned char *buf); -+extern void SetDashes (FD fd, const unsigned char *buf); -+extern void SetClipRectangles (FD fd, const unsigned char *buf); -+extern void FreeGC (FD fd, const unsigned char *buf); -+extern void ClearArea (FD fd, const unsigned char *buf); -+extern void CopyArea (FD fd, const unsigned char *buf); -+extern void CopyPlane (FD fd, const unsigned char *buf); -+extern void PolyPoint (FD fd, const unsigned char *buf); -+extern void PolyLine (FD fd, const unsigned char *buf); -+extern void PolySegment (FD fd, const unsigned char *buf); -+extern void PolyRectangle (FD fd, const unsigned char *buf); -+extern void PolyArc (FD fd, const unsigned char *buf); -+extern void FillPoly (FD fd, const unsigned char *buf); -+extern void PolyFillRectangle (FD fd, const unsigned char *buf); -+extern void PolyFillArc (FD fd, const unsigned char *buf); -+extern void PutImage (FD fd, const unsigned char *buf); -+extern void GetImage (FD fd, const unsigned char *buf); -+extern void GetImageReply (const unsigned char *buf); -+extern void PolyText8 (FD fd, const unsigned char *buf); -+extern void PolyText16 (FD fd, const unsigned char *buf); -+extern void ImageText8 (FD fd, const unsigned char *buf); -+extern void ImageText16 (FD fd, const unsigned char *buf); -+extern void CreateColormap (FD fd, const unsigned char *buf); -+extern void FreeColormap (FD fd, const unsigned char *buf); -+extern void CopyColormapAndFree (FD fd, const unsigned char *buf); -+extern void InstallColormap (FD fd, const unsigned char *buf); -+extern void UninstallColormap (FD fd, const unsigned char *buf); -+extern void ListInstalledColormaps (FD fd, const unsigned char *buf); -+extern void ListInstalledColormapsReply (const unsigned char *buf); -+extern void AllocColor (FD fd, const unsigned char *buf); -+extern void AllocColorReply (const unsigned char *buf); -+extern void AllocNamedColor (FD fd, const unsigned char *buf); -+extern void AllocNamedColorReply (const unsigned char *buf); -+extern void AllocColorCells (FD fd, const unsigned char *buf); -+extern void AllocColorCellsReply (const unsigned char *buf); -+extern void AllocColorPlanes (FD fd, const unsigned char *buf); -+extern void AllocColorPlanesReply (const unsigned char *buf); -+extern void FreeColors (FD fd, const unsigned char *buf); -+extern void StoreColors (FD fd, const unsigned char *buf); -+extern void StoreNamedColor (FD fd, const unsigned char *buf); -+extern void QueryColors (FD fd, const unsigned char *buf); -+extern void QueryColorsReply (const unsigned char *buf); -+extern void LookupColor (FD fd, const unsigned char *buf); -+extern void LookupColorReply (const unsigned char *buf); -+extern void CreateCursor (FD fd, const unsigned char *buf); -+extern void CreateGlyphCursor (FD fd, const unsigned char *buf); -+extern void FreeCursor (FD fd, const unsigned char *buf); -+extern void RecolorCursor (FD fd, const unsigned char *buf); -+extern void QueryBestSize (FD fd, const unsigned char *buf); -+extern void QueryBestSizeReply (const unsigned char *buf); -+extern void QueryExtension (FD fd, const unsigned char *buf); -+extern void QueryExtensionReply (const unsigned char *buf); -+extern void ListExtensions (FD fd, const unsigned char *buf); -+extern void ListExtensionsReply (const unsigned char *buf); -+extern void ChangeKeyboardMapping (FD fd, const unsigned char *buf); -+extern void GetKeyboardMapping (FD fd, const unsigned char *buf); -+extern void GetKeyboardMappingReply (const unsigned char *buf); -+extern void ChangeKeyboardControl (FD fd, const unsigned char *buf); -+extern void GetKeyboardControl (FD fd, const unsigned char *buf); -+extern void GetKeyboardControlReply (const unsigned char *buf); -+extern void Bell (FD fd, const unsigned char *buf); -+extern void ChangePointerControl (FD fd, const unsigned char *buf); -+extern void GetPointerControl (FD fd, const unsigned char *buf); -+extern void GetPointerControlReply (const unsigned char *buf); -+extern void SetScreenSaver (FD fd, const unsigned char *buf); -+extern void GetScreenSaver (FD fd, const unsigned char *buf); -+extern void GetScreenSaverReply (const unsigned char *buf); -+extern void ChangeHosts (FD fd, const unsigned char *buf); -+extern void ListHosts (FD fd, const unsigned char *buf); -+extern void ListHostsReply (const unsigned char *buf); -+extern void SetAccessControl (FD fd, const unsigned char *buf); -+extern void SetCloseDownMode (FD fd, const unsigned char *buf); -+extern void KillClient (FD fd, const unsigned char *buf); -+extern void RotateProperties (FD fd, const unsigned char *buf); -+extern void ForceScreenSaver (FD fd, const unsigned char *buf); -+extern void SetPointerMapping (FD fd, const unsigned char *buf); -+extern void SetPointerMappingReply (const unsigned char *buf); -+extern void GetPointerMapping (FD fd, const unsigned char *buf); -+extern void GetPointerMappingReply (const unsigned char *buf); -+extern void SetModifierMapping (FD fd, const unsigned char *buf); -+extern void SetModifierMappingReply (const unsigned char *buf); -+extern void GetModifierMapping (FD fd, const unsigned char *buf); -+extern void GetModifierMappingReply (const unsigned char *buf); -+extern void NoOperation (FD fd, const unsigned char *buf); -+ - /* prtype.c */ --void SetIndentLevel(int which); --void DumpItem(char *name, FD fd, unsigned char *buf, long n); --void PrintField(unsigned char *buf, int start, int length, int FieldType, char *name); --long PrintList(unsigned char *buf, long number, int ListType, char *name); --long PrintListSTR(unsigned char *buf, long number, char *name); --int PrintBytes(unsigned char buf[], long number, char *name); --int PrintString8(unsigned char buf[], int number, char *name); --int PrintString16(unsigned char buf[], int number, char *name); --void PrintValues(unsigned char *control, int clength, int ctype, unsigned char *values, char *name); --int PrintTextList8(unsigned char *buf, int length, char *name); --int PrintTextList16(unsigned char *buf, int length, char *name); -+extern void SetIndentLevel (short which); -+extern void DumpHexBuffer (const unsigned char *buf, long n); -+extern void DumpItem (const char *name, FD fd, -+ const unsigned char *buf, long n); -+extern void PrintField (const unsigned char *buf, short start, short length, -+ short FieldType, const char *name); -+extern int PrintBytes (const unsigned char *buf, long number, -+ const char *name); -+extern void PrintValues (const unsigned char *control, int clength, int ctype, -+ const unsigned char *values, const char *name); -+extern void PrintTextList8 (const unsigned char *buf, int length, -+ const char *name); -+extern void PrintTextList16 (const unsigned char *buf, int length, -+ const char *name); -+ - /* scope.c */ --void TimerExpired(void); --FD FDPair(FD fd); --FD ClientHalf(FD fd); --FD ServerHalf(FD fd); --char *ClientName(FD fd); --void NewConnection(FD fd); -+extern void TestBreakPoints (const unsigned char *buf, long n); -+extern void TimerExpired (void); -+extern void SetUpPair (FD client, FD server); -+extern FD FDPair (FD fd); -+extern FD ClientHalf (FD fd); -+extern FD ServerHalf (FD fd); -+extern char *ClientName (FD fd); -+extern int ClientNumber (FD fd); -+extern void NewConnection (FD fd); -+extern void FlushFD (FD fd); -+extern short GetServerport (void); -+extern void ReadCommands (void); -+ - /* server.c */ --void ReportFromClient(FD fd, unsigned char *buf, long n); --void ReportFromServer(FD fd, unsigned char *buf, long n); --void PrintTime(void); --long pad(long n); --unsigned long ILong(unsigned char buf[]); --unsigned short IShort(unsigned char buf[]); --unsigned short IByte(unsigned char buf[]); --short IBool(unsigned char buf[]); --void StartClientConnection(FD fd); --void StopClientConnection(FD fd); --void StartServerConnection(FD fd); --void StopServerConnection(FD fd); --/* table11.c */ --void InitializeX11(void); -+extern FD ConnectToServer (Boolean report); -+extern void ProcessBuffer (FD fd, const unsigned char *buf, long n); -+extern void ReportFromClient (FD fd, const unsigned char *buf, long n); -+extern void ReportFromServer (FD fd, const unsigned char *buf, long n); -+extern void PrintTime (void); -+extern void SetBufLimit (FD fd); -+extern void ClearBufLimit (FD fd); -+extern void StartClientConnection (FD fd); -+extern void StopClientConnection (FD fd); -+extern void StartServerConnection (FD fd); -+extern void StopServerConnection (FD fd); -+extern long StartSetUpMessage (FD fd, const unsigned char *buf, long n); -+extern long StartSetUpReply (FD fd, const unsigned char *buf, long n); -+ -+extern long GetXRequestFromName (const char *name); - -+/* table11.c */ -+extern void InitializeX11 (void); -+extern TYPE DefineType (short typeid, short class, const char *name, -+ int (*printproc)(const unsigned char *)); -+extern void DefineEValue (TYPE type, long value, const char *name); -+extern void DefineValues (TYPE type, long value, short length, -+ short ctype, const char *name); -+extern long GetEValue (short typeid, const char *name); -diff --git a/prtype.c b/prtype.c -index 4bcfb8b..6be200d 100644 ---- a/prtype.c -+++ b/prtype.c -@@ -55,8 +55,6 @@ - #include "scope.h" - #include "x11.h" - --static void DumpHexBuffer(unsigned char *buf, long n); -- - /* - For each of the types we need a way to print that type. - Types are of varieties: -@@ -76,8 +74,8 @@ static void DumpHexBuffer(unsigned char *buf, long n); - - - /* print representation of a character for debugging */ --static char *printrep (c) -- unsigned short c; -+static char * -+printrep (unsigned short c) - { - static char pr[8]; - -@@ -132,12 +130,12 @@ static char *printrep (c) - */ - - #define MaxIndent 10 --static char Leader[MaxIndent + 1]; -+char Leader[MaxIndent + 1]; - static short CurrentLevel = 0; - - void --SetIndentLevel(which) -- short which; -+SetIndentLevel ( -+ short which) - { - short i; - -@@ -157,13 +155,14 @@ SetIndentLevel(which) - } - - static void --ModifyIndentLevel(amount) -- short amount; -+ModifyIndentLevel ( -+ short amount) - { - SetIndentLevel(CurrentLevel + amount); - } - --static short SizeofLeader () -+static short -+SizeofLeader (void) - { - return (CurrentLevel * 8); - } -@@ -176,11 +175,11 @@ static short SizeofLeader () - /* if we want verbose enough output, we will dump the buffer in hex */ - - void --DumpItem(name, fd, buf, n) -- char *name; -- FD fd; -- unsigned char *buf; -- long n; -+DumpItem ( -+ const char *name, -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - if (n == 0) - return; -@@ -197,64 +196,69 @@ DumpItem(name, fd, buf, n) - /* ************************************************************ */ - - int --PrintINT8(unsigned char *buf) -+PrintINT8(const unsigned char *buf) - { - /* print a INT8 -- 8-bit signed integer */ - short n = IByte (buf); - if (n > 127) - n = 256 - n; -- return fprintf(stdout, "%d", n); -+ fprintf(stdout, "%d", n); -+ return 1; - } - - int --PrintINT16(unsigned char *buf) -+PrintINT16(const unsigned char *buf) - { - /* print a INT16 -- 16-bit signed integer */ - long n = IShort (buf); - if (n > 32767) - n = 65536 - n; -- return fprintf(stdout, "%d", n); -+ fprintf(stdout, "%ld", n); -+ return 2; - } - - int --PrintINT32(unsigned char *buf) -+PrintINT32(const unsigned char *buf) - { - /* print a INT32 -- 32-bit signed integer */ - long n = ILong (buf); -- return fprintf(stdout, "%d", n); -+ fprintf(stdout, "%ld", n); -+ return 4; - } - - /* ************************************************************ */ - - int --PrintCARD8(unsigned char *buf) -+PrintCARD8(const unsigned char *buf) - { - /* print a CARD8 -- 8-bit unsigned integer */ - unsigned short n = IByte (buf); -- return fprintf(stdout, "%02x", (unsigned)(n & 0xff)); -+ fprintf(stdout, "%02x", (unsigned)(n & 0xff)); -+ return 1; - } - - int --PrintCARD16(unsigned char *buf) -+PrintCARD16(const unsigned char *buf) - { - /* print a CARD16 -- 16-bit unsigned integer */ - unsigned long n = IShort (buf); -- return fprintf(stdout, "%04x", (unsigned)(n & 0xffff)); -+ fprintf(stdout, "%04x", (unsigned)(n & 0xffff)); -+ return 1; - } - - int --PrintCARD32(unsigned char *buf) -+PrintCARD32(const unsigned char *buf) - { - /* print a CARD32 -- 32-bit unsigned integer */ - unsigned long n = ILong (buf); -- fprintf(stdout, "%08x", n); -+ fprintf(stdout, "%08lx", n); - return(4); - } - - /* ************************************************************ */ - - int --PrintBYTE(unsigned char *buf) -+PrintBYTE(const unsigned char *buf) - { - /* print a BYTE -- 8-bit value */ - short n = IByte (buf); -@@ -264,7 +268,7 @@ PrintBYTE(unsigned char *buf) - - - int --PrintCHAR8(unsigned char *buf) -+PrintCHAR8(const unsigned char *buf) - { - /* print a CHAR8 -- 8-bit character */ - unsigned short n = IByte (buf); -@@ -274,16 +278,16 @@ PrintCHAR8(unsigned char *buf) - - - int --PrintSTRING16(unsigned char *buf) -+PrintSTRING16(const unsigned char *buf) - { -- /* print a CHAR16 -- 16-bit character */ -- unsigned short n = IShort (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; - } - - int --PrintSTR(unsigned char *buf) -+PrintSTR(const unsigned char *buf) - { - /* STR have the length (1 byte) then a string of CHAR8 */ - short n; -@@ -298,158 +302,169 @@ PrintSTR(unsigned char *buf) - /* ************************************************************ */ - - int --PrintWINDOW(unsigned char *buf) -+PrintWINDOW(const unsigned char *buf) - { - /* print a WINDOW -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) - fprintf(stdout, "None"); - else -- fprintf(stdout, "WIN %08x", n); -+ fprintf(stdout, "WIN %08lx", n); - return(4); - } - - int --PrintWINDOWD(unsigned char *buf) -+PrintWINDOWD(const unsigned char *buf) - { - /* print a WINDOWD -- CARD32 plus 0 = PointerWindow, 1 = InputFocus */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "PointerWindow"); -+ fprintf(stdout, "PointerWindow"); - else if (n == 1) -- return fprintf(stdout, "InputFocus"); -+ fprintf(stdout, "InputFocus"); - else -- return PrintWINDOW(buf); -+ (void)PrintWINDOW(buf); -+ return 4; - } - - int --PrintWINDOWNR(unsigned char *buf) -+PrintWINDOWNR(const unsigned char *buf) - { - /* print a WINDOWNR -- CARD32 plus 0 = None, 1 = PointerRoot */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else if (n == 1) -- return fprintf(stdout, "PointerRoot"); -+ fprintf(stdout, "PointerRoot"); - else -- return PrintWINDOW(buf); -+ (void)PrintWINDOW(buf); -+ return 4; - } - - - int --PrintPIXMAP(unsigned char *buf) -+PrintPIXMAP(const unsigned char *buf) - { - /* print a PIXMAP -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else -- return fprintf(stdout, "PXM %08x", n); -+ fprintf(stdout, "PXM %08lx", n); -+ return 4; - } - - int --PrintPIXMAPNPR(unsigned char *buf) -+PrintPIXMAPNPR(const unsigned char *buf) - { - /* print a PIXMAPNPR -- CARD32 plus 0 = None, 1 = ParentRelative */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else if (n == 1) -- return fprintf(stdout, "ParentRelative"); -+ fprintf(stdout, "ParentRelative"); - else -- return PrintPIXMAP(buf); -+ PrintPIXMAP(buf); -+ return 4; - } - - int --PrintPIXMAPC(unsigned char *buf) -+PrintPIXMAPC(const unsigned char *buf) - { - /* print a PIXMAPC -- CARD32 plus 0 = CopyFromParent */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "CopyFromParent"); -+ fprintf(stdout, "CopyFromParent"); - else -- return PrintPIXMAP(buf); -+ PrintPIXMAP(buf); -+ return 4; - } - - - int --PrintCURSOR(unsigned char *buf) -+PrintCURSOR(const unsigned char *buf) - { - /* print a CURSOR -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else -- return fprintf(stdout, "CUR %08x", n); -+ fprintf(stdout, "CUR %08lx", n); -+ return 4; - } - - - int --PrintFONT(unsigned char *buf) -+PrintFONT(const unsigned char *buf) - { - /* print a FONT -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else -- return fprintf(stdout, "FNT %08x", n); -+ fprintf(stdout, "FNT %08lx", n); -+ return 4; - } - - - int --PrintGCONTEXT(unsigned char *buf) -+PrintGCONTEXT(const unsigned char *buf) - { - /* print a GCONTEXT -- CARD32 */ - long n = ILong (buf); -- return fprintf(stdout, "GXC %08x", n); -+ fprintf(stdout, "GXC %08lx", n); -+ return 4; - } - - - int --PrintCOLORMAP(unsigned char *buf) -+PrintCOLORMAP(const unsigned char *buf) - { - /* print a COLORMAP -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) - fprintf(stdout, "None"); - else -- fprintf(stdout, "CMP %08x", n); -+ fprintf(stdout, "CMP %08lx", n); - return(4); - } - - int --PrintCOLORMAPC(unsigned char *buf) -+PrintCOLORMAPC(const unsigned char *buf) - { - /* print a COLORMAPC -- CARD32 plus 0 = CopyFromParent */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "CopyFromParent"); -+ fprintf(stdout, "CopyFromParent"); - else -- return PrintCOLORMAP(buf); -+ (void)PrintCOLORMAP(buf); -+ return 4; - } - - - int --PrintDRAWABLE(unsigned char *buf) -+PrintDRAWABLE(const unsigned char *buf) - { - /* print a DRAWABLE -- CARD32 */ - long n = ILong (buf); -- return fprintf(stdout, "DWB %08x", n); -+ fprintf(stdout, "DWB %08lx", n); -+ return 4; - } - - int --PrintFONTABLE(unsigned char *buf) -+PrintFONTABLE(const unsigned char *buf) - { - /* print a FONTABLE -- CARD32 */ - long n = ILong (buf); -- return fprintf(stdout, "FTB %08x", n); -+ fprintf(stdout, "FTB %08lx", n); -+ return 4; - } - - /* ************************************************************ */ - - #define NumberofAtoms 68 - --static char *AtomTable[NumberofAtoms + 1] = -+static const char * const AtomTable[NumberofAtoms + 1] = - { - "NONE", "PRIMARY", "SECONDARY", "ARC", "ATOM", "BITMAP", "CARDINAL", - "COLORMAP", "CURSOR", "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2", -@@ -472,87 +487,92 @@ static char *AtomTable[NumberofAtoms + 1] = - the user defined ones, too. */ - - int --PrintATOM(unsigned char *buf) -+PrintATOM(const unsigned char *buf) - { - /* print a ATOM -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (0 <= n && n <= NumberofAtoms) - fprintf(stdout, "<%s>", AtomTable[n]); - else -- fprintf(stdout, "ATM %08x", n); -+ fprintf(stdout, "ATM %08lx", n); - return(4); - } - - int --PrintATOMT(unsigned char *buf) -+PrintATOMT(const unsigned char *buf) - { - /* print a ATOMT -- CARD32 plus 0 = AnyPropertyType */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "AnyPropertyType"); -+ fprintf(stdout, "AnyPropertyType"); - else -- return PrintATOM(buf); -+ (void)PrintATOM(buf); -+ return 4; - } - - - int --PrintVISUALID(unsigned char *buf) -+PrintVISUALID(const unsigned char *buf) - { - /* print a VISUALID -- CARD32 plus 0 = None */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "None"); -+ fprintf(stdout, "None"); - else -- return fprintf(stdout, "VIS %08x", n); -+ fprintf(stdout, "VIS %08lx", n); -+ return 4; - } - - int --PrintVISUALIDC(unsigned char *buf) -+PrintVISUALIDC(const unsigned char *buf) - { - /* print a VISUALIDC -- CARD32 plus 0 = CopyFromParent */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "CopyFromParent"); -+ fprintf(stdout, "CopyFromParent"); - else -- return PrintVISUALID(buf); -+ PrintVISUALID(buf); -+ return 4; - } - - - int --PrintTIMESTAMP(unsigned char *buf) -+PrintTIMESTAMP(const unsigned char *buf) - { - /* print a TIMESTAMP -- CARD32 plus 0 as the current time */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "CurrentTime"); -+ fprintf(stdout, "CurrentTime"); - else -- return fprintf(stdout, "TIM %08x", n); -+ fprintf(stdout, "TIM %08lx", n); -+ return 4; - } - - - int --PrintRESOURCEID(unsigned char *buf) -+PrintRESOURCEID(const unsigned char *buf) - { - /* print a RESOURCEID -- CARD32 plus 0 = AllTemporary */ - long n = ILong (buf); - if (n == 0) -- return fprintf(stdout, "AllTemporary"); -+ fprintf(stdout, "AllTemporary"); - else -- return fprintf(stdout, "RID %08x", n); -+ fprintf(stdout, "RID %08lx", n); -+ return 4; - } - - - int --PrintKEYSYM(unsigned char *buf) -+PrintKEYSYM(const unsigned char *buf) - { - /* print a KEYSYM -- CARD32 */ - long n = ILong (buf); -- fprintf(stdout, "KYS %08x", n); -+ fprintf(stdout, "KYS %08lx", n); - return(4); - } - - int --PrintKEYCODE(unsigned char *buf) -+PrintKEYCODE(const unsigned char *buf) - { - /* print a KEYCODE -- CARD8 */ - unsigned short n = IByte (buf); -@@ -561,51 +581,55 @@ PrintKEYCODE(unsigned char *buf) - } - - int --PrintKEYCODEA(unsigned char *buf) -+PrintKEYCODEA(const unsigned char *buf) - { - /* print a KEYCODEA -- CARD8 plus 0 = AnyKey */ - long n = IByte (buf); - if (n == 0) -- return fprintf(stdout, "AnyKey"); -+ fprintf(stdout, "AnyKey"); - else -- return PrintKEYCODE(buf); -+ (void)PrintKEYCODE(buf); -+ return 1; - } - - - int --PrintBUTTON(unsigned char *buf) -+PrintBUTTON(const unsigned char *buf) - { - /* print a BUTTON -- CARD8 */ - unsigned short n = IByte (buf); -- return fprintf(stdout, "%d (%s)", n, printrep(n)); -+ fprintf(stdout, "%d (%s)", n, printrep(n)); -+ return 1; - } - - int --PrintBUTTONA(unsigned char *buf) -+PrintBUTTONA(const unsigned char *buf) - { - /* print a BUTTONA -- CARD8 plus 0 = AnyButton */ - long n = IByte (buf); - if (n == 0) -- return fprintf(stdout, "AnyButton"); -+ fprintf(stdout, "AnyButton"); - else -- return PrintBUTTON(buf); -+ PrintBUTTON(buf); -+ return 1; - } - - - /* this is an interesting cheat -- we call DecodeEvent to print an event */ - /* should work, but its never been tried */ - int --PrintEVENTFORM(unsigned char *buf) -+PrintEVENTFORM(const unsigned char *buf) - { - /* print an EVENT_FORM -- event format */ - DecodeEvent(-1, buf, (long)-1); -+ return 32; - } - - /* ************************************************************ */ - - int - PrintENUMERATED( -- unsigned char *buf, -+ const unsigned char *buf, - short length, - struct ValueListEntry *ValueList) - { -@@ -624,16 +648,16 @@ PrintENUMERATED( - p = p->Next; - - if (p != NULL) -- return fprintf(stdout, "%s", p->Name); -+ fprintf(stdout, "%s", p->Name); - else -- return fprintf(stdout, "**INVALID** (%d)", n); -+ fprintf(stdout, "**INVALID** (%ld)", n); - } - - /* ************************************************************ */ - - int - PrintSET( -- unsigned char *buf, -+ const unsigned char *buf, - short length, - struct ValueListEntry *ValueList) - { -@@ -674,9 +698,9 @@ PrintSET( - } - - if (MatchesAll) -- return fprintf(stdout, ""); -+ fprintf(stdout, ""); - else if (!FoundOne) -- return fprintf(stdout, "0"); -+ fprintf(stdout, "0"); - } - - -@@ -686,13 +710,16 @@ PrintSET( - /* ************************************************************ */ - - void --PrintField(buf, start, length, FieldType, name) -- unsigned char *buf; -- short start; -- short length; -- short FieldType; -- char *name; -+PrintField ( -+ const unsigned char *buf, -+ short start, -+ short length, -+ short FieldType, -+ const char *name) - { -+ if (Verbose == 0) -+ return; -+ - if (length == 0) - return; - -@@ -736,11 +763,12 @@ PrintField(buf, start, length, FieldType, name) - /* print a list of things. The things are of type . - They start at . There are things in the list */ - --long PrintList(buf, number, ListType, name) -- unsigned char *buf; -- long number; -- short ListType; -- char *name; -+long -+PrintList ( -+ const unsigned char *buf, -+ long number, -+ short ListType, -+ const char *name) - { - long n; - long i; -@@ -749,7 +777,7 @@ long PrintList(buf, number, ListType, name) - if (number == 0) - return(0); - -- fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number); -+ fprintf(stdout, "%s%20s: (%ld)\n", Leader, name, number); - if (Verbose < 2) - return(0); - -@@ -787,10 +815,11 @@ long PrintList(buf, number, ListType, name) - /* print a list of STRs. Similar to PrintList - They start at . There are things in the list */ - --long PrintListSTR(buf, number, name) -- unsigned char *buf; -- long number; -- char *name; -+long -+PrintListSTR ( -+ const unsigned char *buf, -+ long number, -+ const char *name) - { - long n; - long i; -@@ -799,7 +828,7 @@ long PrintListSTR(buf, number, name) - if (number == 0) - return(0); - -- fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number); -+ fprintf(stdout, "%s%20s: (%ld)\n", Leader, name, number); - if (Verbose < 2) - return(0); - -@@ -827,9 +856,9 @@ long PrintListSTR(buf, number, name) - - int - PrintBytes( -- unsigned char buf[], -+ const unsigned char *buf, - long number, -- char *name) -+ const char *name) - { - /* print a list of BYTE -- 8-bit character */ - long i; -@@ -868,9 +897,9 @@ PrintBytes( - - int - PrintString8( -- unsigned char buf[], -+ const unsigned char *buf, - int number, -- char *name) -+ const char *name) - { - short i; - -@@ -890,11 +919,11 @@ PrintString8( - - int - PrintString16( -- unsigned char buf[], -+ const unsigned char *buf, - int number, -- char *name) -+ const char *name) - { -- short i; -+ long i; - unsigned short c; - - if (number == 0) -@@ -903,7 +932,7 @@ PrintString16( - fprintf(stdout, "%s%20s: \"", Leader, name); - for (i = 0; i < number; i += 2) - { -- c = IShort(&buf[i]); -+ c = IChar2B(&buf[i]); - fprintf(stdout, "%s", printrep(c)); - } - fprintf(stdout, "\"\n"); -@@ -911,6 +940,54 @@ PrintString16( - return(number); - } - -+void -+PrintTString8( -+ const unsigned char *buf, -+ long number, -+ const 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 */ -+void -+PrintTString16( -+ const unsigned char *buf, -+ long number, -+ const 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"); -+} -+ - /* ************************************************************ */ - /* */ - /* */ -@@ -926,11 +1003,11 @@ PrintString16( - - void - PrintValues( -- unsigned char *control, -+ const unsigned char *control, - int clength, - int ctype, -- unsigned char *values, -- char *name) -+ const unsigned char *values, -+ const char *name) - { - long cmask; - struct ValueListEntry *p; -@@ -955,7 +1032,11 @@ PrintValues( - { - 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; - } -@@ -972,11 +1053,11 @@ PrintValues( - /* PolyText8 and PolyText16 take lists of characters with possible - font changes in them. */ - --int -+void - PrintTextList8( -- unsigned char *buf, -+ const unsigned char *buf, - int length, -- char *name) -+ const char *name) - { - short n; - -@@ -987,24 +1068,24 @@ PrintTextList8( - if (n != 255) - { - PrintField(buf, 1, 1, INT8, "delta"); -- PrintString8(&buf[2], 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; - } - } - } - --int -+void - PrintTextList16( -- unsigned char *buf, -+ const unsigned char *buf, - int length, -- char *name) -+ const char *name) - { - short n; - -@@ -1015,15 +1096,15 @@ PrintTextList16( - if (n != 255) - { - PrintField(buf, 1, 1, INT8, "delta"); -- PrintString16(&buf[2], 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; - } - } - } -@@ -1036,12 +1117,12 @@ PrintTextList16( - - #define MAXline 78 - --static void -+void - DumpHexBuffer( -- unsigned char *buf, -+ const unsigned char *buf, - long n) - { -- short i; -+ long i; - short column; - char h[6] /* one hex or octal character */ ; - -@@ -1062,3 +1143,41 @@ DumpHexBuffer( - column += 3; - } - } -+ -+void -+PrintValueRec ( -+ 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..5b63b06 ---- /dev/null -+++ b/randrscope.h -@@ -0,0 +1,29 @@ -+#ifndef _RANDRSCOPE_H_ -+#define _RANDRSCOPE_H_ -+ -+#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) -+ -+extern unsigned char RANDRRequest; -+extern unsigned char RANDREvent; -+ -+extern void RandrQueryVersion (FD fd, const unsigned char *buf); -+extern void RandrQueryVersionReply (FD fd, const unsigned char *buf); -+extern void RandrGetScreenInfo (FD fd, const unsigned char *buf); -+extern void RandrGetScreenInfoReply (FD fd, const unsigned char *buf); -+extern void RandrSetScreenConfig (FD fd, const unsigned char *buf); -+extern void RandrSetScreenConfigReply (FD fd, const unsigned char *buf); -+extern void RandrScreenChangeSelectInput (FD fd, const unsigned char *buf); -+extern void RandrScreenSizes (const unsigned char *buf); -+extern void RandrScreenChangeNotifyEvent (const unsigned char *buf); -+ -+#endif -+ -diff --git a/renderscope.h b/renderscope.h -new file mode 100644 -index 0000000..201e339 ---- /dev/null -+++ b/renderscope.h -@@ -0,0 +1,58 @@ -+#ifndef _RENDERSCOPE_H_ -+#define _RENDERSCOPE_H_ -+ -+#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) -+ -+extern unsigned char RENDERRequest; -+extern unsigned char RENDERError; -+#define RENDERNError 5 -+ -+extern void RenderQueryVersion (FD fd, const unsigned char *buf); -+extern void RenderQueryVersionReply (FD fd, const unsigned char *buf); -+extern void RenderQueryPictFormats (FD fd, const unsigned char *buf); -+extern void RenderQueryPictFormatsReply (FD fd, const unsigned char *buf); -+extern void RenderQueryPictIndexValues (FD fd, const unsigned char *buf); -+extern void RenderQueryPictIndexValuesReply (FD fd, const unsigned char *buf); -+extern void RenderQueryDithers (FD fd, const unsigned char *buf); -+extern void RenderQueryDithersReply (FD fd, const unsigned char *buf); -+extern void RenderCreatePicture (FD fd, const unsigned char *buf); -+extern void RenderChangePicture (FD fd, const unsigned char *buf); -+extern void RenderSetPictureClipRectangles (FD fd, const unsigned char *buf); -+extern void RenderFreePicture (FD fd, const unsigned char *buf); -+extern void RenderComposite (FD fd, const unsigned char *buf); -+extern void RenderScale (FD fd, const unsigned char *buf); -+extern void RenderTrapezoids (FD fd, const unsigned char *buf); -+extern void RenderTriangles (FD fd, const unsigned char *buf); -+extern void RenderTriStrip (FD fd, const unsigned char *buf); -+extern void RenderTriFan (FD fd, const unsigned char *buf); -+extern void RenderColorTrapezoids (FD fd, const unsigned char *buf); -+extern void RenderColorTriangles (FD fd, const unsigned char *buf); -+extern void RenderTransform (FD fd, const unsigned char *buf); -+extern void RenderCreateGlyphSet (FD fd, const unsigned char *buf); -+extern void RenderReferenceGlyphSet (FD fd, const unsigned char *buf); -+extern void RenderFreeGlyphSet (FD fd, const unsigned char *buf); -+extern void RenderAddGlyphs (FD fd, const unsigned char *buf); -+extern void RenderAddGlyphsFromPicture (FD fd, const unsigned char *buf); -+extern void RenderFreeGlyphs (FD fd, const unsigned char *buf); -+extern void RenderCompositeGlyphs8 (FD fd, const unsigned char *buf); -+extern void RenderCompositeGlyphs16 (FD fd, const unsigned char *buf); -+extern void RenderCompositeGlyphs32 (FD fd, const unsigned char *buf); -+extern void RenderFillRectangles (FD fd, const unsigned char *buf); -+ -+extern void RenderPictFormatError (FD fd, const unsigned char *buf); -+extern void RenderPictureError (FD fd, const unsigned char *buf); -+extern void RenderPictOpError (FD fd, const unsigned char *buf); -+extern void RenderGlyphSetError (FD fd, const unsigned char *buf); -+extern void RenderGlyphError (FD fd, const unsigned char *buf); -+ -+#endif -+ -diff --git a/scope.c b/scope.c -index 32c80c6..45f2724 100644 ---- a/scope.c -+++ b/scope.c -@@ -54,89 +54,618 @@ - ***************************************************** */ - - #include "scope.h" -+#include "nas.h" - --#include -+#include - #include --#include - - #ifdef SYSV - #define bzero(s,l) memset(s, 0, l) - #define bcopy(s,d,l) memmove(d,s,l) - #endif - -+#include /* needed by sys/socket.h and netinet/in.h */ -+#include /* for struct iovec, used by socket.h */ -+#include /* for AF_INET, SOCK_STREAM, ... */ -+#include /* for FIONCLEX, FIONBIO, ... */ -+#ifdef SVR4 -+#include -+#endif -+#include -+#include /* struct sockaddr_in */ -+#include -+#include /* struct servent * and struct hostent * */ -+#include /* for EINTR, EADDRINUSE, ... */ -+ -+ - /* ********************************************** */ - /* */ - /* ********************************************** */ - - #define DefaultPort 6000 - --static char ServerHostName[MAXHOSTNAMELEN]; -+ char ServerHostName[MAXHOSTNAMELEN]; -+ char AudioServerHostName[MAXHOSTNAMELEN]; - long ServerBasePort = DefaultPort; - static long ServerInPort = 1; - static long ServerOutPort = 0; - static long ServerDisplay = 0; - --#ifdef USE_XTRANS --#undef DNETCONN --#undef DNETSVR4 --#endif -+static FD ConnectToClient(FD ConnectionSocket); -+static void DataFromClient(FD fd); -+static void SetUpStdin(void); - --#ifdef DNETCONN --#include --#include --int decnet_in = 0; --int decnet_out = 0; --int decnet_server = 0; --#endif --#ifdef DNETSVR4 --#include --extern struct hostent *(*dnet_gethostbyname)(); --extern int (*dnet_gethostname)(); --short initialize_libdni(); --int decnet_in = 0; --int decnet_out = 0; --int decnet_server = 0; -+long TranslateText = 0; -+char ScopeEnabled = 1; -+char HandleSIGUSR1 = 0; -+char DoAudio = 0; -+char TerminateClose = 0; -+int Interrupt = 0; -+ -+struct FDDescriptor *FDD = NULL; -+short MaxFD = 0; -+short nFDsInUse = 0; -+fd_set ReadDescriptors; -+fd_set WriteDescriptors; -+fd_set BlockedReadDescriptors; -+short HighestFD; -+ -+short debuglevel = 0; -+short Verbose = 0; -+short XVerbose = 0; -+short NasVerbose = 0; -+int ScopePort = 0; -+char *ScopeHost = NULL; -+ -+ -+typedef struct _BreakPoint { -+ struct _BreakPoint *next; -+ int number; -+ unsigned char request; -+ Boolean enabled; -+} BP; -+ -+typedef enum _CMDResult { CMDProceed, CMDDebug, CMDSyntax, CMDError } CMDResult; -+ -+static CMDResult CMDStep (int argc, char **argv); -+static CMDResult CMDCont (int argc, char **argv); -+static CMDResult CMDBreak (int argc, char **argv); -+static CMDResult CMDDelete (int argc, char **argv); -+static CMDResult CMDDisable (int argc, char **argv); -+static CMDResult CMDEnable (int argc, char **argv); -+static CMDResult CMDLevel (int argc, char **argv); -+static CMDResult CMDAudio (int argc, char **argv); -+static CMDResult CMDQuit (int argc, char **argv); -+static CMDResult CMDHelp (int argc, char **argv); -+ -+typedef struct _CMDFunc { -+ char *name; -+ char *alias; -+ CMDResult (*func)(int argc, char **argv); -+ char *usage; -+ char *help; -+} CMDFuncRec; -+typedef const CMDFuncRec *CMDFuncPtr; -+ -+static const 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 FD ConnectToClient(FD ConnectionSocket); --static FD ConnectToServer(int report); --static void SetUpStdin(void); -+static int -+CMDStringToInt ( -+ 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 ( -+ const 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 NULL; -+} -+ -+static int -+CMDSplitIntoWords ( -+ 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 = NULL; -+ return argc; -+} -+ -+static CMDResult -+CMDHelp( -+ 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( -+ int argc, -+ char **argv) -+{ -+ printf("Syntax error in:"); -+ while (*argv) -+ printf(" %s", *argv++); -+ printf("\n"); -+} -+ -+void -+ReadCommands (void) -+{ -+ 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 ( -+ const 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 (); -+ } -+} -+ -+static void -+setBreakPoint (void) -+{ -+ 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++) -+ { -+ if (FDD[fd].Busy && FDD[fd].InputHandler == DataFromClient) -+ { -+ if (BreakPoint) -+ SetBufLimit (fd); -+ else -+ ClearBufLimit (fd); -+ } -+ } -+ } -+} -+ -+static CMDResult -+CMDBreak ( -+ 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 = NULL; -+ *prev = bp; -+ prev = &bp->next; -+ } -+ } -+ setBreakPoint (); -+ return CMDDebug; -+} -+ -+static CMDResult -+CMDCont ( -+ int argc, -+ char **argv) -+{ -+ SingleStep = 0; -+ return CMDProceed; -+} -+ -+static CMDResult -+CMDDisable ( -+ 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; -+} -+ -+static CMDResult -+CMDDelete ( -+ int argc, -+ char **argv) -+{ -+ BP *bp, **prev; -+ int number; -+ -+ if (argc == 1) -+ { -+ printf ("Deleting all breakpoints...\n"); -+ while ((bp = breakPoints) != NULL) -+ { -+ 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; -+} -+ -+static CMDResult -+CMDEnable ( -+ 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; -+} -+ -+static CMDResult -+CMDStep ( -+ int argc, -+ char **argv) -+{ -+ SingleStep = 1; -+ setBreakPoint (); -+ return CMDProceed; -+} -+ -+static CMDResult -+CMDQuit ( -+ int argc, -+ char **argv) -+{ -+ printf ("exiting...\n"); -+ exit (0); -+} -+ -+static CMDResult -+CMDLevel ( -+ 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; -+} -+ -+static CMDResult -+CMDAudio ( -+ 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; -+} - - /* ********************************************** */ - /* */ - /* */ - /* ********************************************** */ - --static short GetServerport () -+short -+GetServerport (void) - { - short port; - - enterprocedure("GetServerport"); - --#if defined(DNETCONN) || defined(DNETSVR4) -- if (decnet_server) { -- port = ServerDisplay + ServerOutPort; -- return(port); -- } --#endif - port = ServerBasePort + ServerOutPort + ServerDisplay; - debug(4,(stderr, "Server service is on port %d\n", port)); - return(port); - } - --static short GetScopePort () -+static short -+GetScopePort (void) - { - short port; - - enterprocedure("GetScopePort"); - --#if defined(DNETCONN) || defined(DNETSVR4) -- if (decnet_in) { -- port = ServerInPort + ServerDisplay; -- return(port); -- } --#endif - port = ServerBasePort + ServerInPort + ServerDisplay; - debug(4,(stderr, "scope service is on port %d\n", port)); - return(port); -@@ -147,7 +676,7 @@ static short GetScopePort () - /* ********************************************** */ - - static void --Usage() -+Usage(void) - { - fprintf(stderr, "Usage: xscope\n"); - fprintf(stderr, " [-h]\n"); -@@ -158,20 +687,22 @@ Usage() - #ifdef RAW_MODE - fprintf(stderr, " [-r] -- raw output\n"); - #endif -+ fprintf(stderr, " [-a] -- audio verbose output\n"); - fprintf(stderr, " [-q] -- quiet output\n"); - fprintf(stderr, " [-D]\n"); -+ fprintf(stderr, " [-S] -- start/stop on SIGUSR1\n"); -+ fprintf(stderr, " [-t] -- terminate when all clients close\n"); - exit(1); - } - -+ - static void --ScanArgs(argc, argv) -- int argc; -- char **argv; -+ScanArgs ( -+ int argc, -+ char **argv) - { --#if defined(DNETCONN) || defined(DNETSVR4) -- char *ss; --#endif -- Verbose = 1 /* default verbose-ness level */; -+ XVerbose = 1 /* default verbose-ness level */; -+ NasVerbose = 1; - #ifdef RAW_MODE - Raw = 0 ; - #endif -@@ -196,19 +727,18 @@ 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; - - #ifdef RAW_MODE -@@ -218,48 +748,61 @@ ScanArgs(argc, argv) - break; - #endif - -+ case 'v': /* verbose mode */ -+ XVerbose = atoi(++*argv); -+ debug(1,(stderr, "Verbose = %d\n", XVerbose)); -+ break; -+ - case 'o': - ServerOutPort = atoi(++*argv); - if (ServerOutPort <= 0) - ServerOutPort = 0; -- debug(1,(stderr, "ServerOutPort = %d\n", ServerOutPort)); -+ debug(1,(stderr, "ServerOutPort = %ld\n", ServerOutPort)); - break; - - case 'd': - ServerDisplay = atoi(++*argv); - if (ServerDisplay <= 0) - ServerDisplay = 0; -- debug(1,(stderr, "ServerDisplay=%d\n", ServerDisplay)); -+ debug(1,(stderr, "ServerDisplay = %ld\n", ServerDisplay)); - break; - - case 'i': --#if defined(DNETCONN) || defined(DNETSVR4) -- if (ss = (char *)strchr(*argv,':')) { -- decnet_in = 1; -- *ss = NULL; -- } --#endif - ServerInPort = atoi(++*argv); - if (ServerInPort <= 0) - ServerInPort = 0; -- debug(1,(stderr, "ServerInPort = %d\n", ServerInPort)); -+ debug(1,(stderr, "ServerInPort = %ld\n", ServerInPort)); - break; - - case 'h': --#if defined(DNETCONN) || defined(DNETSVR4) -- if (ss = (char *)strchr(*argv,':')) { -- decnet_server = 1; -- *ss = NULL; -- strcpy(ServerHostName,++*argv); -- break; -- } --#endif - if (++*argv != NULL && **argv != '\0' - && (strlen(*argv) < sizeof(ServerHostName))) - strcpy(ServerHostName, *argv); - debug(1,(stderr, "ServerHostName=%s\n", ServerHostName)); - break; - -+ 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, *argv); -+ debug(1,(stderr, "AudioServerHostName=%s\n", AudioServerHostName)); -+ break; -+ case 't': -+ TerminateClose = 1; -+ break; -+ - default: - fprintf(stderr, "Unknown option %c\n", **argv); - Usage(); -@@ -277,7 +820,7 @@ ScanArgs(argc, argv) - if (ServerInPort == ServerOutPort) - if (ServerHostName[0] == '\0') - { -- fprintf(stderr, "Can't have xscope on same port as server (%d)\n", -+ fprintf(stderr, "Can't have xscope on same port as server (%ld)\n", - ServerInPort); - Usage(); - } -@@ -289,29 +832,27 @@ ScanArgs(argc, argv) - /* */ - /* ********************************************** */ - --main(argc, argv) -- int argc; -- char **argv; -+int -+main ( -+ int argc, -+ char **argv) - { - ScanArgs(argc, argv); - InitializeFD(); - InitializeX11(); -+ if (DoAudio) -+ InitializeAudio(); - SetUpStdin(); --#if defined(DNETCONN) || defined(DNETSVR4) -- if (decnet_in) -- SetUpDECnetConnection(GetScopePort()); -- else -- SetUpConnectionSocket(GetScopePort()); --#else -- SetUpConnectionSocket(GetScopePort()); -+ SetUpConnectionSocket(GetScopePort(), NewConnection); -+ if (DoAudio) -+ SetUpConnectionSocket (GetScopePort() + 2000, NewAudio); - SetSignalHandling(); --#endif - - return MainLoop(); - } - - void --TimerExpired() -+TimerExpired (void) - { - debug(16,(stderr, "Timer tick\n")); - } -@@ -333,22 +874,22 @@ TimerExpired() - */ - - static void --ReadStdin(fd) -- FD fd; -+ReadStdin ( -+ FD fd) - { - char buf[2048]; - long n; - - enterprocedure("ReadStdin"); - n = read(fd, buf, 2048); -- debug(4,(stderr, "read %d bytes from stdin\n", n)); -+ debug(4,(stderr, "read %ld bytes from stdin\n", n)); - } - - static void --SetUpStdin() -+SetUpStdin (void) - { - enterprocedure("SetUpStdin"); -- UsingFD(fileno(stdin), ReadStdin, NULL); -+ UsingFD(fileno(stdin), ReadStdin, NULL, NULL); - } - - /* ************************************************************ */ -@@ -365,32 +906,31 @@ 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 struct fdinfo FDinfo[StaticMaxFD]; -+static long clientNumber = 0; -+struct fdinfo FDinfo[StaticMaxFD]; - --static void --SetUpPair(client, server) -- FD client; -- FD server; -+void -+SetUpPair( -+ FD client, -+ FD 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) -@@ -401,10 +941,30 @@ SetUpPair(client, server) - } - - static void --CloseConnection(fd) -- FD fd; -+ResetPair ( -+ 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; -+ } -+} -+ -+static void -+CloseConnection ( -+ FD fd) - { - debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd))); -+ ResetPair (ClientHalf(fd), ServerHalf(fd)); - StopClientConnection(ServerHalf(fd)); - StopServerConnection(ClientHalf(fd)); - -@@ -417,63 +977,148 @@ CloseConnection(fd) - #endif - NotUsingFD(fd); - NotUsingFD(FDPair(fd)); -+ if (TerminateClose) -+ exit (0); - } - - /* ************************************************************ */ - --FD FDPair(fd) -- FD fd; -+FD -+FDPair ( -+ FD fd) - { - return(FDinfo[fd].pair); - } - --FD ClientHalf(fd) -- FD fd; -+FD -+ClientHalf ( -+ FD fd) - { - if (FDinfo[fd].Server) - return(FDinfo[fd].pair); - return(fd); - } - --FD ServerHalf(fd) -- FD fd; -+FD -+ServerHalf ( -+ FD fd) - { - if (FDinfo[fd].Server) - return(fd); - return(FDinfo[fd].pair); - } - --char *ClientName (fd) -- FD fd; -+char * -+ClientName ( -+ FD fd) - { - static char name[12]; - -- if (ClientNumber <= 1) -+ if (clientNumber <= 1) - return(""); -- sprintf(name, " %d", FDinfo[fd].ClientNumber); -+ (void)sprintf(name, " %ld", FDinfo[fd].ClientNumber); - return(name); - } - -+int -+ClientNumber ( -+ 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 -+ */ -+void -+FlushFD ( -+ FD fd) -+{ -+ long BytesToWrite = FDinfo[fd].bufcount - FDinfo[fd].bufstart; -+ unsigned 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) { -+ FD_CLR(PeerFD, &BlockedReadDescriptors); -+ } -+ FD_CLR(fd, &WriteDescriptors); -+ FDinfo[fd].bufcount = FDinfo[fd].bufstart = 0; -+ } -+ else -+ { -+ if (PeerFD >= 0) { -+ FD_SET(PeerFD, &BlockedReadDescriptors); -+ } -+ if (FDinfo[fd].buflimit != FDinfo[fd].bufdelivered) { -+ FD_SET(PeerFD, &WriteDescriptors); -+ } -+ } -+} -+ - /* 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. */ - - static void --DataFromClient(fd) -- FD fd; -+DataFromClient ( -+ 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 Client%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 %ld bytes from Client%s\n", n, ClientName(fd))); - if (n < 0) - { - PrintTime(); -@@ -484,58 +1129,18 @@ DataFromClient(fd) - if (n == 0) - { - PrintTime(); -- fprintf(stdout, "Client%s --> EOF\n", ClientName(fd)); -+ if (Verbose >= 0) -+ fprintf(stdout, "Client%s --> EOF\n", ClientName(fd)); - CloseConnection(fd); - return; - } - -- ServerFD = FDPair(fd); -- if (ServerFD < 0) -- { -- ServerFD = ConnectToServer(false); -- SetUpPair(fd, ServerFD); -- } -- -- /* write bytes from client to server, allow for server to fail */ -- if (ServerFD >= 0) -- { -- long BytesToWrite = n; -- unsigned char *p = buf; -- -- while (BytesToWrite > 0) -- { -- int n1 = write (ServerFD, (char *)p, (int)BytesToWrite); -- debug(4,(stderr, "write %d bytes to Server%s\n", n1, ClientName(fd))); -- if (n1 > 0) -- { -- BytesToWrite -= n1; -- p += n1; -- } -- /* -- B U G : 4156754 -- -- Write may fail with an error code of EAGAIN if -- BytesToWrite is less than PIPE_BUF, but bigger -- than available free space. This error says, wait -- and try again till PIPE is flushed and has more -- free space. -- */ -- else if (errno == EAGAIN) -- { -- /* Wait for some time and try again */ -- sleep (1); -- } -- else -- { -- perror("Error on write to Server"); -- CloseConnection(fd); -- BytesToWrite = 0; -- } -- } -- } -+ 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); - } - - /* ********************************************** */ -@@ -546,16 +1151,23 @@ DataFromClient(fd) - we close the connection down -- don't need a server with no client. */ - - static void --DataFromServer(fd) -- FD fd; -+DataFromServer ( -+ 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 Server%s\n", n, ClientName(fd))); -+ n = read(fd, (char *)FDinfo[ClientFD].buffer, BUFFER_SIZE); -+ debug(4,(stderr, "read %ld bytes from Server%s\n", n, ClientName(fd))); - if (n < 0) - { - PrintTime(); -@@ -566,56 +1178,18 @@ DataFromServer(fd) - if (n == 0) - { - PrintTime(); -- fprintf(stdout, "EOF <-- Server%s\n", ClientName(fd)); -+ if (Verbose >= 0) -+ fprintf(stdout, "EOF <-- Server%s\n", ClientName(fd)); - CloseConnection(fd); - return; - } - -- ClientFD = FDPair(fd); -- if (ClientFD < 0) -- { -- CloseConnection(fd); -- return; -- } -- -- /* write bytes from server to client, allow for client to fail */ -- { -- long BytesToWrite = n; -- unsigned char *p = buf; -- while (BytesToWrite > 0) -- { -- int n1 = write (ClientFD, (char *)p, (int)BytesToWrite); -- debug(4,(stderr, "write %d bytes to Client%s\n", n1, ClientName(fd))); -- if (n1 > 0) -- { -- BytesToWrite -= n1; -- p += n1; -- } -- /* -- B U G : 4156754 -- -- Write may fail with an error code of EAGAIN if -- BytesToWrite is less than PIPE_BUF, but bigger -- than available free space. This error says, wait -- and try again till PIPE is flushed and has more -- free space. -- */ -- else if (errno == EAGAIN) -- { -- /* Wait for some time and try again */ -- sleep (1); -- } -- else -- { -- perror("Error on write to Client"); -- CloseConnection(fd); -- BytesToWrite = 0; -- } -- } -- } -+ 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); - } - - -@@ -626,59 +1200,23 @@ DataFromServer(fd) - /* */ - /* ************************************************************ */ - --#include /* needed by sys/socket.h and netinet/in.h */ --#include /* for struct iovec, used by socket.h */ --#include /* for AF_INET, SOCK_STREAM, ... */ --#include /* for FIONCLEX, FIONBIO, ... */ --#include /* struct sockaddr_in */ --#include /* struct servent * and struct hostent * */ --#include /* for EINTR, EADDRINUSE, ... */ --extern int errno; -- --static int ON = 1 /* used in ioctl */ ; - - void --NewConnection(fd) -- FD fd; -+NewConnection ( -+ FD fd) - { -- FD ServerFD = -1; -- FD ClientFD = -1; -- --#ifdef DNETCONN -- if (decnet_in) -- ClientFD = ConnectToDECnetClient(fd); -- else -- ClientFD = ConnectToClient(fd); -- if (decnet_server) -- ServerFD = ConnectToDECnetServer(true); -- else -- ServerFD = ConnectToServer(true); --#endif --#ifdef DNETSVR4 -- ClientFD = ConnectToClient(fd); -- if (decnet_server) { -- if (!initialize_libdni()) { -- fprintf(stderr,"Unable to open libdni.so\n"); -- exit(0); -- } -- ServerFD = ConnectToDECnetSVR4Server(true); -- } -- else -- ServerFD = ConnectToServer(true); --#endif --#if !(defined(DNETCONN)) && !(defined(DNETSVR4)) -- ClientFD = ConnectToClient(fd); -- ServerFD = ConnectToServer(true); -+ FD ClientFD = ConnectToClient(fd); -+ FD ServerFD = ConnectToServer(true); - --#endif - SetUpPair(ClientFD, ServerFD); - } - - - /* ************************************************************ */ - --static FD ConnectToClient(ConnectionSocket) -- FD ConnectionSocket; -+static FD -+ConnectToClient ( -+ FD ConnectionSocket) - { - FD ClientFD; - XtransConnInfo trans_conn = NULL; -@@ -688,6 +1226,7 @@ static FD ConnectToClient(ConnectionSocket) - #else - struct sockaddr_in from; - int len = sizeof (from); -+ int ON = 1 /* used in ioctl */ ; - #endif - - enterprocedure("ConnectToClient"); -@@ -701,7 +1240,7 @@ static FD ConnectToClient(ConnectionSocket) - _X11TransSetOption(trans_conn, TRANS_NONBLOCKING, 1); - ClientFD = _X11TransGetConnectionNumber(trans_conn); - #else -- ClientFD = accept(ConnectionSocket, (struct sockaddr *)&from, &len); -+ ClientFD = AcceptConnection(ConnectionSocket); - #endif - debug(4,(stderr, "Connect To Client: FD %d\n", ClientFD)); - if (ClientFD < 0 && errno == EWOULDBLOCK) -@@ -715,7 +1254,7 @@ static FD ConnectToClient(ConnectionSocket) - panic("Can't connect to Client"); - } - -- UsingFD(ClientFD, DataFromClient, trans_conn); -+ UsingFD(ClientFD, DataFromClient, FlushFD, trans_conn); - #ifndef USE_XTRANS - ioctl(ClientFD, FIOCLEX, 0); - ioctl(ClientFD, FIONBIO, &ON); -@@ -731,31 +1270,20 @@ static FD ConnectToClient(ConnectionSocket) - - - --static FD ConnectToServer(report) -- Boolean report; -+FD -+ConnectToServer ( -+ Boolean report) - { - FD ServerFD; - XtransConnInfo trans_conn = NULL; /* transport connection object */ --#ifdef USE_XTRANS -- char address[256]; -- int connect_stat; -- extern long ServerBasePort; --#else -- struct sockaddr_in sin; -- struct hostent *hp; --#endif - short port; - - enterprocedure("ConnectToServer"); - -- /* 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)); - port = GetServerport (); - -- if (port == ScopePort -- && strcmp(ServerHostName, ScopeHost) == 0) -+ if (port == ScopePort && -+ ((ServerHostName[0] == '\0') || strcmp(ServerHostName, ScopeHost) == 0)) - { - char error_message[100]; - sprintf(error_message, "Trying to attach to myself: %s,%d\n", -@@ -763,233 +1291,13 @@ static FD ConnectToServer(report) - panic(error_message); - } - --#ifdef USE_XTRANS -- snprintf (address, sizeof(address), "%s:%d", ServerHostName, -- port - ServerBasePort); -- if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL ) { -- debug(1,(stderr, "OpenCOTSClient failed\n")); -- panic("Can't open connection to Server"); -- } -- if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 ) { -- _X11TransClose(trans_conn); -- trans_conn = NULL; -- debug(1,(stderr, "TransConnect failed\n")); -- panic("Can't open connection to Server"); -- } -- -- ServerFD = _X11TransGetConnectionNumber(trans_conn); --#else -- /* 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); -- (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0); --#ifdef SO_DONTLINGER -- (void) setsockopt(ServerFD, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); --#endif -- -- 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 (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 */ -- close(ServerFD); -- debug(1,(stderr, "No Server\n")); -- if (report) -- warn("Can't open connection to Server"); -- return(-1); -- -- default: -- close(ServerFD); -- panic("Can't open connection to Server"); -- } -- } --#endif -+ ServerFD = MakeConnection (ServerHostName, port, report, &trans_conn); - - debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); - if (ServerFD >= 0) - { -- UsingFD(ServerFD, DataFromServer, trans_conn); -+ UsingFD(ServerFD, DataFromServer, FlushFD, trans_conn); - StartServerConnection(ServerFD); - } - return(ServerFD); - } -- --#ifdef DNETSVR4 --FD ConnectToDECnetSVR4Server(report) -- Boolean report; --{ -- FD ServerFD; -- struct sockaddr_dn sdn; -- struct hostent *hp; -- -- enterprocedure("ConnectToServer"); -- -- /* establish a socket to the name server for this host */ -- ServerFD = socket(AF_DECnet, 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); -- (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0); -- /* determine the host machine for this process */ -- initialize_libdni(); -- if (ServerHostName[0] == '\0') -- (dnet_gethostname)(ServerHostName); -- debug(4,(stderr, "try to connect on %s\n", ServerHostName)); -- -- hp = (struct hostent *)(dnet_gethostbyname)(ServerHostName); -- if (hp == 0) -- { -- perror("gethostbyname failed"); -- debug(1,(stderr, "gethostbyname failed for %s\n", ServerHostName)); -- panic("Can't open connection to Server"); -- } -- -- sdn.sdn_family = AF_DECnet; -- sdn.sdn_format = DNADDR_FMT1; -- sdn.sdn_port = 0; -- sprintf (sdn.sdn_name, "X$X%d", GetServerport() ); -- sdn.sdn_namelen = strlen(sdn.sdn_name); -- sdn.sdn_addr = *(u_short *)hp->h_addr_list[0]; -- -- /* ******************************************************** */ -- /* try to connect to Server */ -- -- if (connect(ServerFD, (struct sockaddr *)&sdn, sizeof(sdn)) < 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 */ -- close(ServerFD); -- debug(1,(stderr, "No Server\n")); -- if (report) -- warn("Can't open connection to Server"); -- return(-1); -- -- default: -- close(ServerFD); -- panic("Can't open connection to Server"); -- } -- } -- -- debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); -- if (ServerFD >= 0) -- { -- UsingFD(ServerFD, DataFromServer, NULL); -- StartServerConnection(ServerFD); -- } -- return(ServerFD); --} --#endif -- --/* ********************************************** */ --/* */ --/* ********************************************** */ -- --#ifdef DNETCONN --FD ConnectToDECnetClient(fd) -- FD fd; --{ -- struct ses_io_type sesopts; -- static SessionData sd= {0, {0, ""}}; -- -- if (ioctl(fd, SES_ACCEPT, &sd) < 0) { -- fprintf(stderr,"xscope: dni: SES_ACCEPT failed\n"); -- exit(-1); -- } -- UsingFD(fd, DataFromClient, NULL); -- StartClientConnection(fd); -- /* unlike sockets, dni consumes the fd on which it was listening */ -- /* in order to accept new logical link requests using the same name */ -- /* we must re-open the logical link device and re-supply the */ -- /* appropriate access control information */ -- -- SetUpDECnetConnection(GetScopePort()); -- -- return(fd); --} -- -- --FD ConnectToDECnetServer(report) -- Boolean report; --{ -- FD fd; -- OpenBlock opblk; -- struct ses_io_type sesopts; -- struct nodeent *np; -- -- if ((fd = open("/dev/dni", O_RDWR)) < 0) { -- fprintf(stderr,"xscope: dni: open failed\n"); -- exit(-1); -- } -- if (ioctl(fd, SES_GET_LINK, 0)) { -- fprintf(stderr,"xscope: dni: can't get link\n"); -- exit(-1); -- } -- -- /* set nonblocking here since dni can't handle fcntls */ -- sesopts.io_flags = SES_IO_NBIO; -- sesopts.io_io_signal = sesopts.io_int_signal = 0; -- -- if (ioctl(fd, SES_IO_TYPE, &sesopts) < 0) { -- fprintf(stderr,"xscope: dni: ioctl failed\n"); -- exit(-1); -- } -- -- strncpy(opblk.op_node_name,ServerHostName , 6); /* dni server name */ -- opblk.op_node_name[6] = '\0'; -- sprintf(opblk.op_task_name, "X$X%d", GetServerport()); -- opblk.op_userid[0] = '\0'; /* No one checks our id */ -- opblk.op_object_nbr = 0; /* Any fields not used */ -- opblk.op_account[0] = '\0'; /* should be set to zero */ -- opblk.op_password[0] = '\0'; -- opblk.op_opt_data.im_length = 0; -- -- if (ioctl(fd, SES_LINK_ACCESS, &opblk) == -1) { -- fprintf(stderr,"xscope: dni: cannot connect to server\n"); -- exit(-1); -- } -- UsingFD(fd, DataFromServer, NULL); -- StartServerConnection(fd); -- return(fd); -- --} --#endif -- -diff --git a/scope.h b/scope.h -index cec14b2..3100559 100644 ---- a/scope.h -+++ b/scope.h -@@ -53,7 +53,16 @@ - * - ********************************************** */ - -+#ifndef XSCOPE_SCOPE_H -+#define XSCOPE_SCOPE_H -+ -+#include -+#include - #include -+#include -+#include -+#include -+#include - #ifdef SVR4 - #include - #endif /* SVR4 */ -@@ -62,39 +71,37 @@ - #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; - - /* ********************************************** */ - /* */ - /* ********************************************** */ - --short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ; -+extern short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ; -+extern short XVerbose; -+extern short NasVerbose; - #ifdef RAW_MODE --short Raw /* raw data output only */ ; -+extern short Raw /* raw data output only */ ; - #else - #define Raw 0 - #endif - --int ScopePort; --char *ScopeHost; - --/* external function type declarations */ -+extern int ScopePort; -+extern char *ScopeHost; - --extern void *Malloc (long n); --#ifdef X_NOT_STDC_ENV --extern char *strcpy(); --extern char *sprintf(); --#else --#include --#include --#endif --extern char *ClientName(); -+extern int Interrupt, SingleStep, BreakPoint; -+ -+extern char ServerHostName[MAXHOSTNAMELEN]; -+extern char AudioServerHostName[MAXHOSTNAMELEN]; - - /* ********************************************** */ - /* */ -@@ -102,3 +109,29 @@ extern char *ClientName(); - - #include "fd.h" - #include "proto.h" -+ -+#define BUFFER_SIZE (1024 * 32) -+ -+struct fdinfo -+{ -+ Boolean Server; -+ long ClientNumber; -+ FD pair; -+ unsigned char buffer[BUFFER_SIZE]; -+ int bufcount; -+ int bufstart; -+ int buflimit; /* limited writes */ -+ int bufdelivered; /* total bytes delivered */ -+ Boolean writeblocked; -+}; -+ -+extern struct fdinfo FDinfo[StaticMaxFD]; -+extern int littleEndian; -+extern char HandleSIGUSR1; -+extern char Leader[]; -+extern long ServerBasePort; -+extern char ScopeEnabled; -+extern long TranslateText; -+ -+ -+#endif /* XSCOPE_SCOPE_H */ -diff --git a/server.c b/server.c -index 076648d..d04c335 100644 ---- a/server.c -+++ b/server.c -@@ -61,7 +61,10 @@ - #define bcopy(s,d,l) memmove(d,s,l) - #endif - --static void ProcessBuffer(FD fd, unsigned char *buf, long n); -+struct TypeDef TD[MaxTypes]; -+unsigned char RBf[2]; -+unsigned char SBf[4]; -+struct ConnState CS[StaticMaxFD]; - - /* ************************************************************ */ - /* */ -@@ -69,27 +72,36 @@ static void ProcessBuffer(FD fd, unsigned char *buf, long n); - /* ************************************************************ */ - - void --ReportFromClient(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ReportFromClient( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- PrintTime(); -- fprintf(stdout, "Client%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 --> %4ld %s\n", -+ ClientName(fd), n, (n == 1 ? "byte" : "bytes")); -+ } -+ } -+ ProcessBuffer(fd, buf, n); - } - - void --ReportFromServer(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ReportFromServer ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- 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); -+ if (Verbose > 0) { -+ if (ScopeEnabled) { -+ PrintTime(); -+ fprintf(stdout, "\t\t\t\t\t%4ld %s <-- X11 Server%s\n", -+ n, (n == 1 ? "byte" : "bytes"), ClientName(fd)); -+ } -+ } -+ ProcessBuffer(fd, buf, n); - } - - -@@ -98,7 +110,6 @@ ReportFromServer(fd, buf, n) - /* */ - /* ************************************************************ */ - --#include /* for struct timeval * */ - static long ZeroTime1 = -1; - static long ZeroTime2 = -1; - static struct timeval tp; -@@ -106,7 +117,7 @@ static struct timeval tp; - /* print the time since we started in hundredths (1/100) of seconds */ - - void --PrintTime() -+PrintTime(void) - { - static long lastsec = 0; - long sec /* seconds */ ; -@@ -127,7 +138,7 @@ PrintTime() - hsec += 100; - sec -= 1; - } -- fprintf(stdout, "%2d.%02ld: ", sec, hsec); -+ fprintf(stdout, "%2ld.%02ld: ", sec, hsec); - } - - /* ************************************************************ */ -@@ -139,39 +150,52 @@ PrintTime() - requests as various built-in types. The following routines - support the types built into X11 */ - --long pad (n) -- long n; -+long -+pad ( -+ long n) - { - /* round up to next multiple of 4 */ - return((n + 3) & ~0x3); - } - --static int littleEndian; -- --unsigned long ILong (buf) -- unsigned char buf[]; -+unsigned long -+ILong ( -+ const unsigned char buf[]) - { -+ /* check for byte-swapping */ - 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 -+IShort ( -+ const unsigned char buf[]) - { -+ /* check for byte-swapping */ - if (littleEndian) - return (buf[1] << 8) | buf[0]; - return((buf[0] << 8) | buf[1]); - } - --unsigned short IByte (buf) --unsigned char buf[]; -+unsigned short -+IChar2B ( -+ const unsigned char buf[]) -+{ -+ /* CHAR2B is like an IShort, but not byte-swapped */ -+ return((buf[0] << 8) | buf[1]); -+} -+ -+unsigned short -+IByte ( -+ const unsigned char buf[]) - { - return(buf[0]); - } - --Boolean IBool(buf) -- unsigned char buf[]; -+Boolean -+IBool ( -+ const unsigned char buf[]) - { - if (buf[0] != 0) - return(true); -@@ -189,10 +213,10 @@ Boolean IBool(buf) - interpret. The following procedures provide this ability */ - - static void --SaveBytes(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+SaveBytes ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - /* check if there is enough space to hold the bytes we want */ - if (CS[fd].NumberofSavedBytes + n > CS[fd].SizeofSavedBytes) -@@ -216,9 +240,9 @@ SaveBytes(fd, buf, n) - } - - static void --RemoveSavedBytes(fd, n) -- FD fd; -- long n; -+RemoveSavedBytes ( -+ FD fd, -+ long n) - { - /* check if all bytes are being removed -- easiest case */ - if (CS[fd].NumberofSavedBytes <= n) -@@ -246,15 +270,13 @@ RemoveSavedBytes(fd, n) - - /* following are the possible values for ByteProcessing */ - /* forward declarations */ --static long StartSetUpMessage(FD fd, unsigned char *buf, long n); --static long FinishSetUpMessage(FD fd, unsigned char *buf, long n); --static long StartRequest(FD fd, unsigned char *buf, long n); --static long FinishRequest(FD fd, unsigned char *buf, long n); -+static long FinishSetUpMessage(FD fd, const unsigned char *buf, long n); -+static long StartRequest(FD fd, const unsigned char *buf, long n); -+static long FinishRequest(FD fd, const unsigned char *buf, long n); - --static long StartSetUpReply(FD fd, unsigned char *buf, long n); --static long FinishSetUpReply(FD fd, unsigned char *buf, long n); --static long ServerPacket(FD fd, unsigned char *buf, long n); --static long FinishReply(FD fd, unsigned char *buf, long n); -+static long FinishSetUpReply(FD fd, const unsigned char *buf, long n); -+static long ServerPacket(FD fd, const unsigned char *buf, long n); -+static long FinishReply(FD fd, const unsigned char *buf, long n); - - - /* ************************************************************ */ -@@ -262,18 +284,24 @@ static long FinishReply(FD fd, unsigned char *buf, long n); - /* */ - /* ************************************************************ */ - --static void --ProcessBuffer(fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+int littleEndian; -+ -+void -+ProcessBuffer ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- unsigned char *BytesToProcess; -+ const unsigned char *BytesToProcess; - long NumberofUsedBytes; - - /* as long as we have enough bytes to do anything -- do it */ - -- littleEndian = CS[fd].littleEndian; -+ if (Verbose > 4) -+ { -+ fprintf (stdout, "\nRead from fd %d\n", fd); -+ DumpHexBuffer (buf, n); -+ } - while (CS[fd].NumberofSavedBytes + n >= CS[fd].NumberofBytesNeeded) - { - /* -@@ -323,6 +351,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); - -@@ -333,6 +362,7 @@ ProcessBuffer(fd, buf, n) - - if (NumberofUsedBytes > 0) - { -+ CS[fd].NumberofBytesProcessed += NumberofUsedBytes; - if (CS[fd].NumberofSavedBytes > 0) - RemoveSavedBytes(fd, NumberofUsedBytes); - else -@@ -345,9 +375,15 @@ ProcessBuffer(fd, buf, n) - } - } /* end of while (NumberofSavedBytes + n >= NumberofBytesNeeded) */ - -+ if (Verbose > 3) -+ fprintf (stdout, "Have %ld need %ld\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; - } - -@@ -363,14 +399,68 @@ ProcessBuffer(fd, buf, n) - */ - - void --StartClientConnection(fd) -- FD fd; -+SetBufLimit ( -+ FD fd) -+{ -+ int ServerFD = FDPair (fd); -+ FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed + -+ CS[fd].NumberofBytesNeeded); -+} -+ -+void -+ClearBufLimit ( -+ FD fd) -+{ -+ int ServerFD = FDPair (fd); -+ FDinfo[ServerFD].buflimit = -1; -+} -+ -+static void -+StartStuff ( -+ FD fd) -+{ -+ if (BreakPoint) -+ { -+ int ServerFD = FDPair (fd); -+ FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed + -+ CS[fd].NumberofBytesNeeded); -+ FlushFD (ServerFD); -+ } -+} -+ -+static void -+FinishStuff ( -+ FD fd, -+ const 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); -+ } -+ } -+} -+ -+void -+StartClientConnection ( -+ FD fd) - { - enterprocedure("StartClientConnection"); - /* when a new connection is started, we have no saved bytes */ - CS[fd].SavedBytes = NULL; - CS[fd].SizeofSavedBytes = 0; - CS[fd].NumberofSavedBytes = 0; -+ CS[fd].NumberofBytesProcessed = 0; - - /* when a new connection is started, we have no reply Queue */ - FlushReplyQ(fd); -@@ -381,11 +471,12 @@ StartClientConnection(fd) - /* we need 12 bytes to start a SetUp message */ - CS[fd].ByteProcessing = StartSetUpMessage; - CS[fd].NumberofBytesNeeded = 12; -+ StartStuff (fd); - } - - void --StopClientConnection(fd) -- FD fd; -+StopClientConnection ( -+ FD fd) - { - enterprocedure("StopClientConnection"); - /* when a new connection is stopped, discard the old buffer */ -@@ -394,10 +485,11 @@ StopClientConnection(fd) - Free((char*)CS[fd].SavedBytes); - } - --static long StartSetUpMessage (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+long -+StartSetUpMessage ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - unsigned short namelength; - unsigned short datalength; -@@ -409,21 +501,26 @@ static 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; - CS[fd].NumberofBytesNeeded = n - + pad((long)namelength) + pad((long)datalength); -- debug(8,(stderr, "need %d bytes to finish startup\n", -+ debug(8,(stderr, "need %ld bytes to finish startup\n", - CS[fd].NumberofBytesNeeded - n)); -+ StartStuff (fd); - return(0); - } - --static long FinishSetUpMessage (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+static long -+FinishSetUpMessage ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - enterprocedure("FinishSetUpMessage"); - if( Raw || (Verbose > 3) ) -@@ -431,43 +528,76 @@ static long FinishSetUpMessage (fd, buf, n) - CS[fd].littleEndian = (buf[0] == 'l'); - CS[ServerHalf(fd)].littleEndian = CS[fd].littleEndian; - littleEndian = CS[fd].littleEndian; -- PrintSetUpMessage(buf); -+ 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); - } - -- --static long StartRequest (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+static long -+StartBigRequest ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- unsigned short requestlength; -- enterprocedure("StartRequest"); -+ enterprocedure("StartBigRequest"); - -- /* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */ -- requestlength = IShort(&buf[2]); -+ /* bytes 0-3 are ignored now; bytes 4-8 tell us the request length */ -+ CS[fd].requestLen = ILong(&buf[4]); - - CS[fd].ByteProcessing = FinishRequest; -- CS[fd].NumberofBytesNeeded = 4 * requestlength; -- debug(8,(stderr, "need %d more bytes to finish request\n", -+ CS[fd].NumberofBytesNeeded = 4 * CS[fd].requestLen; -+ debug(8,(stderr, "need %ld more bytes to finish request\n", - CS[fd].NumberofBytesNeeded - n)); -+ StartStuff (fd); - return(0); - } - -+static long -+StartRequest ( -+ FD fd, -+ const unsigned char *buf, -+ long n) -+{ -+ enterprocedure("StartRequest"); - --static long FinishRequest (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ /* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */ -+ CS[fd].requestLen = IShort(&buf[2]); -+ if (CS[fd].requestLen == 0 && CS[fd].bigreqEnabled) -+ { -+ CS[fd].ByteProcessing = StartBigRequest; -+ CS[fd].NumberofBytesNeeded = 8; -+ } -+ else -+ { -+ if (CS[fd].requestLen == 0) -+ CS[fd].requestLen = 1; -+ CS[fd].ByteProcessing = FinishRequest; -+ CS[fd].NumberofBytesNeeded = 4 * CS[fd].requestLen; -+ debug(8,(stderr, "need %ld more bytes to finish request\n", -+ CS[fd].NumberofBytesNeeded - n)); -+ } -+ StartStuff (fd); -+ return(0); -+} -+ -+ -+static long -+FinishRequest ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - enterprocedure("FinishRequest"); -- DecodeRequest(fd, buf, n); - CS[fd].ByteProcessing = StartRequest; - CS[fd].NumberofBytesNeeded = 4; -+ if (ScopeEnabled) -+ DecodeRequest(fd, buf, n); -+ FinishStuff (fd, buf, n); - return(n); - } - -@@ -477,14 +607,15 @@ static long FinishRequest (fd, buf, n) - /* ************************************************************ */ - - void --StartServerConnection(fd) -- FD fd; -+StartServerConnection ( -+ FD fd) - { - enterprocedure("StartServerConnection"); - /* when a new connection is started, we have no saved bytes */ - CS[fd].SavedBytes = NULL; - CS[fd].SizeofSavedBytes = 0; - CS[fd].NumberofSavedBytes = 0; -+ CS[fd].NumberofBytesProcessed = 0; - - /* when a new connection is started, we have no reply Queue */ - FlushReplyQ(fd); -@@ -495,8 +626,8 @@ StartServerConnection(fd) - } - - void --StopServerConnection(fd) -- FD fd; -+StopServerConnection ( -+ FD fd) - { - enterprocedure("StopServerConnection"); - /* when a new connection is stopped, discard the old buffer */ -@@ -505,11 +636,11 @@ StopServerConnection(fd) - Free((char *)CS[fd].SavedBytes); - } - --static long --StartSetUpReply (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+long -+StartSetUpReply ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - unsigned short replylength; - -@@ -517,21 +648,22 @@ StartSetUpReply (fd, buf, n) - replylength = IShort(&buf[6]); - CS[fd].ByteProcessing = FinishSetUpReply; - CS[fd].NumberofBytesNeeded = n + 4 * replylength; -- debug(8,(stderr, "need %d bytes to finish startup reply\n", -+ debug(8,(stderr, "need %ld bytes to finish startup reply\n", - CS[fd].NumberofBytesNeeded - n)); - return(0); - } - - static long --FinishSetUpReply (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+FinishSetUpReply ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - enterprocedure("FinishSetUpReply"); - if( Raw || (Verbose > 3) ) - DumpItem("Server Connect", fd, buf, n) ; -- PrintSetUpReply(buf); -+ if (ScopeEnabled) -+ PrintSetUpReply(buf); - CS[fd].ByteProcessing = ServerPacket; - CS[fd].NumberofBytesNeeded = 32; - return(n); -@@ -540,44 +672,38 @@ FinishSetUpReply (fd, buf, n) - /* ************************************************************ */ - - static long --ErrorPacket (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ErrorPacket ( -+ FD fd, -+ const 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); - } - - - static long --EventPacket (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+EventPacket ( -+ FD fd, -+ const 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); - } - - - static long --ReplyPacket (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ReplyPacket ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { -- /* -- B U G: 4242329 -- fix for GetImage packet, where data length is too long -- to handle using a short field. -- */ -- - long replylength; - - replylength = ILong(&buf[4]); -@@ -594,15 +720,15 @@ ReplyPacket (fd, buf, n) - - CS[fd].ByteProcessing = FinishReply; - CS[fd].NumberofBytesNeeded = n + 4 * replylength; -- debug(8,(stderr, "need %d bytes to finish reply\n", (4 * replylength))); -+ debug(8,(stderr, "need %ld bytes to finish reply\n", (4 * replylength))); - return(0); - } - - static long --ServerPacket (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+ServerPacket ( -+ FD fd, -+ const unsigned char *buf, -+ long n) - { - short PacketType; - enterprocedure("ServerPacket"); -@@ -615,14 +741,23 @@ ServerPacket (fd, buf, n) - return(EventPacket(fd, buf, n)); - } - --long FinishReply (fd, buf, n) -- FD fd; -- unsigned char *buf; -- long n; -+long -+FinishReply ( -+ FD fd, -+ const 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 ( -+ const char *name) -+{ -+ return GetEValue (REQUEST, name); -+} -diff --git a/shmscope.h b/shmscope.h -new file mode 100644 -index 0000000..6d56f4c ---- /dev/null -+++ b/shmscope.h -@@ -0,0 +1,30 @@ -+#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) -+ -+extern unsigned char MITSHMRequest; -+extern unsigned char MITSHMError; -+extern unsigned char MITSHMEvent; -+ -+extern void MitshmQueryVersion (FD fd, const unsigned char *buf); -+extern void MitshmQueryVersionReply (FD fd, const unsigned char *buf); -+extern void MitshmAttach (FD fd, const unsigned char *buf); -+extern void MitshmDetach (FD fd, const unsigned char *buf); -+extern void MitshmPutImage (FD fd, const unsigned char *buf); -+extern void MitshmGetImage (FD fd, const unsigned char *buf); -+extern void MitshmGetImageReply (FD fd, const unsigned char *buf); -+extern void MitshmCreatePixmap (FD fd, const unsigned char *buf); -+extern void MitshmShmSegError (FD fd, const unsigned char *buf); -+ -+#endif -+ -diff --git a/table11.c b/table11.c -index eaac5af..56fe988 100644 ---- a/table11.c -+++ b/table11.c -@@ -66,21 +66,21 @@ static void InitSetTypes(void); - static void InitRecordTypes(void); - static void InitValuesTypes(void); - --static int PrintCHAR2B(unsigned char *buf); --static int PrintPOINT(unsigned char *buf); --static int PrintRECTANGLE(unsigned char *buf); --static int PrintARC(unsigned char *buf); --static int PrintHOST(unsigned char *buf); --static int PrintTIMECOORD(unsigned char *buf); --static int PrintFONTPROP(unsigned char *buf); --static int PrintCHARINFO(unsigned char *buf); --static int PrintSEGMENT(unsigned char *buf); --static int PrintCOLORITEM(unsigned char *buf); --static int PrintRGB(unsigned char *buf); --static int PrintFORMAT(unsigned char *buf); --static int PrintSCREEN(unsigned char *buf); --static int PrintDEPTH(unsigned char *buf); --static int PrintVISUALTYPE(unsigned char *buf); -+static int PrintCHAR2B(const unsigned char *buf); -+static int PrintPOINT(const unsigned char *buf); -+static int PrintRECTANGLE(const unsigned char *buf); -+static int PrintARC(const unsigned char *buf); -+static int PrintHOST(const unsigned char *buf); -+static int PrintTIMECOORD(const unsigned char *buf); -+static int PrintFONTPROP(const unsigned char *buf); -+static int PrintCHARINFO(const unsigned char *buf); -+static int PrintSEGMENT(const unsigned char *buf); -+static int PrintCOLORITEM(const unsigned char *buf); -+static int PrintRGB(const unsigned char *buf); -+static int PrintFORMAT(const unsigned char *buf); -+static int PrintSCREEN(const unsigned char *buf); -+static int PrintDEPTH(const unsigned char *buf); -+static int PrintVISUALTYPE(const unsigned char *buf); - - /* - To initialize for the X11 protocol, we need to create data structures -@@ -111,7 +111,7 @@ static int PrintVISUALTYPE(unsigned char *buf); - */ - - void --InitializeX11() -+InitializeX11 (void) - { - InitReplyQ(); - -@@ -122,6 +122,105 @@ InitializeX11() - InitRecordTypes(); - } - -+#define HASH_SIZE 997 -+ -+ValuePtr buckets[HASH_SIZE]; -+ -+#define HASH(key) ((key) % HASH_SIZE) -+ -+ValuePtr -+GetValueRec ( -+ unsigned long key) -+{ -+ ValuePtr *bucket, value; -+ -+ bucket = &buckets[HASH(key)]; -+ for (value = *bucket; value; value = value->next) -+ { -+ if (value->key == key) -+ return value; -+ } -+ return NULL; -+} -+ -+void -+CreateValueRec ( -+ unsigned long key, -+ int size, -+ const unsigned long *def) -+{ -+ ValuePtr *bucket, value; -+ int i; -+ -+ bucket = &buckets[HASH(key)]; -+ value = (ValuePtr) malloc (sizeof (ValueRec) + size * sizeof (unsigned long)); -+ if (!value) -+ return; -+ value->values = (unsigned long *) (value + 1); -+ for (i = 0; i < size; i++) -+ value->values[i] = ILong((const unsigned char *) (def + i)); -+ value->size = size; -+ value->key = key; -+ value->next = *bucket; -+ *bucket = value; -+} -+ -+void -+DeleteValueRec ( -+ 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; -+ } -+ } -+} -+ -+void -+SetValueRec ( -+ unsigned long key, -+ const unsigned char *control, -+ short clength, -+ short ctype, -+ const 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; -+ } -+ } -+} -+ - /* ************************************************************ */ - /* */ - /* */ -@@ -129,12 +228,12 @@ InitializeX11() - - /* define the various types */ - --static TYPE --DefineType(typeid, class, name, printproc) -- short typeid; -- short class; -- char *name; -- int (*printproc)(unsigned char *); -+TYPE -+DefineType ( -+ short typeid, -+ short class, -+ const char *name, -+ int (*printproc)(const unsigned char *)) - { - TD[typeid].Name = name; - TD[typeid].Type = class; -@@ -146,11 +245,11 @@ DefineType(typeid, class, name, printproc) - /* ************************************************************ */ - /* define an Enumerated Value (or a Set Value) */ - --static void --DefineEValue(type, value, name) -- TYPE type; -- long value; -- char *name; -+void -+DefineEValue( -+ TYPE type, -+ long value, -+ const char *name) - { - struct ValueListEntry *p; - -@@ -177,6 +276,25 @@ DefineEValue(type, value, name) - } - } - -+long -+GetEValue ( -+ short typeid, -+ const 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 */ -@@ -185,8 +303,9 @@ DefineEValue(type, value, name) - we have an associated value. We need to know the length and type of the - associated value for each bit */ - --static void --DefineValues(TYPE type, long value, short length, short ctype, char *name) -+void -+DefineValues(TYPE type, long value, short length, short ctype, -+ const char *name) - { - struct ValueListEntry *p; - -@@ -219,7 +338,7 @@ DefineValues(TYPE type, long value, short length, short ctype, char *name) - /* ************************************************************ */ - - static void --InitBuiltInTypes() -+InitBuiltInTypes (void) - { - (void) DefineType(INT8, BUILTIN, "INT8", PrintINT8); - (void) DefineType(INT16, BUILTIN, "INT16", PrintINT16); -@@ -264,7 +383,7 @@ InitBuiltInTypes() - /* ************************************************************ */ - - static void --InitEnumeratedTypes() -+InitEnumeratedTypes (void) - { - TYPE p; - -@@ -765,7 +884,7 @@ InitEnumeratedTypes() - /* ************************************************************ */ - - static void --InitSetTypes() -+InitSetTypes (void) - { - TYPE p; - -@@ -869,8 +988,8 @@ InitSetTypes() - /* Print Routines for builtin record types */ - - static int --PrintCHAR2B(buf) -- unsigned char *buf; -+PrintCHAR2B ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, CARD8, "byte1"); - PrintField(buf, 1, 1, CARD8, "byte2"); -@@ -878,8 +997,8 @@ PrintCHAR2B(buf) - } - - static int --PrintPOINT(buf) -- unsigned char *buf; -+PrintPOINT ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, INT16, "x"); - PrintField(buf, 2, 2, INT16, "y"); -@@ -887,8 +1006,8 @@ PrintPOINT(buf) - } - - static int --PrintRECTANGLE(buf) -- unsigned char *buf; -+PrintRECTANGLE ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, INT16, "x"); - PrintField(buf, 2, 2, INT16, "y"); -@@ -898,8 +1017,8 @@ PrintRECTANGLE(buf) - } - - static int --PrintARC(buf) -- unsigned char *buf; -+PrintARC ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, INT16, "x"); - PrintField(buf, 2, 2, INT16, "y"); -@@ -911,8 +1030,8 @@ PrintARC(buf) - } - - static int --PrintHOST(buf) -- unsigned char *buf; -+PrintHOST ( -+ const unsigned char *buf) - { - short n; - PrintField(buf, 0, 1, HOSTFAMILY, "family"); -@@ -951,8 +1070,8 @@ PrintHOST(buf) - } - - static int --PrintTIMECOORD(buf) -- unsigned char *buf; -+PrintTIMECOORD ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 4, TIMESTAMP, "time"); - PrintField(buf, 4, 2, CARD16, "x"); -@@ -961,8 +1080,8 @@ PrintTIMECOORD(buf) - } - - static int --PrintFONTPROP(buf) -- unsigned char *buf; -+PrintFONTPROP ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 4, ATOM, "name"); - PrintField(buf, 4, 4, INT32, "value"); -@@ -970,8 +1089,8 @@ PrintFONTPROP(buf) - } - - static int --PrintCHARINFO(buf) -- unsigned char *buf; -+PrintCHARINFO ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, INT16, "left-side-bearing"); - PrintField(buf, 2, 2, INT16, "right-side-bearing"); -@@ -983,8 +1102,8 @@ PrintCHARINFO(buf) - } - - static int --PrintSEGMENT(buf) -- unsigned char *buf; -+PrintSEGMENT ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, INT16, "x1"); - PrintField(buf, 2, 2, INT16, "y1"); -@@ -994,8 +1113,8 @@ PrintSEGMENT(buf) - } - - static int --PrintCOLORITEM(buf) -- unsigned char *buf; -+PrintCOLORITEM ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 4, CARD32, "pixel"); - PrintField(buf, 4, 2, CARD16, "red"); -@@ -1006,8 +1125,8 @@ PrintCOLORITEM(buf) - } - - static int --PrintRGB(buf) -- unsigned char *buf; -+PrintRGB ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 2, CARD16, "red"); - PrintField(buf, 2, 2, CARD16, "green"); -@@ -1016,8 +1135,8 @@ PrintRGB(buf) - } - - static int --PrintFORMAT(buf) -- unsigned char *buf; -+PrintFORMAT ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 1, CARD8, "depth"); - PrintField(buf, 1, 1, CARD8, "bits-per-pixel"); -@@ -1026,8 +1145,8 @@ PrintFORMAT(buf) - } - - static int --PrintSCREEN(buf) -- unsigned char *buf; -+PrintSCREEN ( -+ const unsigned char *buf) - { - short n /* number of elements in List of DEPTH */ ; - long m /* length (in bytes) of List of DEPTH */ ; -@@ -1054,8 +1173,8 @@ PrintSCREEN(buf) - } - - static int --PrintDEPTH(buf) -- unsigned char *buf; -+PrintDEPTH ( -+ const unsigned char *buf) - { - short n /* number of elements in List of VISUALTYPE */ ; - short m /* length (in bytes) of List of VISUALTYPE */ ; -@@ -1068,8 +1187,8 @@ PrintDEPTH(buf) - } - - static int --PrintVISUALTYPE(buf) -- unsigned char *buf; -+PrintVISUALTYPE ( -+ const unsigned char *buf) - { - PrintField(buf, 0, 4, VISUALID, "visual-id"); - PrintField(buf, 4, 1, COLORCLASS, "class"); -@@ -1084,7 +1203,7 @@ PrintVISUALTYPE(buf) - /* ************************************************************ */ - - static void --InitRecordTypes() -+InitRecordTypes (void) - { - (void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B); - (void) DefineType(POINT, RECORD, "POINT", PrintPOINT); -@@ -1111,7 +1230,7 @@ InitRecordTypes() - /* ************************************************************ */ - - static void --InitValuesTypes() -+InitValuesTypes (void) - { - TYPE p; - -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..6556f6f ---- /dev/null -+++ b/wcpscope.h -@@ -0,0 +1,54 @@ -+/* -+ * $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 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) -+ -+extern unsigned char WCPRequest; -+extern unsigned char WCPError; -+ -+extern void WcpQueryVersion (FD fd, const unsigned char *buf); -+extern void WcpQueryVersionReply (FD fd, const unsigned char *buf); -+extern void WcpPutImage (FD fd, const unsigned char *buf); -+extern void WcpGetImage (FD fd, const unsigned char *buf); -+extern void WcpGetImageReply (FD fd, const unsigned char *buf); -+extern void WcpCreateColorCursor (FD fd, const unsigned char *buf); -+extern void WcpCreateLut (FD fd, const unsigned char *buf); -+extern void WcpFreeLut (FD fd, const unsigned char *buf); -+extern void WcpCopyArea (FD fd, const unsigned char *buf); -+ -+#endif -+ -diff --git a/x11.h b/x11.h -index 175250b..db5abe7 100644 ---- a/x11.h -+++ b/x11.h -@@ -216,8 +216,51 @@ - #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 WCPREQUEST 129 -+#define WCPREPLY 130 -+#define WCPERROR 131 -+ -+#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 PICTFORMINFO 141 -+#define TRAPEZOID 142 -+#define TRIANGLE 143 -+#define POINTFIXED 144 -+#define FIXED 145 -+ -+#define RANDRREQUEST 150 -+#define RANDRREPLY 151 -+#define RANDRERROR 152 -+ -+#define MITSHMREQUEST 153 -+#define MITSHMREPLY 154 -+#define MITSHMEVENT 155 -+#define MITSHMERROR 156 -+ -+#define BIGREQREQUEST 157 -+#define BIGREQREPLY 158 -+ -+#define MaxTypes 256 -+ -+extern char ScopeEnabled; - - /* ************************************************************ */ - /* */ -@@ -247,17 +290,17 @@ - struct ValueListEntry - { - struct ValueListEntry *Next; -- char *Name; -+ const char *Name; - short Type; - short Length; - long Value; - }; - --typedef int (*PrintProcType) (unsigned char *); -+typedef int (*PrintProcType) (const unsigned char *); - - struct TypeDef - { -- char *Name; -+ const char *Name; - short Type /* BUILTIN, ENUMERATED, SET, or RECORD */ ; - struct ValueListEntry *ValueList; - PrintProcType PrintProc; -@@ -265,7 +308,7 @@ struct TypeDef - - typedef struct TypeDef *TYPE; - --struct TypeDef TD[MaxTypes]; -+extern struct TypeDef TD[MaxTypes]; - - /* ************************************************************ */ - /* */ -@@ -274,45 +317,45 @@ struct TypeDef TD[MaxTypes]; - - /* declaration of the existance of print routines for the basic types */ - --int PrintINT8(unsigned char *buf); --int PrintINT16(unsigned char *buf); --int PrintINT32(unsigned char *buf); --int PrintCARD8(unsigned char *buf); --int PrintCARD16(unsigned char *buf); --int PrintCARD32(unsigned char *buf); --int PrintBYTE(unsigned char *buf); --int PrintCHAR8(unsigned char *buf); --int PrintSTRING16(unsigned char *buf); --int PrintTEXTITEM8(unsigned char *buf); --int PrintTEXTITEM16(unsigned char *buf); --int PrintSTR(unsigned char *buf); --int PrintWINDOW(unsigned char *buf); --int PrintWINDOWD(unsigned char *buf); --int PrintWINDOWNR(unsigned char *buf); --int PrintPIXMAP(unsigned char *buf); --int PrintPIXMAPNPR(unsigned char *buf); --int PrintPIXMAPC(unsigned char *buf); --int PrintCURSOR(unsigned char *buf); --int PrintFONT(unsigned char *buf); --int PrintGCONTEXT(unsigned char *buf); --int PrintCOLORMAP(unsigned char *buf); --int PrintCOLORMAPC(unsigned char *buf); --int PrintDRAWABLE(unsigned char *buf); --int PrintFONTABLE(unsigned char *buf); --int PrintATOM(unsigned char *buf); --int PrintATOMT(unsigned char *buf); --int PrintVISUALID(unsigned char *buf); --int PrintVISUALIDC(unsigned char *buf); --int PrintTIMESTAMP(unsigned char *buf); --int PrintRESOURCEID(unsigned char *buf); --int PrintKEYSYM(unsigned char *buf); --int PrintKEYCODE(unsigned char *buf); --int PrintKEYCODEA(unsigned char *buf); --int PrintBUTTON(unsigned char *buf); --int PrintBUTTONA(unsigned char *buf); --int PrintEVENTFORM(unsigned char *buf); --int PrintENUMERATED(unsigned char *buf, short length, struct ValueListEntry *ValueList); --int PrintSET(unsigned char *buf, short length, struct ValueListEntry *ValueList); -+extern int PrintINT8(const unsigned char *buf); -+extern int PrintINT16(const unsigned char *buf); -+extern int PrintINT32(const unsigned char *buf); -+extern int PrintCARD8(const unsigned char *buf); -+extern int PrintCARD16(const unsigned char *buf); -+extern int PrintCARD32(const unsigned char *buf); -+extern int PrintBYTE(const unsigned char *buf); -+extern int PrintCHAR8(const unsigned char *buf); -+extern int PrintSTRING16(const unsigned char *buf); -+extern int PrintTEXTITEM8(const unsigned char *buf); -+extern int PrintTEXTITEM16(const unsigned char *buf); -+extern int PrintSTR(const unsigned char *buf); -+extern int PrintWINDOW(const unsigned char *buf); -+extern int PrintWINDOWD(const unsigned char *buf); -+extern int PrintWINDOWNR(const unsigned char *buf); -+extern int PrintPIXMAP(const unsigned char *buf); -+extern int PrintPIXMAPNPR(const unsigned char *buf); -+extern int PrintPIXMAPC(const unsigned char *buf); -+extern int PrintCURSOR(const unsigned char *buf); -+extern int PrintFONT(const unsigned char *buf); -+extern int PrintGCONTEXT(const unsigned char *buf); -+extern int PrintCOLORMAP(const unsigned char *buf); -+extern int PrintCOLORMAPC(const unsigned char *buf); -+extern int PrintDRAWABLE(const unsigned char *buf); -+extern int PrintFONTABLE(const unsigned char *buf); -+extern int PrintATOM(const unsigned char *buf); -+extern int PrintATOMT(const unsigned char *buf); -+extern int PrintVISUALID(const unsigned char *buf); -+extern int PrintVISUALIDC(const unsigned char *buf); -+extern int PrintTIMESTAMP(const unsigned char *buf); -+extern int PrintRESOURCEID(const unsigned char *buf); -+extern int PrintKEYSYM(const unsigned char *buf); -+extern int PrintKEYCODE(const unsigned char *buf); -+extern int PrintKEYCODEA(const unsigned char *buf); -+extern int PrintBUTTON(const unsigned char *buf); -+extern int PrintBUTTONA(const unsigned char *buf); -+extern int PrintEVENTFORM(const unsigned char *buf); -+extern int PrintENUMERATED(const unsigned char *buf, short length, struct ValueListEntry *ValueList); -+extern int PrintSET(const unsigned char *buf, short length, struct ValueListEntry *ValueList); - - /* ************************************************************ */ - /* */ -@@ -322,13 +365,13 @@ int PrintSET(unsigned char *buf, short length, struct ValueListEntry *ValueList) - /* 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 - the Request procedure */ --unsigned char SBf[4]; -+extern unsigned char SBf[4]; - - - #define PRINTSERVER 5 /* indent output as if it comes from server */ -@@ -449,35 +492,101 @@ unsigned char SBf[4]; - struct ConnState - { - unsigned char *SavedBytes; -- int littleEndian; -+ int littleEndian; -+ int bigreqEnabled; -+ long requestLen; - long SizeofSavedBytes; - long NumberofSavedBytes; - - long NumberofBytesNeeded; -- long (*ByteProcessing)(); -+ long NumberofBytesProcessed; -+ long (*ByteProcessing)(FD fd, const unsigned char *buf, long n); - - 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 (unsigned long key); -+extern void CreateValueRec (unsigned long key, int size, -+ const unsigned long *def); -+extern void DeleteValueRec (unsigned long key); -+extern void SetValueRec (unsigned long key, const unsigned char *control, -+ short clength, short ctype, -+ const unsigned char *values); -+extern void PrintValueRec (unsigned long key, unsigned long cmask, -+ short ctype); - - /* ************************************************************ */ - /* */ - /* */ - /* ************************************************************ */ - --/* declaraction of the types of some common functions */ -- --extern unsigned long ILong(); --extern unsigned short IShort(); --extern unsigned short IByte(); --extern Boolean IBool(); -- --extern long PrintList(); --extern long PrintListSTR(); --extern long pad(); -+/* declaration of the types of some common functions */ -+ -+extern unsigned long ILong(const unsigned char *buf); -+extern unsigned short IShort(const unsigned char *buf); -+extern unsigned short IChar2B(const unsigned char *buf); -+extern unsigned short IByte(const unsigned char *buf); -+extern Boolean IBool(const unsigned char *buf); -+ -+extern int PrintString8(const unsigned char *buf, int number, -+ const char *name); -+extern int PrintString16(const unsigned char *buf, int number, -+ const char *name); -+extern void PrintTString8(const unsigned char *buf, long number, -+ const char *name); -+extern void PrintTString16(const unsigned char *buf, long number, -+ const char *name); -+ -+extern long PrintList (const unsigned char *buf, long number, short ListType, -+ const char *name); -+extern long PrintListSTR (const unsigned char *buf, long number, -+ const char *name); -+ -+extern long pad(long n); -+ -+extern const 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 -+ -+#define printreqlen(buf, fd, dvalue) \ -+ do { \ -+ if (IShort(&(buf)[2]) == 0 && CS[(fd)].bigreqEnabled) { \ -+ printfield (buf, 4, 4, CARD32, "request length"); \ -+ buf += 4; \ -+ } else { \ -+ printfield (buf, 2, 2, CARD16, "request length"); \ -+ } \ -+ } while (0) - - #endif /* XSCOPE_X11_H */ -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); -+} diff --git a/xscope-1.1-lessmacros.patch b/xscope-1.1-lessmacros.patch deleted file mode 100644 index fa9205c..0000000 --- a/xscope-1.1-lessmacros.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -ur xscope-1.1/configure.ac xscope-1.1.lessmacros/configure.ac ---- xscope-1.1/configure.ac 2009-06-27 08:16:40.000000000 +0300 -+++ xscope-1.1.lessmacros/configure.ac 2009-06-27 08:17:33.000000000 +0300 -@@ -39,7 +39,7 @@ - - # Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG, XORG_WITH_LINT - m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])]) --XORG_MACROS_VERSION(1.2) -+XORG_MACROS_VERSION(1.1) - - AC_PROG_CC - XORG_CWARNFLAGS diff --git a/xscope.spec b/xscope.spec index 11ecd2f..aff4db0 100644 --- a/xscope.spec +++ b/xscope.spec @@ -1,21 +1,16 @@ Name: xscope -Version: 1.1 -Release: 4.gitfccbbd6%{?dist} +Version: 1.4.5 +Release: 4%{?dist} Summary: X Window Protocol Viewer -Group: User Interface/X -License: MIT -URL: http://cgit.freedesktop.org/xorg/app/xscope/ -Source0: ftp://ftp.freedesktop.org/pub/xorg/individual/app/%{name}-%{version}.tar.bz2 -# git diff --diff-filter=ACMRT xscope-1.1 fccbbd6 -Patch0: xscope-1.1-diff_to_git.patch -# to build on Fedora 10 reduce the xorg-macros required version -Patch1: xscope-1.1-lessmacros.patch -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +License: MIT AND HPND-sell-variant +URL: https://gitlab.freedesktop.org/xorg/app/xscope +Source0: https://www.x.org/releases/individual/app/%{name}-%{version}.tar.xz +BuildRequires: make +BuildRequires: gcc BuildRequires: xorg-x11-xtrans-devel, xorg-x11-proto-devel -# required for the autoreconf -BuildRequires: automake, autoconf, xorg-x11-util-macros + %description xscope sits in-between an X11 client and an X11 server and prints the contents @@ -26,10 +21,7 @@ servers and clients. %prep %setup -q -%patch0 -p1 -b .diff_to_git -%patch1 -p1 -b .lessmacros -# required for changes in patch0 and patch1 -autoreconf -f + %build %configure @@ -37,22 +29,153 @@ make %{?_smp_mflags} %install -rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT -%clean -rm -rf $RPM_BUILD_ROOT - - %files -%defattr(-,root,root,-) -%doc AUTHORS README COPYING ChangeLog +%doc AUTHORS NEWS ChangeLog README.md +%license COPYING %{_bindir}/%{name} %{_mandir}/man1/%{name}.1.gz %changelog +* Fri Jul 17 2026 Fedora Release Engineering - 1.4.5-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild + +* Sat Jan 17 2026 Fedora Release Engineering - 1.4.5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild + +* Fri Jul 25 2025 Fedora Release Engineering - 1.4.5-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Sun Mar 9 2025 Yanko Kaneti 1.4.5-1 +- Update to 1.4.5 + +* Sun Jan 19 2025 Fedora Release Engineering - 1.4.4-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Sat Jul 20 2024 Fedora Release Engineering - 1.4.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Sat Jan 27 2024 Fedora Release Engineering - 1.4.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sat Jul 22 2023 Fedora Release Engineering - 1.4.4-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Fri Jul 7 2023 Yanko Kaneti 1.4.4-2 +- SPDX migration + +* Sat Jun 3 2023 Yanko Kaneti 1.4.4-1 +- Update to 1.4.4 + +* Sat Jan 21 2023 Fedora Release Engineering - 1.4.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Sat Jul 23 2022 Fedora Release Engineering - 1.4.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Mon Jul 11 2022 Yanko Kaneti 1.4.3-1 +- Update to 1.4.3 + +* Sat Jan 22 2022 Fedora Release Engineering - 1.4.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Tue Dec 7 2021 Yanko Kaneti 1.4.2-1 +- Update to 1.4.2 + +* Fri Jul 23 2021 Fedora Release Engineering - 1.4.1-16 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Thu Jan 28 2021 Fedora Release Engineering - 1.4.1-15 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Wed Jul 29 2020 Fedora Release Engineering - 1.4.1-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Fri Jan 31 2020 Fedora Release Engineering - 1.4.1-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Sat Jul 27 2019 Fedora Release Engineering - 1.4.1-12 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Thu Mar 21 2019 Adam Jackson - 1.4.1-11 +- Rebuild for xtrans 1.4.0 + +* Sun Feb 03 2019 Fedora Release Engineering - 1.4.1-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Sat Jul 14 2018 Fedora Release Engineering - 1.4.1-9 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Fri Feb 09 2018 Fedora Release Engineering - 1.4.1-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Aug 03 2017 Fedora Release Engineering - 1.4.1-7 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Thu Jul 27 2017 Fedora Release Engineering - 1.4.1-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Sat Feb 11 2017 Fedora Release Engineering - 1.4.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Fri Feb 05 2016 Fedora Release Engineering - 1.4.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Tue Jan 26 2016 Yanko Kaneti +- Remove defattr. Use license. + +* Fri Jun 19 2015 Fedora Release Engineering - 1.4.1-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Mon Aug 18 2014 Fedora Release Engineering - 1.4.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sun Jun 8 2014 Yanko Kaneti 1.4.1-1 +- Update to 1.4.1. Autoreconf no longer required + +* Sun Jun 08 2014 Fedora Release Engineering - 1.4-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Sun Aug 04 2013 Fedora Release Engineering - 1.4-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Mon Mar 25 2013 Yanko Kaneti 1.4-3 +- autoreconf for now for aarch64 + +* Fri Feb 15 2013 Fedora Release Engineering - 1.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Tue Nov 20 2012 Yanko Kaneti 1.4-1 +- Latest upstream release - 1.4 + +* Sat Oct 13 2012 Yanko Kaneti 1.3.99.901-1 +- Upstream pre-release for 1.4 + +* Sun Jul 22 2012 Fedora Release Engineering - 1.3.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Wed Feb 22 2012 Yanko Kaneti 1.3.1-1 +- Upstream release 1.3.1 + +* Sat Jan 14 2012 Fedora Release Engineering - 1.3-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Tue Feb 08 2011 Fedora Release Engineering - 1.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Sun Oct 31 2010 Yanko Kaneti 1.3-1 +- New upstream release. Drop patches. + Remove explicit buildroot, clean. + +* Sat Jul 24 2010 Yanko Kaneti 1.2-2 +- Include an upstream patch for basic GLX support + +* Thu Oct 1 2009 Yanko Kaneti 1.2-1 +- New upstream release. Drop patches. + * Mon Jul 27 2009 Fedora Release Engineering - 1.1-4.gitfccbbd6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild