[comp.sources.x] v03i030: latest version of xlock, Part01/01

mikew@wyse.wyse.com (Mike Wexler) (02/22/89)

Submitted-by: naughton@Sun.COM (Patrick Naughton)
Posting-number: Volume 3, Issue 30
Archive-name: xlock/part01

#! /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 archive 1 (of 1)."
# Contents:  README AUTHOR HSBmap.c Imakefile Makefile XCrDynCmap.c
#   XCrHsbCmap.c hopalong.c hopalong.h patchlevel.h xlock.c xlock.man
# Wrapped by mikew@wyse on Tue Feb 21 11:33:05 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(594 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XHere is the latest version of xlock, which incorporates several
Xenhancements and some bug fixes.  It now prompts the user for the
Xpassword rather than providing no feedback as in the last version.  It
Xalso queries the defaults database for all options that are accessible
Xthrough the command line.  So lines like "xlock.font: fixed" in your
X~/.Xdefaults will do the right thing.  The files XCrDynCmap.c and
XXCrHsbCmap.c are good examples of correct use of synamic colormap
Xgeneration and manipulation of HSB linear color ramps.
X
XThere is also a copy on expo.lcs.mit.edu:~/contrib/xlock.shar.Z
X
END_OF_FILE
if test 594 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'AUTHOR' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(805 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X(Message inbox:910)
XReturn-Path: news@Sun.COM
XReceived:  by wyse.wyse.com (5.58/Wyse master/5-13-88)
X	id AA18494; Sat, 18 Feb 89 00:13:05 PST
XReceived: from SUN.COM by uunet.UU.NET (5.61/1.14) with SMTP 
X	id AA18271; Sat, 18 Feb 89 00:47:40 -0500
XReceived: from sun.Sun.COM (sun-bb.sun.com) by Sun.COM (4.1/SMI-4.0)
X	id AA26960; Fri, 17 Feb 89 20:15:23 PST
XReceived: by sun.Sun.COM (4.0/SMI-4.0)
X	id AA22805; Thu, 16 Feb 89 13:25:10 PST
XTo: comp-sources-x@uunet.UU.NET
XPath: sun!wind!naughton
XFrom: naughton@Sun.COM (Patrick Naughton)
XNewsgroups: comp.sources.x
XSubject: New version of xlock
XMessage-Id: <90141@sun.uucp>
XDate: 16 Feb 89 21:25:04 GMT
XSender: news@Sun.COM
XReply-To: naughton@Sun.COM (Patrick Naughton)
XFollowup-To: comp.windows.x
XOrganization: Sun Microsystems, Mountain View
XLines: 1303
X
X
END_OF_FILE
if test 805 -ne `wc -c <'AUTHOR'`; then
    echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'HSBmap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'HSBmap.c'\"
else
echo shar: Extracting \"'HSBmap.c'\" \(2549 characters\)
sed "s/^X//" >'HSBmap.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)HSBmap.c 1.2 89/02/15";
X#endif
X/*-
X * HSBmap.c - Create an HSB ramp.
X *
X * Copyright (c) 1989 by Sun Microsystems, Inc.
X *
X * Author: Patrick J. Naughton
X * naughton@wind.sun.com
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X */
X
X#include <X11/Xos.h>
X#include <math.h>
X
Xvoid
Xhsb2rgb(H, S, B, r, g, b)
X    double      H,
X                S,
X                B;
X    u_char     *r,
X               *g,
X               *b;
X{
X    register int i;
X    register double f,
X                bb;
X    register u_char p,
X                q,
X                t;
X
X    H -= floor(H);		/* remove anything over 1 */
X    H *= 6.0;
X    i = floor(H);		/* 0..5 */
X    f = H - (float) i;		/* f = fractional part of H */
X    bb = 255.0 * B;
X    p = (u_char) (bb * (1.0 - S));
X    q = (u_char) (bb * (1.0 - (S * f)));
X    t = (u_char) (bb * (1.0 - (S * (1.0 - f))));
X    switch (i) {
X    case 0:
X	*r = (u_char) bb;
X	*g = t;
X	*b = p;
X	break;
X    case 1:
X	*r = q;
X	*g = (u_char) bb;
X	*b = p;
X	break;
X    case 2:
X	*r = p;
X	*g = (u_char) bb;
X	*b = t;
X	break;
X    case 3:
X	*r = p;
X	*g = q;
X	*b = (u_char) bb;
X	break;
X    case 4:
X	*r = t;
X	*g = p;
X	*b = (u_char) bb;
X	break;
X    case 5:
X	*r = (u_char) bb;
X	*g = p;
X	*b = q;
X	break;
X    }
X}
X
X
Xvoid
XHSBramp(h1, s1, b1, h2, s2, b2, start, end, red, green, blue)
X    double      h1,
X                s1,
X                b1,
X                h2,
X                s2,
X                b2;
X    int         start,
X                end;
X    u_char     *red,
X               *green,
X               *blue;
X{
X    double      dh,
X                ds,
X                db;
X    register u_char *r,
X               *g,
X               *b;
X    register int i;
X
X    r = red;
X    g = green;
X    b = blue;
X    dh = (h2 - h1) / 255.0;
X    ds = (s2 - s1) / 255.0;
X    db = (b2 - b1) / 255.0;
X    for (i = start; i <= end; i++) {
X	hsb2rgb(h1, s1, b1, r++, g++, b++);
X	h1 += dh;
X	s1 += ds;
X	b1 += db;
X    }
X}
END_OF_FILE
if test 2549 -ne `wc -c <'HSBmap.c'`; then
    echo shar: \"'HSBmap.c'\" unpacked with wrong size!
fi
# end of 'HSBmap.c'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(975 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X# @(#)Imakefile 1.1 89/01/13
X# Imakefile - xlock
X#
X# Copyright (c) 1988 by Sun Microsystems, Inc.
X#
X# Permission to use, copy, modify, and distribute this software and its
X# documentation for any purpose and without fee is hereby granted,
X# provided that the above copyright notice appear in all copies and that
X# both that copyright notice and this permission notice appear in
X# supporting documentation.
X#
X# This file is provided AS IS with no warranties of any kind.  The author
X# shall have no liability with respect to the infringement of copyrights,
X# trade secrets or any patents by this file or any part thereof.  In no
X# event will the author be liable for any lost revenue or profits or
X# other special, indirect and consequential damages.
X#
X#
XLOCAL_LIBRARIES = $(XLIB)
X  SYS_LIBRARIES = -lm
X           SRCS = xlock.c hopalong.c XCrHsbCmap.c HSBmap.c XCrDynCmap.c
X           OBJS = xlock.o hopalong.o XCrHsbCmap.o HSBmap.o XCrDynCmap.o
X
XComplexProgramTarget(xlock)
END_OF_FILE
if test 975 -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'\" \(7286 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space.  Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file.  Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def.  If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit Sun.macros to change
X
X# platform:  $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system:   SunOS 3.4
X
XBOOTSTRAPCFLAGS =
X             AS = as
X             CC = cc
X            CPP = /lib/cpp
X             LD = ld
X           LINT = lint
X        INSTALL = install
X           TAGS = ctags
X             RM = rm -f
X             MV = mv
X             LN = ln -s
X         RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X             AR = ar clq
X             LS = ls
X       LINTOPTS = -xz
X    LINTLIBFLAG = -C
X           MAKE = make
XSTD_CPP_DEFINES =
X    STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site:  $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X          SHELL =  /bin/sh
X
X        DESTDIR = /global
X      USRLIBDIR = $(DESTDIR)/lib
X         BINDIR = $(DESTDIR)/bin/X11
X         INCDIR = $(DESTDIR)/include
X         ADMDIR = $(DESTDIR)/usr/adm
X         LIBDIR = $(USRLIBDIR)/X11
X     LINTLIBDIR = $(USRLIBDIR)/lint
X        FONTDIR = $(LIBDIR)/fonts
X       XINITDIR = $(LIBDIR)/xinit
X         XDMDIR = $(LIBDIR)/xdm
X         UWMDIR = $(LIBDIR)/uwm
X         AWMDIR = $(LIBDIR)/awm
X         TWMDIR = $(LIBDIR)/twm
X          DTDIR = $(LIBDIR)/dt
X        MANPATH = /usr/man
X  MANSOURCEPATH = $(MANPATH)/man
X         MANDIR = $(MANSOURCEPATH)n
X      LIBMANDIR = $(MANSOURCEPATH)n3
X    XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X   INSTBINFLAGS = -m 0755
X   INSTUIDFLAGS = -m 4755
X   INSTLIBFLAGS = -m 0664
X   INSTINCFLAGS = -m 0444
X   INSTMANFLAGS = -m 0444
X   INSTAPPFLAGS = -m 0444
X  INSTKMEMFLAGS = -m 4755
X        FCFLAGS = -t
X    CDEBUGFLAGS = -O
X
X        PATHSEP = /
X         DEPEND = $(BINDIR)/makedepend
X          IMAKE = $(BINDIR)/imake
X            RGB = $(LIBDIR)/rgb
X             FC = $(BINDIR)/bdftosnf
X      MKFONTDIR = $(BINDIR)/mkfontdir
X      MKDIRHIER = $(BINDIR)/mkdirhier.sh
X
X         CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X      LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X        LDFLAGS = $(CDEBUGFLAGS) -L$(USRLIBDIR) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X
X       IRULESRC = $(LIBDIR)/imake.includes
X
X   EXTENSIONLIB = $(USRLIBDIR)/libext.a
X           XLIB = $(USRLIBDIR)/libX11.a
X         XMULIB = $(USRLIBDIR)/libXmu.a
X        OLDXLIB = $(USRLIBDIR)/liboldX.a
X       XTOOLLIB = $(USRLIBDIR)/libXt.a
X         XAWLIB = $(USRLIBDIR)/libXaw.a
X       LINTXLIB = $(USRLIBDIR)/lint/llib-lX11.ln
X        LINTXMU = $(USRLIBDIR)/lint/llib-lXmu.ln
X      LINTXTOOL = $(USRLIBDIR)/lint/llib-lXt.ln
X        LINTXAW = $(USRLIBDIR)/lint/llib-lXaw.ln
X       INCLUDES = -I$(INCDIR)
X      MACROFILE = Sun.macros
X   ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X			$(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X  IMAKE_DEFINES =
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X			-s Makefile $(IMAKE_DEFINES)
X         RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X			.emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules:  $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X# @(#)Imakefile 1.1 89/01/13
X# Imakefile - xlock
X#
X# Copyright (c) 1988 by Sun Microsystems, Inc.
X#
X# Permission to use, copy, modify, and distribute this software and its
X# documentation for any purpose and without fee is hereby granted,
X# provided that the above copyright notice appear in all copies and that
X# both that copyright notice and this permission notice appear in
X# supporting documentation.
X#
X# This file is provided AS IS with no warranties of any kind.  The author
X# shall have no liability with respect to the infringement of copyrights,
X# trade secrets or any patents by this file or any part thereof.  In no
X# event will the author be liable for any lost revenue or profits or
X# other special, indirect and consequential damages.
X#
X#
XLOCAL_LIBRARIES = $(XLIB)
X  SYS_LIBRARIES = -lm
X           SRCS = xlock.c hopalong.c XCrHsbCmap.c HSBmap.c XCrDynCmap.c
X           OBJS = xlock.o hopalong.o XCrHsbCmap.o HSBmap.o XCrDynCmap.o
X
X PROGRAM = xlock
X
Xall:: xlock
X
Xxlock: $(OBJS) $(LOCAL_LIBRARIES)
X	$(RM) $@
X	$(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X	$(RM) $(PROGRAM)
X	$(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xlock
X	$(INSTALL) -c $(INSTALLFLAGS) xlock $(BINDIR)
X
Xinstall.man:: xlock.man
X	$(INSTALL) -c $(INSTMANFLAGS) xlock.man $(MANDIR)/xlock.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X	$(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X	@echo "making $@"; \
X	cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X	$(RM) $(PROGRAM)
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	-@if [ -f Makefile ]; then \
X	echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X	@echo "making $@"; \
X	cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
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 done"
X
Xinstall.man::
X	@echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 7286 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'XCrDynCmap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'XCrDynCmap.c'\"
else
echo shar: Extracting \"'XCrDynCmap.c'\" \(2417 characters\)
sed "s/^X//" >'XCrDynCmap.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)XCrDynCmap.c 1.3 89/02/16";
X#endif
X/*-
X * XCreDynCmap.c - X11 library routine to create dynamic colormaps.
X *
X * Copyright (c) 1989 by Sun Microsystems, Inc.
X *
X * Author: Patrick J. Naughton
X * naughton@wind.sun.com
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X */
X
X#include <X11/X.h>
X#include <X11/Xos.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X
XStatus
XXCreateDynamicColormap(dsp, screen, cmap, visual, colors,
X		       count, red, green, blue)
X    Display    *dsp;
X    int         screen;
X    Colormap   *cmap;
X    Visual    **visual;
X    XColor     *colors;
X    int         count;
X    u_char     *red,
X               *green,
X               *blue;
X{
X    XVisualInfo vinfo;
X    int         pixels[256];
X    int         i,
X                ncolors,
X                planes;
X    unsigned long pmasks;
X    Status      allocReturn;
X
X    planes = DisplayPlanes(dsp, screen);
X    if (XMatchVisualInfo(dsp, screen, planes, PseudoColor, &vinfo)) {
X
X	*visual = vinfo.visual;
X	*cmap = XCreateColormap(dsp, RootWindow(dsp, screen),
X				*visual, AllocNone);
X	ncolors = vinfo.colormap_size;
X
X	if (count > ncolors)
X	    return (BadValue);
X
X	allocReturn = XAllocColorCells(dsp, *cmap,
X				       False, &pmasks, 0,
X				       pixels, count);
X
X/*	This should return Success, but it doesn't... Xlib bug?
X *	(I'll ignore the return value for now...)
X */
X#ifdef NOTDEF
X	if (allocReturn != Success)
X	    return (allocReturn);
X#endif				/* NOTDEF */
X
X	for (i = 0; i < count; i++) {
X	    colors[i].pixel = pixels[i];
X	    colors[i].red = *red++ << 8;
X	    colors[i].green = *green++ << 8;
X	    colors[i].blue = *blue++ << 8;
X	    colors[i].flags = DoRed | DoGreen | DoBlue;
X	}
X	XStoreColors(dsp, *cmap, colors, count);
X	return (Success);
X    } else
X	return (BadMatch);
X}
END_OF_FILE
if test 2417 -ne `wc -c <'XCrDynCmap.c'`; then
    echo shar: \"'XCrDynCmap.c'\" unpacked with wrong size!
fi
# end of 'XCrDynCmap.c'
fi
if test -f 'XCrHsbCmap.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'XCrHsbCmap.c'\"
else
echo shar: Extracting \"'XCrHsbCmap.c'\" \(2164 characters\)
sed "s/^X//" >'XCrHsbCmap.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)XCrHsbCmap.c 1.3 89/02/16";
X#endif
X/*-
X * XCrHsbCmap.c - X11 library routine to create an HSB ramp colormaps.
X *
X * Copyright (c) 1989 by Sun Microsystems, Inc.
X *
X * Author: Patrick J. Naughton
X * naughton@wind.sun.com
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X */
X
X#include <X11/X.h>
X#include <X11/Xos.h>
X#include <X11/Xlib.h>
X
Xextern void HSBmap();
X
XStatus
XXCreateHSBColormap(dsp, screen, cmap, count, h1, s1, b1, h2, s2, b2, bw)
X    Display    *dsp;
X    int         screen;
X    Colormap   *cmap;		/* colormap return value */
Xint         count;		/* number of entrys to use */
Xdouble      h1,			/* starting hue */
X            s1,			/* starting saturation */
X            b1,			/* starting brightness */
X            h2,			/* ending hue */
X            s2,			/* ending saturation */
X            b2;			/* ending brightness */
Xint         bw;			/* Boolean: True = save black and white */
X{
X    u_char      red[256];
X    u_char      green[256];
X    u_char      blue[256];
X    unsigned long pixel;
X    Status      status;
X    Visual     *visual;
X    XColor      xcolors[256];
X
X    if (count > 256)
X	return (BadValue);
X
X    HSBramp(h1, s1, b1, h2, s2, b2, 0, count - 1, red, green, blue);
X
X    if (bw) {
X	pixel = WhitePixel(dsp, screen);
X	red[pixel] = green[pixel] = blue[pixel] = 0xff;
X
X	pixel = BlackPixel(dsp, screen);
X	red[pixel] = green[pixel] = blue[pixel] = 0;
X    }
X    status = XCreateDynamicColormap(dsp, screen, cmap, &visual, xcolors,
X				    count, red, green, blue);
X
X    return (status);
X}
END_OF_FILE
if test 2164 -ne `wc -c <'XCrHsbCmap.c'`; then
    echo shar: \"'XCrHsbCmap.c'\" unpacked with wrong size!
fi
# end of 'XCrHsbCmap.c'
fi
if test -f 'hopalong.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'hopalong.c'\"
else
echo shar: Extracting \"'hopalong.c'\" \(3488 characters\)
sed "s/^X//" >'hopalong.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)hopalong.c 1.3 89/02/16";
X#endif
X/*-
X * hopalong.c - Real Plane Fractals from Sept 86 Scientific American
X *
X * Copyright (c) 1989 by Sun Microsystems, Inc.
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X * Comments and additions should be sent to the author:
X *
X *                     naughton@wind.Sun.COM
X *
X *                     Patrick J. Naughton
X *                     Window Systems Group, MS 14-40
X *                     Sun Microsystems, Inc.
X *                     2550 Garcia Ave
X *                     Mountain View, CA  94043
X *                     (415) 336-1080
X *
X * Revision History:
X * 31-Aug-88: Forked from xlock.c for modularity.
X */
X
X#include <math.h>
X#include <X11/Xos.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X
Xstatic int centerx, centery;		/* center of the screen */
Xstatic double a, b, c, i, j;		/* hopalong parameters */
Xstatic int color;
Xstatic unsigned long pix = 0;
Xstatic Display *Dsp;
Xstatic Window Win;
Xstatic GContext Gc;
Xstatic XPoint *pointBuffer = 0;		/* pointer for XDrawPoints */
Xstatic int Npoints = 0;
Xstatic long startTime;
Xstatic int timeout;
X
Xlong
Xseconds()
X{
Xstruct timeval foo;
X
X    gettimeofday(&foo, (struct timezone *) 0);
X    return(foo.tv_sec);
X}
X
Xvoid
Xinithop(d, w, g, c, t, n, p, x, y, A, B, C)
XDisplay *d;
XWindow w;
XGContext g;
Xint c, t, n, p, x, y;
Xdouble A, B, C;
X{
X    i = j = 0.0;
X    startTime = seconds();
X
X    if ((pointBuffer) || (n != Npoints)) {
X	if (pointBuffer) free(pointBuffer);
X	pointBuffer = (XPoint *) malloc(n * sizeof(XPoint));
X	Npoints = n;
X    }
X
X    Dsp = d;
X    Win = w;
X    Gc = g;
X    color = c;
X    timeout = t;
X    if (p >= 0) pix = (unsigned long) p;
X    centerx = x;
X    centery = y;
X    a = A;
X    b = B;
X    c = C;
X    XClearWindow(Dsp, Win);
X}
X
X
Xvoid
XrandomInithop(d, w, g, c, t, n)
XDisplay *d;
XWindow w;
XGContext g;
Xint c, t, n;
X{
Xint range;
XXWindowAttributes xgwa;
Xdouble A, B, C;
Xint x, y;
X
X    XGetWindowAttributes(d, w, &xgwa);
X    x = xgwa.width / 2;
X    y = xgwa.height / 2;
X    range = (int) sqrt((double)x*x+(double)y*y);
X    A = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
X    B = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
X    C = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
X
X    if (!(random()%3)) a /= 10.0;
X    if (!(random()%2)) b /= 100.0;
X
X    inithop(d, w, g, c, t, n, -1, x, y, A, B, C);
X}
X
X
Xint
Xhopdone()
X{
X    return(seconds() - startTime > timeout);
X}
X
X
Xvoid
Xhop()
X{
Xregister double oldj;
Xregister int k = Npoints;
Xregister XPoint *xp = pointBuffer;
X
X    if (color) {
X	XSetForeground(Dsp, Gc, pix++);
X	pix %= 254;
X    }
X    while (k--) {
X	oldj = j;
X	j = a - i;
X	i = oldj + (i<0?sqrt(fabs(b*i - c)):-sqrt(fabs(b*i - c)));
X	xp->x = centerx + (int)(i+j);
X	xp->y = centery - (int)(i-j);
X	xp++;
X    }
X    XDrawPoints(Dsp, Win, Gc, pointBuffer, Npoints, CoordModeOrigin);
X}
END_OF_FILE
if test 3488 -ne `wc -c <'hopalong.c'`; then
    echo shar: \"'hopalong.c'\" unpacked with wrong size!
fi
# end of 'hopalong.c'
fi
if test -f 'hopalong.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'hopalong.h'\"
else
echo shar: Extracting \"'hopalong.h'\" \(920 characters\)
sed "s/^X//" >'hopalong.h' <<'END_OF_FILE'
X/*-
X * hopalong.h - Real Plane Fractals from Sept 86 Scientific American
X *
X * Copyright (c) 1988 by Sun Microsystems, Inc.
X *
X * Author: Patrick J. Naughton
X * naughton@wind.sun.com
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X */
X
Xvoid	inithop();
Xvoid	randomInithop();
Xint	hopdone();
Xvoid	hop();
END_OF_FILE
if test 920 -ne `wc -c <'hopalong.h'`; then
    echo shar: \"'hopalong.h'\" unpacked with wrong size!
fi
# end of 'hopalong.h'
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 'xlock.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xlock.c'\"
else
echo shar: Extracting \"'xlock.c'\" \(15534 characters\)
sed "s/^X//" >'xlock.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)xlock.c 1.8 89/02/16";
X#endif
X/*-
X * xlock.c - X11 client to lock a display and display the HOPALONG fractals
X *           from page 14 of the September 1986 Scientific American.
X *
X * Copyright (c) 1989 by Sun Microsystems, Inc.
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted,
X * provided that the above copyright notice appear in all copies and that
X * both that copyright notice and this permission notice appear in
X * supporting documentation.
X *
X * This file is provided AS IS with no warranties of any kind.  The author
X * shall have no liability with respect to the infringement of copyrights,
X * trade secrets or any patents by this file or any part thereof.  In no
X * event will the author be liable for any lost revenue or profits or
X * other special, indirect and consequential damages.
X *
X * Comments and additions should be sent to the author:
X *
X *                     naughton@wind.Sun.COM
X *
X *                     Patrick J. Naughton
X *                     Window Systems Group, MS 14-40
X *                     Sun Microsystems, Inc.
X *                     2550 Garcia Ave
X *                     Mountain View, CA  94043
X *                     (415) 336-1080
X *
X * Revision History:
X * 16-Feb-89: Updated calling conventions for XCreateHsbColormap();
X *	      Added -count for number of iterations per color.
X *	      Fixed defaulting mechanism.
X *	      Ripped out VMS hacks.
X * 15-Feb-89: Changed default font to pellucida-sans-18.
X * 20-Jan-89: Added -verbose and fixed usage message.
X * 19-Jan-89: Fixed monochrome gc bug.
X * 16-Dec-88: Added SunView style password prompting.
X * 19-Sep-88: Changed -color to -mono. (default is color on color displays).
X *            Added -saver option. (just do display... don't lock.)
X * 31-Aug-88: Added -time option.
X *            Removed code for fractals to separate file for modularity.
X *            Added signal handler to restore host access.
X *            Installs dynamic colormap with a Hue Ramp.
X *            If grabs fail then exit.
X *            Added VMS Hacks. (password 'iwiwuu').
X * 08-Jun-88: Fixed root password pointer problem and changed PASSLENGTH to 20.
X * 20-May-88: Added -root to allow root to unlock.
X * 12-Apr-88: Added root password override.
X *            Added screen saver override.
X *            Removed XGrabServer/XUngrabServer.
X *            Added access control handling instead.
X * 01-Apr-88: Added XGrabServer/XUngrabServer for more security.
X * 30-Mar-88: Removed startup password requirement.
X *            Removed cursor to avoid phosphor burn.
X * 27-Mar-88: Rotate fractal by 45 degrees clockwise.
X * 24-Mar-88: Added color support. [-color]
X *            wrote the man page.
X * 23-Mar-88: Added HOPALONG routines from Scientific American Sept. 86 p. 14.
X *            added password requirement for invokation
X *            removed option for command line password
X *            added requirement for display to be "unix:0".
X * 22-Mar-88: Recieved Walter Milliken's comp.windows.x posting.
X *
X * Contributors:
X *  milliken@heron.bbn.com
X *  karlton@wsl.dec.com
X *  dana@thumper.bellcore.com
X *  vesper@3d.dec.com
X */
X
X#include <stdio.h>
X#include <math.h>
X#include <signal.h>
X#include <X11/Xos.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/cursorfont.h>
X#include "hopalong.h"
X
Xint         (*reinit) () = hopdone;
Xvoid        (*callback) () = hop;
Xvoid        (*init) () = randomInithop;
X
X#include <pwd.h>
Xchar       *crypt();
X#define DISPLAYNAME ":0"
X
Xchar       *pname;		/* argv[0] */
XDisplay    *dsp = NULL;		/* current display (must be inited) */
Xint         screen;		/* current screen */
XWindow      w,
X            icon,
X            root;		/* window used to cover screen */
XGContext    gc,
X            textgc;		/* graphics context */
XColormap    cmap;		/* colormap */
XCursor      mycursor;		/* blank cursor */
XPixmap      lockc,
X            lockm;		/* pixmaps for cursor and mask */
Xchar        no_bits[] = {0};	/* dummy array for the blank cursor */
XXFontStruct *font;
Xchar       *fontname = NULL;
Xint         inittime = -1;	/* time for each fractal on screen */
Xint         skipRoot;		/* skip root password check */
Xint         color;		/* color or mono */
Xint         count = -1;		/* number of pixels to draw in each color */
Xint         lock;		/* locked or just screensaver mode */
Xint         verbose = False;	/* print configuration info to stderr? */
Xint         timeout,
X            interval,
X            blanking,
X            exposures;		/* screen saver parameters */
X
X#define ICONX			300
X#define ICONY			150
X#define ICONW			64
X#define ICONH			64
X#define ICONTIME		10
X#define ICONLOOPS		6
X#define DEFAULT_FONTNAME	"pellucida-sans-18"
X#define DEFAULT_INITTIME	60
X#define DEFAULT_SKIPROOT	True
X#define DEFAULT_COUNT		100
X
Xvoid
Xerror(s1, s2)
X    char       *s1,
X               *s2;
X{
X    fprintf(stderr, s1, pname, s2);
X    exit(1);
X}
X
Xint         oldsigmask;
X
Xvoid
Xblock()
X{
X    oldsigmask = sigblock(sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGSEGV));
X}
X
Xvoid
Xunblock()
X{
X    sigsetmask(oldsigmask);
X}
X
Xvoid
Xallowsig()
X{
X    unblock();
X    block();
X}
X
X
XXHostAddress *XHosts;
Xint         HostAccessCount;
XBool        HostAccessState;
X
Xvoid
XXGrabHosts(dsp)
X    Display    *dsp;
X{
X    XHosts = XListHosts(dsp, &HostAccessCount, &HostAccessState);
X    XRemoveHosts(dsp, XHosts, HostAccessCount);
X    XEnableAccessControl(dsp);
X}
X
Xvoid
XXUngrabHosts(dsp)
X    Display    *dsp;
X{
X    XAddHosts(dsp, XHosts, HostAccessCount);
X    XFree(XHosts);
X    if (HostAccessState == False)
X	XDisableAccessControl(dsp);
X}
X
X
Xvoid
XXLockDisplay(dsp)
X    Display    *dsp;
X{
X    Status      status;
X
X    XGrabHosts(dsp);
X
X    status = XGrabKeyboard(dsp, w, True,
X			   GrabModeAsync, GrabModeAsync, CurrentTime);
X    if (status != GrabSuccess)
X	error("%s: couldn't grab keyboard! (%d)\n", status);
X
X    status = XGrabPointer(dsp, w, True, -1,
X		  GrabModeAsync, GrabModeAsync, None, mycursor, CurrentTime);
X    if (status != GrabSuccess)
X	error("%s: couldn't grab pointer! (%d)\n", status);
X}
X
X
Xvoid
XXChangeGrabbedCursor(cursor)
X    Cursor      cursor;
X{
X    XGrabPointer(dsp, w, True, -1,
X		 GrabModeAsync, GrabModeAsync, None,
X		 cursor, CurrentTime);
X}
X
X
Xvoid
XXUnlockDisplay()
X{
X    XUngrabHosts(dsp);
X    XUngrabPointer(dsp, CurrentTime);
X    XUngrabKeyboard(dsp, CurrentTime);
X}
X
X
Xvoid
Xfinish()
X{
X    XSync(dsp);
X    XUnlockDisplay();
X    XSetScreenSaver(dsp, timeout, interval, blanking, exposures);
X    XDestroyWindow(dsp, w);
X    if (color)
X	XUninstallColormap(dsp, cmap);
X    XFlush(dsp);
X    XCloseDisplay(dsp);
X}
X
X
Xvoid
Xsigcatch()
X{
X    finish();
X    error("%s: caught terminate signal.\nAccess control list restored.\n",
X	  NULL);
X}
X
X
Xint
XReadXString(s, slen)
X    char       *s;
X    int         slen;
X{
X    XEvent      event;
X    char        keystr[20];
X    char        c;
X    int         i,
X                bp,
X                len,
X                loops;
X
X    XSetForeground(dsp, gc, BlackPixel(dsp, screen));
X    init(dsp, icon, gc, color, ICONTIME, count);
X    bp = 0;
X    while (True) {
X	loops = 0;
X	while (!XPending(dsp)) {
X	    allowsig();
X	    callback();
X	    if (reinit()) {
X		init(dsp, icon, gc, color, ICONTIME, count);
X		if (++loops >= ICONLOOPS)
X		    return (1);
X	    }
X	}
X	XNextEvent(dsp, &event);
X	switch (event.type) {
X	case KeyPress:
X	    len = XLookupString((XKeyEvent *) & event, keystr, 20, NULL, NULL);
X	    for (i = 0; i < len; i++) {
X		c = keystr[i];
X		switch (c) {
X		case 8:	/* ^H */
X		case 127:	/* DEL */
X		    if (bp > 0)
X			bp--;
X		    break;
X		case 10:	/* ^J */
X		case 13:	/* ^M */
X		    s[bp] = '\0';
X		    return (0);
X		case 21:	/* ^U */
X		    bp = 0;
X		    break;
X		default:
X		    s[bp] = c;
X		    if (bp < slen - 1)
X			bp++;
X		}
X	    }
X	    break;
X
X	case ButtonPress:
X	    if (((XButtonEvent *) & event)->window == icon)
X		return (1);
X	    break;
X
X	case KeyRelease:
X	case ButtonRelease:
X	case MotionNotify:
X	    break;
X
X	default:
X	    fprintf(stderr, "%s: unexpected event: %d\n", pname, event.type);
X	    break;
X	}
X    }
X}
X
Xextern char *getenv();
X
Xint
XgetPassword()
X{
X#define PASSLENGTH 20
X    char        buffer[PASSLENGTH];
X    char        userpass[PASSLENGTH];
X    char        rootpass[PASSLENGTH];
X    struct passwd *pw;
X    XWindowAttributes xgwa;
X    char       *user = getenv("USER");
X    char       *name = "Name: ";
X    char       *pass = "Password: ";
X    char       *info = "Enter password to unlock; select icon to lock.";
X    char       *validate = "Validating login...";
X    char       *invalid = "Invalid login.";
X    int         y,
X                line,
X                left,
X                done;
X
X    XGetWindowAttributes(dsp, w, &xgwa);
X
X    XChangeGrabbedCursor(XCreateFontCursor(dsp, XC_left_ptr));
X
X    XSetForeground(dsp, gc, WhitePixel(dsp, screen));
X    XFillRectangle(dsp, w, gc, 0, 0, xgwa.width, xgwa.height);
X
X    XMapWindow(dsp, icon);
X    XRaiseWindow(dsp, icon);
X
X    left = ICONX + ICONW + font->max_bounds.width;
X    line = font->ascent + font->descent + 2;
X    y = ICONY + font->ascent;
X
X    XDrawString(dsp, w, textgc, left, y, name, strlen(name));
X    XDrawString(dsp, w, textgc, left + 1, y, name, strlen(name));
X    XDrawString(dsp, w, textgc,
X		left + XTextWidth(font, name, strlen(name)), y,
X		user, strlen(user));
X    y += line;
X    XDrawString(dsp, w, textgc, left, y, pass, strlen(pass));
X    XDrawString(dsp, w, textgc, left + 1, y, pass, strlen(pass));
X
X    y = ICONY + ICONH + font->ascent + 2;
X    XDrawString(dsp, w, textgc, ICONX, y, info, strlen(info));
X
X    XFlush(dsp);
X
X    y += font->ascent + font->descent + 2;
X
X    pw = getpwuid(0);
X    strcpy(rootpass, pw->pw_passwd);
X
X    pw = getpwuid(getuid());
X    strcpy(userpass, pw->pw_passwd);
X
X    done = False;
X    while (!done) {
X
X	if (ReadXString(buffer, PASSLENGTH)) {
X	    XChangeGrabbedCursor(mycursor);
X	    XUnmapWindow(dsp, icon);
X	    XSetForeground(dsp, gc, WhitePixel(dsp, screen));
X	    return (1);
X	}
X	XSetForeground(dsp, gc, WhitePixel(dsp, screen));
X	XFillRectangle(dsp, w, gc, ICONX, y - font->ascent,
X		       XTextWidth(font, validate, strlen(validate)),
X		       font->ascent + font->descent + 2);
X
X	XDrawString(dsp, w, textgc, ICONX, y, validate, strlen(validate));
X
X	done = !((strcmp(crypt(buffer, userpass), userpass))
X		 && (skipRoot || strcmp(crypt(buffer, rootpass), rootpass)));
X
X	if (!done) {
X	    XFlush(dsp);
X	    sleep(1);
X	    XFillRectangle(dsp, w, gc, ICONX, y - font->ascent,
X			   XTextWidth(font, validate, strlen(validate)),
X			   font->ascent + font->descent + 2);
X
X	    XDrawString(dsp, w, textgc, ICONX, y, invalid, strlen(invalid));
X	}
X    }
X    return (0);
X}
X
Xvoid
XjustDisplay()
X{
X    XEvent      event;
X
X    init(dsp, w, gc, color, inittime, count);
X    do {
X	while (!XPending(dsp)) {
X	    callback();
X	    if (reinit())
X		init(dsp, w, gc, color, inittime, count);
X	}
X	XNextEvent(dsp, &event);
X    } while (event.type != ButtonPress && event.type != KeyPress);
X}
X
Xvoid
XlockDisplay()
X{
X    do {
X	justDisplay();
X    } while (getPassword());
X}
X
X
Xvoid
Xusage()
X{
X    error("usage: %s %s\n",
X	  "[-time n] [-count n] [-font f] [-mono] [-saver] [-root] [-v]");
X}
X
X
Xmain(argc, argv)
X    int         argc;
X    char       *argv[];
X{
X    XSetWindowAttributes xswa;
X    XGCValues   xgcv;
X    XColor      black,
X                white;
X    int         i;
X    char       *s;
X    int         n;
X
X    pname = argv[0];
X    color = True;
X    lock = True;
X    skipRoot = -1;
X
X    for (i = 1; i < argc; i++) {
X	s = argv[i];
X	n = strlen(s);
X	if (!strncmp("-mono", s, n)) {
X	    color = False;
X	} else if (!strncmp("-saver", s, n)) {
X	    lock = False;
X	} else if (!strncmp("-root", s, n)) {
X	    skipRoot = False;
X	} else if (!strncmp("-verbose", s, n)) {
X	    verbose = True;
X	} else if (!strncmp("-time", s, n)) {
X	    if (++i >= argc)
X		usage();
X	    inittime = atoi(argv[i]);
X	    if (inittime < 1)
X		error("%s: time must be positive.", NULL);
X	} else if (!strncmp("-count", s, n)) {
X	    if (++i >= argc)
X		usage();
X	    count = atoi(argv[i]);
X	    if (count < 1)
X		error("%s: count must be positive.", NULL);
X	} else if (!strncmp("-font", s, n)) {
X	    if (++i >= argc)
X		usage();
X	    fontname = argv[i];
X	} else
X	    usage();
X    }
X
X    block();
X    signal(SIGINT, sigcatch);
X    signal(SIGQUIT, sigcatch);
X    signal(SIGSEGV, sigcatch);
X
X    if (!(dsp = XOpenDisplay(DISPLAYNAME)))
X	error("%s: unable to open display.\n", NULL);
X
X    if (fontname == NULL)
X	fontname = XGetDefault(dsp, pname, "font");
X    if (fontname == NULL)
X	fontname = DEFAULT_FONTNAME;
X
X    if (inittime == -1) {
X	s = XGetDefault(dsp, pname, "time");
X	if (s != NULL)
X	    inittime = atoi(s);
X	else
X	    inittime = DEFAULT_INITTIME;
X    }
X    if (count == -1) {
X	s = XGetDefault(dsp, pname, "count");
X	if (s != NULL)
X	    count = atoi(s);
X	else
X	    count = DEFAULT_COUNT;
X    }
X    if (skipRoot == -1) {
X	s = XGetDefault(dsp, pname, "root");
X	if (s != NULL)
X	    skipRoot = !(strncmp("on", s, strlen(s)) == 0);
X	else
X	    skipRoot = DEFAULT_SKIPROOT;
X    }
X    if (verbose) {
X	fprintf(stderr, "%s: Font: %s, Time: %d, Root: %s\n",
X		pname, fontname, inittime, skipRoot ? "False" : "True");
X    }
X    font = XLoadQueryFont(dsp, fontname);
X    if (font == NULL)
X	error("%s: can't find font: %s\n", fontname);
X
X    screen = DefaultScreen(dsp);
X    if (color)
X	color = (DisplayCells(dsp, screen) > 2);
X    root = RootWindow(dsp, screen);
X
X    if (color) {
X	if (XCreateHSBColormap(dsp, screen, &cmap, 256,
X			       0.0, 1.0, 1.0, 1.0, 1.0, 1.0, True) == Success)
X	    XInstallColormap(dsp, cmap);
X	else
X	    error("%s: couldn't create colormap.", NULL);
X    } else
X	cmap = DefaultColormap(dsp, screen);
X
X    black.pixel = BlackPixel(dsp, screen);
X    XQueryColor(dsp, cmap, &black);
X
X    white.pixel = WhitePixel(dsp, screen);
X    XQueryColor(dsp, cmap, &white);
X
X    lockc = XCreateBitmapFromData(dsp, root, no_bits, 1, 1);
X    lockm = XCreateBitmapFromData(dsp, root, no_bits, 1, 1);
X    mycursor = XCreatePixmapCursor(dsp, lockc, lockm, &black, &black, 0, 0);
X    XFreePixmap(dsp, lockc);
X    XFreePixmap(dsp, lockm);
X
X    xswa.cursor = mycursor;
X    xswa.override_redirect = True;
X    xswa.background_pixel = black.pixel;
X    xswa.event_mask = KeyPressMask | ButtonPressMask;
X
X    w = XCreateWindow(dsp, root,
X		      0, 0,
X		      DisplayWidth(dsp, screen),
X		      DisplayHeight(dsp, screen),
X		      0, CopyFromParent, InputOutput, CopyFromParent,
X		      CWCursor | CWOverrideRedirect |
X		      CWBackPixel | CWEventMask, &xswa);
X
X    xswa.cursor = XCreateFontCursor(dsp, XC_target);
X    xswa.background_pixel = white.pixel;
X    xswa.event_mask = ButtonPressMask;
X
X    icon = XCreateWindow(dsp, w,
X			 ICONX, ICONY,
X			 ICONW, ICONH,
X			 1, CopyFromParent, InputOutput, CopyFromParent,
X			 CWCursor | CWBackPixel | CWEventMask, &xswa);
X
X    XMapWindow(dsp, w);
X    XRaiseWindow(dsp, w);
X
X    xgcv.foreground = white.pixel;
X    xgcv.background = black.pixel;
X    gc = (GContext) XCreateGC(dsp, w, GCForeground | GCBackground, &xgcv);
X
X    xgcv.foreground = black.pixel;
X    xgcv.background = white.pixel;
X    xgcv.font = font->fid;
X    textgc = (GContext) XCreateGC(dsp, w,
X				GCFont | GCForeground | GCBackground, &xgcv);
X
X    XGetScreenSaver(dsp, &timeout, &interval, &blanking, &exposures);
X    XSetScreenSaver(dsp, 0, 0, 0, 0);	/* disable screen saver */
X
X    XLockDisplay(dsp);
X    allowsig();
X
X    srandom(getpid());
X
X    if (lock)
X	lockDisplay();
X    else
X	justDisplay();
X
X    finish();
X
X    if (lock)
X	unblock();
X
X    exit(0);
X}
END_OF_FILE
if test 15534 -ne `wc -c <'xlock.c'`; then
    echo shar: \"'xlock.c'\" unpacked with wrong size!
fi
# end of 'xlock.c'
fi
if test -f 'xlock.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xlock.man'\"
else
echo shar: Extracting \"'xlock.man'\" \(3314 characters\)
sed "s/^X//" >'xlock.man' <<'END_OF_FILE'
X.\" @(#)xlock.man 1.4 89/02/16; Copyright (c) 1989 - Sun Microsystems, Inc.
X.TH XLOCK 1 "16 Feb 1989" "X11/NeWS 1.0"
X.SH NAME
Xxlock \- Locks the local X display till a password is entered.
X.SH SYNOPSIS
X.B xlock
X[
X.BI \-time " timeout"
X]
X[
X.BI \-count " pixelcount"
X]
X[
X.B \-font " fontname"
X]
X[
X.B \-mono
X]
X[
X.B \-saver
X]
X[
X.B \-root
X]
X[
X.B \-v
X]
X.SH DESCRIPTION
X.B xlock
Xlocks the X server till the user enters their password at the keyboard.
XWhile
X.B xlock
Xis running,
Xall new server connections are refused.
XThe screen saver is disabled.
XThe mouse cursor is turned off.
XThe screen is blanked and the "real plane" iterative fractals from
Xthe September 1986 issue of Scientific American are put on the screen.
XThe pattern changes after
X.I timeout
Xseconds. 
XIf a key or a mouse button is pressed then the user is prompted for the
Xpassword of the user who started
X.B xlock.
X
XIf the correct password is typed, then the screen is unlocked and the X
Xserver is restored.  When typing the password, characters are not echoed
Xto the screen, but Control-U and Control-H are active as kill and erase
Xrespectively. 
X
X.SH OPTIONS
X.TP 5
X.B \-time " timeout"
XThe
X.I time
Xoption sets the number of seconds that each unique fractal will remain on
Xthe screen before being replaced by the next one to
X.I timeout.
X.TP 5
X.B \-count " pixelcount"
XThe
X.I count
Xoption sets the number of pixels to draw in each color.  The coordinates are
Xcalculated in batches of
X.I pixelcount
Xpixels, then sent to the screen in a single color.  Faster machines,
Xexpecially machines with floating point hardware can set this to a
Xhigher number and still have fast changing fractals.
X.TP 5
X.B \-font " fontname"
XThe
X.I font
Xoption sets the font to be used on the prompt screen.
X.TP 5
X.B \-mono
XThe
X.I mono
Xoption causes xlock to display monochrome, (black and white) pixels rather
Xthan the default colored ones.
X.TP 5
X.B \-saver
XThe
X.I saver
Xoption causes xlock to only draw the fractals and not lock the display.
XA keypress or a mouse click will terminate the screen saver.
X.TP 5
X.B \-root
XThe
X.I root
Xoption allows the root password to unlock the server as well as the user
Xwho started xlock.
X.SH BUGS
X"kill -KILL
X.B xlock
X" causes server to be unusable, since
X.B xlock
Xhas removed all hosts (including localhost) from the access control list
Xto lock out all new X clients, and SIGKILL cannot be caught by any program,
X.B xlock
Xwill terminate before restoring the access control list.  This will
Xleave the X server in a state where
X\fI "you can no longer connect to that server, and this operation cannot be
Xreversed short of resetting the server."\fP
X		-From the X11R2 Xlib Documentation page 140. 
X.SH SEE ALSO
XX(1), Xlib Documentation.
X
X.SH AUTHOR
X Patrick J. Naughton	 (naughton@wind.sun.com)
X Window Systems Group
X Sun Microsystems, Inc.
X Mountain View, CA  94043
X 415/336-1080
X
X.SH COPYRIGHT
X Copyright (c) 1989 by Sun Microsystems, Inc.
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation. 
X
X.SH CONTRIBUTORS
X  milliken@heron.bbn.com	karlton@wsl.dec.com
X  dana@thumper.bellcore.com	vesper@3d.dec.com
END_OF_FILE
if test 3314 -ne `wc -c <'xlock.man'`; then
    echo shar: \"'xlock.man'\" unpacked with wrong size!
fi
# end of 'xlock.man'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x