[comp.sources.x] v09i039: colxterm -- Color xterm, Part09/14

tomw@orac.esd.sgi.com (Tom Weinstein) (09/14/90)

Submitted-by: Tom Weinstein <tomw@orac.esd.sgi.com>
Posting-number: Volume 9, Issue 39
Archive-name: colxterm/part09

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then feed it
# into a shell via "sh file" or similar.  To overwrite existing files,
# type "sh file -c".
# The tool that generated this appeared in the comp.sources.unix newsgroup;
# send mail to comp-sources-unix@uunet.uu.net if you want that tool.
# If this archive is complete, you will see the following message at the end:
#		"End of archive 9 (of 14)."
# Contents:  xterm/Makefile xterm/main.c.ab xterm/termcap.vi
# Wrapped by argv@turnpike on Thu Sep 13 20:42:29 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'xterm/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xterm/Makefile'\"
else
echo shar: Extracting \"'xterm/Makefile'\" \(25588 characters\)
sed "s/^X//" >'xterm/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 sgi.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
XINSTMANDEVFLAGS = -m 0444 -i "x.man.dev"
X
X        OPTIMIZER = -O2
X
X            SHELL = /bin/sh
X
X              TOP = ../../.
X      CURRENT_DIR = ./clients/xterm
X
X               AR = ar scq
X  BOOTSTRAPCFLAGS = "$(OPTIMIZER)"
X               CC = cc
X
X         COMPRESS = compress
X              CPP = /lib/cpp $(STD_CPP_DEFINES)
X    PREPROCESSCMD = cc -E $(STD_CPP_DEFINES)
X          INSTALL = $(SCRIPTSRC)/sgiinst.sh -I$(TOOLROOT)/etc/install
X               LD = ld -L -L$(ROOT)/usr/lib
X             LINT = lint
X      LINTLIBFLAG = -o
X         LINTOPTS = -ax
X               LN = ln -s
X
X               MV = mv
X               CP = cp
X           RANLIB = /bin/true
X  RANLIBINSTFLAGS =
X               RM = rm -f
X  VENDOR_INCLUDES = -I -I$(ROOT)/usr/include
X     STD_INCLUDES =
X  STD_CPP_DEFINES = -DSYSV
X      STD_DEFINES = -DSYSV -DMALLOC_0_RETURNS_NULL
X EXTRA_LOAD_FLAGS =
X  EXTRA_LIBRARIES = -L -L$(ROOT)/usr/lib -lsun -lmalloc -lc_s
X             TAGS = ctags
X
X    SHAREDCODEDEF = -DSHAREDCODE
X         SHLIBDEF = -DATTSHAREDLIB
X
X    PROTO_DEFINES = -DFUNCPROTO -DNARROWPROTO
X
X     INSTPGMFLAGS = -s
X
X     INSTBINFLAGS = -m 0755
X     INSTUIDFLAGS = -m 4755 -u root -i "x.sw.eoe"
X     INSTLIBFLAGS = -m 0664 -i "x.sw.dev"
X     INSTINCFLAGS = -m 0444 -i "x.sw.dev"
X     INSTMANFLAGS = -m 0444 -i "x.man.eoe"
X     INSTDATFLAGS = -m 0444
X    INSTKMEMFLAGS = -m 2755 -g sys -i "x.sw.eoe"
X
X          DESTDIR =
X
X     TOP_INCLUDES = -I$(TOP)
X
X      CDEBUGFLAGS = $(OPTIMIZER)
X        CCOPTIONS = -prototypes -float
X      COMPATFLAGS =
X
X      ALLINCLUDES = $(STD_INCLUDES) $(TOP_INCLUDES) $(INCLUDES) $(EXTRA_INCLUDES) $(VENDOR_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 = -r
X
X        MACROFILE = sgi.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 = $(CONFIGSRC)
X        IMAKE_CMD = $(NEWTOP)$(IMAKE) -I$(NEWTOP)$(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/man
X    MANSOURCEPATH = $(MANPATH)/man
X           MANDIR = $(DESTDIR)/usr/catman/u_man/cat1/X11
X        LIBMANDIR = $(DESTDIR)/usr/catman/p_man/cat3
X      XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X       FONTCFLAGS = -t
X
X     INSTAPPFLAGS = $(INSTDATFLAGS)
X
X            IMAKE = $(IMAKESRC)/imake
X           DEPEND = $(DEPENDSRC)/makedepend
X              RGB = $(RGBSRC)/rgb
X            FONTC = $(BDFTOSNFSRC)/bdftosnf
X        MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X        MKDIRHIER = /bin/sh $(SCRIPTSRC)/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 =  $(EXTENSIONSRC)/lib/libXext.a
X     EXTENSIONLIB =    $(DEPEXTENSIONLIB)
X
X          DEPXLIB = $(DEPEXTENSIONLIB)
X#             XLIB = $(EXTENSIONLIB)  -L$(XLIBSRC) -lX11_s
X             XLIB = $(EXTENSIONLIB)  -L$(XLIBSRC) -lX11
X
X      DEPXAUTHLIB =  $(XAUTHSRC)/libXau.a
X         XAUTHLIB =   $(DEPXAUTHLIB)
X
X        DEPXMULIB =  $(XMUSRC)/libXmu.a
X           XMULIB =   $(DEPXMULIB)
X
X       DEPOLDXLIB =  $(OLDXLIBSRC)/liboldX.a
X          OLDXLIB =   $(DEPOLDXLIB)
X
X      DEPXTOOLLIB =  $(TOOLKITSRC)/libXt.a
X         XTOOLLIB =   $(DEPXTOOLLIB)
X
X        DEPXAWLIB =  $(AWIDGETSRC)/libXaw.a
X           XAWLIB =   $(DEPXAWLIB)
X
X LINTEXTENSIONLIB =  $(EXTENSIONSRC)/lib/llib-lXext.ln
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
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.70 90/05/04 16:57:30 keith Exp $
X
X###########################################################################
X# start of Imakefile
X
X###########################################################################
X#                                                                         #
X#                         Attention xterm porters                         #
X#                                                                         #
X#                                                                         #
X# Xterm assumes that bcopy can handle overlapping arguments.  If your     #
X# bcopy (or memcpy) can't, write a routine called bcopy and link it in    #
X# or add -Dbcopy=mybcopy to the DEFINES list below.                       #
X#                                                                         #
X###########################################################################
X
X   TTYGROUPDEF = -DUSE_TTY_GROUP
X
X   MAIN_DEFINES = -DUTMP $(TTYGROUPDEF) $(PUCCPTYDDEF) -DWTMP -DLASTLOG
X   MISC_DEFINES =
X
X          SRCS1 = button.c charproc.c cursor.c data.c input.c \
X		  main.c menu.c misc.c screen.c scrollbar.c tabs.c \
X		  TekPrsTbl.c Tekproc.c util.c VTPrsTbl.c
X          OBJS1 = main.o input.o charproc.o cursor.o util.o tabs.o \
X		  screen.o scrollbar.o button.o Tekproc.o misc.o \
X		  VTPrsTbl.o TekPrsTbl.o data.o menu.o
X          SRCS2 = resize.c
X          OBJS2 = resize.o
X           SRCS = $(SRCS1) $(SRCS2)
X           OBJS = $(OBJS1) $(OBJS2)
X       PROGRAMS = resize xterm
X       DEPLIBS1 = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
X       DEPLIBS2 =
X       PROGRAMS = xterm resize
X
X     TERMCAPLIB = -ltermlib
X
Xall:: $(PROGRAMS)
X
Xmain.o:
X	$(RM) $@ $*.os \
X	&& $(CC) -c $(CFLAGS) $(MAIN_DEFINES) $*.c \
X	&& $(LD) -x -r $@ -o $*.os \
X	&& $(MV) $*.os $@
X
Xmisc.o:
X	$(RM) $@ $*.os \
X	&& $(CC) -c $(CFLAGS) $(MISC_DEFINES) $*.c \
X	&& $(LD) -x -r $@ -o $*.os \
X	&& $(MV) $*.os $@
X
Xcharproc.o:
X	$(RM) $@ $*.os \
X	&& $(CC) -c $(CFLAGS) $(MISC_DEFINES) $*.c \
X	&& $(LD) -x -r $@ -o $*.os \
X	&& $(MV) $*.os $@
X
Xxterm: $(OBJS1) $(DEPLIBS1)
X	 $(RM) $@
X	$(CC) -o $@ $(OBJS1) $(LDOPTIONS) $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB) $(LDLIBS) $(TERMCAPLIB) $(PTYLIB) $(EXTRA_LOAD_FLAGS)
X
Xclean::
X	$(RM) xterm
X
Xinstall:: xterm
X	$(INSTALL) -c $(INSTPGMFLAGS)  $(INSTUIDFLAGS) xterm  $(BINDIR)
X
Xresize: $(OBJS2) $(DEPLIBS2)
X	 $(RM) $@
X	$(CC) -o $@ $(OBJS2) $(LDOPTIONS)   $(LDLIBS) $(TERMCAPLIB) $(EXTRA_LOAD_FLAGS)
X
Xclean::
X	$(RM) resize
X
Xinstall:: resize
X	$(INSTALL) -c $(INSTPGMFLAGS)   resize  $(BINDIR)
X
Xinstall:: XTerm.ad
X	$(INSTALL) -c $(INSTAPPFLAGS) XTerm.ad $(XAPPLOADDIR)/XTerm
X
Xall:: xterm.nr.z
X
Xxterm.nr.z : xterm.man
X	if [ -f xterm.man ]; then \
X		$(RM) xterm.nr xterm.nr.z; \
X		tbl xterm.man | eqn | nroff -man - > xterm.nr; \
X		pack -f xterm.nr; \
X	else \
X		exit 0 ; \
X	fi
X
Xinstall.man:: xterm.nr.z
X	if [ -f xterm.man ]; then \
X		$(INSTALL) -c $(INSTMANFLAGS) xterm.nr.z $(MANDIR)/xterm.z;\
X	else \
X		exit 0 ; \
X	fi
X
Xclean::
X	$(RM) xterm.nr xterm.nr.z
X
Xall:: resize.nr.z
X
Xresize.nr.z : resize.man
X	if [ -f resize.man ]; then \
X		$(RM) resize.nr resize.nr.z; \
X		tbl resize.man | eqn | nroff -man - > resize.nr; \
X		pack -f resize.nr; \
X	else \
X		exit 0 ; \
X	fi
X
Xinstall.man:: resize.nr.z
X	if [ -f resize.man ]; then \
X		$(INSTALL) -c $(INSTMANFLAGS) resize.nr.z $(MANDIR)/resize.z;\
X	else \
X		exit 0 ; \
X	fi
X
Xclean::
X	$(RM) resize.nr resize.nr.z
X
Xdepend:: $(DEPEND)
X
X$(DEPEND):
X	@echo "checking $@ over in $(DEPENDSRC) first..."; \
X	cd $(DEPENDSRC); $(MAKE); \
X	echo "okay, continuing in $(CURRENT_DIR)"
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:: $(IMAKE)
X
X$(IMAKE):
X	@(cd $(IMAKESRC); if [ -f Makefile ]; then \
X	echo "checking $@ in $(IMAKESRC) first..."; $(MAKE) all; else \
X	echo "bootstrapping $@ from Makefile.ini in $(IMAKESRC) first..."; \
X	$(MAKE) -f Makefile.ini BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS); fi; \
X	echo "okay, continuing in $(CURRENT_DIR)")
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
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
X# DO NOT DELETE
X
Xbutton.o: ../.././X11/copyright.h ptyx.h ../.././X11/IntrinsicP.h
Xbutton.o: ../.././X11/Intrinsic.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xbutton.o: ../.././X11/X.h ../.././X11/Xutil.h ../.././X11/Xresource.h
Xbutton.o: ../.././X11/Xos.h /usr/include/strings.h /usr/include/string.h
Xbutton.o: /usr/include/fcntl.h /usr/include/sys/fcntl.h
Xbutton.o: /usr/include/sys/file.h /usr/include/sys/time.h
Xbutton.o: /usr/include/sys/time.h ../.././X11/Core.h ../.././X11/Composite.h
Xbutton.o: ../.././X11/Constraint.h ../.././X11/Object.h ../.././X11/RectObj.h
Xbutton.o: ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xbutton.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h
Xbutton.o: ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xbutton.o: /usr/include/sys/signal.h ../.././X11/Xatom.h /usr/include/stdio.h
Xbutton.o: /usr/include/setjmp.h /usr/include/ctype.h ../.././X11/Xmu/Atoms.h
Xbutton.o: ../.././X11/Xmu/StdSel.h data.h error.h menu.h
Xcharproc.o: ../.././X11/copyright.h ../.././X11/Xlib.h
Xcharproc.o: /usr/include/sys/types.h ../.././X11/X.h ../.././X11/Xatom.h
Xcharproc.o: ../.././X11/Xmu/Atoms.h /usr/include/stdio.h ../.././X11/Xos.h
Xcharproc.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xcharproc.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xcharproc.o: /usr/include/sys/time.h /usr/include/sys/time.h
Xcharproc.o: /usr/include/sgtty.h /usr/include/sys/ioctl.h
Xcharproc.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h
Xcharproc.o: /usr/include/ctype.h /usr/include/errno.h
Xcharproc.o: /usr/include/sys/errno.h /usr/include/setjmp.h ptyx.h
Xcharproc.o: ../.././X11/IntrinsicP.h ../.././X11/Intrinsic.h
Xcharproc.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Core.h
Xcharproc.o: ../.././X11/Composite.h ../.././X11/Constraint.h
Xcharproc.o: ../.././X11/Object.h ../.././X11/RectObj.h ../.././X11/CoreP.h
Xcharproc.o: ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xcharproc.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xcharproc.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xcharproc.o: /usr/include/sys/signal.h VTparse.h data.h error.h main.h
Xcharproc.o: ../.././X11/cursorfont.h ../.././X11/StringDefs.h menu.h
Xcursor.o: ../.././X11/copyright.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xcursor.o: ../.././X11/X.h /usr/include/stdio.h /usr/include/sys/ioctl.h
Xcursor.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h ptyx.h
Xcursor.o: ../.././X11/IntrinsicP.h ../.././X11/Intrinsic.h
Xcursor.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Xos.h
Xcursor.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xcursor.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xcursor.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xcursor.o: ../.././X11/Composite.h ../.././X11/Constraint.h
Xcursor.o: ../.././X11/Object.h ../.././X11/RectObj.h ../.././X11/CoreP.h
Xcursor.o: ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xcursor.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h
Xcursor.o: /usr/include/signal.h /usr/include/sys/signal.h
Xdata.o: ../.././X11/copyright.h /usr/include/setjmp.h ../.././X11/Xlib.h
Xdata.o: /usr/include/sys/types.h ../.././X11/X.h ../.././X11/Intrinsic.h
Xdata.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Xos.h
Xdata.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xdata.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xdata.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xdata.o: ../.././X11/Composite.h ../.././X11/Constraint.h ../.././X11/Object.h
Xdata.o: ../.././X11/RectObj.h ptyx.h ../.././X11/IntrinsicP.h
Xdata.o: ../.././X11/CoreP.h ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xdata.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h
Xdata.o: /usr/include/signal.h /usr/include/sys/signal.h data.h
Xinput.o: ../.././X11/copyright.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xinput.o: ../.././X11/X.h ../.././X11/keysym.h ../.././X11/keysymdef.h
Xinput.o: ../.././X11/DECkeysym.h ../.././X11/Intrinsic.h ../.././X11/Xutil.h
Xinput.o: ../.././X11/Xresource.h ../.././X11/Xos.h /usr/include/strings.h
Xinput.o: /usr/include/string.h /usr/include/fcntl.h /usr/include/sys/fcntl.h
Xinput.o: /usr/include/sys/file.h /usr/include/sys/time.h
Xinput.o: /usr/include/sys/time.h ../.././X11/Core.h ../.././X11/Composite.h
Xinput.o: ../.././X11/Constraint.h ../.././X11/Object.h ../.././X11/RectObj.h
Xinput.o: /usr/include/stdio.h ptyx.h ../.././X11/IntrinsicP.h
Xinput.o: ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xinput.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h
Xinput.o: ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xinput.o: /usr/include/sys/signal.h
Xmain.o: ../.././X11/copyright.h ../.././X11/Xos.h /usr/include/sys/types.h
Xmain.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xmain.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xmain.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Xlib.h
Xmain.o: ../.././X11/X.h ../.././X11/cursorfont.h /usr/include/pwd.h
Xmain.o: /usr/include/ctype.h /usr/include/sys/ioctl.h
Xmain.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h
Xmain.o: /usr/include/sys/stat.h /usr/include/sgtty.h
Xmain.o: /usr/include/sys/resource.h /usr/include/sys/sysmacros.h
Xmain.o: /usr/include/stdio.h /usr/include/errno.h /usr/include/sys/errno.h
Xmain.o: /usr/include/setjmp.h /usr/include/utmp.h /usr/include/sys/param.h
Xmain.o: /usr/include/sys/signal.h ptyx.h ../.././X11/IntrinsicP.h
Xmain.o: ../.././X11/Intrinsic.h ../.././X11/Xutil.h ../.././X11/Xresource.h
Xmain.o: ../.././X11/Core.h ../.././X11/Composite.h ../.././X11/Constraint.h
Xmain.o: ../.././X11/Object.h ../.././X11/RectObj.h ../.././X11/CoreP.h
Xmain.o: ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xmain.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h
Xmain.o: /usr/include/signal.h data.h error.h main.h menu.h
Xmain.o: ../.././X11/StringDefs.h ../.././X11/Shell.h /usr/include/sys/wait.h
Xmenu.o: /usr/include/stdio.h ../.././X11/Intrinsic.h ../.././X11/Xlib.h
Xmenu.o: /usr/include/sys/types.h ../.././X11/X.h ../.././X11/Xutil.h
Xmenu.o: ../.././X11/Xresource.h ../.././X11/Xos.h /usr/include/strings.h
Xmenu.o: /usr/include/string.h /usr/include/fcntl.h /usr/include/sys/fcntl.h
Xmenu.o: /usr/include/sys/file.h /usr/include/sys/time.h
Xmenu.o: /usr/include/sys/time.h ../.././X11/Core.h ../.././X11/Composite.h
Xmenu.o: ../.././X11/Constraint.h ../.././X11/Object.h ../.././X11/RectObj.h
Xmenu.o: ../.././X11/StringDefs.h ../.././X11/Shell.h
Xmenu.o: ../.././X11/Xaw/SimpleMenu.h ../.././X11/Xmu/Converters.h
Xmenu.o: ../.././X11/Xaw/SmeBSB.h ../.././X11/Xaw/Sme.h
Xmenu.o: ../.././X11/Xaw/SmeLine.h ptyx.h ../.././X11/copyright.h
Xmenu.o: ../.././X11/IntrinsicP.h ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xmenu.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xmenu.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xmenu.o: /usr/include/sys/signal.h /usr/include/setjmp.h data.h menu.h
Xmisc.o: ../.././X11/copyright.h ptyx.h ../.././X11/IntrinsicP.h
Xmisc.o: ../.././X11/Intrinsic.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xmisc.o: ../.././X11/X.h ../.././X11/Xutil.h ../.././X11/Xresource.h
Xmisc.o: ../.././X11/Xos.h /usr/include/strings.h /usr/include/string.h
Xmisc.o: /usr/include/fcntl.h /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xmisc.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xmisc.o: ../.././X11/Composite.h ../.././X11/Constraint.h ../.././X11/Object.h
Xmisc.o: ../.././X11/RectObj.h ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xmisc.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xmisc.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xmisc.o: /usr/include/sys/signal.h /usr/include/stdio.h /usr/include/setjmp.h
Xmisc.o: /usr/include/ctype.h /usr/include/pwd.h ../.././X11/Xatom.h
Xmisc.o: ../.././X11/cursorfont.h ../.././X11/Shell.h ../.././X11/Xmu/Error.h
Xmisc.o: ../.././X11/Xmu/SysUtil.h ../.././X11/Xmu/WinUtil.h data.h error.h
Xmisc.o: menu.h
Xscreen.o: ../.././X11/copyright.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xscreen.o: ../.././X11/X.h /usr/include/stdio.h /usr/include/sys/ioctl.h
Xscreen.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h ptyx.h
Xscreen.o: ../.././X11/IntrinsicP.h ../.././X11/Intrinsic.h
Xscreen.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Xos.h
Xscreen.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xscreen.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xscreen.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xscreen.o: ../.././X11/Composite.h ../.././X11/Constraint.h
Xscreen.o: ../.././X11/Object.h ../.././X11/RectObj.h ../.././X11/CoreP.h
Xscreen.o: ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xscreen.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h
Xscreen.o: /usr/include/signal.h /usr/include/sys/signal.h error.h
Xscrollbar.o: ../.././X11/copyright.h /usr/include/stdio.h
Xscrollbar.o: /usr/include/ctype.h /usr/include/setjmp.h ../.././X11/Xatom.h
Xscrollbar.o: ptyx.h ../.././X11/IntrinsicP.h ../.././X11/Intrinsic.h
Xscrollbar.o: ../.././X11/Xlib.h /usr/include/sys/types.h ../.././X11/X.h
Xscrollbar.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Xos.h
Xscrollbar.o: /usr/include/strings.h /usr/include/string.h
Xscrollbar.o: /usr/include/fcntl.h /usr/include/sys/fcntl.h
Xscrollbar.o: /usr/include/sys/file.h /usr/include/sys/time.h
Xscrollbar.o: /usr/include/sys/time.h ../.././X11/Core.h
Xscrollbar.o: ../.././X11/Composite.h ../.././X11/Constraint.h
Xscrollbar.o: ../.././X11/Object.h ../.././X11/RectObj.h ../.././X11/CoreP.h
Xscrollbar.o: ../.././X11/CompositeP.h ../.././X11/ConstrainP.h
Xscrollbar.o: ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xscrollbar.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xscrollbar.o: /usr/include/sys/signal.h ../.././X11/StringDefs.h
Xscrollbar.o: ../.././X11/Shell.h ../.././X11/Xaw/Scrollbar.h
Xscrollbar.o: ../.././X11/Xmu/Converters.h data.h error.h menu.h
Xtabs.o: ../.././X11/copyright.h ../.././X11/Xlib.h /usr/include/sys/types.h
Xtabs.o: ../.././X11/X.h ptyx.h ../.././X11/IntrinsicP.h
Xtabs.o: ../.././X11/Intrinsic.h ../.././X11/Xutil.h ../.././X11/Xresource.h
Xtabs.o: ../.././X11/Xos.h /usr/include/strings.h /usr/include/string.h
Xtabs.o: /usr/include/fcntl.h /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xtabs.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xtabs.o: ../.././X11/Composite.h ../.././X11/Constraint.h ../.././X11/Object.h
Xtabs.o: ../.././X11/RectObj.h ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xtabs.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xtabs.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xtabs.o: /usr/include/sys/signal.h
XTekPrsTbl.o: ../.././X11/copyright.h Tekparse.h
XTekproc.o: ../.././X11/copyright.h ../.././X11/Xos.h /usr/include/sys/types.h
XTekproc.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
XTekproc.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
XTekproc.o: /usr/include/sys/time.h /usr/include/sys/time.h ptyx.h
XTekproc.o: ../.././X11/IntrinsicP.h ../.././X11/Intrinsic.h
XTekproc.o: ../.././X11/Xlib.h ../.././X11/X.h ../.././X11/Xutil.h
XTekproc.o: ../.././X11/Xresource.h ../.././X11/Core.h ../.././X11/Composite.h
XTekproc.o: ../.././X11/Constraint.h ../.././X11/Object.h
XTekproc.o: ../.././X11/RectObj.h ../.././X11/CoreP.h ../.././X11/CompositeP.h
XTekproc.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h
XTekproc.o: ../.././X11/RectObjP.h ../.././X11/Xmu/Misc.h
XTekproc.o: /usr/include/signal.h /usr/include/sys/signal.h
XTekproc.o: ../.././X11/Xatom.h ../.././X11/cursorfont.h
XTekproc.o: ../.././X11/StringDefs.h ../.././X11/Shell.h
XTekproc.o: ../.././X11/Xmu/CharSet.h Tekparse.h /usr/include/stdio.h
XTekproc.o: /usr/include/sgtty.h /usr/include/sys/ioctl.h
XTekproc.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h
XTekproc.o: /usr/include/ctype.h /usr/include/errno.h /usr/include/sys/errno.h
XTekproc.o: /usr/include/setjmp.h /usr/include/pwd.h data.h error.h menu.h
Xutil.o: ../.././X11/copyright.h /usr/include/stdio.h ../.././X11/Intrinsic.h
Xutil.o: ../.././X11/Xlib.h /usr/include/sys/types.h ../.././X11/X.h
Xutil.o: ../.././X11/Xutil.h ../.././X11/Xresource.h ../.././X11/Xos.h
Xutil.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xutil.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xutil.o: /usr/include/sys/time.h /usr/include/sys/time.h ../.././X11/Core.h
Xutil.o: ../.././X11/Composite.h ../.././X11/Constraint.h ../.././X11/Object.h
Xutil.o: ../.././X11/RectObj.h /usr/include/setjmp.h ptyx.h
Xutil.o: ../.././X11/IntrinsicP.h ../.././X11/CoreP.h ../.././X11/CompositeP.h
Xutil.o: ../.././X11/ConstrainP.h ../.././X11/ObjectP.h ../.././X11/RectObjP.h
Xutil.o: ../.././X11/Xmu/Misc.h /usr/include/signal.h
Xutil.o: /usr/include/sys/signal.h data.h error.h menu.h
XVTPrsTbl.o: ../.././X11/copyright.h VTparse.h
Xresize.o: ../.././X11/copyright.h ../.././X11/Xos.h /usr/include/sys/types.h
Xresize.o: /usr/include/strings.h /usr/include/string.h /usr/include/fcntl.h
Xresize.o: /usr/include/sys/fcntl.h /usr/include/sys/file.h
Xresize.o: /usr/include/sys/time.h /usr/include/sys/time.h
Xresize.o: /usr/include/stdio.h /usr/include/ctype.h /usr/include/sys/ioctl.h
Xresize.o: /usr/include/net/soioctl.h /usr/include/sys/termio.h
Xresize.o: /usr/include/signal.h /usr/include/sys/signal.h /usr/include/pwd.h
END_OF_FILE
if test 25588 -ne `wc -c <'xterm/Makefile'`; then
    echo shar: \"'xterm/Makefile'\" unpacked with wrong size!
fi
# end of 'xterm/Makefile'
fi
if test -f 'xterm/main.c.ab' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xterm/main.c.ab'\"
else
echo shar: Extracting \"'xterm/main.c.ab'\" \(26214 characters\)
sed "s/^X//" >'xterm/main.c.ab' <<'END_OF_FILE'
X	mode = 1;
X	if (ioctl (pty, FIONBIO, (char *)&mode) == -1) SysError (ERROR_FIONBIO);
X#endif	/* USE_SYSV_TERMIO */
X	
X	pty_mask = 1 << pty;
X	X_mask = 1 << Xsocket;
X	Select_mask = pty_mask | X_mask;
X	max_plus1 = (pty < Xsocket) ? (1 + Xsocket) : (1 + pty);
X
X#ifdef DEBUG
X	if (debug) printf ("debugging on\n");
X#endif	/* DEBUG */
X	XSetErrorHandler(xerror);
X	XSetIOErrorHandler(xioerror);
X	for( ; ; ) {
X		if(screen->TekEmu) {
X			TekRun();
X		} else
X			VTRun();
X	}
X}
X
Xchar *basename(name)
Xchar *name;
X{
X	register char *cp;
X#ifndef sgi
X	char *rindex();
X#endif /* sgi */
X
X	return((cp = rindex(name, '/')) ? cp + 1 : name);
X}
X
X/* This function opens up a pty master and stuffs it's value into pty.
X * If it finds one, it returns a value of 0.  If it does not find one,
X * it returns a value of !0.  This routine is designed to be re-entrant,
X * so that if a pty master is found and later, we find that the slave
X * has problems, we can re-enter this function and get another one.
X */
X
Xget_pty (pty)
Xint *pty;
X{
X#ifdef att
X	if ((*pty = open ("/dev/ptmx", O_RDWR)) < 0) {
X	    return 1;
X	}
X	return 0;
X#else /* !att, need lots of code */
X#ifdef USE_GET_PSEUDOTTY
X	return ((*pty = getpseudotty (&ttydev, &ptydev)) >= 0 ? 0 : 1);
X#else
X	static int devindex, letter = 0;
X
X#if defined sgi || (defined (umips) && defined (SYSTYPE_SYSV))
X	struct stat fstat_buf;
X
X	*pty = open ("/dev/ptc", O_RDWR);
X	if (*pty < 0 || (fstat (*pty, &fstat_buf)) < 0) {
X	  return(1);
X	}
X	sprintf (ttydev, "/dev/ttyq%d", minor(fstat_buf.st_rdev));
X#if !defined sgi
X	sprintf (ptydev, "/dev/ptyq%d", minor(fstat_buf.st_rdev));
X	if ((*tty = open (ttydev, O_RDWR)) < 0) {
X	  close (*pty);
X	  return(1);
X	}
X#endif /* ! sgi */
X	/* got one! */
X	return(0);
X#else /* not (umips && SYSTYPE_SYSV) */
X#ifdef CRAY
X	for (; devindex < 256; devindex++) {
X	    sprintf (ttydev, "/dev/ttyp%03d", devindex);
X	    sprintf (ptydev, "/dev/pty/%03d", devindex);
X
X	    if ((*pty = open (ptydev, O_RDWR)) >= 0) {
X		/* We need to set things up for our next entry
X		 * into this function!
X		 */
X		(void) devindex++;
X		return(0);
X	    }
X	}
X#else /* !CRAY */
X	while (PTYCHAR1[letter]) {
X	    ttydev [strlen(ttydev) - 2]  = ptydev [strlen(ptydev) - 2] =
X		    PTYCHAR1 [letter];
X
X	    while (PTYCHAR2[devindex]) {
X		ttydev [strlen(ttydev) - 1] = ptydev [strlen(ptydev) - 1] =
X			PTYCHAR2 [devindex];
X		if ((*pty = open (ptydev, O_RDWR)) >= 0) {
X			/* We need to set things up for our next entry
X			 * into this function!
X			 */
X			(void) devindex++;
X			return(0);
X		}
X		devindex++;
X	    }
X	    devindex = 0;
X	    (void) letter++;
X	}
X#endif /* CRAY else not CRAY */
X	/* We were unable to allocate a pty master!  Return an error
X	 * condition and let our caller terminate cleanly.
X	 */
X	return(1);
X#endif /* umips && SYSTYPE_SYSV */
X#endif /* USE_GET_PSEUDOTTY */
X#endif /* att */
X}
X
Xget_terminal ()
X/* 
X * sets up X and initializes the terminal structure except for term.buf.fildes.
X */
X{
X	register TScreen *screen = &term->screen;
X	
X	screen->arrow = make_colored_cursor (XC_left_ptr, 
X					     screen->mousecolor,
X					     screen->mousecolorback);
X}
X
X/*
X * The only difference in /etc/termcap between 4014 and 4015 is that 
X * the latter has support for switching character sets.  We support the
X * 4015 protocol, but ignore the character switches.  Therefore, we should
X * probably choose 4014 over 4015.
X */
X
Xstatic char *tekterm[] = {
X	"tek4014",
X	"tek4015",		/* has alternate character set switching */
X	"tek4013",
X	"tek4010",
X	"dumb",
X	0
X};
X
Xstatic char *vtterm[] = {
X#ifdef USE_X11TERM
X	"x11term",		/* for people who want special term name */
X#endif
X	"xterm",		/* the prefered name, should be fastest */
X	"vt102",
X	"vt100",
X	"ansi",
X	"dumb",
X	0
X};
X
X/* ARGSUSED */
XSIGNAL_T hungtty(i)
X	int i;
X{
X	longjmp(env, 1);
X	SIGNAL_RETURN;
X}
X
X#ifdef USE_HANDSHAKE
Xtypedef enum {		/* c == child, p == parent                        */
X	PTY_BAD,	/* c->p: can't open pty slave for some reason     */
X	PTY_FATALERROR,	/* c->p: we had a fatal error with the pty        */
X	PTY_GOOD,	/* c->p: we have a good pty, let's go on          */
X	PTY_NEW,	/* p->c: here is a new pty slave, try this        */
X	PTY_NOMORE,	/* p->c; no more pty's, terminate                 */
X	UTMP_ADDED,	/* c->p: utmp entry has been added                */
X	UTMP_TTYSLOT,	/* c->p: here is my ttyslot                       */
X	PTY_EXEC	/* p->c: window has been mapped the first time    */
X} status_t;
X
Xtypedef struct {
X	status_t status;
X	int error;
X	int fatal_error;
X	int tty_slot;
X	int rows;
X	int cols;
X	char buffer[1024];
X} handshake_t;
X
X/* HsSysError()
X *
X * This routine does the equivalent of a SysError but it handshakes
X * over the errno and error exit to the master process so that it can
X * display our error message and exit with our exit code so that the
X * user can see it.
X */
X
Xvoid
XHsSysError(pf, error)
Xint pf;
Xint error;
X{
X	handshake_t handshake;
X
X	handshake.status = PTY_FATALERROR;
X	handshake.error = errno;
X	handshake.fatal_error = error;
X	strcpy(handshake.buffer, ttydev);
X	write(pf, &handshake, sizeof(handshake));
X	exit(error);
X}
X
Xstatic int pc_pipe[2];	/* this pipe is used for parent to child transfer */
Xstatic int cp_pipe[2];	/* this pipe is used for child to parent transfer */
X
Xfirst_map_occurred ()
X{
X    handshake_t handshake;
X    register TScreen *screen = &term->screen;
X
X    if (screen->max_row > 0 && screen->max_col > 0) {
X	handshake.status = PTY_EXEC;
X	handshake.rows = screen->max_row;
X	handshake.cols = screen->max_col;
X	write (pc_pipe[1], (char *) &handshake, sizeof(handshake));
X	close (cp_pipe[0]);
X	close (pc_pipe[1]);
X	waiting_for_initial_map = False;
X    }
X}
X#else
X/*
X * temporary hack to get xterm working on att ptys
X */
Xfirst_map_occurred ()
X{
X    return;
X}
X#define HsSysError(a,b)
X#endif /* USE_HANDSHAKE else !USE_HANDSHAKE */
X
X
Xspawn ()
X/* 
X *  Inits pty and tty and forks a login process.
X *  Does not close fd Xsocket.
X *  If slave, the pty named in passedPty is already open for use
X */
X{
X	extern char *SysErrorMsg();
X	register TScreen *screen = &term->screen;
X	int Xsocket = screen->display->fd;
X#ifdef USE_HANDSHAKE
X	handshake_t handshake;
X#else
X	int fds[2];
X#endif
X	int tty = -1;
X	int done;
X#ifdef USE_SYSV_TERMIO
X	struct termio tio;
X#else	/* else not USE_SYSV_TERMIO */
X	struct tchars tc;
X	struct sgttyb sg;
X#endif	/* USE_SYSV_TERMIO */
X#ifdef TIOCSETD
X	int discipline;
X#ifdef NTTYDISC
X	int ldisc = 0;
X#endif
X#endif
X#ifdef TIOCLSET
X	unsigned lmode;
X#endif	/* TIOCLSET */
X#ifdef TIOCSLTC
X	struct ltchars ltc;
X#endif	/* TIOCSLTC */
X
X#if !defined USE_SYSV_ENVVARS && defined USE_TERMCAP
X	char termcap [1024];
X	char newtc [1024];
X#endif /* !defined USE_SYSV_ENVVARS && defined USE_TERMCAP */
X	char *ptr, *shname, *shname_minus;
X	int i, no_dev_tty = FALSE;
X#ifdef USE_SYSV_TERMIO
X	char *dev_tty_name = (char *) 0;
X	int fd;			/* for /etc/wtmp */
X#endif	/* USE_SYSV_TERMIO */
X	char **envnew;		/* new environment */
X	char buf[32];
X	char *TermName = NULL;
X#ifdef sun
X#ifdef TIOCSSIZE
X	struct ttysize ts;
X#endif	/* TIOCSSIZE */
X#else	/* not sun */
X#ifdef TIOCSWINSZ
X	struct winsize ws;
X#endif	/* TIOCSWINSZ */
X#endif	/* sun */
X	struct passwd *pw = NULL;
X#ifdef UTMP
X	struct utmp utmp;
X#ifdef LASTLOG
X	struct lastlog lastlog;
X#endif	/* LASTLOG */
X#endif	/* UTMP */
X
X	screen->uid = getuid();
X	screen->gid = getgid();
X
X#ifdef SIGTTOU
X	/* so that TIOCSWINSZ || TIOCSIZE doesn't block */
X	signal(SIGTTOU,SIG_IGN);
X#endif
X
X	if (am_slave) {
X		screen->respond = am_slave;
X		ptydev[strlen(ptydev) - 2] = ttydev[strlen(ttydev) - 2] =
X			passedPty[0];
X		ptydev[strlen(ptydev) - 1] = ttydev[strlen(ttydev) - 1] =
X			passedPty[1];
X
X		setgid (screen->gid);
X		setuid (screen->uid);
X	} else {
X		Bool tty_got_hung = False;
X
X 		/*
X 		 * Sometimes /dev/tty hangs on open (as in the case of a pty
X 		 * that has gone away).  Simply make up some reasonable
X 		 * defaults.
X 		 */
X 		signal(SIGALRM, hungtty);
X 		alarm(2);		/* alarm(1) might return too soon */
X 		if (! setjmp(env)) {
X 			tty = open ("/dev/tty", O_RDWR, 0);
X 			alarm(0);
X 		} else {
X			tty_got_hung = True;
X 			tty = -1;
X 			errno = ENXIO;
X 		}
X 		signal(SIGALRM, SIG_DFL);
X 
X		/*
X		 * Check results and ignore current control terminal if
X		 * necessary.  ENXIO is what is normally returned if there is
X		 * no controlling terminal, but some systems (e.g. SunOS 4.0)
X		 * seem to return EIO.
X		 */
X 		if (tty < 0) {
X			if (tty_got_hung || errno == ENXIO || errno == EIO) {
X				no_dev_tty = TRUE;
X#ifdef USE_SYSV_TERMIO
X				tio = d_tio;
X#else	/* not USE_SYSV_TERMIO */
X				sg = d_sg;
X				tc = d_tc;
X#endif	/* USE_SYSV_TERMIO */
X#ifdef TIOCSETD
X				discipline = d_disipline;
X#endif /* TIOCSETD */
X#ifdef TIOCSLTC
X				ltc = d_ltc;
X#endif	/* TIOCSLTC */
X#ifdef TIOCLSET
X				lmode = d_lmode;
X#endif	/* TIOCLSET */
X			} else {
X			    SysError(ERROR_OPDEVTTY);
X			}
X		} else {
X			/* get a copy of the current terminal's state */
X
X#ifdef USE_SYSV_TERMIO
X			if(ioctl(tty, TCGETA, &tio) == -1)
X				SysError(ERROR_TIOCGETP);
X#else	/* not USE_SYSV_TERMIO */
X			if(ioctl(tty, TIOCGETP, (char *)&sg) == -1)
X				SysError (ERROR_TIOCGETP);
X			if(ioctl(tty, TIOCGETC, (char *)&tc) == -1)
X				SysError (ERROR_TIOCGETC);
X#endif	/* USE_SYSV_TERMIO */
X
X#ifdef TIOCSETD
X			if(ioctl(tty, TIOCGETD, (char *)&discipline) == -1)
X				SysError (ERROR_TIOCGETD);
X#endif /* TIOCSETD */
X#ifdef TIOCSLTC
X			if(ioctl(tty, TIOCGLTC, &ltc) == -1)
X				SysError(ERROR_TIOCGLTC);
X#endif	/* TIOCSLTC */
X#ifdef TIOCLSET
X			if(ioctl(tty, TIOCLGET, &lmode) == -1)
X				SysError(ERROR_TIOCLGET);
X#endif	/* TIOCLSET */
X			close (tty);
X			/* tty is no longer an open fd! */
X			tty = -1;
X		}
X
X#ifdef 	PUCC_PTYD
X		if(-1 == (screen->respond = openrpty(ttydev, ptydev,
X				(resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN),
X				getuid(), XDisplayString(screen->display)))) {
X#else /* not PUCC_PTYD */
X		if (get_pty (&screen->respond)) {
X#endif /* PUCC_PTYD */
X			/*  no ptys! */
X			(void) fprintf(stderr, "%s: no available ptys\n",
X				       xterm_name);
X			exit (ERROR_PTYS);
X#ifdef PUCC_PTYD
X		}
X#else
X		}			/* keep braces balanced for emacs */
X#endif
X#ifdef PUCC_PTYD
X		  else {
X			/*
X			 *  set the fd of the master in a global var so
X			 *  we can undo all this on exit
X			 *
X			 */
X			Ptyfd = screen->respond;
X		  }
X#endif /* PUCC_PTYD */
X	}
X
X	/* avoid double MapWindow requests */
X	XtSetMappedWhenManaged( screen->TekEmu ? XtParent(tekWidget) :
X			        XtParent(term), False );
X        /* Realize the Tek or VT widget, depending on which mode we're in.
X           If VT mode, this calls VTRealize (the widget's Realize proc) */
X        XtRealizeWidget (screen->TekEmu ? XtParent(tekWidget) :
X			 XtParent(term));
X
X	if(screen->TekEmu) {
X		envnew = tekterm;
X#if defined USE_TERMCAP
X		ptr = newtc;
X#endif /* defined USE_TERMCAP */
X	} else {
X		envnew = vtterm;
X#if defined USE_TERMCAP
X		ptr = termcap;
X#endif /* defined USE_TERMCAP */
X	}
X	TermName = NULL;
X	if (resource.term_name) {
X	    if (tgetent (ptr, resource.term_name) == 1) {
X		TermName = resource.term_name;
X#if !defined USE_SYSV_ENVVARS && defined USE_TERMCAP
X		if (!screen->TekEmu)
X		    resize (screen, TermName, termcap, newtc);
X#endif /* !defined USE_SYSV_ENVVARS && defined USE_TERMCAP */
X	    } else {
X		fprintf (stderr, "%s:  invalid termcap entry \"%s\".\n",
X			 ProgramName, resource.term_name);
X	    }
X	}
X	if (!TermName) {
X	    while (*envnew != NULL) {
X		if(tgetent(ptr, *envnew) == 1) {
X			TermName = *envnew;
X#if !defined USE_SYSV_ENVVARS && defined USE_TERMCAP
X			if(!screen->TekEmu)
X			    resize(screen, TermName, termcap, newtc);
X#endif /* !defined USE_SYSV_ENVVARS && defined USE_TERMCAP */
X			break;
X		}
X		envnew++;
X	    }
X	    if (TermName == NULL) {
X		fprintf (stderr, "%s:  unable to find usable termcap entry.\n",
X			 ProgramName);
X		Exit (1);
X	    }
X	}
X
X#ifdef sun
X#ifdef TIOCSSIZE
X	/* tell tty how big window is */
X	if(screen->TekEmu) {
X		ts.ts_lines = 38;
X		ts.ts_cols = 81;
X	} else {
X		ts.ts_lines = screen->max_row + 1;
X		ts.ts_cols = screen->max_col + 1;
X	}
X#endif	/* TIOCSSIZE */
X#else	/* not sun */
X#ifdef TIOCSWINSZ
X	/* tell tty how big window is */
X	if(screen->TekEmu) {
X		ws.ws_row = 38;
X		ws.ws_col = 81;
X		ws.ws_xpixel = TFullWidth(screen);
X		ws.ws_ypixel = TFullHeight(screen);
X	} else {
X		ws.ws_row = screen->max_row + 1;
X		ws.ws_col = screen->max_col + 1;
X		ws.ws_xpixel = FullWidth(screen);
X		ws.ws_ypixel = FullHeight(screen);
X	}
X#endif	/* TIOCSWINSZ */
X#endif	/* sun */
X
X	if (!am_slave) {
X#ifdef USE_HANDSHAKE
X	    if (pipe(pc_pipe) || pipe(cp_pipe))
X		SysError (ERROR_FORK);
X#endif
X	    if ((screen->pid = fork ()) == -1)
X		SysError (ERROR_FORK);
X		
X	    if (screen->pid == 0) {
X		/*
X		 * now in child process
X		 */
X		extern char **environ;
X		int pgrp = getpid();
X#ifdef USE_SYSV_TERMIO
X		char numbuf[12];
X#endif	/* USE_SYSV_TERMIO */
X
X#ifndef USE_HANDSHAKE
X		int ptyfd;
X
X		setpgrp();
X		grantpt (screen->respond);
X		unlockpt (screen->respond);
X		if ((ptyfd = open (ptsname(screen->respond), O_RDWR)) < 0) {
X		    SysError (1);
X		}
X		if (ioctl (ptyfd, I_PUSH, "ptem") < 0) {
X		    SysError (2);
X		}
X		if (!getenv("CONSEM") && ioctl (ptyfd, I_PUSH, "consem") < 0) {
X		    SysError (3);
X		}
X		if (ioctl (ptyfd, I_PUSH, "ldterm") < 0) {
X		    SysError (4);
X		}
X		tty = ptyfd;
X		close (screen->respond);
X#ifdef TIOCSWINSZ
X                /* tell tty how big window is */
X                if(screen->TekEmu) {
X                        ws.ws_row = 24;
X                        ws.ws_col = 80;
X                        ws.ws_xpixel = TFullWidth(screen);
X                        ws.ws_ypixel = TFullHeight(screen);
X                } else {
X                        ws.ws_row = screen->max_row + 1;
X                        ws.ws_col = screen->max_col + 1;
X                        ws.ws_xpixel = FullWidth(screen);
X                        ws.ws_ypixel = FullHeight(screen);
X                }
X#endif
X
X
X#else /* USE_HANDSHAKE:  warning, goes for a long ways */
X		/* close parent's sides of the pipes */
X		close (cp_pipe[0]);
X		close (pc_pipe[1]);
X
X		/* Make sure that our sides of the pipes are not in the
X		 * 0, 1, 2 range so that we don't fight with stdin, out
X		 * or err.
X		 */
X		if (cp_pipe[1] <= 2) {
X			if ((i = fcntl(cp_pipe[1], F_DUPFD, 3)) >= 0) {
X				(void) close(cp_pipe[1]);
X				cp_pipe[1] = i;
X			}
X		}
X		if (pc_pipe[0] <= 2) {
X			if ((i = fcntl(pc_pipe[0], F_DUPFD, 3)) >= 0) {
X				(void) close(pc_pipe[0]);
X				pc_pipe[0] = i;
X			}
X		}
X
X		/* we don't need the socket, or the pty master anymore */
X		close (Xsocket);
X		close (screen->respond);
X
X		/* Now is the time to set up our process group and
X		 * open up the pty slave.
X		 */
X#ifdef att
X		/* If we set our process group here any later
X		 * attempt to set out session will fail
X		 */
X		(void) setpgrp();
X#endif /* att */
X		while (1) {
X#ifdef TIOCNOTTY
X			if (!no_dev_tty && (tty = open ("/dev/tty", O_RDWR)) >= 0) {
X				ioctl (tty, TIOCNOTTY, (char *) NULL);
X#ifdef sgi
X#ifdef __KERNEL_BUSTED__TIOCNOTTY_MAKES_PROC_GROUP_LEADER__
X				BSDsetpgrp( 0, 0 ) ;
X#endif /* __KERNEL_BUSTED__TIOCNOTTY_MAKES_PROC_GROUP_LEADER__ */
X#endif /* sgi */
X				close (tty);
X			}
X#ifdef att
X			/* If this "unix" has TIOCNOTTY, we may need
X			 * to recreate our process group in order to
X			 * open "/dev/tty" !
X			 */
X			(void) setpgrp();
X#endif /* att */
X#endif	/* TIOCNOTTY */
X			if ((tty = open(ttydev, O_RDWR, 0)) >= 0) {
X#ifdef att
X				/* We need to make sure that we are acutally
X				 * the process group leader for the pty.  If
X				 * we are, then we should now be able to open
X				 * /dev/tty.
X				 */
X				if ((i = open("/dev/tty", O_RDWR, 0)) >= 0) {
X					/* success! */
X					close(i);
X					break;
X				}
X#else /* !att */
X				break;
X#endif /* att */
X			}
X
X#ifdef TIOCSCTTY
X			ioctl(tty, TIOCSCTTY, 0);
X#endif
X			/* let our master know that the open failed */
X			handshake.status = PTY_BAD;
X			handshake.error = errno;
X			strcpy(handshake.buffer, ttydev);
X			write(cp_pipe[1], (char *) &handshake,
X			    sizeof(handshake));
X
X			/* get reply from parent */
X			i = read(pc_pipe[0], (char *) &handshake,
X			    sizeof(handshake));
X			if (i <= 0) {
X				/* parent terminated */
X				exit(1);
X			}
X
X			if (handshake.status == PTY_NOMORE) {
X				/* No more ptys, let's shutdown. */
X				exit(1);
X			}
X
X			/* We have a new pty to try */
X			free(ttydev);
X			ttydev = malloc((unsigned)
X			    (strlen(handshake.buffer) + 1));
X			strcpy(ttydev, handshake.buffer);
X		}
X
X		/* Now that we have our new tty, let's make
X		** ourselves the process (and session) group(s)
X		** leader.
X		** NOTE: to become the session group leader you
X		**	 MUST NOT YET be a process group leader !
X		**	 ( sorry att )
X		*/
X#ifndef USE_SYSV_PGRP
X		(void) setpgrp( 0, 0 ) ;
X#endif /* USE_SYSV_PGRP */
X#ifdef TIOCSCTTY
X		(void) ioctl( 0, TIOCSCTTY, 0 ) ;
X#endif
X#ifdef HAS_POSIX_SESSIONS
X		if ( setsid() == pgrp )
X			/* NOTE: we no longer have any controlling tty ! */
X			(void) close( open( ttydev, O_WRONLY, 0 ) ) ;
X#endif
X#ifdef TIOCSCTTY
X		(void) ioctl( 0, TIOCSCTTY, (char *) &pgrp ) ;
X#endif
X#ifdef USE_SYSV_PGRP
X		(void) setpgrp() ;
X#else
X		(void) setpgrp( 0, pgrp ) ;
X#endif /* USE_SYSV_PGRP */
X		(void) close( open( ttydev, O_WRONLY, 0 ) ) ;
X#ifdef TIOCSPGRP
X		(void) ioctl( 0, TIOCSPGRP, (char *) &pgrp ) ;
X#endif
X
X		/* use the same tty name that everyone else will use
X		** (from ttyname)
X		*/
X		if (ptr = ttyname(tty))
X		{
X			/* it may be bigger */
X			ttydev = realloc (ttydev, (unsigned) (strlen(ptr) + 1));
X			(void) strcpy(ttydev, ptr);
X		}
X
X#endif /* !USE_HANDSHAKE else USE_HANDSHAKE - from near fork */
X
X#ifdef USE_TTY_GROUP
X	{ 
X#include <grp.h>
X		struct group *ttygrp;
X		if (ttygrp = getgrnam("tty")) {
X			/* change ownership of tty to real uid, "tty" gid */
X			chown (ttydev, screen->uid, ttygrp->gr_gid);
X			chmod (ttydev, 0620);
X		}
X		else {
X			/* change ownership of tty to real group and user id */
X			chown (ttydev, screen->uid, screen->gid);
X			chmod (ttydev, 0622);
X		}
X		endgrent();
X	}
X#else /* else !USE_TTY_GROUP */
X		/* change ownership of tty to real group and user id */
X		chown (ttydev, screen->uid, screen->gid);
X
X		/* change protection of tty */
X		chmod (ttydev, 0622);
X#endif /* USE_TTY_GROUP */
X
X		/*
X		 * set up the tty modes
X		 */
X		{
X#ifdef USE_SYSV_TERMIO
X#ifdef umips
X		    /* If the control tty had its modes screwed around with,
X		       eg. by lineedit in the shell, or emacs, etc. then tio
X		       will have bad values.  Let's just get termio from the
X		       new tty and tailor it.  */
X		    if (ioctl (tty, TCGETA, &tio) == -1)
X		      SysError (ERROR_TIOCGETP);
X		    tio.c_lflag |= ECHOE;
X#endif /* umips */
X		    /* Now is also the time to change the modes of the
X		     * child pty.
X		     */
X		    /* input: nl->nl, don't ignore cr, cr->nl */
X		    tio.c_iflag &= ~(INLCR|IGNCR);
X		    tio.c_iflag |= ICRNL;
X		    /* ouput: cr->cr, nl is not return, no delays, ln->cr/nl */
X		    tio.c_oflag &=
X		     ~(OCRNL|ONLRET|NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
X		    tio.c_oflag |= ONLCR;
X		    tio.c_cflag &= ~(CBAUD);
X#ifdef BAUD_0
X		    /* Do Nothing */
X#else	/* !BAUD_0 */
X#ifdef B38400
X		    tio.c_cflag |= B38400;
X#else	/* !B38400 */
X#ifdef B19200
X		    tio.c_cflag |= B19200;
X#else	/* !B19200 */
X		    tio.c_cflag |= B9600;
X#endif	/* !B19200 */
X#endif	/* !B38400 */
X#endif	/* !BAUD_0 */
X		    /* enable signals, canonical processing (erase, kill, etc),
X		    ** echo
X		    */
X		    tio.c_lflag |= ISIG|ICANON|ECHO;
X		    /* reset EOL to defalult value */
X		    tio.c_cc[VEOL] = '@' & 0x3f;		/* '^@'	*/
X		    /* certain shells (ksh & csh) change EOF as well */
X		    tio.c_cc[VEOF] = 'D' & 0x3f;		/* '^D'	*/
X
X
X#else	/* !USE_SYSV_TERMIO */
X		    sg.sg_flags &= ~(ALLDELAY | XTABS | CBREAK | RAW);
X		    sg.sg_flags |= ECHO | CRMOD;
X		    /* make sure speed is set on pty so that editors work right*/
X		    sg.sg_ispeed = B9600;
X		    sg.sg_ospeed = B9600;
X		    /* reset t_brkc to default value */
X		    tc.t_brkc = -1;
X#endif /* !USE_SYSV_TERMIO */
X
X#define TMODE(ind,var) if (ttymodelist[ind].set) var = ttymodelist[ind].value;
X		    if (override_tty_modes) {
X#ifdef USE_SYSV_TERMIO
X			/* sysv-specific */
X			TMODE (XTTYMODE_intr, tio.c_cc[VINTR]);
X			TMODE (XTTYMODE_quit, tio.c_cc[VQUIT]);
X			TMODE (XTTYMODE_erase, tio.c_cc[VERASE]);
X			TMODE (XTTYMODE_kill, tio.c_cc[VKILL]);
X			TMODE (XTTYMODE_eof, tio.c_cc[VEOF]);
X			TMODE (XTTYMODE_eol, tio.c_cc[VEOL]);
X#ifdef VSWTCH
X			TMODE (XTTYMODE_swtch, d_tio.c_cc[VSWTCH]);
X#endif
X#else /* !USE_SYSV_TERMIO */
X			TMODE (XTTYMODE_intr, tc.t_intrc);
X			TMODE (XTTYMODE_quit, tc.t_quitc);
X			TMODE (XTTYMODE_erase, sg.sg_erase);
X			TMODE (XTTYMODE_kill, sg.sg_kill);
X			TMODE (XTTYMODE_eof, tc.t_eofc);
X			TMODE (XTTYMODE_start, tc.t_startc);
X			TMODE (XTTYMODE_stop, tc.t_stopc);
X			TMODE (XTTYMODE_brk, tc.t_brkc);
X#endif	/* !USE_SYSV_TERMIO */
X#ifdef TIOCSLTC
X			/* both SYSV and BSD have ltchars */
X			TMODE (XTTYMODE_susp, ltc.t_suspc);
X			TMODE (XTTYMODE_dsusp, ltc.t_dsuspc);
X			TMODE (XTTYMODE_rprnt, ltc.t_rprntc);
X			TMODE (XTTYMODE_flush, ltc.t_flushc);
X			TMODE (XTTYMODE_weras, ltc.t_werasc);
X			TMODE (XTTYMODE_lnext, ltc.t_lnextc);
X#endif /* TIOCSLTC */
X		    }
X#undef TMODE
X
X#ifdef USE_SYSV_TERMIO
X		    if (ioctl (tty, TCSETA, &tio) == -1)
X			    HsSysError(cp_pipe[1], ERROR_TIOCSETP);
X#ifdef TIOCSETC
X		    if (ioctl (tty, TIOCSETC, (char *)&tc) == -1)
X			    HsSysError (cp_pipe[1], ERROR_TIOCSETC);
X#endif /* TIOCSETC */
X#else
X		    if (ioctl (tty, TIOCSETP, (char *)&sg) == -1)
X			    HsSysError (cp_pipe[1], ERROR_TIOCSETP);
X#endif	/* !USE_SYSV_TERMIO */
X#ifdef TIOCSETD
X		    if (ioctl (tty, TIOCSETD, (char *)&discipline) == -1)
X			    HsSysError (cp_pipe[1], ERROR_TIOCSETD);
X#endif /* TIOCSETD */
X#ifdef TIOCSLTC
X		    if (ioctl (tty, TIOCSLTC, &ltc) == -1)
X			    HsSysError(cp_pipe[1], ERROR_TIOCSETC);
X#endif	/* TIOCSLTC */
X#ifdef TIOCLSET
X		    if (ioctl (tty, TIOCLSET, (char *)&lmode) == -1)
X			    HsSysError(cp_pipe[1], ERROR_TIOCLSET);
X#endif	/* TIOCLSET */
X#ifdef TIOCCONS
X		    if (Console) {
X			    int on = 1;
X			    if (ioctl (tty, TIOCCONS, (char *)&on) == -1)
X				    HsSysError(cp_pipe[1], ERROR_TIOCCONS);
X		    }
X#endif	/* TIOCCONS */
X		}
X
X		signal (SIGCHLD, SIG_DFL);
X#ifdef att
X		/* watch out for extra shells (I don't understand either) */
X		signal (SIGHUP, SIG_DFL);
X#else
X		signal (SIGHUP, SIG_IGN);
X#endif
X		/* restore various signals to their defaults */
X		signal (SIGINT, SIG_DFL);
X		signal (SIGQUIT, SIG_DFL);
X		signal (SIGTERM, SIG_DFL);
X
X		/* copy the environment before Setenving */
X		for (i = 0 ; environ [i] != NULL ; i++) ;
X		/*
X		 * The `4' (`5' for SYSV) is the number of Setenv()
X		 * calls which may add a new entry to the environment.
X		 * The `1' is for the NULL terminating entry.
X		 */
X#ifdef USE_SYSV_ENVVARS
X		envnew = (char **) calloc ((unsigned) i + (5 + 1), sizeof(char *));
X#else
X#ifdef USE_TERMCAP
X		envnew = (char **) calloc ((unsigned) i + (4 + 1), sizeof(char *));
X#else
X		envnew = (char **) calloc ((unsigned) i + (3 + 1), sizeof(char *));
X#endif /* USE_TERMCAP */
X#endif /* USE_SYSV_ENVVARS */
X		bcopy((char *)environ, (char *)envnew, i * sizeof(char *));
X		environ = envnew;
X		Setenv ("TERM=", TermName);
X		bcopy((char *)environ, (char *)envnew, i * sizeof(char *));
X		environ = envnew;
X		Setenv ("TERM=", TermName);
X#ifdef USE_TERMCAP
X		if(!TermName)
X			*newtc = 0;
X#endif /* USE_TERMCAP */
X
X		sprintf (buf, "%lu", screen->TekEmu ? 
X			 ((unsigned long) XtWindow (XtParent(tekWidget))) :
X			 ((unsigned long) XtWindow (XtParent(term))));
X		Setenv ("WINDOWID=", buf);
X		/* put the display into the environment of the shell*/
X		Setenv ("DISPLAY=", XDisplayString (screen->display));
X
X		signal(SIGTERM, SIG_DFL);
X
X		/* this is the time to go and set up stdin, out, and err
X		 */
X		{
X		    /* dup the tty */
X		    for (i = 0; i <= 2; i++)
X			if (i != tty) {
X			    (void) close(i);
X			    (void) dup(tty);
X			}
X
X#ifndef att
X		    /* and close the tty */
X		    if (tty > 2)
X			(void) close(tty);
X#endif
X		}
X
X#ifdef UTMP
X#ifdef USE_SYSV_UTMP
X		/* Set up our utmp entry now.  We need to do it here
X		** for the following reasons:
X		**   - It needs to have our correct process id (for
X		**     login).
X		**   - If our parent was to set it after the fork(),
X		**     it might make it out before we need it.
X		**   - We need to do it before we go and change our
X		**     user and group id's.
X		*/
X
X		(void) setutent ();
X		/* set up entry to search for */
X		(void) strncpy(utmp.ut_id,ttydev + strlen(ttydev) - 2,
X		 sizeof (utmp.ut_id));
X		utmp.ut_type = DEAD_PROCESS;
X
X		/* position to entry in utmp file */
X		(void) getutid(&utmp);
X
X		/* set up the new entry */
X		pw = getpwuid(screen->uid);
X		utmp.ut_type = USER_PROCESS;
X		utmp.ut_exit.e_exit = 2;
X		(void) strncpy(utmp.ut_user,
X			       (pw && pw->pw_name) ? pw->pw_name : "????",
X			       sizeof(utmp.ut_user));
X		    
X		(void) strncpy(utmp.ut_id, ttydev + strlen(ttydev) - 2,
X			sizeof(utmp.ut_id));
X		(void) strncpy (utmp.ut_line,
X			ttydev + strlen("/dev/"), sizeof (utmp.ut_line));
X#ifdef HAS_UTMP_UT_HOST
X		(void) strncpy(utmp.ut_host, DisplayString(screen->display),
X			       sizeof(utmp.ut_host));
X#endif
X		(void) strncpy(utmp.ut_name, pw->pw_name, 
X			       sizeof(utmp.ut_name));
X
X		utmp.ut_pid = getpid();
X		utmp.ut_time = time ((long *) 0);
X
X		/* write out the entry */
X		if (!resource.utmpInhibit) (void) pututline(&utmp);
X
X#ifdef WTMP
X		    /* set wtmp entry if wtmp file exists */
X		    if ((fd = open(etc_wtmp, O_WRONLY | O_APPEND)) >= 0) {
X		      (void) write(fd, &utmp, sizeof utmp );
X		      (void) close(fd);
X		    }
X#endif
X		/* close the file */
X		(void) endutent();
X
X#else	/* USE_SYSV_UTMP */
X		/* We can now get our ttyslot!  We can also set the initial
X		 * UTMP entry.
X		 */
X		tslot = ttyslot();
X		added_utmp_entry = False;
X		{
X			if (!resource.utmpInhibit &&
X			    (pw = getpwuid(screen->uid)) &&
X			    (i = open(etc_utmp, O_WRONLY)) >= 0) {
X				bzero((char *)&utmp, sizeof(struct utmp));
X				(void) strncpy(utmp.ut_line,
X					       ttydev + strlen("/dev/"),
X					       sizeof(utmp.ut_line));
X				(void) strncpy(utmp.ut_name, pw->pw_name,
X					       sizeof(utmp.ut_name));
X#ifdef HAS_UTMP_UT_HOST
X				(void) strncpy(utmp.ut_host, 
X					       XDisplayString (screen->display),
X					       sizeof(utmp.ut_host));
X#endif
X				time(&utmp.ut_time);
X				lseek(i, (long)(tslot * sizeof(struct utmp)), 0);
X				write(i, (char *)&utmp, sizeof(struct utmp));
X				close(i);
X				added_utmp_entry = True;
X#ifdef WTMP
END_OF_FILE
if test 26214 -ne `wc -c <'xterm/main.c.ab'`; then
    echo shar: \"'xterm/main.c.ab'\" unpacked with wrong size!
fi
# end of 'xterm/main.c.ab'
fi
if test -f 'xterm/termcap.vi' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xterm/termcap.vi'\"
else
echo shar: Extracting \"'xterm/termcap.vi'\" \(849 characters\)
sed "s/^X//" >'xterm/termcap.vi' <<'END_OF_FILE'
Xvs|xterm|4316x|4317x|vs100|xterm terminal emulator (X window system):\
X        :cr=^M:do=^J:nl=^J:bl=^G:le=^H:ho=\E[H:\
X        :LC:co#80:li#65:cl=\E[H\E[2J:bs:am:cm=\E[%i%d;%dH:nd=\E[C:up=\E[A:\
X        :ce=\E[K:cd=\E[J:so=\E[7m:se=\E[m:us=\E[4m:ue=\E[m:\
X        :md=\E[1m:mr=\E[7m:me=\E[m:\
X        :ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:\
X        :k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:ta=^I:pt:sf=\n:sr=\EM:\
X        :al=\E[L:dl=\E[M:ic=\E[@:dc=\E[P:\
X        :MT:ks=\E[?1h\E=:ke=\E[?1l\E>:\
X        :is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:\
X        :rs=\E[r\E<\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l:xn:\
X        :AL=\E[%dL:DL=\E[%dM:IC=\E[%d@:DC=\E[%dP:\
X        :ti=\E7\E[?47h:te=\E[2J\E[?47l\E8:\
X        :hs:ts=\E[?E\E[?%i%dT:fs=\E[?F:es:ds=\E[?E:
Xv2|xterms|4315x|vs100s|xterm terminal emulator (small)(X window system):\
X        :co#80:li#24:tc=xterm:
END_OF_FILE
if test 849 -ne `wc -c <'xterm/termcap.vi'`; then
    echo shar: \"'xterm/termcap.vi'\" unpacked with wrong size!
fi
# end of 'xterm/termcap.vi'
fi
echo shar: End of archive 9 \(of 14\).
cp /dev/null ark9isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 14 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.