v06i027: xplaces, Part01/01

Dan Heller argv%turnpike at Sun.COM
Sun Mar 11 07:54:56 AEST 1990


Submitted-by: Mark Moraes <moraes at cs.toronto.edu>
Posting-number: Volume 6, Issue 27
Archive-name: xplaces/part01

xplaces uses the WM_COMMAND property to print the command strings for
commands on an X display.  It assumes Xt options, -geometry and -xrm.

This is at patchlevel 3 already.  It's been seen to work with R4 with
twm, I'm told it also works with mwm and olwm.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, use "sh file -c".
# If this archive is complete, you will see the following message at the end:
#		"End of shell archive."
#
# Contents:
#   xplaces xplaces/CHANGES.Pat03 xplaces/Imakefile
#   xplaces/Makefile xplaces/Makefile.bak xplaces/README
#   xplaces/patchlevel.h xplaces/rcmd xplaces/rcmd.man
#   xplaces/xplaces.c xplaces/xplaces.man
#
# Wrapped by moraes at cs.utoronto.ca on Sat Mar 10 16:38:04 1990
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d xplaces ; then
    echo shar: Creating directory \"xplaces\"
    mkdir xplaces
fi
if test -f xplaces/CHANGES.Pat03 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/CHANGES.Pat03\"
else
echo shar: Extracting \"xplaces/CHANGES.Pat03\" \(503 characters\)
sed "s/^X//" >xplaces/CHANGES.Pat03 <<'END_OF_xplaces/CHANGES.Pat03'
X- Uses XGetWMSizeHints instead of XGetNormalHints so that it can
Xuse PBaseSize in compliance with ICCCM.  Now gets R4 xterm size
Xright (used to be off by 1)  Thanks to Casey Leedom <casey at gauss.llnl.gov>
Xfor this one.
X
X- xplaces doesn't whine about toplevel windows without WM_COMMAND now.
X
X- rcmd much improved -- runs much faster on machines without builtin
Xtest in the shell, can take multiple commands for a single machine
Xfrom stdin (rsh is too slow for csh users to afford one per remote
Xcommand)
END_OF_xplaces/CHANGES.Pat03
if test 503 -ne `wc -c <xplaces/CHANGES.Pat03`; then
    echo shar: \"xplaces/CHANGES.Pat03\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/Imakefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/Imakefile\"
else
echo shar: Extracting \"xplaces/Imakefile\" \(247 characters\)
sed "s/^X//" >xplaces/Imakefile <<'END_OF_xplaces/Imakefile'
XLOCAL_LIBRARIES = $(XLIB)
X
X/* For R4, define ICCCM_XLIB */
X
X#ifdef CSRIToronto
XDEFINES = -DCSRI
X#endif
X
XSimpleProgramTarget(xplaces)
X
Xinstall::
X	$(INSTALL) rcmd $(BINDIR)
X
XInstallManPage(rcmd, $(MANDIR))
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) -lX11
END_OF_xplaces/Imakefile
if test 247 -ne `wc -c <xplaces/Imakefile`; then
    echo shar: \"xplaces/Imakefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/Makefile\"
else
echo shar: Extracting \"xplaces/Makefile\" \(7349 characters\)
sed "s/^X//" >xplaces/Makefile <<'END_OF_xplaces/Makefile'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08: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# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
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.macros to change
X
X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system:  SunOS 4.0
X
XBOOTSTRAPCFLAGS =
X             AS = as
X             CC = cc
X            CPP = /lib/cpp
X             LD = ld
X           LINT = lint
X        INSTALL = install
X           TAGS = ctags
X             RM = rm -f
X             MV = mv
X             LN = ln -s
X         RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -axz
X    LINTLIBFLAG = -C
X           MAKE = make
XSTD_CPP_DEFINES =
X    STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X XWSRC = $(CONTRIBSRC)/widgets/Xhp/Xw
X
X XWLIB = $(USRLIBDIR)/libXw.a
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL = /bin/sh
X
X        DESTDIR =
X      USRLIBDIR = /local/lib/X11
X         BINDIR = /local/bin/X11
X         INCDIR = $(LIBDIR)/include
X        INCROOT = $(DESTDIR)/usr/include
X         ADMDIR = /var/scr/Xerrors
X         LIBDIR = /local/share/X11
X     LINTLIBDIR = $(LIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X        MANPATH = /local/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)x
X      LIBMANDIR = $(MANSOURCEPATH)3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -g kmem -m 2755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(DEPENDSRC)/makedepend
X          IMAKE = $(BINDIR)/imake
X            RGB = $(RGBSRC)/rgb
X             FC = $(BDFTOSNFSRC)/bdftosnf
X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X            TOP = ../../../../../src/X.V11R3
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     SCRIPTSSRC = $(UTILSRC)/scripts
X     EXAMPLESRC = $(TOP)/examples
X     CONTRIBSRC = $(TOP)/contrib
X         DOCSRC = $(TOP)/doc
X         RGBSRC = $(TOP)/rgb
X      DEPENDSRC = $(UTILSRC)/makedepend
X       IMAKESRC = $(UTILSRC)/imake
X       IRULESRC = $(UTILSRC)/imake.includes
X        XLIBSRC = $(LIBSRC)/X
X         XMUSRC = $(LIBSRC)/Xmu
X     TOOLKITSRC = $(LIBSRC)/Xt
X     AWIDGETSRC = $(LIBSRC)/Xaw
X     OLDXLIBSRC = $(LIBSRC)/oldX
X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X   EXTENSIONSRC = $(TOP)/extensions
X
X   EXTENSIONLIB = $(USRLIBDIR)/lib/libXext.a
X
X           XLIB = -L$(USRLIBDIR) -lX11
X
X         XMULIB = $(USRLIBDIR)/libXmu.a
X        OLDXLIB = $(USRLIBDIR)/liboldX.a
X       XTOOLLIB = $(USRLIBDIR)/libXt.a
X         XAWLIB = $(USRLIBDIR)/libXaw.a
X       INCLUDES = -I$(INCDIR) -I$(INCROOT)
X
X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
X      MACROFILE = Sun.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XLOCAL_LIBRARIES = $(XLIB)
X
XDEFINES = -DCSRI
X
X OBJS = xplaces.o
X SRCS = xplaces.c
X
X PROGRAM = xplaces
X
Xall:: xplaces
X
Xxplaces: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xplaces
X	$(INSTALL) -c $(INSTALLFLAGS) xplaces $(BINDIR)
X
Xinstall.man:: xplaces.man
X	$(INSTALL) -c $(INSTMANFLAGS) xplaces.man $(MANDIR)/xplaces.x
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND)::
Xclean::
X	$(RM) $(PROGRAM)
X
Xinstall::
X	$(INSTALL) rcmd $(BINDIR)
X
Xinstall.man:: rcmd.man
X	$(INSTALL) -c $(INSTMANFLAGS) rcmd.man  $(MANDIR)/rcmd.x
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) -lX11
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	- at 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)
X
X$(IMAKE):
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X$(XLIB)::;
X-L$(USRLIBDIR)::;
X-L$(LIBSRC)/Xpic::;
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_xplaces/Makefile
if test 7349 -ne `wc -c <xplaces/Makefile`; then
    echo shar: \"xplaces/Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/Makefile.bak -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/Makefile.bak\"
else
echo shar: Extracting \"xplaces/Makefile.bak\" \(7338 characters\)
sed "s/^X//" >xplaces/Makefile.bak <<'END_OF_xplaces/Makefile.bak'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08: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# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
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.macros to change
X
X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system:  SunOS 4.0
X
XBOOTSTRAPCFLAGS =
X             AS = as
X             CC = cc
X            CPP = /lib/cpp
X             LD = ld
X           LINT = lint
X        INSTALL = install
X           TAGS = ctags
X             RM = rm -f
X             MV = mv
X             LN = ln -s
X         RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -axz
X    LINTLIBFLAG = -C
X           MAKE = make
XSTD_CPP_DEFINES =
X    STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X XWSRC = $(CONTRIBSRC)/widgets/Xhp/Xw
X
X XWLIB = $(USRLIBDIR)/libXw.a
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL = /bin/sh
X
X        DESTDIR =
X      USRLIBDIR = /tmp/ftp/usr/lib-sun4
X         BINDIR = /local/bin/X11
X         INCDIR = /tmp/ftp/usr/include
X        INCROOT = $(DESTDIR)/usr/include
X         ADMDIR = /var/scr/Xerrors
X         LIBDIR = /tmp/ftp/usr/lib
X     LINTLIBDIR = $(LIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X        MANPATH = /local/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)x
X      LIBMANDIR = $(MANSOURCEPATH)3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -g kmem -m 2755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(DEPENDSRC)/makedepend
X          IMAKE = $(BINDIR)/imake
X            RGB = $(RGBSRC)/rgb
X             FC = $(BDFTOSNFSRC)/bdftosnf
X      MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X      MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X            TOP = ../..
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     SCRIPTSSRC = $(UTILSRC)/scripts
X     EXAMPLESRC = $(TOP)/examples
X     CONTRIBSRC = $(TOP)/contrib
X         DOCSRC = $(TOP)/doc
X         RGBSRC = $(TOP)/rgb
X      DEPENDSRC = $(UTILSRC)/makedepend
X       IMAKESRC = $(UTILSRC)/imake
X       IRULESRC = $(UTILSRC)/imake.includes
X        XLIBSRC = $(LIBSRC)/X
X         XMUSRC = $(LIBSRC)/Xmu
X     TOOLKITSRC = $(LIBSRC)/Xt
X     AWIDGETSRC = $(LIBSRC)/Xaw
X     OLDXLIBSRC = $(LIBSRC)/oldX
X    BDFTOSNFSRC = $(FONTSRC)/bdftosnf
X   MKFONTDIRSRC = $(FONTSRC)/mkfontdir
X   EXTENSIONSRC = $(TOP)/extensions
X
X   EXTENSIONLIB = $(USRLIBDIR)/lib/libXext.a
X
X           XLIB = -L$(USRLIBDIR) -lX11
X
X         XMULIB = $(USRLIBDIR)/libXmu.a
X        OLDXLIB = $(USRLIBDIR)/liboldX.a
X       XTOOLLIB = $(USRLIBDIR)/libXt.a
X         XAWLIB = $(USRLIBDIR)/libXaw.a
X       INCLUDES = -I$(INCDIR) -I$(INCROOT)
X
X       LINTXLIB = $(XLIBSRC)/llib-lX11.ln
X        LINTXMU = $(XMUSRC)/llib-lXmu.ln
X      LINTXTOOL = $(TOOLKITSRC)/llib-lXt.ln
X        LINTXAW = $(AWIDGETSRC)/llib-lXaw.ln
X      MACROFILE = Sun.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
XLOCAL_LIBRARIES = $(XLIB)
X
XDEFINES = -DCSRI
X
X OBJS = xplaces.o
X SRCS = xplaces.c
X
X PROGRAM = xplaces
X
Xall:: xplaces
X
Xxplaces: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xplaces
X	$(INSTALL) -c $(INSTALLFLAGS) xplaces $(BINDIR)
X
Xinstall.man:: xplaces.man
X	$(INSTALL) -c $(INSTMANFLAGS) xplaces.man $(MANDIR)/xplaces.x
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND)::
Xclean::
X	$(RM) $(PROGRAM)
X
Xinstall::
X	$(INSTALL) rcmd $(BINDIR)
X
Xinstall.man:: rcmd.man
X	$(INSTALL) -c $(INSTMANFLAGS) rcmd.man  $(MANDIR)/rcmd.x
X
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) -lX11
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	- at 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)
X
X$(IMAKE):
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
X
X$(XLIB)::;
X-L$(USRLIBDIR)::;
X-L$(LIBSRC)/Xpic::;
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X	@echo "install done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_xplaces/Makefile.bak
if test 7338 -ne `wc -c <xplaces/Makefile.bak`; then
    echo shar: \"xplaces/Makefile.bak\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/README\"
else
echo shar: Extracting \"xplaces/README\" \(1028 characters\)
sed "s/^X//" >xplaces/README <<'END_OF_xplaces/README'
XPretty much a complete rewrite of xplaces to make it ICCCM conformant (more
Xor less) and give it more smarts about icons, icongeometry, and geometry. It
Xalso prints a DISPLAY= at the start -- Bourne shell syntax.
X
XIt gets the WM_COMMAND property and reconstructs the command line with the
Xwindow's present geometry (rather than the geometry it started with),
Xicongeometry and iconic state if any. It also uses the WM_CLIENT_MACHINE
Xproperty to determine whether the application is running remotely or not, if
Xthe latter, it generates a line of the form 'rcmd remotehost command
Xarguments...'. Th ercmd script in this directory works for machines with BSD
Xstyle remote shell (rsh) It should work with reparenting window managers as
Xwell - tested with twm (an alpha version that is sort of ICCCM conformant as
Xwell as the old version).
X
XIt's flexible enough that it should be adaptable to other toolkits with just
Xa change of Option descriptions. See the comment before the Option typedef.
X
X	Mark Moraes <moraes at csri.toronto.edu>
END_OF_xplaces/README
if test 1028 -ne `wc -c <xplaces/README`; then
    echo shar: \"xplaces/README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/patchlevel.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/patchlevel.h\"
else
echo shar: Extracting \"xplaces/patchlevel.h\" \(21 characters\)
sed "s/^X//" >xplaces/patchlevel.h <<'END_OF_xplaces/patchlevel.h'
X#define PATCHLEVEL 3
END_OF_xplaces/patchlevel.h
if test 21 -ne `wc -c <xplaces/patchlevel.h`; then
    echo shar: \"xplaces/patchlevel.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/rcmd -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/rcmd\"
else
echo shar: Extracting \"xplaces/rcmd\" \(1633 characters\)
sed "s/^X//" >xplaces/rcmd <<'END_OF_xplaces/rcmd'
X#! /bin/sh
X# This command runs command(s) remotely in the background, by pointing
X# stdout and stderr at /dev/null. (Should we point stdin at /dev/null too?)
X# By running this through the Bourne shell at the other end, and
X# we get rid of the rsh and rshd which otherwise hang around at either
X# end. Ideas from from a posting by clyde at emx.utexas.edu to list.xpert,
X# and Stephen Bellantoni <sjb at cs.toronto.edu>
X# Mark Moraes, University of Toronto
Xrshargs="/bin/sh"
Xcase $# in
X0)
X	echo Usage: $0 remotehost [-l remoteuser] [command] >&2
X	exit 1
X	;;
X*)	
X	host=$1
X	shift
X	case "$1" in
X	-l)
X		shift
X		rshargs="-l $1 /bin/sh"
X		shift
X		;;
X	esac
X	;;
Xesac
Xlocalhost=y
Xcase "$DISPLAY" in
X'')
X	# Assume unix:0.0
X	DISPLAY=${HOST-`hostname`}:0.0
X	;;
X:*|unix:*)
X	DISPLAY=${HOST-`hostname`}`expr "$DISPLAY" : "[^:]*\(.*\)"`
X	;;
X*)
X	localhost=n
X	;;
Xesac
X# If we are on the local host, do an xhost -- the xhost won't work
X# if DISPLAY isn't unix:0.0, even if we are on the local host.
Xcase $localhost in
Xy)	xhost +$host ;;
Xesac
X(
X # Set remote terminal type, remote display, and close stdin, stdout and
X # stderr at the remote end so the rsh doesn't stay around. This also
X # means that no error feedback is possible, which is a real pain.
X # common problems -- DISPLAY being wrong or the remote host not
X # being authorized to connect to the X server.
X echo "TERM=$TERM;export TERM;DISPLAY=$DISPLAY;export DISPLAY;" \
X      ${CONSOLETYPE:+"CONSOLETYPE=$CONSOLETYPE; export CONSOLETYPE;"} \
X      "exec > /dev/null 2>&1 <&1; (";
X case "$@" in
X '')	while read line; do echo "$line"; done;;
X *)	echo "$@";;
X esac
X echo ") &"
X) | rsh $host $rshargs
END_OF_xplaces/rcmd
if test 1633 -ne `wc -c <xplaces/rcmd`; then
    echo shar: \"xplaces/rcmd\" unpacked with wrong size!
fi
chmod +x xplaces/rcmd
# end of overwriting check
fi
if test -f xplaces/rcmd.man -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/rcmd.man\"
else
echo shar: Extracting \"xplaces/rcmd.man\" \(2761 characters\)
sed "s/^X//" >xplaces/rcmd.man <<'END_OF_xplaces/rcmd.man'
X.TH RCMD X
X.SH NAME
Xrcmd - run a remote command in the background, without stdin, stdout, stderr.
X.SH SYNOPSIS
X.B rcmd
Xremotehost [ -l user ] [ command ]
X.SH DESCRIPTION
X.I Rcmd
Xruns the given 
X.I command 
Xon the specified
X.I remotehost
Xvia 
X.I rsh
Xbut by redirecting stdin, stdout and stderr to /dev/null, and feeding
Xthe given command to the Bourne shell (/bin/sh) in the background, it
Xresults in the rsh exiting and closing the connection, leaving the
Xcommand as a daemon on the remote machine.  This is useful only for
Xcommands that have no use for stdin, stdout and stderr like most
Xapplications for the X Window system.
X.PP
XIt passes the TERM environment variable to the remote shell. It also
Xpasses the DISPLAY environment variable, unless DISPLAY is not defined
Xor is :N or unix:N, in which case it passes `hostname`:N.
X.PP
XIf
X.I rcmd
Xis run from the same machine as the one on which the X server is
Xrunning, then it will run an
X.I xhost
Xcommand to add the remotehost to the access list.
X.RI ( xhost
Xmay not be run from remotehosts, so you'll have to do it yourself if
Xyou run 
X.I rcmd 
Xon a remotehost, for another remotehost)
X.PP
XIf 
X.I command
Xis not provided as an argument,
X.I rcmd
Xreads the standard input and feeds it to the remote shell.
XSo something like
X.nf
X	rcmd remotehost << EOF
X	xterm -ls &
X	xclock &
X	xpostit &
X	EOF
X.fi
Xwill start a remote xterm, xclock and xpostit in the background on the
Xremotehost. This is much faster than using a separate rcmd or rsh for
Xeach command. But an ampersand (&) must be put after each command or
Xthe xclock will only start after the xterm finishes, which is probably
Xnot what is intended.
X.PP
XOf course, these commands could be stored in a shell script at the
Xremote end, and run with
X.nf
X	rcmd remotehost shellscriptname
X.fi
X.SH OPTIONS
X.TP
X.BR \-l " user"
XRuns the remote shell as 
X.I user
Xon the remote host rather than as yourself.
X.SH EXAMPLES
X.nf
Xrcmd godzilla.eecg /local/bin/X11/xterm -geometry 80x50+3-3 -ls
Xrcmd church.csri -l xwindows /local/bin/X11/xpic
X.fi
X.sp
Xwill run xterm on the remote machine 
X.I godzilla
Xwith the display on the current HOST (assuming the environment variable 
XHOST is set to `hostname`).
X.SH BUGS
XThe remote command has no way of notifying the user about error
Xconditions, except through logs. A particularly annoying problem is if
Xthe user has the DISPLAY wrong, or the host is not in the server's
Xaccess list, (via 
X.IR xhost )
Xnothing will happen. If the
X.I .rhosts
Xor
X.I hosts.equiv
Xfiles aren't set up to allow you permission for
X.I rsh 
Xon the remote host, you'll get a "Permission denied" error.
X.PP
XAll bugs associated with
X.I rsh
XUsers with a C-shell or derivative as their login shell will
Xfind rsh takes very long -- this is a feature of C-shell startup.
END_OF_xplaces/rcmd.man
if test 2761 -ne `wc -c <xplaces/rcmd.man`; then
    echo shar: \"xplaces/rcmd.man\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/xplaces.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/xplaces.c\"
else
echo shar: Extracting \"xplaces/xplaces.c\" \(19241 characters\)
sed "s/^X//" >xplaces/xplaces.c <<'END_OF_xplaces/xplaces.c'
X/*
X * xplaces goes through the windows on the screen trying to determine the
X * command used to start each one up in the same state as it is when xplaces is
X * run. It doesn't quite meet such a stringent spec, thanks to complete
X * non-cooperation from clients, and marginal cooperation from window managers.
X * It will, however, give a window manager that obeys at least the WM_STATE
X * directive, come up with a reasonable guess at geometry, icon state, and
X * icon geometry. It outputs a Bourne shell script that may be used to
X * recreate the window setting.
X */
X/*
X * Rewritten from scratch based on Ken Yap's manual page -- the old version
X * was just unable to cope with the ICCCM
X */
X/*
X * It assumes that the rcmd script is available to run a command in the
X * background on a remote machine -- a script that works on systems with the
X * Berkeley remote shell (rsh) command is provided in thsi directory.
X */
X/*
X * Note that the output of xplaces may need to be ordered by hand. xplaces is
X * a fairly low level tool -- shell/awk/perl/C commands should be wrapped
X * around it to match your environment.
X */
X/*
X * !! Won't deal with applications that start up on one display/screen and
X * change to another...
X */
X/*
X * !! It doesn't free any of the WM_COMMAND strings because it allows the
X * Option procs to modify argvp. This shouldn't be a problem -- if you have
X * that many commands around, chances are your X server will die first...
X */
X#include	<stdio.h>
X#include	<X11/Xlib.h>
X#include	<X11/Xutil.h>
X#include 	<X11/Xatom.h>
X#include	<X11/Xos.h>
X
X#ifndef ICCCM_XLIB
X  /* If ICCCM_XLIB isn't defined, try to intuit whether we're ICCCM or not. */
X# ifdef WithdrawnState
X#  define ICCCM_XLIB
X# endif
X#endif
X
Xextern char *malloc();
X
Xstatic Atom wmStateAtom;
Xstatic Window rootw;
Xstatic Display *d;
Xstatic int scr;
Xstatic Bool iconic;
Xstatic char hostname[256];
Xstatic char *progname = "xplaces";
X
X/* forward declarations */
Xstatic XID *GetWMState();
Xstatic Bool argmatch();
Xstatic char *savestr();
Xstatic void dogeom();
Xstatic void doiconic();
Xstatic void printargs();
Xstatic int scanoptions();
X
Xtypedef struct {
X	int valid;
X	int width, height, x, y;
X} Geom;
X
Xstatic Geom geom;
Xstatic Geom igeom;
X
X/* !! Wish the X toolkit would expand -g to -geometry, and so on */
X/*
X * xplaces parsing only deals with xplaces style options. It uses the Option
X * struct and the scanoptions procedure to implement a fairly general way of
X * searching WM_COMMAND and changing them if necessary to match reality. Other
X * toolkits (eg) XView, have different ways of specifying geometry. The only
X * way I can see out of it is to have each toolkit indicate it's style of
X * options in a special property, and make xplaces have a different set of
X * Option structs for each toolkit's options style. The Option struct is a
X * descriptor that describes what to match and how to modify the options. We
X * scan through the arguments in WM_COMMAND looking for things that match
X * 'option', (these arguments must be a minimum of 'atleast' long to be
X * considered a hit -- see argmatch()) -- at least 'numargs' args are expected
X * after the option for a hit, and 'proc' is called as proc(char **argv, int
X * argc, int i, Option *option) where argv is the entire argv array, argc is
X * the number of elements in argv, i is the option in argv which matched, and
X * option is what triggered the match. The proc may modify the strings in argv
X * just so long as it does not increase their length, proc may change any of
X * the pointers in argv except argv[0] change any of the argv pointers.
X */
Xtypedef struct {
X	char *option;
X	int atleast;
X	int numargs;
X	void (* proc)();
X	char *arg;
X} Option;
X
X/*
X * At CSRI, we hack the toolkit to provide a -ig option. The -xrm stuff is too
X * much work.
X */
X#ifdef CSRI
X# define NICON 3
X  static Option opt_ig = {"-igeometry", NICON, 1, dogeom, (char *) &igeom};
X#else
X# define NICON 2
X  static Option opt_ig  = {"-xrm", 2, 1, dogeom, (char *) &igeom};
X#endif
X
Xstatic Option opt_geom = {"-geometry", 2, 1, dogeom, (char *)  &geom};
Xstatic Option opt_icon = {"-iconic", NICON, 0, doiconic, (char *) &iconic};
X
X#ifndef ICCCM_XLIB
X/*
X * All this stuff is a (somewhat sloppy) implementation of some of the
X * proposed Xlib support for the ICCCM. Probably won't be needed in R4.
X */
X
Xtypedef struct {
X	unsigned char *value;	/* property data */
X	Atom encoding;		/* type of property */
X	int format;		/* 8, 16, or 32 */
X	unsigned long nitems;	/* number of items in value */
X} XTextProperty;
X	
Xstatic Status
XXGetTextProperty(dpy, w, text_prop_ret, property)
XDisplay *dpy;
XWindow w;
XXTextProperty *text_prop_ret;
XAtom property;
X{
X	Atom actual_type;
X	int actual_format;
X	unsigned long nitems;
X	unsigned long bytes_after;
X	Status status;
X	unsigned char *propdata;
X
X	text_prop_ret->value = NULL;
X	text_prop_ret->encoding = None;
X	text_prop_ret->format = 0;
X	text_prop_ret->nitems = 0;
X	
X	status = XGetWindowProperty(dpy, w, property, 0L, 4096L, 
X	 False, AnyPropertyType, &actual_type, &actual_format, 
X	 &nitems, &bytes_after, &propdata);
X	if (status == BadWindow) {
X		(void) fprintf(stderr, "Window 0x%lx does not exist!\n", w);
X		return 0;
X	}
X	if (status != Success) {
X		(void) fprintf(stderr,
X		 "XGetWindowProperty failed (status %d)!\n", status);
X		return 0;
X	}
X	if (actual_type == None) {
X		return 0;
X	}
X	if (propdata == NULL) {
X		(void) fprintf(stderr, "NULL property data!\n");
X		return 0;
X	}
X	if (bytes_after != 0) {
X		/* !! Sleazy! We should loop and get it in chunks */
X		(void) fprintf(stderr,
X		 "Only got the first %d items. %d bytes remain\n", 
X		 nitems, bytes_after);
X	}
X	text_prop_ret->value = propdata;
X	text_prop_ret->encoding = actual_type;
X	text_prop_ret->format = actual_format;
X	text_prop_ret->nitems = nitems;
X	return 1;
X}
X	
Xstatic Status
XXGetCommand(dpy, w, argvp, argcp)
XDisplay *dpy;
XWindow w;
Xchar ***argvp;
Xint *argcp;
X{
X	int i, len;
X	char **argv;
X	char *cp;
X	XTextProperty tp;
X	Status status;
X	
X	status = XGetTextProperty(dpy, w, &tp, XA_WM_COMMAND);
X	if (status == 0 || tp.value == NULL)
X		return 0;
X	for(i = 0, len = 0, cp = (char *) tp.value; i < tp.nitems; i++, cp++)
X		if (*cp == '\0')
X			len++;
X	if (len == 0) {
X		XFree((char *) tp.value);
X		(void) fprintf(stderr, "No data in WM_COMMAND\n");
X		return 0;
X	}
X	if ((argv = (char **) malloc(sizeof(char *) * len)) == NULL) {
X		XFree((char *) tp.value);
X		(void) fprintf(stderr, "Not enough memory for string list\n");
X		return 0;
X	}
X	i = 0;
X	cp = (char *) tp.value;
X	do {
X		argv[i++] = cp;
X		while(*cp++ != '\0')
X			;
X	} while (i < len);
X	*argcp = len;
X	*argvp = argv;
X	return 1;
X}
X
Xstatic Status
XXGetWMClientMachine(dpy, w, text_prop_ret)
XDisplay *dpy;
XWindow w;
XXTextProperty *text_prop_ret;
X{
X	return XGetTextProperty(dpy, w, text_prop_ret, XA_WM_CLIENT_MACHINE);
X}
X
Xstatic Status
XXGetWMName(dpy, w, text_prop_ret)
XDisplay *dpy;
XWindow w;
XXTextProperty *text_prop_ret;
X{
X	return XGetTextProperty(dpy, w, text_prop_ret, XA_WM_NAME);
X}
X
Xstatic Status
XXGetWMIconName(dpy, w, text_prop_ret)
XDisplay *dpy;
XWindow w;
XXTextProperty *text_prop_ret;
X{
X	return XGetTextProperty(dpy, w, text_prop_ret, XA_WM_ICON_NAME);
X}
X
Xstatic void
XXFreeStringList(list)
Xchar **list;
X{
X	XFree(*list);
X	free((char *) list);
X}
X
X#endif /* ICCCM_XLIB */
X
Xvoid
Xfatal(message)
Xchar *message;
X{
X	(void) fprintf(stderr, "%s: %s\n", progname, message);
X	exit(1);
X	/*NOTREACHED*/
X}
X
Xvoid
Xusage()
X{
X	fatal("Usage: xplaces [-display displayname]\n");
X	/*NOTREACHED*/
X}
X
Xstatic char *
Xnextarg(i, argv, argc)
Xint i;
Xchar **argv;
Xint argc;
X{
X	if (++i >= argc) {
X		(void) fprintf(stderr, "%s: %s must be followed by argument\n",
X		 progname, argv[i-1]);
X		usage();
X	}
X	return argv[i];
X}
X
Xint
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	char *dpyname = NULL;
X	int i;
X	extern char *getenv();
X	extern long atol();
X	unsigned int nchildren;
X	Window parent_win, *child_list;
X	Window topwin = None;
X	
X	for(i = 1; i < argc;) {
X		if (argmatch(argv[i], "-display", 2)) {
X			dpyname = nextarg(i, argv, argc);
X			i += 2;
X		} else if (argmatch(argv[i], "-id", 3)) {
X			char *cp = nextarg(i, argv, argc);
X
X			if (strncmp(cp, "0x", 2) == 0) {
X				(void) sscanf(cp+2, "%x", &topwin);
X			} else {
X				(void) sscanf(cp, "%d", &topwin);
X			}
X			i += 2;
X		} else {
X			(void) fprintf(stderr, "%s: Bad option -- %s\n",
X			 progname, argv[i]);
X			usage();
X			/*NOTREACHED*/
X		}
X	}
X	if ((d = XOpenDisplay(dpyname)) == NULL) {
X		if (dpyname == NULL)
X			dpyname = getenv("DISPLAY");
X		if (dpyname == NULL)
X			dpyname = "(NULL)";
X		(void) fprintf(stderr, "Can't open display %s\n", dpyname);
X		exit(-1);
X		/*NOTREACHED*/
X	}
X   	(void) gethostname(hostname, sizeof(hostname));
X	(void) printf("DISPLAY=%s; export DISPLAY\n", DisplayString(d));
X	wmStateAtom = XInternAtom (d, "WM_STATE", False);
X	scr = DefaultScreen(d);
X	if (topwin == None)
X		topwin = RootWindow(d, scr);
X	if (XQueryTree(d, topwin, &rootw, &parent_win, &child_list,
X	 &nchildren) == 0) {
X		(void) fprintf(stderr,
X		 "%s: Couldn't get children for top window 0x%lx\n", progname,
X		 topwin);
X		exit(-1);
X		/*NOTREACHED*/
X	}
X		
X	/* scan list */
X	for ( ; nchildren-- > 0; child_list++)
X		(void) searchtree(topwin, *child_list);
X	return 0;
X}
X
X/*
X * Searchtree returns non-zero if w, or one of w's descendants was found
X * carrying a WM_COMMAND property. It attempts to find all top level windows
X * that are descendants of w, and print the command strings for them if they
X * have a WM_COMMAND property. Non-conformant low-down weaselly windows that
X * don't set WM_COMMAND for their top level windows are ignored. (Hmm, might
X * be a better idea to just XKillClient them:-) If a WM_COMMAND property was
X * found on a toplevel window, it prints out the command string for that
X * window and returns. A toplevel window is a window which has
X * override_redirect set to false, and has either WM_STATE set, or is a mapped
X * child of the root window with no descendants that have WM_STATE set,
X * according to Section 5.1.1.3 of the X Penal Code (er, the ICCCM, that is)
X * Sheesh!
X */
Xint
Xsearchtree(parent, w)
XWindow parent;
XWindow w;
X{
X	unsigned int nchildren;
X	int ret = 0;
X	int donegeometry = 0;
X	int doneigeom = 0;
X	int doneiconic = 0;
X	int gotcommand;
X	int argc;
X	Window root_win, parent_win, *child_list, junk;
X	XWindowAttributes win_info;
X	XSizeHints hints;
X	long supplied;
X	XID *state;
X	XTextProperty tp;
X	char **argv;
X
X	/* what do we know about the window? */
X	if (!XGetWindowAttributes(d, w, &win_info)) {
X		(void) fprintf(stderr,
X		 "XGetWindowAttributes failed on window 0x%lx", w);
X		return 0;
X	}
X
X	if (win_info.override_redirect)
X		return 0;	/* ICCCM 5.1.1.3 */
X
X	state = GetWMState(w);
X	/*
X	 * If we get here, then we're a top level window. Question is, are we
X	 * the top level window with the WM_COMMAND? We only return non-zero
X	 * if we're a WM_COMMAND type... Ideally, we should try for a command
X	 * only if WM_STATE is set. Alas, with older non-ICCCM-conformant
X	 * window managers still in existence, WM_STATE may not be set, but
X	 * WM_COMMAND might be.
X	 */
X	gotcommand = XGetCommand(d, w, &argv, &argc);
X	
X	if (state == 0 && gotcommand == 0) {
X		/*
X		 * We don't have a WM_STATE property, maybe one of our kids
X		 * does, so recurse first */
X		if (XQueryTree(d, w, &root_win, &parent_win,
X		 &child_list, &nchildren) == 0)
X			return 0;
X		
X		for ( ; nchildren-- > 0; child_list++) {
X			ret = searchtree(w, *child_list);
X			if (ret != 0) {
X				/*
X				 * One of our children is a toplevel window
X				 * with WM_COMMAND.  Good for them -- we can't
X				 * be one, nor can any of our other children
X				 * have the WM_COMMAND even if they have
X				 * WM_STATE.
X				 */
X				return ret;
X			}
X		}
X		/* We don't have a WM_STATE, none of the kids does */
X		/* Are we a Mapped root window descendant? */
X		if (parent == rootw && win_info.map_state != IsUnmapped)
X			/* yep, so we're top level */
X			ret++;
X		else
X			/* nope. keep looking */
X			return 0;
X	} else {
X		/* We have a WM_STATE or a WM_COMMAND. We're top level */
X		ret++;
X	}
X
X	/*
X	 * Ideally, we'd get the command here instead of earlier, but it ain't
X	 * an ICCCM world yet... We print a warning if we don't get a
X	 * WM_COMMAND from a top level window.
X	 */
X	if (gotcommand == 0) {
X		XTextProperty text_prop;
X		Status status;
X		char *wm_name;
X		char *wm_class;
X		char *wm_client_machine;
X
X		status = XGetTextProperty(d, w, &text_prop,
X		 XA_WM_NAME);
X		if (status == 0 || text_prop.value == NULL)
X			wm_name = "";
X		else
X			wm_name = (char *) text_prop.value;
X		status = XGetTextProperty(d, w, &text_prop,
X		 XA_WM_CLASS);
X		if (status == 0 || text_prop.value == NULL)
X			wm_class = "";
X		else
X			wm_class = (char *) text_prop.value;
X
X		status =  XGetTextProperty(d, w, &text_prop,
X		 XA_WM_CLIENT_MACHINE);
X		if (status == 0 || text_prop.value == NULL)
X			wm_client_machine = "";
X		else
X			wm_client_machine = (char *) text_prop.value;
X
X#ifdef DEBUG
X		(void) fprintf(stderr,
X		 "%s: Top level window 0x%lx has no WM_COMMAND string\n",
X		 progname, w);
X		(void) fprintf(stderr,
X		 "\t\t(name \"%s\", class \"%s\", client machine \"%s\")\n",
X		 wm_name, wm_class, wm_client_machine);
X#endif
X		return 0;
X	}
X
X	if (!XGetWMSizeHints(d, w, &hints, &supplied, XA_WM_NORMAL_HINTS)) {
X		(void) fprintf(stderr,
X		 "XGetWMSizeHints on Window 0x%lx failed.\n", w);
X		hints.flags = 0;	/* can't give up now...*/
X	}
X
X	/* if no position then assume +0+0 */
X	if (!(hints.flags & (USPosition || PPosition)))
X		hints.x = hints.y = 0;
X
X	/*
X	 * terminal windows sizes are in characters so this will compute the
X	 * geometry correctly. Use the win_info stuff, not the hints, since
X	 * almost no window manager or client updates the hints. Grump.
X	 */
X	if (hints.flags & (PMinSize|PBaseSize) && hints.flags & PResizeInc) {
X		if (hints.flags & PBaseSize) {
X			geom.width = (win_info.width - hints.base_width) /
X				hints.width_inc;
X			geom.height = (win_info.height - hints.base_height) /
X				hints.height_inc;
X		} else {
X			geom.width = (win_info.width - hints.min_width) /
X				hints.width_inc;
X			geom.height = (win_info.height - hints.min_height) /
X				hints.height_inc;
X		}
X	} else {
X		geom.width = win_info.width;
X		geom.height = win_info.height;
X	}
X	geom.valid = True;
X	if (! XTranslateCoordinates(d, w, RootWindow(d, scr),
X	 win_info.x, win_info.y, &(geom.x), &(geom.y), &junk)) {
X		/*
X		 * only supposed to fail if w and RootWindow
X		 * are on different screens. Can't happen!
X		 */
X		(void) fprintf(stderr,
X		 "XTranslateCoordinates on Window 0x%lx failed!\n", w);
X		geom.x = geom.y = 0;
X	}
X	
X	if (XGetWMClientMachine(d, w, &tp)) {
X		if (strcmp((char *) tp.value, hostname) != 0) {
X			(void) printf("rcmd %s ", (char *) tp.value);
X		}
X		XFree((char *) tp.value);
X	}
X	/*
X	 * Finally, there's the problem of state - iconic, etc? And
X	 * icon geometry. We flagrantly violate the ICCCM and rely on
X	 * WM_STATE containing a CARD32 with the state, and a WINDOW
X	 * with the icon window. (well, we have the weak excuse that
X	 * xplaces is a poor man's session manager:-)
X	 */
X	iconic = False;
X	igeom.valid = False;
X	if (state != 0) {
X		if (state[0] == IconicState) {
X			iconic = True;
X		}
X		if (state[1] != None) {
X			if (!XGetWindowAttributes(d,
X			 (Window) state[1], &win_info)) {
X			    (void) fprintf(stderr,
X			     "XGetWindowAttr. failed on window 0x%lx",
X			     state[1]);
X			} else {
X			    igeom.valid = True;
X			    igeom.width = win_info.width;
X			    igeom.height = win_info.height;
X			    igeom.x = win_info.x;
X			    igeom.y = win_info.y;
X			}
X		}
X	}
X	/*
X	 * Now we have all the info we need. We first call scanoptions
X	 * to substitute any arguments in WM_COMMAND that may have
X	 * changed. We don't perform this substitution in the actual
X	 * WM_COMMAND properties, attractive as that idea seems.
X	 */
X	donegeometry = scanoptions(argv, argc, &opt_geom);
X	doneigeom = scanoptions(argv, argc, &opt_ig);
X	doneiconic = scanoptions(argv, argc, &opt_icon);
X	/*
X	 * scanoptions doesn't add the options to the end if they
X	 * don't exist. (!! Maybe it should? We should generalize the
X	 * Option structs into a table, have scanoptions accept that
X	 * table, then we could get rid of the multiple calls to
X	 * scanoptions and remove all the straight line code below for
X	 * adding options in) We do it by hand here for each option.
X	 */
X	(void) printf("%s ", argv[0]);
X	/* Safest to print options immediately after argv[0] */
X	if (!donegeometry) {
X		char *targv[2];
X		int targc;
X		
X		targv[0] = opt_geom.option;
X		targv[1] = "";
X		targc = 2;
X		dogeom(targv, targc, 0, &opt_geom);
X		printargs(targv, targc);
X	}
X	if (!doneigeom) {
X		char *targv[2];
X		int targc;
X		
X		targv[0] = opt_ig.option;
X		targv[1] = "";
X		targc = 2;
X		dogeom(targv, targc, 0, &opt_ig);
X		printargs(targv, targc);
X	}
X	if (!doneiconic) {
X		char *targv[2];
X		int targc;
X		
X		targv[0] = opt_icon.option;
X		targc = 1;
X		doiconic(targv, targc, 0, &opt_icon);
X		printargs(targv, targc);
X	}
X	/* print the rest of the arguments */
X	printargs(&argv[1], argc-1);
X	putc('\n', stdout);
X	fflush(stdout);
X	return ret;
X}
X
Xstatic XID *
XGetWMState(w)
XWindow w;
X{
X	int status;
X	XTextProperty tp;
X
X	status = XGetTextProperty(d, w, &tp, wmStateAtom);
X	if (status == 0)
X		return 0;
X	if (tp.nitems != 2) {
X		(void) fprintf(stderr,
X		 "Got %d items for WM_STATE;expected 2\n", tp.nitems);
X	}
X	return (XID *) tp.value;
X}
X
X/*
X * Returns true if s1 and s2 match for the length of s1. s1 must be at least
X * 'atleast' characters long. s1 may at most be as long as s2. Therefore,
X * argmatch("-", "-geometry", 2) will return False, argmatch("-g",
X * "-geometry", 2) will return True, argmatch("-geometry", "-geometry", 2)
X * will return True, and argmatch("-geometryx", "-geometry", 2) will return
X * False.
X */
Xstatic Bool
Xargmatch(s1, s2, atleast)
Xchar *s1;
Xchar *s2;
Xint atleast;
X{
X	int l1 = strlen(s1);
X	int l2 = strlen(s2);
X
X	if (l1 < atleast)
X		return False;
X	if (l1 > l2)
X		return False;
X	return (strncmp(s1, s2, l1) == 0);
X}
X
Xstatic char *
Xsavestr(s)
Xchar *s;
X{
X	char *cp = malloc((unsigned int) (strlen(s) + 1));
X
X	if (cp == NULL)
X		fatal("Out of memory\n");
X	return strcpy(cp, s);
X}
X
X
X/*ARGSUSED*/
Xstatic void
Xdogeom(argv, argc, i, option)
Xchar **argv;
Xint argc;
Xint i;
XOption *option;
X{
X	Geom *g = (Geom *) option->arg;
X	char tmpstr[256]; /* big enough to hold a large geometry... */
X
X	if (! g->valid) {
X		argv[i] = NULL;
X		argv[i+1] = NULL;
X		return;
X	}
X	if (strcmp(option->option, "-xrm") == 0) {
X		(void) sprintf(tmpstr, "\"*iconGeometry: %dx%d+%d+%d\"",
X		 g->width, g->height, g->x, g->y);
X	} else {
X		(void) sprintf(tmpstr, "%dx%d+%d+%d", g->width, g->height,
X		 g->x, g->y);
X	}
X	argv[i+1] = savestr(tmpstr);
X}
X
X/*ARGSUSED*/
Xstatic void
Xdoiconic(argv, argc, i, option)
Xchar **argv;
Xint argc;
Xint i;
XOption *option;
X{
X	int is_iconic = *((int *) option->arg);
X
X	if (is_iconic)
X		return;
X	else
X		argv[i] = NULL;
X}
X
Xstatic void
Xprintargs(argv, argc)
Xchar **argv;
Xint argc;
X{
X	int i;
X
X	for(i = 0; i < argc; i++) {
X		if (argv[i] != NULL) {
X			(void) printf("%s ", argv[i]);
X		}
X	}
X}
X
Xstatic int
Xscanoptions(argv, argc, option)
Xchar **argv;
Xint argc;
XOption *option;
X{
X	int i;
X	int matched = 0;
X
X	/* never scan argv[0] */
X	for(i = 1; i < argc; i++) {
X		if (argv[i] == NULL)
X			continue;
X		if (argmatch(argv[i], option->option, option->atleast)) {
X			(*(option->proc))(argv, argc, i, option);
X			matched++;
X		}
X	}
X	return matched;
X}
END_OF_xplaces/xplaces.c
if test 19241 -ne `wc -c <xplaces/xplaces.c`; then
    echo shar: \"xplaces/xplaces.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xplaces/xplaces.man -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xplaces/xplaces.man\"
else
echo shar: Extracting \"xplaces/xplaces.man\" \(3441 characters\)
sed "s/^X//" >xplaces/xplaces.man <<'END_OF_xplaces/xplaces.man'
X.TH XPLACES X "1 Feb 1988" "X Version 11"
X.SH NAME
Xxplaces - take snapshot of personal X window configuration and print
Xcommand lines for all X applications
X.SH SYNOPSIS
X.B xplaces
X[-display \fIdisplayname\fP] [-id \fIwindow-id\fP]
X.SH DESCRIPTION
X.I xplaces
Xprints on standard output the command lines used to startup 
Xthe X applications presently running and their geometry.
XThe output, after a little editing, can be used
Xin an initialization file.
X.SH EXAMPLE
XHere is a configuration example:
X.sp
X.nf
XDISPLAY=unix:0.0; export DISPLAY
Xxterm -sb -geometry 80x9+1+19 -title console -name console -C \\
X	-display unix:0 -e /e/moraes/.x11startup.bw2  &
Xxclock -geometry 100x100+1048+0  &
Xrcmd neat.ai /ai/bin/X11/xterm -display gerrard.csri:0 \\
X	-geometry 80x57+291+26 -ls  &
Xxterm -geometry 80x56+310+53 -e rlogin bay.csri  &
Xxterm -geometry 80x51+410+128 -title gerrard.csri  &
X.fi
X.sp
X.I This 
Xwill start up a console terminal window (which receives redirected
Xconsole output, preventing it from messing up the display), a clock
Xand three terminal windows, one of which is started up by the shell script
X.I rcmd
Xwhich starts up a command on a remote machine, putting it in the background.
X.I Rcmd 
Xis useful only if the application on the remote machine has no use for
Xstandard output and error because they get redirected to /dev/null.
X.PP
XOn the CSRI and ANT Suns, the recommended way of running
X.I X11
Xis by ``x11''.
XIn that case, the console xterm is automatically started up by the
X.I x11
Xscript, so that command must be removed from the xplaces output, and
Xthe remaining xterms (and other applications can be added to the
X.I x11start
Xfile.
X.SH OPTIONS
X.B xplaces
Xis Xlib based, and accepts only the following two arguments.
X.TP 8
X.BI \-display " displayname"
Xwhere displayname describes the display to use, and is in one
Xof the standard forms. See X(1) for more details. The default is
Xdetermined by the environment variable DISPLAY.
X.TP 8
X.BI \-id " window-id"
Xwhich asks for the command string to start a particular window.
XNote that the window-id specified may be the window id of a parent
Xif the window really holding the command string property (WM_COMMAND)
Xand xplaces will find it correctly by recursive search through the
Xwindow hierarchy. the window-id may be specified either as a decimal
Xnumber, or as a hexadecimal number (prefixed by 0x) which makes it
Xpossible to use the output of 
X.B xlswins, 
Xor 
X.B xwininfo
Xwith this option.
X.SH SEE ALSO
X.IR x11 (x),
X.IR X (x),
X.IR xprop (x),
X.IR xlswins (x)
X.br
XThe Inter Client Communication Conventions Manual.
X.SH DIAGNOSTICS
X.B xplaces
Xwill complain about top level windows without commands associated with
Xthem, and print the name and class of such windows. It also complains
Xabout various X errors that may occur, and will die with an error
Xmessage if used with incorrect arguments.
X.SH BUGS
X.I xplaces
Xcan only print the command line for application well behaved Xt applications,
Xor applications that accept -geometry, and -iconic, and set WM_COMMAND and
XWM_NORMAL_HINTS.
X.br
XIt can get confused if you use ambiguous options (-g for geometry, etc)
X.br
XWith some window managers, it cannot locate icons. Blame for this
Xlies solely with the window managers!
X.SH AUTHOR
XThe first version was by Ken Yap (ken at cs.rochester.edu)
X.br
XThis version was rewritten to deal with a much wider range of window manager
Xand application behaviour by Mark Moraes (moraes at csri.toronto.edu)
END_OF_xplaces/xplaces.man
if test 3441 -ne `wc -c <xplaces/xplaces.man`; then
    echo shar: \"xplaces/xplaces.man\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0

dan
-----------------------------------------------------------
		    O'Reilly && Associates
		argv at sun.com / argv at ora.com
	   632 Petaluma Ave, Sebastopol, CA 95472 
     800-338-NUTS, in CA: 800-533-NUTS, FAX 707-829-0104
    Opinions expressed reflect those of the author only.



More information about the Comp.sources.x mailing list