From dbf94a72289efaa89fdab27b4cf0608994ebd0a1 Mon Sep 17 00:00:00 2001 From: Stuart Kreitman Date: Thu, 11 Sep 2008 18:28:24 -0700 Subject: Merge Sun's version of xscope in Conversion to ANSI C SysVR4 support Conversion of networking code to use xtrans --- common.c | 313 ++++++++++++++++++++------- decode11.c | 114 +++++----- fd.c | 166 ++++++++------- fd.h | 61 +++++- print11.c | 568 ++++++++++++++++++++++++++++++++++--------------- proto.h | 266 +++++++++++++++++++++++ prtype.c | 232 ++++++++++---------- scope-transport.c | 8 + scope.c | 625 ++++++++++++++++++++++++++++++++++++++++-------------- scope.h | 55 ++++- server.c | 208 +++++++++--------- table11.c | 284 +++++++++++++++---------- x11.h | 289 ++++++++++++++----------- 13 files changed, 2182 insertions(+), 1007 deletions(-) create mode 100644 proto.h create mode 100644 scope-transport.c diff --git a/common.c b/common.c index 7ce37a5..2a3f984 100644 --- a/common.c +++ b/common.c @@ -23,28 +23,66 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * \* *********************************************************** */ #include "scope.h" +#ifdef SYSV +#define bzero(s,l) memset(s, 0, l) +#define bcopy(s,d,l) memmove(d,s,l) +#endif + +#include + /* ********************************************** */ /* */ /* Debugging support routines */ /* */ /* ********************************************** */ +void enterprocedure(s) char *s; { debug(2,(stderr, "-> %s\n", s)); } +void warn(s) char *s; { fprintf(stderr, "####### %s\n", s); } +void panic(s) char *s; { @@ -58,21 +96,18 @@ panic(s) /* */ /* ********************************************** */ -extern char *malloc(); - -char *Malloc (n) - long n; +void *Malloc (long n) { - char *p; - p = (char *)malloc((unsigned int)n); + void *p; + p = malloc(n); debug(64,(stderr, "%x = malloc(%d)\n", p, n)); if (p == NULL) panic("no more malloc space"); return(p); } -Free(p) - char *p; +void +Free(void *p) { debug(64,(stderr, "%x = free\n", p)); free(p); @@ -88,82 +123,55 @@ Free(p) #include -#ifdef SIGURG -void SignalURG(int dummy) +static void SignalURG(int sig) { debug(1,(stderr, "==> SIGURG received\n")); } -#endif /* #ifdef SIGURG */ -#ifdef SIGPIPE -void SignalPIPE(int dummy) +static void SignalPIPE(int sig) { debug(1,(stderr, "==> SIGPIPE received\n")); } -#endif /* #ifdef SIGPIPE */ -#ifdef SIGINT -void SignalINT(int dummy) +static void SignalINT(int sig) { debug(1,(stderr, "==> SIGINT received\n")); exit(1); -#endif /* #ifdef SIGINT */ } -#ifdef SIGQUIT -void SignalQUIT(int dummy) +static void SignalQUIT(int sig) { debug(1,(stderr, "==> SIGQUIT received\n")); exit(1); -#endif /* #ifdef SIGQUIT */ } -#ifdef SIGTERM -void SignalTERM(int dummy) +static void SignalTERM(int sig) { debug(1,(stderr, "==> SIGTERM received\n")); exit(1); -#endif /* #ifdef SIGTERM */ } -#ifdef SIGTSTP -void SignalTSTP(int dummy) +static void SignalTSTP(int sig) { debug(1,(stderr, "==> SIGTSTP received\n")); } -#endif /* #ifdef SIGTSTP */ -#ifdef SIGCONT -void SignalCONT(int dummy) +static void SignalCONT(int sig) { debug(1,(stderr, "==> SIGCONT received\n")); } -#endif /* #ifdef SIGCONT */ +void SetSignalHandling() { enterprocedure("SetSignalHandling"); -#ifdef SIGURG - (void)signal(SIGURG, SignalURG); -#endif /* #ifdef SIGURG */ -#ifdef SIGPIPE - (void)signal(SIGPIPE, SignalPIPE); -#endif /* #ifdef SIGPIPE */ -#ifdef SIGINT - (void)signal(SIGINT, SignalINT); -#endif /* #ifdef SIGINT */ -#ifdef SIGQUIT - (void)signal(SIGQUIT, SignalQUIT); -#endif /* #ifdef SIGQUIT */ -#ifdef SIGTERM - (void)signal(SIGTERM, SignalTERM); -#endif /* #ifdef SIGTERM */ -#ifdef SIGTSTP - (void)signal(SIGTSTP, SignalTSTP); -#endif /* #ifdef SIGTSTP */ -#ifdef SIGCONT - (void)signal(SIGCONT, SignalCONT); -#endif /* #ifdef SIGCONT */ + signal(SIGURG, SignalURG); + signal(SIGPIPE, SignalPIPE); + signal(SIGINT, SignalINT); + signal(SIGQUIT, SignalQUIT); + signal(SIGTERM, SignalTERM); + signal(SIGTSTP, SignalTSTP); + signal(SIGCONT, SignalCONT); } @@ -174,31 +182,79 @@ SetSignalHandling() /* */ /* ************************************************************ */ +#ifdef USE_XTRANS + +#include +static XtransConnInfo *ListenTransConns = NULL; +static int *ListenTransFds = NULL; +static int ListenTransCount; + +#else + #include /* needed by sys/socket.h and netinet/in.h */ #include /* for struct iovec, used by socket.h */ #include /* for AF_INET, SOCK_STREAM, ... */ #include /* for FIONCLEX, FIONBIO, ... */ +#include /* for FIONCLEX, FIONBIO, ... */ #include /* struct sockaddr_in */ #include /* struct servent * and struct hostent * */ +#ifdef DNETCONN +#include +#endif +#ifdef DNETSVR4 +#include +#include +struct hostent *(*dnet_gethostbyname)(); +int (*dnet_gethostname)(); +short initialize_libdni(); +#endif static int ON = 1 /* used in ioctl */ ; -#define BACKLOG 5 - -/* for use in the UsingFD call -- defined later */ -extern int NewConnection (); - +#define BACKLOG 5 +#endif -SetUpConnectionSocket(port) - int port; +void +SetUpConnectionSocket(iport) + int iport; { +#ifdef USE_XTRANS + char port[20]; + int partial; + int i; + extern long ServerBasePort; +#else FD ConnectionSocket; struct sockaddr_in sin; -#ifndef SO_DONTLINGER - struct linger linger; -#endif /* #ifndef SO_DONTLINGER */ + short port; +#endif enterprocedure("SetUpConnectionSocket"); +#ifdef USE_XTRANS + ScopePort = iport - ServerBasePort; + sprintf (port, "%d", ScopePort); + if ((_X11TransMakeAllCOTSServerListeners (port, &partial, + &ListenTransCount, &ListenTransConns) >= 0) && + (ListenTransCount >= 1)) { + if (partial) { + debug(4,(stderr, + "Warning: Failed to establish listening connections on some transports\n")); + } + ListenTransFds = (int *) malloc (ListenTransCount * sizeof (int)); + + for (i = 0; i < ListenTransCount; i++) + { + int fd = _X11TransGetConnectionNumber (ListenTransConns[i]); + + ListenTransFds[i] = fd; + debug(4,(stderr, "Listening on FD %d\n", fd)); + UsingFD(fd, NewConnection, ListenTransConns[i]); + } + } else { + panic("Could not open any listening connections"); + } +#else + /* create the connection socket and set its parameters of use */ ConnectionSocket = socket(AF_INET, SOCK_STREAM, 0); if (ConnectionSocket < 0) @@ -207,16 +263,10 @@ SetUpConnectionSocket(port) exit(-1); } (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0); -#ifdef SO_USELOOPBACK (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0); -#endif /* #ifdef SO_USELOOPBACK */ #ifdef SO_DONTLINGER (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_DONTLINGER, (char *)NULL, 0); -#else /* #ifdef SO_DONTLINGER */ - linger.l_onoff = 0; - linger.l_linger = 0; - (void)setsockopt(ConnectionSocket, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger); -#endif /* #ifdef SO_DONTLINGER */ +#endif /* define the name and port to be used with the connection socket */ bzero((char *)&sin, sizeof(sin)); @@ -232,7 +282,7 @@ SetUpConnectionSocket(port) (void) gethostname(MyHostName, sizeof(MyHostName)); ScopeHost = (char *) Malloc((long)(1+strlen(MyHostName))); - (void)strcpy(ScopeHost, MyHostName); + strcpy(ScopeHost, MyHostName); hp = gethostbyname(MyHostName); if (hp == NULL) panic("No address for our host"); @@ -243,7 +293,8 @@ SetUpConnectionSocket(port) addresses. INADDR_ANY should work with all of them at once. */ sin.sin_addr.s_addr = INADDR_ANY; - sin.sin_port = htons(port); + port = iport; + sin.sin_port = htons (port); ScopePort = port; /* bind the name and port number to the connection socket */ @@ -264,13 +315,129 @@ SetUpConnectionSocket(port) }; /* a few more parameter settings */ -#ifdef FIOCLEX - (void)ioctl(ConnectionSocket, FIOCLEX, 0); -#endif /* #ifdef FIOCLEX */ - (void)ioctl(ConnectionSocket, FIONBIO, &ON); + ioctl(ConnectionSocket, FIOCLEX, 0); + ioctl(ConnectionSocket, FIONBIO, &ON); debug(4,(stderr, "Listening on FD %d\n", ConnectionSocket)); UsingFD(ConnectionSocket, NewConnection); +#endif + +} + +#ifndef USE_XTRANS +#ifdef DNETSVR4 +SetUpDECnetConnection(display) +int display; +{ + struct sockaddr_dn *sdn,sdnn; /* DECnet socket */ + struct hostent *hp; + int sock; + char hostname[6]; + + if (!initialize_libdni()) { + fprintf(stderr,"Unable to open libdni.so\n"); + exit(0); + } + sdn = &sdnn; + if (!(dnet_gethostname)(hostname)) { + fprintf(stderr,"Can't get DECnet local host name\n"); + exit(0); + } + if ((hp = (struct hostent *)(dnet_gethostbyname)(hostname)) == NULL) { + fprintf(stderr,"xhost: can't get name %s\n",hostname); + exit(0); + } + sdn->sdn_family = AF_DECnet; + sdn->sdn_format = DNADDR_FMT1; + sdn->sdn_port = 0; + sprintf ((char *)sdn->sdn_name, "X$X%d", display); + sdn->sdn_namelen = strlen((char *)sdn->sdn_name); + sdn->sdn_addr = *(u_short *)hp->h_addr_list[0]; + + if ((sock = socket (AF_DECnet, SOCK_STREAM, 0)) < 0) { + perror("socket"); + exit(0); + } + (void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)NULL, 0); + (void)setsockopt(sock, SOL_SOCKET, SO_USELOOPBACK, (char *)NULL, 0); + + if (bind(sock, (struct sockaddr_dn *)sdn, + sizeof(struct sockaddr_dn)) < 0) { + perror("DNI Bind"); + exit(0); + } + if (listen(sock, 100) < 0) { + perror("DNI Listen"); + exit(0); + } + + UsingFD(sock, NewConnection); } +#endif +#ifdef DNETCONN +SetUpDECnetConnection(display) +int display; +{ + struct ses_io_type sesopts; + char objname[6]; + FD fd; + + enterprocedure("SetUpDECnetConnection"); + sprintf (objname, "X$X%d", display); + if ((fd = open("/dev/dni", O_RDWR)) < 0) { + fprintf(stderr,"xscope: dni: open failed\n"); + exit(-1); + } + if (ioctl(fd, SES_GET_LINK, 0)) { + fprintf(stderr,"xscope: dni: can't get link\n"); + exit(-1); + } + /* set nonblocking here since dni ignores fcntls */ + /* set asyncronous to avoid blocking on SES_GET_AI */ + sesopts.io_flags = SES_IO_NBIO + SES_IO_ASYNCH_MODE; + sesopts.io_io_signal = SIGIO; + sesopts.io_int_signal = 0; + + if (ioctl(fd, SES_IO_TYPE, &sesopts) < 0) { + fprintf(stderr,"xscope: dni: ioctl failed\n"); + exit(-1); + } + + /* register as server */ + if (ioctl(fd, SES_NAME_SERVER, objname) < 0) { + fprintf(stderr,"xscope: dni: ioctl failed\n"); + exit(-1); + } + debug(4,(stderr, "Listening on DECnet FD %d\n", fd)); + UsingFD(fd, NewConnection); +} +#endif +#ifdef DNETSVR4 +short +initialize_libdni() +{ + void *handle; + char *home; + char *path; + + if (dnet_gethostname && dnet_gethostbyname) + return(1); + if (!(handle = dlopen("/etc/openwin/lib/libdni.so",RTLD_NOW))) { + if ((home = (char *)getenv("DNI_X_ENABLE")) == NULL) + return(0); + path = (char *)malloc(strlen(home) + 12); + sprintf(path, "%s%s",home, "/libdni.so"); + if (!(handle = dlopen(path,RTLD_NOW))) + return(0); + free(path); + } + if (!(dnet_gethostbyname = (struct hostent *(*)())dlsym(handle,"dni_gethostbyname"))) + return(0); + if (!(dnet_gethostname = (int (*)())dlsym(handle,"dni_gethostname"))) + return(0); + return(1); +} +#endif +#endif /* USE_XTRANS */ diff --git a/decode11.c b/decode11.c index eb2a12f..c3f5a15 100644 --- a/decode11.c +++ b/decode11.c @@ -23,11 +23,44 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************************ */ #include "scope.h" #include "x11.h" +#ifdef SYSV +#define bzero(s,l) memset(s, 0, l) +#define bcopy(s,d,l) memmove(d,s,l) +#endif + /* There are 4 types of things in X11: requests, replies, errors, and events. @@ -70,7 +103,7 @@ struct QueueEntry static struct QueueEntry *FreeQEntries = NULL; /* ************************************************************ */ -struct QueueEntry *NewQEntry (SequenceNumber, Request) +static struct QueueEntry *NewQEntry (SequenceNumber, Request) long SequenceNumber; short Request; { @@ -105,10 +138,11 @@ struct QueueHeader struct QueueEntry *Tail; }; -struct QueueHeader ReplyQ[StaticMaxFD]; +static struct QueueHeader ReplyQ[StaticMaxFD]; /* ************************************************************ */ +void InitReplyQ() { short i; @@ -119,6 +153,7 @@ InitReplyQ() } } +void FlushReplyQ(fd) FD fd; { @@ -129,21 +164,21 @@ FD fd; for (p = ReplyQ[fd].Head; p != NULL; p = NextQEntry) { NextQEntry = p->Next; - + /* put freed entry on list of free entries (for later reuse) */ p->Next = FreeQEntries; FreeQEntries = p; } - + ReplyQ[fd].Head = NULL; ReplyQ[fd].Tail = NULL; } - +static void DumpReplyQ(fd) FD fd; { - fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n", + fprintf(stderr, "ReplyQ[%d] = { Head 0x%x; Tail 0x%x }\n", fd, ReplyQ[fd].Head, ReplyQ[fd].Tail); { struct QueueEntry *p; @@ -160,6 +195,7 @@ DumpReplyQ(fd) /* A reply is expected to the type of request given for the fd associated with this one */ +static void SequencedReplyExpected(fd, SequenceNumber, RequestType) FD fd; long SequenceNumber; @@ -188,38 +224,14 @@ SequencedReplyExpected(fd, SequenceNumber, RequestType) } -/* search for the type of request that is associated with a reply - to the given sequence number for this fd */ - -short CheckReplyTable (fd, SequenceNumber) - FD fd; - short SequenceNumber; -{ - struct QueueEntry *p; - - if (debuglevel & 128) DumpReplyQ(fd); - for (p = ReplyQ[fd].Head; - p != NULL; - p = p->Next) - { - /* look for matching sequence number in queue of this fd */ - if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber))) - { - return(p->Request); - } - } - - /* not expecting a reply for that sequence number */ - return(0); -} - - static FD Lastfd; static long LastSequenceNumber; static short LastReplyType; +/* search for the type of request that is associated with a reply + to the given sequence number for this fd */ -short ExtractReplyTable (fd, SequenceNumber) +static short CheckReplyTable (fd, SequenceNumber) FD fd; short SequenceNumber; { @@ -268,6 +280,7 @@ short ExtractReplyTable (fd, SequenceNumber) /* A reply is expected to the type of request given for the sequence number associated with this fd */ +static void ReplyExpected(fd, Request) FD fd; short Request; @@ -279,6 +292,7 @@ ReplyExpected(fd, Request) /* another reply is expected for the same reply as we just had */ /* This is only used with ListFontsWithInfo */ +void KeepLastReplyExpected() { SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType); @@ -289,7 +303,7 @@ KeepLastReplyExpected() /* */ /* ************************************************************ */ - +void DecodeRequest(fd, buf, n) FD fd; unsigned char *buf; @@ -300,13 +314,10 @@ DecodeRequest(fd, buf, n) bcopy ((char *)&(CS[fd].SequenceNumber), (char *)SBf, sizeof(long)); SetIndentLevel(PRINTCLIENT); - if (Verbose > 3) + if (Raw || (Verbose > 3)) DumpItem("Request", fd, buf, n); if (Request <= 0 || 127 < Request) - { - warn("Extended request opcode"); - fprintf(stdout, "Extended request opcode: %d\n", Request); - } + warn("Extended request opcode"); else switch (Request) { case 1: @@ -720,28 +731,25 @@ DecodeRequest(fd, buf, n) /* */ /* ************************************************************ */ +void DecodeReply(fd, buf, n) FD fd; unsigned char *buf; long n; { short SequenceNumber = IShort (&buf[2]); - short Request = ExtractReplyTable (fd, SequenceNumber); + short Request = CheckReplyTable (fd, SequenceNumber); if (Request == 0) { warn("Unexpected reply"); - fprintf(stdout, "Unexpected reply: %d\n", SequenceNumber); return; } SetIndentLevel(PRINTSERVER); RBf[0] = Request /* for the PrintField in the Reply procedure */ ; - if (Verbose > 3) + if (Raw || (Verbose > 3)) DumpItem("Reply", fd, buf, n); if (Request <= 0 || 127 < Request) - { - warn("Extended reply opcode"); - fprintf(stdout, "Extended reply opcode: %d\n", Request); - } + warn("Extended reply opcode"); else switch (Request) { case 3: @@ -875,6 +883,7 @@ DecodeReply(fd, buf, n) /* */ /* ************************************************************ */ +void DecodeError(fd, buf, n) FD fd; unsigned char *buf; @@ -882,9 +891,9 @@ DecodeError(fd, buf, n) { short Error = IByte (&buf[1]); SetIndentLevel(PRINTSERVER); - if (Verbose > 3) + if (Raw || (Verbose > 3)) DumpItem("Error", fd, buf, n); - (void)ExtractReplyTable (fd, (short)IShort(&buf[2])); + (void)CheckReplyTable (fd, (short)IShort(&buf[2])); if (Error < 1 || Error > 17) warn("Extended Error code"); else switch (Error) @@ -951,6 +960,7 @@ DecodeError(fd, buf, n) /* */ /* ************************************************************ */ +void DecodeEvent(fd, buf, n) FD fd; unsigned char *buf; @@ -958,14 +968,8 @@ DecodeEvent(fd, buf, n) { short Event = IByte (&buf[0]); SetIndentLevel(PRINTSERVER); - if (Verbose > 3) + if (Raw || (Verbose > 3)) DumpItem("Event", fd, buf, n); - /* high-order bit means SendEvent generated */ - if (Event & 0x80) - { - debug(8,(stderr, "SendEvent generated event 0x%x\n", Event)); - Event = Event & 0x7F; - } if (Event < 2 || Event > 34) warn("Extended Event code"); else switch (Event) diff --git a/fd.c b/fd.c index 629c7fb..1df82ea 100644 --- a/fd.c +++ b/fd.c @@ -23,10 +23,44 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * \* *********************************************************** */ #include "scope.h" +#ifdef SYSV +#include +#define getdtablesize() sysconf(_SC_OPEN_MAX) +#define bzero(s,l) memset(s, 0, l) +#define bcopy(s,d,l) memmove(d,s,l) +#endif /* All of this code is to support the handling of file descriptors (FD). @@ -42,6 +76,7 @@ /* */ /* ************************************************************ */ +void InitializeFD() { register short i; @@ -49,23 +84,25 @@ InitializeFD() enterprocedure("InitializeFD"); /* get the number of file descriptors the system will let us use */ MaxFD = getdtablesize(); - if (MaxFD > StaticMaxFD) - { - fprintf(stderr, "Recompile with larger StaticMaxFD value %d\n", MaxFD); - MaxFD = StaticMaxFD; - } + if (MaxFD > FD_SETSIZE) { + MaxFD = FD_SETSIZE; + } /* allocate space for a File Descriptor (FD) Table */ FDD = (struct FDDescriptor *) Malloc ((long)(MaxFD * sizeof (struct FDDescriptor))); + if (FDD == NULL) { + panic("Can't allocate memory!"); + } + bzero(FDD, (MaxFD * sizeof (struct FDDescriptor))); /* be sure all fd's are closed and marked not busy */ for (i = 0; i < MaxFD; i++) { /* 0, 1, 2 are special (stdin, stdout, stderr) */ if (i > 2) - (void)close(i); - FDD[i].Busy = false; + close(i); + /* FDD[i].Busy = false; - not needed since false==0*/ } /* save one FD for single file input or output like debugging */ @@ -76,16 +113,18 @@ InitializeFD() FD_ZERO(&ReadDescriptors); HighestFD = 0; - UsingFD(fileno(stdin), (int (*)())NULL); - UsingFD(fileno(stdout), (int (*)())NULL); - UsingFD(fileno(stderr), (int (*)())NULL); + UsingFD(fileno(stdin), (void (*)(int))NULL, NULL); + UsingFD(fileno(stdout), (void (*)(int))NULL, NULL); + UsingFD(fileno(stderr), (void (*)(int))NULL, NULL); } /* ************************************************************ */ -UsingFD(fd, Handler) +void +UsingFD(fd, Handler, trans_conn) FD fd; - int (*Handler)(); + void (*Handler)(int); + XtransConnInfo trans_conn; { if (FDD[fd].Busy) NotUsingFD(fd); @@ -93,10 +132,13 @@ UsingFD(fd, Handler) FDD[fd].Busy = true; FDD[fd].InputHandler = Handler; +#ifdef USE_XTRANS + FDD[fd].trans_conn = trans_conn; +#endif if (Handler == NULL) - FD_CLR(fd, &ReadDescriptors); + FD_CLR(fd,&ReadDescriptors) /* clear fd bit */ ; else - FD_SET(fd, &ReadDescriptors); + FD_SET(fd,&ReadDescriptors) /* set fd bit */ ; if (fd > HighestFD) HighestFD = fd; @@ -109,6 +151,7 @@ UsingFD(fd, Handler) /* ************************************************************ */ +void NotUsingFD(fd) FD fd; { @@ -118,7 +161,7 @@ NotUsingFD(fd) nFDsInUse -= 1; FDD[fd].Busy = false; - FD_CLR(fd, &ReadDescriptors); + FD_CLR(fd,&ReadDescriptors) /* clear fd bit */ ; while (!FDD[HighestFD].Busy && HighestFD > 0) HighestFD -= 1; @@ -128,21 +171,30 @@ NotUsingFD(fd) /* ************************************************************ */ +#ifdef USE_XTRANS +XtransConnInfo GetXTransConnInfo(FD fd) +{ + return FDD[fd].trans_conn; +} +#endif + +/* ************************************************************ */ + +static void EOFonFD(fd) FD fd; { enterprocedure("EOFonFD"); debug(128,(stderr, "EOF on %d\n", fd)); - (void)close(fd); +#ifdef USE_XTRANS + if (FDD[fd].trans_conn) + _X11TransClose(FDD[fd].trans_conn); + else +#endif + close(fd); NotUsingFD(fd); } -Boolean ValidFD(fd) - FD fd; -{ - enterprocedure("ValidFD"); - return(FDD[fd].Busy); -} /* ************************************************************ */ /* */ @@ -150,8 +202,7 @@ Boolean ValidFD(fd) /* */ /* ************************************************************ */ -#include /* for struct timeval * */ -#include /* for EINTR, EADDRINUSE, ... */ +#include /* for EINTR, EADDRINUSE, ... */ extern int errno; @@ -161,19 +212,19 @@ MainLoop() while (true) { - fd_set rfds, wfds, xfds; + fd_set rfds, xfds; short nfds; short fd; /* wait for something */ rfds = ReadDescriptors; - FD_ZERO(&wfds); xfds = rfds; debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds)); - nfds = select(HighestFD + 1, &rfds, &wfds, &xfds, (struct timeval *)NULL); - debug(128,(stderr, "select nfds = 0%o, rfds = 0%o, 0%o, xfds 0%o\n", - nfds, rfds, wfds, xfds)); + 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 (nfds < 0) { @@ -206,58 +257,19 @@ MainLoop() starvation of later clients by earlier clients */ - if (!FD_ISSET(fd,&rfds)) + if (FD_ISSET(fd,&rfds) == 0) continue; nfds -= 1; - HandleInput(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); } } -} - -/* ************************************************************ */ -/* */ -/* */ -/* ************************************************************ */ - -Boolean InputAvailable(fd) -FD fd; -{ - fd_set rfds; - int nfds; - struct timeval timeout; - - enterprocedure("InputAvailable"); - FD_ZERO(&rfds); - FD_SET(fd,&rfds); - - /* use zero-valued time out */ - timeout.tv_sec = 0; - timeout.tv_usec = 0; - - debug(128,(stderr, "select %d, rfds = 0%o\n", HighestFD + 1, rfds)); - nfds = select(HighestFD + 1, &rfds, (fd_set *)NULL, (fd_set *)NULL, &timeout); - debug(128,(stderr, "select nfds = 0%o, rfds = 0%o\n", nfds, rfds)); - - if (nfds <= 0 || !FD_ISSET(fd,&rfds)) - return(false); - - if (FD_ISSET(fd,&rfds)) - return(true); - - return(false); -} - -HandleInput(fd) -FD fd; -{ - enterprocedure("HandleInput"); - if (FDD[fd].InputHandler == NULL) - { - panic("FD selected with no handler"); - debug(1,(stderr, "FD %d has NULL handler\n", fd)); - } - else - (FDD[fd].InputHandler)(fd); + return 0; } diff --git a/fd.h b/fd.h index 8836638..aa7bf06 100644 --- a/fd.h +++ b/fd.h @@ -23,15 +23,47 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * ********************************************** */ -/* +/* the following structure remembers for each file descriptor its state. In particular, we need to know if it is busy or free and if it is in use, by whom. */ - +#ifdef USE_XTRANS +#include +#else +typedef void *XtransConnInfo; +#endif #include typedef int FD; @@ -39,16 +71,25 @@ typedef int FD; struct FDDescriptor { Boolean Busy; - int (*InputHandler)(); + void (*InputHandler)(int); +#ifdef USE_XTRANS + XtransConnInfo trans_conn; +#endif }; struct FDDescriptor *FDD /* array of FD descriptors */ ; -short MaxFD /* maximum number of FD's possible */ ; - -short nFDsInUse /* number of FD's actually in use */ ; - +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 */ ; -short HighestFD /* highest FD in use -- for select */ ; +int HighestFD /* highest FD in use -- for select */ ; + +/* need to change the MaxFD to allow larger number of fd's */ +#define StaticMaxFD FD_SETSIZE -Boolean ValidFD(); -Boolean InputAvailable(); +extern void InitializeFD(void); +extern void UsingFD(FD fd, void (*Handler)(int), XtransConnInfo trans_conn); +extern void NotUsingFD(FD fd); +extern int MainLoop(void); +#ifdef USE_XTRANS +extern XtransConnInfo GetXTransConnInfo(FD fd); +#endif diff --git a/print11.c b/print11.c index 2b8f609..687bf6c 100644 --- a/print11.c +++ b/print11.c @@ -23,11 +23,43 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************** */ #include "scope.h" #include "x11.h" +static void PrintFailedSetUpReply(unsigned char *buf); +static void PrintSuccessfulSetUpReply(unsigned char *buf); +static void ListFontsWithInfoReply1(unsigned char *buf); +static void ListFontsWithInfoReply2(unsigned char *buf); + /* ************************************************************ */ /* */ @@ -64,6 +96,7 @@ /* */ /* ************************************************************ */ +void PrintSetUpMessage(buf) unsigned char *buf; { @@ -75,17 +108,17 @@ PrintSetUpMessage(buf) return; SetIndentLevel(PRINTCLIENT); PrintField(buf, 0, 1, BYTEMODE, "byte-order"); - SetByteSwapping(IByte(&buf[0])); PrintField(buf, 2, 2, CARD16, "major-version"); PrintField(buf, 4, 2, CARD16, "minor-version"); printfield(buf, 6, 2, DVALUE2(n), "length of name"); 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"); + PrintString8(&buf[12], n, "authorization-protocol-name"); + PrintString8(&buf[pad((long)(12 + n))], d, "authorization-protocol-data"); } +void PrintSetUpReply(buf) unsigned char *buf; { @@ -97,6 +130,7 @@ PrintSetUpReply(buf) PrintFailedSetUpReply(buf); } +static void PrintFailedSetUpReply(buf) unsigned char *buf; { @@ -110,9 +144,10 @@ PrintFailedSetUpReply(buf) 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"); + PrintString8(&buf[8], n, "reason"); } +static void PrintSuccessfulSetUpReply(buf) unsigned char *buf; { @@ -142,12 +177,11 @@ PrintSuccessfulSetUpReply(buf) PrintField(buf, 33, 1, CARD8, "bitmap-format-scanline-pad"); PrintField(buf, 34, 1, KEYCODE, "min-keycode"); PrintField(buf, 35, 1, KEYCODE, "max-keycode"); - PrintString8(&buf[40], (long)v, "vendor"); - (void)PrintList(&buf[pad((long)(40+v))], (long)n, FORMAT, "pixmap-formats"); - (void)PrintList(&buf[pad((long)(40+v) + 8 * n)], (long)m, SCREEN, "roots"); + PrintString8(&buf[40], v, "vendor"); + PrintList(&buf[pad((long)(40 + v))], (long)n, FORMAT, "pixmap-formats"); + PrintList(&buf[pad((long)(40 + v) + 8 * n)], (long)m, SCREEN, "roots"); } - /* ************************************************************ */ /* */ /* */ @@ -166,199 +200,216 @@ static char *REPLYHEADER = "..............REPLY"; /* Error Printing procedures */ +void RequestError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Request */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void ValueError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Value */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void WindowError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Window */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void PixmapError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Pixmap */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void AtomError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Atom */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, CARD32, "bad atom id"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void CursorError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Cursor */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void FontError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Font */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void MatchError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Match */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void DrawableError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Drawable */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void AccessError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Access */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void AllocError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Alloc */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void ColormapError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Colormap */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void GContextError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* GContext */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void IDChoiceError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* IDChoice */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 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"); } +void NameError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Name */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void LengthError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Length */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } +void ImplementationError(buf) unsigned char *buf; { PrintField(buf, 1, 1, ERROR, ERRORHEADER) /* Implementation */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 8, 2, CARD16, "minor opcode"); PrintField(buf, 10, 1, CARD8, "major opcode"); } @@ -370,6 +421,7 @@ ImplementationError(buf) /* Event Printing procedures */ +void KeyPressEvent(buf) unsigned char *buf; { @@ -377,7 +429,7 @@ KeyPressEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, KEYCODE, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -390,6 +442,7 @@ KeyPressEvent(buf) PrintField(buf, 30, 1, BOOL, "same-screen"); } +void KeyReleaseEvent(buf) unsigned char *buf; { @@ -397,7 +450,7 @@ KeyReleaseEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, KEYCODE, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -410,6 +463,7 @@ KeyReleaseEvent(buf) PrintField(buf, 30, 1, BOOL, "same-screen"); } +void ButtonPressEvent(buf) unsigned char *buf; { @@ -417,7 +471,7 @@ ButtonPressEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, BUTTON, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -430,6 +484,7 @@ ButtonPressEvent(buf) PrintField(buf, 30, 1, BOOL, "same-screen"); } +void ButtonReleaseEvent(buf) unsigned char *buf; { @@ -437,7 +492,7 @@ ButtonReleaseEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, BUTTON, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -450,6 +505,7 @@ ButtonReleaseEvent(buf) PrintField(buf, 30, 1, BOOL, "same-screen"); } +void MotionNotifyEvent(buf) unsigned char *buf; { @@ -457,7 +513,7 @@ MotionNotifyEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, MOTIONDETAIL, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -470,6 +526,7 @@ MotionNotifyEvent(buf) PrintField(buf, 30, 1, BOOL, "same-screen"); } +void EnterNotifyEvent(buf) unsigned char *buf; { @@ -477,7 +534,7 @@ EnterNotifyEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, ENTERDETAIL, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -491,6 +548,7 @@ EnterNotifyEvent(buf) PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus"); } +void LeaveNotifyEvent(buf) unsigned char *buf; { @@ -498,7 +556,7 @@ LeaveNotifyEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, ENTERDETAIL, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "event"); @@ -512,6 +570,7 @@ LeaveNotifyEvent(buf) PrintField(buf, 31, 1, SCREENFOCUS, "same-screen, focus"); } +void FocusInEvent(buf) unsigned char *buf; { @@ -519,11 +578,12 @@ FocusInEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, ENTERDETAIL, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 1, BUTTONMODE, "mode"); } +void FocusOutEvent(buf) unsigned char *buf; { @@ -531,11 +591,12 @@ FocusOutEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, ENTERDETAIL, "detail"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 1, BUTTONMODE, "mode"); } +void KeymapNotifyEvent(buf) unsigned char *buf; { @@ -545,13 +606,14 @@ KeymapNotifyEvent(buf) PrintBytes(&buf[1], (long)31,"keys"); } +void ExposeEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* Expose */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 2, CARD16, "x"); PrintField(buf, 10, 2, CARD16, "y"); @@ -560,13 +622,14 @@ ExposeEvent(buf) PrintField(buf, 16, 2, CARD16, "count"); } +void GraphicsExposureEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GraphicsExposure */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 2, CARD16, "x"); PrintField(buf, 10, 2, CARD16, "y"); @@ -577,36 +640,39 @@ GraphicsExposureEvent(buf) PrintField(buf, 20, 1, CARD8, "major-opcode"); } +void NoExposureEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* NoExposure */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 2, CARD16, "minor-opcode"); PrintField(buf, 10, 1, CARD8, "major-opcode"); } +void VisibilityNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* VisibilityNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 1, VISIBLE, "state"); } +void CreateNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CreateNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "parent"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 2, INT16, "x"); @@ -617,59 +683,64 @@ CreateNotifyEvent(buf) PrintField(buf, 22, 1, BOOL, "override-redirect"); } +void DestroyNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* DestroyNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); } +void UnmapNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* UnmapNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 1, BOOL, "from-configure"); } +void MapNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 1, BOOL, "override-redirect"); } +void MapRequestEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MapRequest */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "parent"); PrintField(buf, 8, 4, WINDOW, "window"); } +void ReparentNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ReparentNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 4, WINDOW, "parent"); @@ -678,13 +749,14 @@ ReparentNotifyEvent(buf) PrintField(buf, 20, 1, BOOL, "override-redirect"); } +void ConfigureNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ConfigureNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 4, WINDOW, "above-sibling"); @@ -696,6 +768,7 @@ ConfigureNotifyEvent(buf) PrintField(buf, 26, 1, BOOL, "override-redirect"); } +void ConfigureRequestEvent(buf) unsigned char *buf; { @@ -703,7 +776,7 @@ ConfigureRequestEvent(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, STACKMODE, "stack-mode"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "parent"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 4, WINDOW, "sibling"); @@ -715,88 +788,95 @@ ConfigureRequestEvent(buf) PrintField(buf, 26, 2, CONFIGURE_BITMASK, "value-mask"); } +void GravityNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* GravityNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); } +void ResizeRequestEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ResizeRequest */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 2, CARD16, "width"); PrintField(buf, 10, 2, CARD16, "height"); } +void CirculateNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "event"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 12, 4, WINDOW, "parent"); PrintField(buf, 16, 1, CIRSTAT, "place"); } +void CirculateRequestEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* CirculateRequest */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "parent"); PrintField(buf, 8, 4, WINDOW, "window"); PrintField(buf, 16, 1, CIRSTAT, "place"); } +void PropertyNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* PropertyNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 4, ATOM, "atom"); PrintField(buf, 12, 4, TIMESTAMP, "time"); PrintField(buf, 16, 1, PROPCHANGE, "state"); } +void SelectionClearEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionClear */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "owner"); PrintField(buf, 12, 4, ATOM, "selection"); } +void SelectionRequestEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionRequest */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "owner"); PrintField(buf, 12, 4, WINDOW, "requestor"); @@ -805,13 +885,14 @@ SelectionRequestEvent(buf) PrintField(buf, 24, 4, ATOM, "property"); } +void SelectionNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* SelectionNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, TIMESTAMP, "time"); PrintField(buf, 8, 4, WINDOW, "requestor"); PrintField(buf, 12, 4, ATOM, "selection"); @@ -819,51 +900,42 @@ SelectionNotifyEvent(buf) PrintField(buf, 20, 4, ATOM, "property"); } +void ColormapNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ColormapNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 4, COLORMAP, "colormap"); PrintField(buf, 12, 1, BOOL, "new"); PrintField(buf, 13, 1, CMAPCHANGE, "state"); } +void ClientMessageEvent(buf) unsigned char *buf; { - short format; - long type; - PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* ClientMessage */ ; if (Verbose < 1) return; PrintField(buf, 1, 1, CARD8, "format"); - format = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 4, WINDOW, "window"); PrintField(buf, 8, 4, ATOM, "type"); - type = ILong(&buf[8]); - if (type == 31 /* string */) - PrintString8(&buf[12], 20L, "data"); - else if (format == 16) - (void)PrintList(&buf[12], 10L, INT16, "data"); - else if (format == 32) - (void)PrintList(&buf[12], 5L, INT32, "data"); - else - PrintBytes(&buf[12], 20L, "data"); + PrintBytes(&buf[12], (long)20,"data"); } +void MappingNotifyEvent(buf) unsigned char *buf; { PrintField(buf, 0, 1, EVENT, EVENTHEADER) /* MappingNotify */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); PrintField(buf, 4, 1, MAPOBJECT, "request"); PrintField(buf, 5, 1, KEYCODE, "first-keycode"); PrintField(buf, 6, 1, CARD8, "count"); @@ -876,6 +948,7 @@ MappingNotifyEvent(buf) /* Request and Reply Printing procedures */ +void CreateWindow(buf) unsigned char *buf; { @@ -901,6 +974,7 @@ CreateWindow(buf) PrintValues(&buf[28], 4, WINDOW_BITMASK, &buf[32], "value-list"); } +void ChangeWindowAttributes(buf) unsigned char *buf; { @@ -917,6 +991,7 @@ ChangeWindowAttributes(buf) PrintValues(&buf[8], 4, WINDOW_BITMASK, &buf[12], "value-list"); } +void GetWindowAttributes(buf) unsigned char *buf; { @@ -931,6 +1006,7 @@ GetWindowAttributes(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void GetWindowAttributesReply(buf) unsigned char *buf; { @@ -938,7 +1014,7 @@ GetWindowAttributesReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, BACKSTORE, "backing-store"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(3), "reply length"); PrintField(buf, 8, 4, VISUALID, "visual"); PrintField(buf, 12, 2, WINDOWCLASS, "class"); @@ -956,6 +1032,7 @@ GetWindowAttributesReply(buf) PrintField(buf, 40, 2, SETofDEVICEEVENT, "do-not-propagate-mask"); } +void DestroyWindow(buf) unsigned char *buf; { @@ -970,6 +1047,7 @@ DestroyWindow(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void DestroySubwindows(buf) unsigned char *buf; { @@ -984,6 +1062,7 @@ DestroySubwindows(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void ChangeSaveSet(buf) unsigned char *buf; { @@ -999,6 +1078,7 @@ ChangeSaveSet(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void ReparentWindow(buf) unsigned char *buf; { @@ -1016,6 +1096,7 @@ ReparentWindow(buf) PrintField(buf, 14, 2, INT16, "y"); } +void MapWindow(buf) unsigned char *buf; { @@ -1030,6 +1111,7 @@ MapWindow(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void MapSubwindows(buf) unsigned char *buf; { @@ -1044,6 +1126,7 @@ MapSubwindows(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void UnmapWindow(buf) unsigned char *buf; { @@ -1058,6 +1141,7 @@ UnmapWindow(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void UnmapSubwindows(buf) unsigned char *buf; { @@ -1072,6 +1156,7 @@ UnmapSubwindows(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void ConfigureWindow(buf) unsigned char *buf; { @@ -1088,6 +1173,7 @@ ConfigureWindow(buf) PrintValues(&buf[8], 2, CONFIGURE_BITMASK, &buf[12], "value-list"); } +void CirculateWindow(buf) unsigned char *buf; { @@ -1103,6 +1189,7 @@ CirculateWindow(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void GetGeometry(buf) unsigned char *buf; { @@ -1117,6 +1204,7 @@ GetGeometry(buf) PrintField(buf, 4, 4, DRAWABLE, "drawable"); } +void GetGeometryReply(buf) unsigned char *buf; { @@ -1124,7 +1212,7 @@ GetGeometryReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, CARD8, "depth"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 2, INT16, "x"); @@ -1134,6 +1222,7 @@ GetGeometryReply(buf) PrintField(buf, 20, 2, CARD16, "border-width"); } +void QueryTree(buf) unsigned char *buf; { @@ -1148,6 +1237,7 @@ QueryTree(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void QueryTreeReply(buf) unsigned char *buf; { @@ -1155,15 +1245,16 @@ QueryTreeReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryTree */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n), "reply length"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "parent"); printfield(buf, 16, 2, DVALUE2(n), "number of children"); n = IShort(&buf[16]); - (void)PrintList(&buf[32], (long)n, WINDOW, "children"); + PrintList(&buf[32], (long)n, WINDOW, "children"); } +void InternAtom(buf) unsigned char *buf; { @@ -1179,20 +1270,22 @@ InternAtom(buf) printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); printfield(buf, 4, 2, DVALUE2(n), "length of name"); n = IShort(&buf[4]); - PrintString8(&buf[8], (long)n, "name"); + PrintString8(&buf[8], n, "name"); } +void InternAtomReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* InternAtom */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, ATOM, "atom"); } +void GetAtomName(buf) unsigned char *buf; { @@ -1207,6 +1300,7 @@ GetAtomName(buf) PrintField(buf, 4, 4, ATOM, "atom"); } +void GetAtomNameReply(buf) unsigned char *buf; { @@ -1214,18 +1308,19 @@ GetAtomNameReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetAtomName */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "length of name"); n = IShort(&buf[8]); - PrintString8(&buf[32], (long)n, "name"); + PrintString8(&buf[32], n, "name"); } +void ChangeProperty(buf) unsigned char *buf; { long n; - short format; + short unit; long type; /* Request ChangeProperty is opcode 18 */ @@ -1242,19 +1337,16 @@ ChangeProperty(buf) PrintField(buf, 12, 4, ATOM, "type"); type = ILong(&buf[12]); PrintField(buf, 16, 1, CARD8, "format"); - format = IByte(&buf[16]); + unit = IByte(&buf[16]) / 8; printfield(buf, 20, 4, CARD32, "length of data"); n = ILong(&buf[20]); if (type == 31 /* string */) - PrintString8(&buf[24], n * format/8, "data"); - else if (format == 16) - (void)PrintList(&buf[24], n, INT16, "data"); - else if (format == 32) - (void)PrintList(&buf[24], n, INT32, "data"); + PrintString8(&buf[24], n * unit, "data"); else - PrintBytes(&buf[24], n * format/8, "data"); + PrintBytes(&buf[24], n * unit, "data"); } +void DeleteProperty(buf) unsigned char *buf; { @@ -1270,6 +1362,7 @@ DeleteProperty(buf) PrintField(buf, 8, 4, ATOM, "property"); } +void GetProperty(buf) unsigned char *buf; { @@ -1289,19 +1382,20 @@ GetProperty(buf) printfield(buf, 20, 4, CARD32, "long-length"); } +void GetPropertyReply(buf) unsigned char *buf; { long n; - short format; + short unit; long type; PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetProperty */ ; if (Verbose < 1) return; PrintField(buf, 1, 1, CARD8, "format"); - format = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + unit = IByte(&buf[1]) / 8; + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); PrintField(buf, 8, 4, ATOM, "type"); type = ILong(&buf[8]); @@ -1309,15 +1403,12 @@ GetPropertyReply(buf) printfield(buf, 16, 4, CARD32, "length of value"); n = ILong(&buf[16]); if (type == 31 /* string */) - PrintString8(&buf[32], n * format/8, "value"); - else if (format == 16) - (void)PrintList(&buf[32], n, INT16, "value"); - else if (format == 32) - (void)PrintList(&buf[32], n, INT32, "value"); + PrintString8(&buf[32], n * unit, "value"); else - PrintBytes(&buf[32], n * format/8, "value"); + PrintBytes(&buf[32], n * unit, "value"); } +void ListProperties(buf) unsigned char *buf; { @@ -1332,6 +1423,7 @@ ListProperties(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void ListPropertiesReply(buf) unsigned char *buf; { @@ -1339,13 +1431,14 @@ ListPropertiesReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListProperties */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "number of atoms"); n = IShort(&buf[8]); - (void)PrintList(&buf[32], (long)n, ATOM, "atoms"); + PrintList(&buf[32], (long)n, ATOM, "atoms"); } +void SetSelectionOwner(buf) unsigned char *buf; { @@ -1362,6 +1455,7 @@ SetSelectionOwner(buf) PrintField(buf, 12, 4, TIMESTAMP, "time"); } +void GetSelectionOwner(buf) unsigned char *buf; { @@ -1376,17 +1470,19 @@ GetSelectionOwner(buf) PrintField(buf, 4, 4, ATOM, "selection"); } +void GetSelectionOwnerReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetSelectionOwner */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, WINDOW, "owner"); } +void ConvertSelection(buf) unsigned char *buf; { @@ -1405,6 +1501,7 @@ ConvertSelection(buf) PrintField(buf, 20, 4, TIMESTAMP, "time"); } +void SendEvent(buf) unsigned char *buf; { @@ -1422,6 +1519,7 @@ SendEvent(buf) PrintField(buf, 12, 32, EVENTFORM, "event"); } +void GrabPointer(buf) unsigned char *buf; { @@ -1443,6 +1541,7 @@ GrabPointer(buf) PrintField(buf, 20, 4, TIMESTAMP, "time"); } +void GrabPointerReply(buf) unsigned char *buf; { @@ -1450,10 +1549,11 @@ GrabPointerReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, GRABSTAT, "status"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); } +void UngrabPointer(buf) unsigned char *buf; { @@ -1468,6 +1568,7 @@ UngrabPointer(buf) PrintField(buf, 4, 4, TIMESTAMP, "time"); } +void GrabButton(buf) unsigned char *buf; { @@ -1490,6 +1591,7 @@ GrabButton(buf) PrintField(buf, 22, 2, SETofKEYMASK, "modifiers"); } +void UngrabButton(buf) unsigned char *buf; { @@ -1506,6 +1608,7 @@ UngrabButton(buf) PrintField(buf, 8, 2, SETofKEYMASK, "modifiers"); } +void ChangeActivePointerGrab(buf) unsigned char *buf; { @@ -1522,6 +1625,7 @@ ChangeActivePointerGrab(buf) PrintField(buf, 12, 2, SETofPOINTEREVENT, "event-mask"); } +void GrabKeyboard(buf) unsigned char *buf; { @@ -1540,6 +1644,7 @@ GrabKeyboard(buf) PrintField(buf, 13, 1, PK_MODE, "keyboard-mode"); } +void GrabKeyboardReply(buf) unsigned char *buf; { @@ -1547,10 +1652,11 @@ GrabKeyboardReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, GRABSTAT, "status"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); } +void UngrabKeyboard(buf) unsigned char *buf; { @@ -1565,6 +1671,7 @@ UngrabKeyboard(buf) PrintField(buf, 4, 4, TIMESTAMP, "time"); } +void GrabKey(buf) unsigned char *buf; { @@ -1584,6 +1691,7 @@ GrabKey(buf) PrintField(buf, 12, 1, PK_MODE, "keyboard-mode"); } +void UngrabKey(buf) unsigned char *buf; { @@ -1600,6 +1708,7 @@ UngrabKey(buf) PrintField(buf, 8, 2, SETofKEYMASK, "modifiers"); } +void AllowEvents(buf) unsigned char *buf; { @@ -1615,6 +1724,7 @@ AllowEvents(buf) PrintField(buf, 4, 4, TIMESTAMP, "time"); } +void GrabServer(buf) unsigned char *buf; { @@ -1628,6 +1738,7 @@ GrabServer(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void UngrabServer(buf) unsigned char *buf; { @@ -1641,6 +1752,7 @@ UngrabServer(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void QueryPointer(buf) unsigned char *buf; { @@ -1655,6 +1767,7 @@ QueryPointer(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void QueryPointerReply(buf) unsigned char *buf; { @@ -1662,7 +1775,7 @@ QueryPointerReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, BOOL, "same-screen"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, WINDOW, "root"); PrintField(buf, 12, 4, WINDOW, "child"); @@ -1673,6 +1786,7 @@ QueryPointerReply(buf) PrintField(buf, 24, 2, SETofKEYBUTMASK, "mask"); } +void GetMotionEvents(buf) unsigned char *buf; { @@ -1689,6 +1803,7 @@ GetMotionEvents(buf) PrintField(buf, 12, 4, TIMESTAMP, "stop"); } +void GetMotionEventsReply(buf) unsigned char *buf; { @@ -1696,13 +1811,14 @@ GetMotionEventsReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetMotionEvents */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(2*n), "reply length"); printfield(buf, 8, 4, DVALUE4(n), "number of events"); n = ILong(&buf[8]); - (void)PrintList(&buf[32], n, TIMECOORD, "events"); + PrintList(&buf[32], n, TIMECOORD, "events"); } +void TranslateCoordinates(buf) unsigned char *buf; { @@ -1720,6 +1836,7 @@ TranslateCoordinates(buf) PrintField(buf, 14, 2, INT16, "src-y"); } +void TranslateCoordinatesReply(buf) unsigned char *buf; { @@ -1727,13 +1844,14 @@ TranslateCoordinatesReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, BOOL, "same-screen"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, WINDOW, "child"); PrintField(buf, 12, 2, INT16, "dst-x"); PrintField(buf, 14, 2, INT16, "dst-y"); } +void WarpPointer(buf) unsigned char *buf; { @@ -1755,6 +1873,7 @@ WarpPointer(buf) PrintField(buf, 22, 2, INT16, "dst-y"); } +void SetInputFocus(buf) unsigned char *buf; { @@ -1771,6 +1890,7 @@ SetInputFocus(buf) PrintField(buf, 8, 4, TIMESTAMP, "time"); } +void GetInputFocus(buf) unsigned char *buf; { @@ -1784,6 +1904,7 @@ GetInputFocus(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetInputFocusReply(buf) unsigned char *buf; { @@ -1791,11 +1912,12 @@ GetInputFocusReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, FOCUSAGENT, "revert-to"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, WINDOWNR, "focus"); } +void QueryKeymap(buf) unsigned char *buf; { @@ -1809,22 +1931,23 @@ QueryKeymap(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void QueryKeymapReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryKeymap */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(2), "reply length"); PrintBytes(&buf[8], 32L, "keys"); } +void OpenFont(buf) unsigned char *buf; { short n; - /* Request OpenFont is opcode 45 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* OpenFont */ ; if (Verbose < 1) @@ -1836,9 +1959,10 @@ OpenFont(buf) PrintField(buf, 4, 4, FONT, "font-id"); printfield(buf, 8, 2, DVALUE2(n), "length of name"); n = IShort(&buf[8]); - PrintString8(&buf[12], (long)n, "name"); + PrintString8(&buf[12], n, "name"); } +void CloseFont(buf) unsigned char *buf; { @@ -1853,6 +1977,7 @@ CloseFont(buf) PrintField(buf, 4, 4, FONT, "font"); } +void QueryFont(buf) unsigned char *buf; { @@ -1867,6 +1992,7 @@ QueryFont(buf) PrintField(buf, 4, 4, FONTABLE, "font"); } +void QueryFontReply(buf) unsigned char *buf; { @@ -1877,7 +2003,7 @@ QueryFontReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryFont */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(7 + 2*n + 3*m), "reply length"); PrintField(buf, 8, 12, CHARINFO, "min-bounds"); PrintField(buf, 24, 12, CHARINFO, "max-bounds"); @@ -1895,9 +2021,10 @@ QueryFontReply(buf) printfield(buf, 56, 4, DVALUE4(m), "number of CHARINFOs"); m = ILong(&buf[56]); k = PrintList(&buf[60], (long)n, FONTPROP, "properties"); - (void)PrintList(&buf[60 + k], (long)m, CHARINFO, "char-infos"); + PrintList(&buf[60 + k], (long)m, CHARINFO, "char-infos"); } +void QueryTextExtents(buf) unsigned char *buf; { @@ -1916,9 +2043,10 @@ QueryTextExtents(buf) if (IBool(&buf[1])) n -= 1; PrintField(buf, 4, 4, FONTABLE, "font"); - PrintString16(&buf[8], (long)n, "string"); + PrintString16(&buf[8], n, "string"); } +void QueryTextExtentsReply(buf) unsigned char *buf; { @@ -1926,7 +2054,7 @@ QueryTextExtentsReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, DIRECT, "draw-direction"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, INT16, "font-ascent"); PrintField(buf, 10, 2, INT16, "font-descent"); @@ -1937,11 +2065,11 @@ QueryTextExtentsReply(buf) PrintField(buf, 24, 4, INT32, "overall-right"); } +void ListFonts(buf) unsigned char *buf; { short n; - /* Request ListFonts is opcode 49 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListFonts */ ; if (Verbose < 1) @@ -1953,9 +2081,10 @@ ListFonts(buf) PrintField(buf, 4, 2, CARD16, "max-names"); printfield(buf, 6, 2, DVALUE2(n), "length of pattern"); n = IShort(&buf[6]); - PrintString8(&buf[8], (long)n, "pattern"); + PrintString8(&buf[8], n, "pattern"); } +void ListFontsReply(buf) unsigned char *buf; { @@ -1964,18 +2093,18 @@ ListFontsReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListFonts */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); printfield(buf, 8, 2, CARD16, "number of names"); n = IShort(&buf[8]); PrintListSTR(&buf[32], (long)n, "names"); } +void ListFontsWithInfo(buf) unsigned char *buf; { short n; - /* Request ListFontsWithInfo is opcode 50 */ PrintField(buf, 0, 1, REQUEST, REQUESTHEADER) /* ListFontsWithInfo */ ; if (Verbose < 1) @@ -1987,9 +2116,10 @@ ListFontsWithInfo(buf) PrintField(buf, 4, 2, CARD16, "max-names"); printfield(buf, 6, 2, DVALUE2(n), "length of pattern"); n = IShort(&buf[6]); - PrintString8(&buf[8], (long)n, "pattern"); + PrintString8(&buf[8], n, "pattern"); } +void ListFontsWithInfoReply(buf) unsigned char *buf; { @@ -2003,10 +2133,12 @@ ListFontsWithInfoReply(buf) ListFontsWithInfoReply1(buf); KeepLastReplyExpected(); } + else ListFontsWithInfoReply2(buf); } +static void ListFontsWithInfoReply1(buf) unsigned char *buf; { @@ -2014,7 +2146,7 @@ ListFontsWithInfoReply1(buf) short m; printfield(buf, 1, 1, DVALUE1(n), "length of name in bytes"); n = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(7 + 2*m + (n + p) / 4), "reply length"); PrintField(buf, 8, 12, CHARINFO, "min-bounds"); PrintField(buf, 24, 12, CHARINFO, "max-bounds"); @@ -2030,18 +2162,20 @@ ListFontsWithInfoReply1(buf) PrintField(buf, 52, 2, INT16, "font-ascent"); PrintField(buf, 54, 2, INT16, "font-descent"); PrintField(buf, 56, 4, CARD32, "replies-hint"); - (void)PrintList(&buf[60], (long)m, FONTPROP, "properties"); - PrintString8(&buf[60 + 8 * m], (long)n, "name"); + PrintList(&buf[60], (long)m, FONTPROP, "properties"); + PrintString8(&buf[60 + 8 * m], n, "name"); } +static void ListFontsWithInfoReply2(buf) unsigned char *buf; { PrintField(buf, 1, 1, CONST1(0), "last-reply indicator"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(7), "reply length"); } +void SetFontPath(buf) unsigned char *buf; { @@ -2059,6 +2193,7 @@ SetFontPath(buf) PrintListSTR(&buf[8], (long)n, "paths"); } +void GetFontPath(buf) unsigned char *buf; { @@ -2072,6 +2207,7 @@ GetFontPath(buf) PrintField(buf, 2, 2, CONST2(1), "request list"); } +void GetFontPathReply(buf) unsigned char *buf; { @@ -2079,13 +2215,14 @@ GetFontPathReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetFontPath */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); printfield(buf, 8, 2, CARD16, "number of paths"); n = IShort(&buf[8]); PrintListSTR(&buf[32], (long)n, "paths"); } +void CreatePixmap(buf) unsigned char *buf; { @@ -2104,6 +2241,7 @@ CreatePixmap(buf) PrintField(buf, 14, 2, CARD16, "height"); } +void FreePixmap(buf) unsigned char *buf; { @@ -2118,6 +2256,7 @@ FreePixmap(buf) PrintField(buf, 4, 4, PIXMAP, "pixmap"); } +void CreateGC(buf) unsigned char *buf; { @@ -2135,6 +2274,7 @@ CreateGC(buf) PrintValues(&buf[12], 4, GC_BITMASK, &buf[16], "value-list"); } +void ChangeGC(buf) unsigned char *buf; { @@ -2151,6 +2291,7 @@ ChangeGC(buf) PrintValues(&buf[8], 4, GC_BITMASK, &buf[12], "value-list"); } +void CopyGC(buf) unsigned char *buf; { @@ -2167,6 +2308,7 @@ CopyGC(buf) PrintField(buf, 12, 4, GC_BITMASK, "value-mask"); } +void SetDashes(buf) unsigned char *buf; { @@ -2186,6 +2328,7 @@ SetDashes(buf) PrintBytes(&buf[12], (long)n, "dashes"); } +void SetClipRectangles(buf) unsigned char *buf; { @@ -2204,9 +2347,10 @@ SetClipRectangles(buf) PrintField(buf, 4, 4, GCONTEXT, "gc"); PrintField(buf, 8, 2, INT16, "clip-x-origin"); PrintField(buf, 10, 2, INT16, "clip-y-origin"); - (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); + PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); } +void FreeGC(buf) unsigned char *buf; { @@ -2221,6 +2365,7 @@ FreeGC(buf) PrintField(buf, 4, 4, GCONTEXT, "gc"); } +void ClearArea(buf) unsigned char *buf; { @@ -2240,6 +2385,7 @@ ClearArea(buf) PrintField(buf, 14, 2, CARD16, "height"); } +void CopyArea(buf) unsigned char *buf; { @@ -2262,6 +2408,7 @@ CopyArea(buf) PrintField(buf, 26, 2, CARD16, "height"); } +void CopyPlane(buf) unsigned char *buf; { @@ -2285,6 +2432,7 @@ CopyPlane(buf) PrintField(buf, 28, 4, CARD32, "bit-plane"); } +void PolyPoint(buf) unsigned char *buf; { @@ -2301,9 +2449,10 @@ PolyPoint(buf) n = (IShort(&buf[2]) - 3); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, POINT, "points"); + PrintList(&buf[12], (long)n, POINT, "points"); } +void PolyLine(buf) unsigned char *buf; { @@ -2320,9 +2469,10 @@ PolyLine(buf) n = (IShort(&buf[2]) - 3); PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, POINT, "points"); + PrintList(&buf[12], (long)n, POINT, "points"); } +void PolySegment(buf) unsigned char *buf; { @@ -2338,9 +2488,10 @@ PolySegment(buf) n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, SEGMENT, "segments"); + PrintList(&buf[12], (long)n, SEGMENT, "segments"); } +void PolyRectangle(buf) unsigned char *buf; { @@ -2356,9 +2507,10 @@ PolyRectangle(buf) n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); + PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); } +void PolyArc(buf) unsigned char *buf; { @@ -2374,9 +2526,10 @@ PolyArc(buf) n = (IShort(&buf[2]) - 3) / 3; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, ARC, "arcs"); + PrintList(&buf[12], (long)n, ARC, "arcs"); } +void FillPoly(buf) unsigned char *buf; { @@ -2394,9 +2547,10 @@ FillPoly(buf) PrintField(buf, 8, 4, GCONTEXT, "gc"); PrintField(buf, 12, 1, POLYSHAPE, "shape"); PrintField(buf, 13, 1, COORMODE, "coordinate-mode"); - (void)PrintList(&buf[16], (long)n, POINT, "points"); + PrintList(&buf[16], (long)n, POINT, "points"); } +void PolyFillRectangle(buf) unsigned char *buf; { @@ -2412,9 +2566,10 @@ PolyFillRectangle(buf) n = (IShort(&buf[2]) - 3) / 2; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); + PrintList(&buf[12], (long)n, RECTANGLE, "rectangles"); } +void PolyFillArc(buf) unsigned char *buf; { @@ -2430,9 +2585,10 @@ PolyFillArc(buf) n = (IShort(&buf[2]) - 3) / 3; PrintField(buf, 4, 4, DRAWABLE, "drawable"); PrintField(buf, 8, 4, GCONTEXT, "gc"); - (void)PrintList(&buf[12], (long)n, ARC, "arcs"); + PrintList(&buf[12], (long)n, ARC, "arcs"); } +void PutImage(buf) unsigned char *buf; { @@ -2471,6 +2627,7 @@ PutImage(buf) PrintBytes(&buf[24], (long)n, "data"); } +void GetImage(buf) unsigned char *buf; { @@ -2491,6 +2648,7 @@ GetImage(buf) PrintField(buf, 16, 4, CARD32, "plane-mask"); } +void GetImageReply(buf) unsigned char *buf; { @@ -2500,7 +2658,7 @@ GetImageReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, CARD8, "depth"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); /* to properly compute the actual size of the image, we have to remember the @@ -2511,6 +2669,7 @@ GetImageReply(buf) PrintBytes(&buf[32], n, "data"); } +void PolyText8(buf) unsigned char *buf; { @@ -2532,6 +2691,7 @@ PolyText8(buf) PrintTextList8(&buf[16], n, "items"); } +void PolyText16(buf) unsigned char *buf; { @@ -2553,6 +2713,7 @@ PolyText16(buf) PrintTextList16(&buf[16], n, "items"); } +void ImageText8(buf) unsigned char *buf; { @@ -2571,9 +2732,10 @@ ImageText8(buf) PrintField(buf, 8, 4, GCONTEXT, "gc"); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); - PrintString8(&buf[16], (long)n, "string"); + PrintString8(&buf[16], n, "string"); } +void ImageText16(buf) unsigned char *buf; { @@ -2592,9 +2754,10 @@ ImageText16(buf) PrintField(buf, 8, 4, GCONTEXT, "gc"); PrintField(buf, 12, 2, INT16, "x"); PrintField(buf, 14, 2, INT16, "y"); - PrintString16(&buf[16], (long)n, "string"); + PrintString16(&buf[16], n, "string"); } +void CreateColormap(buf) unsigned char *buf; { @@ -2612,6 +2775,7 @@ CreateColormap(buf) PrintField(buf, 12, 4, VISUALID, "visual"); } +void FreeColormap(buf) unsigned char *buf; { @@ -2626,6 +2790,7 @@ FreeColormap(buf) PrintField(buf, 4, 4, COLORMAP, "cmap"); } +void CopyColormapAndFree(buf) unsigned char *buf; { @@ -2641,6 +2806,7 @@ CopyColormapAndFree(buf) PrintField(buf, 8, 4, COLORMAP, "src-cmap"); } +void InstallColormap(buf) unsigned char *buf; { @@ -2655,6 +2821,7 @@ InstallColormap(buf) PrintField(buf, 4, 4, COLORMAP, "cmap"); } +void UninstallColormap(buf) unsigned char *buf; { @@ -2669,6 +2836,7 @@ UninstallColormap(buf) PrintField(buf, 4, 4, COLORMAP, "cmap"); } +void ListInstalledColormaps(buf) unsigned char *buf; { @@ -2683,6 +2851,7 @@ ListInstalledColormaps(buf) PrintField(buf, 4, 4, WINDOW, "window"); } +void ListInstalledColormapsReply(buf) unsigned char *buf; { @@ -2690,13 +2859,14 @@ ListInstalledColormapsReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* ListInstalledColormaps */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "number of cmaps"); n = IShort(&buf[8]); - (void)PrintList(&buf[32], (long)n, COLORMAP, "cmaps"); + PrintList(&buf[32], (long)n, COLORMAP, "cmaps"); } +void AllocColor(buf) unsigned char *buf; { @@ -2714,13 +2884,14 @@ AllocColor(buf) PrintField(buf, 12, 2, CARD16, "blue"); } +void AllocColorReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColor */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, CARD16, "red"); PrintField(buf, 10, 2, CARD16, "green"); @@ -2728,6 +2899,7 @@ AllocColorReply(buf) PrintField(buf, 16, 4, CARD32, "pixel"); } +void AllocNamedColor(buf) unsigned char *buf; { @@ -2743,16 +2915,17 @@ AllocNamedColor(buf) PrintField(buf, 4, 4, COLORMAP, "cmap"); printfield(buf, 8, 2, DVALUE2(n), "length of name"); n = IShort(&buf[8]); - PrintString8(&buf[12], (long)n, "name"); + PrintString8(&buf[12], n, "name"); } +void AllocNamedColorReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocNamedColor */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 4, CARD32, "pixel"); PrintField(buf, 12, 2, CARD16, "exact-red"); @@ -2763,6 +2936,7 @@ AllocNamedColorReply(buf) PrintField(buf, 22, 2, CARD16, "visual-blue"); } +void AllocColorCells(buf) unsigned char *buf; { @@ -2780,6 +2954,7 @@ AllocColorCells(buf) PrintField(buf, 10, 2, CARD16, "planes"); } +void AllocColorCellsReply(buf) unsigned char *buf; { @@ -2789,16 +2964,17 @@ AllocColorCellsReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorCells */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n + m), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "number of pixels"); n = IShort(&buf[8]); printfield(buf, 10, 2, DVALUE2(m), "number of masks"); m = IShort(&buf[10]); k = PrintList(&buf[32], (long)n, CARD32, "pixels"); - (void)PrintList(&buf[32 + k], (long)m, CARD32, "masks"); + PrintList(&buf[32 + k], (long)m, CARD32, "masks"); } +void AllocColorPlanes(buf) unsigned char *buf; { @@ -2818,6 +2994,7 @@ AllocColorPlanes(buf) PrintField(buf, 14, 2, CARD16, "blues"); } +void AllocColorPlanesReply(buf) unsigned char *buf; { @@ -2825,16 +3002,17 @@ AllocColorPlanesReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* AllocColorPlanes */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "number of pixels"); n = IShort(&buf[8]); PrintField(buf, 12, 4, CARD32, "red-mask"); PrintField(buf, 16, 4, CARD32, "green-mask"); PrintField(buf, 20, 4, CARD32, "blue-mask"); - (void)PrintList(&buf[32], (long)n, CARD32, "pixels"); + PrintList(&buf[32], (long)n, CARD32, "pixels"); } +void FreeColors(buf) unsigned char *buf; { @@ -2851,9 +3029,10 @@ FreeColors(buf) n = IShort(&buf[2]) - 3; PrintField(buf, 4, 4, COLORMAP, "cmap"); PrintField(buf, 8, 4, CARD32, "plane-mask"); - (void)PrintList(&buf[12], (long)n, CARD32, "pixels"); + PrintList(&buf[12], (long)n, CARD32, "pixels"); } +void StoreColors(buf) unsigned char *buf; { @@ -2868,9 +3047,10 @@ StoreColors(buf) printfield(buf, 2, 2, DVALUE2(2 + 3*n), "request length"); n = (IShort(&buf[2]) - 2) / 3; PrintField(buf, 4, 4, COLORMAP, "cmap"); - (void)PrintList(&buf[8], (long)n, COLORITEM, "items"); + PrintList(&buf[8], (long)n, COLORITEM, "items"); } +void StoreNamedColor(buf) unsigned char *buf; { @@ -2888,9 +3068,10 @@ StoreNamedColor(buf) PrintField(buf, 8, 4, CARD32, "pixel"); printfield(buf, 12, 2, DVALUE2(n), "length of name"); n = IShort(&buf[12]); - PrintString8(&buf[16], (long)n, "name"); + PrintString8(&buf[16], n, "name"); } +void QueryColors(buf) unsigned char *buf; { @@ -2905,9 +3086,10 @@ QueryColors(buf) printfield(buf, 2, 2, DVALUE2(2 + n), "request length"); n = IShort(&buf[2]) - 2; PrintField(buf, 4, 4, COLORMAP, "cmap"); - (void)PrintList(&buf[8], (long)n, CARD32, "pixels"); + PrintList(&buf[8], (long)n, CARD32, "pixels"); } +void QueryColorsReply(buf) unsigned char *buf; { @@ -2915,13 +3097,14 @@ QueryColorsReply(buf) PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryColors */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(2*n), "reply length"); printfield(buf, 8, 2, DVALUE2(n), "number of colors"); n = IShort(&buf[8]); - (void)PrintList(&buf[32], (long)n, RGB, "colors"); + PrintList(&buf[32], (long)n, RGB, "colors"); } +void LookupColor(buf) unsigned char *buf; { @@ -2937,16 +3120,17 @@ LookupColor(buf) PrintField(buf, 4, 4, COLORMAP, "cmap"); printfield(buf, 8, 2, DVALUE2(n), "length of name"); n = IShort(&buf[8]); - PrintString8(&buf[12], (long)n, "name"); + PrintString8(&buf[12], n, "name"); } +void LookupColorReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* LookupColor */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, CARD16, "exact-red"); PrintField(buf, 10, 2, CARD16, "exact-green"); @@ -2956,6 +3140,7 @@ LookupColorReply(buf) PrintField(buf, 18, 2, CARD16, "visual-blue"); } +void CreateCursor(buf) unsigned char *buf; { @@ -2980,6 +3165,7 @@ CreateCursor(buf) PrintField(buf, 30, 2, CARD16, "y"); } +void CreateGlyphCursor(buf) unsigned char *buf; { @@ -3004,6 +3190,7 @@ CreateGlyphCursor(buf) PrintField(buf, 30, 2, CARD16, "back-blue"); } +void FreeCursor(buf) unsigned char *buf; { @@ -3018,6 +3205,7 @@ FreeCursor(buf) PrintField(buf, 4, 4, CURSOR, "cursor"); } +void RecolorCursor(buf) unsigned char *buf; { @@ -3038,6 +3226,7 @@ RecolorCursor(buf) PrintField(buf, 18, 2, CARD16, "back-blue"); } +void QueryBestSize(buf) unsigned char *buf; { @@ -3055,18 +3244,20 @@ QueryBestSize(buf) PrintField(buf, 10, 2, CARD16, "height"); } +void QueryBestSizeReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryBestSize */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, CARD16, "width"); PrintField(buf, 10, 2, CARD16, "height"); } +void QueryExtension(buf) unsigned char *buf; { @@ -3081,16 +3272,17 @@ QueryExtension(buf) printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); printfield(buf, 4, 2, DVALUE2(n), "length of name"); n = IShort(&buf[4]); - PrintString8(&buf[8], (long)n, "name"); + PrintString8(&buf[8], n, "name"); } +void QueryExtensionReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* QueryExtension */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 1, BOOL, "present"); PrintField(buf, 9, 1, CARD8, "major-opcode"); @@ -3098,6 +3290,7 @@ QueryExtensionReply(buf) PrintField(buf, 11, 1, CARD8, "first-error"); } +void ListExtensions(buf) unsigned char *buf; { @@ -3111,6 +3304,7 @@ ListExtensions(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void ListExtensionsReply(buf) unsigned char *buf; { @@ -3121,11 +3315,12 @@ ListExtensionsReply(buf) return; printfield(buf, 1, 1, CARD8, "number names"); n = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); PrintListSTR(&buf[32], (long)n, "names"); } +void ChangeKeyboardMapping(buf) unsigned char *buf; { @@ -3144,9 +3339,10 @@ ChangeKeyboardMapping(buf) PrintField(buf, 4, 1, KEYCODE, "first-keycode"); PrintField(buf, 5, 1, DVALUE1(m), "keysyms-per-keycode"); m = IByte(&buf[5]); - (void)PrintList(&buf[8], (long)(n * m), KEYSYM, "keysyms"); + PrintList(&buf[8], (long)(n * m), KEYSYM, "keysyms"); } +void GetKeyboardMapping(buf) unsigned char *buf; { @@ -3162,6 +3358,7 @@ GetKeyboardMapping(buf) PrintField(buf, 5, 1, CARD8, "count"); } +void GetKeyboardMappingReply(buf) unsigned char *buf; { @@ -3170,12 +3367,13 @@ GetKeyboardMappingReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, DVALUE1(n), "keysyms-per-keycode"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n*m), "reply length"); n = ILong(&buf[4]); - (void)PrintList(&buf[32], n, KEYSYM, "keysyms"); + PrintList(&buf[32], n, KEYSYM, "keysyms"); } +void ChangeKeyboardControl(buf) unsigned char *buf; { @@ -3191,6 +3389,7 @@ ChangeKeyboardControl(buf) PrintValues(&buf[4], 4, KEYBOARD_BITMASK, &buf[8], "value-list"); } +void GetKeyboardControl(buf) unsigned char *buf; { @@ -3204,6 +3403,7 @@ GetKeyboardControl(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetKeyboardControlReply(buf) unsigned char *buf; { @@ -3211,7 +3411,7 @@ GetKeyboardControlReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, OFF_ON, "global-auto-repeat"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(5), "reply length"); PrintField(buf, 8, 4, CARD32, "led-mask"); PrintField(buf, 12, 1, CARD8, "key-click-percent"); @@ -3221,6 +3421,7 @@ GetKeyboardControlReply(buf) PrintBytes(&buf[20], 32L, "auto-repeats"); } +void Bell(buf) unsigned char *buf; { @@ -3235,6 +3436,7 @@ Bell(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void ChangePointerControl(buf) unsigned char *buf; { @@ -3253,6 +3455,7 @@ ChangePointerControl(buf) PrintField(buf, 11, 1, BOOL, "do-threshold"); } +void GetPointerControl(buf) unsigned char *buf; { @@ -3266,19 +3469,21 @@ GetPointerControl(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetPointerControlReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetPointerControl */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, CARD16, "acceleration-numerator"); PrintField(buf, 10, 2, CARD16, "acceleration-denominator"); PrintField(buf, 12, 2, CARD16, "threshold"); } +void SetScreenSaver(buf) unsigned char *buf; { @@ -3296,6 +3501,7 @@ SetScreenSaver(buf) PrintField(buf, 9, 1, NO_YES, "allow-exposures"); } +void GetScreenSaver(buf) unsigned char *buf; { @@ -3309,13 +3515,14 @@ GetScreenSaver(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetScreenSaverReply(buf) unsigned char *buf; { PrintField(RBf, 0, 1, REPLY, REPLYHEADER) /* GetScreenSaver */ ; if (Verbose < 1) return; - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); PrintField(buf, 8, 2, CARD16, "timeout"); PrintField(buf, 10, 2, CARD16, "interval"); @@ -3323,6 +3530,7 @@ GetScreenSaverReply(buf) PrintField(buf, 13, 1, NO_YES, "allow-exposures"); } +void ChangeHosts(buf) unsigned char *buf; { @@ -3336,12 +3544,17 @@ ChangeHosts(buf) PrintField(buf, 1, 1, INS_DEL, "mode"); printfield(buf, 2, 2, DVALUE2(2 + (n + p) / 4), "request length"); + n = IShort(&buf[6]); +#if 0 PrintField(buf, 4, 1, HOSTFAMILY, "family"); printfield(buf, 6, 2, CARD16, "length of address"); - n = IShort(&buf[6]); PrintBytes(&buf[8], (long)n, "address"); +#else + PrintField(buf, 4, 4+n, HOST, "host"); +#endif } +void ListHosts(buf) unsigned char *buf; { @@ -3355,6 +3568,7 @@ ListHosts(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void ListHostsReply(buf) unsigned char *buf; { @@ -3363,13 +3577,14 @@ ListHostsReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, DIS_EN, "mode"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(n / 4), "reply length"); printfield(buf, 8, 2, CARD16, "number of hosts"); n = IShort(&buf[8]); - (void)PrintList(&buf[32], (long)n, HOST, "hosts"); + PrintList(&buf[32], (long)n, HOST, "hosts"); } +void SetAccessControl(buf) unsigned char *buf; { @@ -3384,6 +3599,7 @@ SetAccessControl(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void SetCloseDownMode(buf) unsigned char *buf; { @@ -3398,6 +3614,7 @@ SetCloseDownMode(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void KillClient(buf) unsigned char *buf; { @@ -3412,6 +3629,7 @@ KillClient(buf) PrintField(buf, 4, 4, RESOURCEID, "resource"); } +void RotateProperties(buf) unsigned char *buf; { @@ -3428,9 +3646,10 @@ RotateProperties(buf) printfield(buf, 8, 2, DVALUE2(n), "number of properties"); n = IShort(&buf[8]); PrintField(buf, 10, 2, INT16, "delta"); - (void)PrintList(&buf[12], (long)n, ATOM, "properties"); + PrintList(&buf[12], (long)n, ATOM, "properties"); } +void ForceScreenSaver(buf) unsigned char *buf; { @@ -3445,6 +3664,7 @@ ForceScreenSaver(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void SetPointerMapping(buf) unsigned char *buf; { @@ -3462,6 +3682,7 @@ SetPointerMapping(buf) PrintBytes(&buf[4], (long)n,"map"); } +void SetPointerMappingReply(buf) unsigned char *buf; { @@ -3469,10 +3690,11 @@ SetPointerMappingReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, RSTATUS, "status"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); } +void GetPointerMapping(buf) unsigned char *buf; { @@ -3486,6 +3708,7 @@ GetPointerMapping(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetPointerMappingReply(buf) unsigned char *buf; { @@ -3495,11 +3718,12 @@ GetPointerMappingReply(buf) return; printfield(buf, 1, 1, DVALUE1(n), "length of map"); n = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4((n + p) / 4), "reply length"); PrintBytes(&buf[32], (long)n,"map"); } +void SetModifierMapping(buf) unsigned char *buf; { @@ -3524,6 +3748,7 @@ SetModifierMapping(buf) PrintBytes(&buf[4 + 7 * n], (long)n,"Mod5 keycodes"); } +void SetModifierMappingReply(buf) unsigned char *buf; { @@ -3531,10 +3756,11 @@ SetModifierMappingReply(buf) if (Verbose < 1) return; PrintField(buf, 1, 1, RSTATUS, "status"); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, CONST4(0), "reply length"); } +void GetModifierMapping(buf) unsigned char *buf; { @@ -3548,6 +3774,7 @@ GetModifierMapping(buf) printfield(buf, 2, 2, CONST2(1), "request length"); } +void GetModifierMappingReply(buf) unsigned char *buf; { @@ -3557,11 +3784,12 @@ GetModifierMappingReply(buf) return; PrintField(buf, 1, 1, DVALUE1(n), "keycodes-per-modifier"); n = IByte(&buf[1]); - printfield(buf, 2, 2, INT16, "sequence number"); + printfield(buf, 2, 2, CARD16, "sequence number"); printfield(buf, 4, 4, DVALUE4(2*n), "reply length"); - (void)PrintList(&buf[32], (long)n, KEYCODE, "keycodes"); + PrintList(&buf[32], (long)n, KEYCODE, "keycodes"); } +void NoOperation(buf) unsigned char *buf; { diff --git a/proto.h b/proto.h new file mode 100644 index 0000000..397cb6b --- /dev/null +++ b/proto.h @@ -0,0 +1,266 @@ +#include "x11.h" + +/* common.c */ +void enterprocedure(char *s); +void warn(char *s); +void panic(char *s); +void *Malloc(long n); +void Free(void *p); +void SetSignalHandling(void); +void SetUpConnectionSocket(int iport); +/* decode11.c */ +void InitReplyQ(void); +void FlushReplyQ(FD fd); +void KeepLastReplyExpected(void); +void DecodeRequest(FD fd, unsigned char *buf, long n); +void DecodeReply(FD fd, unsigned char *buf, long n); +void DecodeError(FD fd, unsigned char *buf, long n); +void DecodeEvent(FD fd, unsigned char *buf, long n); +/* print11.c */ +void PrintSetUpMessage(unsigned char *buf); +void PrintSetUpReply(unsigned char *buf); +void RequestError(unsigned char *buf); +void ValueError(unsigned char *buf); +void WindowError(unsigned char *buf); +void PixmapError(unsigned char *buf); +void AtomError(unsigned char *buf); +void CursorError(unsigned char *buf); +void FontError(unsigned char *buf); +void MatchError(unsigned char *buf); +void DrawableError(unsigned char *buf); +void AccessError(unsigned char *buf); +void AllocError(unsigned char *buf); +void ColormapError(unsigned char *buf); +void GContextError(unsigned char *buf); +void IDChoiceError(unsigned char *buf); +void NameError(unsigned char *buf); +void LengthError(unsigned char *buf); +void ImplementationError(unsigned char *buf); +void KeyPressEvent(unsigned char *buf); +void KeyReleaseEvent(unsigned char *buf); +void ButtonPressEvent(unsigned char *buf); +void ButtonReleaseEvent(unsigned char *buf); +void MotionNotifyEvent(unsigned char *buf); +void EnterNotifyEvent(unsigned char *buf); +void LeaveNotifyEvent(unsigned char *buf); +void FocusInEvent(unsigned char *buf); +void FocusOutEvent(unsigned char *buf); +void KeymapNotifyEvent(unsigned char *buf); +void ExposeEvent(unsigned char *buf); +void GraphicsExposureEvent(unsigned char *buf); +void NoExposureEvent(unsigned char *buf); +void VisibilityNotifyEvent(unsigned char *buf); +void CreateNotifyEvent(unsigned char *buf); +void DestroyNotifyEvent(unsigned char *buf); +void UnmapNotifyEvent(unsigned char *buf); +void MapNotifyEvent(unsigned char *buf); +void MapRequestEvent(unsigned char *buf); +void ReparentNotifyEvent(unsigned char *buf); +void ConfigureNotifyEvent(unsigned char *buf); +void ConfigureRequestEvent(unsigned char *buf); +void GravityNotifyEvent(unsigned char *buf); +void ResizeRequestEvent(unsigned char *buf); +void CirculateNotifyEvent(unsigned char *buf); +void CirculateRequestEvent(unsigned char *buf); +void PropertyNotifyEvent(unsigned char *buf); +void SelectionClearEvent(unsigned char *buf); +void SelectionRequestEvent(unsigned char *buf); +void SelectionNotifyEvent(unsigned char *buf); +void ColormapNotifyEvent(unsigned char *buf); +void ClientMessageEvent(unsigned char *buf); +void MappingNotifyEvent(unsigned char *buf); +void CreateWindow(unsigned char *buf); +void ChangeWindowAttributes(unsigned char *buf); +void GetWindowAttributes(unsigned char *buf); +void GetWindowAttributesReply(unsigned char *buf); +void DestroyWindow(unsigned char *buf); +void DestroySubwindows(unsigned char *buf); +void ChangeSaveSet(unsigned char *buf); +void ReparentWindow(unsigned char *buf); +void MapWindow(unsigned char *buf); +void MapSubwindows(unsigned char *buf); +void UnmapWindow(unsigned char *buf); +void UnmapSubwindows(unsigned char *buf); +void ConfigureWindow(unsigned char *buf); +void CirculateWindow(unsigned char *buf); +void GetGeometry(unsigned char *buf); +void GetGeometryReply(unsigned char *buf); +void QueryTree(unsigned char *buf); +void QueryTreeReply(unsigned char *buf); +void InternAtom(unsigned char *buf); +void InternAtomReply(unsigned char *buf); +void GetAtomName(unsigned char *buf); +void GetAtomNameReply(unsigned char *buf); +void ChangeProperty(unsigned char *buf); +void DeleteProperty(unsigned char *buf); +void GetProperty(unsigned char *buf); +void GetPropertyReply(unsigned char *buf); +void ListProperties(unsigned char *buf); +void ListPropertiesReply(unsigned char *buf); +void SetSelectionOwner(unsigned char *buf); +void GetSelectionOwner(unsigned char *buf); +void GetSelectionOwnerReply(unsigned char *buf); +void ConvertSelection(unsigned char *buf); +void SendEvent(unsigned char *buf); +void GrabPointer(unsigned char *buf); +void GrabPointerReply(unsigned char *buf); +void UngrabPointer(unsigned char *buf); +void GrabButton(unsigned char *buf); +void UngrabButton(unsigned char *buf); +void ChangeActivePointerGrab(unsigned char *buf); +void GrabKeyboard(unsigned char *buf); +void GrabKeyboardReply(unsigned char *buf); +void UngrabKeyboard(unsigned char *buf); +void GrabKey(unsigned char *buf); +void UngrabKey(unsigned char *buf); +void AllowEvents(unsigned char *buf); +void GrabServer(unsigned char *buf); +void UngrabServer(unsigned char *buf); +void QueryPointer(unsigned char *buf); +void QueryPointerReply(unsigned char *buf); +void GetMotionEvents(unsigned char *buf); +void GetMotionEventsReply(unsigned char *buf); +void TranslateCoordinates(unsigned char *buf); +void TranslateCoordinatesReply(unsigned char *buf); +void WarpPointer(unsigned char *buf); +void SetInputFocus(unsigned char *buf); +void GetInputFocus(unsigned char *buf); +void GetInputFocusReply(unsigned char *buf); +void QueryKeymap(unsigned char *buf); +void QueryKeymapReply(unsigned char *buf); +void OpenFont(unsigned char *buf); +void CloseFont(unsigned char *buf); +void QueryFont(unsigned char *buf); +void QueryFontReply(unsigned char *buf); +void QueryTextExtents(unsigned char *buf); +void QueryTextExtentsReply(unsigned char *buf); +void ListFonts(unsigned char *buf); +void ListFontsReply(unsigned char *buf); +void ListFontsWithInfo(unsigned char *buf); +void ListFontsWithInfoReply(unsigned char *buf); +void SetFontPath(unsigned char *buf); +void GetFontPath(unsigned char *buf); +void GetFontPathReply(unsigned char *buf); +void CreatePixmap(unsigned char *buf); +void FreePixmap(unsigned char *buf); +void CreateGC(unsigned char *buf); +void ChangeGC(unsigned char *buf); +void CopyGC(unsigned char *buf); +void SetDashes(unsigned char *buf); +void SetClipRectangles(unsigned char *buf); +void FreeGC(unsigned char *buf); +void ClearArea(unsigned char *buf); +void CopyArea(unsigned char *buf); +void CopyPlane(unsigned char *buf); +void PolyPoint(unsigned char *buf); +void PolyLine(unsigned char *buf); +void PolySegment(unsigned char *buf); +void PolyRectangle(unsigned char *buf); +void PolyArc(unsigned char *buf); +void FillPoly(unsigned char *buf); +void PolyFillRectangle(unsigned char *buf); +void PolyFillArc(unsigned char *buf); +void PutImage(unsigned char *buf); +void GetImage(unsigned char *buf); +void GetImageReply(unsigned char *buf); +void PolyText8(unsigned char *buf); +void PolyText16(unsigned char *buf); +void ImageText8(unsigned char *buf); +void ImageText16(unsigned char *buf); +void CreateColormap(unsigned char *buf); +void FreeColormap(unsigned char *buf); +void CopyColormapAndFree(unsigned char *buf); +void InstallColormap(unsigned char *buf); +void UninstallColormap(unsigned char *buf); +void ListInstalledColormaps(unsigned char *buf); +void ListInstalledColormapsReply(unsigned char *buf); +void AllocColor(unsigned char *buf); +void AllocColorReply(unsigned char *buf); +void AllocNamedColor(unsigned char *buf); +void AllocNamedColorReply(unsigned char *buf); +void AllocColorCells(unsigned char *buf); +void AllocColorCellsReply(unsigned char *buf); +void AllocColorPlanes(unsigned char *buf); +void AllocColorPlanesReply(unsigned char *buf); +void FreeColors(unsigned char *buf); +void StoreColors(unsigned char *buf); +void StoreNamedColor(unsigned char *buf); +void QueryColors(unsigned char *buf); +void QueryColorsReply(unsigned char *buf); +void LookupColor(unsigned char *buf); +void LookupColorReply(unsigned char *buf); +void CreateCursor(unsigned char *buf); +void CreateGlyphCursor(unsigned char *buf); +void FreeCursor(unsigned char *buf); +void RecolorCursor(unsigned char *buf); +void QueryBestSize(unsigned char *buf); +void QueryBestSizeReply(unsigned char *buf); +void QueryExtension(unsigned char *buf); +void QueryExtensionReply(unsigned char *buf); +void ListExtensions(unsigned char *buf); +void ListExtensionsReply(unsigned char *buf); +void ChangeKeyboardMapping(unsigned char *buf); +void GetKeyboardMapping(unsigned char *buf); +void GetKeyboardMappingReply(unsigned char *buf); +void ChangeKeyboardControl(unsigned char *buf); +void GetKeyboardControl(unsigned char *buf); +void GetKeyboardControlReply(unsigned char *buf); +void Bell(unsigned char *buf); +void ChangePointerControl(unsigned char *buf); +void GetPointerControl(unsigned char *buf); +void GetPointerControlReply(unsigned char *buf); +void SetScreenSaver(unsigned char *buf); +void GetScreenSaver(unsigned char *buf); +void GetScreenSaverReply(unsigned char *buf); +void ChangeHosts(unsigned char *buf); +void ListHosts(unsigned char *buf); +void ListHostsReply(unsigned char *buf); +void SetAccessControl(unsigned char *buf); +void SetCloseDownMode(unsigned char *buf); +void KillClient(unsigned char *buf); +void RotateProperties(unsigned char *buf); +void ForceScreenSaver(unsigned char *buf); +void SetPointerMapping(unsigned char *buf); +void SetPointerMappingReply(unsigned char *buf); +void GetPointerMapping(unsigned char *buf); +void GetPointerMappingReply(unsigned char *buf); +void SetModifierMapping(unsigned char *buf); +void SetModifierMappingReply(unsigned char *buf); +void GetModifierMapping(unsigned char *buf); +void GetModifierMappingReply(unsigned char *buf); +void NoOperation(unsigned char *buf); +/* prtype.c */ +void SetIndentLevel(int which); +void DumpItem(char *name, FD fd, unsigned char *buf, long n); +void PrintField(unsigned char *buf, int start, int length, int FieldType, char *name); +long PrintList(unsigned char *buf, long number, int ListType, char *name); +long PrintListSTR(unsigned char *buf, long number, char *name); +int PrintBytes(unsigned char buf[], long number, char *name); +int PrintString8(unsigned char buf[], int number, char *name); +int PrintString16(unsigned char buf[], int number, char *name); +void PrintValues(unsigned char *control, int clength, int ctype, unsigned char *values, char *name); +int PrintTextList8(unsigned char *buf, int length, char *name); +int PrintTextList16(unsigned char *buf, int length, char *name); +/* scope.c */ +void TimerExpired(void); +FD FDPair(FD fd); +FD ClientHalf(FD fd); +FD ServerHalf(FD fd); +char *ClientName(FD fd); +void NewConnection(FD fd); +/* server.c */ +void ReportFromClient(FD fd, unsigned char *buf, long n); +void ReportFromServer(FD fd, unsigned char *buf, long n); +void PrintTime(void); +long pad(long n); +unsigned long ILong(unsigned char buf[]); +unsigned short IShort(unsigned char buf[]); +unsigned short IByte(unsigned char buf[]); +short IBool(unsigned char buf[]); +void StartClientConnection(FD fd); +void StopClientConnection(FD fd); +void StartServerConnection(FD fd); +void StopServerConnection(FD fd); +/* table11.c */ +void InitializeX11(void); + diff --git a/prtype.c b/prtype.c index 685943a..b892b51 100644 --- a/prtype.c +++ b/prtype.c @@ -23,11 +23,40 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************** */ #include "scope.h" #include "x11.h" +static void DumpHexBuffer(unsigned char *buf, long n); + /* For each of the types we need a way to print that type. Types are of varieties: @@ -47,7 +76,7 @@ /* print representation of a character for debugging */ -char *printrep (c) +static char *printrep (c) unsigned short c; { static char pr[8]; @@ -62,7 +91,7 @@ char *printrep (c) else if (c < 127) { /* printing characters */ - pr[0] = c; + pr[0] = (char) c; pr[1] = '\0'; } else if (c == 127) @@ -81,7 +110,7 @@ char *printrep (c) else { /* very large number -- print as 0xffff - 4 digit hex */ - (void)sprintf(pr, "0x%04x", c); + sprintf(pr, "0x%04x", c); } return(pr); } @@ -106,6 +135,7 @@ char *printrep (c) static char Leader[MaxIndent + 1]; static short CurrentLevel = 0; +void SetIndentLevel(which) short which; { @@ -126,13 +156,14 @@ SetIndentLevel(which) CurrentLevel = which; } +static void ModifyIndentLevel(amount) short amount; { SetIndentLevel(CurrentLevel + amount); } -short SizeofLeader () +static short SizeofLeader () { return (CurrentLevel * 8); } @@ -144,6 +175,7 @@ short SizeofLeader () /* if we want verbose enough output, we will dump the buffer in hex */ +void DumpItem(name, fd, buf, n) char *name; FD fd; @@ -170,9 +202,8 @@ PrintINT8(buf) /* print a INT8 -- 8-bit signed integer */ short n = IByte (buf); if (n > 127) - n = n - 256; - fprintf(stdout, "%d", n); - return(1); + n = 256 - n; + return fprintf(stdout, "%d", n); } PrintINT16(buf) @@ -181,9 +212,8 @@ PrintINT16(buf) /* print a INT16 -- 16-bit signed integer */ long n = IShort (buf); if (n > 32767) - n = n - 65536; - fprintf(stdout, "%d", n); - return(2); + n = 65536 - n; + return fprintf(stdout, "%d", n); } PrintINT32(buf) @@ -191,8 +221,7 @@ PrintINT32(buf) { /* print a INT32 -- 32-bit signed integer */ long n = ILong (buf); - fprintf(stdout, "%d", n); - return(4); + return fprintf(stdout, "%d", n); } /* ************************************************************ */ @@ -201,9 +230,8 @@ PrintCARD8(buf) unsigned char *buf; { /* print a CARD8 -- 8-bit unsigned integer */ - short n = IByte (buf); - fprintf(stdout, "%02x", (unsigned)(n & 0xff)); - return(1); + unsigned short n = IByte (buf); + return fprintf(stdout, "%02x", (unsigned)(n & 0xff)); } PrintCARD16(buf) @@ -211,8 +239,7 @@ PrintCARD16(buf) { /* print a CARD16 -- 16-bit unsigned integer */ unsigned long n = IShort (buf); - fprintf(stdout, "%04x", (unsigned)(n & 0xffff)); - return(2); + return fprintf(stdout, "%04x", (unsigned)(n & 0xffff)); } PrintCARD32(buf) @@ -249,8 +276,8 @@ PrintCHAR8(buf) PrintSTRING16(buf) unsigned char *buf; { - /* print a CHAR2B -- 16-bit character which is never byte-swapped */ - unsigned short n = IChar2B (buf); + /* print a CHAR16 -- 16-bit character */ + unsigned short n = IShort (buf); fprintf(stdout, "%s", printrep(n)); return(1); } @@ -288,12 +315,11 @@ PrintWINDOWD(buf) /* print a WINDOWD -- CARD32 plus 0 = PointerWindow, 1 = InputFocus */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "PointerWindow"); + return fprintf(stdout, "PointerWindow"); else if (n == 1) - fprintf(stdout, "InputFocus"); + return fprintf(stdout, "InputFocus"); else - (void)PrintWINDOW(buf); - return(4); + return PrintWINDOW(buf); } PrintWINDOWNR(buf) @@ -302,12 +328,11 @@ PrintWINDOWNR(buf) /* print a WINDOWNR -- CARD32 plus 0 = None, 1 = PointerRoot */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else if (n == 1) - fprintf(stdout, "PointerRoot"); + return fprintf(stdout, "PointerRoot"); else - (void)PrintWINDOW(buf); - return(4); + return PrintWINDOW(buf); } @@ -317,10 +342,9 @@ PrintPIXMAP(buf) /* print a PIXMAP -- CARD32 plus 0 = None */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else - fprintf(stdout, "PXM %08x", n); - return(4); + return fprintf(stdout, "PXM %08x", n); } PrintPIXMAPNPR(buf) @@ -329,12 +353,11 @@ PrintPIXMAPNPR(buf) /* print a PIXMAPNPR -- CARD32 plus 0 = None, 1 = ParentRelative */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else if (n == 1) - fprintf(stdout, "ParentRelative"); + return fprintf(stdout, "ParentRelative"); else - PrintPIXMAP(buf); - return(4); + return PrintPIXMAP(buf); } PrintPIXMAPC(buf) @@ -343,10 +366,9 @@ PrintPIXMAPC(buf) /* print a PIXMAPC -- CARD32 plus 0 = CopyFromParent */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "CopyFromParent"); + return fprintf(stdout, "CopyFromParent"); else - PrintPIXMAP(buf); - return(4); + return PrintPIXMAP(buf); } @@ -356,10 +378,9 @@ PrintCURSOR(buf) /* print a CURSOR -- CARD32 plus 0 = None */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else - fprintf(stdout, "CUR %08x", n); - return(4); + return fprintf(stdout, "CUR %08x", n); } @@ -369,10 +390,9 @@ PrintFONT(buf) /* print a FONT -- CARD32 plus 0 = None */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else - fprintf(stdout, "FNT %08x", n); - return(4); + return fprintf(stdout, "FNT %08x", n); } @@ -381,8 +401,7 @@ PrintGCONTEXT(buf) { /* print a GCONTEXT -- CARD32 */ long n = ILong (buf); - fprintf(stdout, "GXC %08x", n); - return(4); + return fprintf(stdout, "GXC %08x", n); } @@ -404,10 +423,9 @@ PrintCOLORMAPC(buf) /* print a COLORMAPC -- CARD32 plus 0 = CopyFromParent */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "CopyFromParent"); + return fprintf(stdout, "CopyFromParent"); else - (void)PrintCOLORMAP(buf); - return(4); + return PrintCOLORMAP(buf); } @@ -416,8 +434,7 @@ PrintDRAWABLE(buf) { /* print a DRAWABLE -- CARD32 */ long n = ILong (buf); - fprintf(stdout, "DWB %08x", n); - return(4); + return fprintf(stdout, "DWB %08x", n); } PrintFONTABLE(buf) @@ -425,15 +442,14 @@ PrintFONTABLE(buf) { /* print a FONTABLE -- CARD32 */ long n = ILong (buf); - fprintf(stdout, "FTB %08x", n); - return(4); + return fprintf(stdout, "FTB %08x", n); } /* ************************************************************ */ #define NumberofAtoms 68 -char *AtomTable[NumberofAtoms + 1] = +static char *AtomTable[NumberofAtoms + 1] = { "NONE", "PRIMARY", "SECONDARY", "ARC", "ATOM", "BITMAP", "CARDINAL", "COLORMAP", "CURSOR", "CUT_BUFFER0", "CUT_BUFFER1", "CUT_BUFFER2", @@ -473,10 +489,9 @@ PrintATOMT(buf) /* print a ATOMT -- CARD32 plus 0 = AnyPropertyType */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "AnyPropertyType"); + return fprintf(stdout, "AnyPropertyType"); else - (void)PrintATOM(buf); - return(4); + return PrintATOM(buf); } @@ -486,10 +501,9 @@ PrintVISUALID(buf) /* print a VISUALID -- CARD32 plus 0 = None */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "None"); + return fprintf(stdout, "None"); else - fprintf(stdout, "VIS %08x", n); - return(4); + return fprintf(stdout, "VIS %08x", n); } PrintVISUALIDC(buf) @@ -498,10 +512,9 @@ PrintVISUALIDC(buf) /* print a VISUALIDC -- CARD32 plus 0 = CopyFromParent */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "CopyFromParent"); + return fprintf(stdout, "CopyFromParent"); else - PrintVISUALID(buf); - return(4); + return PrintVISUALID(buf); } @@ -511,10 +524,9 @@ PrintTIMESTAMP(buf) /* print a TIMESTAMP -- CARD32 plus 0 as the current time */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "CurrentTime"); + return fprintf(stdout, "CurrentTime"); else - fprintf(stdout, "TIM %08x", n); - return(4); + return fprintf(stdout, "TIM %08x", n); } @@ -524,10 +536,9 @@ PrintRESOURCEID(buf) /* print a RESOURCEID -- CARD32 plus 0 = AllTemporary */ long n = ILong (buf); if (n == 0) - fprintf(stdout, "AllTemporary"); + return fprintf(stdout, "AllTemporary"); else - fprintf(stdout, "RID %08x", n); - return(4); + return fprintf(stdout, "RID %08x", n); } @@ -555,10 +566,9 @@ PrintKEYCODEA(buf) /* print a KEYCODEA -- CARD8 plus 0 = AnyKey */ long n = IByte (buf); if (n == 0) - fprintf(stdout, "AnyKey"); + return fprintf(stdout, "AnyKey"); else - (void)PrintKEYCODE(buf); - return(1); + return PrintKEYCODE(buf); } @@ -567,8 +577,7 @@ PrintBUTTON(buf) { /* print a BUTTON -- CARD8 */ unsigned short n = IByte (buf); - fprintf(stdout, "%d (%s)", n, printrep(n)); - return(1); + return fprintf(stdout, "%d (%s)", n, printrep(n)); } PrintBUTTONA(buf) @@ -577,10 +586,9 @@ PrintBUTTONA(buf) /* print a BUTTONA -- CARD8 plus 0 = AnyButton */ long n = IByte (buf); if (n == 0) - fprintf(stdout, "AnyButton"); + return fprintf(stdout, "AnyButton"); else - PrintBUTTON(buf); - return(1); + return PrintBUTTON(buf); } @@ -595,10 +603,10 @@ PrintEVENTFORM(buf) /* ************************************************************ */ -PrintENUMERATED(buf, length, ValueList) - unsigned char *buf; - short length; - struct ValueListEntry *ValueList; +PrintENUMERATED( + unsigned char *buf, + short length, + struct ValueListEntry *ValueList) { long n; struct ValueListEntry *p; @@ -615,18 +623,17 @@ PrintENUMERATED(buf, length, ValueList) p = p->Next; if (p != NULL) - fprintf(stdout, "%s", p->Name); + return fprintf(stdout, "%s", p->Name); else - fprintf(stdout, "**INVALID** (%d)", n); - return(length); + return fprintf(stdout, "**INVALID** (%d)", n); } /* ************************************************************ */ -PrintSET(buf, length, ValueList) - unsigned char *buf; - short length; - struct ValueListEntry *ValueList; +PrintSET( + unsigned char *buf, + short length, + struct ValueListEntry *ValueList) { unsigned long n; struct ValueListEntry *p; @@ -665,10 +672,9 @@ PrintSET(buf, length, ValueList) } if (MatchesAll) - fprintf(stdout, ""); + return fprintf(stdout, ""); else if (!FoundOne) - fprintf(stdout, "0"); - return(length); + return fprintf(stdout, "0"); } @@ -677,6 +683,7 @@ PrintSET(buf, length, ValueList) /* */ /* ************************************************************ */ +void PrintField(buf, start, length, FieldType, name) unsigned char *buf; short start; @@ -716,7 +723,7 @@ PrintField(buf, start, length, FieldType, name) break; } fprintf(stdout, "\n"); - (void)fflush(stdout); + fflush(stdout); } /* ************************************************************ */ @@ -778,7 +785,7 @@ long PrintList(buf, number, ListType, name) /* print a list of STRs. Similar to PrintList They start at . There are things in the list */ -PrintListSTR(buf, number, name) +long PrintListSTR(buf, number, name) unsigned char *buf; long number; char *name; @@ -788,11 +795,11 @@ PrintListSTR(buf, number, name) long sum; if (number == 0) - return; + return(0); fprintf(stdout, "%s%20s: (%d)\n", Leader, name, number); if (Verbose < 2) - return; + return(0); ModifyIndentLevel(1); sum = 0; @@ -806,7 +813,7 @@ PrintListSTR(buf, number, name) } ModifyIndentLevel(-1); - return; + return(sum); } @@ -826,7 +833,7 @@ PrintBytes(buf, number, name) short column; if (number == 0) - return; + return(0); fprintf(stdout, "%s%20s: ", Leader, name); column = SizeofLeader() + 25; @@ -844,7 +851,7 @@ PrintBytes(buf, number, name) } fprintf(stdout, "\n"); - return; + return(number); } @@ -858,42 +865,45 @@ PrintBytes(buf, number, name) PrintString8(buf, number, name) unsigned char buf[]; - long number; + short number; char *name; { - long i; + short i; if (number == 0) - return; + return(0); fprintf(stdout, "%s%20s: \"", Leader, name); for (i = 0; i < number; i++) fprintf(stdout, "%s", printrep(buf[i])); fprintf(stdout, "\"\n"); + + return(number); } -/* print a String of CHAR2B -- 16-bit characters */ +/* print a String of CHAR16 -- 16-bit characters */ PrintString16(buf, number, name) unsigned char buf[]; - long number; + short number; char *name; { - long i; - long j; + short i; unsigned short c; if (number == 0) - return; + return(0); fprintf(stdout, "%s%20s: \"", Leader, name); - for (i = 0, j = 0; i < number; i += 1, j += 2) + for (i = 0; i < number; i += 2) { - c = IChar2B(&buf[j]); + c = IShort(&buf[i]); fprintf(stdout, "%s", printrep(c)); } fprintf(stdout, "\"\n"); + + return(number); } /* ************************************************************ */ @@ -909,6 +919,7 @@ PrintString16(buf, number, name) (2) A list of values. */ +void PrintValues(control, clength, ctype, values, name) unsigned char *control; short clength; @@ -970,7 +981,7 @@ PrintTextList8(buf, length, name) if (n != 255) { PrintField(buf, 1, 1, INT8, "delta"); - PrintString8(&buf[2], (long)n, "text item 8 string"); + PrintString8(&buf[2], n, "text item 8 string"); buf += n + 2; length -= n + 2; } @@ -997,7 +1008,7 @@ PrintTextList16(buf, length, name) if (n != 255) { PrintField(buf, 1, 1, INT8, "delta"); - PrintString16(&buf[2], (long)n, "text item 16 string"); + PrintString16(&buf[2], n, "text item 16 string"); buf += n + 2; length -= n + 2; } @@ -1018,6 +1029,7 @@ PrintTextList16(buf, length, name) #define MAXline 78 +static void DumpHexBuffer(buf, n) unsigned char *buf; long n; @@ -1030,7 +1042,7 @@ DumpHexBuffer(buf, n) for (i = 0; i < n; i++) { /* get the hex representations */ - (void)sprintf(h, "%02x",(0xff & buf[i])); + sprintf(h, "%02x",(0xff & buf[i])); /* check if these characters will fit on this line */ if ((column + strlen(h) + 1) > MAXline) diff --git a/scope-transport.c b/scope-transport.c new file mode 100644 index 0000000..43fad0c --- /dev/null +++ b/scope-transport.c @@ -0,0 +1,8 @@ +/* Xscope xtrans layer */ + +extern short debuglevel; +#define DEBUG ((debuglevel & 4) ? 4 : 1) +#define TRANS_CLIENT +#define TRANS_SERVER +#define X11_t +#include diff --git a/scope.c b/scope.c index 9511f5a..32c80c6 100644 --- a/scope.c +++ b/scope.c @@ -23,18 +23,46 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * ***************************************************** */ #include "scope.h" -#include /* needed by sys/socket.h and netinet/in.h */ -#include /* for struct iovec, used by socket.h */ -#include /* for AF_INET, SOCK_STREAM, ... */ -#include /* for FIONCLEX, FIONBIO, ... */ -#include /* struct sockaddr_in */ -#include /* struct servent * and struct hostent * */ -#include /* for EINTR, EADDRINUSE, ... */ -extern int errno; +#include +#include +#include + +#ifdef SYSV +#define bzero(s,l) memset(s, 0, l) +#define bcopy(s,d,l) memmove(d,s,l) +#endif /* ********************************************** */ /* */ @@ -42,11 +70,37 @@ extern int errno; #define DefaultPort 6000 -char ServerHostName[255]; -long ServerBasePort = DefaultPort; -long ServerInPort = 1; -long ServerOutPort = 0; -long ServerDisplay = 0; +static char ServerHostName[MAXHOSTNAMELEN]; + long ServerBasePort = DefaultPort; +static long ServerInPort = 1; +static long ServerOutPort = 0; +static long ServerDisplay = 0; + +#ifdef USE_XTRANS +#undef DNETCONN +#undef DNETSVR4 +#endif + +#ifdef DNETCONN +#include +#include +int decnet_in = 0; +int decnet_out = 0; +int decnet_server = 0; +#endif +#ifdef DNETSVR4 +#include +extern struct hostent *(*dnet_gethostbyname)(); +extern int (*dnet_gethostname)(); +short initialize_libdni(); +int decnet_in = 0; +int decnet_out = 0; +int decnet_server = 0; +#endif + +static FD ConnectToClient(FD ConnectionSocket); +static FD ConnectToServer(int report); +static void SetUpStdin(void); /* ********************************************** */ @@ -54,23 +108,35 @@ long ServerDisplay = 0; /* */ /* ********************************************** */ -short GetServerport () +static short GetServerport () { short port; enterprocedure("GetServerport"); +#if defined(DNETCONN) || defined(DNETSVR4) + if (decnet_server) { + port = ServerDisplay + ServerOutPort; + return(port); + } +#endif port = ServerBasePort + ServerOutPort + ServerDisplay; debug(4,(stderr, "Server service is on port %d\n", port)); return(port); } -short GetScopePort () +static short GetScopePort () { short port; enterprocedure("GetScopePort"); +#if defined(DNETCONN) || defined(DNETSVR4) + if (decnet_in) { + port = ServerInPort + ServerDisplay; + return(port); + } +#endif port = ServerBasePort + ServerInPort + ServerDisplay; debug(4,(stderr, "scope service is on port %d\n", port)); return(port); @@ -80,6 +146,7 @@ short GetScopePort () /* */ /* ********************************************** */ +static void Usage() { fprintf(stderr, "Usage: xscope\n"); @@ -88,21 +155,26 @@ Usage() fprintf(stderr, " [-o]\n"); fprintf(stderr, " [-d]\n"); fprintf(stderr, " [-v] -- verbose output\n"); +#ifdef RAW_MODE + fprintf(stderr, " [-r] -- raw output\n"); +#endif fprintf(stderr, " [-q] -- quiet output\n"); fprintf(stderr, " [-D]\n"); exit(1); } - -char *OfficialName(); /* forward type declaration */ - +static void ScanArgs(argc, argv) int argc; char **argv; { - NoExtensions = false /* default is to allow extensions */; +#if defined(DNETCONN) || defined(DNETSVR4) + char *ss; +#endif Verbose = 1 /* default verbose-ness level */; - RequestSync = false /* default is to just copy blocks */; +#ifdef RAW_MODE + Raw = 0 ; +#endif /* Scan argument list */ while (--argc > 0) @@ -139,12 +211,14 @@ ScanArgs(argc, argv) debug(1,(stderr, "Verbose = %d\n", Verbose)); break; - case 's': /* synchronous mode */ - RequestSync = true; - debug(1,(stderr, "RequestSync true\n")); - break; +#ifdef RAW_MODE + case 'r': /* raw mode */ + Raw = 1 ; + debug(1,(stderr, "Raw = %d\n", Raw)); + break; +#endif - case 'o': /* output port */ + case 'o': ServerOutPort = atoi(++*argv); if (ServerOutPort <= 0) ServerOutPort = 0; @@ -159,6 +233,12 @@ ScanArgs(argc, argv) break; case 'i': +#if defined(DNETCONN) || defined(DNETSVR4) + if (ss = (char *)strchr(*argv,':')) { + decnet_in = 1; + *ss = NULL; + } +#endif ServerInPort = atoi(++*argv); if (ServerInPort <= 0) ServerInPort = 0; @@ -166,16 +246,20 @@ ScanArgs(argc, argv) break; case 'h': - if (++*argv != NULL && **argv != '\0') - (void)strcpy(ServerHostName, OfficialName(*argv)); +#if defined(DNETCONN) || defined(DNETSVR4) + if (ss = (char *)strchr(*argv,':')) { + decnet_server = 1; + *ss = NULL; + strcpy(ServerHostName,++*argv); + break; + } +#endif + if (++*argv != NULL && **argv != '\0' + && (strlen(*argv) < sizeof(ServerHostName))) + strcpy(ServerHostName, *argv); debug(1,(stderr, "ServerHostName=%s\n", ServerHostName)); break; - case 'x': - NoExtensions = true; - debug(1,(stderr, "NoExtensions\n")); - break; - default: fprintf(stderr, "Unknown option %c\n", **argv); Usage(); @@ -213,13 +297,20 @@ main(argc, argv) InitializeFD(); InitializeX11(); SetUpStdin(); +#if defined(DNETCONN) || defined(DNETSVR4) + if (decnet_in) + SetUpDECnetConnection(GetScopePort()); + else + SetUpConnectionSocket(GetScopePort()); +#else SetUpConnectionSocket(GetScopePort()); SetSignalHandling(); +#endif - MainLoop(); - exit(0); + return MainLoop(); } +void TimerExpired() { debug(16,(stderr, "Timer tick\n")); @@ -241,6 +332,7 @@ TimerExpired() (e) allow fake events, errors to be generated. */ +static void ReadStdin(fd) FD fd; { @@ -252,10 +344,11 @@ ReadStdin(fd) debug(4,(stderr, "read %d bytes from stdin\n", n)); } +static void SetUpStdin() { enterprocedure("SetUpStdin"); - /* UsingFD(fileno(stdin), ReadStdin); */ + UsingFD(fileno(stdin), ReadStdin, NULL); } /* ************************************************************ */ @@ -280,8 +373,9 @@ struct fdinfo }; static long ClientNumber = 0; -struct fdinfo FDinfo[StaticMaxFD]; +static struct fdinfo FDinfo[StaticMaxFD]; +static void SetUpPair(client, server) FD client; FD server; @@ -301,12 +395,12 @@ SetUpPair(client, server) } else if (server >= 0) { - (void)close(server); + close(server); NotUsingFD(server); } } - +static void CloseConnection(fd) FD fd; { @@ -314,9 +408,14 @@ CloseConnection(fd) StopClientConnection(ServerHalf(fd)); StopServerConnection(ClientHalf(fd)); - (void)close(fd); +#ifdef USE_XTRANS + _X11TransClose(GetXTransConnInfo(fd)); + _X11TransClose(GetXTransConnInfo(FDPair(fd))); +#else + close(fd); + close(FDPair(fd)); +#endif NotUsingFD(fd); - (void)close(FDPair(fd)); NotUsingFD(FDPair(fd)); } @@ -347,11 +446,11 @@ FD ServerHalf(fd) char *ClientName (fd) FD fd; { - static char name[20]; + static char name[12]; - (void)sprintf(name, " %s %d", - (FDinfo[fd].Server ? "Server" : "Client"), - FDinfo[fd].ClientNumber); + if (ClientNumber <= 1) + return(""); + sprintf(name, " %d", FDinfo[fd].ClientNumber); return(name); } @@ -364,6 +463,7 @@ char *ClientName (fd) server for this client, then dump it to the client. Note, we don't have to have a server, if there isn't one. */ +static void DataFromClient(fd) FD fd; { @@ -373,7 +473,7 @@ DataFromClient(fd) enterprocedure("DataFromClient"); n = read(fd, (char *)buf, 2048); - debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd))); + debug(4,(stderr, "read %d bytes from Client%s\n", n, ClientName(fd))); if (n < 0) { PrintTime(); @@ -384,17 +484,10 @@ DataFromClient(fd) if (n == 0) { PrintTime(); - fprintf(stdout, "%s --> EOF\n", ClientName(fd)); + fprintf(stdout, "Client%s --> EOF\n", ClientName(fd)); CloseConnection(fd); return; } - if (debuglevel > 4) - { - fflush(stdout); fflush(stderr); - DumpHexBuffer(buf, n); - fprintf(stdout,"\n"); - fflush(stdout); fflush(stderr); - } ServerFD = FDPair(fd); if (ServerFD < 0) @@ -404,7 +497,42 @@ DataFromClient(fd) } /* write bytes from client to server, allow for server to fail */ - if (!RequestSync) WriteBytes(ServerFD, buf, n); + 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; + } + } + } /* also report the bytes to standard out */ ReportFromClient(fd, buf, n); @@ -417,6 +545,7 @@ DataFromClient(fd) /* similar situation for the server, but note that if there is no client, we close the connection down -- don't need a server with no client. */ +static void DataFromServer(fd) FD fd; { @@ -426,7 +555,7 @@ DataFromServer(fd) enterprocedure("DataFromServer"); n = read(fd, (char *)buf, 2048); - debug(4,(stderr, "read %d bytes from %s\n", n, ClientName(fd))); + debug(4,(stderr, "read %d bytes from Server%s\n", n, ClientName(fd))); if (n < 0) { PrintTime(); @@ -437,17 +566,10 @@ DataFromServer(fd) if (n == 0) { PrintTime(); - fprintf(stdout, "EOF <-- %s\n", ClientName(fd)); + fprintf(stdout, "EOF <-- Server%s\n", ClientName(fd)); CloseConnection(fd); return; } - if (debuglevel > 4) - { - fflush(stdout); fflush(stderr); - DumpHexBuffer(buf, n); - fprintf(stdout,"\n"); - fflush(stdout); fflush(stderr); - } ClientFD = FDPair(fd); if (ClientFD < 0) @@ -456,20 +578,41 @@ DataFromServer(fd) return; } - if (NoExtensions) - { - if (buf[0] == 1) /* reply code */ - { - short SequenceNumber = IShort (&buf[2]); - short Request = CheckReplyTable (fd, SequenceNumber); - if (Request == 98) /* Query Extension */ - if (buf[8] == 1) - buf[8] = 0; - } - } - /* write bytes from server to client, allow for client to fail */ - WriteBytes(ClientFD, buf, n); + { + 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; + } + } + } /* also report the bytes to standard out */ ReportFromServer(fd, buf, n); @@ -477,75 +620,89 @@ DataFromServer(fd) -/* ************************************************************ */ -/* */ -/* */ -/* ************************************************************ */ - -WriteBytes(fd, buf, n) -FD fd; -unsigned char *buf; -long n; -{ - long BytesToWrite = n; - unsigned char *p = buf; - - if (fd < 0) return; - if (!ValidFD(fd)) return; - - while (BytesToWrite > 0) - { - int n1 = write (fd, (char *)p, (int)BytesToWrite); - debug(4,(stderr, "write %d bytes to %s\n", n1, ClientName(fd))); - if (n1 > 0) - { - BytesToWrite -= n1; - p += n1; - } - else - { - char message[255]; - sprintf(message,"Error on write to %s", ClientName(fd)); - perror(message); - CloseConnection(fd); - BytesToWrite = 0; - } - } -} - - /* ************************************************************ */ /* */ /* Create New Connection to a client program and to Server */ /* */ /* ************************************************************ */ +#include /* needed by sys/socket.h and netinet/in.h */ +#include /* for struct iovec, used by socket.h */ +#include /* for AF_INET, SOCK_STREAM, ... */ +#include /* for FIONCLEX, FIONBIO, ... */ +#include /* struct sockaddr_in */ +#include /* struct servent * and struct hostent * */ +#include /* for EINTR, EADDRINUSE, ... */ +extern int errno; + static int ON = 1 /* used in ioctl */ ; +void NewConnection(fd) FD fd; { FD ServerFD = -1; FD ClientFD = -1; +#ifdef DNETCONN + if (decnet_in) + ClientFD = ConnectToDECnetClient(fd); + else + ClientFD = ConnectToClient(fd); + if (decnet_server) + ServerFD = ConnectToDECnetServer(true); + else + ServerFD = ConnectToServer(true); +#endif +#ifdef DNETSVR4 + ClientFD = ConnectToClient(fd); + if (decnet_server) { + if (!initialize_libdni()) { + fprintf(stderr,"Unable to open libdni.so\n"); + exit(0); + } + ServerFD = ConnectToDECnetSVR4Server(true); + } + else + ServerFD = ConnectToServer(true); +#endif +#if !(defined(DNETCONN)) && !(defined(DNETSVR4)) ClientFD = ConnectToClient(fd); ServerFD = ConnectToServer(true); + +#endif SetUpPair(ClientFD, ServerFD); } /* ************************************************************ */ -FD ConnectToClient(ConnectionSocket) +static FD ConnectToClient(ConnectionSocket) FD ConnectionSocket; { FD ClientFD; + XtransConnInfo trans_conn = NULL; +#ifdef USE_XTRANS + XtransConnInfo listen_conn; + int status; +#else struct sockaddr_in from; - size_t len = sizeof (from); + int len = sizeof (from); +#endif enterprocedure("ConnectToClient"); +#ifdef USE_XTRANS + listen_conn = GetXTransConnInfo(ConnectionSocket); + if ((trans_conn = _X11TransAccept (listen_conn, &status)) == NULL) { + debug(4,(stderr, "Failed to accept connection\n")); + return -1; + } + _X11TransSetOption(trans_conn, TRANS_NONBLOCKING, 1); + ClientFD = _X11TransGetConnectionNumber(trans_conn); +#else ClientFD = accept(ConnectionSocket, (struct sockaddr *)&from, &len); +#endif debug(4,(stderr, "Connect To Client: FD %d\n", ClientFD)); if (ClientFD < 0 && errno == EWOULDBLOCK) { @@ -558,17 +715,15 @@ FD ConnectToClient(ConnectionSocket) panic("Can't connect to Client"); } - UsingFD(ClientFD, DataFromClient); -#ifdef FIOCLEX - (void)ioctl(ClientFD, FIOCLEX, 0); -#endif /* #ifdef FIOCLEX */ - (void)ioctl(ClientFD, FIONBIO, &ON); + UsingFD(ClientFD, DataFromClient, trans_conn); +#ifndef USE_XTRANS + ioctl(ClientFD, FIOCLEX, 0); + ioctl(ClientFD, FIONBIO, &ON); +#endif StartClientConnection(ClientFD); return(ClientFD); } - - /* ************************************************************ */ /* */ /* */ @@ -576,18 +731,54 @@ FD ConnectToClient(ConnectionSocket) -FD ConnectToServer(report) +static 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; -#ifndef SO_DONTLINGER - struct linger linger; -#endif /* #ifndef SO_DONTLINGER */ +#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) + { + char error_message[100]; + sprintf(error_message, "Trying to attach to myself: %s,%d\n", + ServerHostName, port); + 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); @@ -598,21 +789,10 @@ FD ConnectToServer(report) panic("Can't open connection to Server"); } (void) setsockopt(ServerFD, SOL_SOCKET, SO_REUSEADDR, (char *) NULL, 0); -#ifdef SO_USELOOPBACK (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0); -#endif /* #ifdef SO_USELOOPBACK */ #ifdef SO_DONTLINGER (void) setsockopt(ServerFD, SOL_SOCKET, SO_DONTLINGER, (char *) NULL, 0); -#else /* #ifdef SO_DONTLINGER */ - linger.l_onoff = 0; - linger.l_linger = 0; - (void) setsockopt(ServerFD, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof linger); -#endif /* #ifdef SO_DONTLINGER */ - - /* determine the host machine for this process */ - if (ServerHostName[0] == '\0') - (void) gethostname(ServerHostName, sizeof (ServerHostName)); - debug(4,(stderr, "try to connect on %s\n", ServerHostName)); +#endif hp = gethostbyname(ServerHostName); if (hp == 0) @@ -624,21 +804,89 @@ FD ConnectToServer(report) sin.sin_family = AF_INET; bcopy((char *)hp->h_addr, (char *)&sin.sin_addr, hp->h_length); - sin.sin_port = htons(GetServerport()); + sin.sin_port = htons (port); - if ((sin.sin_port == ScopePort) - && strcmp(ServerHostName, ScopeHost) == 0) + /* ******************************************************** */ + /* try to connect to Server */ + + if (connect(ServerFD, (struct sockaddr *)&sin, sizeof(sin)) < 0) { - char error_message[100]; - (void)sprintf(error_message, "Trying to attach to myself: %s,%d\n", - ServerHostName, sin.sin_port); - panic(error_message); + 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 + + debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); + if (ServerFD >= 0) + { + UsingFD(ServerFD, DataFromServer, trans_conn); + StartServerConnection(ServerFD); + } + return(ServerFD); +} + +#ifdef DNETSVR4 +FD ConnectToDECnetSVR4Server(report) + Boolean report; +{ + FD ServerFD; + struct sockaddr_dn sdn; + struct hostent *hp; + + enterprocedure("ConnectToServer"); + + /* establish a socket to the name server for this host */ + ServerFD = socket(AF_DECnet, SOCK_STREAM, 0); + if (ServerFD < 0) + { + perror("socket() to Server failed"); + debug(1,(stderr, "socket failed\n")); + panic("Can't open connection to Server"); + } + (void) setsockopt(ServerFD, SOL_SOCKET, SO_REUSEADDR, (char *) NULL, 0); + (void) setsockopt(ServerFD, SOL_SOCKET, SO_USELOOPBACK,(char *) NULL, 0); + /* determine the host machine for this process */ + initialize_libdni(); + if (ServerHostName[0] == '\0') + (dnet_gethostname)(ServerHostName); + debug(4,(stderr, "try to connect on %s\n", ServerHostName)); + + hp = (struct hostent *)(dnet_gethostbyname)(ServerHostName); + if (hp == 0) + { + perror("gethostbyname failed"); + debug(1,(stderr, "gethostbyname failed for %s\n", ServerHostName)); + panic("Can't open connection to Server"); } + sdn.sdn_family = AF_DECnet; + sdn.sdn_format = DNADDR_FMT1; + sdn.sdn_port = 0; + sprintf (sdn.sdn_name, "X$X%d", GetServerport() ); + sdn.sdn_namelen = strlen(sdn.sdn_name); + sdn.sdn_addr = *(u_short *)hp->h_addr_list[0]; + /* ******************************************************** */ /* try to connect to Server */ - if (connect(ServerFD, (struct sockaddr *)&sin, sizeof(sin)) < 0) + if (connect(ServerFD, (struct sockaddr *)&sdn, sizeof(sdn)) < 0) { debug(4,(stderr, "connect returns errno of %d\n", errno)); if (errno != 0) @@ -649,14 +897,14 @@ FD ConnectToServer(report) case ECONNREFUSED: /* experience says this is because there is no Server to connect to */ - (void)close(ServerFD); + close(ServerFD); debug(1,(stderr, "No Server\n")); if (report) warn("Can't open connection to Server"); return(-1); default: - (void)close(ServerFD); + close(ServerFD); panic("Can't open connection to Server"); } } @@ -664,29 +912,84 @@ FD ConnectToServer(report) debug(4,(stderr, "Connect To Server: FD %d\n", ServerFD)); if (ServerFD >= 0) { - UsingFD(ServerFD, DataFromServer); + UsingFD(ServerFD, DataFromServer, NULL); StartServerConnection(ServerFD); } return(ServerFD); } - +#endif /* ********************************************** */ /* */ /* ********************************************** */ -char *OfficialName(name) -char *name; +#ifdef DNETCONN +FD ConnectToDECnetClient(fd) + FD fd; { - struct hostent *HostEntry; + struct ses_io_type sesopts; + static SessionData sd= {0, {0, ""}}; + + if (ioctl(fd, SES_ACCEPT, &sd) < 0) { + fprintf(stderr,"xscope: dni: SES_ACCEPT failed\n"); + exit(-1); + } + UsingFD(fd, DataFromClient, NULL); + StartClientConnection(fd); + /* unlike sockets, dni consumes the fd on which it was listening */ + /* in order to accept new logical link requests using the same name */ + /* we must re-open the logical link device and re-supply the */ + /* appropriate access control information */ + + SetUpDECnetConnection(GetScopePort()); + + return(fd); +} - HostEntry = gethostbyname(name); - if (HostEntry == NULL) - { - perror("gethostbyname"); - exit(-1); - } - debug(4,(stderr, "Official name of %s is %s\n", name, HostEntry->h_name)); - return(HostEntry->h_name); + +FD ConnectToDECnetServer(report) + Boolean report; +{ + FD fd; + OpenBlock opblk; + struct ses_io_type sesopts; + struct nodeent *np; + + if ((fd = open("/dev/dni", O_RDWR)) < 0) { + fprintf(stderr,"xscope: dni: open failed\n"); + exit(-1); + } + if (ioctl(fd, SES_GET_LINK, 0)) { + fprintf(stderr,"xscope: dni: can't get link\n"); + exit(-1); + } + + /* set nonblocking here since dni can't handle fcntls */ + sesopts.io_flags = SES_IO_NBIO; + sesopts.io_io_signal = sesopts.io_int_signal = 0; + + if (ioctl(fd, SES_IO_TYPE, &sesopts) < 0) { + fprintf(stderr,"xscope: dni: ioctl failed\n"); + exit(-1); + } + + strncpy(opblk.op_node_name,ServerHostName , 6); /* dni server name */ + opblk.op_node_name[6] = '\0'; + sprintf(opblk.op_task_name, "X$X%d", GetServerport()); + opblk.op_userid[0] = '\0'; /* No one checks our id */ + opblk.op_object_nbr = 0; /* Any fields not used */ + opblk.op_account[0] = '\0'; /* should be set to zero */ + opblk.op_password[0] = '\0'; + opblk.op_opt_data.im_length = 0; + + if (ioctl(fd, SES_LINK_ACCESS, &opblk) == -1) { + fprintf(stderr,"xscope: dni: cannot connect to server\n"); + exit(-1); + } + UsingFD(fd, DataFromServer, NULL); + StartServerConnection(fd); + return(fd); + } +#endif diff --git a/scope.h b/scope.h index 62b3189..cec14b2 100644 --- a/scope.h +++ b/scope.h @@ -1,6 +1,6 @@ /* ********************************************** * * - * header file for the Server spy scope * + * header file for the Server spy scope * * * * James Peterson, 1987 * * Copyright (C) 1987 MCC @@ -23,9 +23,40 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * ********************************************** */ #include +#ifdef SVR4 +#include +#endif /* SVR4 */ #define Boolean short #define true 1 @@ -43,25 +74,31 @@ short debuglevel; /* */ /* ********************************************** */ -Boolean NoExtensions /* Should we deny extensions exist ? */ ; short Verbose /* quiet (0) or increasingly verbose ( > 0) */ ; -Boolean RequestSync; +#ifdef RAW_MODE +short Raw /* raw data output only */ ; +#else +#define Raw 0 +#endif int ScopePort; char *ScopeHost; /* external function type declarations */ -extern char *Malloc (); +extern void *Malloc (long n); +#ifdef X_NOT_STDC_ENV extern char *strcpy(); -char *ClientName (); +extern char *sprintf(); +#else +#include +#include +#endif +extern char *ClientName(); /* ********************************************** */ /* */ /* ********************************************** */ -/* need to change the MaxFD to allow larger number of fd's */ -#define StaticMaxFD 32 - - #include "fd.h" +#include "proto.h" diff --git a/server.c b/server.c index ba8b7cb..076648d 100644 --- a/server.c +++ b/server.c @@ -23,34 +23,71 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************** */ #include "scope.h" #include "x11.h" +#ifdef SYSV +#define bzero(s,l) memset(s, 0, l) +#define bcopy(s,d,l) memmove(d,s,l) +#endif + +static void ProcessBuffer(FD fd, unsigned char *buf, long n); + /* ************************************************************ */ /* */ /* */ /* ************************************************************ */ +void ReportFromClient(fd, buf, n) FD fd; unsigned char *buf; long n; { PrintTime(); - fprintf(stdout, "%s --> %4d %s\n", + fprintf(stdout, "Client%s --> %4d %s\n", ClientName(fd), n, (n == 1 ? "byte" : "bytes")); ProcessBuffer(fd, buf, n); } +void ReportFromServer(fd, buf, n) FD fd; unsigned char *buf; long n; { PrintTime(); - fprintf(stdout, "\t\t\t\t\t%4d %s <-- X11 %s\n", + fprintf(stdout, "\t\t\t\t\t%4d %s <-- X11 Server%s\n", n, (n == 1 ? "byte" : "bytes"), ClientName(fd)); ProcessBuffer(fd, buf, n); } @@ -68,13 +105,14 @@ static struct timeval tp; /* print the time since we started in hundredths (1/100) of seconds */ +void PrintTime() { static long lastsec = 0; long sec /* seconds */ ; long hsec /* hundredths of a second */ ; - (void)gettimeofday(&tp, (struct timezone *)NULL); + gettimeofday(&tp, (struct timezone *)NULL); if (ZeroTime1 == -1 || (tp.tv_sec - lastsec) >= 1000) { ZeroTime1 = tp.tv_sec; @@ -108,51 +146,21 @@ long pad (n) return((n + 3) & ~0x3); } - -static Boolean byteswap = false; -void SetByteSwapping(int how) -{ - byteswap = (how == 0x6c); -} +static int littleEndian; unsigned long ILong (buf) unsigned char buf[]; { - unsigned short a,b,c,d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - /* check for byte-swapping */ - - if (byteswap) - return((((((d << 8) | c) << 8) | b) << 8) | a); - else - return((((((a << 8) | b) << 8) | c) << 8) | d); + if (littleEndian) + return((((((buf[3] << 8) | buf[2]) << 8) | buf[1]) << 8) | buf[0]); + return((((((buf[0] << 8) | buf[1]) << 8) | buf[2]) << 8) | buf[3]); } unsigned short IShort (buf) unsigned char buf[]; { - unsigned short a,b,c,d; - - a = buf[0]; - b = buf[1]; - - /* check for byte-swapping */ - - if (byteswap) - return((b << 8) | a); - else - return((a << 8) | b); -} - -unsigned short IChar2B (buf) -unsigned char buf[]; -{ - /* CHAR2B is like an IShort, but not byte-swapped */ + if (littleEndian) + return (buf[1] << 8) | buf[0]; return((buf[0] << 8) | buf[1]); } @@ -180,6 +188,7 @@ Boolean IBool(buf) /* we will need to save bytes until we get a complete request to interpret. The following procedures provide this ability */ +static void SaveBytes(fd, buf, n) FD fd; unsigned char *buf; @@ -191,13 +200,10 @@ SaveBytes(fd, buf, n) /* not enough room so far; malloc more space and copy */ long SizeofNewBytes = (CS[fd].NumberofSavedBytes + n + 1); unsigned char *NewBytes = (unsigned char *)Malloc (SizeofNewBytes); - if (CS[fd].NumberofSavedBytes > 0) - { - bcopy(/* from */(char *)CS[fd].SavedBytes, - /* to */(char *)NewBytes, - /* count */(int)CS[fd].NumberofSavedBytes); - Free((char *)CS[fd].SavedBytes); - } + bcopy(/* from */(char *)CS[fd].SavedBytes, + /* to */(char *)NewBytes, + /* count */(int)CS[fd].SizeofSavedBytes); + Free((char *)CS[fd].SavedBytes); CS[fd].SavedBytes = NewBytes; CS[fd].SizeofSavedBytes = SizeofNewBytes; } @@ -209,6 +215,7 @@ SaveBytes(fd, buf, n) CS[fd].NumberofSavedBytes += n; } +static void RemoveSavedBytes(fd, n) FD fd; long n; @@ -239,15 +246,15 @@ RemoveSavedBytes(fd, n) /* following are the possible values for ByteProcessing */ /* forward declarations */ -long StartSetUpMessage (); -long FinishSetUpMessage (); -long StartRequest (); -long FinishRequest (); +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); -long StartSetUpReply (); -long FinishSetUpReply (); -long ServerPacket (); -long FinishReply (); +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); /* ************************************************************ */ @@ -255,6 +262,7 @@ long FinishReply (); /* */ /* ************************************************************ */ +static void ProcessBuffer(fd, buf, n) FD fd; unsigned char *buf; @@ -265,6 +273,7 @@ ProcessBuffer(fd, buf, n) /* as long as we have enough bytes to do anything -- do it */ + littleEndian = CS[fd].littleEndian; while (CS[fd].NumberofSavedBytes + n >= CS[fd].NumberofBytesNeeded) { /* @@ -353,7 +362,7 @@ ProcessBuffer(fd, buf, n) and ByteProcessing. It probably needs to do some computation first. */ - +void StartClientConnection(fd) FD fd; { @@ -374,6 +383,7 @@ StartClientConnection(fd) CS[fd].NumberofBytesNeeded = 12; } +void StopClientConnection(fd) FD fd; { @@ -384,13 +394,13 @@ StopClientConnection(fd) Free((char*)CS[fd].SavedBytes); } -long StartSetUpMessage (fd, buf, n) +static long StartSetUpMessage (fd, buf, n) FD fd; unsigned char *buf; long n; { - short namelength; - short datalength; + unsigned short namelength; + unsigned short datalength; enterprocedure("StartSetUpMessage"); /* @@ -410,14 +420,18 @@ long StartSetUpMessage (fd, buf, n) return(0); } -long FinishSetUpMessage (fd, buf, n) +static long FinishSetUpMessage (fd, buf, n) FD fd; unsigned char *buf; long n; { enterprocedure("FinishSetUpMessage"); + if( Raw || (Verbose > 3) ) + DumpItem("Client Connect", fd, buf, n) ; + CS[fd].littleEndian = (buf[0] == 'l'); + CS[ServerHalf(fd)].littleEndian = CS[fd].littleEndian; + littleEndian = CS[fd].littleEndian; PrintSetUpMessage(buf); - if (RequestSync) SendToServer(fd,buf,n); /* after a set-up message, we expect a string of requests */ CS[fd].ByteProcessing = StartRequest; @@ -426,16 +440,17 @@ long FinishSetUpMessage (fd, buf, n) } -long StartRequest (fd, buf, n) +static long StartRequest (fd, buf, n) FD fd; unsigned char *buf; long n; { - short requestlength; + unsigned short requestlength; enterprocedure("StartRequest"); /* bytes 0,1 are ignored now; bytes 2,3 tell us the request length */ requestlength = IShort(&buf[2]); + CS[fd].ByteProcessing = FinishRequest; CS[fd].NumberofBytesNeeded = 4 * requestlength; debug(8,(stderr, "need %d more bytes to finish request\n", @@ -444,15 +459,13 @@ long StartRequest (fd, buf, n) } -long FinishRequest (fd, buf, n) +static long FinishRequest (fd, buf, n) FD fd; unsigned char *buf; long n; { enterprocedure("FinishRequest"); DecodeRequest(fd, buf, n); - if (RequestSync) SendToServer(fd,buf,n); - CS[fd].ByteProcessing = StartRequest; CS[fd].NumberofBytesNeeded = 4; return(n); @@ -463,39 +476,7 @@ long FinishRequest (fd, buf, n) /* */ /* ************************************************************ */ -SendToServer (fd, buf, n) - FD fd; - unsigned char *buf; - long n; -{ - FD Server; - - enterprocedure("SendToServer"); - /* - We are in RequestSync mode. These means that each request is - separately sent to the server and we wait until it is done before - proceeding to the next request. This is useful when a client - request causes the server to crash. In this case, if we batch - up 100 requests and send them to the server all at once, we will - have no idea which was the last one processed, and hence which - was the one that caused the server to crash. - - We first write the buffer to the server, then flush it. Then we - check if the server has input available, and if so process it - before returning to finish the rest of the client buffer. - */ - - Server = ServerHalf(fd); - WriteBytes(Server, buf, n); - - if (InputAvailable(Server)) - HandleInput(Server); -} -/* ************************************************************ */ -/* */ -/* */ -/* ************************************************************ */ - +void StartServerConnection(fd) FD fd; { @@ -513,6 +494,7 @@ StartServerConnection(fd) CS[fd].NumberofBytesNeeded = 8; } +void StopServerConnection(fd) FD fd; { @@ -523,12 +505,13 @@ StopServerConnection(fd) Free((char *)CS[fd].SavedBytes); } -long StartSetUpReply (fd, buf, n) +static long +StartSetUpReply (fd, buf, n) FD fd; unsigned char *buf; long n; { - short replylength; + unsigned short replylength; enterprocedure("StartSetUpReply"); replylength = IShort(&buf[6]); @@ -539,12 +522,15 @@ long StartSetUpReply (fd, buf, n) return(0); } -long FinishSetUpReply (fd, buf, n) +static long +FinishSetUpReply (fd, buf, n) FD fd; unsigned char *buf; long n; { enterprocedure("FinishSetUpReply"); + if( Raw || (Verbose > 3) ) + DumpItem("Server Connect", fd, buf, n) ; PrintSetUpReply(buf); CS[fd].ByteProcessing = ServerPacket; CS[fd].NumberofBytesNeeded = 32; @@ -553,7 +539,8 @@ long FinishSetUpReply (fd, buf, n) /* ************************************************************ */ -long ErrorPacket (fd, buf, n) +static long +ErrorPacket (fd, buf, n) FD fd; unsigned char *buf; long n; @@ -566,7 +553,8 @@ long ErrorPacket (fd, buf, n) } -long EventPacket (fd, buf, n) +static long +EventPacket (fd, buf, n) FD fd; unsigned char *buf; long n; @@ -578,12 +566,19 @@ long EventPacket (fd, buf, n) } -long ReplyPacket (fd, buf, n) +static long +ReplyPacket (fd, buf, n) FD fd; unsigned char *buf; long n; { - short replylength; + /* + 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]); @@ -603,7 +598,8 @@ long ReplyPacket (fd, buf, n) return(0); } -long ServerPacket (fd, buf, n) +static long +ServerPacket (fd, buf, n) FD fd; unsigned char *buf; long n; diff --git a/table11.c b/table11.c index c527424..63b2011 100644 --- a/table11.c +++ b/table11.c @@ -23,11 +23,65 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************** */ #include "scope.h" #include "x11.h" +#include +#include +#include +#include + +static void InitBuiltInTypes(void); +static void InitEnumeratedTypes(void); +static void InitSetTypes(void); +static void InitRecordTypes(void); +static void InitValuesTypes(void); + +static int PrintCHAR2B(unsigned char *buf); +static int PrintPOINT(unsigned char *buf); +static int PrintRECTANGLE(unsigned char *buf); +static int PrintARC(unsigned char *buf); +static int PrintHOST(unsigned char *buf); +static int PrintTIMECOORD(unsigned char *buf); +static int PrintFONTPROP(unsigned char *buf); +static int PrintCHARINFO(unsigned char *buf); +static int PrintSEGMENT(unsigned char *buf); +static int PrintCOLORITEM(unsigned char *buf); +static int PrintRGB(unsigned char *buf); +static int PrintFORMAT(unsigned char *buf); +static int PrintSCREEN(unsigned char *buf); +static int PrintDEPTH(unsigned char *buf); +static int PrintVISUALTYPE(unsigned char *buf); + /* To initialize for the X11 protocol, we need to create data structures describing the data types used by X11. @@ -56,10 +110,9 @@ (index) and the bytes in memory that are its value. */ - +void InitializeX11() { - enterprocedure("InitializeX11"); InitReplyQ(); InitBuiltInTypes(); @@ -76,11 +129,12 @@ InitializeX11() /* define the various types */ -TYPE DefineType(typeid, class, name, printproc) +static TYPE +DefineType(typeid, class, name, printproc) short typeid; short class; char *name; - int (*printproc)(); + int (*printproc)(unsigned char *); { TD[typeid].Name = name; TD[typeid].Type = class; @@ -92,6 +146,7 @@ TYPE DefineType(typeid, class, name, printproc) /* ************************************************************ */ /* define an Enumerated Value (or a Set Value) */ +static void DefineEValue(type, value, name) TYPE type; long value; @@ -130,6 +185,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 DefineValues(type, value, length, ctype, name) TYPE type; long value; @@ -165,9 +221,9 @@ DefineValues(type, value, length, ctype, name) /* ************************************************************ */ +static void InitBuiltInTypes() { - enterprocedure("InitBuiltInTypes"); (void) DefineType(INT8, BUILTIN, "INT8", PrintINT8); (void) DefineType(INT16, BUILTIN, "INT16", PrintINT16); (void) DefineType(INT32, BUILTIN, "INT32", PrintINT32); @@ -210,12 +266,12 @@ InitBuiltInTypes() /* */ /* ************************************************************ */ +static void InitEnumeratedTypes() { TYPE p; - enterprocedure("InitEnumeratedTypes"); - p = DefineType(REQUEST, ENUMERATED, "REQUEST", PrintENUMERATED); + p = DefineType(REQUEST, ENUMERATED, "REQUEST", (PrintProcType) PrintENUMERATED); DefineEValue(p, 1L, "CreateWindow"); DefineEValue(p, 2L, "ChangeWindowAttributes"); DefineEValue(p, 3L, "GetWindowAttributes"); @@ -337,7 +393,7 @@ InitEnumeratedTypes() DefineEValue(p, 119L, "GetModifierMapping"); DefineEValue(p, 127L, "NoOperation"); - p = DefineType(REPLY, ENUMERATED, "REPLY", PrintENUMERATED); + p = DefineType(REPLY, ENUMERATED, "REPLY", (PrintProcType) PrintENUMERATED); DefineEValue(p, 3L, "GetWindowAttributes"); DefineEValue(p, 14L, "GetGeometry"); DefineEValue(p, 15L, "QueryTree"); @@ -379,7 +435,7 @@ InitEnumeratedTypes() DefineEValue(p, 118L, "SetModifierMapping"); DefineEValue(p, 119L, "GetModifierMapping"); - p = DefineType(ERROR, ENUMERATED, "ERROR", PrintENUMERATED); + p = DefineType(ERROR, ENUMERATED, "ERROR", (PrintProcType) PrintENUMERATED); DefineEValue(p, 1L, "Request"); DefineEValue(p, 2L, "Value"); DefineEValue(p, 3L, "Window"); @@ -398,7 +454,7 @@ InitEnumeratedTypes() DefineEValue(p, 16L, "Length"); DefineEValue(p, 17L, "Implementation"); - p = DefineType(EVENT, ENUMERATED, "EVENT", PrintENUMERATED); + p = DefineType(EVENT, ENUMERATED, "EVENT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 2L, "KeyPress"); DefineEValue(p, 3L, "KeyRelease"); DefineEValue(p, 4L, "ButtonPress"); @@ -433,42 +489,8 @@ InitEnumeratedTypes() DefineEValue(p, 33L, "ClientMessage"); DefineEValue(p, 34L, "MappingNotify"); - DefineEValue(p, 0x80L | 2L, "KeyPress (from SendEvent)"); - DefineEValue(p, 0x80L | 3L, "KeyRelease (from SendEvent)"); - DefineEValue(p, 0x80L | 4L, "ButtonPress (from SendEvent)"); - DefineEValue(p, 0x80L | 5L, "ButtonRelease (from SendEvent)"); - DefineEValue(p, 0x80L | 6L, "MotionNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 7L, "EnterNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 8L, "LeaveNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 9L, "FocusIn (from SendEvent)"); - DefineEValue(p, 0x80L | 10L, "FocusOut (from SendEvent)"); - DefineEValue(p, 0x80L | 11L, "KeymapNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 12L, "Expose (from SendEvent)"); - DefineEValue(p, 0x80L | 13L, "GraphicsExposure (from SendEvent)"); - DefineEValue(p, 0x80L | 14L, "NoExposure (from SendEvent)"); - DefineEValue(p, 0x80L | 15L, "VisibilityNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 16L, "CreateNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 17L, "DestroyNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 18L, "UnmapNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 19L, "MapNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 20L, "MapRequest (from SendEvent)"); - DefineEValue(p, 0x80L | 21L, "ReparentNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 22L, "ConfigureNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 23L, "ConfigureRequest (from SendEvent)"); - DefineEValue(p, 0x80L | 24L, "GravityNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 25L, "ResizeRequest (from SendEvent)"); - DefineEValue(p, 0x80L | 26L, "CirculateNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 27L, "CirculateRequest (from SendEvent)"); - DefineEValue(p, 0x80L | 28L, "PropertyNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 29L, "SelectionClear (from SendEvent)"); - DefineEValue(p, 0x80L | 30L, "SelectionRequest (from SendEvent)"); - DefineEValue(p, 0x80L | 31L, "SelectionNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 32L, "ColormapNotify (from SendEvent)"); - DefineEValue(p, 0x80L | 33L, "ClientMessage (from SendEvent)"); - DefineEValue(p, 0x80L | 34L, "MappingNotify (from SendEvent)"); - - - p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY", PrintENUMERATED); + + p = DefineType(BITGRAVITY, ENUMERATED, "BITGRAVITY", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Forget"); DefineEValue(p, 1L, "NorthWest"); DefineEValue(p, 2L, "North"); @@ -481,7 +503,7 @@ InitEnumeratedTypes() DefineEValue(p, 9L, "SouthEast"); DefineEValue(p, 10L, "Static"); - p = DefineType(WINGRAVITY, ENUMERATED, "WINGRAVITY", PrintENUMERATED); + p = DefineType(WINGRAVITY, ENUMERATED, "WINGRAVITY", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Unmap"); DefineEValue(p, 1L, "NorthWest"); DefineEValue(p, 2L, "North"); @@ -494,63 +516,67 @@ InitEnumeratedTypes() DefineEValue(p, 9L, "SouthEast"); DefineEValue(p, 10L, "Static"); - p = DefineType(BOOL, ENUMERATED, "BOOL", PrintENUMERATED); + p = DefineType(BOOL, ENUMERATED, "BOOL", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "False"); DefineEValue(p, 1L, "True"); - p = DefineType(HOSTFAMILY, ENUMERATED, "HOSTFAMILY", PrintENUMERATED); + p = DefineType(HOSTFAMILY, ENUMERATED, "HOSTFAMILY", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Internet"); DefineEValue(p, 1L, "DECnet"); DefineEValue(p, 2L, "Chaos"); + DefineEValue(p, 6L, "InternetV6"); + DefineEValue(p, 252L, "LocalHost"); + DefineEValue(p, 253L, "Kerberos5"); + DefineEValue(p, 254L, "SecureRPC"); - p = DefineType(PK_MODE, ENUMERATED, "PK_MODE", PrintENUMERATED); + p = DefineType(PK_MODE, ENUMERATED, "PK_MODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Synchronous"); DefineEValue(p, 1L, "Asynchronous"); - p = DefineType(NO_YES, ENUMERATED, "NO_YES", PrintENUMERATED); + p = DefineType(NO_YES, ENUMERATED, "NO_YES", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "No"); DefineEValue(p, 1L, "Yes"); DefineEValue(p, 2L, "Default"); - p = DefineType(WINDOWCLASS, ENUMERATED, "WINDOWCLASS", PrintENUMERATED); + p = DefineType(WINDOWCLASS, ENUMERATED, "WINDOWCLASS", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "CopyFromParent"); DefineEValue(p, 1L, "InputOutput"); DefineEValue(p, 2L, "InputOnly"); - p = DefineType(BACKSTORE, ENUMERATED, "BACKSTORE", PrintENUMERATED); + p = DefineType(BACKSTORE, ENUMERATED, "BACKSTORE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "NotUseful"); DefineEValue(p, 1L, "WhenMapped"); DefineEValue(p, 2L, "Always"); - p = DefineType(MAPSTATE, ENUMERATED, "MAPSTATE", PrintENUMERATED); + p = DefineType(MAPSTATE, ENUMERATED, "MAPSTATE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Unmapped"); DefineEValue(p, 1L, "Unviewable"); DefineEValue(p, 2L, "Viewable"); - p = DefineType(STACKMODE, ENUMERATED, "STACKMODE", PrintENUMERATED); + p = DefineType(STACKMODE, ENUMERATED, "STACKMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Above"); DefineEValue(p, 1L, "Below"); DefineEValue(p, 2L, "TopIf"); DefineEValue(p, 3L, "BottomIf"); DefineEValue(p, 4L, "Opposite"); - p = DefineType(CIRMODE, ENUMERATED, "CIRMODE", PrintENUMERATED); + p = DefineType(CIRMODE, ENUMERATED, "CIRMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "RaiseLowest"); DefineEValue(p, 1L, "LowerHighest"); - p = DefineType(CHANGEMODE, ENUMERATED, "CHANGEMODE", PrintENUMERATED); + p = DefineType(CHANGEMODE, ENUMERATED, "CHANGEMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Replace"); DefineEValue(p, 1L, "Prepend"); DefineEValue(p, 2L, "Append"); - p = DefineType(GRABSTAT, ENUMERATED, "GRABSTAT", PrintENUMERATED); + p = DefineType(GRABSTAT, ENUMERATED, "GRABSTAT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Success"); DefineEValue(p, 1L, "AlreadyGrabbed"); DefineEValue(p, 2L, "InvalidTime"); DefineEValue(p, 3L, "NotViewable"); DefineEValue(p, 4L, "Frozen"); - p = DefineType(EVENTMODE, ENUMERATED, "EVENTMODE", PrintENUMERATED); + p = DefineType(EVENTMODE, ENUMERATED, "EVENTMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "AsyncPointer"); DefineEValue(p, 1L, "SyncPointer"); DefineEValue(p, 2L, "ReplayPointer"); @@ -560,16 +586,16 @@ InitEnumeratedTypes() DefineEValue(p, 6L, "AsyncBoth"); DefineEValue(p, 7L, "SyncBoth"); - p = DefineType(FOCUSAGENT, ENUMERATED, "FOCUSAGENT", PrintENUMERATED); + p = DefineType(FOCUSAGENT, ENUMERATED, "FOCUSAGENT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "None"); DefineEValue(p, 1L, "PointerRoot"); DefineEValue(p, 2L, "Parent"); - p = DefineType(DIRECT, ENUMERATED, "DIRECT", PrintENUMERATED); + p = DefineType(DIRECT, ENUMERATED, "DIRECT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "LeftToRight"); DefineEValue(p, 1L, "RightToLeft"); - p = DefineType(GCFUNC, ENUMERATED, "GCFUNC", PrintENUMERATED); + p = DefineType(GCFUNC, ENUMERATED, "GCFUNC", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Clear"); DefineEValue(p, 1L, "And"); DefineEValue(p, 2L, "AndReverse"); @@ -587,101 +613,101 @@ InitEnumeratedTypes() DefineEValue(p, 14L, "Nand"); DefineEValue(p, 15L, "Set"); - p = DefineType(LINESTYLE, ENUMERATED, "LINESTYLE", PrintENUMERATED); + p = DefineType(LINESTYLE, ENUMERATED, "LINESTYLE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Solid"); DefineEValue(p, 1L, "OnOffDash"); DefineEValue(p, 2L, "DoubleDash"); - p = DefineType(CAPSTYLE, ENUMERATED, "CAPSTYLE", PrintENUMERATED); + p = DefineType(CAPSTYLE, ENUMERATED, "CAPSTYLE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "NotLast"); DefineEValue(p, 1L, "Butt"); DefineEValue(p, 2L, "Round"); DefineEValue(p, 3L, "Projecting"); - p = DefineType(JOINSTYLE, ENUMERATED, "JOINSTYLE", PrintENUMERATED); + p = DefineType(JOINSTYLE, ENUMERATED, "JOINSTYLE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Miter"); DefineEValue(p, 1L, "Round"); DefineEValue(p, 2L, "Bevel"); - p = DefineType(FILLSTYLE, ENUMERATED, "FILLSTYLE", PrintENUMERATED); + p = DefineType(FILLSTYLE, ENUMERATED, "FILLSTYLE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Solid"); DefineEValue(p, 1L, "Tiled"); DefineEValue(p, 2L, "Stippled"); DefineEValue(p, 3L, "OpaqueStippled"); - p = DefineType(FILLRULE, ENUMERATED, "FILLRULE", PrintENUMERATED); + p = DefineType(FILLRULE, ENUMERATED, "FILLRULE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "EvenOdd"); DefineEValue(p, 1L, "Winding"); - p = DefineType(SUBWINMODE, ENUMERATED, "SUBWINMODE", PrintENUMERATED); + p = DefineType(SUBWINMODE, ENUMERATED, "SUBWINMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "ClipByChildren"); DefineEValue(p, 1L, "IncludeInferiors"); - p = DefineType(ARCMODE, ENUMERATED, "ARCMODE", PrintENUMERATED); + p = DefineType(ARCMODE, ENUMERATED, "ARCMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Chord"); DefineEValue(p, 1L, "PieSlice"); - p = DefineType(RECTORDER, ENUMERATED, "RECTORDER", PrintENUMERATED); + p = DefineType(RECTORDER, ENUMERATED, "RECTORDER", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "UnSorted"); DefineEValue(p, 1L, "YSorted"); DefineEValue(p, 2L, "YXSorted"); DefineEValue(p, 3L, "YXBanded"); - p = DefineType(COORMODE, ENUMERATED, "COORMODE", PrintENUMERATED); + p = DefineType(COORMODE, ENUMERATED, "COORMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Origin"); DefineEValue(p, 1L, "Previous"); - p = DefineType(POLYSHAPE, ENUMERATED, "POLYSHAPE", PrintENUMERATED); + p = DefineType(POLYSHAPE, ENUMERATED, "POLYSHAPE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Complex"); DefineEValue(p, 1L, "Nonconvex"); DefineEValue(p, 2L, "Convex"); - p = DefineType(IMAGEMODE, ENUMERATED, "IMAGEMODE", PrintENUMERATED); + p = DefineType(IMAGEMODE, ENUMERATED, "IMAGEMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Bitmap"); DefineEValue(p, 1L, "XYPixmap"); DefineEValue(p, 2L, "ZPixmap"); - p = DefineType(ALLORNONE, ENUMERATED, "ALLORNONE", PrintENUMERATED); + p = DefineType(ALLORNONE, ENUMERATED, "ALLORNONE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "None"); DefineEValue(p, 1L, "All"); - p = DefineType(OBJECTCLASS, ENUMERATED, "OBJECTCLASS", PrintENUMERATED); + p = DefineType(OBJECTCLASS, ENUMERATED, "OBJECTCLASS", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Cursor"); DefineEValue(p, 1L, "Tile"); DefineEValue(p, 2L, "Stipple"); - p = DefineType(OFF_ON, ENUMERATED, "OFF_ON", PrintENUMERATED); + p = DefineType(OFF_ON, ENUMERATED, "OFF_ON", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Off"); DefineEValue(p, 1L, "On"); DefineEValue(p, 2L, "Default"); - p = DefineType(INS_DEL, ENUMERATED, "INS_DEL", PrintENUMERATED); + p = DefineType(INS_DEL, ENUMERATED, "INS_DEL", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Insert"); DefineEValue(p, 1L, "Delete"); - p = DefineType(DIS_EN, ENUMERATED, "DIS_EN", PrintENUMERATED); + p = DefineType(DIS_EN, ENUMERATED, "DIS_EN", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Disabled"); DefineEValue(p, 1L, "Enabled"); - p = DefineType(CLOSEMODE, ENUMERATED, "CLOSEMODE", PrintENUMERATED); + p = DefineType(CLOSEMODE, ENUMERATED, "CLOSEMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Destroy"); DefineEValue(p, 1L, "RetainPermanent"); DefineEValue(p, 2L, "RetainTemporary"); - p = DefineType(SAVEMODE, ENUMERATED, "SAVEMODE", PrintENUMERATED); + p = DefineType(SAVEMODE, ENUMERATED, "SAVEMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Reset"); DefineEValue(p, 1L, "Activate"); - p = DefineType(RSTATUS, ENUMERATED, "RSTATUS", PrintENUMERATED); + p = DefineType(RSTATUS, ENUMERATED, "RSTATUS", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Success"); DefineEValue(p, 1L, "Busy"); DefineEValue(p, 2L, "Failed"); - p = DefineType(MOTIONDETAIL, ENUMERATED, "MOTIONDETAIL", PrintENUMERATED); + p = DefineType(MOTIONDETAIL, ENUMERATED, "MOTIONDETAIL", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Normal"); DefineEValue(p, 1L, "Hint"); - p = DefineType(ENTERDETAIL, ENUMERATED, "ENTERDETAIL", PrintENUMERATED); + p = DefineType(ENTERDETAIL, ENUMERATED, "ENTERDETAIL", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Ancestor"); DefineEValue(p, 1L, "Virtual"); DefineEValue(p, 2L, "Inferior"); @@ -691,43 +717,43 @@ InitEnumeratedTypes() DefineEValue(p, 6L, "PointerRoot"); DefineEValue(p, 7L, "None"); - p = DefineType(BUTTONMODE, ENUMERATED, "BUTTONMODE", PrintENUMERATED); + p = DefineType(BUTTONMODE, ENUMERATED, "BUTTONMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Normal"); DefineEValue(p, 1L, "Grab"); DefineEValue(p, 2L, "Ungrab"); DefineEValue(p, 3L, "WhileGrabbed"); - p = DefineType(VISIBLE, ENUMERATED, "VISIBLE", PrintENUMERATED); + p = DefineType(VISIBLE, ENUMERATED, "VISIBLE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Unobscured"); DefineEValue(p, 1L, "PartiallyObscured"); DefineEValue(p, 2L, "FullyObscured"); - p = DefineType(CIRSTAT, ENUMERATED, "CIRSTAT", PrintENUMERATED); + p = DefineType(CIRSTAT, ENUMERATED, "CIRSTAT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Top"); DefineEValue(p, 1L, "Bottom"); - p = DefineType(PROPCHANGE, ENUMERATED, "PROPCHANGE", PrintENUMERATED); + p = DefineType(PROPCHANGE, ENUMERATED, "PROPCHANGE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "NewValue"); DefineEValue(p, 1L, "Deleted"); - p = DefineType(CMAPCHANGE, ENUMERATED, "CMAPCHANGE", PrintENUMERATED); + p = DefineType(CMAPCHANGE, ENUMERATED, "CMAPCHANGE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Uninstalled"); DefineEValue(p, 1L, "Installed"); - p = DefineType(MAPOBJECT, ENUMERATED, "MAPOBJECT", PrintENUMERATED); + p = DefineType(MAPOBJECT, ENUMERATED, "MAPOBJECT", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "Modifier"); DefineEValue(p, 1L, "Keyboard"); DefineEValue(p, 2L, "Pointer"); - p = DefineType(BYTEMODE, ENUMERATED, "BYTEMODE", PrintENUMERATED); + p = DefineType(BYTEMODE, ENUMERATED, "BYTEMODE", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0x42L, "MSB first"); DefineEValue(p, 0x6CL, "LSB first"); - p = DefineType(BYTEORDER, ENUMERATED, "BYTEORDER", PrintENUMERATED); + p = DefineType(BYTEORDER, ENUMERATED, "BYTEORDER", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "LSB first"); DefineEValue(p, 1L, "MSB first"); - p = DefineType(COLORCLASS, ENUMERATED, "COLORCLASS", PrintENUMERATED); + p = DefineType(COLORCLASS, ENUMERATED, "COLORCLASS", (PrintProcType) PrintENUMERATED); DefineEValue(p, 0L, "StaticGray"); DefineEValue(p, 1L, "GrayScale"); DefineEValue(p, 2L, "StaticColor"); @@ -741,12 +767,12 @@ InitEnumeratedTypes() /* */ /* ************************************************************ */ +static void InitSetTypes() { TYPE p; - enterprocedure("InitSetTypes"); - p = DefineType(SETofEVENT, SET, "SETofEVENT", PrintSET); + p = DefineType(SETofEVENT, SET, "SETofEVENT", (PrintProcType) PrintSET); DefineEValue(p, 0x00000001L, "KeyPress"); DefineEValue(p, 0x00000002L, "KeyRelease"); DefineEValue(p, 0x00000004L, "ButtonPress"); @@ -773,7 +799,7 @@ InitSetTypes() DefineEValue(p, 0x00800000L, "ColormapChange"); DefineEValue(p, 0x01000000L, "OwnerGrabButton"); - p = DefineType(SETofPOINTEREVENT, SET, "SETofPOINTEREVENT", PrintSET); + p = DefineType(SETofPOINTEREVENT, SET, "SETofPOINTEREVENT", (PrintProcType) PrintSET); DefineEValue(p, 0x00000004L, "ButtonPress"); DefineEValue(p, 0x00000008L, "ButtonRelease"); DefineEValue(p, 0x00000010L, "EnterWindow"); @@ -788,7 +814,7 @@ InitSetTypes() DefineEValue(p, 0x00002000L, "ButtonMotion"); DefineEValue(p, 0x00004000L, "KeymapState"); - p = DefineType(SETofDEVICEEVENT, SET, "SETofDEVICEEVENT", PrintSET); + p = DefineType(SETofDEVICEEVENT, SET, "SETofDEVICEEVENT", (PrintProcType) PrintSET); DefineEValue(p, 0x00000001L, "KeyPress"); DefineEValue(p, 0x00000002L, "KeyRelease"); DefineEValue(p, 0x00000004L, "ButtonPress"); @@ -801,7 +827,7 @@ InitSetTypes() DefineEValue(p, 0x00001000L, "Button5Motion"); DefineEValue(p, 0x00002000L, "ButtonMotion"); - p = DefineType(SETofKEYBUTMASK, SET, "SETofKEYBUTMASK", PrintSET); + p = DefineType(SETofKEYBUTMASK, SET, "SETofKEYBUTMASK", (PrintProcType) PrintSET); DefineEValue(p, 0x0001L, "Shift"); DefineEValue(p, 0x0002L, "Lock"); DefineEValue(p, 0x0004L, "Control"); @@ -816,7 +842,7 @@ InitSetTypes() DefineEValue(p, 0x0800L, "Button4"); DefineEValue(p, 0x1000L, "Button5"); - p = DefineType(SETofKEYMASK, SET, "SETofKEYMASK", PrintSET); + p = DefineType(SETofKEYMASK, SET, "SETofKEYMASK", (PrintProcType) PrintSET); DefineEValue(p, 0x0001L, "Shift"); DefineEValue(p, 0x0002L, "Lock"); DefineEValue(p, 0x0004L, "Control"); @@ -827,12 +853,12 @@ InitSetTypes() DefineEValue(p, 0x0080L, "Mod5"); DefineEValue(p, 0x8000L, "AnyModifier"); - p = DefineType(COLORMASK, SET, "COLORMASK", PrintSET); + p = DefineType(COLORMASK, SET, "COLORMASK", (PrintProcType) PrintSET); DefineEValue(p, 0x01L, "do-red"); DefineEValue(p, 0x02L, "do-green"); DefineEValue(p, 0x04L, "do-blue"); - p = DefineType(SCREENFOCUS, SET, "SCREENFOCUS", PrintSET); + p = DefineType(SCREENFOCUS, SET, "SCREENFOCUS", (PrintProcType) PrintSET); DefineEValue(p, 0x01L, "focus"); DefineEValue(p, 0x02L, "same-screen"); } @@ -845,13 +871,16 @@ InitSetTypes() /* Print Routines for builtin record types */ +static int PrintCHAR2B(buf) unsigned char *buf; { PrintField(buf, 0, 1, CARD8, "byte1"); PrintField(buf, 1, 1, CARD8, "byte2"); + return(2); } +static int PrintPOINT(buf) unsigned char *buf; { @@ -860,6 +889,7 @@ PrintPOINT(buf) return(4); } +static int PrintRECTANGLE(buf) unsigned char *buf; { @@ -870,6 +900,7 @@ PrintRECTANGLE(buf) return(8); } +static int PrintARC(buf) unsigned char *buf; { @@ -882,6 +913,7 @@ PrintARC(buf) return(12); } +static int PrintHOST(buf) unsigned char *buf; { @@ -889,10 +921,39 @@ PrintHOST(buf) PrintField(buf, 0, 1, HOSTFAMILY, "family"); PrintField(buf, 2, 2, DVALUE2(n), "length of address"); n = IShort(&buf[2]); - (void)PrintList(&buf[4], (long)n, BYTE, "address"); + switch (buf[0]) { + case 0: + { + struct in_addr ia; + char *addr; + memcpy(&ia, &buf[4], sizeof(ia)); /* Need to get alignment right */ + addr = inet_ntoa(ia); + PrintString8((unsigned char *)addr, strlen(addr), "address"); + break; + } +#ifdef IPv6 + case 6: + { + struct in6_addr i6a; + char addr[INET6_ADDRSTRLEN]; + memcpy(&i6a, &buf[4], sizeof(i6a)); /* Need to get alignment right */ + inet_ntop(AF_INET6, &i6a, addr, sizeof(addr)); + PrintString8((unsigned char *) addr, strlen(addr), "address"); + break; + } +#endif + + case 254: + PrintString8(&buf[4], n, "address"); + break; + + default: + PrintList(&buf[4], (long)n, BYTE, "address"); + } return(pad((long)(4 + n))); } +static int PrintTIMECOORD(buf) unsigned char *buf; { @@ -902,6 +963,7 @@ PrintTIMECOORD(buf) return(8); } +static int PrintFONTPROP(buf) unsigned char *buf; { @@ -910,6 +972,7 @@ PrintFONTPROP(buf) return(8); } +static int PrintCHARINFO(buf) unsigned char *buf; { @@ -922,6 +985,7 @@ PrintCHARINFO(buf) return(12); } +static int PrintSEGMENT(buf) unsigned char *buf; { @@ -932,6 +996,7 @@ PrintSEGMENT(buf) return(8); } +static int PrintCOLORITEM(buf) unsigned char *buf; { @@ -943,6 +1008,7 @@ PrintCOLORITEM(buf) return(12); } +static int PrintRGB(buf) unsigned char *buf; { @@ -952,6 +1018,7 @@ PrintRGB(buf) return(8); } +static int PrintFORMAT(buf) unsigned char *buf; { @@ -961,6 +1028,7 @@ PrintFORMAT(buf) return(8); } +static int PrintSCREEN(buf) unsigned char *buf; { @@ -988,6 +1056,7 @@ PrintSCREEN(buf) return(40 + m); } +static int PrintDEPTH(buf) unsigned char *buf; { @@ -1001,6 +1070,7 @@ PrintDEPTH(buf) return(8 + m); } +static int PrintVISUALTYPE(buf) unsigned char *buf; { @@ -1016,9 +1086,9 @@ PrintVISUALTYPE(buf) /* ************************************************************ */ +static void InitRecordTypes() { - enterprocedure("InitRecordTypes"); (void) DefineType(CHAR2B, RECORD, "CHAR2B", PrintCHAR2B); (void) DefineType(POINT, RECORD, "POINT", PrintPOINT); (void) DefineType(RECTANGLE, RECORD, "RECTANGLE", PrintRECTANGLE); @@ -1043,12 +1113,12 @@ InitRecordTypes() /* */ /* ************************************************************ */ +static void InitValuesTypes() { TYPE p; - enterprocedure("InitValueTypes"); - p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK", PrintSET); + p = DefineType(WINDOW_BITMASK, SET, "WINDOW_BITMASK", (PrintProcType) PrintSET); DefineValues(p, 0x00000001L, 4, PIXMAPNPR, "background-pixmap"); DefineValues(p, 0x00000002L, 4, CARD32, "background-pixel"); @@ -1066,7 +1136,7 @@ InitValuesTypes() DefineValues(p, 0x00002000L, 4, COLORMAPC, "colormap"); DefineValues(p, 0x00004000L, 4, CURSOR, "cursor"); - p = DefineType(CONFIGURE_BITMASK, SET, "CONFIGURE_BITMASK", PrintSET); + p = DefineType(CONFIGURE_BITMASK, SET, "CONFIGURE_BITMASK", (PrintProcType) PrintSET); DefineValues(p, 0x0001L, 2, INT16, "x"); DefineValues(p, 0x0002L, 2, INT16, "y"); DefineValues(p, 0x0004L, 2, CARD16, "width"); @@ -1075,7 +1145,7 @@ InitValuesTypes() DefineValues(p, 0x0020L, 4, WINDOW, "sibling"); DefineValues(p, 0x0040L, 1, STACKMODE, "stack-mode"); - p = DefineType(GC_BITMASK, SET, "GC_BITMASK", PrintSET); + p = DefineType(GC_BITMASK, SET, "GC_BITMASK", (PrintProcType) PrintSET); DefineValues(p, 0x00000001L, 1, GCFUNC, "function"); DefineValues(p, 0x00000002L, 4, CARD32, "plane-mask"); DefineValues(p, 0x00000004L, 4, CARD32, "foreground"); @@ -1100,7 +1170,7 @@ InitValuesTypes() DefineValues(p, 0x00200000L, 1, CARD8, "dashes"); DefineValues(p, 0x00400000L, 1, ARCMODE, "arc-mode"); - p = DefineType(KEYBOARD_BITMASK, SET, "KEYBOARD_BITMASK", PrintSET); + p = DefineType(KEYBOARD_BITMASK, SET, "KEYBOARD_BITMASK", (PrintProcType) PrintSET); DefineValues(p, 0x0001L, 1, INT8, "key-click-percent"); DefineValues(p, 0x0002L, 1, INT8, "bell-percent"); DefineValues(p, 0x0004L, 2, INT16, "bell-pitch"); diff --git a/x11.h b/x11.h index 059b159..175250b 100644 --- a/x11.h +++ b/x11.h @@ -23,8 +23,37 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * + * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + * * ************************************************************ */ +#ifndef XSCOPE_X11_H +#define XSCOPE_X11_H /* Some field contents are constants, not just types */ @@ -64,7 +93,7 @@ #define WINDOWNR 14 /* CARD32 plus 0 = None, 1 = PointerRoot */ #define PIXMAP 15 /* CARD32 plus 0 = None */ -#define PIXMAPNPR 16 /* CARD32 plus 0 = None, 1 = ParentRelative +#define PIXMAPNPR 16 /* CARD32 plus 0 = None, 1 = ParentRelative */ #define PIXMAPC 17 /* CARD32 plus 0 = CopyFromParent */ @@ -108,72 +137,72 @@ /* Defined types */ -#define BITGRAVITY 40 -#define WINGRAVITY 41 -#define BOOL 42 -#define HOSTFAMILY 43 -#define PK_MODE 44 -#define NO_YES 45 -#define WINDOWCLASS 46 -#define BACKSTORE 47 -#define MAPSTATE 48 -#define STACKMODE 49 -#define CIRMODE 50 -#define CHANGEMODE 51 -#define GRABSTAT 52 -#define EVENTMODE 53 -#define FOCUSAGENT 54 -#define DIRECT 55 -#define GCFUNC 56 -#define LINESTYLE 57 -#define CAPSTYLE 58 -#define JOINSTYLE 59 -#define FILLSTYLE 60 -#define FILLRULE 61 -#define SUBWINMODE 62 -#define ARCMODE 63 -#define RECTORDER 64 -#define COORMODE 65 -#define POLYSHAPE 66 -#define IMAGEMODE 67 -#define ALLORNONE 68 -#define OBJECTCLASS 69 -#define OFF_ON 70 -#define INS_DEL 71 -#define DIS_EN 72 -#define CLOSEMODE 73 -#define SAVEMODE 74 -#define RSTATUS 75 -#define MOTIONDETAIL 76 -#define ENTERDETAIL 77 -#define BUTTONMODE 78 -#define SCREENFOCUS 79 -#define VISIBLE 80 -#define CIRSTAT 81 -#define PROPCHANGE 82 -#define CMAPCHANGE 83 -#define MAPOBJECT 84 -#define SETofEVENT 85 -#define SETofPOINTEREVENT 86 -#define SETofDEVICEEVENT 87 -#define SETofKEYBUTMASK 88 -#define SETofKEYMASK 89 -#define WINDOW_BITMASK 90 -#define CONFIGURE_BITMASK 91 -#define GC_BITMASK 92 -#define KEYBOARD_BITMASK 93 -#define COLORMASK 94 -#define CHAR2B 95 -#define POINT 96 -#define RECTANGLE 97 -#define ARC 98 -#define HOST 99 -#define TIMECOORD 100 -#define FONTPROP 101 -#define CHARINFO 102 -#define SEGMENT 103 -#define COLORITEM 104 -#define RGB 105 +#define BITGRAVITY 40 +#define WINGRAVITY 41 +#define BOOL 42 +#define HOSTFAMILY 43 +#define PK_MODE 44 +#define NO_YES 45 +#define WINDOWCLASS 46 +#define BACKSTORE 47 +#define MAPSTATE 48 +#define STACKMODE 49 +#define CIRMODE 50 +#define CHANGEMODE 51 +#define GRABSTAT 52 +#define EVENTMODE 53 +#define FOCUSAGENT 54 +#define DIRECT 55 +#define GCFUNC 56 +#define LINESTYLE 57 +#define CAPSTYLE 58 +#define JOINSTYLE 59 +#define FILLSTYLE 60 +#define FILLRULE 61 +#define SUBWINMODE 62 +#define ARCMODE 63 +#define RECTORDER 64 +#define COORMODE 65 +#define POLYSHAPE 66 +#define IMAGEMODE 67 +#define ALLORNONE 68 +#define OBJECTCLASS 69 +#define OFF_ON 70 +#define INS_DEL 71 +#define DIS_EN 72 +#define CLOSEMODE 73 +#define SAVEMODE 74 +#define RSTATUS 75 +#define MOTIONDETAIL 76 +#define ENTERDETAIL 77 +#define BUTTONMODE 78 +#define SCREENFOCUS 79 +#define VISIBLE 80 +#define CIRSTAT 81 +#define PROPCHANGE 82 +#define CMAPCHANGE 83 +#define MAPOBJECT 84 +#define SETofEVENT 85 +#define SETofPOINTEREVENT 86 +#define SETofDEVICEEVENT 87 +#define SETofKEYBUTMASK 88 +#define SETofKEYMASK 89 +#define WINDOW_BITMASK 90 +#define CONFIGURE_BITMASK 91 +#define GC_BITMASK 92 +#define KEYBOARD_BITMASK 93 +#define COLORMASK 94 +#define CHAR2B 95 +#define POINT 96 +#define RECTANGLE 97 +#define ARC 98 +#define HOST 99 +#define TIMECOORD 100 +#define FONTPROP 101 +#define CHARINFO 102 +#define SEGMENT 103 +#define COLORITEM 104 +#define RGB 105 #define BYTEMODE 110 #define BYTEORDER 111 #define COLORCLASS 112 @@ -189,52 +218,6 @@ #define MaxTypes 128 -/* ************************************************************ */ -/* */ -/* */ -/* ************************************************************ */ - -/* declaration of the existance of print routines for the basic types */ - -extern PrintINT8(); -extern PrintINT16(); -extern PrintINT32(); -extern PrintCARD8(); -extern PrintCARD16(); -extern PrintCARD32(); -extern PrintBYTE(); -extern PrintCHAR8(); -extern PrintSTRING16(); -extern PrintTEXTITEM8(); -extern PrintTEXTITEM16(); -extern PrintSTR(); -extern PrintWINDOW(); -extern PrintWINDOWD(); -extern PrintWINDOWNR(); -extern PrintPIXMAP(); -extern PrintPIXMAPNPR(); -extern PrintPIXMAPC(); -extern PrintCURSOR(); -extern PrintFONT(); -extern PrintGCONTEXT(); -extern PrintCOLORMAP(); -extern PrintCOLORMAPC(); -extern PrintDRAWABLE(); -extern PrintFONTABLE(); -extern PrintATOM(); -extern PrintATOMT(); -extern PrintVISUALID(); -extern PrintVISUALIDC(); -extern PrintTIMESTAMP(); -extern PrintRESOURCEID(); -extern PrintKEYSYM(); -extern PrintKEYCODE(); -extern PrintKEYCODEA(); -extern PrintBUTTON(); -extern PrintBUTTONA(); -extern PrintEVENTFORM(); -extern PrintENUMERATED(); -extern PrintSET(); /* ************************************************************ */ /* */ @@ -244,7 +227,7 @@ extern PrintSET(); /* Type Definition Table Each item in the X11 Protocol has a type. There are about 120 - different types. We need to be able to print each item in a + different types. We need to be able to print each item in a format and interpretation which is appropriate for the type of that item. To do so, we build a table describing each type. Each type has a name, possibly a list of named values and a @@ -270,12 +253,14 @@ struct ValueListEntry long Value; }; +typedef int (*PrintProcType) (unsigned char *); + struct TypeDef { char *Name; short Type /* BUILTIN, ENUMERATED, SET, or RECORD */ ; struct ValueListEntry *ValueList; - int (*PrintProc)(); + PrintProcType PrintProc; }; typedef struct TypeDef *TYPE; @@ -287,6 +272,53 @@ 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); + +/* ************************************************************ */ +/* */ +/* */ +/* ************************************************************ */ + /* 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 */ @@ -294,7 +326,7 @@ unsigned char RBf[2]; /* Sequence Buffer: Pseudo-buffer used to provide the sequence number for a - request: Set by DecodeReply and used in a PrintField of + request: Set by DecodeReply and used in a PrintField of the Request procedure */ unsigned char SBf[4]; @@ -307,7 +339,7 @@ unsigned char SBf[4]; /* */ /* ************************************************************ */ -/* +/* In general, we are called with a buffer of bytes and are supposed to try to make sense of these bytes according to the X11 protocol. There are two different types of communication: requests from the client to @@ -324,7 +356,7 @@ unsigned char SBf[4]; have until more bytes arrive. In general, we do two things: we wait for some number of bytes, and - then we interpret this set of bytes. To interpret this data we use + then we interpret this set of bytes. To interpret this data we use a modified state machine. We keep two pieces of information: (1) the number of bytes that we need @@ -338,7 +370,7 @@ unsigned char SBf[4]; The data going from the client to the x11 server consists of a set-up message followed by an infinite stream of variable length - requests. + requests. Our overall flow is then: @@ -347,7 +379,7 @@ unsigned char SBf[4]; length of the rest of the message. (c) Wait for the rest of the set-up message. (d) Interpret and print the set-up message. - + *** end of set-up phase -- start normal request loop *** (e) Wait for 4 bytes. @@ -388,19 +420,19 @@ unsigned char SBf[4]; This latter seems more effective. It appears reply/error/event formats were selected to allow waiting for 32 bytes, and it will allow short packets which are only 32 bytes long, to be processed completely in one step. - - Thus, For normal reply/error/event processing we have + + Thus, For normal reply/error/event processing we have (e) Wait for 32 bytes. (f) Interpret these 32 bytes. If possible, go back to step (e). (g) If the packet is a reply with bytes 4-7 non-zero, wait for the remainder of the the reply. (h) Interpret and print the longer reply. Go back to step (e). - + The similarity in approach to how both the client and server are handled suggests we can use the same control structure to drive the interpretation - of both types of communication client->server and server->client. + of both types of communication client->server and server->client. Accordingly, we package up the relevant variables in a ConnState record. The ConnState record contains the buffer of saved bytes (if any), the size and length of this buffer, the number of bytes we are waiting for @@ -417,6 +449,7 @@ unsigned char SBf[4]; struct ConnState { unsigned char *SavedBytes; + int littleEndian; long SizeofSavedBytes; long NumberofSavedBytes; @@ -440,13 +473,11 @@ struct ConnState CS[StaticMaxFD]; extern unsigned long ILong(); extern unsigned short IShort(); -extern unsigned short IChar2B(); extern unsigned short IByte(); extern Boolean IBool(); -extern PrintString8(); -extern PrintString16(); -extern PrintListSTR(); - extern long PrintList(); +extern long PrintListSTR(); extern long pad(); + +#endif /* XSCOPE_X11_H */ -- cgit v1.2.1