diff options
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | Makefile.am | 28 | ||||
-rw-r--r-- | README | 91 | ||||
-rw-r--r-- | audio.c | 482 | ||||
-rw-r--r-- | bigreqscope.h | 17 | ||||
-rw-r--r-- | common.c | 84 | ||||
-rw-r--r-- | decode11.c | 597 | ||||
-rw-r--r-- | decode_bigreq.c | 80 | ||||
-rw-r--r-- | decode_lbx.c | 149 | ||||
-rw-r--r-- | decode_pex.c | 786 | ||||
-rw-r--r-- | decode_randr.c | 98 | ||||
-rw-r--r-- | decode_render.c | 318 | ||||
-rw-r--r-- | decode_shm.c | 116 | ||||
-rw-r--r-- | decode_wcp.c | 130 | ||||
-rw-r--r-- | decodenas.c | 465 | ||||
-rw-r--r-- | fd.c | 275 | ||||
-rw-r--r-- | fd.h | 24 | ||||
-rw-r--r-- | imakefile | 5 | ||||
-rw-r--r-- | lbxscope.h | 43 | ||||
-rw-r--r-- | nas.h | 123 | ||||
-rw-r--r-- | patchlevel.h | 2 | ||||
-rw-r--r-- | pexOCNames.h | 134 | ||||
-rw-r--r-- | pexOCTab.awk | 86 | ||||
-rw-r--r-- | pexRNames.h | 134 | ||||
-rw-r--r-- | pexRTab.awk | 81 | ||||
-rw-r--r-- | pexscope.h | 62 | ||||
-rw-r--r-- | print11.c | 530 | ||||
-rw-r--r-- | print_bigreq.c | 53 | ||||
-rw-r--r-- | print_lbx.c | 197 | ||||
-rw-r--r-- | print_pex.c | 917 | ||||
-rw-r--r-- | print_randr.c | 171 | ||||
-rw-r--r-- | print_render.c | 589 | ||||
-rw-r--r-- | print_shm.c | 171 | ||||
-rw-r--r-- | print_wcp.c | 465 | ||||
-rw-r--r-- | printnas.c | 950 | ||||
-rw-r--r-- | proto.h | 7 | ||||
-rw-r--r-- | prtype.c | 242 | ||||
-rw-r--r-- | randrscope.h | 16 | ||||
-rw-r--r-- | renderscope.h | 16 | ||||
-rw-r--r-- | scope.c | 978 | ||||
-rw-r--r-- | scope.h | 42 | ||||
-rw-r--r-- | server.c | 200 | ||||
-rw-r--r-- | shmscope.h | 16 | ||||
-rw-r--r-- | table11.c | 121 | ||||
-rw-r--r-- | tablenas.c | 29 | ||||
-rw-r--r-- | wcpscope.h | 41 | ||||
-rw-r--r-- | x11.h | 179 | ||||
-rw-r--r-- | xstats.c | 114 |
48 files changed, 9683 insertions, 772 deletions
@@ -1 +1,2 @@ James Peterson, MCC +Keith Packard diff --git a/Makefile.am b/Makefile.am index 89928cf..8ccda83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,24 +34,46 @@ AM_CFLAGS = $(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 \ fd.c \ fd.h \ + lbxscope.h \ + nas.h \ + patchlevel.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@) @@ -0,0 +1,91 @@ + + XSCOPE -- a program to monitor X11/Client conversations + +XSCOPE is a program to monitor the connections between the X11 window +server and a client program. xscope runs as a separate process. By +adjusting the host and/or display number that a X11 client attaches +to, the client is attached to xscope instead of X11. xscope attaches +to X11 as if it were the client. All bytes from the client are sent +to xscope which passes them on to X11; All bytes from X11 are sent to +xscope which sends them on to the client. xscope is transparent to +the client and X11. + +In addition to passing characters back and forth, xscope will print +information about this traffic on stdout, giving performance and +debugging information for an X11 client and server. + + + -------------- -------------- -------------- + | | | | | | + | | ------------> | | ----------> | | + | client | | xscope | | server | + | | | | | | + | | <----------- | | <---------- | | + | | | | | | + -------------- -------------- -------------- + | + | + v + trace output to stdout + + +When running with xscope, three processes are involved, potentially all +on different machines: + +X11 -- the X11 window server will be running on machine "A" for Display "B". + ("A" is a machine name; "B" is a display number). + +xscope -- xscope must be told where the X11 window server is + (what machine and what display). The options for xscope are + -h<X11-host> and -d<display-number>. In our example, -hA and -dB. + Typically the display-number is not given. xscope will not try to + connect to X11 until the client connects to xscope. + +client -- the client should connect to xscope rather than X11. To avoid + changing the code for the client, xscope listens on the same port + as X11. If X11 and xscope are on different machines, this works + well. However, if X11 and xscope are on the same machine, this + creates a port conflict. To resolve this conflict, xscope can + be given a different input or output port number, as necessary + to avoid the port that X11 is listening to. The client must connect + to this offset port number. The input port for xscope is set by + -i<port-number>; the output port is set by -o<port-number>. The + default input port is 1; the default output port is 0. These ports + are offset by the X11 base (6000) and the display number. The client + attaches to xscope by changing its display number by the port offset. + +For example, with X11 running on "bagel", display 0 (the default), and +xscope and the client running on "cleo", we would start xscope as +"xscope -hbagel -i0". The client program could then connect to "X11" on +"cleo:0", and would be attached to xscope, which would then attach to +X11 on "bagel:0". + +If, however, all three processes were running on "cleo", we would +start xscope by "xscope -i1". This would cause it to listen on +port 6001 (which is display 1 for X11). The client would attach to +X11 on "cleo:1", and xscope would connect through to X11 on "cleo:0". + + +LIMITATIONS: + +xscope has been written and used on a Sun3. Additional code may be needed +for byteswapping on different architectures. + +The command line arguments for specifying the real X server should probably + be changed to be more consistent with X11R3 applications. + +The Imakefile may be incorrect. + +The builtin atoms have been wired in directly; they should probably be +picked up from a header file. + +No provision is included for extensions to the base protocol. + +There is no code yet to interpret typed commands from the keyboard. + It would be possible for a command language at the keyboard to create + artificial characters to be sent to X11 or the client as if they were + generated by the other, or to dynamically alter requests or replies. + + + + @@ -0,0 +1,482 @@ +/* + * $NCDOr: audio.c,v 1.1 1996/07/18 23:25:52 keithp Exp keithp $ + * + * Copyright 1996 Network Computing Devices + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of NCD. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. NCD. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, Network Computing Devices + */ + +#include "scope.h" +#include "nas.h" + +#include <sys/uio.h> /* for struct iovec, used by socket.h */ +#include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ +#include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ +#ifdef SVR4 +#include <sys/filio.h> +#endif +#include <fcntl.h> +#include <netinet/in.h> /* struct sockaddr_in */ +#include <netinet/tcp.h> +#include <netdb.h> /* struct servent * and struct hostent * */ +#include <errno.h> /* for EINTR, EADDRINUSE, ... */ +extern int errno; + +extern char ScopeEnabled; + +ReportFromAudioClient (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + if (NasVerbose) { + if (ScopeEnabled) { + PrintTime (); + fprintf(stdout, "NAS Client%s --> %4d %s\n", + ClientName(fd), n, (n == 1 ? "byte" : "bytes")); + } + } + ProcessBuffer (fd, buf, n); +} + +ReportFromAudioServer(fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + if (NasVerbose) { + if (ScopeEnabled) { + PrintTime(); + fprintf(stdout, "\t\t\t\t\t%4d %s <-- NAS Server%s\n", + n, (n == 1 ? "byte" : "bytes"), ClientName(fd)); + } + } + ProcessBuffer(fd, buf, n); +} + +extern long StartAudioSetUpMessage (); +extern long FinishAudioSetUpMessage (); +extern long StartAudioRequest (); +extern long FinishAudioRequest (); +extern long StartAudioSetUpReply (); +extern long FinishAudioSetUpReply (); +extern long AudioServerPacket (); +extern long FinishAudioReply (); +extern long FlushFD (); + +StartAudioClientConnection(fd) + FD fd; +{ + enterprocedure("StartAudioClientConnection"); + /* when a new connection is started, we have no saved bytes */ + CS[fd].SavedBytes = NULL; + CS[fd].SizeofSavedBytes = 0; + CS[fd].NumberofSavedBytes = 0; + CS[fd].NumberofBytesProcessed = 0; + + /* when a new connection is started, we have no reply Queue */ + FlushReplyQ(fd); + + /* each new connection gets a request sequence number */ + CS[fd].SequenceNumber = 0; + + /* we need 12 bytes to start a SetUp message */ + CS[fd].ByteProcessing = StartAudioSetUpMessage; + CS[fd].NumberofBytesNeeded = 12; +} + +StopAudioClientConnection(fd) + FD fd; +{ + enterprocedure("StopAudioClientConnection"); + /* when a new connection is stopped, discard the old buffer */ + + if (CS[fd].SizeofSavedBytes > 0) + Free((char*)CS[fd].SavedBytes); +} + +long StartAudioSetUpMessage (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short namelength; + short datalength; + extern int littleEndian; + + enterprocedure("StartSetUpMessage"); + /* + we need the first 12 bytes to be able to determine if, and how many, + additional bytes we need for name and data authorization. However, we + can't process the first 12 bytes until we get all of them, so + return zero bytes used, and increase the number of bytes needed + */ + + CS[fd].littleEndian = (buf[0] == 'l'); + CS[ServerHalf(fd)].littleEndian = CS[fd].littleEndian; + littleEndian = CS[fd].littleEndian; + namelength = IShort(&buf[6]); + datalength = IShort(&buf[8]); + CS[fd].ByteProcessing = FinishAudioSetUpMessage; + CS[fd].NumberofBytesNeeded = n + + pad((long)namelength) + pad((long)datalength); + debug(8,(stderr, "need %d bytes to finish startup\n", + CS[fd].NumberofBytesNeeded - n)); + return(0); +} + +long FinishAudioSetUpMessage (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + enterprocedure("FinishSetUpMessage"); + if (ScopeEnabled) + PrintAudioSetUpMessage(buf); + + /* after a set-up message, we expect a string of requests */ + CS[fd].ByteProcessing = StartAudioRequest; + CS[fd].NumberofBytesNeeded = 4; + return(n); +} + + +long StartAudioRequest (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + unsigned short requestlength; + enterprocedure("StartRequest"); + + /* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */ + requestlength = IShort(&buf[2]); + CS[fd].ByteProcessing = FinishAudioRequest; + CS[fd].NumberofBytesNeeded = 4 * requestlength; + debug(8,(stderr, "need %d more bytes to finish request\n", + CS[fd].NumberofBytesNeeded - n)); + return(0); +} + + +long FinishAudioRequest (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + enterprocedure("FinishRequest"); + CS[fd].ByteProcessing = StartAudioRequest; + CS[fd].NumberofBytesNeeded = 4; + if (ScopeEnabled) + DecodeAudioRequest(fd, buf, n); + return(n); +} + +StartAudioServerConnection(fd) + FD fd; +{ + enterprocedure("StartAudioServerConnection"); + /* when a new connection is started, we have no saved bytes */ + CS[fd].SavedBytes = NULL; + CS[fd].SizeofSavedBytes = 0; + CS[fd].NumberofSavedBytes = 0; + CS[fd].NumberofBytesProcessed = 0; + + /* when a new connection is started, we have no reply Queue */ + FlushReplyQ(fd); + + /* we need 8 bytes to start a SetUp reply */ + CS[fd].ByteProcessing = StartAudioSetUpReply; + CS[fd].NumberofBytesNeeded = 8; +} + +StopAudioServerConnection(fd) + FD fd; +{ + enterprocedure("StopAudioServerConnection"); + /* when a new connection is stopped, discard the old buffer */ + + if (CS[fd].SizeofSavedBytes > 0) + Free((char *)CS[fd].SavedBytes); +} + +long StartAudioSetUpReply (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short replylength; + + enterprocedure("StartSetUpReply"); + replylength = IShort(&buf[6]); + CS[fd].ByteProcessing = FinishAudioSetUpReply; + CS[fd].NumberofBytesNeeded = n + 4 * replylength; + debug(8,(stderr, "need %d bytes to finish startup reply\n", + CS[fd].NumberofBytesNeeded - n)); + return(0); +} + +long FinishAudioSetUpReply (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + enterprocedure("FinishSetUpReply"); + if (ScopeEnabled) + PrintAudioSetUpReply(buf); + CS[fd].ByteProcessing = AudioServerPacket; + CS[fd].NumberofBytesNeeded = 32; + return(n); +} + +/* ************************************************************ */ + +long AudioErrorPacket (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + CS[fd].ByteProcessing = AudioServerPacket; + CS[fd].NumberofBytesNeeded = 32; + DecodeAudioError(fd, buf, n); + return(n); +} + + +long AudioEventPacket (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + CS[fd].ByteProcessing = AudioServerPacket; + CS[fd].NumberofBytesNeeded = 32; + if (ScopeEnabled) + DecodeAudioEvent(fd, buf, n); + return(n); +} + + +long AudioReplyPacket (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + long replylength; + + replylength = ILong(&buf[4]); + + /* + Replies may need more bytes, so we compute how many more + bytes are needed and ask for them, not using any of the bytes + we were given (return(0) to say that no bytes were used). + If the replylength is zero (we don't need any more bytes), the + number of bytes needed will be the same as what we have, and + so the top-level loop will call the next routine immediately + with the same buffer of bytes that we were given. + */ + + CS[fd].ByteProcessing = FinishAudioReply; + CS[fd].NumberofBytesNeeded = n + 4 * replylength; + debug(8,(stderr, "need %d bytes to finish reply\n", (4 * replylength))); + return(0); +} + +long FinishAudioReply (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + CS[fd].ByteProcessing = AudioServerPacket; + CS[fd].NumberofBytesNeeded = 32; + enterprocedure("FinishAudioReply"); + if (ScopeEnabled) + DecodeAudioReply(fd, buf, n); + return(n); +} + +long AudioServerPacket (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short PacketType; + enterprocedure("ServerPacket"); + + PacketType = IByte(&buf[0]); + if (PacketType == 0) + return(AudioErrorPacket(fd, buf, n)); + if (PacketType == 1) + return(AudioReplyPacket(fd, buf, n)); + return(AudioEventPacket(fd, buf, n)); +} + +CloseAudioConnection(fd) + FD fd; +{ + debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd))); + StopAudioClientConnection(ServerHalf(fd)); + StopAudioServerConnection(ClientHalf(fd)); + + (void)close(fd); + NotUsingFD(fd); + (void)close(FDPair(fd)); + NotUsingFD(FDPair(fd)); +} + +/* when we get data from a client, we read it in, copy it to the + server for this client, then dump it to the client. Note, we don't + have to have a server, if there isn't one. */ + +DataFromAudioClient(fd) + FD fd; +{ + long n; + FD ServerFD; + + Verbose = NasVerbose; + enterprocedure("DataFromAudioClient"); + ServerFD = FDPair(fd); + if (ServerFD < 0) + { + ServerFD = ConnectToServer(false); + if (ServerFD < 0) + { + CloseAudioConnection(fd); + return; + } + SetUpPair(fd, ServerFD); + } + + n = read(fd, FDinfo[ServerFD].buffer, BUFFER_SIZE); + debug(4,(stderr, "read %d bytes from Client%s\n", n, ClientName(fd))); + if (n < 0) + { + PrintTime(); + perror("Client --> read error:"); + CloseAudioConnection(fd); + return; + } + if (n == 0) + { + PrintTime(); + if (NasVerbose >= 0) + fprintf(stdout, "Client%s --> EOF\n", ClientName(fd)); + CloseAudioConnection(fd); + return; + } + + FDinfo[ServerFD].bufcount = n; + FDinfo[ServerFD].bufstart = 0; + + FlushFD (ServerFD); + /* also report the bytes to standard out */ + ReportFromAudioClient(fd, FDinfo[ServerFD].buffer, n); +} + +/* ********************************************** */ +/* */ +/* ********************************************** */ + +/* similar situation for the server, but note that if there is no client, + we close the connection down -- don't need a server with no client. */ + +DataFromAudioServer(fd) + FD fd; +{ + long n; + FD ClientFD; + + Verbose = NasVerbose; + ClientFD = FDPair(fd); + if (ClientFD < 0) + { + CloseAudioConnection(fd); + return; + } + + enterprocedure("DataFromAudioServer"); + n = read(fd, (char *)FDinfo[ClientFD].buffer, BUFFER_SIZE); + debug(4,(stderr, "read %d bytes from Server%s\n", n, ClientName(fd))); + if (n < 0) + { + PrintTime(); + perror("read error <- Server"); + CloseAudioConnection(fd); + return; + } + if (n == 0) + { + PrintTime(); + if (NasVerbose >= 0) + fprintf(stdout, "EOF <-- Server%s\n", ClientName(fd)); + CloseAudioConnection(fd); + return; + } + + FDinfo[ClientFD].bufcount = n; + FDinfo[ClientFD].bufstart = 0; + FlushFD (ClientFD); + + /* also report the bytes to standard out */ + ReportFromAudioServer(fd, FDinfo[ClientFD].buffer, n); +} + +FD ConnectToAudioClient(ConnectionSocket) + FD ConnectionSocket; +{ + FD ClientFD; + ClientFD = AcceptConnection(ConnectionSocket); + UsingFD(ClientFD, DataFromAudioClient, FlushFD, NULL); + StartAudioClientConnection(ClientFD); + return(ClientFD); +} + +FD ConnectToAudioServer(report) + 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); +} + +NewAudio (fd) + FD fd; +{ + FD ServerFD = -1; + FD ClientFD = -1; + + ClientFD = ConnectToAudioClient(fd); + ServerFD = ConnectToAudioServer(true); + SetUpPair(ClientFD, ServerFD); +} + +InitializeAudio () +{ + InitializeAudioDecode (); +} diff --git a/bigreqscope.h b/bigreqscope.h new file mode 100644 index 0000000..80648f1 --- /dev/null +++ b/bigreqscope.h @@ -0,0 +1,17 @@ +#ifndef _BIGREQSCOPE_H_ +#define _BIGREQSCOPE_H_ + + +#define BIGREQREQUESTHEADER "BIGREQREQUEST" +#define BIGREQREPLYHEADER "BIGREQREPLY" + +/* + To aid in making the choice between level 1 and level 2, we + define the following define, which does not print relatively + unimportant fields. +*/ + +#define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e) + +#endif + @@ -54,6 +54,7 @@ \* *********************************************************** */ #include "scope.h" +#include <fcntl.h> #ifdef SYSV #define bzero(s,l) memset(s, 0, l) @@ -121,6 +122,7 @@ Free(void *p) /* */ /* ************************************************************ */ +#define __USE_BSD_SIGNAL #include <signal.h> static void SignalURG(int sig) @@ -130,13 +132,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 +165,29 @@ static void SignalCONT(int sig) debug(1,(stderr, "==> SIGCONT received\n")); } +static void SignalUSR1(int sig) +{ + extern char ScopeEnabled; + + debug(1,(stderr, "==> SIGCONT received\n")); + ScopeEnabled = ! ScopeEnabled; +} + void SetSignalHandling() { + extern char HandleSIGUSR1; + 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,6 +215,10 @@ static int ListenTransCount; #include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ #include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ #include <sys/fcntl.h> /* for FIONCLEX, FIONBIO, ... */ +#ifdef SVR4 +#include <sys/filio.h> +#endif + #include <netinet/in.h> /* struct sockaddr_in */ #include <netdb.h> /* struct servent * and struct hostent * */ @@ -217,8 +237,9 @@ static int ON = 1 /* used in ioctl */ ; #endif void -SetUpConnectionSocket(iport) +SetUpConnectionSocket(iport, connectionFunc) int iport; + int (*connectionFunc)(); { #ifdef USE_XTRANS char port[20]; @@ -228,7 +249,11 @@ SetUpConnectionSocket(iport) #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 +276,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 +290,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,13 +349,25 @@ SetUpConnectionSocket(iport) }; /* a few more parameter settings */ - ioctl(ConnectionSocket, FIOCLEX, 0); - ioctl(ConnectionSocket, FIONBIO, &ON); +#ifdef FD_CLOEXEC + (void)fcntl(ConnectionSocket, F_SETFD, FD_CLOEXEC); +#else + (void)ioctl(ConnectionSocket, FIOCLEX, 0); +#endif + /* ultrix reads hang on Unix sockets, hpux reads fail */ +#if defined(O_NONBLOCK) && (!defined(ultrix) && !defined(hpux)) + (void) fcntl (ConnectionSocket, F_SETFL, O_NONBLOCK); +#else +#ifdef FIOSNBIO + (void) ioctl (ConnectionSocket, FIOSNBIO, &ON); +#else + (void) fcntl (ConnectionSocket, F_SETFL, FNDELAY); +#endif +#endif debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket)); - UsingFD(ConnectionSocket, NewConnection); + UsingFD(ConnectionSocket, connectionFunc, NULL, NULL); #endif - } #ifndef USE_XTRANS @@ -374,7 +417,7 @@ int display; exit(0); } - UsingFD(sock, NewConnection); + UsingFD(sock, NewConnection, NULL, NULL); } #endif @@ -413,7 +456,7 @@ int display; exit(-1); } debug(4,(stderr, "Listening on DECnet FD %d\n", fd)); - UsingFD(fd, NewConnection); + UsingFD(fd, NewConnection, NULL, NULL); } #endif @@ -444,3 +487,4 @@ initialize_libdni() } #endif #endif /* USE_XTRANS */ + @@ -54,7 +54,7 @@ * ************************************************************ */ #include "scope.h" -#include "x11.h" +#include "x11.h" #ifdef SYSV #define bzero(s,l) memset(s, 0, l) @@ -96,6 +96,7 @@ struct QueueEntry struct QueueEntry *Next; long SequenceNumber; short Request; + short RequestMinor; }; /* free space list of Q entries */ @@ -103,9 +104,10 @@ struct QueueEntry static struct QueueEntry *FreeQEntries = NULL; /* ************************************************************ */ -static struct QueueEntry *NewQEntry (SequenceNumber, Request) +static struct QueueEntry *NewQEntry (SequenceNumber, Request, RequestMinor) long SequenceNumber; short Request; + short RequestMinor; { struct QueueEntry *p; @@ -126,6 +128,7 @@ static struct QueueEntry *NewQEntry (SequenceNumber, Request) p->Next = NULL; p->SequenceNumber = SequenceNumber; p->Request = Request; + p->RequestMinor = RequestMinor; return(p); } /* ************************************************************ */ @@ -196,17 +199,17 @@ DumpReplyQ(fd) with this one */ static void -SequencedReplyExpected(fd, SequenceNumber, RequestType) +SequencedReplyExpected(fd, SequenceNumber, RequestType, RequestMinorType) FD fd; long SequenceNumber; short RequestType; { struct QueueEntry *p; - debug(8,(stderr, "Reply expected: sequence %d and request type %d for fd %d\n", - SequenceNumber, RequestType, fd)); + debug(8,(stderr, "Reply expected: sequence %d and request type %d,%d for fd %d\n", + SequenceNumber, RequestType, RequestMinorType, fd)); /* create a new queue entry */ - p = NewQEntry(SequenceNumber, RequestType); + p = NewQEntry(SequenceNumber, RequestType, RequestMinorType); /* find the server associated with this client */ fd = FDPair(fd); @@ -219,21 +222,23 @@ SequencedReplyExpected(fd, SequenceNumber, RequestType) ReplyQ[fd].Head = p; ReplyQ[fd].Tail = p; - debug(8,(stderr, "Save sequence %d and request type %d for fd %d\n", - p->SequenceNumber, p->Request, fd)); + debug(8,(stderr, "Save sequence %d and request type %d,%d for fd %d\n", + p->SequenceNumber, p->Request, p->RequestMinor, fd)); } static FD Lastfd; static long LastSequenceNumber; static short LastReplyType; +static short LastReplyMinorType; /* search for the type of request that is associated with a reply to the given sequence number for this fd */ -static short CheckReplyTable (fd, SequenceNumber) +short CheckReplyTable (fd, SequenceNumber, minorp) FD fd; short SequenceNumber; + short *minorp; { struct QueueEntry *p; struct QueueEntry *trailer; @@ -250,6 +255,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 +269,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 +287,20 @@ 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 +void ReplyExpected(fd, Request) FD fd; short Request; { - SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request); + SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, 0); +} + +ExtendedReplyExpected (fd, Request, RequestMinor) + FD fd; + short Request; + short RequestMinor; +{ + SequencedReplyExpected(fd, CS[fd].SequenceNumber, Request, RequestMinor); } /* ************************************************************ */ @@ -295,14 +310,67 @@ ReplyExpected(fd, Request) void KeepLastReplyExpected() { - SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType); + SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType, + LastReplyMinorType); } +#define DUMP_REQUEST 0 +#define DUMP_REPLY 1 +#define DUMP_EVENT 2 +#define DUMP_ERROR 3 + +static char *simple_names[] = { + "REQUEST", + "REPLY ", + "EVENT ", + "ERROR ", +}; + +SimpleDump (type, fd, Major, Minor, bytes) +{ + PrintTime (); + fprintf (stdout, "@@%s %3d %3d %3d %7d\n", + simple_names[type], + ClientNumber(fd), + Major, Minor, bytes); +} + /* ************************************************************ */ /* */ /* */ /* ************************************************************ */ +#ifdef PEX +extern unsigned char LookForPEXFlag; +extern unsigned char PEXCode; +#endif + +extern unsigned char LookForLBXFlag; +extern unsigned char LBXRequest; +extern unsigned char LBXError; +extern unsigned char LBXEvent; + +extern unsigned char LookForWCPFlag; +extern unsigned char WCPRequest; +extern unsigned char WCPError; + +extern unsigned char LookForRENDERFlag; +extern unsigned char RENDERRequest; +extern unsigned char RENDERError; +#define RENDERNError 5 + +extern unsigned char LookForRANDRFlag; +extern unsigned char RANDRRequest; +extern unsigned char RANDREvent; + +extern unsigned char LookForMITSHMFlag; +extern unsigned char MITSHMRequest; +extern unsigned char MITSHMError; +extern unsigned char MITSHMEvent; + +extern unsigned char LookForBIGREQFlag; +extern unsigned char BIGREQRequest; + void DecodeRequest(fd, buf, n) FD fd; @@ -310,15 +378,63 @@ DecodeRequest(fd, buf, n) long n; { short Request = IByte (&buf[0]); + short RequestMinor = Request >= 128 ? IByte (&buf[1]) : 0; + unsigned long seq; + CS[fd].SequenceNumber += 1; - bcopy ((char *)&(CS[fd].SequenceNumber), (char *)SBf, sizeof(long)); + seq = CS[fd].SequenceNumber; + if (CS[fd].littleEndian) { + SBf[0] = seq; + SBf[1] = seq >> 8; + SBf[2] = seq >> 16; + SBf[3] = seq >> 24; + } else { + SBf[0] = seq >> 24; + SBf[1] = seq >> 16; + SBf[2] = seq >> 8; + SBf[3] = seq; + } SetIndentLevel(PRINTCLIENT); + if (IShort(&buf[2]) == 0 && CS[fd].bigreqEnabled) + { + memmove (buf + 4, buf, 4); + CS[fd].requestLen--; + buf += 4; + } + 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"); - else switch (Request) + if (Request < 0 || 127 < Request) { +#ifdef PEX + if (Request == PEXCode) { + pex_decode_req(fd, buf); + } else +#endif + if (Request == LBXRequest) { + lbx_decode_req(fd, buf); + } else + if (Request == WCPRequest) { + wcp_decode_req(fd, buf); + } else if (Request == RENDERRequest) { + render_decode_req(fd,buf); + } else if (Request == RANDRRequest) { + randr_decode_req(fd,buf); + } else if (Request == MITSHMRequest) { + mitshm_decode_req(fd,buf); + } else if (Request == BIGREQRequest) { + bigreq_decode_req(fd,buf); + } else + { + ExtendedRequest(fd, buf); + ReplyExpected(fd, Request); + } + } else switch (Request) { case 1: CreateWindow(buf); @@ -642,6 +758,31 @@ DecodeRequest(fd, buf, n) break; case 98: QueryExtension(buf); + +#ifdef PEX + /* PEX content */ + if (strncmp("X3D-PEX",(char *)&buf[8],7) == 0) + LookForPEXFlag=1; +#endif + + if (strncmp("LBX",(char *)&buf[8],3) == 0) + LookForLBXFlag=1; + + if (strncmp("NCD-WinCenterPro",(char *)&buf[8],16) == 0) + LookForWCPFlag=1; + + if (strncmp("RENDER",(char *)&buf[8],6) == 0) + LookForRENDERFlag=1; + + if (strncmp("RANDR",(char *)&buf[8],6) == 0) + LookForRANDRFlag=1; + + if (strncmp("MIT-SHM",(char *)&buf[8],7) == 0) + LookForMITSHMFlag=1; + + if (strncmp ("BIG-REQUESTS",(char *)&buf[8],12) == 0) + LookForBIGREQFlag=1; + ReplyExpected(fd, Request); break; case 99: @@ -738,20 +879,45 @@ DecodeReply(fd, buf, n) 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); + + 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) +#ifdef PEX + if (Request == PEXCode) + pex_decode_reply(fd, buf); + else +#endif + if (Request == LBXRequest) + lbx_decode_reply(fd, buf, RequestMinor); + else + if (Request == WCPRequest) + wcp_decode_reply(fd, buf, RequestMinor); + else if (Request == RENDERRequest) + render_decode_reply(fd, buf, RequestMinor); + else if (Request == RANDRRequest) + randr_decode_reply(fd, buf, RequestMinor); + else if (Request == MITSHMRequest) + mitshm_decode_reply(fd, buf, RequestMinor); + else if (Request == BIGREQRequest) + bigreq_decode_reply(fd, buf, RequestMinor); + else if (Request < 0 || 127 < Request) warn("Extended reply opcode"); else switch (Request) { + case 0: + UnknownReply(buf); + break; case 3: GetWindowAttributesReply(buf); break; @@ -889,69 +1055,88 @@ DecodeError(fd, buf, n) 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 == 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 if (Error < 1 || Error > 17) + warn("Extended Error code"); + else switch (Error) + { + case 1: + RequestError(buf); + break; + case 2: + ValueError(buf); + break; + case 3: + WindowError(buf); + break; + case 4: + PixmapError(buf); + break; + case 5: + AtomError(buf); + break; + case 6: + CursorError(buf); + break; + case 7: + FontError(buf); + break; + case 8: + MatchError(buf); + break; + case 9: + DrawableError(buf); + break; + case 10: + AccessError(buf); + break; + case 11: + AllocError(buf); + break; + case 12: + ColormapError(buf); + break; + case 13: + GContextError(buf); + break; + case 14: + IDChoiceError(buf); + break; + case 15: + NameError(buf); + break; + case 16: + LengthError(buf); + break; + case 17: + ImplementationError(buf); + break; + default: + warn("Unimplemented error code"); + break; } } @@ -966,115 +1151,135 @@ DecodeEvent(fd, buf, n) 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 == 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 if (Event < 2 || Event > 34) + warn("Extended Event code"); + else switch (Event) + { + case 2: + KeyPressEvent(buf); + break; + case 3: + KeyReleaseEvent(buf); + break; + case 4: + ButtonPressEvent(buf); + break; + case 5: + ButtonReleaseEvent(buf); + break; + case 6: + MotionNotifyEvent(buf); + break; + case 7: + EnterNotifyEvent(buf); + break; + case 8: + LeaveNotifyEvent(buf); + break; + case 9: + FocusInEvent(buf); + break; + case 10: + FocusOutEvent(buf); + break; + case 11: + KeymapNotifyEvent(buf); + break; + case 12: + ExposeEvent(buf); + break; + case 13: + GraphicsExposureEvent(buf); + break; + case 14: + NoExposureEvent(buf); + break; + case 15: + VisibilityNotifyEvent(buf); + break; + case 16: + CreateNotifyEvent(buf); + break; + case 17: + DestroyNotifyEvent(buf); + break; + case 18: + UnmapNotifyEvent(buf); + break; + case 19: + MapNotifyEvent(buf); + break; + case 20: + MapRequestEvent(buf); + break; + case 21: + ReparentNotifyEvent(buf); + break; + case 22: + ConfigureNotifyEvent(buf); + break; + case 23: + ConfigureRequestEvent(buf); + break; + case 24: + GravityNotifyEvent(buf); + break; + case 25: + ResizeRequestEvent(buf); + break; + case 26: + CirculateNotifyEvent(buf); + break; + case 27: + CirculateRequestEvent(buf); + break; + case 28: + PropertyNotifyEvent(buf); + break; + case 29: + SelectionClearEvent(buf); + break; + case 30: + SelectionRequestEvent(buf); + break; + case 31: + SelectionNotifyEvent(buf); + break; + case 32: + ColormapNotifyEvent(buf); + break; + case 33: + ClientMessageEvent(buf); + break; + case 34: + MappingNotifyEvent(buf); + break; + default: + warn("Unimplemented event code"); + break; } } diff --git a/decode_bigreq.c b/decode_bigreq.c new file mode 100644 index 0000000..1a75265 --- /dev/null +++ b/decode_bigreq.c @@ -0,0 +1,80 @@ +/* + * $XFree86$ + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include "scope.h" +#include "x11.h" +#include "bigreqscope.h" + +unsigned char LookForBIGREQFlag; + +unsigned char BIGREQRequest; + +bigreq_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: + CS[fd].bigreqEnabled = 1; + BigreqEnable (fd, buf); + ExtendedReplyExpected (fd, Major, Minor); break; + default: + break; + } +} + +bigreq_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: BigreqEnableReply (fd, buf); break; + } +} + +InitializeBIGREQ(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + BIGREQRequest = (unsigned char)(buf[9]); + LookForBIGREQFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) BIGREQRequest, "BigreqRequest"); + DefineEValue (&TD[REPLY], (unsigned long) BIGREQRequest, "BigreqReply"); + + p = DefineType(BIGREQREQUEST, ENUMERATED, "BIGREQREQUEST", PrintENUMERATED); + DefineEValue(p, 0L, "BigreqEnable"); + + p = DefineType(BIGREQREPLY, ENUMERATED, "BIGREQREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "BigreqEnable"); +} diff --git a/decode_lbx.c b/decode_lbx.c new file mode 100644 index 0000000..5aced31 --- /dev/null +++ b/decode_lbx.c @@ -0,0 +1,149 @@ +/* + * $NCDId$ + * + * Copyright 1992 Network Computing Devices + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of NCD. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. NCD. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, Network Computing Devices + */ + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#define _XLBX_SERVER_ +#include "scope.h" +#include "x11.h" +#include "lbxscope.h" + +unsigned char LookForLBXFlag; + +unsigned char LBXRequest, LBXEvent, LBXError; + +lbx_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: + LbxQueryVersion (fd, buf); + ExtendedReplyExpected (fd, Major, Minor); + break; + case 1: + LbxStartProxy (fd, buf); + break; + case 2: + LbxStopProxy (fd, buf); + break; + case 3: + LbxSwitch (fd, buf); + break; + case 4: + LbxNewClient(fd, buf); + break; + case 5: + LbxCloseClient (fd, buf); + break; + case 6: + LbxModifySequence (fd, buf); + break; + default: + break; + } +} + +lbx_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: + LbxQueryVersionReply (fd, buf); + break; + default: + break; + } +} + +lbx_decode_error(fd, buf) + FD fd; + unsigned char *buf; +{ + short error = IByte(&buf[1]) - LBXError; + + switch (error) { + case 0: + break; + default: + break; + } +} + +lbx_decode_event (fd, buf) + FD fd; + unsigned char *buf; +{ + short event = IByte(&buf[0]) - LBXEvent; + + switch (event) { + case 0: + LbxSwitchEvent (fd, buf); + break; + case 1: + LbxCloseEvent (fd, buf); + break; + default: + break; + } +} + +InitializeLBX(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + LBXRequest = (unsigned char)(buf[9]); + LBXEvent = (unsigned char)(buf[10]); + LBXError = (unsigned char)(buf[11]); + LookForLBXFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) LBXRequest, "LbxRequest"); + DefineEValue (&TD[REPLY], (unsigned long) LBXRequest, "LbxReply"); + DefineEValue (&TD[EVENT], (unsigned long) LBXEvent, "LbxEvent"); + DefineEValue (&TD[ERROR], (unsigned long) LBXError, "LbxError"); + + p = DefineType(LBXREQUEST, ENUMERATED, "LBXREQUEST", PrintENUMERATED); + DefineEValue(p, 0L, "QueryVersion"); + DefineEValue(p, 1L, "StartProxy"); + DefineEValue(p, 2L, "StopProxy"); + DefineEValue(p, 3L, "Switch"); + DefineEValue(p, 4L, "NewClient"); + DefineEValue(p, 5L, "CloseClient"); + DefineEValue(p, 6L, "ModifySequence"); + + p = DefineType(LBXREPLY, ENUMERATED, "LBXREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "QueryVersion"); + + p = DefineType(LBXEVENT, ENUMERATED, "LBXEVENT", PrintENUMERATED); + DefineEValue (p, 0L, "SwitchEvent"); + DefineEValue (p, 1L, "CloseEvent"); +} diff --git a/decode_pex.c b/decode_pex.c new file mode 100644 index 0000000..2a31d60 --- /dev/null +++ b/decode_pex.c @@ -0,0 +1,786 @@ +/* $XConsortium: decode_pex.c,v 5.3 91/02/17 12:34:53 rws Exp $ */ + +/*********************************************************** +Copyright 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Sun Microsystems, +the X Consortium, and MIT not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#include <stdio.h> +#include <X11/X.h> +#include <X11/extensions/PEX.h> +#include <X11/extensions/PEXproto.h> +#include "scope.h" +#include "pexRNames.h" +#include "pexOCNames.h" +#include "pexscope.h" + +unsigned char pex_last_req; + +BOOL LookForPEXFlag; + +CARD8 PEXCode; + +pex_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short req = IByte (&buf[0]); + + if ((buf[1] < PEX_GetExtensionInfo) || + (buf[1] > PEXMaxRequest)) { + return; + } else + pex_last_req =buf[1]; + + switch (buf[1]) { + case PEX_GetExtensionInfo: + GetExtensionInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetEnumeratedTypeInfo: + GetEnumeratedTypeInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetImpDepConstants: + GetImpDepConstants(buf); + ReplyExpected(fd, req); + break; + case PEX_CreateLookupTable: + CreateLookupTable(buf); + break; + case PEX_CopyLookupTable: + CopyLookupTable(buf); + break; + case PEX_FreeLookupTable: + FreeLookupTable(buf); + break; + case PEX_GetTableInfo: + GetTableInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetPredefinedEntries: + GetPredefinedEntries(buf); + ReplyExpected(fd, req); + break; + case PEX_GetDefinedIndices: + GetDefinedIndices(buf); + ReplyExpected(fd, req); + break; + case PEX_GetTableEntry: + GetTableEntry(buf); + ReplyExpected(fd, req); + break; + case PEX_GetTableEntries: + GetTableEntries(buf); + ReplyExpected(fd, buf); + break; + case PEX_SetTableEntries: + SetTableEntries(buf); + break; + case PEX_DeleteTableEntries: + DeleteTableEntries(buf); + break; + case PEX_CreatePipelineContext: + CreatePipelineContext(buf); + break; + case PEX_CopyPipelineContext: + CopyPipelineContext(buf); + break; + case PEX_FreePipelineContext: + FreePipelineContext(buf); + break; + case PEX_GetPipelineContext: + GetPipelineContext(buf); + ReplyExpected(fd, req); + break; + case PEX_ChangePipelineContext: + ChangePipelineContext(buf); + break; + case PEX_CreateRenderer: + CreateRenderer(buf); + break; + case PEX_FreeRenderer: + FreeRenderer(buf); + break; + case PEX_ChangeRenderer: + ChangeRenderer(buf); + break; + case PEX_GetRendererAttributes: + GetRendererAttributes(buf); + ReplyExpected(fd, req); + break; + case PEX_BeginRendering: + BeginRendering(buf); + break; + case PEX_EndRendering: + EndRendering(buf); + break; + case PEX_BeginStructure: + BeginStructure(buf); + break; + case PEX_EndStructure: + EndStructure(buf); + break; + case PEX_RenderOutputCommands: + RenderOutputCommands(buf); + break; + case PEX_RenderNetwork: + RenderNetwork(buf); + break; + case PEX_CreateStructure: + CreateStructure(buf); + break; + case PEX_CopyStructure: + CopyStructure(buf); + break; + case PEX_GetRendererDynamics: + GetRendererDynamics(buf); + ReplyExpected(fd, req); + break; + case PEX_DestroyStructures: + DestroyStructures(buf); + break; + case PEX_GetStructureInfo: + GetStructureInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetElementInfo: + GetElementInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetStructuresInNetwork: + GetStructuresInNetwork(buf); + ReplyExpected(fd, req); + break; + case PEX_GetAncestors: + GetAncestors(buf); + ReplyExpected(fd, req); + break; + case PEX_GetDescendants: + GetDescendants(buf); + ReplyExpected(fd, req); + break; + case PEX_FetchElements: + FetchElements(buf); + ReplyExpected(fd, req); + break; + case PEX_SetEditingMode: + SetEditingMode(buf); + break; + case PEX_SetElementPointer: + SetElementPointer(buf); + break; + case PEX_SetElementPointerAtLabel: + SetElementPointerAtLabel(buf); + break; + case PEX_ElementSearch: + ElementSearch(buf); + ReplyExpected(fd, req); + break; + case PEX_StoreElements: + StoreElements(buf); + break; + case PEX_DeleteElements: + DeleteElements(buf); + break; + case PEX_DeleteElementsToLabel: + DeleteElementsToLabel(buf); + break; + case PEX_DeleteBetweenLabels: + DeleteBetweenLabels(buf); + break; + case PEX_CopyElements: + CopyElements(buf); + break; + case PEX_ChangeStructureRefs: + ChangeStructureRefs(buf); + break; + case PEX_CreateNameSet: + CreateNameSet(buf); + break; + case PEX_CopyNameSet: + CopyNameSet(buf); + break; + case PEX_FreeNameSet: + FreeNameSet(buf); + break; + case PEX_GetNameSet: + GetNameSet(buf); + ReplyExpected(fd, req); + break; + case PEX_ChangeNameSet: + ChangeNameSet(buf); + break; + case PEX_CreateSearchContext: + CreateSearchContext(buf); + break; + case PEX_CopySearchContext: + CopySearchContext(buf); + break; + case PEX_FreeSearchContext: + FreeSearchContext(buf); + break; + case PEX_GetSearchContext: + GetSearchContext(buf); + ReplyExpected(fd, req); + break; + case PEX_ChangeSearchContext: + ChangeSearchContext(buf); + break; + case PEX_SearchNetwork: + SearchNetwork(buf); + ReplyExpected(fd, req); + break; + case PEX_CreatePhigsWks: + CreatePhigsWks(buf); + break; + case PEX_FreePhigsWks: + FreePhigsWks(buf); + break; + case PEX_GetWksInfo: + GetWksInfo(buf); + ReplyExpected(fd, req); + break; + case PEX_GetDynamics: + GetDynamics(buf); + ReplyExpected(fd, req); + break; + case PEX_GetViewRep: + GetViewRep(buf); + ReplyExpected(fd, req); + break; + case PEX_RedrawAllStructures: + RedrawAllStructures(buf); + break; + case PEX_UpdateWorkstation: + UpdateWorkstation(buf); + break; + case PEX_ExecuteDeferredActions: + ExecuteDeferredActions(buf); + break; + case PEX_SetViewPriority: + SetViewPriority(buf); + break; + case PEX_SetDisplayUpdateMode: + SetDisplayUpdateMode(buf); + break; + case PEX_MapDCtoWC: + MapDCtoWC(buf); + ReplyExpected(fd, req); + break; + case PEX_MapWCtoDC: + MapWCtoDC(buf); + ReplyExpected(fd, req); + break; + case PEX_SetViewRep: + SetViewRep(buf); + break; + case PEX_SetWksWindow: + SetWksWindow(buf); + break; + case PEX_SetWksViewport: + SetWksViewport(buf); + break; + case PEX_SetHlhsrMode: + SetHlhsrMode(buf); + break; + case PEX_PostStructure: + PostStructure(buf); + break; + case PEX_UnpostStructure: + UnpostStructure(buf); + break; + case PEX_UnpostAllStructures: + UnpostAllStructures(buf); + break; + case PEX_GetWksPostings: + GetWksPostings(buf); + ReplyExpected(fd, req); + break; + case PEX_GetPickDevice: + GetPickDevice(buf); + ReplyExpected(fd, req); + break; + case PEX_ChangePickDevice: + ChangePickDevice(buf); + break; + case PEX_CreatePickMeasure: + CreatePickMeasure(buf); + break; + case PEX_FreePickMeasure: + FreePickMeasure(buf); + break; + case PEX_GetPickMeasure: + GetPickMeasure(buf); + ReplyExpected(fd, req); + break; + case PEX_UpdatePickMeasure: + UpdatePickMeasure(buf); + break; + case PEX_OpenFont: + pexopenfont(buf); + break; + case PEX_CloseFont: + pexclosefont(buf); + break; + case PEX_QueryFont: + pexqueryfont(buf); + ReplyExpected(fd, req); + break; + case PEX_ListFonts: + pexlistfonts(buf); + ReplyExpected(fd, req); + break; + case PEX_ListFontsWithInfo: + pexlistfontswithinfo(buf); + ReplyExpected(fd, req); + break; + case PEX_QueryTextExtents: + pexquerytextextents(buf); + ReplyExpected(fd, req); + break; + case PEX_RedrawClipRegion: + RedrawClipRegion(buf); + break; + default: + break; + } +} + +/* + * + * + * + */ +pex_decode_elem(num_cmds, buf) +CARD32 num_cmds; +unsigned char *buf; +{ + register long i; + register pexElementInfo *el_info; + + for (i = 0; i < num_cmds; i++) { + el_info = (pexElementInfo *) buf; + if ((el_info->elementType <= PEXOCAll) || + (el_info->elementType >= PEXMaxOC) ) + return; + fprintf(stdout, "\t\t\t %s\n", + pex_oc_name[el_info->elementType]); + + fprintf(stdout, "\t\t\t length : %d\n",el_info->length); + buf += el_info->length * 4; + +#ifdef IGNORE + switch (el_info->elementType) { + case PEXOCMarkerType: + break; + case PEXOCMarkerScale: + break; + case PEXOCMarkerColourIndex: + break; + case PEXOCMarkerColour: + break; + case PEXOCMarkerBundleIndex: + break; + case PEXOCTextFontIndex: + break; + case PEXOCTextPrecision: + break; + case PEXOCCharExpansion: + break; + case PEXOCCharSpacing: + break; + case PEXOCTextColourIndex: + break; + case PEXOCTextColour: + break; + case PEXOCCharHeight: + break; + case PEXOCCharUpVector: + break; + case PEXOCTextPath: + break; + case PEXOCTextAlignment: + break; + case PEXOCAtextHeight: + break; + case PEXOCAtextUpVector: + break; + case PEXOCAtextPath: + break; + case PEXOCAtextAlignment: + break; + case PEXOCAtextStyle: + break; + case PEXOCTextBundleIndex: + break; + case PEXOCLineType: + break; + case PEXOCLineWidth: + break; + case PEXOCLineColourIndex: + break; + case PEXOCLineColour: + break; + case PEXOCCurveApproximation: + break; + case PEXOCPolylineInterp: + break; + case PEXOCLineBundleIndex: + break; + case PEXOCInteriorStyle: + break; + case PEXOCInteriorStyleIndex: + break; + case PEXOCSurfaceColourIndex: + break; + case PEXOCSurfaceColour: + break; + case PEXOCSurfaceReflAttr: + break; + case PEXOCSurfaceReflModel: + break; + case PEXOCSurfaceInterp: + break; + case PEXOCBfInteriorStyle: + break; + case PEXOCBfInteriorStyleIndex: + break; + case PEXOCBfSurfaceColourIndex: + break; + case PEXOCBfSurfaceColour: + break; + case PEXOCBfSurfaceReflAttr: + break; + case PEXOCBfSurfaceReflModel: + break; + case PEXOCBfSurfaceInterp: + break; + case PEXOCSurfaceApproximation: + break; + case PEXOCTCApproximation: + break; + case PEXOCCullingMode: + break; + case PEXOCDistinguishFlag: + break; + case PEXOCNormalFlip: + break; + case PEXOCPatternSize: + break; + case PEXOCPatternRefPt: + break; + case PEXOCPatternAttr: + break; + case PEXOCInteriorBundleIndex: + break; + case PEXOCSurfaceEdgeFlag: + break; + case PEXOCSurfaceEdgeType: + break; + case PEXOCSurfaceEdgeWidth: + break; + case PEXOCSurfaceEdgeColourIndex: + break; + case PEXOCSurfaceEdgeColour: + break; + case PEXOCEdgeBundleIndex: + break; + case PEXOCSetAsfValues: + break; + case PEXOCLocalTransform: + break; + case PEXOCLocalTransform2D: + break; + case PEXOCGlobalTransform: + break; + case PEXOCGlobalTransform2D: + break; + case PEXOCModelClip: + break; + case PEXOCModelClipVolume: + break; + case PEXOCModelClipVolume2D : + break; + case PEXOCRestoreModelClip: + break; + case PEXOCViewIndex: + break; + case PEXOCLightState: + break; + case PEXOCDepthCueIndex: + break; + case PEXOCPickId: + break; + case PEXOCHlhsrIdentifier: + break; + case PEXOCAddToNameSet: + break; + case PEXOCRemoveFromNameSet: + break; + case PEXOCExecuteStructure: + break; + case PEXOCLabel: + break; + case PEXOCApplicationData: + break; + case PEXOCGse: + break; + case PEXOCMarker: + break; + case PEXOCMarker2D: + break; + case PEXOCText: + break; + case PEXOCText2D: + break; + case PEXOCAnnotationText: + break; + case PEXOCAnnotationText2D: + break; + case PEXOCPolyline: + break; + case PEXOCPolyline2D: + break; + case PEXOCPolylineSet: + break; + case PEXOCNurbCurve: + break; + case PEXOCFillArea: + break; + case PEXOCFillArea2D: + break; + case PEXOCExtFillArea: + break; + case PEXOCFillAreaSet: + break; + case PEXOCFillAreaSet2D: + break; + case PEXOCExtFillAreaSet: + break; + case PEXOCTriangleStrip: + break; + case PEXOCQuadrilateralMesh: + break; + case PEXOCIndexedPolygons: + break; + case PEXOCNurbSurface: + break; + case PEXOCCellArray: + break; + case PEXOCCellArray2D: + break; + case PEXOCExtCellArray: + break; + case PEXOCGdp: + break; + case PEXOCGdp2D: + break; + case PEXOCColourApproxIndex: + break; + default: + break; + } +#endif /* IGNORE */ + } +} + +/* + * + * + * + */ +pex_decode_reply(fd, buf) +FD fd; +unsigned char *buf; +{ + switch (pex_last_req) { + case PEX_GetExtensionInfo: + GetExtensionInfoReply(buf); + break; + case PEX_GetEnumeratedTypeInfo: + GetEnumeratedTypeInfoReply(buf); + break; + case PEX_GetImpDepConstants: + GetImpDepConstantsReply(buf); + break; + case PEX_GetTableInfo: + GetTableInfoReply(buf); + break; + case PEX_GetPredefinedEntries: + GetPredefinedEntriesReply(buf); + break; + case PEX_GetDefinedIndices: + GetDefinedIndicesReply(buf); + break; + case PEX_GetTableEntry: + GetTableEntryReply(buf); + break; + case PEX_GetTableEntries: + GetTableEntriesReply(buf); + break; + case PEX_GetPipelineContext: + GetPipelineContextReply(buf); + break; + case PEX_GetRendererAttributes: + GetRendererAttributesReply(buf); + break; + case PEX_GetRendererDynamics: + GetRendererDynamicsReply(buf); + break; + case PEX_GetStructureInfo: + GetStructureInfoReply(buf); + break; + case PEX_GetElementInfo: + GetElementInfoReply(buf); + break; + case PEX_GetStructuresInNetwork: + GetStructuresInNetworkReply(buf); + break; + case PEX_GetAncestors: + GetAncestorsReply(buf); + break; + case PEX_GetDescendants: + GetDescendantsReply(buf); + break; + case PEX_FetchElements: + FetchElementsReply(buf); + break; + case PEX_ElementSearch: + ElementSearchReply(buf); + break; + case PEX_GetNameSet: + GetNameSetReply(buf); + break; + case PEX_GetSearchContext: + GetSearchContextReply(buf); + break; + case PEX_SearchNetwork: + SearchNetworkReply(buf); + break; + case PEX_GetWksInfo: + GetWksInfoReply(buf); + break; + case PEX_GetDynamics: + GetDynamicsReply(buf); + break; + case PEX_GetViewRep: + GetViewRepReply(buf); + break; + case PEX_MapDCtoWC: + MapDCtoWCReply(buf); + break; + case PEX_MapWCtoDC: + MapWCtoDCReply(buf); + break; + case PEX_GetWksPostings: + GetWksPostingsReply(buf); + break; + case PEX_GetPickDevice: + GetPickDeviceReply(buf); + break; + case PEX_GetPickMeasure: + GetPickMeasureReply(buf); + break; + case PEX_QueryFont: + pexqueryfontreply(buf); + break; + case PEX_ListFonts: + pexlistfontsreply(buf); + break; + case PEX_ListFontsWithInfo: + pexlistfontswithinforeply(buf); + break; + case PEX_QueryTextExtents: + pexquerytextextentsreply(buf); + break; + default: + break; + } +} + +/* + * + * + */ + +pex_decode_error(fd, buf) +FD fd; +unsigned char *buf; +{ + short error = IByte(&buf[1]); + switch (error) { + case PEXColourTypeError: + pexerror_colortype(buf); + break; + case PEXRendererStateError: + pexerror_rendererstate(buf); + break; + case PEXFloatingPointFormatError: + pexerror_floatingpointformat(buf); + break; + case PEXLabelError: + pexerror_label(buf); + break; + case PEXLookupTableError: + pexerror_lookuptable(buf); + break; + case PEXNameSetError: + pexerror_nameset(buf); + break; + case PEXPathError: + pexerror_path(buf); + break; + case PEXFontError: + pexerror_font(buf); + break; + case PEXPhigsWksError: + pexerror_phigswks(buf); + break; + case PEXPickMeasureError: + pexerror_pickmeasure(buf); + break; + case PEXPipelineContextError: + pexerror_pipelinecontext(buf); + break; + case PEXRendererError: + pexerror_renderer(buf); + break; + case PEXSearchContextError: + pexerror_searchcontext(buf); + break; + case PEXStructureError: + pexerror_structure(buf); + break; + case PEXOutputCommandError: + pexerror_outputcommand(buf); + break; + default: + break; + } +} + +InitializePEX() +{ + LookForPEXFlag = 0; + PEXCode = 0; +} diff --git a/decode_randr.c b/decode_randr.c new file mode 100644 index 0000000..dfe9a3d --- /dev/null +++ b/decode_randr.c @@ -0,0 +1,98 @@ +/* + * $XFree86$ + * + * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#define _RANDR_SERVER_ +#include "scope.h" +#include "x11.h" +#include "randrscope.h" + +unsigned char LookForRANDRFlag; + +unsigned char RANDRRequest, RANDRError, RANDREvent; + +randr_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: RandrQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 1: RandrGetScreenInfo (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 2: RandrSetScreenConfig (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 3: RandrScreenChangeSelectInput (fd, buf); + default: + break; + } +} + +randr_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: RandrQueryVersionReply (fd, buf); break; + case 1: RandrGetScreenInfoReply (fd, buf); break; + case 2: RandrSetScreenConfigReply (fd, buf); break; + } +} + +randr_decode_event (fd, buf) + FD fd; + unsigned char *buf; +{ + RandrScreenChangeNotifyEvent (buf); +} + +InitializeRANDR(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + RANDRRequest = (unsigned char)(buf[9]); + RANDREvent = (unsigned char)(buf[10]); + RANDRError = (unsigned char)(buf[11]); + LookForRANDRFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) RANDRRequest, "RandrRequest"); + DefineEValue (&TD[REPLY], (unsigned long) RANDRRequest, "RandrReply"); + DefineEValue (&TD[EVENT], (unsigned long) RANDREvent, "RRScreenChangeNotify"); + + p = DefineType(RANDRREQUEST, ENUMERATED, "RANDRREQUEST", PrintENUMERATED); + DefineEValue(p, 0L, "RandrQueryVersion"); + DefineEValue(p, 1L, "RandrGetScreenInfo"); + DefineEValue(p, 2L, "RandrSetScreenConfig"); + DefineEValue(p, 3L, "RandrScreenChangeSelectInput"); + + p = DefineType(RANDRREPLY, ENUMERATED, "RANDRREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "QueryVersion"); + DefineEValue (p, 1L, "GetScreenInfo"); + DefineEValue (p, 2L, "SetScreenConfig"); +} diff --git a/decode_render.c b/decode_render.c new file mode 100644 index 0000000..8e52d54 --- /dev/null +++ b/decode_render.c @@ -0,0 +1,318 @@ +/* + * $XFree86$ + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#define _RENDER_SERVER_ +#include "scope.h" +#include "x11.h" +#include "renderscope.h" + +unsigned char LookForRENDERFlag; + +unsigned char RENDERRequest, RENDERError; + +render_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: RenderQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 1: RenderQueryPictFormats (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 2: RenderQueryPictIndexValues (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 3: RenderQueryDithers (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 4: RenderCreatePicture (fd, buf); break; + case 5: RenderChangePicture (fd, buf); break; + case 6: RenderSetPictureClipRectangles (fd, buf); break; + case 7: RenderFreePicture (fd, buf); break; + case 8: RenderComposite (fd, buf); break; + case 9: RenderScale (fd, buf); break; + case 10: RenderTrapezoids (fd, buf); break; + case 11: RenderTriangles (fd, buf); break; + case 12: RenderTriStrip (fd, buf); break; + case 13: RenderTriFan (fd, buf); break; + case 14: RenderColorTrapezoids (fd, buf); break; + case 15: RenderColorTriangles (fd, buf); break; + case 16: RenderTransform (fd, buf); break; + case 17: RenderCreateGlyphSet (fd, buf); break; + case 18: RenderReferenceGlyphSet (fd, buf); break; + case 19: RenderFreeGlyphSet (fd, buf); break; + case 20: RenderAddGlyphs (fd, buf); break; + case 21: RenderAddGlyphsFromPicture (fd, buf); break; + case 22: RenderFreeGlyphs (fd, buf); break; + case 23: RenderCompositeGlyphs8 (fd, buf); break; + case 24: RenderCompositeGlyphs16 (fd, buf); break; + case 25: RenderCompositeGlyphs32 (fd, buf); break; + case 26: RenderFillRectangles (fd, buf); break; + default: + break; + } +} + +render_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: RenderQueryVersionReply (fd, buf); break; + case 1: RenderQueryPictFormatsReply (fd, buf); break; + case 2: RenderQueryPictIndexValuesReply (fd, buf); break; + case 3: RenderQueryDithersReply (fd, buf); break; + } +} + +render_decode_error(fd, buf) + FD fd; + unsigned char *buf; +{ + short error = IByte(&buf[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; + } +} + + +PrintPICTURE(buf) + unsigned char *buf; +{ + /* print a WINDOW -- CARD32 plus 0 = None */ + long n = ILong (buf); + if (n == 0) + fprintf(stdout, "None"); + else + fprintf(stdout, "PICTURE %08x", n); + return(4); +} + +PrintPICTFORMAT(buf) + unsigned char *buf; +{ + /* print a WINDOW -- CARD32 plus 0 = None */ + long n = ILong (buf); + if (n == 0) + fprintf(stdout, "None"); + else + fprintf(stdout, "PICTFORMAT %08x", n); + return(4); +} + +PrintPICTFORMINFO(buf) + unsigned char *buf; +{ + /* print a PictFormInfo */ + long n = ILong(buf); + short t = IByte(buf+4); + short d = IByte(buf+5); + + fprintf (stdout, "PICTFORMINFO %08x %s %d ", + n, t == 0 ? "Indexed" : "Direct", d); + if (t == 0) { + long c = ILong(buf+20); + fprintf (stdout, "cmap %08x", 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); +} + +PrintGLYPHSET(buf) + unsigned char *buf; +{ + /* print a GLYPHSET -- CARD32 plus 0 = None */ + long n = ILong (buf); + if (n == 0) + fprintf(stdout, "None"); + else + fprintf(stdout, "GLYPHSET %08x", n); + return(4); +} + +PrintRENDERCOLOR(buf) + unsigned char *buf; +{ + /* print a RENDERCOLOR */ + unsigned short r, g, b, a; + + r = IShort(buf); + g = IShort(buf+2); + b = IShort(buf+4); + a = IShort(buf+6); + fprintf(stdout, "COLOR r:%04x g:%04x b:%04x a:%04x", r, g, b, a); + return(8); +} + +PrintFIXED(buf) + unsigned char *buf; +{ + /* print a PICTURE */ + long n = ILong (buf); + fprintf (stdout, "FIXED %7.2f", n / 65536.0); + return 4; +} + +PrintPOINTFIXED(buf) + 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; +} + +PrintTRAPEZOID(buf) + 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; +} + +PrintTRIANGLE(buf) + 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; +} + +InitializeRENDER(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + RENDERRequest = (unsigned char)(buf[9]); + RENDERError = (unsigned char)(buf[11]); + LookForRENDERFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) RENDERRequest, "RenderRequest"); + DefineEValue (&TD[REPLY], (unsigned long) RENDERRequest, "RenderReply"); + + DefineEValue (&TD[ERROR], (unsigned long) RENDERError + 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", PrintENUMERATED); + DefineEValue(p, 0L, "RenderQueryVersion"); + DefineEValue(p, 1L, "RenderQueryPictFormats"); + DefineEValue(p, 2L, "RenderQueryPictIndexValues"); + DefineEValue(p, 3L, "RenderQueryDithers"); + DefineEValue(p, 4L, "RenderCreatePicture"); + DefineEValue(p, 5L, "RenderChangePicture"); + DefineEValue(p, 6L, "RenderSetPictureClipRectangles"); + DefineEValue(p, 7L, "RenderFreePicture"); + DefineEValue(p, 8L, "RenderComposite"); + DefineEValue(p, 9L, "RenderScale"); + DefineEValue(p, 10L, "RenderTrapezoids"); + DefineEValue(p, 11L, "RenderTriangles"); + DefineEValue(p, 12L, "RenderTriStrip"); + DefineEValue(p, 13L, "RenderTriFan"); + DefineEValue(p, 14L, "RenderColorTrapezoids"); + DefineEValue(p, 15L, "RenderColorTriangles"); + DefineEValue(p, 16L, "RenderTransform"); + DefineEValue(p, 17L, "RenderCreateGlyphSet"); + DefineEValue(p, 18L, "RenderReferenceGlyphSet"); + DefineEValue(p, 19L, "RenderFreeGlyphSet"); + DefineEValue(p, 20L, "RenderAddGlyphs"); + DefineEValue(p, 21L, "RenderAddGlyphsFromPicture"); + DefineEValue(p, 22L, "RenderFreeGlyphs"); + DefineEValue(p, 23L, "RenderCompositeGlyphs8"); + DefineEValue(p, 24L, "RenderCompositeGlyphs16"); + DefineEValue(p, 25L, "RenderCompositeGlyphs32"); + DefineEValue(p, 26L, "RenderFillRectangles"); + + p = DefineType(RENDERREPLY, ENUMERATED, "RENDERREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "QueryVersion"); + 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", PrintSET); + + DefineValues(p, 0x00000001L, 1, BOOL, "repeat"); + DefineValues(p, 0x00000002L, 1, PICTURE, "alpha-map"); + DefineValues(p, 0x00000004L, 1, INT16, "alpha-x-origin"); + DefineValues(p, 0x00000008L, 1, INT16, "alpha-y-origin"); + DefineValues(p, 0x00000010L, 1, INT16, "clip-x-origin"); + DefineValues(p, 0x00000020L, 1, INT16, "clip-y-origin"); + DefineValues(p, 0x00000040L, 1, PIXMAP, "clip-mask"); + DefineValues(p, 0x00000080L, 1, BOOL, "graphics-exposures"); + DefineValues(p, 0x00000100L, 1, SUBWINMODE, "repeat"); + DefineValues(p, 0x00000200L, 1, BOOL, "poly-edge"); + DefineValues(p, 0x00000400L, 1, BOOL, "poly-mode"); + DefineValues(p, 0x00000800L, 1, ATOM, "dither"); + DefineValues(p, 0x00001000L, 1, BOOL, "component-alpha"); + + p = DefineType(PICTOP, ENUMERATED, "PICTOP", PrintENUMERATED); + DefineEValue (p, 0L, "Clear"); + DefineEValue (p, 1L, "Src"); + DefineEValue (p, 2L, "Dst"); + DefineEValue (p, 3L, "Over"); + DefineEValue (p, 4L, "OverReverse"); + DefineEValue (p, 5L, "In"); + DefineEValue (p, 6L, "InReverse"); + DefineEValue (p, 7L, "Out"); + DefineEValue (p, 8L, "OutReverse"); + DefineEValue (p, 9L, "Atop"); + DefineEValue (p, 10L, "AtopReverse"); + DefineEValue (p, 11L, "Xor"); + DefineEValue (p, 12L, "Add"); + DefineEValue (p, 13L, "Saturate"); + + 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..da2b74c --- /dev/null +++ b/decode_shm.c @@ -0,0 +1,116 @@ +/* + * $XFree86$ + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include "scope.h" +#include "x11.h" +#include "shmscope.h" + +unsigned char LookForMITSHMFlag; + +unsigned char MITSHMRequest, MITSHMError, MITSHMEvent; + +mitshm_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: MitshmQueryVersion (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 1: MitshmAttach (fd, buf); break; + case 2: MitshmDetach (fd, buf); break; + case 3: MitshmPutImage (fd, buf); break; + case 4: MitshmGetImage (fd, buf); ExtendedReplyExpected (fd, Major, Minor); break; + case 5: MitshmCreatePixmap (fd, buf); break; + default: + break; + } +} + +mitshm_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: MitshmQueryVersionReply (fd, buf); break; + case 4: MitshmGetImageReply (fd, buf); break; + } +} + +mitshm_decode_event(fd, buf) + FD fd; + unsigned char *buf; +{ +} + +mitshm_decode_error(fd, buf) + FD fd; + unsigned char *buf; +{ + short error = IByte(&buf[0]) - MITSHMError; + + switch (error) { + case 0: MitshmShmSegError (fd, buf); break; + default: + break; + } +} + + +InitializeMITSHM(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + MITSHMRequest = (unsigned char)(buf[9]); + MITSHMEvent = (unsigned char)(buf[10]); + MITSHMError = (unsigned char)(buf[11]); + LookForMITSHMFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) MITSHMRequest, "MitshmRequest"); + DefineEValue (&TD[REPLY], (unsigned long) MITSHMRequest, "MitshmReply"); + DefineEValue (&TD[EVENT], (unsigned long) MITSHMEvent, "MitshmEvent"); + DefineEValue (&TD[ERROR], (unsigned long) MITSHMError, "MitshmError"); + + p = DefineType(MITSHMREQUEST, ENUMERATED, "MITSHMREQUEST", PrintENUMERATED); + DefineEValue(p, 0L, "MitshmQueryVersion"); + DefineEValue(p, 1L, "MitshmAttach"); + DefineEValue(p, 2L, "MitshmDetach"); + DefineEValue(p, 3L, "MitshmPutImage"); + DefineEValue(p, 4L, "MitshmGetImage"); + DefineEValue(p, 5L, "MitshmCreatePixmap"); + + p = DefineType(MITSHMREPLY, ENUMERATED, "MITSHMREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "QueryVersion"); + DefineEValue (p, 4L, "GetImage"); + + p = DefineType(MITSHMEVENT, ENUMERATED, "MITSHMEVENT", PrintENUMERATED); + DefineEValue (p, 0L, "CompletionEvent"); +} diff --git a/decode_wcp.c b/decode_wcp.c new file mode 100644 index 0000000..f6529c2 --- /dev/null +++ b/decode_wcp.c @@ -0,0 +1,130 @@ +/* + * $NCDOr$ + * + * Copyright 1996 Network Computing Devices + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of NCD. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. NCD. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, Network Computing Devices + */ + +#include <stdio.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#define _WCP_SERVER_ +#include "scope.h" +#include "x11.h" +#include "wcpscope.h" + +unsigned char LookForWCPFlag; + +unsigned char WCPRequest, WCPError; + +wcp_decode_req(fd, buf) +FD fd; +unsigned char *buf; +{ + short Major = IByte (&buf[0]); + short Minor = IByte (&buf[1]); + + switch (Minor) { + case 0: + WcpQueryVersion (fd, buf); + ExtendedReplyExpected (fd, Major, Minor); + break; + case 1: + WcpPutImage (fd, buf); + break; + case 2: + WcpGetImage (fd, buf); + ExtendedReplyExpected (fd, Major, Minor); + break; + case 3: + WcpCreateColorCursor (fd, buf); + break; + case 4: + WcpCreateLut (fd, buf); + break; + case 5: + WcpFreeLut (fd, buf); + break; + case 6: + WcpCopyArea (fd, buf); + break; + default: + break; + } +} + +wcp_decode_reply(fd, buf, RequestMinor) + FD fd; + unsigned char *buf; + short RequestMinor; +{ + switch (RequestMinor) { + case 0: + WcpQueryVersionReply (fd, buf); + break; + case 2: + WcpGetImageReply (fd, buf); + break; + default: + break; + } +} + +wcp_decode_error(fd, buf) + FD fd; + unsigned char *buf; +{ + short error = IByte(&buf[1]) - WCPError; + + switch (error) { + case 0: + break; + default: + break; + } +} + +InitializeWCP(buf) + unsigned char *buf; +{ + TYPE p, DefineType (); + + WCPRequest = (unsigned char)(buf[9]); + WCPError = (unsigned char)(buf[11]); + LookForWCPFlag = 0; + + DefineEValue (&TD[REQUEST], (unsigned long) WCPRequest, "WcpRequest"); + DefineEValue (&TD[REPLY], (unsigned long) WCPRequest, "WcpReply"); + DefineEValue (&TD[ERROR], (unsigned long) WCPError, "WcpError"); + + p = DefineType(WCPREQUEST, ENUMERATED, "WCPREQUEST", PrintENUMERATED); + DefineEValue(p, 0L, "WcpQueryVersion"); + DefineEValue(p, 1L, "WcpPutImage"); + DefineEValue(p, 2L, "WcpGetImage"); + DefineEValue(p, 3L, "WcpCreateColorCursor"); + DefineEValue(p, 4L, "WcpCreateLut"); + DefineEValue(p, 5L, "WcpFreeLut"); + DefineEValue(p, 6L, "WcpCopyArea"); + + p = DefineType(WCPREPLY, ENUMERATED, "WCPREPLY", PrintENUMERATED); + DefineEValue (p, 0L, "QueryVersion"); + +} diff --git a/decodenas.c b/decodenas.c new file mode 100644 index 0000000..687c344 --- /dev/null +++ b/decodenas.c @@ -0,0 +1,465 @@ +/* ************************************************************ * + * * + * Decoding and switching routines for the NAS protocol * + * * + * James Peterson, 1988 * + * (c) Copyright MCC, 1988 * + * * + * ************************************************************ */ + +#include "scope.h" +#include "nas.h" + +/* + There are 4 types of things in NAS: requests, replies, errors, and events. + + Each of them has a format defined by a small integer that defines + the type of the thing. + + Requests have an opcode in the first byte. + Events have a code in the first byte. + Errors have a code in the second byte (the first byte is 0) + Replies ... + + Replies have a sequence number in bytes 2 and 3. The sequence + number should be used to identify the request that was sent, and + from that request we can determine the type of the reply. +*/ + + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + + +/* + We need to keep the sequence number for a request to match it with + an expected reply. The sequence number is associated only with the + particular connection that we have. We would expect these replies + to be handled as a FIFO queue. +*/ + +#define DUMP_REQUEST 0 +#define DUMP_REPLY 1 +#define DUMP_EVENT 2 +#define DUMP_ERROR 3 + +static char *simple_names[] = { + "REQUEST", + "REPLY ", + "EVENT ", + "ERROR ", +}; + +AudioSimpleDump (type, fd, Major, Minor, bytes) +{ + PrintTime (); + fprintf (stdout, "@@%s %3d %3d %3d %7d\n", + simple_names[type], + ClientNumber(fd), + Major, Minor, bytes); +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +DecodeAudioRequest(fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short Request = IByte (&buf[0]); + short RequestMinor = Request >= 128 ? IByte (&buf[1]) : 0; + unsigned long seq; + + CS[fd].SequenceNumber += 1; + seq = CS[fd].SequenceNumber; + if (CS[fd].littleEndian) { + SBf[0] = seq; + SBf[1] = seq >> 8; + SBf[2] = seq >> 16; + SBf[3] = seq >> 24; + } else { + SBf[0] = seq >> 24; + SBf[1] = seq >> 16; + SBf[2] = seq >> 8; + SBf[3] = seq; + } + SetIndentLevel(PRINTCLIENT); + + if (NasVerbose == 0) + { + AudioSimpleDump (DUMP_REQUEST, fd, Request, RequestMinor, n); + return; + } + + if (NasVerbose > 3) + DumpItem("Request", fd, buf, n); + switch (Request) + { + case 1: + AudioListDevices (buf); + ReplyExpected(fd, Request); + break; + case 2: + AudioGetDeviceAttributes(buf); + ReplyExpected(fd, Request); + break; + case 3: + AudioSetDeviceAttributes (buf); + break; + case 4: + AudioCreateBucket (buf); + break; + case 5: + AudioDestroyBucket (buf); + break; + case 6: + AudioListBuckets (buf); + ReplyExpected (fd, Request); + break; + case 7: + AudioGetBucketAttributes (buf); + ReplyExpected (fd, Request); + break; + case 8: + AudioSetBucketAttributes (buf); + break; + case 9: + AudioCreateRadio (buf); + break; + case 10: + AudioDestroyRadio (buf); + break; + case 11: + AudioListRadios (buf); + ReplyExpected (fd, Request); + break; + case 12: + AudioGetRadioAttributes (buf); + ReplyExpected (fd, Request); + break; + case 13: + AudioSetRadioAttributes (buf); + break; + case 14: + AudioCreateFlow (buf); + break; + case 15: + AudioDestroyFlow (buf); + break; + case 16: + AudioGetFlowAttributes (buf); + ReplyExpected (fd, Request); + break; + case 17: + AudioSetFlowAttributes (buf); + break; + case 18: + AudioGetElements (buf); + ReplyExpected (fd, Request); + break; + case 19: + AudioSetElements (buf); + break; + case 20: + AudioGetElementStates (buf); + ReplyExpected (fd, Request); + break; + case 21: + AudioSetElementStates (buf); + break; + case 22: + AudioGetElementParameters (buf); + ReplyExpected (fd, Request); + break; + case 23: + AudioSetElementParameters (buf); + break; + case 24: + AudioWriteElement (buf); + break; + case 25: + AudioReadElement (buf); + ReplyExpected (fd, Request); + break; + case 26: + AudioGrabComponent (buf); + break; + case 27: + AudioUngrabComponent (buf); + break; + case 28: + AudioSendEvent (buf); + break; + case 29: + AudioGetAllowedUsers (buf); + ReplyExpected (fd, Request); + break; + case 30: + AudioSetAllowedUsers (buf); + break; + case 31: + AudioListExtensions (buf); + ReplyExpected (fd, Request); + break; + case 32: + AudioQueryExtension (buf); + ReplyExpected (fd, Request); + break; + case 33: + AudioGetCloseDownMode (buf); + ReplyExpected (fd, Request); + break; + case 34: + AudioSetCloseDownMode (buf); + break; + case 35: + AudioKillClient (buf); + break; + case 36: + AudioGetServerTime (buf); + ReplyExpected (fd, Request); + break; + case 37: + AudioNoOperation (buf); + break; + default: + warn("Unimplemented request opcode"); + break; + } +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +DecodeAudioReply(fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short SequenceNumber = IShort (&buf[2]); + short RequestMinor; + short Request = CheckReplyTable (fd, SequenceNumber, &RequestMinor); + + if (NasVerbose == 0) + { + AudioSimpleDump (DUMP_REPLY, fd, Request, RequestMinor, n); + return; + } + + SetIndentLevel(PRINTSERVER); + RBf[0] = Request /* for the PrintField in the Reply procedure */ ; + RBf[1] = RequestMinor; + if (NasVerbose > 3) + DumpItem("Reply", fd, buf, n); + switch (Request) + { + case 0: + UnknownAudioReply(buf); + break; + case 1: + AudioListDevicesReply (buf); + break; + case 2: + AudioGetDeviceAttributesReply (buf); + break; + case 6: + AudioListBucketsReply (buf); + break; + case 7: + AudioGetBucketAttributesReply (buf); + break; + case 11: + AudioListRadiosReply (); + break; + case 12: + AudioGetRadioAttributesReply (buf); + break; + case 16: + AudioGetFlowAttributesReply (buf); + break; + case 18: + AudioGetElementsReply (buf); + break; + case 20: + AudioGetElementStatesReply (buf); + break; + case 22: + AudioGetElementParametersReply (buf); + break; + case 25: + AudioReadElementReply (buf); + break; + case 29: + AudioGetAllowedUsersReply (buf); + break; + case 31: + AudioListExtensionsReply (buf); + break; + case 32: + AudioQueryExtensionReply (buf); + break; + case 33: + AudioGetCloseDownModeReply (buf); + break; + case 36: + AudioGetServerTimeReply (buf); + break; + default: + warn("Unimplemented reply opcode"); + break; + } +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +DecodeAudioError(fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short Error = IByte (&buf[1]); + short Request = 0; + short RequestMinor = 0; + + Request = CheckReplyTable (fd, (short)IShort(&buf[2]), &RequestMinor); + + if (NasVerbose == 0) + { + AudioSimpleDump (DUMP_ERROR, fd, Request, RequestMinor, n); + return; + } + + SetIndentLevel(PRINTSERVER); + if (NasVerbose > 3) + DumpItem("Error", fd, buf, n); +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +DecodeAudioEvent(fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + short Event = IByte (&buf[0]); + short EventMinor = 0; + + if (NasVerbose == 0) + { + AudioSimpleDump (DUMP_EVENT, fd, Event, EventMinor, n); + return; + } + + SetIndentLevel(PRINTSERVER); + if (NasVerbose > 3) + DumpItem("Event", fd, buf, n); + /* high-order bit means SendEvent generated */ + if (Event & 0x80) + { + debug(8,(stderr, "SendEvent generated event 0x%x\n", Event)); + Event = Event & 0x7F; + } + switch (Event) + { + case 2: + AudioElementNotify (buf); + break; + case 3: + AudioGrabNotify (buf); + break; + case 4: + AudioMonitorNotify (buf); + break; + case 5: + AudioBucketNotify (buf); + break; + case 6: + AudioDeviceNotify (buf); + break; + default: + warn("Unimplemented event code"); + break; + } +} + +InitializeAudioDecode () +{ + TYPE p; + extern TYPE DefineType (); + + p = DefineType (NASREQUEST, ENUMERATED, "NASREQUEST", PrintENUMERATED); + DefineEValue (p, 1L, "ListDevices"); + DefineEValue (p, 2L, "GetDeviceAttributes"); + DefineEValue (p, 3L, "SetDeviceAttributes"); + DefineEValue (p, 4L, "CreateBucket"); + DefineEValue (p, 5L, "DestroyBucket"); + DefineEValue (p, 6L, "ListBuckets"); + DefineEValue (p, 7L, "GetBucketAttributes"); + DefineEValue (p, 8L, "SetBucketAttributes"); + DefineEValue (p, 9L, "CreateRadio"); + DefineEValue (p, 10L, "DestroyRadio"); + DefineEValue (p, 11L, "ListRadios"); + DefineEValue (p, 12L, "GetRadioAttributes"); + DefineEValue (p, 13L, "SetRadioAttributes"); + DefineEValue (p, 14L, "CreateFlow"); + DefineEValue (p, 15L, "DestroyFlow"); + DefineEValue (p, 16L, "GetFlowAttributes"); + DefineEValue (p, 17L, "SetFlowAttributes"); + DefineEValue (p, 18L, "GetElements"); + DefineEValue (p, 19L, "SetElements"); + DefineEValue (p, 20L, "GetElementStates"); + DefineEValue (p, 21L, "SetElementStates"); + DefineEValue (p, 22L, "GetElementParameters"); + DefineEValue (p, 23L, "SetElementParameters"); + DefineEValue (p, 24L, "WriteElement"); + DefineEValue (p, 25L, "ReadElement"); + DefineEValue (p, 26L, "GrabComponent"); + DefineEValue (p, 27L, "UngrabComponent"); + DefineEValue (p, 28L, "SendEvent"); + DefineEValue (p, 29L, "GetAllowedUsers"); + DefineEValue (p, 30L, "SetAllowedUsers"); + DefineEValue (p, 31L, "ListExtensions"); + DefineEValue (p, 32L, "QuerExtension"); + DefineEValue (p, 33L, "GetCloseDownMode"); + DefineEValue (p, 34L, "SetCloseDownMode"); + DefineEValue (p, 35L, "KillClient"); + DefineEValue (p, 36L, "GetServerTime"); + DefineEValue (p, 37L, "NoOperation"); + p = DefineType (NASREPLY, ENUMERATED, "NASREPLY", PrintENUMERATED); + DefineEValue (p, 1L, "ListDevices"); + DefineEValue (p, 2L, "GetDeviceAttributes"); + DefineEValue (p, 6L, "ListBuckets"); + DefineEValue (p, 7L, "GetBucketAttributes"); + DefineEValue (p, 11L, "ListRadios"); + DefineEValue (p, 12L, "GetRadioAttributes"); + DefineEValue (p, 16L, "GetFlowAttributes"); + DefineEValue (p, 18L, "GetElements"); + DefineEValue (p, 20L, "GetElementStates"); + DefineEValue (p, 22L, "GetElementParameters"); + DefineEValue (p, 25L, "ReadElement"); + DefineEValue (p, 29L, "GetAllowedUsers"); + DefineEValue (p, 31L, "ListExtensions"); + DefineEValue (p, 32L, "QueryExtension"); + DefineEValue (p, 33L, "GetCloseDownMode"); + DefineEValue (p, 36L, "GetServerTime"); + p = DefineType (NASEVENT, ENUMERATED, "NASEVENT", PrintENUMERATED); + DefineEValue(p, 2L, "ElementNotify"); + DefineEValue(p, 3L, "GrabNotify"); + DefineEValue(p, 4L, "MonitorNotify"); + DefineEValue(p, 5L, "BucketNotify"); + DefineEValue(p, 6L, "DeviceNotify"); + +} @@ -62,6 +62,21 @@ #define bcopy(s,d,l) memmove(d,s,l) #endif +#include <sys/uio.h> /* for struct iovec, used by socket.h */ +#include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ +#include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ +#ifdef SVR4 +#include <sys/filio.h> +#endif +#include <fcntl.h> +#include <netinet/in.h> /* struct sockaddr_in */ +#include <sys/un.h> /* struct sockaddr_un */ +#include <netinet/tcp.h> +#include <netdb.h> /* struct servent * and struct hostent * */ +#include <errno.h> /* for EINTR, EADDRINUSE, ... */ +extern int errno; + + /* All of this code is to support the handling of file descriptors (FD). The idea is to keep a table of the FDs that are in use and why. @@ -83,10 +98,19 @@ InitializeFD() enterprocedure("InitializeFD"); /* get the number of file descriptors the system will let us use */ +#if defined(hpux) || defined(SVR4) + MaxFD = _NFILE - 1; +#else MaxFD = getdtablesize(); 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 *) @@ -110,20 +134,21 @@ InitializeFD() MaxFD -= 4; nFDsInUse = 0 /* stdin, stdout, stderr */ ; - FD_ZERO(&ReadDescriptors); + ReadDescriptors = 0; 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) +UsingFD(fd, Handler, FlushHandler, trans_conn) FD fd; void (*Handler)(int); + void (*FlushHandler)(int); XtransConnInfo trans_conn; { if (FDD[fd].Busy) @@ -132,13 +157,14 @@ 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 if (Handler == NULL) - FD_CLR(fd,&ReadDescriptors) /* clear fd bit */ ; + ReadDescriptors &= ~(1 << fd) /* clear fd bit */ ; else - FD_SET(fd,&ReadDescriptors) /* set fd bit */ ; + ReadDescriptors |= 1 << fd /* set fd bit */ ; if (fd > HighestFD) HighestFD = fd; @@ -161,7 +187,7 @@ NotUsingFD(fd) nFDsInUse -= 1; FDD[fd].Busy = false; - FD_CLR(fd,&ReadDescriptors) /* clear fd bit */ ; + ReadDescriptors &= ~(1 << fd) /* clear fd bit */ ; while (!FDD[HighestFD].Busy && HighestFD > 0) HighestFD -= 1; @@ -195,7 +221,183 @@ EOFonFD(fd) NotUsingFD(fd); } +FD +AcceptConnection (ConnectionSocket) + 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(server, port, report, trans_conn) + char *server; + short port; + int report; + XtransConnInfo *trans_conn; /* transport connection object */ +{ + FD ServerFD; +#ifdef USE_XTRANS + char address[256]; + int connect_stat; + extern long ServerBasePort; + + snprintf (address, sizeof(address), "%s:%d", 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 */ @@ -212,19 +414,25 @@ MainLoop(void) while (true) { - fd_set rfds, xfds; + int rfds, wfds, xfds; short nfds; short fd; /* wait for something */ - rfds = ReadDescriptors; + rfds = ReadDescriptors & ~BlockedReadDescriptors; + wfds = ReadDescriptors & WriteDescriptors; xfds = rfds; 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 || (rfds == 0 && wfds == 0)) + { + ReadCommands (); + Interrupt = 0; + continue; + } + nfds = select(HighestFD + 1, &rfds, &wfds, &xfds, (struct timeval *)NULL); + debug(128,(stderr, "select nfds = 0%o, rfds = 0%o, 0%o, xfds 0%o\n", + nfds, rfds, wfds, xfds)); if (nfds < 0) { @@ -239,7 +447,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 +466,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 (rfds & (1 << fd)) + { + if (FDD[fd].InputHandler == NULL) + { + panic("FD selected with no handler"); + debug(1,(stderr, "FD %d has NULL handler\n", fd)); + } + else + (FDD[fd].InputHandler)(fd); + } + if (wfds & (1 << fd)) + { + if (FDD[fd].FlushHandler == NULL) { - panic("FD selected with no 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; @@ -53,6 +53,8 @@ * ********************************************** */ +#ifndef XSCOPE_FD_H +#define XSCOPE_FD_H /* the following structure remembers for each file descriptor its @@ -74,25 +76,33 @@ 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 long ReadDescriptors /* bit map of FD's in use -- for select */ ; +extern long WriteDescriptors /* bit map of write blocked FD's -- for select */; +extern long BlockedReadDescriptors /* bit map of FD's blocked from reading */; +extern short HighestFD /* highest FD in use -- for select */ ; /* 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 int MainLoop(void); #ifdef USE_XTRANS extern XtransConnInfo GetXTransConnInfo(FD fd); #endif + +#endif /* XSCOPE_FD_H */ diff --git a/imakefile b/imakefile deleted file mode 100644 index 5bc330d..0000000 --- a/imakefile +++ /dev/null @@ -1,5 +0,0 @@ -LOCAL_LIBRARIES = -SRCS = prtype.c print11.c table11.c decode11.c server.c fd.c common.c scope.c -OBJS = scope.o common.o fd.o server.o decode11.o table11.o print11.o prtype.o - -ComplexProgramTarget(xscope) diff --git a/lbxscope.h b/lbxscope.h new file mode 100644 index 0000000..4a48c53 --- /dev/null +++ b/lbxscope.h @@ -0,0 +1,43 @@ +/* $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) + +#endif + @@ -0,0 +1,123 @@ +/* ************************************************************ * + * * + * Type definitions and Connection State for the NAS protocol * + * * + * James Peterson, 1988 * + * (c) Copyright MCC, 1988 * + * * + * ************************************************************ */ + + +#include "x11.h" + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +/* + In general, we are called with a buffer of bytes and are supposed to + try to make sense of these bytes according to the NAS protocol. There + are two different types of communication: requests from the client to + the server and replies/errors/events from the server to the client. + We must interpret these two differently. + + Also, we must consider that the bytes on the communication socket may + be sent asynchronously in any amount. This means that we must be prepared + to read in and save some bytes until we get enough to do something with + them. For example, suppose that we get a buffer from a client. We would + expect it to be a request. The request may be 24 bytes long. We may find, + however, that only 16 bytes have actually arrived -- the other 8 are stuck + in a buffer somewhere. We must be prepared to simply hold the 16 bytes we + have until more bytes arrive. + + In general, we do two things: we wait for some number of bytes, and + then we interpret this set of bytes. To interpret this data we use + a modified state machine. We keep two pieces of information: + + (1) the number of bytes that we need + (2) what to do with those bytes. + + This last piece of information is the "state" of the interpretation. + We keep the state as a pointer to the procedure that is to be executed. + + + CLIENTS: + + The data going from the client to the x11 server consists of a + set-up message followed by an infinite stream of variable length + requests. + + Our overall flow is then: + + (a) Wait for 12 bytes. + (b) Interpret these first 12 bytes of the set-up message to get the + length of the rest of the message. + (c) Wait for the rest of the set-up message. + (d) Interpret and print the set-up message. + + *** end of set-up phase -- start normal request loop *** + + (e) Wait for 4 bytes. + (f) Interpret these 4 bytes to get the length of the rest of the command. + (g) Wait for the rest of the command. + (h) Interpret and print the command. + (i) Go back to step (e). + + SERVERS: + + Again, we have a set-up reply followed by an infinite stream of variable + length replies/errors/events. + + Our overall flow is then: + + (a) Wait for 8 bytes. + (b) Interpret the 8 bytes to get the length of the rest of the set-up reply. + (c) Wait for the rest of the set-up reply. + (d) Interpret and print the set-up reply. + + *** end of set-up phase -- start normal reply/error/event loop *** + + We have the following properties of NAS replies, errors, and events: + + Replies: 32 bytes plus a variable amount. Byte 0 is 1. + Bytes 2-3 are a sequence number; bytes 4-7 are length (n). The + complete length of the reply is 32 + 4 * n. + + Errors: 32 bytes. Byte 0 is 0. + Byte 1 is an error code; bytes 2-3 are a sequence number. + Bytes 8-9 are a major opcode; byte 10 is a minor opcode. + + Events: 32 bytes. Byte 0 is 2, 3, 4, .... + + Looking at this we have two choices: wait for one byte and then separately + wait for replies, errors, and events, or wait for 32 bytes, then separately + process each type. We may have to wait for more, in the event of a reply. + This latter seems more effective. It appears reply/error/event formats + were selected to allow waiting for 32 bytes, and it will allow short packets + which are only 32 bytes long, to be processed completely in one step. + + Thus, For normal reply/error/event processing we have + + (e) Wait for 32 bytes. + (f) Interpret these 32 bytes. If possible, go back to step (e). + (g) If the packet is a reply with bytes 4-7 non-zero, wait for the + remainder of the the reply. + (h) Interpret and print the longer reply. Go back to step (e). + + + The similarity in approach to how both the client and server are handled + suggests we can use the same control structure to drive the interpretation + of both types of communication client->server and server->client. + Accordingly, we package up the relevant variables in a ConnState + record. The ConnState record contains the buffer of saved bytes (if any), + the size and length of this buffer, the number of bytes we are waiting for + and what to do when we get them. A separate ConnState record is kept + for the client and server. + + In addition, we may have several different client or server connections. + Thus we need an array of all the necessary state for each client or server. + A client/server is identified with a file descriptor (fd), so we use the + fd to identify the client/server and use it as an index into an array of + state variables. +*/ diff --git a/patchlevel.h b/patchlevel.h new file mode 100644 index 0000000..0dad8d2 --- /dev/null +++ b/patchlevel.h @@ -0,0 +1,2 @@ +#define PATCHLEVEL 1 + diff --git a/pexOCNames.h b/pexOCNames.h new file mode 100644 index 0000000..9124aea --- /dev/null +++ b/pexOCNames.h @@ -0,0 +1,134 @@ +/* Automatically generated OC table + */ +/****************************************************************** +Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Sun Microsystems, +the X Consortium, and MIT not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +static char *pex_oc_name [] = { + "", + "MarkerType", + "MarkerScale", + "MarkerColourIndex", + "MarkerColour", + "MarkerBundleIndex", + "TextFontIndex", + "TextPrecision", + "CharExpansion", + "CharSpacing", + "TextColourIndex", + "TextColour", + "CharHeight", + "CharUpVector", + "TextPath", + "TextAlignment", + "AtextHeight", + "AtextUpVector", + "AtextPath", + "AtextAlignment", + "AtextStyle", + "TextBundleIndex", + "LineType", + "LineWidth", + "LineColourIndex", + "LineColour", + "CurveApproximation", + "PolylineInterp", + "LineBundleIndex", + "InteriorStyle", + "InteriorStyleIndex", + "SurfaceColourIndex", + "SurfaceColour", + "SurfaceReflAttr", + "SurfaceReflModel", + "SurfaceInterp", + "BfInteriorStyle", + "BfInteriorStyleIndex", + "BfSurfaceColourIndex", + "BfSurfaceColour", + "BfSurfaceReflAttr", + "BfSurfaceReflModel", + "BfSurfaceInterp", + "SurfaceApproximation", + "CullingMode", + "DistinguishFlag", + "PatternSize", + "PatternRefPt", + "PatternAttr", + "InteriorBundleIndex", + "SurfaceEdgeFlag", + "SurfaceEdgeType", + "SurfaceEdgeWidth", + "SurfaceEdgeColourIndex", + "SurfaceEdgeColour", + "EdgeBundleIndex", + "SetAsfValues", + "LocalTransform", + "LocalTransform2D", + "GlobalTransform", + "GlobalTransform2D", + "ModelClip", + "ModelClipVolume", + "ModelClipVolume2D", + "RestoreModelClip", + "ViewIndex", + "LightState", + "DepthCueIndex", + "PickId", + "HlhsrIdentifier", + "ColourApproxIndex", + "RenderingColourModel", + "ParaSurfCharacteristics", + "AddToNameSet", + "RemoveFromNameSet", + "ExecuteStructure", + "Label", + "ApplicationData", + "Gse", + "Marker", + "Marker2D", + "Text", + "Text2D", + "AnnotationText", + "AnnotationText2D", + "Polyline", + "Polyline2D", + "PolylineSet", + "NurbCurve", + "FillArea", + "FillArea2D", + "ExtFillArea", + "FillAreaSet", + "FillAreaSet2D", + "ExtFillAreaSet", + "TriangleStrip", + "QuadrilateralMesh", + "SOFAS", + "NurbSurface", + "CellArray", + "CellArray2D", + "ExtCellArray", + "Gdp", + "Gdp2D", + "Noop" +}; + + diff --git a/pexOCTab.awk b/pexOCTab.awk new file mode 100644 index 0000000..4794790 --- /dev/null +++ b/pexOCTab.awk @@ -0,0 +1,86 @@ +## +# $XConsortium: pexOCTab.awk,v 5.1 91/02/16 09:32:13 rws Exp $ +########################################################################### +## Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. +## +## All Rights Reserved +## +## Permission to use, copy, modify, and distribute this software and its +## documentation for any purpose and without fee is hereby granted, +## provided that the above copyright notice appear in all copies and that +## both that copyright notice and this permission notice appear in +## supporting documentation, and that the names of Sun Microsystems, +## the X Consortium, and MIT not be used in advertising or publicity +## pertaining to distribution of the software without specific, written +## prior permission. +## +## SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +## INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +## SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +## SOFTWARE. +## +########################################################################### +## Usage: +## rm -f temp.dat +## awk -f pex_oc_table.awk <pex-include-path>/PEX.h > <output_file> +## +BEGIN { num=0; i=0; gap_begin=0; val=0; gap=0; j=0 + print "/* Automatically generated OC table" + print " */" + print "/******************************************************************" + print "Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium." + print "" + print " All Rights Reserved" + print "" + print "Permission to use, copy, modify, and distribute this software and its " + print "documentation for any purpose and without fee is hereby granted, " + print "provided that the above copyright notice appear in all copies and that" + print "both that copyright notice and this permission notice appear in " + print "supporting documentation, and that the names of Sun Microsystems," + print "the X Consortium, and MIT not be used in advertising or publicity " + print "pertaining to distribution of the software without specific, written " + print "prior permission. " + print "" + print "SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, " + print "INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT " + print "SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL " + print "DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS," + print "WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION," + print "ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS" + print "SOFTWARE." + print "" + print "******************************************************************/" + } +## +## Look only for lines starting with PEXOC (in PEX.h). +## Name (minus PEXOC) is saved in array for printing at the end +## (signalled by reaching "PEXMaxOC"). This allows us to do the +## extern declarations and the table in one pass. +## + $1 == "#define" { + if ($2 == "PEXMaxOC") { + print "static char *pex_oc_name [] = {" + for (i=0; i<(num-1); i++) { + if (str[i] == "PEX_OC_GAP") { + for (j=0; j<gap; j++) print "\t\"\"," } + else print "\t\"" str[i] "\"," } + print "\t\"" str[i] "\"" + print "};\n\n" } + else if (index($2,"PEXOC") == 1) { + str[num] = substr($2,6,(length($2)-5)) + if (str[num] == "All") { str[num] = "" } + val = $3 + if ((gap_begin != 0) && (gap == 0)) { gap = val - gap_begin - 1 } + num++ } + else if (num > 0) { + if ($2 == "PEX_OC_GAP") { + str[num] = "PEX_OC_GAP" + gap_begin = val + num++ } } + } +## +## +END { } diff --git a/pexRNames.h b/pexRNames.h new file mode 100644 index 0000000..6fa1a7f --- /dev/null +++ b/pexRNames.h @@ -0,0 +1,134 @@ +/* Automatically generated OC table + */ +/****************************************************************** +Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Sun Microsystems, +the X Consortium, and MIT not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ +static char *pex_req_name [] = { + "", + "GetExtensionInfo", + "GetEnumeratedTypeInfo", + "GetImpDepConstants", + "CreateLookupTable", + "CopyLookupTable", + "FreeLookupTable", + "GetTableInfo", + "GetPredefinedEntries", + "GetDefinedIndices", + "GetTableEntry", + "GetTableEntries", + "SetTableEntries", + "DeleteTableEntries", + "CreatePipelineContext", + "CopyPipelineContext", + "FreePipelineContext", + "GetPipelineContext", + "ChangePipelineContext", + "CreateRenderer", + "FreeRenderer", + "ChangeRenderer", + "GetRendererAttributes", + "GetRendererDynamics", + "BeginRendering", + "EndRendering", + "BeginStructure", + "EndStructure", + "RenderOutputCommands", + "RenderNetwork", + "CreateStructure", + "CopyStructure", + "DestroyStructures", + "GetStructureInfo", + "GetElementInfo", + "GetStructuresInNetwork", + "GetAncestors", + "GetDescendants", + "FetchElements", + "SetEditingMode", + "SetElementPointer", + "SetElementPointerAtLabel", + "ElementSearch", + "StoreElements", + "DeleteElements", + "DeleteElementsToLabel", + "DeleteBetweenLabels", + "CopyElements", + "ChangeStructureRefs", + "CreateNameSet", + "CopyNameSet", + "FreeNameSet", + "GetNameSet", + "ChangeNameSet", + "CreateSearchContext", + "CopySearchContext", + "FreeSearchContext", + "GetSearchContext", + "ChangeSearchContext", + "SearchNetwork", + "CreatePhigsWks", + "FreePhigsWks", + "GetWksInfo", + "GetDynamics", + "GetViewRep", + "RedrawAllStructures", + "UpdateWorkstation", + "RedrawClipRegion", + "ExecuteDeferredActions", + "SetViewPriority", + "SetDisplayUpdateMode", + "MapDCtoWC", + "MapWCtoDC", + "SetViewRep", + "SetWksWindow", + "SetWksViewport", + "SetHlhsrMode", + "SetWksBufferMode", + "PostStructure", + "UnpostStructure", + "UnpostAllStructures", + "GetWksPostings", + "GetPickDevice", + "ChangePickDevice", + "CreatePickMeasure", + "FreePickMeasure", + "GetPickMeasure", + "UpdatePickMeasure", + "OpenFont", + "CloseFont", + "QueryFont", + "ListFonts", + "ListFontsWithInfo", + "QueryTextExtents", + "MatchRendererTargets", + "Escape", + "EscapeWithReply", + "RenderElements", + "AccumulateState", + "BeginPickOne", + "EndPickOne", + "PickOne", + "BeginPickAll", + "EndPickAll", + "PickAll" +}; + + diff --git a/pexRTab.awk b/pexRTab.awk new file mode 100644 index 0000000..5ee8ad8 --- /dev/null +++ b/pexRTab.awk @@ -0,0 +1,81 @@ +## +# $XConsortium: pexRTab.awk,v 5.1 91/02/16 09:32:10 rws Exp $ +########################################################################### +## Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. +## +## All Rights Reserved +## +## Permission to use, copy, modify, and distribute this software and its +## documentation for any purpose and without fee is hereby granted, +## provided that the above copyright notice appear in all copies and that +## both that copyright notice and this permission notice appear in +## supporting documentation, and that the names of Sun Microsystems, +## the X Consortium, and MIT not be used in advertising or publicity +## pertaining to distribution of the software without specific, written +## prior permission. +## +## SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +## INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +## SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +## DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +## SOFTWARE. +## +########################################################################### +## Usage: +## rm -f temp.dat +## awk -f pex_oc_table.awk <pex-include-path>/PEX.h > <output_file> +## +BEGIN { num=0; i=0; gap_begin=0; val=0; gap=0; j=0 + print "/* Automatically generated OC table" + print " */" + print "/******************************************************************" + print "Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium." + print "" + print " All Rights Reserved" + print "" + print "Permission to use, copy, modify, and distribute this software and its " + print "documentation for any purpose and without fee is hereby granted, " + print "provided that the above copyright notice appear in all copies and that" + print "both that copyright notice and this permission notice appear in " + print "supporting documentation, and that the names of Sun Microsystems," + print "the X Consortium, and MIT not be used in advertising or publicity " + print "pertaining to distribution of the software without specific, written " + print "prior permission. " + print "" + print "SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, " + print "INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT " + print "SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL " + print "DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS," + print "WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION," + print "ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS" + print "SOFTWARE." + print "" + print "******************************************************************/" + } +## +## Look only for lines starting with PEXOC (in PEX.h). +## Name (minus PEXOC) is saved in array for printing at the end +## (signalled by reaching "PEXMaxOC"). This allows us to do the +## extern declarations and the table in one pass. +## + $2 == "PEX_GetExtensionInfo" { + str[num] = "" + num++ } + num > 0 { + if ($1 == "#define") { + if ($2 == "PEXMaxRequest") { + print "static char *pex_req_name [] = {" + for (i=0; i<(num-1); i++) { print "\t\"" str[i] "\"," } + print "\t\"" str[i] "\"" + print "};\n\n" } + else if (index($2,"PEX_") == 1) { + str[num] = substr($2,5,(length($2)-4)) + val = $3 + if ((gap_begin != 0) && (gap == 0)) { gap = val - gap_begin - 1 } + num++ } + } } +## +## +END { } diff --git a/pexscope.h b/pexscope.h new file mode 100644 index 0000000..3c42531 --- /dev/null +++ b/pexscope.h @@ -0,0 +1,62 @@ +/* $XConsortium: pexscope.h,v 5.1 91/02/16 09:31:57 rws Exp $ */ + +/*********************************************************** +Copyright 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Sun Microsystems, +the X Consortium, and MIT not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#ifndef PEXSCOPE_H_INCLUDED +#define PEXSCOPE_H_INCLUDED + +#ifdef __STDC__ +#define PEX_DECODE_REQUEST(_request_name,ptr) \ + (void) fprintf(stderr,"\t........PEX_REQUEST: %s\n", \ + pex_req_name[PEX_##_request_name]); \ + (void) fprintf(stderr,"\t.............length: %d\n", \ + ((pex##_request_name##Req *)ptr)->length) +#else +#define PEX_DECODE_REQUEST(_request_name,ptr) \ + (void) fprintf(stderr,"\t........PEX_REQUEST: %s\n", \ + pex_req_name[PEX_/**/_request_name]); \ + (void) fprintf(stderr,"\t.............length: %d\n", \ + ((pex/**/_request_name/**/Req *)ptr)->length) +#endif + +#ifdef __STDC__ +#define PEX_DECODE_REPLY(_reply_name,ptr) \ + (void) fprintf(stderr,"\t..........PEX_REPLY: %s\n", \ + pex_req_name[PEX_##_reply_name]); \ + (void) fprintf(stderr,"\t.............length: %d\n", \ + ((pex##_reply_name##Reply *)ptr)->length) +#else +#define PEX_DECODE_REPLY(_reply_name,ptr) \ + (void) fprintf(stderr,"\t..........PEX_REPLY: %s\n", \ + pex_req_name[PEX_/**/_reply_name]); \ + (void) fprintf(stderr,"\t.............length: %d\n", \ + ((pex/**/_reply_name/**/Reply *)ptr)->length) +#endif + +#define PEX_DECODE_ELEM(_opcode) \ + (void) fprint(stderr,"\t..................... %s\n", \ + pex_oc_name[_opcode]) + +#endif /* PEXSCOPE_H_INCLUDED */ @@ -90,7 +90,6 @@ static void ListFontsWithInfoReply2(unsigned char *buf); #define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e) - /* ************************************************************ */ /* */ /* */ @@ -187,10 +186,10 @@ PrintSuccessfulSetUpReply(buf) /* */ /* ************************************************************ */ -static char *REQUESTHEADER = "............REQUEST"; -static char *EVENTHEADER = "..............EVENT"; -static char *ERRORHEADER = "..............ERROR"; -static char *REPLYHEADER = "..............REPLY"; +char *REQUESTHEADER = "............REQUEST"; +char *EVENTHEADER = "..............EVENT"; +char *ERRORHEADER = "..............ERROR"; +char *REPLYHEADER = "..............REPLY"; /* ************************************************************ */ @@ -948,6 +947,35 @@ MappingNotifyEvent(buf) /* Request and Reply Printing procedures */ +ExtendedRequest(fd, buf) + int fd; + unsigned char *buf; +{ + short n; + PrintField(buf, 0, 1, REQUEST, REQUESTHEADER); + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + PrintField(buf, 1, 1, CARD8, "minor opcode"); + printfield (buf, 2, 2, DVALUE2(n-1), "request length"); + n = CS[fd].requestLen - 1; + (void) PrintList (&buf[4], n, CARD32, "data"); +} + +UnknownReply(buf) + unsigned char *buf; +{ + long n; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER); + PrintField(buf, 1, 1, CARD8, "data"); + printfield (buf, 2, 2, CARD16, "sequence number"); + printfield (buf, 4, 4, DVALUE4(n), "reply length"); + n = ILong (&buf[4]) + 6; + (void) PrintList (&buf[8], n, CARD32, "data"); +} + void CreateWindow(buf) unsigned char *buf; @@ -957,7 +985,7 @@ CreateWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, CARD8, "depth"); printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); @@ -983,7 +1011,7 @@ ChangeWindowAttributes(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1000,7 +1028,7 @@ GetWindowAttributes(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1041,7 +1069,7 @@ DestroyWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1056,7 +1084,7 @@ DestroySubwindows(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1071,7 +1099,7 @@ ChangeSaveSet(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, INS_DEL, "mode"); printfield(buf, 2, 2, CONST2(2), "request length"); @@ -1087,7 +1115,7 @@ ReparentWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1105,7 +1133,7 @@ MapWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1120,7 +1148,7 @@ MapSubwindows(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1135,7 +1163,7 @@ UnmapWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1150,7 +1178,7 @@ UnmapSubwindows(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1165,7 +1193,7 @@ ConfigureWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1182,7 +1210,7 @@ CirculateWindow(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, CIRMODE, "direction"); printfield(buf, 2, 2, CONST2(2), "request length"); @@ -1198,7 +1226,7 @@ GetGeometry(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, DRAWABLE, "drawable"); @@ -1231,7 +1259,7 @@ QueryTree(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1264,7 +1292,7 @@ InternAtom(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "only-if-exists"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); @@ -1294,7 +1322,7 @@ GetAtomName(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, ATOM, "atom"); @@ -1328,7 +1356,7 @@ ChangeProperty(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, CHANGEMODE, "mode"); printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length"); @@ -1355,7 +1383,7 @@ DeleteProperty(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(3), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1371,7 +1399,7 @@ GetProperty(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "delete"); printfield(buf, 2, 2, CONST2(6), "request length"); @@ -1417,7 +1445,7 @@ ListProperties(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1447,7 +1475,7 @@ SetSelectionOwner(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, WINDOW, "owner"); @@ -1464,7 +1492,7 @@ GetSelectionOwner(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, ATOM, "selection"); @@ -1491,7 +1519,7 @@ ConvertSelection(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(6), "request length"); PrintField(buf, 4, 4, WINDOW, "requestor"); @@ -1510,7 +1538,7 @@ SendEvent(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "propagate"); printfield(buf, 2, 2, CONST2(11), "request length"); @@ -1528,7 +1556,7 @@ GrabPointer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "owner-events"); printfield(buf, 2, 2, CONST2(6), "request length"); @@ -1562,7 +1590,7 @@ UngrabPointer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, TIMESTAMP, "time"); @@ -1577,7 +1605,7 @@ GrabButton(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "owner-events"); printfield(buf, 2, 2, CONST2(6), "request length"); @@ -1600,7 +1628,7 @@ UngrabButton(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BUTTONA, "button"); printfield(buf, 2, 2, CONST2(3), "request length"); @@ -1617,7 +1645,7 @@ ChangeActivePointerGrab(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, CURSOR, "cursor"); @@ -1634,7 +1662,7 @@ GrabKeyboard(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "owner-events"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -1665,7 +1693,7 @@ UngrabKeyboard(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, TIMESTAMP, "time"); @@ -1680,7 +1708,7 @@ GrabKey(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "owner-events"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -1700,7 +1728,7 @@ UngrabKey(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, KEYCODEA, "key"); printfield(buf, 2, 2, CONST2(3), "request length"); @@ -1717,7 +1745,7 @@ AllowEvents(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, EVENTMODE, "mode"); printfield(buf, 2, 2, CONST2(2), "request length"); @@ -1733,7 +1761,7 @@ GrabServer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -1747,7 +1775,7 @@ UngrabServer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -1761,7 +1789,7 @@ QueryPointer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1795,7 +1823,7 @@ GetMotionEvents(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -1827,7 +1855,7 @@ TranslateCoordinates(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, WINDOW, "src-window"); @@ -1860,7 +1888,7 @@ WarpPointer(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(6), "request length"); PrintField(buf, 4, 4, WINDOW, "src-window"); @@ -1882,7 +1910,7 @@ SetInputFocus(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, FOCUSAGENT, "revert-to"); printfield(buf, 2, 2, CONST2(3), "request length"); @@ -1899,7 +1927,7 @@ GetInputFocus(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -1926,7 +1954,7 @@ QueryKeymap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -1953,7 +1981,7 @@ OpenFont(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length"); PrintField(buf, 4, 4, FONT, "font-id"); @@ -1971,7 +1999,7 @@ CloseFont(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, FONT, "font"); @@ -1986,7 +2014,7 @@ QueryFont(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, FONTABLE, "font"); @@ -2028,14 +2056,14 @@ void QueryTextExtents(buf) unsigned char *buf; { - short n; + int n; /* Request QueryTextExtents is opcode 48 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* QueryTextExtents */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 1, 1, BOOL, "odd length?"); printfield(buf, 2, 2, DVALUE2(2 + (2*n + p) / 4), "request length"); @@ -2075,7 +2103,7 @@ ListFonts(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); PrintField(buf, 4, 2, CARD16, "max-names"); @@ -2110,7 +2138,7 @@ ListFontsWithInfo(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); PrintField(buf, 4, 2, CARD16, "max-names"); @@ -2185,7 +2213,7 @@ SetFontPath(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); printfield(buf, 4, 2, CARD16, "number of paths"); @@ -2202,7 +2230,7 @@ GetFontPath(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 2, 2, CONST2(1), "request list"); } @@ -2231,7 +2259,7 @@ CreatePixmap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, CARD8, "depth"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -2250,22 +2278,51 @@ FreePixmap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, PIXMAP, "pixmap"); } +unsigned long GCDefaults[] = { + 3, /* function GXcopy */ + ~0, /* planemask */ + 0, /* foreground */ + 1, /* background */ + 0, /* line width */ + 0, /* line style Solid */ + 1, /* cap style Butt */ + 0, /* join style Miter */ + 0, /* fill style Solid */ + 0, /* fill rule EvenOdd */ + 0, /* tile */ + 0, /* stipple */ + 0, /* ts org x */ + 0, /* ts org y */ + 0, /* font */ + 0, /* sub window mode ClipByChildren */ + 1, /* graphics expose True */ + 0, /* clip x org */ + 0, /* clip y org */ + 0, /* clip mask */ + 0, /* dash offset */ + 4, /* dashes */ + 1, /* arc mode PieSlice */ +}; + void CreateGC(buf) unsigned char *buf; { + CreateValueRec (ILong(buf+4), 23, GCDefaults); + SetValueRec (ILong(buf+4), &buf[12], 4, GC_BITMASK, &buf[16]); + /* Request CreateGC is opcode 55 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* CreateGC */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(4 + n), "request length"); PrintField(buf, 4, 4, GCONTEXT, "graphic-context-id"); @@ -2278,12 +2335,14 @@ void ChangeGC(buf) unsigned char *buf; { + SetValueRec (ILong(buf+4), &buf[8], 4, GC_BITMASK, &buf[12]); + /* Request ChangeGC is opcode 56 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ChangeGC */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); PrintField(buf, 4, 4, GCONTEXT, "gc"); @@ -2300,7 +2359,7 @@ CopyGC(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, GCONTEXT, "src-gc"); @@ -2318,7 +2377,7 @@ SetDashes(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length"); PrintField(buf, 4, 4, GCONTEXT, "gc"); @@ -2339,7 +2398,7 @@ SetClipRectangles(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, RECTORDER, "ordering"); printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length"); @@ -2354,12 +2413,14 @@ void FreeGC(buf) unsigned char *buf; { + DeleteValueRec (ILong (&buf[4])); + /* Request FreeGC is opcode 60 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* FreeGC */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, GCONTEXT, "gc"); @@ -2374,7 +2435,7 @@ ClearArea(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "exposures"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -2394,12 +2455,18 @@ CopyArea(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(7), "request length"); PrintField(buf, 4, 4, DRAWABLE, "src-drawable"); PrintField(buf, 8, 4, DRAWABLE, "dst-drawable"); PrintField(buf, 12, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[12]), + GC_function| + GC_plane_mask| + GC_graphics_exposures, + GC_BITMASK); PrintField(buf, 16, 2, INT16, "src-x"); PrintField(buf, 18, 2, INT16, "src-y"); PrintField(buf, 20, 2, INT16, "dst-x"); @@ -2417,12 +2484,20 @@ CopyPlane(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(8), "request length"); PrintField(buf, 4, 4, DRAWABLE, "src-drawable"); PrintField(buf, 8, 4, DRAWABLE, "dst-drawable"); PrintField(buf, 12, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[12]), + GC_function| + GC_plane_mask| + GC_foreground| + GC_background| + GC_graphics_exposures, + GC_BITMASK); PrintField(buf, 16, 2, INT16, "src-x"); PrintField(buf, 18, 2, INT16, "src-y"); PrintField(buf, 20, 2, INT16, "dst-x"); @@ -2442,14 +2517,20 @@ PolyPoint(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, COORMODE, "coordinate-mode"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); n = (IShort(&buf[2]) - 3); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - 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 @@ -2462,14 +2543,28 @@ PolyLine(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, COORMODE, "coordinate-mode"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); n = (IShort(&buf[2]) - 3); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - PrintList(&buf[12], (long)n, POINT, "points"); + 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 @@ -2482,13 +2577,26 @@ PolySegment(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length"); n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - PrintList(&buf[12], (long)n, SEGMENT, "segments"); + 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 @@ -2501,13 +2609,27 @@ PolyRectangle(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length"); n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); + 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 @@ -2520,13 +2642,27 @@ PolyArc(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + 3*n), "request length"); n = (IShort(&buf[2]) - 3) / 3; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - PrintList(&buf[12], (long)n, ARC, "arcs"); + 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 @@ -2539,12 +2675,23 @@ FillPoly(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(4 + n), "request length"); n = (IShort(&buf[2]) - 4); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong(buf+8), + GC_function| + GC_plane_mask| + GC_fill_style| + GC_fill_rule| + GC_foreground| + GC_background| + GC_tile| + GC_stipple, + GC_BITMASK); PrintField(buf, 12, 1, POLYSHAPE, "shape"); PrintField(buf, 13, 1, COORMODE, "coordinate-mode"); PrintList(&buf[16], (long)n, POINT, "points"); @@ -2560,13 +2707,23 @@ PolyFillRectangle(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + 2*n), "request length"); n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - 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 @@ -2579,26 +2736,37 @@ PolyFillArc(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + 3*n), "request length"); n = (IShort(&buf[2]) - 3) / 3; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - PrintList(&buf[12], (long)n, ARC, "arcs"); + 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(buf) unsigned char *buf; { - short n; + int n; /* Request PutImage is opcode 72 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PutImage */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, IMAGEMODE, "format"); printfield(buf, 2, 2, DVALUE2(6 + (n + p) / 4), "request length"); @@ -2618,13 +2786,21 @@ PutImage(buf) n = (IShort(&buf[2]) - 6) * 4; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[8]), + GC_function| + GC_plane_mask| + GC_foreground| + GC_background, + GC_BITMASK); PrintField(buf, 12, 2, CARD16, "width"); PrintField(buf, 14, 2, CARD16, "height"); PrintField(buf, 16, 2, INT16, "dst-x"); PrintField(buf, 18, 2, INT16, "dst-y"); PrintField(buf, 20, 1, CARD8, "left-pad"); PrintField(buf, 21, 1, CARD8, "depth"); - PrintBytes(&buf[24], (long)n, "data"); + if (Verbose > 3) + PrintBytes(&buf[24], (long)n, "data"); } void @@ -2636,7 +2812,7 @@ GetImage(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, IMAGEMODE, "format"); printfield(buf, 2, 2, CONST2(5), "request length"); @@ -2666,26 +2842,38 @@ 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; { - short n; + int n; /* Request PolyText8 is opcode 74 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyText8 */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length"); n = (IShort(&buf[2]) - 4) * 4; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[8]), + GC_function| + GC_plane_mask| + GC_fill_style| + GC_font| + GC_foreground| + GC_background| + GC_tile| + GC_stipple, + GC_BITMASK); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); PrintTextList8(&buf[16], n, "items"); @@ -2695,19 +2883,30 @@ void PolyText16(buf) unsigned char *buf; { - short n; + int n; /* Request PolyText16 is opcode 75 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* PolyText16 */ ; if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length"); n = (IShort(&buf[2]) - 4) * 4; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[8]), + GC_function| + GC_plane_mask| + GC_fill_style| + GC_font| + GC_foreground| + GC_background| + GC_tile| + GC_stipple, + GC_BITMASK); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); PrintTextList16(&buf[16], n, "items"); @@ -2723,16 +2922,23 @@ ImageText8(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 1, 1, DVALUE1(n), "length of string"); n = IByte(&buf[1]); printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length"); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[8]), + GC_plane_mask| + GC_font| + GC_foreground| + GC_background, + GC_BITMASK); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); - PrintString8(&buf[16], n, "string"); + PrintTString8(&buf[16], (long)n, "string"); } void @@ -2745,16 +2951,23 @@ ImageText16(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 1, 1, DVALUE1(n), "length of string"); n = IByte(&buf[1]); printfield(buf, 2, 2, DVALUE2(4 + (2*n + p) / 4), "request length"); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong (&buf[8]), + GC_plane_mask| + GC_font| + GC_foreground| + GC_background, + GC_BITMASK); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); - PrintString16(&buf[16], n, "string"); + PrintTString16(&buf[16], (long)n, "string"); } void @@ -2766,7 +2979,7 @@ CreateColormap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, ALLORNONE, "alloc"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -2784,7 +2997,7 @@ FreeColormap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -2799,7 +3012,7 @@ CopyColormapAndFree(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(3), "request length"); PrintField(buf, 4, 4, COLORMAP, "color-map-id"); @@ -2815,7 +3028,7 @@ InstallColormap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -2830,7 +3043,7 @@ UninstallColormap(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -2845,7 +3058,7 @@ ListInstalledColormaps(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -2875,7 +3088,7 @@ AllocColor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(4), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -2909,7 +3122,7 @@ AllocNamedColor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -2945,7 +3158,7 @@ AllocColorCells(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "contiguous"); printfield(buf, 2, 2, CONST2(3), "request length"); @@ -2983,7 +3196,7 @@ AllocColorPlanes(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, BOOL, "contiguous"); printfield(buf, 2, 2, CONST2(4), "request length"); @@ -3023,7 +3236,7 @@ FreeColors(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); n = IShort(&buf[2]) - 3; @@ -3042,7 +3255,7 @@ StoreColors(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + 3*n), "request length"); n = (IShort(&buf[2]) - 2) / 3; @@ -3060,7 +3273,7 @@ StoreNamedColor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, COLORMASK, "which colors?"); printfield(buf, 2, 2, DVALUE2(4 + (n + p) / 4), "request length"); @@ -3081,7 +3294,7 @@ QueryColors(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + n), "request length"); n = IShort(&buf[2]) - 2; @@ -3114,7 +3327,7 @@ LookupColor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + (n + p) / 4), "request length"); PrintField(buf, 4, 4, COLORMAP, "cmap"); @@ -3149,7 +3362,7 @@ CreateCursor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(8), "request length"); PrintField(buf, 4, 4, CURSOR, "cursor-id"); @@ -3174,7 +3387,7 @@ CreateGlyphCursor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(8), "request length"); PrintField(buf, 4, 4, CURSOR, "cursor-id"); @@ -3199,7 +3412,7 @@ FreeCursor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, CURSOR, "cursor"); @@ -3214,7 +3427,7 @@ RecolorCursor(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(5), "request length"); PrintField(buf, 4, 4, CURSOR, "cursor"); @@ -3235,7 +3448,7 @@ QueryBestSize(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, OBJECTCLASS, "class"); printfield(buf, 2, 2, CONST2(3), "request length"); @@ -3267,18 +3480,53 @@ QueryExtension(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); printfield(buf, 4, 2, DVALUE2(n), "length of name"); n = IShort(&buf[4]); - PrintString8(&buf[8], n, "name"); + PrintString8(&buf[8], (long)n, "name"); } void QueryExtensionReply(buf) unsigned char *buf; { + extern unsigned char LookForLBXFlag; + extern unsigned char LookForWCPFlag; + extern unsigned char LookForRENDERFlag; + extern unsigned char LookForRANDRFlag; + extern unsigned char LookForMITSHMFlag; + extern unsigned char LookForBIGREQFlag; +#ifdef PEX + extern unsigned char LookForPEXFlag; + extern unsigned char PEXCode; + + /* PEX content */ + if (LookForPEXFlag) { + PEXCode = (unsigned char)(buf[9]); + LookForPEXFlag=0; + } +#endif + if (LookForLBXFlag) { + InitializeLBX(buf); + LookForLBXFlag = 0; + } + if (LookForWCPFlag) { + InitializeWCP(buf); + } + if (LookForRENDERFlag) { + InitializeRENDER(buf); + } + if (LookForRANDRFlag) { + InitializeRANDR(buf); + } + if (LookForMITSHMFlag) { + InitializeMITSHM(buf); + } + if (LookForBIGREQFlag) { + InitializeBIGREQ(buf); + } PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryExtension */ ; if (Verbose < 1) return; @@ -3299,7 +3547,7 @@ ListExtensions(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3331,7 +3579,7 @@ ChangeKeyboardMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, DVALUE1(n), "keycode-count"); n = IByte(&buf[1]); @@ -3351,7 +3599,7 @@ GetKeyboardMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 1, KEYCODE, "first-keycode"); @@ -3382,7 +3630,7 @@ ChangeKeyboardControl(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(2 + n), "request length"); PrintField(buf, 4, 4, KEYBOARD_BITMASK, "value-mask"); @@ -3398,7 +3646,7 @@ GetKeyboardControl(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3430,7 +3678,7 @@ Bell(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, INT8, "percent"); printfield(buf, 2, 2, CONST2(1), "request length"); @@ -3445,7 +3693,7 @@ ChangePointerControl(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(3), "request length"); PrintField(buf, 4, 2, INT16, "acceleration-numerator"); @@ -3464,7 +3712,7 @@ GetPointerControl(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3492,7 +3740,7 @@ SetScreenSaver(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(3), "request length"); PrintField(buf, 4, 2, INT16, "timeout"); @@ -3510,7 +3758,7 @@ GetScreenSaver(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3540,7 +3788,7 @@ ChangeHosts(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, INS_DEL, "mode"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); @@ -3563,7 +3811,7 @@ ListHosts(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3593,7 +3841,7 @@ SetAccessControl(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, DIS_EN, "mode"); printfield(buf, 2, 2, CONST2(1), "request length"); @@ -3608,7 +3856,7 @@ SetCloseDownMode(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, CLOSEMODE, "mode"); printfield(buf, 2, 2, CONST2(1), "request length"); @@ -3623,7 +3871,7 @@ KillClient(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(2), "request length"); PrintField(buf, 4, 4, RESOURCEID, "resource"); @@ -3639,7 +3887,7 @@ RotateProperties(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, DVALUE2(3 + n), "request length"); PrintField(buf, 4, 4, WINDOW, "window"); @@ -3658,7 +3906,7 @@ ForceScreenSaver(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, SAVEMODE, "mode"); printfield(buf, 2, 2, CONST2(1), "request length"); @@ -3674,7 +3922,7 @@ SetPointerMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 1, 1, DVALUE1(n), "length of map"); n = IByte(&buf[1]); @@ -3703,7 +3951,7 @@ GetPointerMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3733,7 +3981,7 @@ SetModifierMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier"); n = IByte(&buf[1]); @@ -3769,7 +4017,7 @@ GetModifierMapping(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } @@ -3798,7 +4046,7 @@ NoOperation(buf) if (Verbose < 1) return; if (Verbose > 1) - PrintField(SBf, 0, 4, INT32, "sequence number"); + PrintField(SBf, 0, 4, CARD32, "sequence number"); printfield(buf, 2, 2, CONST2(1), "request length"); } diff --git a/print_bigreq.c b/print_bigreq.c new file mode 100644 index 0000000..230cee4 --- /dev/null +++ b/print_bigreq.c @@ -0,0 +1,53 @@ +/* + * $XFree86$ + * + * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "scope.h" +#include "x11.h" +#include "bigreqscope.h" + +BigreqEnable (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* BigreqRequest */ ; + PrintField (buf, 1, 1, BIGREQREQUEST, BIGREQREQUESTHEADER) /* BigreqSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +BigreqEnableReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* BigreqRequest reply */ ; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 4, CARD32, "max-request-size"); +} diff --git a/print_lbx.c b/print_lbx.c new file mode 100644 index 0000000..d758dd9 --- /dev/null +++ b/print_lbx.c @@ -0,0 +1,197 @@ +/* + * $NCDId$ + * + * Copyright 1992 Network Computing Devices + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of NCD. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. NCD. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, Network Computing Devices + */ + +#include "scope.h" +#include "x11.h" +#include "lbxscope.h" + +static unsigned long sequences[256]; +static unsigned char starting_server[256]; +static unsigned char starting_client[256]; +static int client_client, server_client; + +LbxQueryVersion (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +LbxQueryVersionReply (fd, buf) +register unsigned char *buf; +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LbxRequest reply */ ; + PrintField(RBf, 1, 1, LBXREPLY, LBXREPLYHEADER) /* LbxQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 2, CARD16, "major-version"); + PrintField(buf, 10, 2, CARD16, "minor-version"); +} + +LbxStartProxy (fd, buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +LbxStopProxy (fd, buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +LbxNewClient (fd, buf) +register unsigned char *buf; +{ + unsigned long c; + + c = ILong(&buf[4]); + starting_client[c] = 1; + starting_server[c] = 1; + sequences[c] = 0; + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, CARD32, "new-client-id"); +} + +LbxCloseClient (fd, buf) + unsigned char *buf; +{ +} + +long StartSetUpMessage (); +long StartSetUpReply (); + +LbxSwitch (fd, buf) +register unsigned char *buf; +{ + unsigned long c; + c = ILong(&buf[4]); + CS[fd].SequenceNumber--; + sequences[client_client] = CS[fd].SequenceNumber; + if (starting_client[c]) + { + CS[fd].ByteProcessing = StartSetUpMessage; + CS[fd].NumberofBytesNeeded = 12; + starting_client[c] = 0; + } + CS[fd].SequenceNumber = sequences[c]; + client_client = c; + + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, CARD32, "client number"); +} + +LbxModifySequence (fd, buf) + unsigned char *buf; +{ + int mod; + + mod = ILong(&buf[4]); + CS[fd].SequenceNumber += mod; + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* LbxRequest */ ; + PrintField (buf, 1, 1, LBXREQUEST, LBXREQUESTHEADER) /* LbxModifySequence */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + printfield(buf, 4, 4, INT32, "adjustment"); +} + +LbxSwitchEvent (fd, buf) + unsigned char *buf; +{ + unsigned long c; + + c = ILong(&buf[4]); + if (starting_server[c]) + { + CS[fd].ByteProcessing = StartSetUpReply; + CS[fd].NumberofBytesNeeded = 8; + starting_server[c] = 0; + } + + PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LbxEvent */ ; + PrintField(buf, 1, 1, LBXEVENT, LBXEVENTHEADER) /* LbxSwitchEvent */ ; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, CARD32, "client"); +} + +LbxCloseEvent (fd, buf) + unsigned char *buf; +{ + PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* LbxEvent */ ; + PrintField(buf, 1, 1, LBXEVENT, LBXEVENTHEADER) /* LbxSwitchEvent */ ; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, CARD32, "client"); +} diff --git a/print_pex.c b/print_pex.c new file mode 100644 index 0000000..8929d90 --- /dev/null +++ b/print_pex.c @@ -0,0 +1,917 @@ +/* $XConsortium: print_pex.c,v 5.4 91/02/17 12:34:48 rws Exp $ */ + +/*********************************************************** +Copyright (c) 1989, 1990, 1991 by Sun Microsystems, Inc. and the X Consortium. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the names of Sun Microsystems, +the X Consortium, and MIT not be used in advertising or publicity +pertaining to distribution of the software without specific, written +prior permission. + +SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT +SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +******************************************************************/ + +#include <stdio.h> +#include <X11/X.h> +#include <X11/extensions/PEX.h> +#include <X11/extensions/PEXproto.h> +#include "pexRNames.h" +#include "pexOCNames.h" +#include "pexscope.h" + + +#define PEX_CARD8 0 +#define PEX_CARD16 1 +#define PEX_CARD32 2 +#define PEX_ENUM 3 +#define PEX_FP_FORMAT 4 +#define PEX_STRING 5 +#define PEX_DRAWABLE 6 + +Nothing(buf) +register unsigned char *buf; +{ +} + +GetExtensionInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetExtensionInfo,buf); + pex_print(buf,4,2,PEX_CARD16," Protocol Major Version"); + pex_print(buf,6,2,PEX_CARD16," Protocol Minor Version"); +} + +GetExtensionInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetExtensionInfo,buf); + pex_print(buf,8,2,PEX_CARD16," Protocol Major Version"); + pex_print(buf,10,2,PEX_CARD16," Protocol Minor Version"); + pex_print(buf,12,4,PEX_CARD32,"\t Release Number"); + pex_print(buf,16,4,PEX_CARD32," Length of Vendor Name"); + pex_print(buf,20,4,PEX_CARD32,"\t\tSubset info"); +} + +GetEnumeratedTypeInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetEnumeratedTypeInfo,buf); + pex_print(buf,4,4,PEX_DRAWABLE,"\t Drawable Id"); +} + +GetEnumeratedTypeInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetEnumeratedTypeInfo,buf); +} + +GetImpDepConstants(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetImpDepConstants,buf); +} + +GetImpDepConstantsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetImpDepConstants,buf); +} + +CreateLookupTable(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreateLookupTable,buf); +} + +CopyLookupTable(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopyLookupTable,buf); +} + +FreeLookupTable(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreeLookupTable,buf); +} + +GetTableInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetTableInfo,buf); +} + +GetTableInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetTableInfo,buf); +} + +GetPredefinedEntries(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetPredefinedEntries,buf); +} + +GetPredefinedEntriesReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetPredefinedEntries,buf); +} + +GetDefinedIndices(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetDefinedIndices,buf); +} + +GetDefinedIndicesReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetDefinedIndices,buf); +} + +GetTableEntry(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetTableEntry,buf); +} + +GetTableEntryReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetTableEntry,buf); +} + +GetTableEntries(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetTableEntries,buf); +} + +GetTableEntriesReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetTableEntries,buf); +} + +SetTableEntries(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetTableEntries,buf); +} + +DeleteTableEntries(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(DeleteTableEntries,buf); +} + +CreatePipelineContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreatePipelineContext,buf); +} + +CopyPipelineContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopyPipelineContext,buf); +} + +FreePipelineContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreePipelineContext,buf); +} + +GetPipelineContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetPipelineContext,buf); +} + +GetPipelineContextReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetPipelineContext,buf); +} + +ChangePipelineContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangePipelineContext,buf); +} + +CreateRenderer(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreateRenderer,buf); +} + +FreeRenderer(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreeRenderer,buf); +} + +ChangeRenderer(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangeRenderer,buf); +} + +GetRendererAttributes(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetRendererAttributes,buf); +} + +GetRendererAttributesReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetRendererAttributes,buf); +} + +BeginRendering(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(BeginRendering,buf); +} + +EndRendering(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(EndRendering,buf); +} + +BeginStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(BeginStructure,buf); +} + +EndStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(EndStructure,buf); +} + +RenderOutputCommands(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(RenderOutputCommands,buf); +} + +RenderNetwork(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(RenderNetwork,buf); +} + +CreateStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreateStructure,buf); +} + +CopyStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopyStructure,buf); +} + +GetRendererDynamics(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetRendererDynamics,buf); +} + +GetRendererDynamicsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetRendererDynamics,buf); +} + +DestroyStructures(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(DestroyStructures,buf); +} + +GetStructureInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetStructureInfo,buf); +} + +GetStructureInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetStructureInfo,buf); +} + +GetElementInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetElementInfo,buf); +} + +GetElementInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetElementInfo,buf); +} + +GetStructuresInNetwork(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetStructuresInNetwork,buf); +} + +GetStructuresInNetworkReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetStructuresInNetwork,buf); +} + +GetAncestors(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetAncestors,buf); +} + +GetAncestorsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetAncestors,buf); +} + +GetDescendants(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetDescendants,buf); +} + +GetDescendantsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetDescendants,buf); +} + +FetchElements(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FetchElements,buf); +} + +FetchElementsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(FetchElements,buf); +} + +SetEditingMode(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetEditingMode,buf); +} + +SetElementPointer(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetElementPointer,buf); +} + +SetElementPointerAtLabel(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetElementPointerAtLabel,buf); +} + +ElementSearch(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ElementSearch,buf); +} + +ElementSearchReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(ElementSearch,buf); +} + +StoreElements(buf) +unsigned char *buf; +{ + pexStoreElementsReq *req_ptr = (pexStoreElementsReq *)buf; + CARD32 num_cmds = req_ptr->numCommands; + PEX_DECODE_REQUEST(StoreElements,buf); + buf += sizeof(pexStoreElementsReq); + pex_decode_elem(num_cmds, (unsigned char *)(buf)); +} + +DeleteElements(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(DeleteElements,buf); +} + +DeleteElementsToLabel(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(DeleteElementsToLabel,buf); +} + +DeleteBetweenLabels(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(DeleteBetweenLabels,buf); +} + +CopyElements(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopyElements,buf); +} + +ChangeStructureRefs(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangeStructureRefs,buf); +} + +CreateNameSet(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreateNameSet,buf); +} + +CopyNameSet(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopyNameSet,buf); +} + +FreeNameSet(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreeNameSet,buf); +} + +GetNameSet(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetNameSet,buf); +} + +GetNameSetReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetNameSet,buf); +} + +ChangeNameSet(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangeNameSet,buf); +} + +CreateSearchContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreateSearchContext,buf); +} + +CopySearchContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CopySearchContext,buf); +} + +FreeSearchContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreeSearchContext,buf); +} + +GetSearchContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetSearchContext,buf); +} + +GetSearchContextReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetSearchContext,buf); +} + +ChangeSearchContext(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangeSearchContext,buf); +} + +SearchNetwork(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SearchNetwork,buf); +} + +SearchNetworkReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(SearchNetwork,buf); +} + +CreatePhigsWks(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreatePhigsWks,buf); +} + +FreePhigsWks(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreePhigsWks,buf); +} + +GetWksInfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetWksInfo,buf); +} + +GetWksInfoReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetWksInfo,buf); +} + +GetDynamics(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetDynamics,buf); +} + +GetDynamicsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetDynamics,buf); +} + +GetViewRep(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetViewRep,buf); +} + +GetViewRepReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetViewRep,buf); +} + +RedrawAllStructures(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(RedrawAllStructures,buf); +} + +UpdateWorkstation(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(UpdateWorkstation,buf); +} + +ExecuteDeferredActions(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ExecuteDeferredActions,buf); +} + +SetViewPriority(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetViewPriority,buf); +} + +SetDisplayUpdateMode(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetDisplayUpdateMode,buf); +} + +MapDCtoWC(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(MapDCtoWC,buf); +} + +MapDCtoWCReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(MapDCtoWC,buf); +} + +MapWCtoDC(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(MapWCtoDC,buf); +} + +MapWCtoDCReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(MapWCtoDC,buf); +} + +SetViewRep(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetViewRep,buf); +} + +SetWksWindow(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetWksWindow,buf); +} + +SetWksViewport(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetWksViewport,buf); +} + +SetHlhsrMode(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(SetHlhsrMode,buf); +} + +PostStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(PostStructure,buf); +} + +UnpostStructure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(UnpostStructure,buf); +} + +UnpostAllStructures(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(UnpostAllStructures,buf); +} + +GetWksPostings(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetWksPostings,buf); +} + +GetWksPostingsReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetWksPostings,buf); +} + +GetPickDevice(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetPickDevice,buf); +} + +GetPickDeviceReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetPickDevice,buf); +} + +ChangePickDevice(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ChangePickDevice,buf); +} + +CreatePickMeasure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CreatePickMeasure,buf); +} + +FreePickMeasure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(FreePickMeasure,buf); +} + +GetPickMeasure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(GetPickMeasure,buf); +} + +GetPickMeasureReply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(GetPickMeasure,buf); +} + +UpdatePickMeasure(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(UpdatePickMeasure,buf); +} + +pexopenfont(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(OpenFont,buf); +} + +pexclosefont(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(CloseFont,buf); +} + +pexqueryfont(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(QueryFont,buf); +} + +pexqueryfontreply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(QueryFont,buf); +} + +pexlistfonts(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ListFonts,buf); +} + +pexlistfontsreply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(ListFonts,buf); +} + +pexlistfontswithinfo(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(ListFontsWithInfo,buf); +} + +pexlistfontswithinforeply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(ListFontsWithInfo,buf); +} + +pexquerytextextents(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(QueryTextExtents,buf); +} + +pexquerytextextentsreply(buf) +register unsigned char *buf; +{ + PEX_DECODE_REPLY(QueryTextExtents,buf); +} + +RedrawClipRegion(buf) +register unsigned char *buf; +{ + PEX_DECODE_REQUEST(RedrawClipRegion,buf); +} + +/* + * PEX Error Printing procedures + */ +pexerror_colortype(buf) +register unsigned char *buf; +{ +} + +pexerror_rendererstate(buf) +register unsigned char *buf; +{ +} + +pexerror_floatingpointformat(buf) +register unsigned char *buf; +{ +} + +pexerror_label(buf) +register unsigned char *buf; +{ +} + +pexerror_lookuptable(buf) +register unsigned char *buf; +{ +} + +pexerror_nameset(buf) +register unsigned char *buf; +{ +} + +pexerror_path(buf) +register unsigned char *buf; +{ +} +pexerror_font(buf) +register unsigned char *buf; +{ +} + +pexerror_phigswks(buf) +register unsigned char *buf; +{ +} + +pexerror_pickmeasure(buf) +register unsigned char *buf; +{ +} + +pexerror_pipelinecontext(buf) +register unsigned char *buf; +{ +} + +pexerror_renderer(buf) +register unsigned char *buf; +{ +} + +pexerror_searchcontext(buf) +register unsigned char *buf; +{ +} + +pexerror_structure(buf) +register unsigned char *buf; +{ +} + +pexerror_outputcommand(buf) +register unsigned char *buf; +{ +} + + +pex_print(buf, start, length, field_type, name) + unsigned char *buf; + short start; + short length; + short field_type; + char *name; +{ + switch (field_type) { + case PEX_CARD8: + break; + case PEX_CARD16: + fprintf(stderr,"%s: %d\n",name,*((CARD16*)&buf[start])); + break; + case PEX_CARD32: + fprintf(stderr,"%s: %d\n",name,*((CARD32*)&buf[start])); + break; + case PEX_DRAWABLE: + fprintf(stderr,"%s: %d\n",name,*((Drawable*)&buf[start])); + break; + case PEX_ENUM: + break; + case PEX_FP_FORMAT: + break; + case PEX_STRING: + break; + default: + break; + } +} diff --git a/print_randr.c b/print_randr.c new file mode 100644 index 0000000..da2da74 --- /dev/null +++ b/print_randr.c @@ -0,0 +1,171 @@ +/* + * $XFree86$ + * + * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "scope.h" +#include "x11.h" +#include "randrscope.h" + +RandrQueryVersion (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ; + PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RandrQueryVersionReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ; + PrintField(RBf, 1, 1, RANDRREPLY, RANDRREPLYHEADER) /* RandrQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 2, CARD16, "major-version"); + PrintField(buf, 10, 2, CARD16, "minor-version"); +} +RandrGetScreenInfo (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ; + PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, WINDOW, "window"); +} + +RandrGetScreenInfoReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + unsigned short nsize; + unsigned short nvg; + unsigned short ngvg; + unsigned short i; + + 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"); +} + +RandrSetScreenConfig (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ; + PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, DRAWABLE, "drawable"); + PrintField(buf, 8, 4, TIMESTAMP, "timestamp"); + PrintField(buf,12, 4, TIMESTAMP, "config-timestamp"); + PrintField(buf,16, 2, CARD16, "size-id"); + PrintField(buf,18, 2, CARD16, "rotation"); + PrintField(buf,20, 2, CARD16, "visual-group-id"); +} + +RandrSetScreenConfigReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RandrRequest reply */ ; + PrintField(buf, 1, 1, BOOL, "success") /* RandrQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 4, TIMESTAMP, "new-timestamp"); + PrintField(buf,12, 4, TIMESTAMP, "new-config-timestamp"); + PrintField(buf,16, 4, WINDOW, "root"); +} + +RandrScreenChangeSelectInput (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RandrRequest */ ; + PrintField (buf, 1, 1, RANDRREQUEST, RANDRREQUESTHEADER) /* RandrSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, WINDOW, "window"); + PrintField(buf, 8, 1, BOOL, "enable"); +} + +RandrScreenSizes (buf) + unsigned char *buf; +{ + PrintField(buf, 0, 2, CARD16, "width-in-pixels"); + PrintField(buf, 2, 2, CARD16, "height-in-pixels"); + PrintField(buf, 4, 2, CARD16, "width-in-millimeters"); + PrintField(buf, 6, 2, CARD16, "height-in-millimeters"); + PrintField(buf, 8, 2, CARD16, "visual-group"); +} + +RandrScreenChangeNotifyEvent(buf) + unsigned char *buf; +{ + PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* RRScreenChangeNotify */ ; + if (Verbose < 1) + return; + PrintField(buf, 1, 1, BOOL, "resident"); + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, TIMESTAMP, "timestamp"); + PrintField(buf, 8, 4, TIMESTAMP, "config-timestamp"); + PrintField(buf,12, 4, WINDOW, "root"); + PrintField(buf,16, 2, CARD16, "size id"); + PrintField(buf,18, 2, CARD16, "rotation"); + RandrScreenSizes (buf + 20); +} diff --git a/print_render.c b/print_render.c new file mode 100644 index 0000000..fa56d17 --- /dev/null +++ b/print_render.c @@ -0,0 +1,589 @@ +/* + * $XFree86$ + * + * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "scope.h" +#include "x11.h" +#include "renderscope.h" + +RenderQueryVersion (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderQueryVersionReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ; + PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 2, CARD16, "major-version"); + PrintField(buf, 10, 2, CARD16, "minor-version"); +} +RenderQueryPictFormats (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderQueryPictFormatsReply (FD fd, unsigned char *buf) +{ + long n; + long f; + long s; + long d; + long v; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ; + PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + 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"); +} +RenderQueryPictIndexValues (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderQueryPictIndexValuesReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ; + PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); +} +RenderQueryDithers (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderQueryDithersReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* RenderRequest reply */ ; + PrintField(RBf, 1, 1, RENDERREPLY, RENDERREPLYHEADER) /* RenderQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); +} +RenderCreatePicture (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, DVALUE2(5+n), "request length"); + PrintField(buf, 4, 4, PICTURE, "picture"); + PrintField(buf, 8, 4, DRAWABLE, "drawable"); + PrintField(buf, 12, 4, PICTFORMAT, "format"); + PrintField(buf, 16, 4, PICTURE_BITMASK, "value-mask"); + PrintValues(&buf[16], 4, PICTURE_BITMASK, &buf[20], "value-list"); +} +RenderChangePicture (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, DVALUE2(3+n), "request length"); + PrintField(buf, 4, 4, PICTURE, "picture"); + PrintField(buf, 8, 4, PICTURE_BITMASK, "value-mask"); + PrintValues(&buf[8], 4, PICTURE_BITMASK, &buf[12], "value-list"); +} +RenderSetPictureClipRectangles (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderFreePicture (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderComposite (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderScale (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderTrapezoids (FD fd, unsigned char *buf) +{ + int n; + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + 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"); +} + +RenderTriangles (FD fd, 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"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + 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"); +} +RenderTriStrip (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderTriFan (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderColorTrapezoids (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderColorTriangles (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderTransform (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderCreateGlyphSet (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, GLYPHSET, "glyphset"); + PrintField(buf, 8, 4, PICTFORMAT, "format"); +} +RenderReferenceGlyphSet (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} +RenderFreeGlyphSet (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, GLYPHSET, "glyphset"); +} +extern char Leader[]; + +void +PrintGlyphs(unsigned char *buf, int n, char *name) +{ + unsigned char *gids; + 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; + } +} + +RenderAddGlyphs (FD fd, unsigned char *buf) +{ + long n; + long i; + long g; + long nb; + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + PrintField(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, GLYPHSET, "glyphset"); + PrintField(buf, 8, 4, CARD32, "nglyphs"); + PrintGlyphs(&buf[12], ILong(&buf[8]), "glyphs"); +} +RenderAddGlyphsFromPicture (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + +} +RenderFreeGlyphs (FD fd, unsigned char *buf) +{ + 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"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, GLYPHSET, "glyphset"); + n = (IShort(&buf[2]) - 2); + (void)PrintList(&buf[8], (long)n, CARD32, "glyphs"); +} + +extern char Leader[]; + +void +PrintGlyphList(unsigned char *buf, int length, char *name, int size) +{ + short n; + + fprintf(stdout, "%s%20s:\n", Leader, name); + while (length >= 8) + { + n = IByte(&buf[0]); + if (n != 255) + { + printfield(buf, 0, 1, CARD8, "length"); + PrintField(buf, 4, 2, INT16, "delta x"); + PrintField(buf, 6, 2, INT16, "delta y"); + switch (size) { + case 1: + PrintTString8(&buf[8], (long) n, "glyph item 8 string"); break; + case 2: + PrintTString16(&buf[8], (long) n, "glyph item 16 string"); break; + case 4: + break; + } + n = ((n * size + 8) + 3) & ~3; + buf += n; + length -= n; + } + else + { + PrintField(buf, 8, 4, GLYPHSET, "glyphset"); + buf += 12; + length -= 12; + } + } +} + +RenderCompositeGlyphs8 (FD fd, unsigned char *buf) +{ + int n; + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + n = (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); +} + +RenderCompositeGlyphs16 (FD fd, unsigned char *buf) +{ + int n; + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + n = (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); +} +RenderCompositeGlyphs32 (FD fd, unsigned char *buf) +{ + int n; + + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + n = (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); +} +RenderFillRectangles (FD fd, unsigned char *buf) +{ + int n; + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* RenderRequest */ ; + PrintField (buf, 1, 1, RENDERREQUEST, RENDERREQUESTHEADER) /* RenderSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + n = (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"); +} +RenderPictFormatError (fd, 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"); +} + +RenderPictureError (fd, 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"); +} + +RenderPictOpError (fd, 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"); +} + +RenderGlyphSetError (fd, 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"); +} + +RenderGlyphError (fd, 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..e5a5b3e --- /dev/null +++ b/print_shm.c @@ -0,0 +1,171 @@ +/* + * $XFree86$ + * + * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Keith Packard not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Keith Packard makes no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#include "scope.h" +#include "x11.h" +#include "shmscope.h" + +MitshmQueryVersion (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +MitshmQueryVersionReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* MitshmRequest reply */ ; + if (Verbose < 1) + return; + PrintField(RBf, 1, 1, BOOL, "shared-pixmaps") /* shared Pixmaps */; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 2, CARD16, "major-version"); + PrintField(buf, 10, 2, CARD16, "minor-version"); + PrintField(buf, 12, 2, CARD16, "uid"); + PrintField(buf, 14, 2, CARD16, "gid"); + PrintField(buf, 16, 1, CARD8, "pxiamp-fromat"); +} +MitshmAttach (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, CARD32, "shmseg"); + PrintField(buf, 8, 4, CARD32, "shmid"); + PrintField(buf, 12, 1, BOOL, "read-only"); +} + +MitshmDetach (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField (buf, 4, 4, CARD32, "shmseg"); +} + +MitshmPutImage (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField (buf, 4, 4, DRAWABLE, "drawable"); + PrintField (buf, 8, 4, GCONTEXT, "gc"); + PrintField (buf, 12, 2, CARD16, "total-width"); + PrintField (buf, 14, 2, CARD16, "total-width"); + PrintField (buf, 16, 2, CARD16, "src-x"); + PrintField (buf, 18, 2, CARD16, "src-y"); + PrintField (buf, 20, 2, CARD16, "src-width"); + PrintField (buf, 22, 2, CARD16, "src-height"); + PrintField (buf, 24, 2, INT16, "dst-x"); + PrintField (buf, 26, 2, INT16, "dst-y"); + PrintField (buf, 28, 1, CARD8, "depth"); + PrintField (buf, 29, 1, CARD8, "format"); + PrintField (buf, 30, 1, BOOL, "send-event"); + PrintField (buf, 31, 1, CARD8, "bpad"); + PrintField (buf, 32, 4, CARD32, "shmseg"); + PrintField (buf, 36, 4, CARD32, "offset"); +} + +MitshmGetImage (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, DVALUE2(5+n), "request length"); + PrintField (buf, 4, 4, DRAWABLE, "drawable"); + PrintField (buf, 8, 2, INT16, "x"); + PrintField (buf, 10, 2, INT16, "y"); + PrintField (buf, 12, 2, CARD16, "width"); + PrintField (buf, 14, 2, CARD16, "height"); + PrintField (buf, 16, 4, CARD32, "planemask"); + PrintField (buf, 20, 1, CARD8, "format"); + PrintField (buf, 24, 4, CARD32, "shmseg"); + PrintField (buf, 28, 4, CARD32, "shmseg"); +} + +MitshmGetImageReply (FD fd, unsigned char *buf) +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* MitshmRequest reply */ ; + if (Verbose < 1) + return; + PrintField(RBf, 1, 1, CARD8, "depth") /* shared Pixmaps */; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 4, VISUALID, "visual"); +} + +MitshmCreatePixmap (FD fd, unsigned char *buf) +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* MitshmRequest */ ; + PrintField (buf, 1, 1, MITSHMREQUEST, MITSHMREQUESTHEADER) /* MitshmSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, DVALUE2(3+n), "request length"); + PrintField(buf, 4, 4, PIXMAP, "pid"); + PrintField(buf, 8, 4, DRAWABLE, "drawable"); + PrintField(buf, 12, 2, CARD16, "width"); + PrintField(buf, 14, 2, CARD16, "height"); + PrintField(buf, 16, 1, CARD8, "depth"); + PrintField(buf, 20, 4, CARD32, "shmseg"); + PrintField(buf, 24, 4, CARD32, "offset"); +} +MitshmShmSegError (fd, buf) +{ +} diff --git a/print_wcp.c b/print_wcp.c new file mode 100644 index 0000000..e86158f --- /dev/null +++ b/print_wcp.c @@ -0,0 +1,465 @@ +/* + * $NCDOr: print_wcp.c,v 1.1 1996/07/18 23:26:38 keithp Exp keithp $ + * + * Copyright 1996 Network Computing Devices + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of NCD. not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. NCD. makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * NCD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NCD. + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Keith Packard, Network Computing Devices + */ + +#include "scope.h" +#include "x11.h" +#include "wcpscope.h" + +WcpQueryVersion (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +WcpQueryVersionReply (fd, buf) +register unsigned char *buf; +{ + short n; + long m; + long k; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* WcpRequest reply */ ; + PrintField(RBf, 1, 1, WCPREPLY, WCPREPLYHEADER) /* WcpQueryVersion reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(0), "reply length"); + PrintField(buf, 8, 2, CARD16, "major-version"); + PrintField(buf, 10, 2, CARD16, "minor-version"); +} + +#define NextByte(dst) if (!len--) { error = "Out of data"; break; } dst = *data++; + +extern char Leader[]; + +WcpAnalyzeImage1RLL (buf, len, width, height) + char *buf; + int len; + int width; + int height; +{ + unsigned char byte; + unsigned char *data = (unsigned char *) buf; + int x, y; + char *error = 0; + int bytewidth; + int i; + int w; + + y = 0; + bytewidth = (width + 7) >> 3; + while (!error && height--) + { + x = 0; + if (Verbose > 2) + fprintf (stdout, "%s %9d %9d:", Leader, y, (char *) data - buf); + NextByte (byte); + if (Verbose > 2) + fprintf (stdout, " %2x", byte); + switch (byte) { + case 0xff: + for (i = 0; i < bytewidth; i++) + { + NextByte(byte); + } + break; + default: + w = width; + while (w) + { + NextByte(byte); + if (Verbose > 2) + fprintf (stdout, " %3d", byte); + if (byte > w) + { + error = "bad run"; + break; + } + x += byte; + w -= byte; + } + break; + } + if (Verbose > 2) + fprintf (stdout, "\n"); + y++; + } + if (error) + fprintf (stdout, "%s%20s: %d, %d %d\n", Leader, error, + x, y - 1, (char *) data - buf); +} + +WcpAnalyzeImageNRLL (buf, len, width, height, bytes) + char *buf; + int len; + int width; + int height; + int bytes; +{ +} + +#define MAX_LRU_SHORT 0xe +#define LRU_LONG 0xf +#define MAX_LRU_RUN (MAX_LRU_SHORT + 0xff) + +#define LRU_CACHE 0xf +#define LRU_MISS 0xf + +typedef unsigned long PIXEL; + +static void +init_cache (cache, BPP) + PIXEL cache[LRU_CACHE]; + int BPP; +{ + int e; + + /* + * initialize cache values + */ + for (e = 0; e < 8; e++) + { + cache[e] = e; + cache[LRU_CACHE-e-1] = ((1 << BPP) - 1) - e; + } +} + +static void +push (cache, pixel) + PIXEL cache[LRU_CACHE]; + PIXEL pixel; +{ + int e; + + e = LRU_CACHE - 1; + while (--e >= 0) + cache[e+1] = cache[e]; + cache[0] = pixel; +} + +static PIXEL +use (cache, e) + PIXEL cache[LRU_CACHE]; + int e; +{ + PIXEL tmp; + + tmp = cache[e]; + if (e) + { + while (--e >= 0) + cache[e+1] = cache[e]; + cache[0] = tmp; + } + return tmp; +} + +static int +match (cache, pixel) + PIXEL cache[LRU_CACHE]; + PIXEL pixel; +{ + int e; + + for (e = 0; e < LRU_CACHE; e++) + if (cache[e] == pixel) + { + use (cache, e); + return e; + } + push (cache, pixel); + return LRU_MISS; +} + +WcpAnalyzeImageNLRU (buf, len, width, height, bytes) + char *buf; + int len; + int width; + int height; + int bytes; +{ + unsigned char *data = (unsigned char *) buf; + unsigned char byte; + int x, y; + int w; + int i; + int bytewidth; + int cache; + unsigned long run; + PIXEL lru[LRU_CACHE]; + PIXEL pix; + char *error = 0; + + y = 0; + bytewidth = width * bytes; + while (!error && height--) + { + x = 0; + if (Verbose > 2) + fprintf (stdout, "%s %9d %9d:", Leader, y, (char *) data - buf); + NextByte (byte); + if (Verbose > 2) + fprintf (stdout, " %2x", byte); + switch (byte) { + case 0xff: + for (i = 0; i < bytewidth; i++) + { + NextByte (byte); + } + break; + default: + init_cache (lru, bytes * 8); + w = width; + while (w) + { + NextByte (byte); + run = byte >> 4; + cache = byte & 0xf; + if (run == LRU_LONG) + { + NextByte (byte); + run = (int) byte + MAX_LRU_SHORT; + } + run++; + if (cache == LRU_MISS) + { + pix = 0; + for (i = 0; i < bytes; i++) + { + pix = pix << 8; + NextByte (byte); + pix |= byte; + } + push (lru, pix); + } + else + { + pix = use (lru, cache); + } + w -= run; + if (w < 0) + { + error = "bad run"; + break; + } + x += run; + fprintf (stdout, " %3d:%0*x", run, bytes * 2, pix); + } + break; + } + if (Verbose > 2) + fprintf (stdout, "\n"); + y++; + } + if (error) + fprintf (stdout, "%s%20s: %d, %d %d\n", Leader, error, + x, y - 1, (char *) data - buf); +} + +WcpAnalyzeImage (buf, len, depth, encoding, width, height) + char *buf; + int len; + int depth; + int encoding; + int width; + int height; +{ + int bytes; + + bytes = depth / 8; + switch (depth) { + case 1: + switch (encoding) { + case 1: + case 2: + case 3: + case 4: + WcpAnalyzeImage1RLL (buf, len, width, height); + return; + default: + break; + } + break; + case 4: + switch (encoding) { + case 1: + case 2: + case 3: + case 4: + default: + break; + } + break; + case 8: + case 16: + case 24: + switch (encoding) { + case 1: + case 2: + case 3: + WcpAnalyzeImageNRLL (buf, len, width, height, bytes); + return; + case 4: + WcpAnalyzeImageNLRU (buf, len, width, height, bytes); + return; + default: + break; + } + break; + } + fprintf (stdout, "%s%20s: ", Leader, "invalid"); + fprintf (stdout, "encoding %d depth %d\n", encoding, depth); +} + +WcpPutImage (fd, buf) + unsigned char *buf; +{ + int n; + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + n = (IShort(&buf[2]) - 7) * 4; + printfield(buf, 2, 2, DVALUE2(7 + (n + p) / 4), "request length"); + PrintField(buf, 4, 4, DRAWABLE, "drawable"); + PrintField(buf, 8, 4, GCONTEXT, "gc"); + if (Verbose > 2) + PrintValueRec (ILong(&buf[8]), + GC_function| + GC_plane_mask| + GC_foreground| + GC_background, + GC_BITMASK); + PrintField(buf, 12, 4, CARD32, "lut"); + PrintField(buf, 16, 2, INT16, "dst-x"); + PrintField(buf, 18, 2, INT16, "dst-y"); + PrintField(buf, 20, 2, CARD16, "width"); + PrintField(buf, 22, 2, CARD16, "height"); + PrintField(buf, 24, 1, CARD8, "depth"); + PrintField(buf, 25, 1, CARD8, "encoding"); + PrintField(buf, 26, 1, CARD8, "left-pad"); + WcpAnalyzeImage (&buf[28], (long) n, buf[24], buf[25], + IShort(&buf[20]) + buf[26], + IShort(&buf[22])); + PrintBytes(&buf[28], (long)n, "data"); +} + +WcpGetImage (fd, buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); + PrintField(buf, 4, 4, DRAWABLE, "drawable"); + PrintField(buf, 8, 4, CARD32, "lut"); + PrintField(buf, 12, 2, INT16, "x"); + PrintField(buf, 14, 2, INT16, "y"); + PrintField(buf, 16, 2, CARD16, "width"); + PrintField(buf, 18, 2, CARD16, "height"); + PrintField(buf, 20, 1, CARD8, "encoding"); +} + +WcpGetImageReply (fd, buf) +register unsigned char *buf; +{ + long n; + + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* WcpRequest reply */ ; + PrintField(RBf, 1, 1, WCPREPLY, WCPREPLYHEADER) /* WcpGetImage reply */; + if (Verbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4(n), "reply length"); + PrintField(buf, 8, 4, CARD32, "visual"); + n = ILong (&buf[4]) * 4; + PrintBytes (&buf[32], n, "data"); +} + +WcpCreateColorCursor (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +WcpCreateLut (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +WcpFreeLut (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} + +WcpCopyArea (fd, buf) +register unsigned char *buf; +{ + PrintField (buf, 0, 1, REQUEST, REQUESTHEADER) /* WcpRequest */ ; + PrintField (buf, 1, 1, WCPREQUEST, WCPREQUESTHEADER) /* WcpSwitch */ ; + if (Verbose < 1) + return; + if (Verbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + + printfield(buf, 2, 2, CONST2(2), "request length"); +} diff --git a/printnas.c b/printnas.c new file mode 100644 index 0000000..4ee29cc --- /dev/null +++ b/printnas.c @@ -0,0 +1,950 @@ +/* ************************************************** * + * * + * Request, Reply, Event, Error Printing * + * * + * James Peterson, 1988 * + * (c) Copyright MCC, 1988 * + * * + * ************************************************** */ + +#include "scope.h" +#include "nas.h" + + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +/* + In printing the contents of the fields of the X11 packets, some + fields are of obvious value, and others are of lesser value. To + control the amount of output, we generate our output according + to the level of Verbose-ness that was selected by the user. + + NasVerbose = 0 == Headers only, time and request/reply/... names. + + NasVerbose = 1 == Very useful content fields. + + NasVerbose = 2 == Almost everything. + + NasVerbose = 3 == Every single bit and byte. + +*/ + +/* + To aid in making the choice between level 1 and level 2, we + define the following define, which does not print relatively + unimportant fields. +*/ + +#define printfield(a,b,c,d,e) if (NasVerbose > 1) PrintField(a,b,c,d,e) + + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +PrintAudioSetUpMessage(buf) + unsigned char *buf; +{ + short n; + short d; + + enterprocedure("PrintSetUpMessage"); + if (NasVerbose < 1) + return; + SetIndentLevel(PRINTCLIENT); + PrintField(buf, 0, 1, BYTEMODE, "byte-order"); + PrintField(buf, 2, 2, CARD16, "major-version"); + PrintField(buf, 4, 2, CARD16, "minor-version"); + printfield(buf, 6, 2, DVALUE2(n), "length of name"); + n = IShort(&buf[6]); + printfield(buf, 8, 2, DVALUE2(d), "length of data"); + d = IShort(&buf[8]); + PrintString8(&buf[12], (long)n, "authorization-protocol-name"); + PrintString8(&buf[pad((long)(12+n))], (long)d, "authorization-protocol-data"); +} + +PrintAudioSetUpReply(buf) + unsigned char *buf; +{ + enterprocedure("PrintSetUpReply"); + SetIndentLevel(PRINTSERVER); + if (IByte(&buf[0])) + PrintSuccessfulAudioSetUpReply(buf); + else + PrintFailedAudioSetUpReply(buf); +} + +PrintFailedAudioSetUpReply(buf) + unsigned char *buf; +{ + short n; + + PrintField(buf, 0, 1, 0, "SetUp Failed"); + if (NasVerbose < 1) + return; + printfield(buf, 1, 1, DVALUE1(n), "length of reason in bytes"); + n = IByte(&buf[1]); + PrintField(buf, 2, 2, CARD16, "major-version"); + PrintField(buf, 4, 2, CARD16, "minor-version"); + printfield(buf, 6, 2, DVALUE2((n + p) / 4), "length of data"); + PrintString8(&buf[8], (long)n, "reason"); +} + +PrintSuccessfulAudioSetUpReply(buf) + unsigned char *buf; +{ + short v; + short n; + short m; + + if (NasVerbose < 1) + return; + PrintField(buf, 2, 2, CARD16, "protocol-major-version"); + PrintField(buf, 4, 2, CARD16, "protocol-minor-version"); + printfield(buf, 6, 2, DVALUE2(8 + 2*n + (v + p + m) / 4), "length of data"); + PrintField(buf, 8, 4, CARD32, "release-number"); + PrintField(buf, 12, 4, CARD32, "resource-id-base"); + PrintField(buf, 16, 4, CARD32, "resource-id-mask"); + PrintField(buf, 20, 2, CARD16, "min-sample-rate"); + PrintField(buf, 22, 2, CARD16, "max-sample-rate"); + printfield(buf, 24, 2, DVALUE2(v), "length of vendor"); + v = IShort(&buf[24]); + printfield(buf, 26, 2, CARD16, "maximum-request-length"); + printfield(buf, 28, 1, CARD8, "max-tracks"); + m = IByte(&buf[28]); + printfield(buf, 29, 1, DVALUE1(n), "number of audio formats"); + n = IByte(&buf[29]); + PrintField(buf, 30, 1, CARD8, "number of element-types"); + PrintField(buf, 31, 1, CARD8, "number of wave-forms"); + PrintField(buf, 32, 1, CARD8, "number of actions"); + PrintField(buf, 33, 1, CARD8, "number of devices"); + PrintField(buf, 34, 1, CARD8, "number of buckets"); + PrintField(buf, 35, 1, CARD8, "number of radios"); + PrintString8(&buf[36], (long)v, "vendor"); +} + + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +extern char *REQUESTHEADER; +extern char *EVENTHEADER; +extern char *ERRORHEADER; +extern char *REPLYHEADER; + + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +/* Error Printing procedures */ + +AudioRequestError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioValueError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, INT32, "bad value"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioMatchError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioAccessError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioAllocError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioIDChoiceError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, CARD32, "bad resource id"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioLengthError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +AudioImplementationError(buf) + unsigned char *buf; +{ + PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 8, 2, CARD16, "minor opcode"); + PrintField(buf, 10, 1, CARD8, "major opcode"); +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +/* Event Printing procedures */ + +AudioElementNotify (buf) + unsigned char *buf; +{ + PrintField(buf, 0, 1, NASEVENT, EVENTHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 1, 1, CARD8, "detail"); + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, TIMESTAMP, "time"); + PrintField(buf, 8, 4, CARD32, "flow"); + printfield(buf, 12, 2, CARD16, "element num"); + printfield(buf, 14, 2, CARD16, "kind"); + printfield(buf, 16, 2, CARD16, "prev state"); + printfield(buf, 18, 2, CARD16, "cur state"); + printfield(buf, 20, 2, CARD16, "reason"); + printfield(buf, 24, 4, CARD32, "num bytes"); +} + +AudioGrabNotify (buf) + unsigned char *buf; +{ +} + +AudioMonitorNotify (buf) + unsigned char *buf; +{ + PrintField(buf, 0, 1, NASEVENT, EVENTHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 1, 1, CARD8, "detail"); + printfield(buf, 2, 2, CARD16, "sequence number"); + PrintField(buf, 4, 4, TIMESTAMP, "time"); + PrintField(buf, 8, 4, CARD32, "flow"); + printfield(buf, 12, 2, CARD16, "element num"); + printfield(buf, 14, 1, CARD8, "format"); + printfield(buf, 15, 1, CARD8, "num tracks"); + printfield(buf, 16, 2, CARD16, "count"); + printfield(buf, 18, 2, CARD16, "num fields"); + PrintField(buf, 20, 4, CARD32, "data"); + PrintField(buf, 24, 4, CARD32, "date1"); + PrintField(buf, 28, 4, CARD32, "data2"); +} + +AudioBucketNotify (buf) + unsigned char *buf; +{ +} + +AudioDeviceNotify (buf) + unsigned char *buf; +{ +} + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + +/* Request and Reply Printing procedures */ + +UnknownAudioReply(buf) + unsigned char *buf; +{ + long n; + + PrintField(RBf, 0, 1, NASREPLY, REPLYHEADER); + PrintField(buf, 1, 1, CARD8, "data"); + printfield (buf, 2, 2, CARD16, "sequence number"); + printfield (buf, 4, 4, DVALUE4(n), "reply length"); + n = ILong (&buf[4]) + 6; + (void) PrintList (&buf[8], n, CARD32, "data"); +} + +AudioListDevices (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER) /* ListDevices */; + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListDevicesReply(buf) + unsigned char *buf; +{ + long n; + PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetWindowAttributes */ ; + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, CARD32, "reply length"); + printfield(buf, 8, 4, CARD32, "num devices"); + n = ILong(&buf[8]); +} + +static +AuString (buf) + unsigned char *buf; +{ + long n; + + printfield(buf, 0, 1, CARD8, "type"); + printfield(buf, 4, 4, CARD32, "length"); + n = ILong(&buf[8]); + PrintString8(&buf[8], n, "string"); + return 8 + pad(n); +} + +static +AuDeviceAttributes (buf) + unsigned char *buf; +{ + int l; + printfield(buf, 0, 4, CARD32, "value mask"); + printfield(buf, 4, 4, CARD32, "changable mask"); + printfield(buf, 8, 4, CARD32, "id"); + printfield(buf, 12, 1, CARD8, "kind"); + printfield(buf, 13, 1, CARD8, "use"); + printfield(buf, 14, 1, CARD8, "format"); + printfield(buf, 15, 1, CARD8, "num tracks"); + printfield(buf, 16, 4, CARD32, "access"); + l = 20 + AuString(&buf[20]); +} + +AudioGetDeviceAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetDeviceAttributesReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); + AuDeviceAttributes (&buf[32]); +} + +AudioSetDeviceAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); + printfield(buf, 4, 4, CARD32, "device"); + AuDeviceAttributes (&buf[8]); +} + +AudioCreateBucket (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioDestroyBucket (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListBuckets (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListBucketsReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioGetBucketAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetBucketAttributesReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetBucketAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioCreateRadio (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioDestroyRadio (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListRadios (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListRadiosReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioGetRadioAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetRadioAttributesReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetRadioAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioCreateFlow (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioDestroyFlow (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetFlowAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetFlowAttributesReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetFlowAttributes (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetElements (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetElementsReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetElements (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetElementStates (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioElementState (buf) + unsigned char *buf; +{ + printfield(buf, 0, 4, CARD32, "flow"); + printfield(buf, 4, 1, CARD8, "element number"); + printfield(buf, 5, 1, CARD8, "state"); +} + +AudioGetElementStatesReply (buf) + unsigned char *buf; +{ + int n, i; + int o; + + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); + n = ILong(&buf[8]); + o = 32; + for (i = 0; i < n; i++) + { + AudioElementState (buf+o); + o += 8; + } +} + +AudioSetElementStates (buf) + unsigned char *buf; +{ + int nstates, i; + int o; + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); + printfield(buf, 4, 4, CARD32, "number states"); + nstates = ILong(&buf[4]); + o = 8; + for (i = 0; i < nstates; i++) + { + AudioElementState (buf+o); + o += 8; + } +} + +AudioGetElementParameters (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetElementParametersReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetElementParameters (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioWriteElement (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); + printfield(buf, 4, 4, CARD32, "flow"); + printfield(buf, 8, 4, CARD32, "num bytes"); + printfield(buf, 12, 1, CARD8, "state"); +} + +AudioReadElement (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioReadElementReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioGrabComponent (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioUngrabComponent (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioSendEvent (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetAllowedUsers (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetAllowedUsersReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetAllowedUsers (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListExtensions (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioListExtensionsReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioQueryExtension (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioQueryExtensionReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioGetCloseDownMode (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetCloseDownModeReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioSetCloseDownMode (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioKillClient (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetServerTime (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} + +AudioGetServerTimeReply (buf) + unsigned char *buf; +{ + PrintField (RBf, 0, 1, NASREPLY, REPLYHEADER); + if (NasVerbose < 1) + return; + printfield(buf, 2, 2, CARD16, "sequence number"); + printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); +} + +AudioNoOperation (buf) + unsigned char *buf; +{ + PrintField (buf, 0, 1, NASREQUEST, REQUESTHEADER); + if (NasVerbose < 1) + return; + if (NasVerbose > 1) + PrintField(SBf, 0, 4, CARD32, "sequence number"); + printfield(buf, 2, 2, DVALUE2(8 + n), "request length"); +} @@ -7,7 +7,7 @@ void panic(char *s); void *Malloc(long n); void Free(void *p); void SetSignalHandling(void); -void SetUpConnectionSocket(int iport); +void SetUpConnectionSocket(int iport, int (*connectionFunc)()); /* decode11.c */ void InitReplyQ(void); void FlushReplyQ(FD fd); @@ -231,6 +231,7 @@ void GetModifierMappingReply(unsigned char *buf); void NoOperation(unsigned char *buf); /* prtype.c */ void SetIndentLevel(int which); +void DumpHexBuffer(unsigned char *buf, long n); 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); @@ -249,6 +250,8 @@ FD ServerHalf(FD fd); char *ClientName(FD fd); void NewConnection(FD fd); /* server.c */ +FD ConnectToServer(int report); +void ProcessBuffer(FD fd, unsigned char *buf, long n); void ReportFromClient(FD fd, unsigned char *buf, long n); void ReportFromServer(FD fd, unsigned char *buf, long n); void PrintTime(void); @@ -261,6 +264,8 @@ void StartClientConnection(FD fd); void StopClientConnection(FD fd); void StartServerConnection(FD fd); void StopServerConnection(FD fd); +long StartSetUpMessage(FD fd, unsigned char *buf, long n); +long StartSetUpReply(FD fd, unsigned char *buf, long n); /* table11.c */ void InitializeX11(void); @@ -55,7 +55,7 @@ #include "scope.h" #include "x11.h" -static void DumpHexBuffer(unsigned char *buf, long n); +extern int littleEndian; /* For each of the types we need a way to print that type. @@ -132,7 +132,7 @@ static char *printrep (c) */ #define MaxIndent 10 -static char Leader[MaxIndent + 1]; +char Leader[MaxIndent + 1]; static short CurrentLevel = 0; void @@ -203,7 +203,8 @@ PrintINT8(unsigned char *buf) short n = IByte (buf); if (n > 127) n = 256 - n; - return fprintf(stdout, "%d", n); + fprintf(stdout, "%d", n); + return 1; } int @@ -213,7 +214,8 @@ PrintINT16(unsigned char *buf) long n = IShort (buf); if (n > 32767) n = 65536 - n; - return fprintf(stdout, "%d", n); + fprintf(stdout, "%d", n); + return 2; } int @@ -221,7 +223,8 @@ PrintINT32(unsigned char *buf) { /* print a INT32 -- 32-bit signed integer */ long n = ILong (buf); - return fprintf(stdout, "%d", n); + fprintf(stdout, "%d", n); + return 4; } /* ************************************************************ */ @@ -231,7 +234,8 @@ PrintCARD8(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 @@ -239,7 +243,8 @@ PrintCARD16(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 @@ -276,10 +281,10 @@ PrintCHAR8(unsigned char *buf) int PrintSTRING16(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 @@ -315,11 +320,12 @@ PrintWINDOWD(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 @@ -328,11 +334,12 @@ PrintWINDOWNR(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; } @@ -342,9 +349,10 @@ PrintPIXMAP(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 %08x", n); + return 4; } int @@ -353,11 +361,12 @@ PrintPIXMAPNPR(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 @@ -366,9 +375,10 @@ PrintPIXMAPC(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; } @@ -378,9 +388,10 @@ PrintCURSOR(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 %08x", n); + return 4; } @@ -390,9 +401,10 @@ PrintFONT(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 %08x", n); + return 4; } @@ -401,7 +413,8 @@ PrintGCONTEXT(unsigned char *buf) { /* print a GCONTEXT -- CARD32 */ long n = ILong (buf); - return fprintf(stdout, "GXC %08x", n); + fprintf(stdout, "GXC %08x", n); + return 4; } @@ -423,9 +436,10 @@ PrintCOLORMAPC(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; } @@ -434,7 +448,8 @@ PrintDRAWABLE(unsigned char *buf) { /* print a DRAWABLE -- CARD32 */ long n = ILong (buf); - return fprintf(stdout, "DWB %08x", n); + fprintf(stdout, "DWB %08x", n); + return 4; } int @@ -442,7 +457,8 @@ PrintFONTABLE(unsigned char *buf) { /* print a FONTABLE -- CARD32 */ long n = ILong (buf); - return fprintf(stdout, "FTB %08x", n); + fprintf(stdout, "FTB %08x", n); + return 4; } /* ************************************************************ */ @@ -489,9 +505,10 @@ PrintATOMT(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; } @@ -501,9 +518,10 @@ PrintVISUALID(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 %08x", n); + return 4; } int @@ -512,9 +530,10 @@ PrintVISUALIDC(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; } @@ -524,9 +543,10 @@ PrintTIMESTAMP(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 %08x", n); + return 4; } @@ -536,9 +556,10 @@ PrintRESOURCEID(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 %08x", n); + return 4; } @@ -566,9 +587,10 @@ PrintKEYCODEA(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; } @@ -577,7 +599,8 @@ PrintBUTTON(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 @@ -586,9 +609,10 @@ PrintBUTTONA(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; } @@ -599,6 +623,7 @@ PrintEVENTFORM(unsigned char *buf) { /* print an EVENT_FORM -- event format */ DecodeEvent(-1, buf, (long)-1); + return 32; } /* ************************************************************ */ @@ -624,9 +649,9 @@ 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** (%d)", n); } /* ************************************************************ */ @@ -674,9 +699,9 @@ PrintSET( } if (MatchesAll) - return fprintf(stdout, "<ALL>"); + fprintf(stdout, "<ALL>"); else if (!FoundOne) - return fprintf(stdout, "0"); + fprintf(stdout, "0"); } @@ -693,6 +718,9 @@ PrintField(buf, start, length, FieldType, name) short FieldType; char *name; { + if (Verbose == 0) + return; + if (length == 0) return; @@ -894,7 +922,7 @@ PrintString16( int number, char *name) { - short i; + long i; unsigned short c; if (number == 0) @@ -903,7 +931,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 +939,55 @@ PrintString16( return(number); } +extern long TranslateText; + +PrintTString8(buf, number, name) + unsigned char buf[]; + long number; + char *name; +{ + long i; + int off; + + if (number == 0) + return; + + off = 0; + if (TranslateText) + off = 0x20; + fprintf(stdout, "%s%20s: \"", Leader, name); + for (i = 0; i < number; i++) + fprintf(stdout, "%s", printrep(buf[i] + off)); + fprintf(stdout, "\"\n"); +} + + +/* print a String of CHAR2B -- 16-bit characters */ + +PrintTString16(buf, number, name) + unsigned char buf[]; + long number; + char *name; +{ + long i; + unsigned short c; + int off; + + if (number == 0) + return; + + off = 0; + if (TranslateText) + off = 0x20; + fprintf(stdout, "%s%20s: \"", Leader, name); + for (i = 0; i < number; i += 2) + { + c = IChar2B(&buf[i]); + fprintf(stdout, "%s", printrep(c + off)); + } + fprintf(stdout, "\"\n"); +} + /* ************************************************************ */ /* */ /* */ @@ -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; } @@ -987,15 +1068,15 @@ 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; } } } @@ -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, long n) { - short i; + long i; short column; char h[6] /* one hex or octal character */ ; @@ -1062,3 +1143,40 @@ DumpHexBuffer( column += 3; } } + +PrintValueRec (key, cmask, ctype) + unsigned long key; + unsigned long cmask; + short ctype; +{ + unsigned char *values; + struct ValueListEntry *p; + ValuePtr value; + + value = GetValueRec (key); + if (!value) + return; + values = (unsigned char *) value->values; + + /* now if it is zero, ignore and return */ + if (cmask == 0) + return; + + /* there are bits in the controlling bitmask, figure out which */ + /* the ctype is a set type, so this code is similar to PrintSET */ + ModifyIndentLevel(1); + for (p = TD[ctype].ValueList; p != NULL; p = p->Next) + { + if ((p->Value & cmask) != 0) + { + short m; + if (littleEndian) + m=0; + else + m = 4 - p->Length; + PrintField(values, m, p->Length, p->Type, p->Name); + } + values += 4; + } + ModifyIndentLevel(-1); +} diff --git a/randrscope.h b/randrscope.h new file mode 100644 index 0000000..bb95728 --- /dev/null +++ b/randrscope.h @@ -0,0 +1,16 @@ +#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) + +#endif + diff --git a/renderscope.h b/renderscope.h new file mode 100644 index 0000000..a539c1e --- /dev/null +++ b/renderscope.h @@ -0,0 +1,16 @@ +#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) + +#endif + @@ -55,9 +55,7 @@ #include "scope.h" -#include <errno.h> #include <unistd.h> -#include <netdb.h> #include <sys/param.h> #ifdef SYSV @@ -65,13 +63,29 @@ #define bcopy(s,d,l) memmove(d,s,l) #endif +#include <sys/uio.h> /* for struct iovec, used by socket.h */ +#include <sys/socket.h> /* for AF_INET, SOCK_STREAM, ... */ +#include <sys/ioctl.h> /* for FIONCLEX, FIONBIO, ... */ +#ifdef SVR4 +#include <sys/filio.h> +#endif +#include <fcntl.h> +#include <netinet/in.h> /* struct sockaddr_in */ +#include <netinet/tcp.h> +#include <netdb.h> /* struct servent * and struct hostent * */ +#include <errno.h> /* for EINTR, EADDRINUSE, ... */ +extern int errno; + + +extern InitializePEX(); /* ********************************************** */ /* */ /* ********************************************** */ #define DefaultPort 6000 -static char ServerHostName[MAXHOSTNAMELEN]; + char ServerHostName[MAXHOSTNAMELEN]; + char AudioServerHostName[MAXHOSTNAMELEN]; long ServerBasePort = DefaultPort; static long ServerInPort = 1; static long ServerOutPort = 0; @@ -100,16 +114,562 @@ int decnet_server = 0; #endif static FD ConnectToClient(FD ConnectionSocket); -static FD ConnectToServer(int report); static void SetUpStdin(void); +long TranslateText = 0; +char ScopeEnabled = 1; +char HandleSIGUSR1 = 0; +char DoAudio = 0; +char TerminateClose = 0; +int Interrupt = 0; + +struct FDDescriptor *FDD = 0; +short MaxFD = 0; +short nFDsInUse = 0; +long ReadDescriptors = 0; +long WriteDescriptors = 0; +long BlockedReadDescriptors; +short HighestFD; + +short debuglevel = 0; +short Verbose = 0; +short XVerbose = 0; +short NasVerbose = 0; +int ScopePort = 0; +char *ScopeHost = 0; + + +typedef struct _BreakPoint { + struct _BreakPoint *next; + int number; + unsigned char request; + Boolean enabled; +} BP; + +typedef enum _CMDResult { CMDProceed, CMDDebug, CMDSyntax, CMDError } CMDResult; + +CMDResult CMDStep (); +CMDResult CMDCont (); +CMDResult CMDBreak (); +CMDResult CMDDelete (); +CMDResult CMDDisable (); +CMDResult CMDEnable (); +CMDResult CMDLevel (); +CMDResult CMDAudio (); +CMDResult CMDQuit (); +CMDResult CMDHelp (); + +typedef struct _CMDFunc { + char *name; + char *alias; + CMDResult (*func)(); + char *usage; + char *help; +} CMDFuncRec, *CMDFuncPtr; + +CMDFuncRec CMDFuncs[] = { + "audio", "a", CMDAudio, "[a]udio", + "Set audio output level\n", + "break", "b", CMDBreak, "[b]reak", + "Create breakpoints\n", + "cont", "c", CMDCont, "[c]ont", + "Continue scoping\n", + "delete", "del", CMDDelete, "[del]ete", + "Delete breakpoints\n", + "disable","d", CMDDisable, "[d]isable", + "Disable breakpoints\n", + "enable", "e", CMDEnable, "[e]nable", + "Enable breakpoints\n", + "help", "?", CMDHelp, "help", + "Print this list\n", + "level", "l", CMDLevel, "[l]evel", + "Set output level\n", + "quit", "q", CMDQuit, "[q]uit", + "Quit Xscope\n", + "step", "s", CMDStep, "[s]tep", + "Step trace one request\n", +}; + +#define NumCMDFuncs (sizeof CMDFuncs / sizeof CMDFuncs[0]) + +#ifndef FALSE +#define FALSE 0 +#define TRUE 1 +#endif + +static int +CMDStringToInt(s, v) + char *s; + int *v; +{ + int sign = 1; + + switch (*s) { + case '-': + sign = -1; + s++; + break; + case '+': + s++; + break; + } + + if (!strncmp (s, "0x", 2)) + { + sscanf (s + 2, "%x", v); + } + else if (*s == '0') + { + sscanf (s, "%o", v); + } + else if (isdigit (*s)) + { + sscanf (s, "%d", v); + } + else if (*s == '\'') + { + s++; + if (*s == '\\') { + s++; + switch (*s) { + case 'n': + *v = '\n'; + break; + case 't': + *v = '\t'; + break; + default: + *v = (int) *s; + break; + } + } else + *v = (int) *s; + s++; + if (*s != '\'') + return FALSE; + } + else + return FALSE; + *v *= sign; + return TRUE; +} + +static CMDFuncPtr +CMDStringToFunc (name) + char *name; +{ + int i; + for (i = 0; i < NumCMDFuncs; i++) + { + if (!strcmp (name, CMDFuncs[i].name) || + !strcmp (name, CMDFuncs[i].alias)) + { + return &CMDFuncs[i]; + } + } + return 0; +} + +static int +CMDSplitIntoWords(line, argv) + char *line; + char **argv; +{ + char quotechar; + int argc; + + argc = 0; + while (*line) { + while (isspace(*line)) + line++; + if (!*line) + break; + if (*line == '"') + { + quotechar = *line++; + *argv++ = line; + argc++; + while (*line && *line != quotechar) + line++; + if (*line) + *line++ = '\0'; + } + else + { + *argv++ = line; + argc++; + while (*line && !isspace(*line)) + line++; + if (*line) + *line++ = '\0'; + } + } + *argv = 0; + return argc; +} + +CMDResult +CMDHelp(argc, argv) + int argc; + char **argv; +{ + int i; + CMDFuncPtr func; + + if (argc == 1) + { + for (i = 0; i < NumCMDFuncs; i++) + printf("%-10s%s\n", CMDFuncs[i].name, CMDFuncs[i].usage); + } + else + { + for (i = 1; i < argc; i++) + { + func = CMDStringToFunc (argv[i]); + if (!func) + { + printf ("%-10s unknown command\n", argv[i]); + return CMDSyntax; + } + printf ("%-10s %s\n%s", func->name, func->usage, func->help); + } + } + return CMDDebug; +} + +static void +CMDSyntaxError(argc, argv) + int argc; + char **argv; +{ + printf("Syntax error in:"); + while (*argv) + printf(" %s", *argv++); + printf("\n"); +} + +void +ReadCommands () +{ + int argc; + char line[1024]; + char *argv[20]; + CMDResult result; + CMDFuncPtr func; + static int here; + + if (here) + return; + here = 1; + for (;;) { + printf ("> "); + if (!fgets (line, sizeof line, stdin)) + break; + argc = CMDSplitIntoWords(line, argv); + if (argc > 0) { + func = CMDStringToFunc (argv[0]); + if (!func) + CMDSyntaxError (argc, argv); + else + { + result = (*func->func)(argc, argv); + switch (result) { + case CMDSyntax: + CMDSyntaxError(argc, argv); + break; + case CMDError: + printf ("Error\n"); + break; + case CMDProceed: + here = 0; + return; + default: + break; + } + } + } + } + printf("...\n"); + here = 0; +} + +int SingleStep; +int BreakPoint; +BP *breakPoints; +int breakPointNumber; + +void +TestBreakPoints (buf, n) + unsigned char *buf; + long n; +{ + BP *bp; + + for (bp = breakPoints; bp; bp = bp->next) + { + if (bp->request == buf[0]) + { + break; + } + } + if (bp) + { + printf ("Breakpoint on request %d\n", bp->request); + ReadCommands (); + } +} + +void +setBreakPoint () +{ + Boolean b = false; + BP *bp; + FD fd; + + if (SingleStep) + b = true; + else + { + for (bp = breakPoints; bp; bp = bp->next) + { + if (bp->enabled) + { + b = true; + break; + } + } + } + if (b != BreakPoint) + { + BreakPoint = b; + for (fd = 0; fd < HighestFD; fd++) + { + static void DataFromClient(FD fd); + + if (FDD[fd].Busy && FDD[fd].InputHandler == DataFromClient) + { + if (BreakPoint) + SetBufLimit (fd); + else + ClearBufLimit (fd); + } + } + } +} + +CMDResult +CMDBreak (argc, argv) + int argc; + char **argv; +{ + BP *bp, **prev; + int request; + + if (argc == 1) + { + for (bp = breakPoints; bp; bp = bp->next) + { + printf ("%3d: %3d %s\n", bp->number, bp->request, + bp->enabled ? "enabled" : "disabled"); + } + } + else + { + for (prev = &breakPoints; *prev; prev = &(*prev)->next); + while (*++argv) { + request = GetXRequestFromName (*argv); + if (request < 0 && !CMDStringToInt (*argv, &request)) + return CMDSyntax; + bp = (BP *) malloc (sizeof (BP)); + bp->request = request; + bp->number = ++breakPointNumber; + bp->enabled = true; + bp->next = 0; + *prev = bp; + prev = &bp->next; + } + } + setBreakPoint (); + return CMDDebug; +} + +CMDResult +CMDCont (argc, argv) + int argc; + char **argv; +{ + SingleStep = 0; + return CMDProceed; +} + +CMDResult +CMDDisable (argc, argv) + int argc; + char **argv; +{ + BP *bp; + int number; + + if (argc == 1) + { + printf ("Disabling all breakpoints...\n"); + for (bp = breakPoints; bp; bp = bp->next) + bp->enabled = false; + } + else + { + while (*++argv) { + if (!CMDStringToInt (*argv, &number)) + return CMDSyntax; + for (bp = breakPoints; bp; bp = bp->next) + if (bp->number == number) + { + bp->enabled = false; + break; + } + if (!bp) + { + printf ("No such breakpoint %s\n", *argv); + } + } + } + setBreakPoint (); + return CMDDebug; +} + +CMDResult +CMDDelete (argc, argv) + int argc; + char **argv; +{ + BP *bp, **prev; + int number; + + if (argc == 1) + { + printf ("Deleting all breakpoints...\n"); + while (bp = breakPoints) + { + breakPoints = bp->next; + free (bp); + } + } + else + { + while (*++argv) { + if (!CMDStringToInt (*argv, &number)) + return CMDSyntax; + for (prev = &breakPoints; bp = *prev; prev = &bp->next) + { + if (bp->number == number) + { + *prev = bp->next; + free (bp); + break; + } + } + if (!bp) + { + printf ("No such breakpoint %s\n", *argv); + } + } + } + setBreakPoint (); + return CMDDebug; +} + +CMDResult +CMDEnable (argc, argv) + int argc; + char **argv; +{ + BP *bp; + int number; + + if (argc == 1) + { + printf ("Enablingg all breakpoints...\n"); + for (bp = breakPoints; bp; bp = bp->next) + bp->enabled = true; + } + else + { + while (*++argv) { + if (!CMDStringToInt (*argv, &number)) + return CMDSyntax; + for (bp = breakPoints; bp; bp = bp->next) + if (bp->number == number) + { + bp->enabled = true; + break; + } + if (!bp) + { + printf ("No such breakpoint %s\n", *argv); + } + } + } + setBreakPoint (); + return CMDDebug; +} + +CMDResult +CMDStep (argc, argv) + int argc; + char **argv; +{ + SingleStep = 1; + setBreakPoint (); + return CMDProceed; +} + +CMDResult +CMDQuit (argc, argv) + int argc; + char **argv; +{ + printf ("exiting...\n"); + exit (0); +} + +CMDResult +CMDLevel (argc, argv) + int argc; + char **argv; +{ + int level; + + if (argc == 1) + printf ("Level: %d\n", XVerbose); + else if (argc == 2 && CMDStringToInt (argv[1], &level)) + XVerbose = level; + else + return CMDSyntax; + return CMDDebug; +} + +CMDResult +CMDAudio (argc, argv) + int argc; + char **argv; +{ + int level; + + if (argc == 1) + printf ("Audio Level: %d\n", NasVerbose); + else if (argc == 2 && CMDStringToInt (argv[1], &level)) + NasVerbose = level; + else + return CMDSyntax; + return CMDDebug; +} /* ********************************************** */ /* */ /* */ /* ********************************************** */ -static short GetServerport () +short GetServerport () { short port; @@ -159,11 +719,15 @@ Usage() #ifdef RAW_MODE fprintf(stderr, " [-r] -- raw output\n"); #endif + fprintf(stderr, " [-a<n>] -- audio verbose output\n"); fprintf(stderr, " [-q] -- quiet output\n"); fprintf(stderr, " [-D<debug-level>]\n"); + fprintf(stderr, " [-S<n>] -- start/stop on SIGUSR1\n"); + fprintf(stderr, " [-t] -- terminate when all clients close\n"); exit(1); } + static void ScanArgs(argc, argv) int argc; @@ -172,7 +736,8 @@ ScanArgs(argc, 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 @@ -197,19 +762,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 @@ -219,6 +783,11 @@ 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) @@ -261,6 +830,28 @@ ScanArgs(argc, 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(); @@ -290,6 +881,8 @@ ScanArgs(argc, argv) /* */ /* ********************************************** */ +int NewAudio (); + main(argc, argv) int argc; char **argv; @@ -297,14 +890,21 @@ main(argc, argv) ScanArgs(argc, argv); InitializeFD(); InitializeX11(); + if (DoAudio) + InitializeAudio(); +#ifdef PEX + InitializePEX(); +#endif SetUpStdin(); #if defined(DNETCONN) || defined(DNETSVR4) if (decnet_in) - SetUpDECnetConnection(GetScopePort()); + SetUpDECnetConnection(GetScopePort(), NewConnection); else - SetUpConnectionSocket(GetScopePort()); + SetUpConnectionSocket(GetScopePort(), NewConnection); #else - SetUpConnectionSocket(GetScopePort()); + SetUpConnectionSocket(GetScopePort(), NewConnection); + if (DoAudio) + SetUpConnectionSocket (GetScopePort() + 2000, NewAudio); SetSignalHandling(); #endif @@ -349,7 +949,7 @@ static void SetUpStdin() { enterprocedure("SetUpStdin"); - UsingFD(fileno(stdin), ReadStdin, NULL); + UsingFD(fileno(stdin), ReadStdin, (int (*)()) NULL, NULL); } /* ************************************************************ */ @@ -366,32 +966,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 +void SetUpPair(client, server) 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,11 +1000,31 @@ SetUpPair(client, server) } } + +ResetPair (client, server) + FD client; + FD server; +{ + if (client >= 0) + { + FDinfo[client].bufcount = 0; + FDinfo[client].buflimit = -1; + FDinfo[client].bufdelivered = 0; + } + if (server >= 0) + { + FDinfo[server].bufcount = 0; + FDinfo[server].buflimit = -1; + FDinfo[server].bufdelivered = 0; + } +} + static void CloseConnection(fd) FD fd; { debug(4,(stderr, "close %d and %d\n", fd, FDPair(fd))); + ResetPair (ClientHalf(fd), ServerHalf(fd)); StopClientConnection(ServerHalf(fd)); StopServerConnection(ClientHalf(fd)); @@ -418,6 +1037,8 @@ CloseConnection(fd) #endif NotUsingFD(fd); NotUsingFD(FDPair(fd)); + if (TerminateClose) + exit (0); } /* ************************************************************ */ @@ -449,17 +1070,80 @@ char *ClientName (fd) { static char name[12]; - if (ClientNumber <= 1) + if (clientNumber <= 1) return(""); - sprintf(name, " %d", FDinfo[fd].ClientNumber); + (void)sprintf(name, " %d", FDinfo[fd].ClientNumber); return(name); } +int ClientNumber (fd) + FD fd; +{ + return FDinfo[fd].ClientNumber; +} /* ********************************************** */ /* */ /* ********************************************** */ +/* + * Write as much of the queued data as the receiver will accept + * Block reads from the sender until the receiver gets all of the + * data + */ +void +FlushFD (fd) + FD fd; +{ + long BytesToWrite = FDinfo[fd].bufcount - FDinfo[fd].bufstart; + char *p = FDinfo[fd].buffer + FDinfo[fd].bufstart; + int PeerFD; + + PeerFD = FDPair (fd); + if (FDinfo[fd].buflimit >= 0) + { + if (FDinfo[fd].bufdelivered + BytesToWrite > FDinfo[fd].buflimit) + BytesToWrite = FDinfo[fd].buflimit - FDinfo[fd].bufdelivered; + } + while (BytesToWrite > 0) + { + int n1 = write (fd, (char *)p, (int)BytesToWrite); + debug(4,(stderr, "write %d bytes\n", n1)); + if (n1 < 0) + { + if (errno != EWOULDBLOCK && errno != EAGAIN) + { + perror("Error on write"); + if (PeerFD >= 0) + CloseConnection(PeerFD); + BytesToWrite = 0; + } + break; + } + else + { + FDinfo[fd].bufstart += n1; + FDinfo[fd].bufdelivered += n1; + BytesToWrite -= n1; + p += n1; + } + } + if (FDinfo[fd].bufstart == FDinfo[fd].bufcount) + { + if (PeerFD >= 0) + BlockedReadDescriptors &= ~ (1 << PeerFD); + WriteDescriptors &= ~(1 << fd); + FDinfo[fd].bufcount = FDinfo[fd].bufstart = 0; + } + else + { + if (PeerFD >= 0) + BlockedReadDescriptors |= 1 << PeerFD; + if (FDinfo[fd].buflimit != FDinfo[fd].bufdelivered) + WriteDescriptors |= 1 << fd; + } +} + /* when we get data from a client, we read it in, copy it to the server for this client, then dump it to the client. Note, we don't have to have a server, if there isn't one. */ @@ -468,12 +1152,24 @@ static void DataFromClient(fd) FD fd; { - unsigned char buf[2048]; long n; FD ServerFD; + Verbose = XVerbose; enterprocedure("DataFromClient"); - n = read(fd, (char *)buf, 2048); + ServerFD = FDPair(fd); + if (ServerFD < 0) + { + ServerFD = ConnectToServer(false); + if (ServerFD < 0) + { + CloseConnection(fd); + return; + } + SetUpPair(fd, ServerFD); + } + + n = read(fd, FDinfo[ServerFD].buffer, BUFFER_SIZE); debug(4,(stderr, "read %d bytes from Client%s\n", n, ClientName(fd))); if (n < 0) { @@ -485,58 +1181,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); } /* ********************************************** */ @@ -550,12 +1206,19 @@ static void DataFromServer(fd) FD fd; { - unsigned char buf[2048]; long n; FD ClientFD; + Verbose = XVerbose; + ClientFD = FDPair(fd); + if (ClientFD < 0) + { + CloseConnection(fd); + return; + } + enterprocedure("DataFromServer"); - n = read(fd, (char *)buf, 2048); + n = read(fd, (char *)FDinfo[ClientFD].buffer, BUFFER_SIZE); debug(4,(stderr, "read %d bytes from Server%s\n", n, ClientName(fd))); if (n < 0) { @@ -567,56 +1230,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); } @@ -702,7 +1327,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) @@ -716,7 +1341,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); @@ -732,31 +1357,19 @@ static FD ConnectToClient(ConnectionSocket) -static FD ConnectToServer(report) +FD ConnectToServer(report) 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", @@ -764,80 +1377,12 @@ 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); @@ -913,7 +1458,7 @@ FD ConnectToDECnetSVR4Server(report) debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); if (ServerFD >= 0) { - UsingFD(ServerFD, DataFromServer, NULL); + UsingFD(ServerFD, DataFromServer, FlushFD, NULL); StartServerConnection(ServerFD); } return(ServerFD); @@ -935,7 +1480,7 @@ FD ConnectToDECnetClient(fd) fprintf(stderr,"xscope: dni: SES_ACCEPT failed\n"); exit(-1); } - UsingFD(fd, DataFromClient, NULL); + UsingFD(fd, DataFromClient, NULL, 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 */ @@ -987,10 +1532,9 @@ FD ConnectToDECnetServer(report) fprintf(stderr,"xscope: dni: cannot connect to server\n"); exit(-1); } - UsingFD(fd, DataFromServer, NULL); + UsingFD(fd, DataFromServer, NULL, NULL); StartServerConnection(fd); return(fd); } #endif - @@ -53,7 +53,10 @@ * ********************************************** */ +#include <X11/Xos.h> +#include <X11/Xfuncs.h> #include <stdio.h> +#include <netdb.h> #ifdef SVR4 #include <sys/filio.h> #endif /* SVR4 */ @@ -62,27 +65,39 @@ #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; + +extern int ScopePort; +extern char *ScopeHost; + +extern int Interrupt, SingleStep, BreakPoint; + +extern void ReadCommands (); + +extern char ServerHostName[MAXHOSTNAMELEN]; +extern char AudioServerHostName[MAXHOSTNAMELEN]; /* external function type declarations */ @@ -102,3 +117,20 @@ extern char *ClientName(); #include "fd.h" #include "proto.h" + +#define BUFFER_SIZE (1024 * 32) + +struct fdinfo +{ + Boolean Server; + long ClientNumber; + FD pair; + char buffer[BUFFER_SIZE]; + int bufcount; + int bufstart; + int buflimit; /* limited writes */ + int bufdelivered; /* total bytes delivered */ + Boolean writeblocked; +}; + +extern struct fdinfo FDinfo[StaticMaxFD]; @@ -61,7 +61,12 @@ #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]; + +extern char ScopeEnabled; /* ************************************************************ */ /* */ @@ -74,10 +79,15 @@ ReportFromClient(fd, buf, n) 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 --> %4d %s\n", + ClientName(fd), n, (n == 1 ? "byte" : "bytes")); + } + } + ProcessBuffer(fd, buf, n); } void @@ -86,10 +96,14 @@ ReportFromServer(fd, buf, n) 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%4d %s <-- X11 Server%s\n", + n, (n == 1 ? "byte" : "bytes"), ClientName(fd)); + } + } + ProcessBuffer(fd, buf, n); } @@ -98,7 +112,6 @@ ReportFromServer(fd, buf, n) /* */ /* ************************************************************ */ -#include <sys/time.h> /* for struct timeval * */ static long ZeroTime1 = -1; static long ZeroTime2 = -1; static struct timeval tp; @@ -146,11 +159,12 @@ long pad (n) return((n + 3) & ~0x3); } -static int littleEndian; +extern int littleEndian; unsigned long ILong (buf) 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]); @@ -159,11 +173,19 @@ unsigned long ILong (buf) unsigned short IShort (buf) unsigned char buf[]; { + /* check for byte-swapping */ if (littleEndian) return (buf[1] << 8) | buf[0]; return((buf[0] << 8) | buf[1]); } +unsigned short IChar2B (buf) +unsigned char buf[]; +{ + /* CHAR2B is like an IShort, but not byte-swapped */ + return((buf[0] << 8) | buf[1]); +} + unsigned short IByte (buf) unsigned char buf[]; { @@ -246,12 +268,10 @@ 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 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); @@ -262,7 +282,9 @@ static long FinishReply(FD fd, unsigned char *buf, long n); /* */ /* ************************************************************ */ -static void +int littleEndian; + +void ProcessBuffer(fd, buf, n) FD fd; unsigned char *buf; @@ -273,7 +295,11 @@ ProcessBuffer(fd, buf, n) /* 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 +349,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 +360,7 @@ ProcessBuffer(fd, buf, n) if (NumberofUsedBytes > 0) { + CS[fd].NumberofBytesProcessed += NumberofUsedBytes; if (CS[fd].NumberofSavedBytes > 0) RemoveSavedBytes(fd, NumberofUsedBytes); else @@ -345,9 +373,15 @@ ProcessBuffer(fd, buf, n) } } /* end of while (NumberofSavedBytes + n >= NumberofBytesNeeded) */ + if (Verbose > 3) + fprintf (stdout, "Have %d need %d\n", + CS[fd].NumberofSavedBytes + n, + CS[fd].NumberofBytesNeeded); /* not enough bytes -- just save the new bytes for more later */ if (n > 0) + { SaveBytes(fd, buf, n); + } return; } @@ -362,6 +396,55 @@ ProcessBuffer(fd, buf, n) and ByteProcessing. It probably needs to do some computation first. */ +SetBufLimit (fd) + FD fd; +{ + int ServerFD = FDPair (fd); + FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed + + CS[fd].NumberofBytesNeeded); +} + +ClearBufLimit (fd) + FD fd; +{ + int ServerFD = FDPair (fd); + FDinfo[ServerFD].buflimit = -1; +} + +StartStuff (fd) + FD fd; +{ + if (BreakPoint) + { + int ServerFD = FDPair (fd); + FDinfo[ServerFD].buflimit = (CS[fd].NumberofBytesProcessed + + CS[fd].NumberofBytesNeeded); + FlushFD (ServerFD); + } +} + +FinishStuff (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + if (BreakPoint) + { + int ServerFD = FDPair (fd); + + FlushFD (ServerFD); + if (SingleStep) + ReadCommands (); + else if (BreakPoint) + TestBreakPoints (buf, n); + if (!BreakPoint) + { + FDinfo[ServerFD].buflimit = -1; + FlushFD (ServerFD); + } + } +} + void StartClientConnection(fd) FD fd; @@ -371,6 +454,7 @@ StartClientConnection(fd) CS[fd].SavedBytes = NULL; CS[fd].SizeofSavedBytes = 0; CS[fd].NumberofSavedBytes = 0; + CS[fd].NumberofBytesProcessed = 0; /* when a new connection is started, we have no reply Queue */ FlushReplyQ(fd); @@ -381,6 +465,7 @@ StartClientConnection(fd) /* we need 12 bytes to start a SetUp message */ CS[fd].ByteProcessing = StartSetUpMessage; CS[fd].NumberofBytesNeeded = 12; + StartStuff (fd); } void @@ -394,7 +479,7 @@ StopClientConnection(fd) Free((char*)CS[fd].SavedBytes); } -static long StartSetUpMessage (fd, buf, n) +long StartSetUpMessage (fd, buf, n) FD fd; unsigned char *buf; long n; @@ -409,7 +494,10 @@ 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; @@ -417,6 +505,7 @@ static long StartSetUpMessage (fd, buf, n) + pad((long)namelength) + pad((long)datalength); debug(8,(stderr, "need %d bytes to finish startup\n", CS[fd].NumberofBytesNeeded - n)); + StartStuff (fd); return(0); } @@ -431,30 +520,58 @@ 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) +long StartBigRequest (fd, buf, n) FD fd; 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; + CS[fd].NumberofBytesNeeded = 4 * CS[fd].requestLen; debug(8,(stderr, "need %d more bytes to finish request\n", CS[fd].NumberofBytesNeeded - n)); + StartStuff (fd); + return(0); +} + +static long StartRequest (fd, buf, n) + FD fd; + unsigned char *buf; + long n; +{ + enterprocedure("StartRequest"); + + /* 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 %d more bytes to finish request\n", + CS[fd].NumberofBytesNeeded - n)); + } + StartStuff (fd); return(0); } @@ -465,9 +582,11 @@ static long FinishRequest (fd, buf, n) 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); } @@ -485,6 +604,7 @@ StartServerConnection(fd) CS[fd].SavedBytes = NULL; CS[fd].SizeofSavedBytes = 0; CS[fd].NumberofSavedBytes = 0; + CS[fd].NumberofBytesProcessed = 0; /* when a new connection is started, we have no reply Queue */ FlushReplyQ(fd); @@ -505,7 +625,7 @@ StopServerConnection(fd) Free((char *)CS[fd].SavedBytes); } -static long +long StartSetUpReply (fd, buf, n) FD fd; unsigned char *buf; @@ -531,7 +651,8 @@ FinishSetUpReply (fd, buf, 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); @@ -545,10 +666,9 @@ ErrorPacket (fd, buf, n) unsigned char *buf; long n; { - fprintf(stdout, "Error: "); - DecodeError(fd, buf, n); CS[fd].ByteProcessing = ServerPacket; CS[fd].NumberofBytesNeeded = 32; + DecodeError(fd, buf, n); return(n); } @@ -559,9 +679,10 @@ EventPacket (fd, buf, n) unsigned char *buf; long n; { - DecodeEvent(fd, buf, n); CS[fd].ByteProcessing = ServerPacket; CS[fd].NumberofBytesNeeded = 32; + if (ScopeEnabled) + DecodeEvent(fd, buf, n); return(n); } @@ -572,12 +693,6 @@ ReplyPacket (fd, buf, n) 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]); @@ -620,9 +735,16 @@ long FinishReply (fd, buf, n) unsigned char *buf; long n; { - enterprocedure("FinishReply"); - DecodeReply(fd, buf, n); CS[fd].ByteProcessing = ServerPacket; CS[fd].NumberofBytesNeeded = 32; + enterprocedure("FinishReply"); + if (ScopeEnabled) + DecodeReply(fd, buf, n); return(n); } + +long GetXRequestFromName (name) + char *name; +{ + return GetEValue (REQUEST, name); +} diff --git a/shmscope.h b/shmscope.h new file mode 100644 index 0000000..d898326 --- /dev/null +++ b/shmscope.h @@ -0,0 +1,16 @@ +#ifndef _MITSHMSCOPE_H_ +#define _MITSHMSCOPE_H_ + +#define MITSHMREQUESTHEADER "MITSHMREQUEST" +#define MITSHMREPLYHEADER "MITSHMREPLY" + +/* + To aid in making the choice between level 1 and level 2, we + define the following define, which does not print relatively + unimportant fields. +*/ + +#define printfield(a,b,c,d,e) if (Verbose > 1) PrintField(a,b,c,d,e) + +#endif + @@ -122,6 +122,102 @@ InitializeX11() InitRecordTypes(); } +#define HASH_SIZE 997 + +ValuePtr buckets[HASH_SIZE]; + +#define HASH(key) ((key) % HASH_SIZE) + +ValuePtr +GetValueRec (key) + unsigned long key; +{ + ValuePtr *bucket, value; + + bucket = &buckets[HASH(key)]; + for (value = *bucket; value; value = value->next) + { + if (value->key == key) + return value; + } + return 0; +} + +CreateValueRec (key, size, def) + unsigned long key; + int size; + unsigned long *def; +{ + ValuePtr *bucket, value; + int i; + + bucket = &buckets[HASH(key)]; + value = (ValuePtr) malloc (sizeof (ValueRec) + size * sizeof (unsigned long)); + if (!value) + return 0; + value->values = (unsigned long *) (value + 1); + for (i = 0; i < size; i++) + value->values[i] = ILong((char *) (def + i)); + value->size = size; + value->key = key; + value->next = *bucket; + *bucket = value; +} + +DeleteValueRec (key) + unsigned long key; +{ + ValuePtr *bucket, value; + + for (bucket = &buckets[HASH(key)]; value = *bucket; bucket = &value->next) + { + if (value->key == key) + { + *bucket = value->next; + free (value); + return; + } + } +} + +SetValueRec (key, control, clength, ctype, values) + unsigned long key; + unsigned char *control; + short clength; + short ctype; + unsigned char *values; +{ + long cmask; + struct ValueListEntry *p; + ValuePtr value; + int i; + + value = GetValueRec (key); + if (!value) + return; + /* first get the control mask */ + if (clength == 1) + cmask = IByte(control); + else if (clength == 2) + cmask = IShort(control); + else + cmask = ILong(control); + + /* now if it is zero, ignore and return */ + if (cmask == 0) + return; + /* there are bits in the controlling bitmask, figure out which */ + /* the ctype is a set type, so this code is similar to PrintSET */ + for (p = TD[ctype].ValueList, i = 0; p != NULL; p = p->Next, i++) + { + if ((p->Value & cmask) != 0) + { + memcpy (&value->values[i], values, sizeof (unsigned long)); + values += 4; + } + } +} + /* ************************************************************ */ /* */ /* */ @@ -129,7 +225,7 @@ InitializeX11() /* define the various types */ -static TYPE +TYPE DefineType(typeid, class, name, printproc) short typeid; short class; @@ -146,7 +242,7 @@ DefineType(typeid, class, name, printproc) /* ************************************************************ */ /* define an Enumerated Value (or a Set Value) */ -static void +void DefineEValue(type, value, name) TYPE type; long value; @@ -177,6 +273,25 @@ DefineEValue(type, value, name) } } +long +GetEValue (typeid, name) + short typeid; + char *name; +{ + TYPE p; + struct ValueListEntry *v; + + if (typeid < 0 || MaxTypes <= typeid) + return -1; + p = &TD[typeid]; + if (!p) + return -2; + for (v = p->ValueList; v; v = v->Next) + if (!strcmp (name, v->Name)) + return v->Value; + return -3; +} + /* ************************************************************ */ /* a Values list is like an enumerated Value, but has a type and length in addition to a value and name. It is used to print a Values List */ @@ -185,7 +300,7 @@ 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 +void DefineValues(TYPE type, long value, short length, short ctype, char *name) { struct ValueListEntry *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..7206bfd --- /dev/null +++ b/wcpscope.h @@ -0,0 +1,41 @@ +/* + * $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) + +#endif + @@ -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; /* ************************************************************ */ /* */ @@ -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(unsigned char *buf); +extern int PrintINT16(unsigned char *buf); +extern int PrintINT32(unsigned char *buf); +extern int PrintCARD8(unsigned char *buf); +extern int PrintCARD16(unsigned char *buf); +extern int PrintCARD32(unsigned char *buf); +extern int PrintBYTE(unsigned char *buf); +extern int PrintCHAR8(unsigned char *buf); +extern int PrintSTRING16(unsigned char *buf); +extern int PrintTEXTITEM8(unsigned char *buf); +extern int PrintTEXTITEM16(unsigned char *buf); +extern int PrintSTR(unsigned char *buf); +extern int PrintWINDOW(unsigned char *buf); +extern int PrintWINDOWD(unsigned char *buf); +extern int PrintWINDOWNR(unsigned char *buf); +extern int PrintPIXMAP(unsigned char *buf); +extern int PrintPIXMAPNPR(unsigned char *buf); +extern int PrintPIXMAPC(unsigned char *buf); +extern int PrintCURSOR(unsigned char *buf); +extern int PrintFONT(unsigned char *buf); +extern int PrintGCONTEXT(unsigned char *buf); +extern int PrintCOLORMAP(unsigned char *buf); +extern int PrintCOLORMAPC(unsigned char *buf); +extern int PrintDRAWABLE(unsigned char *buf); +extern int PrintFONTABLE(unsigned char *buf); +extern int PrintATOM(unsigned char *buf); +extern int PrintATOMT(unsigned char *buf); +extern int PrintVISUALID(unsigned char *buf); +extern int PrintVISUALIDC(unsigned char *buf); +extern int PrintTIMESTAMP(unsigned char *buf); +extern int PrintRESOURCEID(unsigned char *buf); +extern int PrintKEYSYM(unsigned char *buf); +extern int PrintKEYCODE(unsigned char *buf); +extern int PrintKEYCODEA(unsigned char *buf); +extern int PrintBUTTON(unsigned char *buf); +extern int PrintBUTTONA(unsigned char *buf); +extern int PrintEVENTFORM(unsigned char *buf); +extern int PrintENUMERATED(unsigned char *buf, short length, struct ValueListEntry *ValueList); +extern int PrintSET(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,20 +492,33 @@ unsigned char SBf[4]; struct ConnState { unsigned char *SavedBytes; - int littleEndian; + int littleEndian; + int bigreqEnabled; + long requestLen; long SizeofSavedBytes; long NumberofSavedBytes; long NumberofBytesNeeded; + long NumberofBytesProcessed; long (*ByteProcessing)(); long SequenceNumber; }; -struct ConnState CS[StaticMaxFD]; - +extern struct ConnState CS[StaticMaxFD]; +typedef struct _Value { + struct _Value *next; + unsigned long key; + int size; + unsigned long *values; +} ValueRec, *ValuePtr; +extern ValuePtr GetValueRec (); +extern CreateValueRec (); +extern DeleteValueRec (); +extern SetValueRec (); +extern PrintValueRec (); /* ************************************************************ */ /* */ @@ -476,8 +532,37 @@ extern unsigned short IShort(); extern unsigned short IByte(); extern Boolean IBool(); +extern PrintString8(), PrintTString8 (); +extern PrintString16(), PrintTString16 (); + extern long PrintList(); extern long PrintListSTR(); extern long pad(); +extern char *REQUESTHEADER, *EVENTHEADER, *ERRORHEADER, *REPLYHEADER; + +#define GC_function 0x00000001L +#define GC_plane_mask 0x00000002L +#define GC_foreground 0x00000004L +#define GC_background 0x00000008L +#define GC_line_width 0x00000010L +#define GC_line_style 0x00000020L +#define GC_cap_style 0x00000040L +#define GC_join_style 0x00000080L +#define GC_fill_style 0x00000100L +#define GC_fill_rule 0x00000200L +#define GC_tile 0x00000400L +#define GC_stipple 0x00000800L +#define GC_tile_stipple_x_origin 0x00001000L +#define GC_tile_stipple_y_origin 0x00002000L +#define GC_font 0x00004000L +#define GC_subwindow_mode 0x00008000L +#define GC_graphics_exposures 0x00010000L +#define GC_clip_x_origin 0x00020000L +#define GC_clip_y_origin 0x00040000L +#define GC_clip_mask 0x00080000L +#define GC_dash_offset 0x00100000L +#define GC_dashes 0x00200000L +#define GC_arc_mode 0x00400000L + #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); +} |