[comp.sources.x] v10i067: xlock, Part01/03

naughton@Eng (Patrick Naughton) (11/14/90)

Submitted-by: naughton@Eng (Patrick Naughton)
Posting-number: Volume 10, Issue 67
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 3)."
# Contents:  Imakefile MANIFEST Makefile README XLock.ad blank.c
#   hopalong.c hsbramp.c image.c lifeicon.bit patchlevel.h qix.c
#   sunlogo.bit swarm.c usleep.c xlock.h xlock.man
# Wrapped by naughton@wind on Tue Oct 30 11:26:50 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Imakefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(1135 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X# @(#)Imakefile 23.5 90/10/29
X# Imakefile - xlock
X#
X# Copyright (c) 1990 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#
X        DEFINES = -DDEF_FILESEARCHPATH=\"$(LIBDIR)/%T/%N%S\"
XLOCAL_LIBRARIES = $(XLIB)
X  SYS_LIBRARIES = -lm
X           SRCS = xlock.c hsbramp.c usleep.c resource.c \
X		hopalong.c qix.c life.c image.c blank.c swarm.c
X           OBJS = xlock.o hsbramp.o usleep.o resource.o \
X		hopalong.o qix.o life.o image.o blank.o swarm.o
X
XComplexProgramTarget(xlock)
XInstallAppDefaults(XLock)
END_OF_FILE
if test 1135 -ne `wc -c <'Imakefile'`; then
    echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1095 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X Imakefile                  1	best guess at an Imakefile
X MANIFEST                   1	This shipping list
X Makefile                   1	simple makefile for imake.
X README                     1	Latest revision notes
X XLock.ad                   1	resource file
X blank.c                    1	blank mode
X hopalong.c                 1	HOPALONG fractal mode
X hsbramp.c                  1	Hue/Saturation/Brightness code
X image.c                    1	bouncing image mode.
X life.c                     2	Life mode.
X lifeicon.bit               1	X bitmap Life uses.
X patchlevel.h               1	current patchlevel
X qix.c                      1	Qix(tm) mode.
X resource.c                 2	Xrm resource management code.
X sunlogo.bit                1	icon used by image mode.
X swarm.c                    1	Swarm mode
X usleep.c                   1	portable usleep() function.
X xlock.c                    3	main program.
X xlock.h                    1	global defines/externs.
X xlock.man                  1	man page
END_OF_FILE
if test 1095 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(468 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X            TOP = ./../..
X             MV = mv
X             RM = rm -f
X        UTILSRC = $(TOP)/util
X       IMAKESRC = $(UTILSRC)/imake
X       IRULESRC = $(UTILSRC)/imake.includes
X          IMAKE = $(IMAKESRC)/imake
X      IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl \
X                        -I$(NEWTOP)$(IRULESRC) \
X                        -s Makefile
X
XMakefile:: Imakefile
X        -$(RM) Makefile.bak; $(MV) Makefile Makefile.bak
X        $(IMAKE_CMD) -DTOPDIR=$(TOP)
END_OF_FILE
if test 468 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1751 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X
XThis is the latest version of xlock (sccs version 23.16) patchlevel = 2.1
X
XCHANGES:
X    o now uses Xrm for resource management.
X    o locks all screens on a server.
X    o new modes: swarm, image and blank.
X    o better usage message.
X    o support for locking remote machines (X terminals)
X    o changed color allocation to non-dynamic (so twm won't complain)
X    o center prompt screen (for hires displays).
X    o make sure Xlib input buffer does not use up all of swap.
X    o make displayed text come from resource file for better I18N.
X    o add backward compatible signal handlers for pre 4.1 machines.
X    o protect Host access from accessing freed data.
X    o autoraise when obscured by a pop-up.
X    o searches for machine name aliases.
X    o ported to SYSVR4.
X    o portable usleep().
X
X Copyright (c) 1988-90 by Patrick Naughton and 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    ______________________________________________________________________
X    Patrick J. Naughton				    ARPA: naughton@sun.com
X    Windows and Graphics Group			    UUCP: ...!sun!naughton
X    Sun Microsystems, Inc.			    AT&T: (415) 336 - 1080
END_OF_FILE
if test 1751 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'XLock.ad' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'XLock.ad'\"
else
echo shar: Extracting \"'XLock.ad'\" \(801 characters\)
sed "s/^X//" >'XLock.ad' <<'END_OF_FILE'
XXLock.mode:		swarm
XXLock.font:		-*-lucida-medium-r-normal-sans-24-*-*-*-*-*-*-*
XXLock.background:	gray
XXLock.foreground:	blue
XXLock.nice:		16
XXLock.timeout:		30
XXLock.mono:		false
XXLock.remote:		false
XXLock.nolock:		false
XXLock.allowroot:	false
XXLock.enablesaver:	false
XXLock.allowaccess:	true
XXLock.echokeys:		false
XXLock.verbose:		false
X
XXLock.hop.delay:	0
XXLock.hop.batchcount:	1000
XXLock.hop.saturation:	1
X
XXLock.image.delay:	2000000
XXLock.image.batchcount:	8
XXLock.image.saturation:	.2
X
XXLock.qix.delay:	30000
XXLock.qix.batchcount:	64
XXLock.qix.saturation:	1
X
XXLock.life.delay:	1000000
XXLock.life.batchcount:	1
XXLock.life.saturation:	1
X
XXLock.blank.delay:	5000000
XXLock.blank.batchcount:	1
XXLock.blank.saturation:	1
X
XXLock.swarm.delay:	10000
XXLock.swarm.batchcount:	100
XXLock.swarm.saturation:	1
END_OF_FILE
if test 801 -ne `wc -c <'XLock.ad'`; then
    echo shar: \"'XLock.ad'\" unpacked with wrong size!
fi
# end of 'XLock.ad'
fi
if test -f 'blank.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'blank.c'\"
else
echo shar: Extracting \"'blank.c'\" \(1347 characters\)
sed "s/^X//" >'blank.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)blank.c	1.3 90/10/28 XLOCK SMI";
X#endif
X/*-
X * blank.c - blank screen for the xlock X11 terminal locker.
X *
X * Copyright (c) 1990 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 31-Aug-90: Written.
X */
X
X#include "xlock.h"
X
X/*ARGSUSED*/
Xvoid
Xdrawblank(win)
X    Window      win;
X{
X}
X
Xvoid
Xinitblank(win)
X    Window      win;
X{
X    XClearWindow(dsp, win);
X}
END_OF_FILE
if test 1347 -ne `wc -c <'blank.c'`; then
    echo shar: \"'blank.c'\" unpacked with wrong size!
fi
# end of 'blank.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'\" \(4115 characters\)
sed "s/^X//" >'hopalong.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)hopalong.c	23.7 90/10/29 XLOCK SMI";
X#endif
X/*-
X * hopalong.c - Real Plane Fractals for the xlock X11 terminal locker.
X *
X * Copyright (c) 1988-90 by Patrick Naughton and 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 29-Oct-90: fix bad (int) cast.
X * 29-Jul-90: support for multiple screens.
X * 08-Jul-90: new timing and colors and new algorithm for fractals.
X * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors.
X * 08-Oct-89: Fixed long standing typo bug in RandomInitHop();
X *	      Fixed bug in memory allocation in inithop();
X *	      Moved seconds() to an extern.
X *	      Got rid of the % mod since .mod is slow on a sparc.
X * 20-Sep-89: Lint.
X * 31-Aug-88: Forked from xlock.c for modularity.
X * 23-Mar-88: Coded HOPALONG routines from Scientific American Sept. 86 p. 14.
X */
X
X#include "xlock.h"
X#include <math.h>
X
Xtypedef struct {
X    int         centerx;
X    int         centery;	/* center of the screen */
X    double      a;
X    double      b;
X    double      c;
X    double      i;
X    double      j;		/* hopalong parameters */
X    int         inc;
X    int         pix;
X    long        startTime;
X}           hopstruct;
X
Xstatic hopstruct hops[MAXSCREENS];
Xstatic XPoint *pointBuffer = 0;	/* pointer for XDrawPoints */
X
X#define TIMEOUT 30
X#define MAXRAND (4294967296.0)	/* 2^32 */
X
Xvoid
Xinithop(win)
X    Window      win;
X{
X    double      range;
X    XWindowAttributes xgwa;
X    hopstruct  *hp = &hops[screen];
X
X
X    XGetWindowAttributes(dsp, win, &xgwa);
X    hp->centerx = xgwa.width / 2;
X    hp->centery = xgwa.height / 2;
X    range = sqrt((double) hp->centerx * hp->centerx +
X		 (double) hp->centery * hp->centery) /
X	(10.0 + random() % 10);
X
X    hp->pix = 0;
X    hp->inc = (int) ((random() / MAXRAND) * 400) - 200;
X    hp->a = (random() / MAXRAND) * range - range / 2.0;
X    hp->b = (random() / MAXRAND) * range - range / 2.0;
X    hp->c = (random() / MAXRAND) * range - range / 2.0;
X    if (!(random() % 2))
X	hp->c = 0.0;
X
X    hp->i = hp->j = 0.0;
X
X    if (!pointBuffer)
X	pointBuffer = (XPoint *) malloc(batchcount * sizeof(XPoint));
X
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XFillRectangle(dsp, win, Scr[screen].gc, 0, 0,
X		   hp->centerx * 2, hp->centery * 2);
X    XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen));
X    hp->startTime = seconds();
X}
X
X
Xvoid
Xdrawhop(win)
X    Window      win;
X{
X    double      oldj;
X    int         k = batchcount;
X    XPoint     *xp = pointBuffer;
X    hopstruct  *hp = &hops[screen];
X
X    hp->inc++;
X    if (!mono && Scr[screen].npixels > 2) {
X	XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[hp->pix]);
X	if (++hp->pix >= Scr[screen].npixels)
X	    hp->pix = 0;
X    }
X    while (k--) {
X	oldj = hp->j;
X	hp->j = hp->a - hp->i;
X	hp->i = oldj + (hp->i < 0
X			? sqrt(fabs(hp->b * (hp->i + hp->inc) - hp->c))
X			: -sqrt(fabs(hp->b * (hp->i + hp->inc) - hp->c)));
X	xp->x = hp->centerx + (int) (hp->i + hp->j);
X	xp->y = hp->centery - (int) (hp->i - hp->j);
X	xp++;
X    }
X    XDrawPoints(dsp, win, Scr[screen].gc,
X		pointBuffer, batchcount, CoordModeOrigin);
X    if (seconds() - hp->startTime > TIMEOUT)
X	inithop(win);
X}
END_OF_FILE
if test 4115 -ne `wc -c <'hopalong.c'`; then
    echo shar: \"'hopalong.c'\" unpacked with wrong size!
fi
# end of 'hopalong.c'
fi
if test -f 'hsbramp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'hsbramp.c'\"
else
echo shar: Extracting \"'hsbramp.c'\" \(3001 characters\)
sed "s/^X//" >'hsbramp.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)hsbramp.c	23.4 90/10/28 XLOCK SMI";
X#endif
X/*-
X * hsbramp.c - Create an HSB ramp.
X *
X * Copyright (c) 1988-90 by Patrick Naughton and 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 29-Jul-90: renamed hsbramp.c from HSBmap.c
X *	      minor optimizations.
X * 01-Sep-88: Written.
X */
X
X#include <sys/types.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    int         i;
X    double      f;
X    double      bb;
X    u_char      p;
X    u_char      q;
X    u_char      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
X/*
X * Input is two points in HSB color space and a count
X * of how many discreet rgb space values the caller wants.
X *
X * Output is that many rgb triples which describe a linear
X * interpolate ramp between the two input colors.
X */
X
Xvoid
Xhsbramp(h1, s1, b1, h2, s2, b2, count, red, green, blue)
X    double      h1,
X                s1,
X                b1,
X                h2,
X                s2,
X                b2;
X    int         count;
X
X    u_char     *red,
X               *green,
X               *blue;
X{
X    double      dh;
X    double      ds;
X    double      db;
X
X    dh = (h2 - h1) / count;
X    ds = (s2 - s1) / count;
X    db = (b2 - b1) / count;
X    while (count--) {
X	hsb2rgb(h1, s1, b1, red++, green++, blue++);
X	h1 += dh;
X	s1 += ds;
X	b1 += db;
X    }
X}
END_OF_FILE
if test 3001 -ne `wc -c <'hsbramp.c'`; then
    echo shar: \"'hsbramp.c'\" unpacked with wrong size!
fi
# end of 'hsbramp.c'
fi
if test -f 'image.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'image.c'\"
else
echo shar: Extracting \"'image.c'\" \(3782 characters\)
sed "s/^X//" >'image.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)image.c	1.5 90/10/28 XLOCK SMI";
X#endif
X/*-
X * image.c - image bouncer for the xlock X11 terminal locker.
X *
X * Copyright (c) 1990 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 authors:
X *
X *		       naughton@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 29-Jul-90: Written.
X */
X
X#include "xlock.h"
X#include "sunlogo.bit"
X
Xstatic XImage logo = {
X    0, 0,			/* width, height */
X    0, XYBitmap, 0,		/* xoffset, format, data */
X    LSBFirst, 8,		/* byte-order, bitmap-unit */
X    LSBFirst, 8, 1		/* bitmap-bit-order, bitmap-pad, depth */
X};
X
X#define MAXICONS 256
X
Xtypedef struct {
X    int         x;
X    int         y;
X}           point;
X
Xtypedef struct {
X    int         width;
X    int         height;
X    int         nrows;
X    int         ncols;
X    int         xb;
X    int         yb;
X    int         iconmode;
X    int         iconcount;
X    point       icons[MAXICONS];
X    long        startTime;
X}           imagestruct;
X
Xstatic imagestruct ims[MAXSCREENS];
X
Xvoid
Xdrawimage(win)
X    Window      win;
X{
X    imagestruct *ip = &ims[screen];
X    int         i;
X
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    for (i = 0; i < ip->iconcount; i++) {
X	if (!ip->iconmode)
X	    XFillRectangle(dsp, win, Scr[screen].gc,
X			   ip->xb + sunlogo_width * ip->icons[i].x,
X			   ip->yb + sunlogo_height * ip->icons[i].y,
X			   sunlogo_width, sunlogo_height);
X
X	ip->icons[i].x = random() % ip->ncols;
X	ip->icons[i].y = random() % ip->nrows;
X    }
X    if (Scr[screen].npixels == 2)
X	XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen));
X    for (i = 0; i < ip->iconcount; i++) {
X	if (Scr[screen].npixels > 2)
X	    XSetForeground(dsp, Scr[screen].gc,
X			 Scr[screen].pixels[random() % Scr[screen].npixels]);
X
X	XPutImage(dsp, win, Scr[screen].gc, &logo,
X		  0, 0,
X		  ip->xb + sunlogo_width * ip->icons[i].x,
X		  ip->yb + sunlogo_height * ip->icons[i].y,
X		  sunlogo_width, sunlogo_height);
X    }
X}
X
Xvoid
Xinitimage(win)
X    Window      win;
X{
X    XWindowAttributes xgwa;
X    imagestruct *ip = &ims[screen];
X
X    ip->startTime = seconds();
X    srandom(time((long *) 0));
X
X    logo.data = sunlogo_bits;
X    logo.width = sunlogo_width;
X    logo.height = sunlogo_height;
X    logo.bytes_per_line = (sunlogo_width + 7) / 8;
X
X    XGetWindowAttributes(dsp, win, &xgwa);
X    ip->width = xgwa.width;
X    ip->height = xgwa.height;
X    ip->ncols = ip->width / sunlogo_width;
X    ip->nrows = ip->height / sunlogo_height;
X    ip->iconmode = (ip->ncols < 2 || ip->nrows < 2);
X    if (ip->iconmode) {
X	ip->xb = 0;
X	ip->yb = 0;
X	ip->iconcount = 1;	/* icon mode */
X    } else {
X	ip->xb = (ip->width - sunlogo_width * ip->ncols) / 2;
X	ip->yb = (ip->height - sunlogo_height * ip->nrows) / 2;
X	ip->iconcount = batchcount;
X    }
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, ip->width, ip->height);
X}
END_OF_FILE
if test 3782 -ne `wc -c <'image.c'`; then
    echo shar: \"'image.c'\" unpacked with wrong size!
fi
# end of 'image.c'
fi
if test -f 'lifeicon.bit' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lifeicon.bit'\"
else
echo shar: Extracting \"'lifeicon.bit'\" \(812 characters\)
sed "s/^X//" >'lifeicon.bit' <<'END_OF_FILE'
X#define lifeicon_width 29
X#define lifeicon_height 29
Xstatic char lifeicon_bits[] = {
X   0x00, 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0xb8, 0x03, 0x00,
X   0x00, 0x74, 0x07, 0x00, 0x00, 0xee, 0x0e, 0x00, 0x00, 0xdd, 0x1d, 0x00,
X   0x80, 0xbb, 0x3b, 0x00, 0x40, 0x77, 0x57, 0x00, 0xe0, 0xee, 0xee, 0x00,
X   0x70, 0xdd, 0x75, 0x01, 0xb8, 0xbb, 0xb9, 0x03, 0xdc, 0xf1, 0xdd, 0x01,
X   0xee, 0xee, 0xee, 0x0e, 0x77, 0x1f, 0x77, 0x1f, 0xbb, 0x1b, 0xbb, 0x1b,
X   0xdf, 0x1d, 0xdf, 0x1d, 0xee, 0xee, 0xee, 0x0e, 0x70, 0xf7, 0x71, 0x07,
X   0xb8, 0xb3, 0xbb, 0x03, 0xd0, 0x75, 0xd7, 0x01, 0xe0, 0xee, 0xee, 0x00,
X   0x40, 0xdd, 0x5d, 0x00, 0x80, 0xbb, 0x3b, 0x00, 0x00, 0x77, 0x17, 0x00,
X   0x00, 0xee, 0x0e, 0x00, 0x00, 0xdc, 0x05, 0x00, 0x00, 0xb8, 0x01, 0x00,
X   0x00, 0xf0, 0x01, 0x00, 0x00, 0xe0, 0x00, 0x00};
END_OF_FILE
if test 812 -ne `wc -c <'lifeicon.bit'`; then
    echo shar: \"'lifeicon.bit'\" unpacked with wrong size!
fi
# end of 'lifeicon.bit'
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'\" \(4 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X2.1
END_OF_FILE
if test 4 -ne `wc -c <'patchlevel.h'`; then
    echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'qix.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'qix.c'\"
else
echo shar: Extracting \"'qix.c'\" \(4754 characters\)
sed "s/^X//" >'qix.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)qix.c	23.7 90/10/28 XLOCK SMI";
X#endif
X/*-
X * qix.c - The old standby vector swirl for the xlock X11 terminal locker.
X *
X * Copyright (c) 1989-90 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 29-Jul-90: support for multiple heads.
X *	      made check_bounds_?() a macro.
X *	      fixed initial parameter setup.
X * 15-Dec-89: Fix for proper skipping of {White,Black}Pixel() in colors.
X * 08-Oct-89: Fixed bug in memory allocation in initqix().
X *	      Moved seconds() to an extern.
X * 23-Sep-89: Switch to random() and fixed bug w/ less than 4 lines.
X * 20-Sep-89: Lint.
X * 24-Mar-89: Written.
X */
X
X#include "xlock.h"
X
Xtypedef struct {
X    int         x;
X    int         y;
X}           point;
X
Xtypedef struct {
X    int         pix;
X    long        startTime;
X    int         first;
X    int         last;
X    int         dx1;
X    int         dy1;
X    int         dx2;
X    int         dy2;
X    int         x1;
X    int         y1;
X    int         x2;
X    int         y2;
X    int         offset;
X    int         delta;
X    int         width;
X    int         height;
X    int         nlines;
X    point      *lineq;
X}           qixstruct;
X
Xstatic qixstruct qixs[MAXSCREENS];
X
Xvoid
Xinitqix(win)
X    Window      win;
X{
X    XWindowAttributes xgwa;
X    qixstruct  *qp = &qixs[screen];
X
X    qp->startTime = seconds();
X    srandom(time((long *) 0));
X
X    qp->nlines = (batchcount + 1) * 2;
X    if (!qp->lineq) {
X	qp->lineq = (point *) malloc(qp->nlines * sizeof(point));
X	memset(qp->lineq, '\0', qp->nlines * sizeof(point));
X    }
X
X    XGetWindowAttributes(dsp, win, &xgwa);
X    qp->width = xgwa.width;
X    qp->height = xgwa.height;
X    qp->delta = 16;
X
X    if (qp->width < 100) {	/* icon window */
X	qp->nlines /= 4;
X	qp->delta /= 4;
X    }
X    qp->offset = qp->delta / 3;
X    qp->last = 0;
X    qp->pix = 0;
X    qp->dx1 = random() % qp->delta + qp->offset;
X    qp->dy1 = random() % qp->delta + qp->offset;
X    qp->dx2 = random() % qp->delta + qp->offset;
X    qp->dy2 = random() % qp->delta + qp->offset;
X    qp->x1 = random() % qp->width;
X    qp->y1 = random() % qp->height;
X    qp->x2 = random() % qp->width;
X    qp->y2 = random() % qp->height;
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, qp->width, qp->height);
X}
X
X#define check_bounds(qp, val, del, max)				\
X{								\
X    if ((val) < 0) {						\
X	*(del) = (random() % (qp)->delta) + (qp)->offset;	\
X    } else if ((val) > (max)) {					\
X	*(del) = -(random() % (qp)->delta) - (qp)->offset;	\
X    }								\
X}
X
Xvoid
Xdrawqix(win)
X    Window      win;
X{
X    qixstruct  *qp = &qixs[screen];
X
X    qp->first = (qp->last + 2) % qp->nlines;
X
X    qp->x1 += qp->dx1;
X    qp->y1 += qp->dy1;
X    qp->x2 += qp->dx2;
X    qp->y2 += qp->dy2;
X    check_bounds(qp, qp->x1, &qp->dx1, qp->width);
X    check_bounds(qp, qp->y1, &qp->dy1, qp->height);
X    check_bounds(qp, qp->x2, &qp->dx2, qp->width);
X    check_bounds(qp, qp->y2, &qp->dy2, qp->height);
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XDrawLine(dsp, win, Scr[screen].gc,
X	      qp->lineq[qp->first].x, qp->lineq[qp->first].y,
X	      qp->lineq[qp->first + 1].x, qp->lineq[qp->first + 1].y);
X    if (!mono && Scr[screen].npixels > 2) {
X	XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[qp->pix]);
X	if (++qp->pix >= Scr[screen].npixels)
X	    qp->pix = 0;
X    } else
X	XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen));
X
X    XDrawLine(dsp, win, Scr[screen].gc, qp->x1, qp->y1, qp->x2, qp->y2);
X
X    qp->lineq[qp->last].x = qp->x1;
X    qp->lineq[qp->last].y = qp->y1;
X    qp->last++;
X    if (qp->last >= qp->nlines)
X	qp->last = 0;
X
X    qp->lineq[qp->last].x = qp->x2;
X    qp->lineq[qp->last].y = qp->y2;
X    qp->last++;
X    if (qp->last >= qp->nlines)
X	qp->last = 0;
X}
END_OF_FILE
if test 4754 -ne `wc -c <'qix.c'`; then
    echo shar: \"'qix.c'\" unpacked with wrong size!
fi
# end of 'qix.c'
fi
if test -f 'sunlogo.bit' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'sunlogo.bit'\"
else
echo shar: Extracting \"'sunlogo.bit'\" \(3284 characters\)
sed "s/^X//" >'sunlogo.bit' <<'END_OF_FILE'
X#define sunlogo_width 64
X#define sunlogo_height 64
Xstatic char sunlogo_bits[] = {
X   0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
X   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc,
X   0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x7e, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0xfe,
X   0xfe, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xfc, 0xfd, 0x07, 0x00, 0x00,
X   0x00, 0x00, 0xf0, 0xfd, 0xfb, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xfb,
X   0xf7, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xf4, 0xf7, 0xef, 0x3f, 0x00, 0x00,
X   0x00, 0x00, 0xee, 0xef, 0xdf, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xdf, 0xdf,
X   0xbf, 0xff, 0x00, 0x00, 0x00, 0x80, 0xbf, 0xbf, 0x7f, 0xff, 0x00, 0x00,
X   0x00, 0x80, 0x7f, 0x7f, 0xff, 0x7e, 0x03, 0x00, 0x00, 0x60, 0xff, 0xfe,
X   0xfe, 0xbd, 0x07, 0x00, 0x00, 0xf0, 0xfe, 0xfd, 0xfd, 0xdb, 0x0f, 0x00,
X   0x00, 0xf8, 0xfd, 0xfb, 0xfb, 0xe7, 0x1f, 0x00, 0x00, 0xfc, 0xfb, 0xf7,
X   0xf7, 0xf7, 0x2f, 0x00, 0x00, 0xfe, 0xf5, 0xef, 0xef, 0xfb, 0x77, 0x00,
X   0x00, 0xff, 0xee, 0xdf, 0xcf, 0xfd, 0xfb, 0x00, 0x80, 0x7f, 0xdf, 0xbf,
X   0x9f, 0xfe, 0xfd, 0x01, 0xc0, 0xbf, 0xbf, 0xff, 0x1f, 0xff, 0xfe, 0x00,
X   0xe0, 0xdf, 0x1f, 0xff, 0x9f, 0x7f, 0x7f, 0x00, 0xf0, 0xef, 0x0f, 0xfe,
X   0xcf, 0xbf, 0x3f, 0x07, 0xf8, 0xf7, 0xe7, 0xfc, 0xef, 0xdf, 0xdf, 0x1f,
X   0xfc, 0xfb, 0xfb, 0xfb, 0xf7, 0xef, 0xef, 0x3f, 0xfe, 0xfd, 0xfd, 0xe7,
X   0xf9, 0xf7, 0xf7, 0x7f, 0xfe, 0xfe, 0xfe, 0x07, 0xf8, 0xfb, 0xfb, 0x7f,
X   0x7f, 0x7f, 0xff, 0x0f, 0xfc, 0xfd, 0xfd, 0xff, 0xbf, 0xbf, 0xff, 0x0f,
X   0xfc, 0xfe, 0xfe, 0xff, 0xff, 0xdf, 0xdf, 0x0f, 0xfc, 0x7f, 0xff, 0xfe,
X   0xff, 0xef, 0xef, 0x0f, 0xfc, 0xbf, 0x7f, 0xff, 0xfe, 0xf7, 0xf7, 0x07,
X   0xf8, 0xdf, 0xbf, 0x7f, 0xfe, 0xfb, 0xfb, 0xe7, 0xf9, 0xef, 0xdf, 0x7f,
X   0xfc, 0xfd, 0xfd, 0xfb, 0xf7, 0xf7, 0xef, 0x3f, 0x70, 0xfe, 0xfe, 0xfd,
X   0xcf, 0xf9, 0xf7, 0x1f, 0x00, 0x7f, 0xff, 0xfc, 0x1f, 0xfc, 0xfb, 0x0f,
X   0x80, 0xbf, 0x7f, 0xfe, 0x3f, 0xfe, 0xfd, 0x07, 0xc0, 0xdf, 0x3f, 0xfe,
X   0x7f, 0xff, 0xfe, 0x03, 0x80, 0xef, 0x5f, 0x7e, 0xff, 0x7e, 0xff, 0x01,
X   0x00, 0xf7, 0xef, 0xfc, 0xfe, 0xbd, 0xff, 0x00, 0x00, 0xfa, 0xf7, 0xfd,
X   0xfd, 0xdb, 0x7f, 0x00, 0x00, 0xfc, 0xfb, 0xfb, 0xfb, 0xe7, 0x3f, 0x00,
X   0x00, 0xf8, 0xf9, 0xf7, 0xf7, 0xef, 0x1f, 0x00, 0x00, 0xf0, 0xee, 0xef,
X   0xef, 0xdf, 0x0f, 0x00, 0x00, 0x60, 0xdf, 0xdf, 0xdf, 0xbf, 0x07, 0x00,
X   0x00, 0x80, 0xbf, 0xbf, 0xbf, 0x7f, 0x03, 0x00, 0x00, 0x80, 0x7f, 0x7f,
X   0x7f, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xfe, 0xfe, 0xfe, 0x00, 0x00,
X   0x00, 0x00, 0xfe, 0xfd, 0xfd, 0x7d, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xfb,
X   0xfb, 0x3b, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xf7, 0xf7, 0x17, 0x00, 0x00,
X   0x00, 0x00, 0xf0, 0xef, 0xef, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xdf,
X   0xdf, 0x07, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xbf, 0x9f, 0x03, 0x00, 0x00,
X   0x00, 0x00, 0x80, 0x7f, 0x3f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
X   0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0xfc, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8,
X   0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00};
END_OF_FILE
if test 3284 -ne `wc -c <'sunlogo.bit'`; then
    echo shar: \"'sunlogo.bit'\" unpacked with wrong size!
fi
# end of 'sunlogo.bit'
fi
if test -f 'swarm.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'swarm.c'\"
else
echo shar: Extracting \"'swarm.c'\" \(6572 characters\)
sed "s/^X//" >'swarm.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)swarm.c	1.3 90/10/28 XLOCK SMI";
X#endif
X/*-
X * swarm.c - swarm of bees for the xlock X11 terminal locker.
X *
X * Copyright (c) 1990 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 31-Aug-90: Adapted from xswarm by Jeff Butterworth. (butterwo@ncsc.org)
X */
X
X#include "xlock.h"
X
X#define TIMES	4		/* number of time positions recorded */
X#define BEEACC	3		/* acceleration of bees */
X#define WASPACC 5		/* maximum acceleration of wasp */
X#define BEEVEL	11		/* maximum bee velocity */
X#define WASPVEL 12		/* maximum wasp velocity */
X#define BORDER	50		/* wasp won't go closer than this to the edge */
X
X/* Macros */
X#define X(t,b)	(sp->x[(t)*sp->beecount+(b)])
X#define Y(t,b)	(sp->y[(t)*sp->beecount+(b)])
X#define RAND(v)	((random()%(v))-((v)/2))	/* random number around 0 */
X
Xtypedef struct {
X    int         pix;
X    long        startTime;
X    int         width;
X    int         height;
X    int         beecount;	/* number of bees */
X    XSegment   *segs;		/* bee lines */
X    XSegment   *old_segs;	/* old bee lines */
X    short      *x;
X    short      *y;		/* bee positions x[time][bee#] */
X    short      *xv;
X    short      *yv;		/* bee velocities xv[bee#] */
X    short       wx[3];
X    short       wy[3];
X    short       wxv;
X    short       wyv;
X}           swarmstruct;
X
Xstatic swarmstruct swarms[MAXSCREENS];
X
Xvoid
Xinitswarm(win)
X    Window      win;
X{
X    XWindowAttributes xgwa;
X    swarmstruct *sp = &swarms[screen];
X    int         b;
X
X    sp->startTime = seconds();
X    srandom(time((long *) 0));
X
X    sp->beecount = batchcount;
X
X    XGetWindowAttributes(dsp, win, &xgwa);
X    sp->width = xgwa.width;
X    sp->height = xgwa.height;
X
X    /* Clear the background. */
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, sp->width, sp->height);
X
X    /* Get the random number generator reasp->dy. */
X    srandom((int) time(0) % 231);
X
X    /* Allocate memory. */
X
X    if (!sp->segs) {
X	sp->segs = (XSegment *) malloc(sizeof(XSegment) * sp->beecount);
X	sp->old_segs = (XSegment *) malloc(sizeof(XSegment) * sp->beecount);
X	sp->x = (short *) malloc(sizeof(short) * sp->beecount * TIMES);
X	sp->y = (short *) malloc(sizeof(short) * sp->beecount * TIMES);
X	sp->xv = (short *) malloc(sizeof(short) * sp->beecount);
X	sp->yv = (short *) malloc(sizeof(short) * sp->beecount);
X    }
X    /* Initialize point positions, velocities, etc. */
X
X    /* wasp */
X    sp->wx[0] = BORDER + random() % (sp->width - 2 * BORDER);
X    sp->wy[0] = BORDER + random() % (sp->height - 2 * BORDER);
X    sp->wx[1] = sp->wx[0];
X    sp->wy[1] = sp->wy[0];
X    sp->wxv = 0;
X    sp->wyv = 0;
X
X    /* bees */
X    for (b = 0; b < sp->beecount; b++) {
X	X(0, b) = random() % sp->width;
X	X(1, b) = X(0, b);
X	Y(0, b) = random() % sp->height;
X	Y(1, b) = Y(0, b);
X	sp->xv[b] = RAND(7);
X	sp->yv[b] = RAND(7);
X    }
X}
X
X
X
Xvoid
Xdrawswarm(win)
X    Window      win;
X{
X    swarmstruct *sp = &swarms[screen];
X    int         b;
X
X    /* <=- Wasp -=> */
X    /* Age the arrays. */
X    sp->wx[2] = sp->wx[1];
X    sp->wx[1] = sp->wx[0];
X    sp->wy[2] = sp->wy[1];
X    sp->wy[1] = sp->wy[0];
X    /* Accelerate */
X    sp->wxv += RAND(WASPACC);
X    sp->wyv += RAND(WASPACC);
X
X    /* Speed Limit Checks */
X    if (sp->wxv > WASPVEL)
X	sp->wxv = WASPVEL;
X    if (sp->wxv < -WASPVEL)
X	sp->wxv = -WASPVEL;
X    if (sp->wyv > WASPVEL)
X	sp->wyv = WASPVEL;
X    if (sp->wyv < -WASPVEL)
X	sp->wyv = -WASPVEL;
X
X    /* Move */
X    sp->wx[0] = sp->wx[1] + sp->wxv;
X    sp->wy[0] = sp->wy[1] + sp->wyv;
X
X    /* Bounce Checks */
X    if ((sp->wx[0] < BORDER) || (sp->wx[0] > sp->width - BORDER - 1)) {
X	sp->wxv = -sp->wxv;
X	sp->wx[0] += sp->wxv;
X    }
X    if ((sp->wy[0] < BORDER) || (sp->wy[0] > sp->height - BORDER - 1)) {
X	sp->wyv = -sp->wyv;
X	sp->wy[0] += sp->wyv;
X    }
X    /* Don't let things settle down. */
X    sp->xv[random() % sp->beecount] += RAND(3);
X    sp->yv[random() % sp->beecount] += RAND(3);
X
X    /* <=- Bees -=> */
X    for (b = 0; b < sp->beecount; b++) {
X	int         distance,
X	            dx,
X	            dy;
X	/* Age the arrays. */
X	X(2, b) = X(1, b);
X	X(1, b) = X(0, b);
X	Y(2, b) = Y(1, b);
X	Y(1, b) = Y(0, b);
X
X	/* Accelerate */
X	dx = sp->wx[1] - X(1, b);
X	dy = sp->wy[1] - Y(1, b);
X	distance = abs(dx) + abs(dy);	/* approximation */
X	if (distance == 0)
X	    distance = 1;
X	sp->xv[b] += (dx * BEEACC) / distance;
X	sp->yv[b] += (dy * BEEACC) / distance;
X
X	/* Speed Limit Checks */
X	if (sp->xv[b] > BEEVEL)
X	    sp->xv[b] = BEEVEL;
X	if (sp->xv[b] < -BEEVEL)
X	    sp->xv[b] = -BEEVEL;
X	if (sp->yv[b] > BEEVEL)
X	    sp->yv[b] = BEEVEL;
X	if (sp->yv[b] < -BEEVEL)
X	    sp->yv[b] = -BEEVEL;
X
X	/* Move */
X	X(0, b) = X(1, b) + sp->xv[b];
X	Y(0, b) = Y(1, b) + sp->yv[b];
X
X	/* Fill the segment lists. */
X	sp->segs[b].x1 = X(0, b);
X	sp->segs[b].y1 = Y(0, b);
X	sp->segs[b].x2 = X(1, b);
X	sp->segs[b].y2 = Y(1, b);
X	sp->old_segs[b].x1 = X(1, b);
X	sp->old_segs[b].y1 = Y(1, b);
X	sp->old_segs[b].x2 = X(2, b);
X	sp->old_segs[b].y2 = Y(2, b);
X    }
X
X    XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
X    XDrawLine(dsp, win, Scr[screen].gc,
X	      sp->wx[1], sp->wy[1], sp->wx[2], sp->wy[2]);
X    XDrawSegments(dsp, win, Scr[screen].gc, sp->old_segs, sp->beecount);
X
X    XSetForeground(dsp, Scr[screen].gc, WhitePixel(dsp, screen));
X    XDrawLine(dsp, win, Scr[screen].gc,
X	      sp->wx[0], sp->wy[0], sp->wx[1], sp->wy[1]);
X    if (!mono && Scr[screen].npixels > 2) {
X	XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[sp->pix]);
X	if (++sp->pix >= Scr[screen].npixels)
X	    sp->pix = 0;
X    }
X    XDrawSegments(dsp, win, Scr[screen].gc, sp->segs, sp->beecount);
X}
END_OF_FILE
if test 6572 -ne `wc -c <'swarm.c'`; then
    echo shar: \"'swarm.c'\" unpacked with wrong size!
fi
# end of 'swarm.c'
fi
if test -f 'usleep.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'usleep.c'\"
else
echo shar: Extracting \"'usleep.c'\" \(1832 characters\)
sed "s/^X//" >'usleep.c' <<'END_OF_FILE'
X#ifndef lint
Xstatic char sccsid[] = "@(#)usleep.c	1.2 90/10/28 XLOCK SMI";
X#endif
X/*-
X * usleep.c - OS dependant implementation of usleep().
X *
X * Copyright (c) 1990 by Patrick Naughton and 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@eng.sun.com
X *
X *		       Patrick J. Naughton
X *		       MS 14-01
X *		       Windows and Graphics Group
X *		       Sun Microsystems, Inc.
X *		       2550 Garcia Ave
X *		       Mountain View, CA  94043
X *
X * Revision History:
X * 30-Aug-90: written.
X *
X */
X
X#include "xlock.h"
X
Xint
Xusleep(usec)
X    unsigned long usec;
X{
X#ifdef SYSV
X    poll((struct poll *) 0, (size_t) 0, usec / 1000);	/* ms resolution */
X#else
X    struct timeval timeout;
X    timeout.tv_usec = usec % (unsigned long) 1000000;
X    timeout.tv_sec = usec / (unsigned long) 1000000;
X    select(0, (void *) 0, (void *) 0, (void *) 0, &timeout);
X#endif
X    return 0;
X}
X
X/*
X * returns the number of seconds since 01-Jan-70.
X * This is used to control rate and timeout in many of the animations.
X */
Xlong
Xseconds()
X{
X    struct timeval now;
X
X    gettimeofday(&now, (struct timezone *) 0);
X    return now.tv_sec;
X}
END_OF_FILE
if test 1832 -ne `wc -c <'usleep.c'`; then
    echo shar: \"'usleep.c'\" unpacked with wrong size!
fi
# end of 'usleep.c'
fi
if test -f 'xlock.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xlock.h'\"
else
echo shar: Extracting \"'xlock.h'\" \(1516 characters\)
sed "s/^X//" >'xlock.h' <<'END_OF_FILE'
X/*
X * @(#)xlock.h	1.6 90/10/28 XLOCK SMI
X */
X
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/Xos.h>
X
X#define MAXSCREENS 3
X#define NUMCOLORS 64
X
Xtypedef struct {
X    GC          gc;		/* graphics context for animation */
X    int         npixels;	/* number of valid entries in pixels */
X    u_long      pixels[NUMCOLORS];	/* pixel values in the colormap */
X}           perscreen;
X
Xextern perscreen Scr[MAXSCREENS];
Xextern Display *dsp;
Xextern int  screen;
X
Xextern char *ProgramName;
Xextern char *display;
Xextern char *mode;
Xextern char *fontname;
Xextern char *background;
Xextern char *foreground;
Xextern char *text_name;
Xextern char *text_pass;
Xextern char *text_info;
Xextern char *text_valid;
Xextern char *text_invalid;
Xextern float saturation;
Xextern int  nicelevel;
Xextern int  delay;
Xextern int  batchcount;
Xextern int  reinittime;
Xextern int  timeout;
Xextern Bool mono;
Xextern Bool nolock;
Xextern Bool allowroot;
Xextern Bool enablesaver;
Xextern Bool allowaccess;
Xextern Bool echokeys;
Xextern Bool verbose;
Xextern void (*callback) ();
Xextern void (*init) ();
X
Xextern void GetResources();
Xextern void hsbramp();
Xextern void error();
Xextern long seconds();
Xextern void usage();
X
X/* System V Release 4 redefinitions of BSD functions and structures */
X
X#ifdef SYSV
X
X#include <sys/time.h>
X#include <poll.h>
X#include <shadow.h>
X#define srandom srand
X#define random rand
X#define USERNAME "LOGNAME"
X#define passwd spwd
X#define pw_passwd sp_pwdp
X#define getpwnam getspnam
X
X#else
X
X#define USERNAME "USER"
X
X#endif
END_OF_FILE
if test 1516 -ne `wc -c <'xlock.h'`; then
    echo shar: \"'xlock.h'\" unpacked with wrong size!
fi
# end of 'xlock.h'
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'\" \(7393 characters\)
sed "s/^X//" >'xlock.man' <<'END_OF_FILE'
X.\" @(#)xlock.1	1.3 90/10/28; Copyright (c) 1990 - Sun Microsystems, Inc.
X.TH XLOCK 1 "28 Oct 1990" "OpenWindows"
X.SH NAME
Xxlock \- Locks the local X display until a password is entered.
X
X.IX xlock#(1) "" "\fLxlock\fP(1)"
X.SH SYNOPSIS
X.B xlock
X[
X.BI \-display " dsp"
X]
X[
X.BI -/+remote
X]
X[
X.BI -/+mono
X]
X[
X.BI -/+nolock
X]
X[
X.BI -/+allowroot
X]
X[
X.BI -/+enablesaver
X]
X[
X.BI -/+allowaccess
X]
X[
X.BI -/+echokeys
X]
X[
X.BI -/+v
X]
X[
X.BI \-delay " usecs"
X]
X[
X.BI \-batchcount " num"
X]
X[
X.BI \-nice " level"
X]
X[
X.BI \-timeout " seconds"
X]
X[
X.BI \-saturation " value"
X]
X[
X.BI \-font " fontname"
X]
X[
X.BI \-bg " color"
X]
X[
X.BI \-fg " color"
X]
X[
X.BI \-mode " mode"
X]
X[
X.BI \-name " textstring"
X]
X[
X.BI \-password " textstring"
X]
X[
X.BI \-info " textstring"
X]
X[
X.BI \-validate " textstring"
X]
X[
X.BI \-invalid " textstring"
X]
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 a changing pattern is put on the screen.
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 Control-U and Control-H are
Xactive as kill and erase respectively.  To return to the locked screen,
Xclick in the small icon version of the changing pattern.
X
X.SH OPTIONS
X.TP 5
X.B \-display " dsp"
XThe
X.I display
Xoption sets the X11 display to lock.
X.B xlock
Xlocks all available screens on a given server,
Xand restricts you to locking only a local server such as
X.BI unix:0,
X.BI localhost:0,
Xor
X.BI :0
Xunless you set the
X.B \-remote
Xoption.
X.TP 5
X.B \-mode " modename"
XAs of this writing there are six display modes supported.
X.TP 8
X.B hop
XHop mode shows the "real plane fractals" from the September 1986 issue of
XScientific American.
X.TP 8
X.B life
XLife mode shows Conway's game of life.
X.TP 8
X.B qix
XQix mode shows the spinning lines similar to the old video game
Xby the same name.
X.TP 8
X.B image
XImage mode shows several sun logos randomly appearing on the screen.
X.TP 8
X.B swarm
XSwarm mode shows a swarm of bees following a wasp.
X.TP 8
X.B blank
XBlank mode shows nothing but a black screen.
X
X.TP 5
X.B \-delay " usecs"
XThe
X.I delay
Xoption sets the speed at which a mode will operate.  It simply sets the
Xnumber of microseconds to delay between batches of "hopalong pixels",
X"qix lines", "life generations", "image blits", and "swarm motions".  In
Xblank mode, it is important to set this to some small number of seconds,
Xbecause the keyboard and mouse are only checked after each delay, so you
Xcannot set the delay too high, but a delay of zero would needlessly
Xconsume cpu checking for mouse and keyboard input in a tight loop, since
Xblank mode has no work to do.
X.TP 5
X.B \-batchcount " num"
XThe
X.I batchcount
Xoption sets number of
X.I things
Xto do per batch to
X.I num .
XIn qix mode this refers to the number of lines rendered in the same color.
XIn hop mode this refers to the number of pixels rendered in the same color.
XIn image mode this refers to the number of sunlogos on screen at once.
XIn swarm mode this refers to the number of bees.
XIn life and blank mode it means nothing.
X.TP 5
X.B \-nice " nicelevel"
XThe
X.I nice
Xoption sets system nicelevel of the xlock process to
X.I nicelevel .
X.TP 5
X.B \-timeout " seconds"
XThe
X.I timeout
Xoption sets the number of
X.I seconds
Xbefore the password screen will time out.
X.TP 5
X.B \-saturation " value"
XThe
X.I saturation
Xoption sets saturation of the color ramp used to
X.I value .
X0 is grayscale and 1 is very rich color.  0.4 is a nice pastel.
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 \-fg " color"
XThe
X.I fg
Xoption sets the color of the text on the password screen to
X.I color .
X.TP 5
X.B \-bg " color"
XThe
X.I bg
Xoption sets the color of the background on the password screen to
X.I color .
X.TP 5
X.B \-name " textstring"
X.I textstring
Xis shown in front of user name, defaults to "Name: ".
X.TP 5
X.B \-password " textstring"
X.I textstring
Xis the password prompt string, defaults to "Password: ".
X.TP 5
X.B \-info " textstring"
X.I textstring
Xis an informational message to tell the user what to do, defaults to
X"Enter password to unlock; select icon to lock.".
X.TP 5
X.BI \-validate " textstring"
X.I textstring
X.BI \-validate " message shown while validating the password, defaults to
X"Validating login..."
X.TP 5
X.BI \-invalid " textstring"
X.I textstring
X.BI \-invalid " message shown when password is invalid, defaults to
X"Invalid login."
X
X.TP 5
X.B -/+remote
XThe
X.I remote
Xoption tells xlock to not stop you from locking remote X11 servers.  This
Xoption should be used with care and is intended mainly to lock X11 terminals
Xwhich cannot run
X.I xlock
Xlocally.  If you lock someone else's workstation, they will have to know
X.B your
Xpassword to unlock it.
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 on color displays
X.TP 5
X.B +/-nolock
XThe
X.I nolock
Xoption causes xlock to only draw the patterns and not lock the display.
XA keypress or a mouse click will terminate the screen saver.
X.TP 5
X.B -/+allowroot
XThe
X.I allowroot
Xoption allows the root password to unlock the server as well as the user
Xwho started xlock.
X.TP 5
X.B -/+enablesaver
XBy default xlock will disable the normal X server's screen saver since
Xit is in effect a replacement for it.  Since it is possible to set delay
Xparameters long enough to cause phosphor burn on some displays, this
Xoption will turn back on the default screensaver which is very careful
Xto keep most of the screen black.
X.TP 5
X.B -/+allowaccess
XThis option is simply a hack for the paranoid, who don't want to disable the
Xaccess control list, but still want the local server to prompt for a password.
XThis way if xlock is killed -KILL, the access control list is not lost.
X.TP 5
X.B -/+echokeys
XThe
X.I echokeys
Xoption causes xlock to echo '?' characters for each key typed into the
Xpassword prompt.  Some consider this a security risk, so the default is
Xto not echo anything. 
X.TP 5
X.B \-v
XVerbose mode, tells what options it is going to use.
X
X.SH BUGS
X"kill -KILL
X.B xlock
X" causes the server that was locked to be unusable, since all hosts
X(including localhost) were removed from the access control list
Xto lock out new X clients, and since xlock couldn't catch SIGKILL,
Xit terminated 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,
Xand this operation cannot be reversed unless you reset the server."\fP
X		-From the X11R4 Xlib Documentation, Chapter 7.
X.SH SEE ALSO
XX(1), Xlib Documentation.
X.SH AUTHOR
X Patrick J. Naughton	 (naughton@wind.eng.sun.com)
X MailStop 14-01
X Windows and Graphics Group
X Sun Microsystems, Inc.
X Mountain View, CA  94043
X 415/336-1080
X.SH COPYRIGHT
XCopyright (c) 1988-90 by Patrick J. Naughton and 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. 
END_OF_FILE
if test 7393 -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 3\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 3 archives.
    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

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.
--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.