v13i042: xsh, Part01/01

Mario Dragone - CICB Rennes 99.36.20.00 Mario.Dragone at cicb.fr
Fri May 31 03:29:56 AEST 1991


Submitted-by: "Mario Dragone - CICB Rennes 99.36.20.00" <Mario.Dragone at cicb.fr>
Posting-number: Volume 13, Issue 42
Archive-name: xsh/part01

This is the xsh program version 1. Its purpose is to provide an easy way to
submit shell commands by simply clicking or typing a character in a command
button. xsh looks like xshell excepted that the text of the commands submited
is displayed in a field label. 
Xsh resources may be used to bind shell commands with mouse or keyboard events,
to control what must be displayed when a command is submited, to specify fonts, 
bitmap. 

------------ Cut here ----------
#! /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, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  Imakefile Makefile README patchlevel.h xsh.c xsh.english
#   xsh.man
# Wrapped by dragone at servix on Thu May 30 09:24:24 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(275 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
XLOCAL_LIBRARIES = XawClientLibs
X           SRCS = xsh.c
X           OBJS = xsh.o
X
XAllTarget(xsh)
XNormalProgramTarget(xsh,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES), /**/)
X
XInstallProgram(xsh, $(BINDIR))
XInstallManPage(xsh, $(MANDIR))
X
X/* InstallAppDefaults(xsh) */
X
XDependTarget()
END_OF_FILE
if test 275 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(8161 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
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###########################################################################
X# Makefile generated from "Imake.tmpl" and <Imakefile>
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 gould_np1.cf to change
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 = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = 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   SIGNAL_DEFINES = -DSIGNALRETURNSINT
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 =
X        CCOPTIONS =
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 = gould_np1.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.68 90/07/03 12:14:47 rws Exp $
X
X###########################################################################
X# X Window System make variables; this need to be coordinated with rules
X# $XConsortium: Project.tmpl,v 1.68 90/07/03 12:14:47 rws Exp $
X
X          PATHSEP = /
X        USRLIBDIR = $(DESTDIR)/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 = $(USRLIBDIR)/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/X11R4/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(MANSOURCEPATH)n
X        LIBMANDIR = $(MANSOURCEPATH)3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
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
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)  $(USRLIBDIR)/libX11.a
X             XLIB = $(EXTENSIONLIB) 			  -lX11
X
X      DEPXAUTHLIB =  $(USRLIBDIR)/libXau.a
X         XAUTHLIB = 			  -lXau
X
X        DEPXMULIB =  $(USRLIBDIR)/libXmu.a
X           XMULIB = 			  -lXmu
X
X       DEPOLDXLIB =  $(USRLIBDIR)/liboldX.a
X          OLDXLIB = 			  -loldX
X
X      DEPXTOOLLIB =  $(USRLIBDIR)/libXt.a
X         XTOOLLIB = 			  -lXt
X
X        DEPXAWLIB =  $(USRLIBDIR)/libXaw.a
X           XAWLIB = 			  -lXaw
X
X LINTEXTENSIONLIB =  $(LINTLIBDIR)/llib-lXext.ln
X         LINTXLIB =  $(LINTLIBDIR)/llib-lX11.ln
X          LINTXMU =  $(LINTLIBDIR)/llib-lXmu.ln
X        LINTXTOOL =  $(LINTLIBDIR)/llib-lXt.ln
X          LINTXAW =  $(LINTLIBDIR)/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 = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
X           SRCS = xsh.c
X           OBJS = xsh.o
X
Xall:: xsh
X
Xxsh: $(OBJS) $(DEPLIBS)
X	 $(RM) $@
X	$(CC) -o $@ $(OBJS) $(LDOPTIONS) $(LOCAL_LIBRARIES) $(LDLIBS)  
$(EXTRA_LOAD_FLAGS)
X
Xclean::
X	$(RM) xsh
X
Xinstall:: xsh
X	$(INSTALL) -c $(INSTPGMFLAGS)   xsh  $(BINDIR)
X
Xinstall.man:: xsh.man
X	$(INSTALL) -c $(INSTMANFLAGS) xsh.man  $(MANDIR)/xsh.n
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLDEFINES) -- $(SRCS)
X
X###########################################################################
X# common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile::
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) -DCURDIR=$(CURRENT_DIR)
X
Xtags::
X	$(TAGS) -w *.[ch]
X	$(TAGS) -xw *.[ch] > TAGS
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
END_OF_FILE
if test 8161 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(608 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XCeci est Xsh
X     "utilitaire de lancement de commandes au processeur shell pour
X      X Window X11R4"
X
XJ'ai ecrit xsh en m'inspirant un peu du programme xshell qui ne semble
Xpas avoir ete porte en X11R4. En particulier, un intitule s'affiche lorsqu'on
Xclique dans le bouton de commande permettant ainsi de voir ce qui est execute.
X
X   - Version 1 Patchlevel 0
X   - Base sur les Athena Widgets
X   - Ecrit par Mario Dragone - CICB France
X   - Copyright 1991 Centre Interuniversitaire de Calcul de Bretagne
X
XXsh a ete teste sur Np1, SunOS 4.1.1
X
XEnvoyer commentaires et bogues a:
X     
X     dragone at cicb.fr
X
X
X
END_OF_FILE
if test 608 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(21 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
END_OF_FILE
if test 21 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'xsh.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xsh.c'\"
else
echo shar: Extracting \"'xsh.c'\" \(14973 characters\)
sed "s/^X//" >'xsh.c' <<'END_OF_FILE'
X/*
X *
X * xsh est une application X de soumission par cliquage de commandes
X * au processeur shell (telles que xterm) librement distribuable.
X * Mario Dragone en a un Copyright (1991). Vous pouvez modifier et
X * utiliser ce programme, a condition de lui envoyer les modifications. Il
X * peut etre inclus dans toute distribution, commerciale ou non, a
X * condition que cette notice et la banniere definie ci-dessous ne soient
X * pas modifies (sauf pour le numero de version) et que cette banniere
X * soit affichee a l'appel du programme. Toute contribution, correction
X * de bogue et commentaires doivent etre envoyes a :
X *
X * Mario Dragone, Centre Inter-universitaire de Calcul de Bretagne (CICB)
X *                Campus de Beaulieu
X *                35042 Rennes Cedex - France
X *                Tel: 99.36.20.00
X *
X * e-mail: dragone at cicb.fr, dragone at FRCICB81.bitnet
X */
X
X#define BANNER "xsh, version 1 -- Copyright (c) 1991 CICB"
X
X/* xsh.c : soumission de commandes a un interpreteur shell en cliquant  */
X/*	   dans un bouton de commande represente par un bitmap.		*/
X/*         9 commandes principales peuvent etre definies, chacune etant */
X/*	   associee a un bouton de la souris et un `alterateur' (Shift, */
X/*	   Control)							*/
X/*									*/
X/* Ressources :								*/
X/*         Xsh.commandBitmap						*/
X/*	   Xsh.labelFont						*/
X/*	   Xsh.actionFont						*/
X/*	   Xsh.command1							*/
X/*	   Xsh.command2							*/
X/*	   Xsh.command3							*/
X/*	   Xsh.shiftCommand1						*/
X/*	   Xsh.shiftCommand2						*/
X/*	   Xsh.shiftCommand3						*/
X/*	   Xsh.ctrlCommand1						*/
X/*	   Xsh.ctrlCommand2						*/
X/*	   Xsh.ctrlCommand3						*/
X/*	   Xsh.label1							*/
X/*	   Xsh.label2							*/
X/*	   Xsh.label3							*/
X/*	   Xsh.shiftLabel1						*/
X/*	   Xsh.shiftLabel2						*/
X/*	   Xsh.shiftLabel3						*/
X/*	   Xsh.ctrlLabel1						*/
X/*	   Xsh.ctrlLabel2						*/
X/*	   Xsh.ctrlLabel3						*/
X/*									*/
X/* De plus, toute ressource associee a un caractere du clavier peut	*/
X/* etre definie pour specifier une commande :				*/
X/*	   Xsh.<c>							*/
X/*									*/
X/* par exemple:								*/
X/*	   Xsh.s: 	rxterm sunex					*/
X/*									*/
X/* Mario Dragone, CICB le 10/01/91 					*/
X/*		  email: dragone at cicb.fr				*/
X
X#include <stdio.h>
X#include <ctype.h>
X#include <sys/signal.h>
X#include <sys/wait.h>
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Shell.h>
X
X#include <X11/Xaw/Command.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/Cardinals.h>
X
X#include "patchlevel.h"
X
X/* ---------- EXTERNES ---------- */
X
Xchar           *strtok ();
Xchar           *malloc ();
X
Xstatic void     destroy (), quit (), exec (), switchon (), switchoff (),
X                acknowledge_process (), dispatch (), exec_shell ();
X
X
X/* ---------- STATIQUES ---------- */
X
Xstatic char     banner[] = BANNER;
X
X/* Redefinition de la table de translations pour le widget de commande */
X
Xstatic XtActionsRec actionTable[] = {
X    {"quit", (XtActionProc) quit},
X    {"switchon", (XtActionProc) switchon},
X    {"switchoff", (XtActionProc) switchoff},
X    {"dispatch", (XtActionProc) dispatch},
X    {NULL, NULL}
X};
X
Xstatic String   output_translations = "\#override\n\
X	<EnterWindow>:		highlight()\n\
X	<LeaveWindow>:		reset()\n\
X	<BtnDown>:		switchon() set() \n\
X	<BtnUp>:		notify() switchoff() unset()\n\
X	<Key>q:			quit()\n\
X	s<Key>:			set() dispatch() unset()\n\
X	None<Key>:              set() dispatch() unset()";
X
X
Xstatic char     hostname[32];
X
X/* Definition des ressources */
X
Xtypedef struct _AppRessources {
X    XFontStruct    *label_font,
X                   *action_font;
X    String          label;
X    Pixmap          command_bitmap;
X}               XshResources;
X
Xstatic XshResources xsh_resources;
X
Xstatic XtResource resources[] = {
X    {"commandBitmap", "CommandBitmap", XtRBitmap, sizeof (Pixmap),
X	XtOffset (XshResources *, command_bitmap), XtRString, NULL},
X	{"label", "Label", XtRString, sizeof (String),
X	XtOffset (XshResources *, label), XtRString, hostname},
X    {"labelFont", "Font", XtRFontStruct, sizeof (XFontStruct *),
X	XtOffset (XshResources *, label_font),
X	XtRString, "-*-helvetica-medium-r-*-24-*"},
X    {"actionFont", "Font", XtRFontStruct, sizeof (XFontStruct *),
X	XtOffset (XshResources *, action_font), XtRString, "6x13"},
X};
X
XString          fallback_resources[] = {
X    "*borderWidth:	    0",
X    NULL,
X};
X
X
X/* Ces tableaux memorisent lors du premier acces les commandes associees aux
X   boutons de la souris */
X
X#define NBMAX_COMMANDES 9
X
Xstatic String   cmd[NBMAX_COMMANDES + 1];	/* commandes issues des
X						   ressouces */
Xstatic int      cmd_def[NBMAX_COMMANDES + 1];	/* 1 si la commande a deja ete
X						   referencee */
Xstatic String   cmd_lab[NBMAX_COMMANDES + 1];	/* labels issus des
X						   ressources */
Xstatic String   shellcmd[NBMAX_COMMANDES + 1];	/* commandes soumises au shell
X						   (avec &) */
X
X/* Bitmap associee au bouton de commande */
X
X#define xsh_width 64
X#define xsh_height 64
Xstatic char     xsh_bits[] = {
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0xb8, 0xc8, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x8c, 0x10, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x09, 0x1d, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x23, 0x19, 0x39, 0x00, 0x00, 0x3e, 0x00, 0x80,
X    0x21, 0x80, 0x70, 0x00, 0x00, 0xff, 0x00, 0x40, 0x24, 0x89, 0x64, 0x00,
X    0x80, 0xed, 0x03, 0x60, 0x64, 0x89, 0xe0, 0x00, 0x80, 0xbf, 0x0f, 0x20,
X    0x01, 0x82, 0x90, 0x01, 0x40, 0xf8, 0x3e, 0x20, 0x1a, 0xca, 0x88, 0x01,
X    0x40, 0xe0, 0xfb, 0x20, 0x10, 0x40, 0x84, 0x03, 0x60, 0x80, 0xef, 0xbf,
X    0x21, 0x46, 0x36, 0x03, 0x20, 0x00, 0xbe, 0x1f, 0x90, 0x5d, 0x02, 0x07,
X    0x20, 0x01, 0xf8, 0x3e, 0x96, 0xe0, 0x01, 0x06, 0x20, 0x04, 0xe0, 0xff,
X    0x64, 0xc0, 0x00, 0x06, 0x10, 0x10, 0x80, 0xff, 0x65, 0x00, 0xc1, 0x06,
X    0x10, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x06, 0x10, 0x00, 0x00, 0x00,
X    0x00, 0x33, 0x03, 0x0c, 0x90, 0x0d, 0xf0, 0x3f, 0x20, 0x01, 0x06, 0x0e,
X    0x18, 0xf0, 0x05, 0x00, 0x22, 0x30, 0x08, 0x0c, 0x08, 0x00, 0x00, 0x14,
X    0x49, 0x12, 0x0a, 0x0c, 0x08, 0x00, 0x00, 0x02, 0x48, 0x28, 0x10, 0x0c,
X    0x08, 0x00, 0x80, 0x41, 0xc4, 0x42, 0x61, 0x0c, 0x08, 0x00, 0xe0, 0xa0,
X    0x25, 0x40, 0x80, 0x0c, 0x08, 0x60, 0x1b, 0x10, 0x21, 0x51, 0x01, 0x0e,
X    0x08, 0x0c, 0x00, 0x08, 0x35, 0x5a, 0x02, 0x0e, 0x08, 0x02, 0x00, 0x24,
X    0x20, 0x13, 0x02, 0x0c, 0x08, 0x02, 0x20, 0x24, 0x81, 0x12, 0x04, 0x0c,
X    0x08, 0x01, 0x10, 0x10, 0x01, 0x12, 0x04, 0x06, 0x98, 0x00, 0x01, 0x12,
X    0x20, 0x02, 0x08, 0x06, 0x90, 0x80, 0x00, 0x11, 0x01, 0x22, 0x10, 0x07,
X    0x10, 0x60, 0x00, 0x08, 0x20, 0x40, 0x20, 0x03, 0x30, 0x10, 0x40, 0x04,
X    0x01, 0x42, 0x80, 0x01, 0x60, 0x00, 0x30, 0x04, 0x21, 0x42, 0x80, 0x00,
X    0xc0, 0x08, 0x08, 0x02, 0x01, 0x02, 0xc0, 0x00, 0x80, 0x09, 0x00, 0x02,
X    0x01, 0x80, 0x60, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00, 0x02, 0x63, 0x00,
X    0x00, 0x06, 0x04, 0x81, 0x20, 0x02, 0x38, 0x00, 0x00, 0x1e, 0x04, 0x01,
X    0x20, 0x0c, 0x18, 0x00, 0x00, 0x38, 0x04, 0x80, 0x20, 0x10, 0x0e, 0x00,
X    0x00, 0xe0, 0x04, 0x02, 0x41, 0x00, 0x07, 0x00, 0x00, 0xc0, 0x01, 0x00,
X    0x82, 0xc0, 0x03, 0x00, 0x00, 0x80, 0x03, 0x04, 0x02, 0xf1, 0x00, 0x00,
X    0x00, 0x00, 0x0e, 0x04, 0x04, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00,
X    0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff, 0xff, 0x03, 0x00, 0x00,
X    0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
X
Xstatic XFontStruct *fonte_grasse,
X               *fonte_normale;
Xstatic Widget   toplevel,
X                label;
X
Xstatic int      num_act = 0;
X
Xstatic char    *prog_name = "Xsh";
X
X
X/* -------------------- MAIN -------------------- */
X
Xmain (argc, argv)
X/**************************************************/
X    int             argc;
X    char          **argv;
X{
X    XtAppContext    app_con;
X    Widget          form,
X                    command;
X
X
X    fprintf (stderr, "%s\n", banner);
X
X    signal (SIGHUP, quit);
X    signal (SIGINT, quit);
X    signal (SIGTERM, quit);
X    signal (SIGCHLD, acknowledge_process);
X
X    gethostname (hostname, sizeof (hostname));
X
X    toplevel = XtAppInitialize (&app_con, prog_name,
X				NULL, ZERO,
X				&argc, argv, fallback_resources, NULL, ZERO);
X
X    XtGetApplicationResources (toplevel, (XtPointer) & xsh_resources, resources,
X			       XtNumber (resources), NULL, 0);
X
X    if (xsh_resources.command_bitmap == 0)
X	xsh_resources.command_bitmap =
X	  XCreateBitmapFromData (XtDisplay (toplevel),
X				 RootWindow (XtDisplay (toplevel),
X					DefaultScreen (XtDisplay (toplevel))),
X				 xsh_bits, xsh_width, xsh_height);
X
X    XtAppAddActions (app_con, actionTable, XtNumber (actionTable));
X
X    fonte_grasse = xsh_resources.label_font;
X    fonte_normale = xsh_resources.action_font;
X
X    form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL);
X
X    label = XtVaCreateManagedWidget ("label", labelWidgetClass, form,
X				     XtNlabel, xsh_resources.label,
X				     XtNfont, fonte_grasse,
X				     NULL);
X
X    command = XtVaCreateManagedWidget ("command", commandWidgetClass, form,
X					XtNfromVert, label,
X				      XtNbitmap, xsh_resources.command_bitmap,
X	       XtNtranslations, XtParseTranslationTable (output_translations),
X					NULL);
X
X    {
X	Dimension       width_l,
X	                width_c;
X
X	XtVaGetValues (label, XtNwidth, &width_l, NULL);
X	XtVaGetValues (command, XtNwidth, &width_c, NULL);
X	if (width_l > width_c)
X	    XtVaSetValues (command, XtNwidth, width_l, NULL);
X	else
X	    XtVaSetValues (label, XtNwidth, width_c, NULL);
X    }
X
X    XtAddCallback (command, XtNcallback, exec, NULL);
X    XtAddCallback (command, XtNdestroyCallback, destroy, NULL);
X
X    XtRealizeWidget (toplevel);
X    XtAppMainLoop (app_con);
X}
X
X
X
X/* ---------- CALLBACKS ---------- */
X
Xstatic void     destroy (w, client_data, call_data)
X/**************************************************/
X    Widget          w;
X    XtPointer       call_data,
X                    client_data;
X{
X    exit (0);
X}
X
X
X
Xstatic void     exec ()
X/**************************************************/
X{
X    /* NUM_ACT a ete positionne par l'action switchon et contient l'index de
X       commande a executer */
X    if (cmd[num_act] != NULL)
X	exec_shell (shellcmd[num_act]);
X    else
X	XBell (XtDisplay (toplevel), 0);
X}
X
X
X/* ---------- ACTIONS ---------- */
X
Xstatic void     quit ()
X/**************************************************/
X{
X    exit (0);
X}
X
X
X/*
X * switchon: procedure d'action switchon(), concerne uniquement l'action des
X *	 boutons de la souris.
X *       NUM_ACT est calcule pour indiquer l'index de commande en fonction du
X *	 bouton actionne.
X *       Le widget label indique temporairement la commande selectionnee
X */
Xstatic void     switchon (w, event, params, num_params)
X/**************************************************/
X    Widget          w;
X    XEvent         *event;
X    String         *params;
X    Cardinal       *num_params;
X{
X    char            command_rn[32],
X                    label_rn[32];
X    unsigned int    bouton = event->xbutton.button,
X                    etat = event->xbutton.state;
X    char           *pcom;
X
X    /* identification de la source d'evenement */
X    if (etat & ShiftMask) {
X	num_act = bouton + 3;
X	sprintf (command_rn, "shiftCommand%d", bouton);
X	sprintf (label_rn, "shiftLabel%d", bouton);
X    } else if (etat & ControlMask) {
X	num_act = bouton + 6;
X	sprintf (command_rn, "ctrlCommand%d", bouton);
X	sprintf (label_rn, "ctrlLabel%d", bouton);
X    } else {
X	num_act = bouton;
X	sprintf (command_rn, "command%d", bouton);
X	sprintf (label_rn, "label%d", bouton);
X    }
X
X    /* acces a la ressource si la commande n'a pas encore ete executee */
X    /* on positionne systematiquement le caractere d'arriere plan dans
X       la commande */
X    if (cmd_def[num_act] == 0) {
X	cmd_def[num_act] = 1;
X	cmd[num_act] = XGetDefault (XtDisplay (toplevel), prog_name, command_rn);
X	cmd_lab[num_act] = XGetDefault (XtDisplay (toplevel), prog_name, label_rn);
X	shellcmd[num_act] = malloc ((unsigned) (strlen (cmd[num_act]) + 2));
X	sprintf (shellcmd[num_act], "%s&", cmd[num_act]);
X	if (cmd_lab[num_act] == NULL) {
X	    cmd_lab[num_act] = malloc ((unsigned) (strlen (cmd[num_act]) + 1));
X	    strcpy (cmd_lab[num_act], cmd[num_act]);
X	}
X    }
X
X    /* Affichage temporaire du label specifique a la commande selectionnee */
X    if (cmd[num_act] != NULL)
X	XtVaSetValues (label, XtNfont, fonte_normale, XtNlabel,
cmd_lab[num_act], NULL);
X}
X
X
X/*
X * switchoff: procedure d'action switchoff
X *	le widget label est restaure dans son etat precedant le switchon
X */
Xstatic void     switchoff ()
X/**************************************************/
X{
X    num_act = 0;
X    XtVaSetValues (label, XtNfont, fonte_grasse, XtNlabel,
xsh_resources.label, NULL);
X}
X
X
X/*
X * dispatch: reception d'un evenement du clavier. S'il s'agit d'un caractere
X *	 la ressource Xsh.<car> est lue (mais pas memorisee) puis executee
X */
Xstatic void     dispatch (w, event, params, num_params)
X/**************************************************/
X    Widget          w;
X    XEvent         *event;
X    String         *params;
X    Cardinal       *num_params;
X{
X    char            buf[32];
X    int             nbuf;
X    KeySym          keysym;
X    XComposeStatus  status;
X    char           *cp;
X
X    if (XLookupString (event, buf, sizeof (buf), &keysym, &status) > 0) {
X	cp = XGetDefault (XtDisplay (toplevel), prog_name,
XKeysymToString (keysym));
X	if (cp == NULL)
X	    XBell (XtDisplay (toplevel), 0);
X	else {
X	    int             pid;
X	    char            cmd[256];
X	    /* on positionne le caractere d'arriere plan dans la commande */
X	    sprintf (cmd, "%s&", cp);
X	    exec_shell (cmd);
X	}
X    }
X}
X
X
X/* ---------- INTERNALS ---------- */
X
Xstatic void     exec_shell (shell_command)
X/**************************************************/
X    char           *shell_command;
X{
X    int             pid;
X
X    if ((pid = vfork ()) == 0) {
X	execlp ("/bin/sh", "sh", "-c", shell_command, NULL);
X	perror ("execlp");
X	exit (0);
X    } else if (pid == -1)
X	perror ("vfork");
X}
X
X
Xstatic void     acknowledge_process ()
X/**************************************************/
X{
X    union wait      status;
X
X    while (wait3 (&status, WNOHANG, 0) > 0) {
X    };
X}
X
END_OF_FILE
if test 14973 -ne `wc -c <'xsh.c'`; then
    echo shar: \"'xsh.c'\" unpacked with wrong size!
fi
# end of 'xsh.c'
fi
if test -f 'xsh.english' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xsh.english'\"
else
echo shar: Extracting \"'xsh.english'\" \(2985 characters\)
sed "s/^X//" >'xsh.english' <<'END_OF_FILE'
X.TH XSH n "14 january 1991"  "Xsh Version 1"
X
X.SH NAME
Xxsh \- execute shell commands
X
X.SH SYNTAX
X.B xsh
X[\fIXtoolkit args\fP]
X
X.SH DESCRIPTION
X.PP
X
XThe \fIXsh\fP program is a shell command trigger for the X Window System by
Xsimply clicking or typing single characters in the command button.
X
X
X.SH XSH WINDOW
X
XThe window is divided in two parts:
X.TP .5c
X- 
Xa \fBlabel field\fP
X.TP .5c
X- 
Xa \fBcommand button\fP figured with a bitmap image. Clicking inside will
Xchange temporarily the \fBlabel\fP field with the text of the command submited
Xor a specific text (see \fBRESOURCES\fP). The \fBq\fP character
Xterminates \fIxsh\fP. 
X
X
X.SH RESOURCES
X.PP
XThe resources allow the association of a shell command with a mouse or
Xkeyboard event as follow:
X.sp 1
X	\fBXsh.<resource>:	value\fP
X.sp 1
Xwhere \fI<resource>\fP is one of the following:
X.TP 2.5c
X\fBcommand1, command2, command3\fP
Xshell command executed when the mouse buttons are clicked in the 
X\fIcommand button\fP.
X.TP 2.5c
X\fBshiftCommand1, shiftCommand2, shiftCommand3\fP
Xshell command executed when the mouse buttons whith the \fBSHIFT\fP
Xmodifier are clicked in the \fIcommand button\fP.
X.TP 2.5c
X\fBctrlCommand1, ctrlCommand2, ctrlCommand3\fP
Xshell command executed when the mouse buttons whith the \fBCONTROL\fP
Xmodifier are clicked in the \fIcommand button\fP.
X.TP 2.5c
X\fBlabel1, label2, label3\fP
XText to display in the \fIlabel field\fP when the corresponding button events
Xoccur. By default, the shell commands are displayed.
X.TP 2.5c
X\fBshiftLabel1, shiftLabel2, shiftLabel3\fP
XText to display in the \fIlabel field\fP when the corresponding button events
Xoccur. By default, the shell commands are displayed.
X.TP 2.5c
X\fBctrlLabel1, ctrlLabel2, ctrlLabel3\fP
XText to display in the \fIlabel field\fP when the corresponding button events
Xoccur. By default, the shell commands are displayed.
X.TP 2.5c
X\fB<char>\fP
Xshell command executed if the specific \fI<char>\fP character is typed in the  
X\fIcommand button\fP.
X.TP 2.5c
X\fBlabel\fP
Xdefines the \fIlabel field\fP. The default is the name of the current host.
X.TP 2.5c
X\fBcommandBitmap\fP
Xbitmap image of the \fIcommand button\fP.
X.TP 2.5c
X\fBactionFont\fP
Xfont used to display the action label in the \fIaction field\fP 
X(\fB6x13\fP by default).
X.TP 2.5c
X\fBlabelFont\fP
Xfont used to display the permanent label in the \fIlabel field\fP
X(\fB-*-helvetica-medium-r-*-24-*\fP by default).
X.RE -2.5c
X
X.SH EXAMPLES
X
X.nf
XXsh.actionFont:         -*-times-medium-i-*-20-*
XXsh.command1:           xterm -title servix
XXsh.label1:             Servix
XXsh.command2:           rxterm iren -title iren
XXsh.label2:             Iren
XXsh.ctrlCommand1:       xmh
XXsh.s:                  xterm -title servix
XXsh.S:                  rxterm sunex -title sunex
X.fi
X
X.SH NOTES
XThe shell processor is \fBsh\fP. All commands are submited in background.
X
X
X.SH AUTHOR
X.PP
XMario Dragone
X.br
XCentre Interuniversitaire de Calcul de Bretagne
X.br
XRennes (99.36.20.00)
X.br
XFrance
X.br
X
Xdragone at cicb.fr
X
X
X
X
X
END_OF_FILE
if test 2985 -ne `wc -c <'xsh.english'`; then
    echo shar: \"'xsh.english'\" unpacked with wrong size!
fi
# end of 'xsh.english'
fi
if test -f 'xsh.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xsh.man'\"
else
echo shar: Extracting \"'xsh.man'\" \(3263 characters\)
sed "s/^X//" >'xsh.man' <<'END_OF_FILE'
X.TH XSH n "14 janvier 1991"  "Xsh Version 1"
X.so /usr/lib/ms/s.acc
X
X.SH SYNTAXE D'APPEL
X.B xsh
X[\fIXtoolkit args\fP]
X
X.SH DESCRIPTION
X.PP
X
X\fIXsh\fP est une application X permettant de soumettre des commandes au
Xprocesseur \fIshell\fP (/bin/sh) en cliquant dans le bouton de commande. Son
Xinte\*'re\*^t est de pouvoir lancer \fIrapidement\fP des applications X telles
Xque \fIxterm\fP.
X
X
X.SH LA FENETRE xsh
X
XLa fene\*^tre \fIXsh\fP est divise\*'e en deux parties :
X.TP .5c
X- 
Xun \fBlabel\fP indiquant en temps normal le nom de la machine sur laquelle
Xs'exe\*'cute \fIXsh\fP
X.TP .5c
X- 
Xun \fBbouton de commande\fP repre\*'sente\*' par un coquillage. En cliquant
Xdedans, le label indique temporairement le texte de la commande a\*`
Xexe\*'cuter. La commande \fBq\fP termine l'exe\*'cution de \fIXsh\fP.
X
X
X.SH RESSOURCES
X.PP
XLes ressources permettent d'associer une commande a\*` un bouton de la souris
Xsous la forme:
X.sp 1
X	\fBXsh.<ressource>:	valeur\fP
X.sp 1
X9 possibilite\*'s majeures sont pre\*'vues:
X.TP 2.5c
X\fBcommand1, command2, command3\fP
Xcommandes exe\*'cute\*'es lorsque le bouton 1, 2 ou 3 de la souris est 
Xclique\*' 
X.TP 2.5c
X\fBshiftCommand1, shiftCommand2, shiftCommand3\fP
Xcommandes exe\*'cute\*'es lorsque le bouton 1, 2 ou 3 de la souris est 
Xclique\*' en appuyant simultane\*'ment sur la touche SHIFT
X.TP 2.5c
X\fBctrlCommand1, ctrlCommand2, ctrlCommand3\fP
Xcommandes exe\*'cute\*'es lorsque le bouton 1, 2 ou 3 de la souris est 
Xclique\*' en appuyant simultane\*'ment sur la touche CONTROL
X
XPar de\*'faut, seule la ressource \fBcommand1\fP est de\*'finie avec la valeur
X\fBxterm\fP.
X
XD'autres ressources existent:
X.TP 2.5c
X\fBlabel1, label2, label3\fP
Xlabel affiche\*' lorsque le bouton 1, 2 ou 3 de la souris est clique\*'. Par 
Xde\*'faut, c'est le texte de la commande.
X.TP 2.5c
X\fBshiftLabel1, shiftLabel2, shiftLabel3\fP
Xlabel affiche\*' lorsque le bouton 1, 2 ou 3 de la souris est 
Xclique\*' en appuyant simultane\*'ment sur la touche SHIFT.
XPar de\*'faut, c'est le texte de la commande.
X.TP 2.5c
X\fBctrlLabel1, ctrlLabel2, ctrlLabel3\fP
Xlabel affiche\*' lorsque le bouton 1, 2 ou 3 de la souris est 
Xclique\*' en appuyant simultane\*'ment sur la touche CONTROL.
XPar de\*'faut, c'est le texte de la commande.
X.TP 2.5c
X\fIcar\fP
Xcommande a\*` exe\*'cuter si le caracte\*`re \fIcar\fP est frappe\*'. Le
Xcaracte\*`re \fBq\fP de\*'ja\*` re\*'serve\*' ne peut e\*^tre utilise\*'.
X.TP 2.5c
X\fBlabel\fP
Xlabel de l'application, le nom de la machine sur laquelle s'exe\*'cute 
X\fIxsh\fP par de\*'faut.
X.TP 2.5c
X\fBcommandBitmap\fP
Xbitmap figurant dans le bouton de commande.
X.TP 2.5c
X\fBactionFont\fP
Xpolice utilise\*'e pour afficher temporairement le texte de la commande a\*`
Xexe\*'cuter (\fB6x13\fP par de\*'faut).
X.TP 2.5c
X\fBlabelFont\fP
Xpolice utilise\*' pour afficher le label permanent de l'application \fIXsh\fP
X(\fB-*-helvetica-medium-r-*-24-*\fP par de\*'faut).
X.RE -2.5c
X
X.SH NOTES
XLes commandes sont soumises au processeur \fI/bin/sh\fP en arrie\*`re-plan. Le
Xtexte des commandes peut donc contenir toutes les constructions permises par le
X\fIshell\fP, par exemple: \fBxterm -title `hostname`\fP
X
X
X.SH AUTEUR
X.PP
XMario Dragone
X.br
XCentre Interuniversitaire de Calcul de Bretagne
X.br
XRennes (99.36.20.00)
X.br
X
Xdragone at servix.cicb.fr
X
X
X
X
X
END_OF_FILE
if test 3263 -ne `wc -c <'xsh.man'`; then
    echo shar: \"'xsh.man'\" unpacked with wrong size!
fi
# end of 'xsh.man'
fi
echo shar: End of shell archive.
exit 0
--
Dan Heller
O'Reilly && Associates       Z-Code Software    Comp-sources-x:
Senior Writer                President          comp-sources-x at uunet.uu.net
argv at ora.com                 argv at zipcode.com



More information about the Comp.sources.x mailing list