Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!sun-barr!newstop!sun!otc.otca.oz.au From: gregm@otc.otca.oz.au (Greg McFarlane) Newsgroups: comp.sources.x Subject: v09i015: Xmon - X protocol monitor, Part01/05 Message-ID: <141778@sun.Eng.Sun.COM> Date: 4 Sep 90 18:46:23 GMT Sender: news@sun.Eng.Sun.COM Lines: 2181 Approved: argv@sun.com Submitted-by: Greg McFarlane Posting-number: Volume 9, Issue 15 Archive-name: xmon/part01 Xmon, an interactive X protocol monitor Xmon interactively monitors the byte-stream connections between an X server and a number of X clients. Xmon recognizes all X requests, events, errors and replies sent between the clients and the server which are part of the X protocol. The contents of these messages are displayed on standard output at a user settable degree of detail from none to every bit and byte. Xmon also allows the user to select a number of requests or events to be monitored at a different degree of detail. Xmon will also block the transmission of selected requests from the clients to the server and selected events from the server to the clients. Xmon also keeps statistics of the number of requests, events, and errors received. Xmon is made up of two separate processes. The core of xmon is xmond which monitors the X protocol streams and displays the protocol messages on standard output. The interactive interface is handled by xmonui. These two processes communicate via a pipe from the standard output of xmonui to the standard input of xmond. Xmon was written by Greg McFarlane, OTC, Australia, based on the xscope program written by James L Peterson, MCC. Submitted-by: gregm@otc.otca.oz.au Archive-name: xmon/part01 ---- Cut Here and unpack ---- #!/bin/sh # This is xmon, a shell archive (shar 3.32) # made 09/04/1990 00:13 UTC by gregm@otc.otca.oz.au # Source directory /u/sysdev/gregm/xmon.post # # existing files will NOT be overwritten # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 724 -rw-rw-r-- README # 6411 -rw-r--r-- xmon.man # 705 -rw-rw-r-- Imakefile # 9934 -rw-rw-r-- Makefile # 22888 -rw-rw-r-- decode11.c # 3043 -rwxr-xr-- linkl.c # 105346 -rw-rw-r-- print11.c # 9529 -rw-rw-r-- server.c # 1997 -rw-rw-r-- fd.c # 30426 -rw-rw-r-- main.c # 19125 -rw-rw-r-- prtype.c # 37451 -rw-rw-r-- table11.c # 6219 -rwxrwxr-x widgeti.c # 10121 -rw-rw-r-- xmonui.c # 1104 -rwxr-xr-- common.h # 773 -rw-rw-r-- events.h # 1368 -rwxr-xr-- linkl.h # 2861 -rw-rw-r-- requests.h # 3646 -rw-rw-r-- select_args.h # 1551 -rwxrwxr-x widgeti.h # 10536 -rw-rw-r-- x11.h # 18148 -rwxrwxr-x xmond.h # 247 -rwxrwxr-x xmonui.h # 21 -rw-rw-r-- patchlevel.h # if touch 2>&1 | fgrep 'amc' > /dev/null then TOUCH=touch else TOUCH=true fi # ============= README ============== if test X"$1" != X"-c" -a -f 'README'; then echo "File already exists: skipping 'README'" else echo "x - extracting README (Text)" sed 's/^X//' << 'SHAR_EOF' > README && XXMON - An interactive X protocol monitor X XIf you want to read about xmon, look at the manual page in xmon.man. X XTo make xmon first make the Makefile. If you have xmkmf, then Xuse it to create the Makefile. XIf you don't have xmkmf, then type X make Makefile XIf you don't have imake, then good luck with modifing the Makefile. X XYou may want to delete the -Bstatic flag from the Imakefile (or Makefile Xif you are not using imake). I need it to get around the infamous X ld.so: Undefined symbol: __XtInherit Xerror with shared libraries on Suns. X XWhen you have finished the Makefile, type X make Xto make the two programs xmond and xmonui. X XRun xmon with the command X xmonui | xmond X XPlease send any reports to X gregm@otc.otca.oz.au X SHAR_EOF $TOUCH -am 0903172790 README && chmod 0664 README || echo "restore of README failed" set `wc -c README`;Wc_c=$1 if test "$Wc_c" != "724"; then echo original size 724, current size $Wc_c fi fi # ============= xmon.man ============== if test X"$1" != X"-c" -a -f 'xmon.man'; then echo "File already exists: skipping 'xmon.man'" else echo "x - extracting xmon.man (Text)" sed 's/^X//' << 'SHAR_EOF' > xmon.man && X.TH xmon 1 "September, 1990" "X Version 11" X.SH NAME Xxmon \- interactive X protocol monitor X.SH SYNOPSIS X.B xmonui X[ X.B Xoptions X] | X.B Xxmond X[ X.B Xoptions X] X.SH DESCRIPTION XXmon interactively monitors the byte-stream connections between an XX server and a number of X clients. Xmon recognizes all X requests, Xevents, errors and replies sent between the clients and the server Xwhich are part of the X protocol. The contents of these messages are Xdisplayed on standard output at a user settable degree of detail Xfrom none to every bit and byte. Xmon also allows the user to Xselect a number of requests or events to be monitored at a different Xdegree of detail. Xmon will also block the transmission Xof selected requests from the clients to the server and selected events Xfrom the server to the clients. Xmon also keeps statistics of the Xnumber of requests, events, and errors received. X.PP XXmon is made up of two separate processes. The core of xmon is xmond Xwhich monitors the X protocol streams and displays the protocol Xmessages on standard output. The interactive interface is Xhandled by xmonui. These two processes communicate via a pipe from Xthe standard output of xmonui to the standard input of xmond. X.PP XThe following diagram shows the relationships between xmonui Xand xmond, and the clients and the server. X.PP X ---------- X | xmonui | X ---------- X | X v X ------------ ---------- X | client 1 |<------->| | X ------------ | | ---------- X : | xmond |<----->| server | X : | | ---------- X ------------ | | X | client n |<------->| | X ------------ ---------- X | X v X monitor output to stdout X X.PP XIn the diagram the vertical connections are pipes and the horizontal Xconnections are normal X connections. X.PP XXmond sits transparently between the X clients and an X server. XTo the clients it behaves just like an X server and to the server Xit behaves just like a number of X clients. X.SH OPTIONS TO XMOND X.TP X.B "-server \fIdisplay_name\fP:\fIdisplay_number\fP" XThis option sets the X display which xmond connects to. XDefault for \fIdisplay_name\fP is the local host. XDefault for \fIdisplay_number\fP is 0. X.TP X.B "-port \fIdisplay_number\fP" XThis option sets the Xport on which xmond listens for client connections. This port is always Xon the host where xmond is running. XDefault is 1. X.SH OPTIONS TO XMONUI XXmonui accepts all of the standard X Toolkit command line options. XIn particular X.TP X.B "-display \fIdisplay_name\fP:\fIdisplay_number\fP" XIndicates where to display the user interface window. X.SH EXAMPLES X1) To monitor connections made to the local host use the following command line X.PP Xxmonui | xmond X.PP XConnections made to the display \fIlocalhost:1\fP will appear on Xthe display \fIlocalhost:0\fP. XThe xmonui user interface will Xappear on the display \fIlocalhost:0\fP. X.PP X2) If you are on the host \fIsquiggle\fP which has two X servers using Xthe displays \fIsquiggle:0\fP and \fIsquiggle:1\fP, and want to monitor Xconnections made to the server running on the display X\fIjuggler:0\fP, enter the following command line. X.PP Xxmonui -display squiggle:0 | xmond -server juggler:0 -port 2 X.PP XConnections now made to the "display" \fIsquiggle:2\fP will Xappear on the display \fIjuggler:0\fP. XThe xmonui user interface will Xappear on the display \fIsquiggle:0\fP. XMonitor output will appear in the window where the command was entered. X.SH THE USER INTERFACE XThe user interface is divided into four parts: output detail, Xstatistics, selected requests and selected events. X.PP XIn the \fIoutput detail\fP section, the amount of detail contained Xin the output of xmon can be selected. Different levels of detail can Xbe selected for each of the message types: requests, Xevents, errors and replies. The detail setting for errors also applies to Xsetup messages sent at client connection and the end-of-file "message" sent Xat client shutdown. XThe meaning of each level is as follows. X.TP X.I off XNo monitor output is produced. X.TP X.I names XOnly the names of the messages are output. X.TP X.I main XThe most interesting fields of the message are output. X.TP X.I full XAll fields of the message are output. X.TP X.I hex XAll fields of the message are output, as well as a hexadecimal dump. X.PP XIn the \fIstatistics\fP section, the counting of requests, events and Xerrors can be controlled as follows. X.TP X.I start XEnable the taking of statistics. X.TP X.I stop XDisable the taking of statistics. X.TP X.I clear XClear the counts for this message group. X.TP X.I print XPrint the name and number of occurrences of each message in this group, Xexcluding messages received zero times. X.TP X.I print zero XPrint the names of messages in this group that have been received zero times. X.PP XIn the \fIselected requests\fP section, selected requests can be monitored Xat a different level of detail, or can be blocked from transmission. XRequests can be selected by clicking on their names in the scrollable list. XClicking again de-selects the request. XSelected requests are indicated Xby an asterisk (*) in the scrollable list. X.PP XThe \fIdetail\fP toggle is Xof the same form as in the \fIoutput detail\fP section, but applies only Xto those requests selected in the left scrollable list. X.PP XIf the \fIblocking\fP toggle in set to \fIon\fP, Xall selected requests in the right hand scrollable list are blocked by xmon. XThey are not forwarded to the server, although they are monitored and Xcounted normally. XIf the \fIblocking\fP toggle in set to \fIoff\fP, all requests are Xforwarded to the server. X.PP XThe \fIselected events\fP section is similar to the above section but Xdeals with events received from the server. X.SH BUGS XTested only on Sun3 machines. Byte swapping may produce problems on other Xmachines. X.PP XNo provision is included for extensions to the base protocol. X.SH SEE ALSO XX(1) X.PP XX Window System Protocol, MIT X Consortium Standard, X Version 11, Release 4, Xby Robert W. Scheifler. X.SH AUTHORS XGreg McFarlane, OTC, Australia, from the xscope program Xwritten by James L Peterson, MCC. X.PP XPlease send any bug reports or modifications to X.PP X gregm@otc.otca.oz.au SHAR_EOF $TOUCH -am 0903174090 xmon.man && chmod 0644 xmon.man || echo "restore of xmon.man failed" set `wc -c xmon.man`;Wc_c=$1 if test "$Wc_c" != "6411"; then echo original size 6411, current size $Wc_c fi fi # ============= Imakefile ============== if test X"$1" != X"-c" -a -f 'Imakefile'; then echo "File already exists: skipping 'Imakefile'" else echo "x - extracting Imakefile (Text)" sed 's/^X//' << 'SHAR_EOF' > Imakefile && XLOCAL_LIBRARIES = -Bstatic -lXaw -lXmu -lXt -lXext -lX11 XCDEBUGFLAGS = -g X XSRCS1 = decode11.c linkl.c print11.c server.c fd.c main.c prtype.c table11.c XOBJS1 = decode11.o linkl.o print11.o server.o fd.o main.o prtype.o table11.o X XSRCS2 = widgeti.c xmonui.c XOBJS2 = widgeti.o xmonui.o X XINCLUDE_FILES = common.h events.h linkl.h requests.h select_args.h \ X widgeti.h x11.h xmond.h xmonui.h patchlevel.h X XPROGRAMS = xmond xmonui X XComplexProgramTarget_1(xmond, $(LOCAL_LIBRARIES), ) XComplexProgramTarget_2(xmonui, $(LOCAL_LIBRARIES), ) X XSHARFILES = README xmon.man Imakefile Makefile $(SRCS1) $(SRCS2) $(INCLUDE_FILES) X Xshar: X shar -n xmon -s "gregm@otc.otca.oz.au" -a -o xmon.shar -l 75 -x -c $(SHARFILES) X SHAR_EOF $TOUCH -am 0904101290 Imakefile && chmod 0664 Imakefile || echo "restore of Imakefile failed" set `wc -c Imakefile`;Wc_c=$1 if test "$Wc_c" != "705"; then echo original size 705, current size $Wc_c fi fi # ============= Makefile ============== if test X"$1" != X"-c" -a -f 'Makefile'; then echo "File already exists: skipping 'Makefile'" else echo "x - extracting Makefile (Text)" sed 's/^X//' << 'SHAR_EOF' > Makefile && X# Makefile generated by imake - do not edit! X# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $ X# X# The cpp used on this machine replaces all newlines and multiple tabs and X# spaces in a macro expansion with a single space. Imake tries to compensate X# for this, but is not always successful. X# X X########################################################################### X# Makefile generated from "Imake.tmpl" and X# $XConsortium: Imake.tmpl,v 1.77 89/12/18 17:01:37 jim Exp $ X# X# Platform-specific parameters may be set in the appropriate .cf X# configuration files. Site-wide parameters may be set in the file X# site.def. Full rebuilds are recommended if any parameters are changed. X# X# If your C preprocessor doesn't define any unique symbols, you'll need X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing X# "make Makefile", "make Makefiles", or "make World"). X# X# If you absolutely can't get imake to work, you'll need to set the X# variables at the top of each Makefile as well as the dependencies at the X# bottom (makedepend will do this automatically). X# X X########################################################################### X# platform-specific configuration parameters - edit sun.cf to change X X# platform: $XConsortium: sun.cf,v 1.38 89/12/23 16:10:10 jim Exp $ X# operating system: SunOS 4.0.1 X X########################################################################### X# site-specific configuration parameters - edit site.def to change X X# site: $XConsortium: site.def,v 1.21 89/12/06 11:46:50 jim Exp $ X X SHELL = /bin/sh X X TOP = . X CURRENT_DIR = . X X AR = ar cq X BOOTSTRAPCFLAGS = X CC = /bin/cc X X COMPRESS = compress X CPP = /lib/cpp $(STD_CPP_DEFINES) X PREPROCESSCMD = /bin/cc -E $(STD_CPP_DEFINES) X INSTALL = install X LD = ld X LINT = lint X LINTLIBFLAG = -C X LINTOPTS = -axz X LN = ln -s X MAKE = make X MV = mv X CP = cp X RANLIB = ranlib X RANLIBINSTFLAGS = X RM = rm -f X STD_INCLUDES = X STD_CPP_DEFINES = X STD_DEFINES = X EXTRA_LOAD_FLAGS = X EXTRA_LIBRARIES = X TAGS = ctags X X SHAREDCODEDEF = -DSHAREDCODE X SHLIBDEF = -DSUNSHLIB X X PROTO_DEFINES = X X INSTPGMFLAGS = X X INSTBINFLAGS = -m 0755 X INSTUIDFLAGS = -m 4755 X INSTLIBFLAGS = -m 0664 X INSTINCFLAGS = -m 0444 X INSTMANFLAGS = -m 0444 X INSTDATFLAGS = -m 0444 X INSTKMEMFLAGS = -m 4755 X X DESTDIR = X X TOP_INCLUDES = -I$(INCROOT) X X CDEBUGFLAGS = -O X CCOPTIONS = -f68881 -pipe X COMPATFLAGS = X X ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) X ALLDEFINES = $(ALLINCLUDES) $(STD_DEFINES) $(PROTO_DEFINES) $(DEFINES) $(COMPATFLAGS) X CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLDEFINES) X LINTFLAGS = $(LINTOPTS) -DLINT $(ALLDEFINES) X LDLIBS = $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X LDOPTIONS = $(CDEBUGFLAGS) $(CCOPTIONS) X LDCOMBINEFLAGS = -X -r X X MACROFILE = sun.cf X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut X X IMAKE_DEFINES = X X IRULESRC = $(CONFIGDIR) X IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(IRULESRC) $(IMAKE_DEFINES) X X ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \ X $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \ X $(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES) X X########################################################################### X# X Window System Build Parameters X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X########################################################################### X# X Window System make variables; this need to be coordinated with rules X# $XConsortium: Project.tmpl,v 1.63 89/12/18 16:46:44 jim Exp $ X X PATHSEP = / X USRLIBDIR = /usr/lib/X11/usr.lib X BINDIR = $(DESTDIR)/usr/bin/X11 X INCROOT = $(DESTDIR)/usr/include X BUILDINCROOT = $(TOP) X BUILDINCDIR = $(BUILDINCROOT)/X11 X BUILDINCTOP = .. X INCDIR = $(INCROOT)/X11 X ADMDIR = $(DESTDIR)/usr/adm X LIBDIR = /usr/lib/X11 X CONFIGDIR = $(LIBDIR)/config X LINTLIBDIR = $(USRLIBDIR)/lint X X FONTDIR = $(LIBDIR)/fonts X XINITDIR = $(LIBDIR)/xinit X XDMDIR = $(LIBDIR)/xdm X AWMDIR = $(LIBDIR)/awm X TWMDIR = $(LIBDIR)/twm X GWMDIR = $(LIBDIR)/gwm X MANPATH = $(DESTDIR)/usr/local/X11/man X MANSOURCEPATH = $(MANPATH)/man X MANDIR = $(MANSOURCEPATH)n X LIBMANDIR = $(MANSOURCEPATH)3 X XAPPLOADDIR = $(LIBDIR)/app-defaults X X SOXLIBREV = 4.2 X SOXTREV = 4.0 X SOXAWREV = 4.0 X SOOLDXREV = 4.0 X SOXMUREV = 4.0 X SOXEXTREV = 4.0 X X FONTCFLAGS = -t X X INSTAPPFLAGS = $(INSTDATFLAGS) X X IMAKE = imake X DEPEND = makedepend X RGB = rgb X FONTC = bdftosnf X MKFONTDIR = mkfontdir X MKDIRHIER = /bin/sh $(BINDIR)/mkdirhier.sh X X CONFIGSRC = $(TOP)/config X CLIENTSRC = $(TOP)/clients X DEMOSRC = $(TOP)/demos X LIBSRC = $(TOP)/lib X FONTSRC = $(TOP)/fonts X INCLUDESRC = $(TOP)/X11 X SERVERSRC = $(TOP)/server X UTILSRC = $(TOP)/util X SCRIPTSRC = $(UTILSRC)/scripts X EXAMPLESRC = $(TOP)/examples X CONTRIBSRC = $(TOP)/../contrib X DOCSRC = $(TOP)/doc X RGBSRC = $(TOP)/rgb X DEPENDSRC = $(UTILSRC)/makedepend X IMAKESRC = $(CONFIGSRC) X XAUTHSRC = $(LIBSRC)/Xau X XLIBSRC = $(LIBSRC)/X X XMUSRC = $(LIBSRC)/Xmu X TOOLKITSRC = $(LIBSRC)/Xt X AWIDGETSRC = $(LIBSRC)/Xaw X OLDXLIBSRC = $(LIBSRC)/oldX X XDMCPLIBSRC = $(LIBSRC)/Xdmcp X BDFTOSNFSRC = $(FONTSRC)/bdftosnf X MKFONTDIRSRC = $(FONTSRC)/mkfontdir X EXTENSIONSRC = $(TOP)/extensions X X DEPEXTENSIONLIB = $(USRLIBDIR)/libXext.a X EXTENSIONLIB = -lXext X X DEPXLIB = $(DEPEXTENSIONLIB) X XLIB = $(EXTENSIONLIB) -lX11 X X DEPXAUTHLIB = $(USRLIBDIR)/libXau.a X XAUTHLIB = -lXau X X DEPXMULIB = X XMULIB = -lXmu X X DEPOLDXLIB = X OLDXLIB = -loldX X X DEPXTOOLLIB = X XTOOLLIB = -lXt X X DEPXAWLIB = X XAWLIB = -lXaw X X LINTEXTENSIONLIB = $(USRLIBDIR)/llib-lXext.ln X LINTXLIB = $(USRLIBDIR)/llib-lX11.ln X LINTXMU = $(USRLIBDIR)/llib-lXmu.ln X LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln X LINTXAW = $(USRLIBDIR)/llib-lXaw.ln X X DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB) X X DEPLIBS1 = $(DEPLIBS) X DEPLIBS2 = $(DEPLIBS) X DEPLIBS3 = $(DEPLIBS) X X########################################################################### X# Imake rules for building libraries, programs, scripts, and data files X# rules: $XConsortium: Imake.rules,v 1.67 89/12/18 17:14:15 jim Exp $ X X########################################################################### X# start of Imakefile X XLOCAL_LIBRARIES = -Bstatic -lXaw -lXmu -lXt -lXext -lX11 XCDEBUGFLAGS = -g X XSRCS1 = decode11.c linkl.c print11.c server.c fd.c main.c prtype.c table11.c XOBJS1 = decode11.o linkl.o print11.o server.o fd.o main.o prtype.o table11.o X XSRCS2 = widgeti.c xmonui.c XOBJS2 = widgeti.o xmonui.o X XINCLUDE_FILES = common.h events.h linkl.h requests.h select_args.h \ X widgeti.h x11.h xmond.h xmonui.h patchlevel.h X XPROGRAMS = xmond xmonui X X OBJS = $(OBJS1) $(OBJS2) $(OBJS3) X SRCS = $(SRCS1) $(SRCS2) $(SRCS3) X Xall:: $(PROGRAMS) X Xxmond: $(OBJS1) $(DEPLIBS1) X $(RM) $@ X $(CC) -o $@ $(LDOPTIONS) $(OBJS1) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X Xinstall:: xmond X $(INSTALL) -c $(INSTPGMFLAGS) xmond $(BINDIR) X Xinstall.man:: xmond.man X $(INSTALL) -c $(INSTMANFLAGS) xmond.man $(MANDIR)/xmond.n X Xsaber_xmond: X #load $(ALLDEFINES) $(SRCS1) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xosaber_xmond: X #load $(ALLDEFINES) $(OBJS1) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xdepend:: X $(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS) X Xlint: X $(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS) Xlint1: X $(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS) X Xclean:: X $(RM) $(PROGRAMS) X Xxmonui: $(OBJS2) $(DEPLIBS2) X $(RM) $@ X $(CC) -o $@ $(LDOPTIONS) $(OBJS2) $(LOCAL_LIBRARIES) $(LDLIBS) $(EXTRA_LOAD_FLAGS) X Xsaber_xmonui: X #load $(ALLDEFINES) $(SRCS2) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xosaber_xmonui: X #load $(ALLDEFINES) $(OBJS2) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) $(EXTRA_LIBRARIES) X Xinstall:: xmonui X $(INSTALL) -c $(INSTPGMFLAGS) xmonui $(BINDIR) X Xinstall.man:: xmonui.man X $(INSTALL) -c $(INSTMANFLAGS) xmonui.man $(MANDIR)/xmonui.n X XSHARFILES = README xmon.man Imakefile Makefile $(SRCS1) $(SRCS2) $(INCLUDE_FILES) X Xshar: X shar -n xmon -s "gregm@otc.otca.oz.au" -a -o xmon.shar -l 75 -x -c $(SHARFILES) X X########################################################################### X# common rules for all Makefiles - do not edit X Xemptyrule:: X Xclean:: X $(RM_CMD) \#* X XMakefile:: X -@if [ -f Makefile ]; then \ X echo " $(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \ X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \ X else exit 0; fi X $(IMAKE_CMD) -DTOPDIR=$(TOP) -DCURDIR=$(CURRENT_DIR) X Xtags:: X $(TAGS) -w *.[ch] X $(TAGS) -xw *.[ch] > TAGS X Xsaber: X #load $(ALLDEFINES) $(SRCS) X Xosaber: X #load $(ALLDEFINES) $(OBJS) X X########################################################################### X# empty rules for directories that do not have SUBDIRS - do not edit X Xinstall:: X @echo "install in $(CURRENT_DIR) done" X Xinstall.man:: X @echo "install.man in $(CURRENT_DIR) done" X XMakefiles:: X Xincludes:: X X########################################################################### X# dependencies generated by makedepend X SHAR_EOF $TOUCH -am 0904101290 Makefile && chmod 0664 Makefile || echo "restore of Makefile failed" set `wc -c Makefile`;Wc_c=$1 if test "$Wc_c" != "9934"; then echo original size 9934, current size $Wc_c fi fi # ============= decode11.c ============== if test X"$1" != X"-c" -a -f 'decode11.c'; then echo "File already exists: skipping 'decode11.c'" else echo "x - extracting decode11.c (Text)" sed 's/^X//' << 'SHAR_EOF' > decode11.c && X/* X * Project: XMON - An X protocol monitor X * X * File: decode11.c X * X * Description: Decoding and switching routines for the X11 protocol X * X * There are 4 types of things in X11: requests, replies, errors, and X * events. X * X * Each of them has a format defined by a small integer that defines the X * type of the thing. X * X * Requests have an opcode in the first byte. X * X * Events have a code in the first byte. X * X * Errors have a code in the second byte (the first byte is 0) X * X * Replies have a sequence number in bytes 2 and 3. The sequence number X * should be used to identify the request that was sent, and from that X * request we can determine the type of the reply. X * X */ X X#include "common.h" X X#include "xmond.h" X#include "linkl.h" X#include "x11.h" X X#define MAX_REQUEST 127 X#define MAX_EXT_REQUEST 255 X#define MAX_EVENT 34 X#define MAX_ERROR 17 X X/* X * We need to keep the sequence number for a request to match it with an X * expected reply. The sequence number is associated only with the X * particular connection that we have. We would expect these replies to be X * handled as a FIFO queue. X*/ X Xtypedef struct X{ X long SequenceNumber; X short Request; X} X QueueEntry; X X/* function prototypes: */ X/* decode11.c: */ Xstatic void SequencedReplyExpected P((Client *client , short RequestType )); Xstatic short CheckReplyTable P((Server *server , short SequenceNumber , Bool checkZero )); Xstatic void ReplyExpected P((Client *client , short Request )); X X/* end function prototypes */ X Xextern Bool ignore_bytes; X Xextern int RequestVerbose; Xextern int EventVerbose; Xextern int ReplyVerbose; Xextern int ErrorVerbose; Xextern int CurrentVerbose; X Xextern Bool VerboseRequest[]; Xextern Bool VerboseEvent[]; Xextern Bool BlockRequest[]; Xextern Bool BlockEvent[]; Xextern Bool MonitoringRequests; Xextern Bool MonitoringEvents; Xextern Bool BlockingRequests; Xextern Bool BlockingEvents; Xextern int SelectedRequestVerbose; Xextern int SelectedEventVerbose; X Xstatic int Lastfd; Xstatic long LastSequenceNumber; Xstatic short LastReplyType; Xstatic int RequestCount[MAX_EXT_REQUEST + 1]; Xstatic int EventCount[MAX_EVENT + 1]; Xstatic int ErrorCount[MAX_ERROR + 1]; Xstatic Bool CountRequests; Xstatic Bool CountEvents; Xstatic Bool CountErrors; X X XGlobal void XInitRequestCount() X{ X ClearRequestCount(); X CountRequests = True; X} X XGlobal void XClearRequestCount() X{ X int i; X X for (i = 0; i <= MAX_EXT_REQUEST; i++) X RequestCount[i] = 0; X} X XGlobal void XStartRequestCount() X{ X CountRequests = True; X} X XGlobal void XEndRequestCount() X{ X CountRequests = False; X} X XGlobal void XPrintRequestCounts() X{ X int i; X Bool found; X X found = False; X for (i = MAX_REQUEST + 1; i <= MAX_EXT_REQUEST; i++) X if (RequestCount[i] != 0) X { X if (!found) X fprintf(stdout, "extended requests received:\n"); X found = True; X fprintf(stdout, "%3d %d\n", i, RequestCount[i]); X } X if (found) X fprintf(stdout, "\n"); X found = False; X for (i = 1; i <= MAX_REQUEST; i++) X if ((i <= 119 || i == 127) && RequestCount[i] != 0) X { X if (!found) X fprintf(stdout, "requests received:\ncode count name \n"); X found = True; X fprintf(stdout, "%3d %3d ", i, RequestCount[i]); X PrintENUMERATED(&i, sizeof(i), TD[REQUEST].ValueList); X fprintf(stdout, "\n"); X } X if (!found) X fprintf(stdout, "no requests received\n"); X} X XGlobal void XPrintZeroRequestCounts() X{ X int i; X X fprintf(stdout, "requests never received:\ncode name\n"); X for (i = 1; i <= MAX_REQUEST; i++) X if ((i <= 119 || i == 127) && RequestCount[i] == 0) X { X fprintf(stdout, "%3d ", i); X PrintENUMERATED(&i, sizeof(i), TD[REQUEST].ValueList); X fprintf(stdout, "\n"); X } X} X XGlobal void XInitEventCount() X{ X ClearEventCount(); X CountEvents = True; X} X XGlobal void XClearEventCount() X{ X int i; X X for (i = 0; i <= MAX_EVENT; i++) X EventCount[i] = 0; X} X XGlobal void XStartEventCount() X{ X CountEvents = True; X} X XGlobal void XEndEventCount() X{ X CountEvents = False; X} X XGlobal void XPrintEventCounts() X{ X int i; X Bool found; X X found = False; X for (i = 2; i <= MAX_EVENT; i++) X if (EventCount[i] != 0) X { X if (!found) X fprintf(stdout, "events received:\ncode count name:\n"); X found = True; X fprintf(stdout, "%3d %3d ", i, EventCount[i]); X PrintENUMERATED(&i, sizeof(i), TD[EVENT].ValueList); X fprintf(stdout, "\n"); X } X if (!found) X fprintf(stdout, "no events received\n"); X} X XGlobal void XPrintZeroEventCounts() X{ X int i; X X fprintf(stdout, "events never received:\ncode name\n"); X for (i = 2; i <= MAX_EVENT; i++) X if (EventCount[i] == 0) X { X fprintf(stdout, "%3d ", i); X PrintENUMERATED(&i, sizeof(i), TD[EVENT].ValueList); X fprintf(stdout, "\n"); X } X} X XGlobal void XInitErrorCount() X{ X ClearErrorCount(); X CountErrors = True; X} X XGlobal void XClearErrorCount() X{ X int i; X X for (i = 0; i <= MAX_ERROR; i++) X ErrorCount[i] = 0; X} X XGlobal void XStartErrorCount() X{ X CountErrors = True; X} X XGlobal void XEndErrorCount() X{ X CountErrors = False; X} X XGlobal void XPrintErrorCounts() X{ X int i; X Bool found; X X found = False; X for (i = 1; i <= MAX_ERROR; i++) X if (ErrorCount[i] != 0) X { X if (!found) X fprintf(stdout, "errors received:\ncode count name \n"); X found = True; X fprintf(stdout, "%3d %3d ", i, ErrorCount[i]); X PrintENUMERATED(&i, sizeof(i), TD[ERROR].ValueList); X fprintf(stdout, "\n"); X } X if (!found) X fprintf(stdout, "no errors received\n"); X} X XGlobal void XPrintZeroErrorCounts() X{ X int i; X X fprintf(stdout, "errors never received:\ncode name\n"); X for (i = 1; i <= MAX_ERROR; i++) X if (ErrorCount[i] == 0) X { X fprintf(stdout, "%3d ", i); X PrintENUMERATED(&i, sizeof(i), TD[ERROR].ValueList); X fprintf(stdout, "\n"); X } X} X XGlobal void XDecodeRequest(client, buf, n) X Client *client; X unsigned char *buf; X long n; X{ X int fd = client->fdd->fd; X short Request = IByte (&buf[0]); X X client->SequenceNumber += 1; X bcopy ((char *)&(client->SequenceNumber), (char *)SBf, sizeof(long)); X SetIndentLevel(PRINTCLIENT); X X if X ( X BlockingRequests X && X 1 <= Request && Request <= 127 X && X BlockRequest[Request] X ) X ignore_bytes = True; X X if X ( X MonitoringRequests X && X 1 <= Request && Request <= 127 X && X VerboseRequest[Request] X ) X CurrentVerbose = SelectedRequestVerbose; X else X CurrentVerbose = RequestVerbose; X X if (CurrentVerbose > 3) X DumpItem("Request", fd, buf, n); X if (CountRequests) X { X if (Request < 0 || Request > MAX_EXT_REQUEST) X fprintf(stdout, "####### Illegal request opcode %d\n", Request); X else X RequestCount[Request]++; X } X if (Request <= 0 || 127 < Request) X fprintf X ( X stdout, "Extended request opcode: %d, SequenceNumber: %d\n", X Request, client->SequenceNumber X ); X else X switch (Request) X { X case 1: X CreateWindow(buf); X break; X case 2: X ChangeWindowAttributes(buf); X break; X case 3: X GetWindowAttributes(buf); X ReplyExpected(client, Request); X break; X case 4: X DestroyWindow(buf); X break; X case 5: X DestroySubwindows(buf); X break; X case 6: X ChangeSaveSet(buf); X break; X case 7: X ReparentWindow(buf); X break; X case 8: X MapWindow(buf); X break; X case 9: X MapSubwindows(buf); X break; X case 10: X UnmapWindow(buf); X break; X case 11: X UnmapSubwindows(buf); X break; X case 12: X ConfigureWindow(buf); X break; X case 13: X CirculateWindow(buf); X break; X case 14: X GetGeometry(buf); X ReplyExpected(client, Request); X break; X case 15: X QueryTree(buf); X ReplyExpected(client, Request); X break; X case 16: X InternAtom(buf); X ReplyExpected(client, Request); X break; X case 17: X GetAtomName(buf); X ReplyExpected(client, Request); X break; X case 18: X ChangeProperty(buf); X break; X case 19: X DeleteProperty(buf); X break; X case 20: X GetProperty(buf); X ReplyExpected(client, Request); X break; X case 21: X ListProperties(buf); X ReplyExpected(client, Request); X break; X case 22: X SetSelectionOwner(buf); X break; X case 23: X GetSelectionOwner(buf); X ReplyExpected(client, Request); X break; X case 24: X ConvertSelection(buf); X break; X case 25: X SendEvent(buf); X break; X case 26: X GrabPointer(buf); X ReplyExpected(client, Request); X break; X case 27: X UngrabPointer(buf); X break; X case 28: X GrabButton(buf); X break; X case 29: X UngrabButton(buf); X break; X case 30: X ChangeActivePointerGrab(buf); X break; X case 31: X GrabKeyboard(buf); X ReplyExpected(client, Request); X break; X case 32: X UngrabKeyboard(buf); X break; X case 33: X GrabKey(buf); X break; X case 34: X UngrabKey(buf); X break; X case 35: X AllowEvents(buf); X break; X case 36: X GrabServer(buf); X break; X case 37: X UngrabServer(buf); X break; X case 38: X QueryPointer(buf); X ReplyExpected(client, Request); X break; X case 39: X GetMotionEvents(buf); X ReplyExpected(client, Request); X break; X case 40: X TranslateCoordinates(buf); X ReplyExpected(client, Request); X break; X case 41: X WarpPointer(buf); X break; X case 42: X SetInputFocus(buf); X break; X case 43: X GetInputFocus(buf); X ReplyExpected(client, Request); X break; X case 44: X QueryKeymap(buf); X ReplyExpected(client, Request); X break; X case 45: X OpenFont(buf); X break; X case 46: X CloseFont(buf); X break; X case 47: X QueryFont(buf); X ReplyExpected(client, Request); X break; X case 48: X QueryTextExtents(buf); X ReplyExpected(client, Request); X break; X case 49: X ListFonts(buf); X ReplyExpected(client, Request); X break; X case 50: X ListFontsWithInfo(buf); X ReplyExpected(client, Request); X break; X case 51: X SetFontPath(buf); X break; X case 52: X GetFontPath(buf); X ReplyExpected(client, Request); X break; X case 53: X CreatePixmap(buf); X break; X case 54: X FreePixmap(buf); X break; X case 55: X CreateGC(buf); X break; X case 56: X ChangeGC(buf); X break; X case 57: X CopyGC(buf); X break; X case 58: X SetDashes(buf); X break; X case 59: X SetClipRectangles(buf); X break; X case 60: X FreeGC(buf); X break; X case 61: X ClearArea(buf); X break; X case 62: X CopyArea(buf); X break; X case 63: X CopyPlane(buf); X break; X case 64: X PolyPoint(buf); X break; X case 65: X PolyLine(buf); X break; X case 66: X PolySegment(buf); X break; X case 67: X PolyRectangle(buf); X break; X case 68: X PolyArc(buf); X break; X case 69: X FillPoly(buf); X break; X case 70: X PolyFillRectangle(buf); X break; X case 71: X PolyFillArc(buf); X break; X case 72: X PutImage(buf); X break; X case 73: X GetImage(buf); X ReplyExpected(client, Request); X break; X case 74: X PolyText8(buf); X break; X case 75: X PolyText16(buf); X break; X case 76: X ImageText8(buf); X break; X case 77: X ImageText16(buf); X break; X case 78: X CreateColormap(buf); X break; X case 79: X FreeColormap(buf); X break; X case 80: X CopyColormapAndFree(buf); X break; X case 81: X InstallColormap(buf); X break; X case 82: X UninstallColormap(buf); X break; X case 83: X ListInstalledColormaps(buf); X ReplyExpected(client, Request); X break; X case 84: X AllocColor(buf); X ReplyExpected(client, Request); X break; X case 85: X AllocNamedColor(buf); X ReplyExpected(client, Request); X break; X case 86: X AllocColorCells(buf); X ReplyExpected(client, Request); X break; X case 87: X AllocColorPlanes(buf); X ReplyExpected(client, Request); X break; X case 88: X FreeColors(buf); X break; X case 89: X StoreColors(buf); X break; X case 90: X StoreNamedColor(buf); X break; X case 91: X QueryColors(buf); X ReplyExpected(client, Request); X break; X case 92: X LookupColor(buf); X ReplyExpected(client, Request); X break; X case 93: X CreateCursor(buf); X break; X case 94: X CreateGlyphCursor(buf); X break; X case 95: X FreeCursor(buf); X break; X case 96: X RecolorCursor(buf); X break; X case 97: X QueryBestSize(buf); X ReplyExpected(client, Request); X break; X case 98: X QueryExtension(buf); X ReplyExpected(client, Request); X break; X case 99: X ListExtensions(buf); X ReplyExpected(client, Request); X break; X case 100: X ChangeKeyboardMapping(buf); X break; X case 101: X GetKeyboardMapping(buf); X ReplyExpected(client, Request); X break; X case 102: X ChangeKeyboardControl(buf); X break; X case 103: X GetKeyboardControl(buf); X ReplyExpected(client, Request); X break; X case 104: X Bell(buf); X break; X case 105: X ChangePointerControl(buf); X break; X case 106: X GetPointerControl(buf); X ReplyExpected(client, Request); X break; X case 107: X SetScreenSaver(buf); X break; X case 108: X GetScreenSaver(buf); X ReplyExpected(client, Request); X break; X case 109: X ChangeHosts(buf); X break; X case 110: X ListHosts(buf); X ReplyExpected(client, Request); X break; X case 111: X SetAccessControl(buf); X break; X case 112: X SetCloseDownMode(buf); X break; X case 113: X KillClient(buf); X break; X case 114: X RotateProperties(buf); X break; X case 115: X ForceScreenSaver(buf); X break; X case 116: X SetPointerMapping(buf); X ReplyExpected(client, Request); X break; X case 117: X GetPointerMapping(buf); X ReplyExpected(client, Request); X break; X case 118: X SetModifierMapping(buf); X ReplyExpected(client, Request); X break; X case 119: X GetModifierMapping(buf); X ReplyExpected(client, Request); X break; X case 127: X NoOperation(buf); X break; X default: X fprintf(stdout, "####### Illegal request opcode (%d)\n", Request); X break; X } X} X XGlobal void XDecodeReply(server, buf, n) X Server *server; X unsigned char *buf; X long n; X{ X int fd = server->fdd->fd; X short SequenceNumber = IShort (&buf[2]); X short Request; X X Request = CheckReplyTable(server, SequenceNumber, True); X if X ( X MonitoringRequests X && X 1 <= Request && Request <= 127 X && X VerboseRequest[Request] X ) X CurrentVerbose = SelectedRequestVerbose; X else X CurrentVerbose = ReplyVerbose; X if (Request == 0) X return; X if (CurrentVerbose <= 0) X return; X SetIndentLevel(PRINTSERVER); X RBf[0] = Request /* for the PrintField in the Reply procedure */ ; X if (CurrentVerbose > 3) X DumpItem("Reply", fd, buf, n); X if (Request <= 0 || 127 < Request) X fprintf(stdout, "####### Extended reply opcode %d\n", Request); X else X switch (Request) X { X case 3: X GetWindowAttributesReply(buf); X break; X case 14: X GetGeometryReply(buf); X break; X case 15: X QueryTreeReply(buf); X break; X case 16: X InternAtomReply(buf); X break; X case 17: X GetAtomNameReply(buf); X break; X case 20: X GetPropertyReply(buf); X break; X case 21: X ListPropertiesReply(buf); X break; X case 23: X GetSelectionOwnerReply(buf); X break; X case 26: X GrabPointerReply(buf); X break; X case 31: X GrabKeyboardReply(buf); X break; X case 38: X QueryPointerReply(buf); X break; X case 39: X GetMotionEventsReply(buf); X break; X case 40: X TranslateCoordinatesReply(buf); X break; X case 43: X GetInputFocusReply(buf); X break; X case 44: X QueryKeymapReply(buf); X break; X case 47: X QueryFontReply(buf); X break; X case 48: X QueryTextExtentsReply(buf); X break; X case 49: X ListFontsReply(buf); X break; X case 50: X ListFontsWithInfoReply(buf); X break; X case 52: X GetFontPathReply(buf); X break; X case 73: X GetImageReply(buf); X break; X case 83: X ListInstalledColormapsReply(buf); X break; X case 84: X AllocColorReply(buf); X break; X case 85: X AllocNamedColorReply(buf); X break; X case 86: X AllocColorCellsReply(buf); X break; X case 87: X AllocColorPlanesReply(buf); X break; X case 91: X QueryColorsReply(buf); X break; X case 92: X LookupColorReply(buf); X break; X case 97: X QueryBestSizeReply(buf); X break; X case 98: X QueryExtensionReply(buf); X break; X case 99: X ListExtensionsReply(buf); X break; X case 101: X GetKeyboardMappingReply(buf); X break; X case 103: X GetKeyboardControlReply(buf); X break; X case 106: X GetPointerControlReply(buf); X break; X case 108: X GetScreenSaverReply(buf); X break; X case 110: X ListHostsReply(buf); X break; X case 116: X SetPointerMappingReply(buf); X break; X case 117: X GetPointerMappingReply(buf); X break; X case 118: X SetModifierMappingReply(buf); X break; X case 119: X GetModifierMappingReply(buf); X break; X default: X fprintf(stdout, "####### Unimplemented reply opcode %d\n", Request); X break; X } X} X XGlobal void XDecodeError(server, buf, n) X Server *server; X unsigned char *buf; X long n; X{ X int fd = server->fdd->fd; X short Error = IByte (&buf[1]); X X (void)CheckReplyTable (server, (short)IShort(&buf[2]), False); X if (CountErrors) X { X if (Error < 0 || Error > MAX_ERROR) X fprintf(stdout, "####### Illegal error opcode %d\n", Error); X else X ErrorCount[Error]++; X } X CurrentVerbose = ErrorVerbose; X if (CurrentVerbose <= 0) X return; X SetIndentLevel(PRINTSERVER); X if (CurrentVerbose > 3) X DumpItem("Error", fd, buf, n); X if (Error < 1 || Error > 17) X fprintf(stdout, "####### Extended Error opcode %d\n", Error); X else X switch (Error) X { X case 1: X RequestError(buf); X break; X case 2: X ValueError(buf); X break; X case 3: X WindowError(buf); X break; X case 4: X PixmapError(buf); X break; X case 5: X AtomError(buf); X break; X case 6: X CursorError(buf); X break; X case 7: X FontError(buf); X break; X case 8: X MatchError(buf); X break; X case 9: X DrawableError(buf); X break; X case 10: X AccessError(buf); X break; X case 11: X AllocError(buf); X break; X case 12: X ColormapError(buf); X break; X case 13: X GContextError(buf); X break; X case 14: X IDChoiceError(buf); X break; X case 15: X NameError(buf); X break; X case 16: X LengthError(buf); X break; X case 17: X ImplementationError(buf); X break; X default: X fprintf(stdout, "####### Unimplemented Error opcode %d\n", Error); X break; X } X} X XGlobal void XDecodeEvent(server, buf, n) X Server *server; X unsigned char *buf; X long n; X{ X int fd = server->fdd->fd; X short Event = IByte (&buf[0]); X X if (CountEvents) X { X if (Event < 0 || Event >= MAX_EVENT) X fprintf(stdout, "####### Illegal event opcode %d\n", Event); X else X EventCount[Event]++; X } X X if X ( X BlockingEvents X && X 2 <= Event && Event <= 34 X && X BlockEvent[Event] X ) X ignore_bytes = True; X X if X ( X MonitoringEvents X && X 2 <= Event && Event <= 34 X && X VerboseEvent[Event] X ) X CurrentVerbose = SelectedEventVerbose; X else X CurrentVerbose = EventVerbose; X if (CurrentVerbose <= 0) X return; X SetIndentLevel(PRINTSERVER); X if (CurrentVerbose > 3) X DumpItem("Event", fd, buf, n); X if (Event < 2 || Event > 34) X fprintf(stdout, "####### Extended Event opcode %d\n", Event); X else X switch (Event) X { X case 2: X KeyPressEvent(buf); X break; X case 3: X KeyReleaseEvent(buf); X break; X case 4: X ButtonPressEvent(buf); X break; X case 5: X ButtonReleaseEvent(buf); X break; X case 6: X MotionNotifyEvent(buf); X break; X case 7: X EnterNotifyEvent(buf); X break; X case 8: X LeaveNotifyEvent(buf); X break; X case 9: X FocusInEvent(buf); X break; X case 10: X FocusOutEvent(buf); X break; X case 11: X KeymapNotifyEvent(buf); X break; X case 12: X ExposeEvent(buf); X break; X case 13: X GraphicsExposureEvent(buf); X break; X case 14: X NoExposureEvent(buf); X break; X case 15: X VisibilityNotifyEvent(buf); X break; X case 16: X CreateNotifyEvent(buf); X break; X case 17: X DestroyNotifyEvent(buf); X break; X case 18: X UnmapNotifyEvent(buf); X break; X case 19: X MapNotifyEvent(buf); X break; X case 20: X MapRequestEvent(buf); X break; X case 21: X ReparentNotifyEvent(buf); X break; X case 22: X ConfigureNotifyEvent(buf); X break; X case 23: X ConfigureRequestEvent(buf); X break; X case 24: X GravityNotifyEvent(buf); X break; X case 25: X ResizeRequestEvent(buf); X break; X case 26: X CirculateNotifyEvent(buf); X break; X case 27: X CirculateRequestEvent(buf); X break; X case 28: X PropertyNotifyEvent(buf); X break; X case 29: X SelectionClearEvent(buf); X break; X case 30: X SelectionRequestEvent(buf); X break; X case 31: X SelectionNotifyEvent(buf); X break; X case 32: X ColormapNotifyEvent(buf); X break; X case 33: X ClientMessageEvent(buf); X break; X case 34: X MappingNotifyEvent(buf); X break; X default: X fprintf(stdout, "####### Unimplemented Event opcode %d\n", Event); X break; X } X} X X#ifdef NOT_YET X/* X * KeepLastReplyExpected: X * X * another reply is expected for the same reply as we just had. This is X * only used with ListFontsWithInfo X */ XGlobal void XKeepLastReplyExpected() X{ X SequencedReplyExpected(Lastfd, LastSequenceNumber, LastReplyType); X} X#endif X X/* X * SequencedReplyExpected: X * X * A reply is expected to the type of request given for the fd associated X * with this one X */ Xstatic void XSequencedReplyExpected(client, RequestType) X Client *client; X short RequestType; X{ X Server *server; X long SequenceNumber = client->SequenceNumber; X QueueEntry *p; X X /* create a new queue entry */ X p = Tmalloc(QueueEntry); X p->SequenceNumber = SequenceNumber; X p->Request = RequestType; X X server = (Server *)(TopOfList(&client->server_list)); X appendToList(&server->reply_list, (Pointer)p); X} X X/* X * CheckReplyTable: X * X * search for the type of request that is associated with a reply to the X * given sequence number for this fd X */ X Xstatic short XCheckReplyTable (server, SequenceNumber, checkZero) X Server *server; X short SequenceNumber; X Bool checkZero; X{ X int fd = server->fdd->fd; X QueueEntry *p; X X ForAllInList(&server->reply_list) X { X p = (QueueEntry *)CurrentContentsOfList(&server->reply_list); X if (SequenceNumber == ((short)(0xFFFF & p->SequenceNumber))) X { X /* save the Request type */ X Lastfd = fd; X LastSequenceNumber = p->SequenceNumber; X LastReplyType = p->Request; X /* pull the queue entry out of the queue for this fd */ X freeCurrent(&server->reply_list); X return(LastReplyType); X } X } X X /* not expecting a reply for that sequence number */ X if (checkZero) X { X fprintf(stdout, "Unexpected reply, SequenceNumber: %d", SequenceNumber); X if (ListIsEmpty(&server->reply_list)) X fprintf(stdout, "No expected replies\n"); X else X { X fprintf(stdout, "Expected replies are:\n"); X ForAllInList(&server->reply_list) X { X p = (QueueEntry *)CurrentContentsOfList(&server->reply_list); X fprintf X ( X stdout, "Reply on fd %d for sequence %d is type %d\n", X fd, p->SequenceNumber, p->Request X ); X } X fprintf(stdout, "End of expected replies\n"); X } X } X return(0); X} X X X/* X * ReplyExpected: X * X * A reply is expected to the type of request given for the sequence X * number associated with this fd X */ Xstatic void XReplyExpected(client, Request) X Client *client; X short Request; X{ X SequencedReplyExpected(client, Request); X} SHAR_EOF $TOUCH -am 0903162990 decode11.c && chmod 0664 decode11.c || echo "restore of decode11.c failed" set `wc -c decode11.c`;Wc_c=$1 if test "$Wc_c" != "22888"; then echo original size 22888, current size $Wc_c fi fi # ============= linkl.c ============== if test X"$1" != X"-c" -a -f 'linkl.c'; then echo "File already exists: skipping 'linkl.c'" else echo "x - extracting linkl.c (Text)" sed 's/^X//' << 'SHAR_EOF' > linkl.c && X/* X * File: linkl.c X * X * Description: Functions implementing general linked lists X */ X X#include "common.h" X#include "linkl.h" X X/* function prototypes: */ X/* linkl.c: */ Xstatic void linkl_panic P((char *s )); X X/* end function prototypes */ X XGlobal void XinitList(list) X LinkList *list; X{ X list->top = list->bottom = list->current = (LinkLeaf *)list; X} X XGlobal void XprependToList(list, contents) X LinkList *list; X Pointer contents; X{ X LinkLeaf *leaf; X X if ((leaf = Tmalloc(LinkLeaf)) == NULL) X linkl_panic("prependList: malloc failed\n"); X else X { X leaf->prev = (LinkLeaf *)list; X leaf->next = list->top; X list->top = list->top->prev = leaf; X leaf->contents = contents; X } X} X XGlobal void XappendToList(list, contents) X LinkList *list; X Pointer contents; X{ X LinkLeaf *leaf; X X if ((leaf = Tmalloc(LinkLeaf)) == NULL) X linkl_panic("appendToList: malloc failed\n"); X else X { X leaf->next = (LinkLeaf *)list; X leaf->prev = list->bottom; X list->bottom = list->bottom->next = leaf; X leaf->contents = contents; X } X} X XGlobal Pointer XdeleteFirst(list) X LinkList *list; X{ X LinkLeaf *leaf = list->top; X Pointer contents; X X if (leaf == (LinkLeaf *)list) X return ((Pointer)NULL); X list->top = leaf->next; X leaf->next->prev = (LinkLeaf *)list; X if (list->current == leaf) X list->current = leaf->next; X contents = leaf->contents; X Tfree(leaf); X return (contents); X} X XGlobal Pointer XdeleteLast(list) X LinkList *list; X{ X LinkLeaf *leaf = list->bottom; X Pointer contents; X X if (leaf == (LinkLeaf *)list) X return ((Pointer)NULL); X list->bottom = leaf->prev; X leaf->prev->next = (LinkLeaf *)list; X if (list->current == leaf) X list->current = leaf->prev; X contents = leaf->contents; X Tfree(leaf); X return(contents); X} X XGlobal Pointer XdeleteCurrent(list) X LinkList *list; X{ X LinkLeaf *leaf = list->current; X Pointer contents; X X if (leaf == (LinkLeaf *)list) X return ((Pointer)NULL); X list->current = leaf->prev->next = leaf->next; X leaf->next->prev = leaf->prev; X contents = leaf->contents; X Tfree(leaf); X return(contents); X} X XGlobal void XAppendToCurrent(list, contents) X LinkList *list; X Pointer contents; X{ X LinkLeaf *leaf; X X if ((leaf = Tmalloc(LinkLeaf)) == NULL) X linkl_panic("AppendToCurrent: malloc failed\n"); X else X { X leaf->prev = list->current; X leaf->next = list->current->next; X leaf->contents = contents; X list->current->next = list->current->next->prev = leaf; X } X} X XGlobal void XPrependToCurrent(list, contents) X LinkList *list; X Pointer contents; X{ X LinkLeaf *leaf; X X if ((leaf = Tmalloc(LinkLeaf)) == NULL) X linkl_panic("PrependToCurrent: malloc failed\n"); X else X { X leaf->next = list->current; X leaf->prev = list->current->prev; X leaf->contents = contents; X list->current->prev = list->current->prev->next = leaf; X } X} X XGlobal void XfreeList(list) X LinkList *list; X{ X while (!ListIsEmpty(list)) X Tfree(deleteFirst(list)); X} X XGlobal void XfreeCurrent(list) X LinkList *list; X{ X Tfree(deleteCurrent(list)); X} X Xstatic void Xlinkl_panic(s) X char *s; X{ X fprintf(stderr, "%s\n", s); X exit(1); X} SHAR_EOF $TOUCH -am 0903162990 linkl.c && chmod 0754 linkl.c || echo "restore of linkl.c failed" set `wc -c linkl.c`;Wc_c=$1 if test "$Wc_c" != "3043"; then echo original size 3043, current size $Wc_c fi fi echo "End of part 1, continue with part 2" exit 0 Greg McFarlane |||| OTC || ACSnet: gregm@otc.otca.oz.au UUCP: {uunet,mcvax}!otc.otca.oz.au!gregm Snail: GPO Box 7000, Sydney 2001, Australia Phone: +61 2 287 4104 Fax: +61 2 287 4990 dan ---------------------------------------------------- O'Reilly && Associates argv@sun.com / argv@ora.com Opinions expressed reflect those of the author only.