v03i042: Yet another screen saver, Part02/03

Mike Wexler mikew at wyse.wyse.com
Sat Mar 11 04:40:12 AEST 1989


Submitted-by: jik at pit-manager.mit.edu (Jonathan I. Kamens)
Posting-number: Volume 3, Issue 42
Archive-name: xsaver/part02

#! /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 2 (of 3)."
# Contents:  Makefile PromptBox.c Xsaver.sed main.c menuIcon.c
#   password.c toolkit.pat util.c xsaver.h xsaver.man.s
# Wrapped by mikew at wyse on Fri Mar 10 10:36:40 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(7851 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
XBITMAPDIR       =       /global/bitmaps
XICONBITMAP	=	SigmaPiBeta
XFLOATBITMAP	=	yinyang
XICONPIXMAP	=	SigmaPiBeta
XBITMAPS		=	$(ICONBITMAP) $(FLOATBITMAP) $(ICONPIXMAP)
XSYS_LIBRARIES   = $(XAWLIB) $(XTOOLLIB) $(XMULIB) $(XLIB) -lm
XLOCAL_LIBRARIES =
XSRCS 		=	main.c scaling.c List.c password.c savescreen.c\
X			menuIcon.c PromptBox.c util.c
XOBJS		=	main.o scaling.o List.o password.o savescreen.o\
X			menuIcon.o PromptBox.o util.o
XTARGET=xsaver
X
Xall:: $(TARGET) Xsaver.ad xsaver.man
X
X PROGRAM = $(TARGET)
X
Xall:: $(TARGET)
X
X$(TARGET): $(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:: $(TARGET)
X	$(INSTALL) -c $(INSTALLFLAGS) $(TARGET) $(BINDIR)
X
Xinstall.man:: $(TARGET).man
X	$(INSTALL) -c $(INSTMANFLAGS) $(TARGET).man $(MANDIR)/$(TARGET).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
Xlint:
X	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)
Xlint1:
X	$(LINT) $(LINTFLAGS) $(FILE) $(LINTLIBS)
X
Xinstall.man:: xsaver.man.man
X	$(INSTALL) -c $(INSTMANFLAGS) xsaver.man.man $(MANDIR)/xsaver.man.n
X
Xinstall:: Xsaver.ad
X	$(INSTALL) -c $(INSTAPPFLAGS) Xsaver.ad $(XAPPLOADDIR)/Xsaver
X
Xinstall:: $(BITMAPS)
X	@case '${MFLAGS}' in *[i]*) set +e;; esac; \
X	for i in $(BITMAPS); do \
X	(set -x; $(INSTALL) -c $(INSTALLFLAGS) $$i $(BITMAPDIR)); \
X	done
X
XXsaver.ad: Xsaver.sed
X	sed -e 's|$$BITMAPDIR|$(BITMAPDIR)|g'\
X		-e 's|$$ICONPIXMAP|$(ICONPIXMAP)|g'\
X		-e 's|$$ICONBITMAP|$(ICONBITMAP)|g'\
X		-e 's|$$FLOATBITMAP|$(FLOATBITMAP)|g'\
X		Xsaver.sed > $@
X
Xxsaver.man: xsaver.man.s
X	sed -e 's|$$TARGET|$(TARGET)|g'\
X		-e 's|$$APPDIR|$(APPDIR)|g'\
X		-e 's|$$APPTARGET|$(APPTARGET)|g'\
X		-e 's|$$BITMAPDIR|$(BITMAPDIR)|g'\
X		-e 's|$$ICONPIXMAP|$(ICONPIXMAP)|g'\
X		-e 's|$$ICONBITMAP|$(ICONBITMAP)|g'\
X		-e 's|$$FLOATBITMAP|$(FLOATBITMAP)|g'\
X		xsaver.man.s > xsaver.man
X
Xclean::
X	rm -f xsaver.man Xsaver.ad $(OBJS)
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X	$(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X	$(IRULESRC)/Imake.tmpl \
X	$(IRULESRC)/Imake.rules \
X	$(IRULESRC)/site.def \
X	$(IRULESRC)/$(MACROFILE)
X	- at if [ -f Makefile ]; then \
X	echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X	$(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X	else exit 0; fi
X	$(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X	@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 7851 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'PromptBox.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'PromptBox.c'\"
else
echo shar: Extracting \"'PromptBox.c'\" \(3291 characters\)
sed "s/^X//" >'PromptBox.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/PromptBox.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains a set of routines
X * for building form widgets fileed with lines of centered
X * text/bitmaps.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#ifndef lint
X     static char rcsid_PromptBox_c[] = "$Header: PromptBox.c,v 1.5 89/02/28 06:54:34 jik Exp $";
X#endif
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Form.h>
X#include <X11/Label.h>
X#include <X11/Xos.h>
X#include "xsaver.h"
X#include "globals.h"
X
X
Xextern Dimension widget_width();
Xextern void XtMoveWidget();
X
X
X
X
X
Xstatic Widget addBox(w, line, last)
XWidget w, *last;
XPromptLine *line;
X{
X     Arg arglist[10];
X     int i = 0;
X     
X     XtSetArg(arglist[i], XtNborderWidth, 0); i++;
X     if (! line->use_default) {
X	  if (line->bitmap) {
X	       XtSetArg(arglist[i], XtNbitmap, line->bitmap); i++;
X	       XtSetArg(arglist[i], XtNlabel, None); i++;
X	  }
X	  else {
X	       XtSetArg(arglist[i], XtNbitmap, None); i++;
X	       XtSetArg(arglist[i], XtNlabel, line->str); i++;
X	  }
X     }
X     XtSetArg(arglist[i], XtNfromVert, *last); i++;
X     if (line->spread) {
X	  XtSetArg(arglist[i], XtNvertDistance, line->spread); i++;
X     }
X     *last = XtCreateWidget(line->name, labelWidgetClass, w, arglist, i);
X     line->width = widget_width(*last);
X     return(*last);
X}
X
X
X
X
X
XWidget PromptBox(parent, name, strings, num, return_widgets)
XWidget parent;
Xchar *name;
XPromptLine *strings;
XWidget *return_widgets;
Xint num;
X{
X     Widget prompt, lines[MAXPROMPT], last = (Widget) NULL;
X     PromptLine *line_ptr;
X     Dimension width = 0;
X     Dimension shell_width, shell_height, shell_x, shell_y, shell_border;
X     Arg arglist[10];
X     int i = 0;
X     
X     prompt = XtCreateWidget(name, formWidgetClass, parent, NULL, 0);
X     for (line_ptr = strings; line_ptr - strings < num; line_ptr++) {
X	  lines[line_ptr - strings] = addBox(prompt, line_ptr, &last);
X	  if (width < line_ptr->width) width = line_ptr->width;
X     }
X     for (line_ptr = strings; line_ptr - strings < num; line_ptr++)
X	  if (line_ptr->center) center(lines[line_ptr - strings],
X				       line_ptr->width, width);
X     if (return_widgets)
X	  for (line_ptr = strings; line_ptr - strings < num; line_ptr++)
X	       return_widgets[line_ptr - strings] = lines[line_ptr - strings];
X     XtManageChildren(lines, num);
X
X     /* Center the widget on the screen */
X     XtRealizeWidget(prompt);
X     XtSetArg(arglist[i], XtNwidth, &shell_width); i++;
X     XtSetArg(arglist[i], XtNheight, &shell_height); i++;
X     XtSetArg(arglist[i], XtNborder, &shell_border); i++;
X     XtGetValues(prompt, arglist, i); i = 0;
X     shell_x = (display_width - shell_width - 2 * shell_border) / 2;
X     shell_y = (display_height - shell_height - 2 * shell_border) / 2;
X     XtMoveWidget(prompt, shell_x, shell_y);
X
X     return(prompt);
X}
END_OF_FILE
if test 3291 -ne `wc -c <'PromptBox.c'`; then
    echo shar: \"'PromptBox.c'\" unpacked with wrong size!
fi
# end of 'PromptBox.c'
fi
if test -f 'Xsaver.sed' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Xsaver.sed'\"
else
echo shar: Extracting \"'Xsaver.sed'\" \(2842 characters\)
sed "s/^X//" >'Xsaver.sed' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/Xscreensaver.sed,v $
X * $Author: jik $
X * $Header: Xscreensaver.sed,v 1.4 89/02/28 08:00:45 jik Exp $
X *
X * This file is part of xscreensaver.  It contains the application
X * defaults file that should be placed in the application defaults
X * directory defined in the Makefile.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * (c) 1989 by Jonathan Kamens.  This code may be distributed freely
X * as long as this notice is kept intact in its entirety and every
X * effort is made to send all corrections and improvements to the code
X * back to the author.  Also, don't try to make money off of it or
X * pretend that you wrote it.
X */
X
X/*
X * THE FOLLOWING DEFAULTS ARE GLOBAL
X */
X
XXsaver*cursor:			center_ptr
XXsaver*menuButton:		2
XXsaver*geometry:			+0+0
XXsaver*iconPixmap:		$BITMAPDIR/$ICONPIXMAP
XXsaver*synchronize:		true
XXsaver*resizable:			false
X
X/*
X * THE FOLLOWING DEFAULTS ARE FOR THE Xsaver ICON 
X */
X
XXsaver*icon.bitmap:		$BITMAPDIR/$ICONBITMAP
XXsaver*icon.resizable:		false
X
X
X/* 
X * THE FOLLOWING DEFAULTS ARE FOR THE POPUP MENU 
X */
X
XXsaver*menu.font:			9x15
XXsaver*menu.defaultColumns:	1
XXsaver*menu.forceColumns:		true
XXsaver*menu.cursor:		left_ptr
XXsaver*menuShell.allowShellResize:true
X
X/* The purpose of the following accelerator table is a bit mysterious.
X   Basically, if it doesn't exist, then if the user clicks on the icon
X   and pops up a menu, drags the mouse out of the menu and lets go,
X   the menu *will not go away*.  If he then moves the mouse back into
X   the menu, pushes down and holds, moves out of the menu *again* and
X   lets go, the menu *will* go away.  The accelerator table fixes
X   things so it goes away the first time.  Playing with it would be a
X   bad idea, I think. */
XXsaver*menu.accelerators: \
X	<BtnUp>:	Notify() Unset() IconOn() MenuPopdown(menuShell)
XXsaver*menu.translations: \
X	<BtnDown>:	Set()\n\
X	<BtnUp>:	Notify() Unset() IconOn() MenuPopdown(menuShell)\n\
X	<PtrMoved>:	Set()\n\
X	<Key>q:		Unset() IconOn() MenuPopdown(menuShell)\n\
X	<Leave>:	Unset()
X
X
X/*
X * THE FOLLOWING DEFAULTS ARE FOR THE SCREEN-LOCKING WINDOW
X */
X
X/* Having something that calls itself a screen saver popping up a
X   white window when it is blanking or locking the screen is a bid
X   ludicrous, even though that's what *should* happen in a normal
X   video application.  Well, this isn't a normal video application --
X   let's use black :-) */
XXsaver*root.background:	black
X
X
X/* 
X * THE FOLLOWING DEFAULTS ARE FOR THE FLOATING ICON 
X */
X
XXsaver*float.bitmap:	$BITMAPDIR/$FLOATBITMAP
XXsaver*float.resizable:	true
XXsaver*float.font:	9x15
XXsaver*message.font:	9x15
X
X
X/*
X * THE FOLLOWING DEFAULTS ARE FOR THE PASSWORD PROMPT BOXES 
X */
X
XXsaver*prompt.font:	9x15
XXsaver*prompt.time.font:	8x13
END_OF_FILE
if test 2842 -ne `wc -c <'Xsaver.sed'`; then
    echo shar: \"'Xsaver.sed'\" unpacked with wrong size!
fi
# end of 'Xsaver.sed'
fi
if test -f 'main.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'main.c'\"
else
echo shar: Extracting \"'main.c'\" \(3951 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/main.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains the code for main()
X * and a few other procedures used by main.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#ifndef lint
X     static char rcsid_main_c[] = "$Header: main.c,v 1.9 89/02/28 06:55:05 jik Exp $";
X#endif
X
X#include <stdio.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <signal.h>
X#include "xsaver.h"
X#include "resources.h"
X#include "commLine.h"
X#define MAIN
X#include "globals.h"
X#include "action.h"
X
X#ifndef XAPPLRESDIR
X#define XAPPLRESDIR "/usr/sipb/lib/app-defaults/"
X#endif
X
Xextern char *get_passwd();
Xextern void build_menu(), build_icon(), init_scaling();
XBoolean signal_caught = False;
X
X
X#ifdef DEBUG
Xhandler(dpy, event)
XDisplay *dpy;
XXErrorEvent *event;
X{
X     abort();
X}
X
X
XIOhandler(dpy)
XDisplay *dpy;
X{
X     abort();
X}
X#endif
X     
X
X
X
Xclean_up()
X{
X     wait(0);
X}
X
X
X
X/*
X * Commenting this out until we can get the signal stuff to work
X * properly.  May end up needing a change in the toolkit :-)
X */
X#ifdef NOTDEF
Xvoid SetSignal()
X{     
X     signal_caught = True;
X}
X
X
X/* ARGSUSED */
XBoolean CheckSignal(garbage)
Xcaddr_t garbage;
X{
X     if (signal_caught) {
X	  lock_flag = True;
X	  signal_caught = False;
X	  ActivateRoot();
X	  return(True);
X     }
X     return(False);
X}
X#endif
X
X
X
X
X
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X     int child;
X     FILE *pid_file;
X     char pid_file_name[50];
X     
X#ifdef DEBUG
X     XSetErrorHandler(handler);
X     XSetIOErrorHandler(IOhandler);
X#endif
X     whoami = argv[0];
X     setenv("XAPPLRESDIR", XAPPLRESDIR, 1);
X     srandom((int) time((long *)0));
X     signal(SIGCHLD, clean_up);
X     
X     top_widget = XtInitialize("main", "Xsaver", app_options,
X			       XtNumber(app_options), &argc, argv);
X
X     dpy = XtDisplay(top_widget);
X     screen = DefaultScreen(dpy);
X     real_root_window = RootWindow(dpy, screen);
X     display_height = DisplayHeight(dpy, screen);
X     display_width = DisplayWidth(dpy, screen);
X
X     XtAddActions(actionTable, XtNumber(actionTable));
X
X     XtGetApplicationResources(top_widget, &defs, app_resources,
X			       XtNumber(app_resources), NULL, 0);
X     if ((! *defs.ekey) && defs.use_passwd  && (! *defs.key))
X	  defs.ekey = get_passwd();
X     else if ((! *defs.ekey) && (*defs.key))
X	  install_password();
X     
X     XGetScreenSaver(dpy, &saver.timeout, &saver.interval,
X		     &saver.prefer_blanking, &saver.allow_exposures);
X#ifdef MAXTIMEOUT
X     if ((defs.timeout > MAXTIMEOUT) || (defs.timeout == 0)) {
X	  fprintf(stderr, "%s: Timeout cannot be greater than %d minutes.\n",
X		  whoami, MAXTIMEOUT);
X	  defs.timeout = MAXTIMEOUT;
X     }
X#endif
X     
X     /* Init_scaling calculates various screen dimension proportion */
X     /* necessary for the later calculation of the timeouts used for */
X     /* the floating Form widget. */
X     init_scaling ();
X
X     build_icon();
X     build_menu();
X
X     XtRealizeWidget(top_widget);
X
X/*
X * Commenting this out until we can figure out how to get it to work right.
X     signal (SIGUSR1, SetSignal);
X     XtAddWorkProc(CheckSignal, NULL);
X*/
X     
X     if (! defs.no_fork) if ((child = fork()) == -1) {
X	  fprintf(stderr, "%s: Error forking to go into the background.\n",
X		  whoami);
X	  exit(1);
X     }
X     else if (child)
X	  exit(0);
X
X     if (pid_file = fopen(sprintf(pid_file_name, "/tmp/Xscreensaver.%s.pid",
X				  getenv("USER")), "w")) {
X	  fprintf(pid_file, "%d\n", getpid());
X	  fclose(pid_file);
X     }
X
X     XtMainLoop();
X} /* main */
X
X
X
X
X
X
X
END_OF_FILE
if test 3951 -ne `wc -c <'main.c'`; then
    echo shar: \"'main.c'\" unpacked with wrong size!
fi
# end of 'main.c'
fi
if test -f 'menuIcon.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'menuIcon.c'\"
else
echo shar: Extracting \"'menuIcon.c'\" \(7677 characters\)
sed "s/^X//" >'menuIcon.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/menuIcon.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains the code for the
X * xscreensaver icon and for the pop-up menu.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#ifndef lint
X     static char rcsid_menuIcon_c[] = "$Header: menuIcon.c,v 1.5 89/02/28 06:55:08 jik Exp $";
X#endif
X
X#include <stdio.h>
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Label.h>
X#include <X11/List.h>
X#include <X11/Command.h>
X#include <X11/Shell.h>
X#include "xsaver.h"
X#include "globals.h"
X
X
Xextern void ActivateRoot(), XtMoveWidget();
X
Xvoid ClickSave(), ActivateMenu(), build_menu(), build_icon(), IconOn(),
X     IconOff(), check_lock();
X
Xstatic void menu_select(), switch_menus();
X
Xstatic Widget menu_shell, menu_widget, icon_widget;
X
X
X/* The two arrays of strings we will use for the popup menu: */
X
Xstatic String stringlist_autolock[] = {
X     "Auto-Lock (now ON)",
X     "Blank Screen",
X     "Lock Screen",
X     "Exit",
X     (char *) NULL
X};
X
X
Xstatic String stringlist_noautolock[] = {
X     "Auto-Lock (now OFF)",
X     "Blank Screen",
X     "Lock Screen",
X     "Exit",
X     (char *) NULL
X};
X
X
X
X
Xvoid build_icon()
X{
X     static String transStrings[] = {
X	  "<Btn2Down>:		set()\n\
X           <Btn3Down>:		set()\n\
X	   <Btn2Down>,<Btn2Up>:	IconOff() ClickSave() reset()\n\
X           <Btn3Down>,<Btn3Up>:	IconOff() ClickSave() reset()\n\
X           <Btn1Down>:		set() IconOff() reset() MenuPopup(menuShell)\n\
X           <Enter>:		highlight()\n\
X           <Leave>:		reset()\n\
X           <Map>:			check_lock()",
X	  "<Btn1Down>:		set()\n\
X           <Btn3Down>:		set()\n\
X	   <Btn1Down>,<Btn1Up>:	IconOff() ClickSave() reset()\n\
X           <Btn3Down>,<Btn3Up>:	IconOff() ClickSave() reset()\n\
X           <Btn2Down>:		set() IconOff() reset() MenuPopup(menuShell)\n\
X           <Enter>:		highlight()\n\
X           <Leave>:		reset()\n\
X           <Map>:			check_lock()",
X	  "<Btn1Down>:		set()\n\
X           <Btn2Down>:		set()\n\
X	   <Btn1Down>,<Btn1Up>:	IconOff() ClickSave() reset()\n\
X           <Btn2Down>,<Btn2Up>:	IconOff() ClickSave() reset()\n\
X           <Btn3Down>:		set() IconOff() reset() MenuPopup(menuShell)\n\
X           <Enter>:		highlight()\n\
X           <Leave>:		reset()\n\
X           <Map>:			check_lock()"
X     };
X     
X		
X	  
X
X     icon_widget = XtCreateManagedWidget("icon", commandWidgetClass,
X					 top_widget, NULL, 0);
X     XtUninstallTranslations(icon_widget);
X     XtOverrideTranslations(icon_widget, XtParseTranslationTable
X			    (transStrings[defs.menu_button - 1]));
X}
X
X
X
X
Xvoid build_menu()
X{
X     Arg arglist[10];
X     int i = 0;
X     static String leaveClose =
X	  "<Leave>:		Unset() IconOn() MenuPopdown(menuShell)\n";
X     
X     menu_shell = XtCreatePopupShell("menuShell", overrideShellWidgetClass,
X				     top_widget, NULL, 0);
X
X     if (defs.auto_lock) {
X	  XtSetArg(arglist[i], XtNlist, stringlist_autolock);		i++;
X     }
X     else {
X	  XtSetArg(arglist[i], XtNlist, stringlist_noautolock); 	i++;
X     }
X
X     menu_widget = XtCreateManagedWidget("menu", listWidgetClass, menu_shell,
X					 arglist, i);
X
X     XtInstallAccelerators(menu_shell, menu_widget);
X     if (defs.leave_close)
X	  XtOverrideTranslations(menu_widget,
X				 XtParseTranslationTable(leaveClose));
X     XtAddCallback(menu_widget, XtNcallback, menu_select, NULL);
X     XtAddCallback(menu_shell, XtNpopupCallback, ActivateMenu, NULL);
X     XtRealizeWidget(menu_shell);
X
X}
X
X
X
X
X
X
Xstatic void switch_menus()
X{
X     defs.auto_lock = !defs.auto_lock;
X
X     if (defs.auto_lock)
X	  XtListChange(menu_widget, stringlist_autolock, 0, 0, True);
X     else
X	  XtListChange(menu_widget, stringlist_noautolock, 0, 0, True);
X}
X
X
X
X
X
X/* Now, the action procedures and callbacks: */
X
X/* ARGSUSED */
Xvoid ActivateMenu(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X     Window garbage1, garbage2;		/* garbage return values */
X     int root_x, root_y;		/* the cursor position with */
X					/* respect to the origin of */
X					/* the root window.  This is */
X					/* what we want to use. */
X     int x2, y2;			/* more garbage */
X     unsigned int mask;			/* still more garbage */
X     Dimension width, height, border;	/* dimensions of the menu */
X     Arg arglist[3];
X     int i = 0;
X
X     /* The purpose of all this rigamarole when all we want to do is */
X     /* popup a menu is to place the menu at the current cursor */
X     /* position while making sure that it does not go off the screen. */
X
X     if (XQueryPointer(dpy, real_root_window, &garbage1, &garbage2,
X		       &root_x, &root_y, &x2, &y2, &mask)) {
X	  XtSetArg(arglist[i], XtNwidth, &width); 			i++;
X	  XtSetArg(arglist[i], XtNheight, &height); 			i++;
X	  XtSetArg(arglist[i], XtNborderWidth, &border); 		i++;
X	  XtGetValues(menu_shell, arglist, i); 				i = 0;
X	  
X	  /* First, calculate the x coordinate so that the menu pops */
X	  /* up with the mouse on the vertical center-line if */
X	  /* possible, or come as close as possible. */
X	  if (root_x >= width / 2 + border) 
X	       root_x -= width / 2 + border;
X	  else				
X	       root_x = 0;
X
X	  /* Make sure we're not falling off the screen. */
X	  if (root_x + width + 2 * border > display_width)
X	       root_x = display_width - width - 2 * border;
X	  if (root_y + height + 2 * border > display_height)
X	       root_y = display_height - height - 2 * border;
X
X	  /* Move the widget to the new location. */
X	  XtMoveWidget(menu_shell, root_x, root_y);
X     }
X     else
X	  fprintf(stderr, "%s: Error in XQueryWindow.\n", whoami);
X}
X
X
X
X
X
X
X#define AUTOLOCK 	0
X#define BLANK 		1
X#define	LOCK		2
X#define EXIT		3
X
X/* ARGSUSED */
Xstatic void menu_select(w, client_data, call_data)
XWidget w;
Xcaddr_t client_data;
Xcaddr_t call_data;
X{
X     XtListReturnStruct *selected;
X
X     selected = (XtListReturnStruct *) call_data;
X     XtListUnhighlight(menu_widget);
X     XtPopdown(menu_shell);
X     switch (selected->index) {
X     case EXIT:
X	  XtDestroyWidget(top_widget);
X	  XtCloseDisplay(dpy);
X	  exit(0);
X     case LOCK:
X	  lock_flag = True;
X	  ActivateRoot();
X	  break;
X     case BLANK:
X	  lock_flag = False;
X	  ActivateRoot();
X	  break;
X     case AUTOLOCK:
X	  switch_menus();
X	  break;
X     default:
X	  break;
X     }
X}
X
X
X
X
X/* ARGSUSED */
Xvoid IconOff(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X     Arg arglist[1];
X     XtSetArg(arglist[0], XtNsensitive, False);
X     XtSetValues(icon_widget, arglist, 1);
X}
X
X
X
X
X
X/* ARGSUSED */
Xvoid IconOn(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X     Arg arglist[1];
X     XtSetArg(arglist[0], XtNsensitive, True);
X     XtSetValues(icon_widget, arglist, 1);
X}
X
X
X
X
X/* ARGSUSED */
Xvoid check_lock(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X     if (defs.start_locked) {
X	  sleep(1);  /* give the window manager time to get the icon up */
X	  lock_flag = True;
X	  ActivateRoot();
X     }
X}
X
X
X
X
X	  
X/* ARGSUSED */
Xvoid ClickSave(w, event, params, num_params)
XWidget w;
XXEvent *event;
XString *params;
XCardinal *num_params;
X{
X     lock_flag = defs.auto_lock;
X     ActivateRoot();
X     IconOn((Widget) NULL, (XEvent *) NULL, (String *) NULL, (Cardinal *)
X	    NULL);
X}
END_OF_FILE
if test 7677 -ne `wc -c <'menuIcon.c'`; then
    echo shar: \"'menuIcon.c'\" unpacked with wrong size!
fi
# end of 'menuIcon.c'
fi
if test -f 'password.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'password.c'\"
else
echo shar: Extracting \"'password.c'\" \(4736 characters\)
sed "s/^X//" >'password.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/password.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains the code for
X * password manipulation.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#ifndef lint
X     static char rcsid_password_c[] = "$Header: password.c,v 1.6 89/02/28 06:55:12 jik Exp $";
X#endif
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Form.h>
X#include <X11/Label.h>
X#include <X11/Shell.h>
X#include <stdio.h>
X#include <pwd.h>
X#include "xsaver.h"
X#include "globals.h"
X
X
Xchar *get_passwd();
XWidget PasswordWindow();
X
Xextern char *time_string(), *timeleft_string(), *timeout_string(),
X     *user_string(), *get_user(), *malloc(), *crypt();
Xextern Widget PromptBox();
Xextern long random();
X
X
X
X
XWidget PasswordWindow(which)
Xint which;
X{
X     PromptLine prompt_lines[MAXPROMPT];
X     int i = 0;
X     Widget prompt;
X     
X     prompt_lines[i] = default_line;
X     prompt_lines[i].str = user_string(USER_FORMAT); i++;
X     prompt_lines[i] = default_line;
X     prompt_lines[i].name = "time";
X     prompt_lines[i].str = time_string(TIME_FORMAT, Force); i++;
X     if (defs.timeout && lock_flag) {
X	  prompt_lines[i] = default_line;
X	  if (which < 3) {
X	       prompt_lines[i].str = timeout_string(TIMEOUT_FORMAT, Force);
X	       i++;
X	  }
X	  else {
X	       prompt_lines[i].str = timeleft_string(TIMELEFT_FORMAT, Force);
X	       i++;
X	  }
X     }
X     prompt_lines[i] = default_line;
X     prompt_lines[i].str = "";
X     prompt_lines[i].center = False; i++;
X     prompt_lines[i] = default_line;
X     if (which != 2)
X	  prompt_lines[i].str = PASS_PROMPT1;
X     else
X	  prompt_lines[i].str = PASS_PROMPT2;
X     prompt_lines[i].center = False; i++;
X     prompt_lines[i].spread = 10;
X
X     prompt = PromptBox(root_widget, "prompt", prompt_lines, i,
X			(Widget *) NULL);
X
X     XtMapWidget(prompt);
X
X     return(prompt);
X}
X
X
X
X
X     
X     
Xchar *get_passwd()
X{
X     struct passwd *pwent;
X     char *user;
X     char *passwd;
X     
X     user = get_user();
X
X     if (! *user)
X	  return((char *) NULL);
X     
X     pwent = getpwnam(user);
X
X     if (pwent) if (strlen(pwent->pw_passwd) == PASSWDLENGTH)
X	  return(pwent->pw_passwd);
X     
X     passwd = malloc(1);
X     *passwd = '\0';
X     return(passwd);
X}
X
X
XBoolean correct_password(passwd)
Xchar *passwd;
X{
X     char seed[3];
X
X     if (*defs.ekey) {
X	  strncpy(seed, defs.ekey, 2);
X	  return(! strcmp(crypt(passwd, seed), defs.ekey));
X     }
X     else if (*defs.key) {
X	  if (! strcmp(passwd, defs.key))
X	       return(True);
X	  else
X	       return(False);
X     }
X     else
X	  return(False);
X}
X
X
X/*
X * Takes the password from defs.key, encrypts it, places its value
X * into defs.ekey, and then zeros out defs.key.  This is basically for
X * security reasons -- if someone gcore's the file or manages to read
X * memory and the key is stored in plaintext, they can read it and do
X * nasty things.
X *
X * There's no sanity checking here -- if there's nothing in defs.key,
X * things will lose.
X * 
X * This is relatively useless when the unencrypted key is given on the
X * command line or put in the user's resources, since the toolkit
X * keeps several copies of the key floating around.  Even if we bzero
X * the copy we have, there are still several others in memory.  It
X * becomes useful when the key is typed in the first time the screen
X * is locked, and since we're assuming that that's what will be
X * happening most of the time, this is a useful procedure.
X */
Xinstall_password()
X{
X     char seed[3];
X     char error_buf[BUFSIZ];
X     
X     /* Calculate the seed for the password */
X     *seed = *(seed + 1) = *(seed + 2) = 0;
X     do {
X	  *seed = (char) (random() % 0172);
X     } while (! (((*seed >= 056) && (*seed <= 071)) || /* /, ., 0-9 */
X		 ((*seed >= 0101) && (*seed <= 0132)) || /* A-Z */
X		 ((*seed >= 0141) && (*seed <= 0172)))); /* a-z */
X     do {
X	  seed[1] = (char) (random() % 0172);
X     } while (! (((seed[1] >= 056) && (seed[1] <= 071)) || /* /, ., 0-9 */
X		 ((seed[1] >= 0101) && (seed[1] <= 0132)) || /* A-Z */
X		 ((seed[1] >= 0141) && (seed[1] <= 0172)))); /* a-z */
X
X     defs.ekey = malloc(PASSWDLENGTH + 1);
X     if (! defs.ekey) {
X	  perror(sprintf(error_buf, "%s: install_password", whoami));
X	  exit(1);
X     }
X     strcpy(defs.ekey, crypt(defs.key, seed));
X
X     bzero(defs.key, strlen(defs.key));
X}
X
X	  
END_OF_FILE
if test 4736 -ne `wc -c <'password.c'`; then
    echo shar: \"'password.c'\" unpacked with wrong size!
fi
# end of 'password.c'
fi
if test -f 'toolkit.pat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'toolkit.pat'\"
else
echo shar: Extracting \"'toolkit.pat'\" \(4197 characters\)
sed "s/^X//" >'toolkit.pat' <<'END_OF_FILE'
X/* Caution:  These are unpublished patches and may not be
X * redistributed.  Anyone installing them should preserve
X * the old version of the files so that the published fix
X * may be installed without error when it becomes available.
X */
X
X*** old/lib/Xt/Geometry.c
X--- lib/Xt/Geometry.c
X***************
X*** 1,5 ****
X  #ifndef lint
X! static char Xrcsid[] = "$XConsortium: Geometry.c,v 1.29 88/09/06 16:27:56 jim Exp $";
X  /* $oHeader: Geometry.c,v 1.3 88/08/23 11:37:50 asente Exp $ */
X  #endif lint
X  
X--- 1,5 ----
X  #ifndef lint
X! static char Xrcsid[] = "$XConsortium: Geometry.c,v 1.32 89/01/18 12:38:04 swick Exp $";
X  /* $oHeader: Geometry.c,v 1.3 88/08/23 11:37:50 asente Exp $ */
X  #endif lint
X  
X***************
X*** 48,53 ****
X--- 48,54 ----
X             "XtMakeGeometryRequest - NULL parent.  Use SetValues instead",
X              (String *)NULL, (Cardinal *)NULL); 
X      }
X+     managed = XtIsManaged(widget);
X  
X      if (XtIsComposite(parent)) {
X  	parentRealized = XtIsRealized(parent);
X***************
X*** 60,76 ****
X  	manager = ((CompositeObjectClass) (parent->core.widget_class))
X      		->composite_class.geometry_manager;
X  	
X!     } else {
X  	/* Should never happen - XtManageChildren should have checked */
X  	XtErrorMsg("invalidParent","xtMakeGeometryRequest","XtToolkitError",
X               "XtMakeGeometryRequest - parent not composite",
X                (String *)NULL, (Cardinal *)NULL);
X      }
X  
X!     if (manager == (XtGeometryHandler) NULL) {
X  	XtErrorMsg("invalidGeometryManager","xtMakeGeometryRequest",
X                   "XtToolkitError",
X!                  "XtMakeGeometryRequest - parent has no geometry manger",
X                    (String *)NULL, (Cardinal *)NULL);
X      }
X  
X--- 61,84 ----
X  	manager = ((CompositeObjectClass) (parent->core.widget_class))
X      		->composite_class.geometry_manager;
X  	
X!     } else if (managed) {
X  	/* Should never happen - XtManageChildren should have checked */
X  	XtErrorMsg("invalidParent","xtMakeGeometryRequest","XtToolkitError",
X               "XtMakeGeometryRequest - parent not composite",
X                (String *)NULL, (Cardinal *)NULL);
X+     } else {
X+ 	/* no need to waste time checking if parent is actually realized
X+ 	 * at this point; since the child is unmanaged we need to perform
X+ 	 * the configure iff the child is realized, so we dummy the
X+ 	 * parentRealized checks below.
X+ 	 */
X+ 	parentRealized = TRUE;
X      }
X  
X!     if (managed && manager == (XtGeometryHandler) NULL) {
X  	XtErrorMsg("invalidGeometryManager","xtMakeGeometryRequest",
X                   "XtToolkitError",
X!                  "XtMakeGeometryRequest - parent has no geometry manager",
X                    (String *)NULL, (Cardinal *)NULL);
X      }
X  
X***************
X*** 81,87 ****
X      } else {
X          widgetRealized = FALSE;
X      };
X-     managed = XtIsManaged(widget);
X  
X      /* see if requesting anything to change */
X      changeMask = 0;
X--- 89,94 ----
X*** old/lib/Xt/TMstate.c
X--- lib/Xt/TMstate.c
X*** /tmp/,RCSt1a02952	Thu Feb 23 11:28:13 1989
X--- TMstate.c	Tue Jan 31 15:50:54 1989
X***************
X*** 1,5 ****
X  #ifndef lint
X! static char Xrcsid[] = "$XConsortium: TMstate.c,v 1.67 89/01/30 15:01:40 swick Exp $";
X  /* $oHeader: TMstate.c,v 1.5 88/09/01 17:17:29 asente Exp $ */
X  #endif lint
X  /*LINTLIBRARY*/
X--- 1,5 ----
X  #ifndef lint
X! static char Xrcsid[] = "$XConsortium: TMstate.c,v 1.68 89/01/31 15:50:05 swick Exp $";
X  /* $oHeader: TMstate.c,v 1.5 88/09/01 17:17:29 asente Exp $ */
X  #endif lint
X  /*LINTLIBRARY*/
X***************
X*** 1114,1120 ****
X  	 unbound != 0 && actionList != NULL;
X  	 actionList = actionList->next) {
X  	unbound = BindAccActions(widget,stateTable, actionList->table,
X!                                 index, (XtBoundAccActions) accBindings);
X      }
X  /*    if (unbound != 0) ReportUnboundActions(tm, stateTable);*/
X      (*accBindings) = accTemp;
X--- 1114,1120 ----
X  	 unbound != 0 && actionList != NULL;
X  	 actionList = actionList->next) {
X  	unbound = BindAccActions(widget,stateTable, actionList->table,
X!                                 index, accTemp);
X      }
X  /*    if (unbound != 0) ReportUnboundActions(tm, stateTable);*/
X      (*accBindings) = accTemp;
X
END_OF_FILE
if test 4197 -ne `wc -c <'toolkit.pat'`; then
    echo shar: \"'toolkit.pat'\" unpacked with wrong size!
fi
# end of 'toolkit.pat'
fi
if test -f 'util.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'util.c'\"
else
echo shar: Extracting \"'util.c'\" \(4759 characters\)
sed "s/^X//" >'util.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/util.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains a whole bunch of
X * utility procedures.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#ifndef lint
Xstatic char rcsid_util_c[] = "$Header: util.c,v 1.4 89/02/28 06:55:28 jik Exp $";
X#endif
X
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Form.h>
X#include <pwd.h>
X#include "xsaver.h"
X#include "globals.h"
X
X
Xextern char *sprintf(), *getenv();
X
Xchar *get_user();
X
X
X
X
X
X
X
X/* Returns the width of the widget passed in as an argument */
XDimension widget_width(w)
XWidget w;
X{
X     Arg arglist[1];
X     Dimension width;
X     
X     XtSetArg(arglist[0], XtNwidth, &width);
X     XtGetValues(w, arglist, 1);
X
X     return(width);
X}
X
X
X
X
X
X /* Useed with children of a form widget -- given the widget, its width */
X /* and the horizontal width in which to center it, this function will  */
X /* set the XtNhorizDistance value of the widget properly.              */
Xcenter (w, width, in_width)
XWidget w;
XDimension width, in_width;
X{
X     Arg arglist[1];
X
X     width = (in_width - width) / 2;
X     XtSetArg(arglist[0], XtNhorizDistance, width);
X     XtSetValues(w, arglist, 1);
X}
X
X
X
X
X/* Returns a blank cursor */
XCursor blank_cursor()
X{
X     Pixmap foo;
X     Cursor bar;
X     XColor baz;
X
X     foo = XCreatePixmap(dpy, RootWindow(dpy, screen), 1, 1, 1);
X     baz.red = baz.blue = baz.green = 0;
X     bar = XCreatePixmapCursor(dpy, foo, foo, &baz, &baz, 1, 1);
X     return(bar);
X}
X
X
X
X
X
Xchar *user_string(str)
Xchar *str;
X{
X     static char buf[100];
X     static int initialized = 0;
X
X     if (! initialized) {
X	  sprintf(buf, str, get_user());
X     }
X     return(buf);
X}
X
X
Xchar *time_string(str, force)
XForceType force;
Xchar *str;
X{
X     struct tm *local;
X     static char buf[100];
X     char new[100];
X     int newf = 0;
X     
X     local = localtime((long) &times.current);
X     sprintf(new, str, local->tm_hour, local->tm_min);
X     if (strcmp(new, buf)) {
X	  strcpy(buf, new);
X	  newf++;
X     }
X     if (newf || (force == Force))
X	  return(buf);
X     else
X	  return ((char *) NULL);
X}     
X
X
X
Xchar *elapsed_string(str, force)
XForceType force;
Xchar *str;
X{
X     static char buf[100];
X     int hours, minutes;
X     char new[100];
X     int newf = 0;
X
X     int elapsed_sec = times.current - times.start;
X     hours = elapsed_sec / 3600;
X     minutes = (elapsed_sec - 3600 * hours) / 60;
X     sprintf(new, str, hours, minutes);
X     if (strcmp(new, buf)) {
X	  strcpy(buf, new);
X	  newf++;
X     }
X     if (newf || (force == Force))
X	  return(buf);
X     else
X	  return((char *) NULL);
X}
X
X
Xchar *timeout_string(str, force)
XForceType force;
Xchar *str;
X{
X     static char buf[100];
X     int hours, minutes;
X     char new[100];
X     int newf = 0;
X     
X     hours = defs.timeout / 60;
X     minutes = defs.timeout - 60 * hours;
X     sprintf(new, str, hours, (hours == 1 ? "hour" : "hours"), 
X	     minutes, (minutes == 1 ? "minute" : "minutes"));
X     if (strcmp(new, buf)) {
X	  strcpy(buf, new);
X	  newf++;
X     }
X
X     if (newf || (force == Force))
X	  return(buf);
X     else
X	  return((char *) NULL);
X}
X
X
Xchar *timeleft_string(str, force)
XForceType force;
Xchar *str;
X{
X     static char buf[100];
X     int hours, minutes;
X     int elapsed_sec = times.current - times.start;
X     char new[100];
X     int newf = 0;
X
X     /* Note that the + 60 in both equations is so that the counter will
X      * always display the minute it is counting down, instead of the
X      * minute before it.
X      */
X     hours = (defs.timeout * 60 - elapsed_sec + 60) / 3600;
X     minutes = (defs.timeout * 60 - elapsed_sec + 60 - 3600 * hours) / 60;
X     sprintf(new, str, hours, (hours == 1 ? "hour" : "hours"),
X	     minutes, (minutes == 1 ? "minute" : "minutes"));
X     if (strcmp(new, buf)) {
X	  strcpy(buf, new);
X	  newf++;
X     }
X
X     if (newf || (force == Force))
X	  return(buf);
X     else
X	  return((char *) NULL);
X}
X
X
X
X
X
Xchar *get_user()
X{
X     static char user[MAXUSERNAME];
X     struct passwd *pwent;
X     static char *ptr = (char *) NULL;
X     
X     if (ptr)
X	  return(ptr);
X     
X     ptr = getenv("USER");
X
X     if (ptr) {
X	  ptr = strcpy(user, ptr);
X	  return(user);
X     }
X
X     pwent = getpwuid(getuid());
X
X     if (pwent) {
X	  ptr = strcpy(user, pwent->pw_name);
X	  return(ptr);
X     }
X
X     *user = '\0';
X     
X     return(user);
X}
END_OF_FILE
if test 4759 -ne `wc -c <'util.c'`; then
    echo shar: \"'util.c'\" unpacked with wrong size!
fi
# end of 'util.c'
fi
if test -f 'xsaver.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xsaver.h'\"
else
echo shar: Extracting \"'xsaver.h'\" \(2677 characters\)
sed "s/^X//" >'xsaver.h' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/xscreensaver.h,v $
X * $Author: jik $
X * $Header: xscreensaver.h,v 1.7 89/02/28 06:55:31 jik Exp $
X *
X * This file is part of xscreensaver.  It contains the general header
X * stuff for the screensaver.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Copyright (c) 1989 by Jonathan Kamens.  This code may be
X * distributed freely as long as this notice is kept intact in its
X * entirety and every effort is made to send all corrections and
X * improvements to the code back to the author.  Also, don't try to
X * make any money off of it or pretend that you wrote it.
X */
X
X#define PASSWDLENGTH 		13 /* length of correct password in */
X				   /* the /etc/passwd file */
X#define MAXUSERNAME		15 /* maximum length of a username */
X#define MAXPASSWORD		20 /* maximum length of a password */
X#define MAXPROMPT		10 /* max number of lines in a */
X				   /* promptbox */
Xtypedef struct {
X     int velocity, timeout, menu_button;
X     Boolean use_background, auto_lock, use_passwd, transparent, no_fork;
X     Boolean d_time, d_elapsed, d_timeout, leave_close, start_locked;
X     String key, ekey, lock_message;
X     String lock_command, unlock_command;
X} Defaults;
X
X#define TIME_FORMAT 		"Time: %d:%02d"
X#define ELAPSED_FORMAT 		"Elapsed: %d:%02d"
X#define TIMEOUT_FORMAT 		"Timeout: %d %s, %d %s"
X#define TIMELEFT_FORMAT		"Time Left: %d %s, %d %s"
X#define USER_FORMAT		"User: %s"
X#define PASS_PROMPT1		"Enter password:     "
X#define PASS_PROMPT2		"Enter it again:     "
X
Xtypedef enum {
X     Force,
X     NoForce,
X} ForceType;
X
X	  
X
X
Xtypedef struct {
X     char *str;
X     char *name;
X     Pixmap bitmap;
X     Boolean use_default;
X     Boolean center;
X     int spread;
X     Dimension width;
X} PromptLine;
X
X
X
Xstatic PromptLine default_line = {
X     "promptLabel",
X     "prompt",
X     (Pixmap) NULL,
X     False,
X     True,
X     0,
X     0
X};
X
X
X
X /* Note that if MAXTIMEOUT is set, then TIMEOUT must not be set to 0! */
X /* If it is, then a spurious error message will be generated every */
X /* time the program is run!  Both TIMEOUT and MAXTIMEOUT should be */
X /* set in minutes. */
X#define TIMEOUT			"0"
X#undef MAXTIMEOUT
X#define CMPERMINUTE 		"40"
X#define MENUBUTTON		"2"
X
X /* If your C library uses "putenv" instead of "setenv," you need to */
X /* define setenv to putenv, because my library uses setenv. */
X#define setenv putenv
X
Xtypedef struct {
X     Widget widget;
X     Dimension width;
X} WidgetandWidth;
X
X
X
Xtypedef struct {
X     int start, current, saver;
X} Times;
X
Xtypedef struct {
X     int timeout, interval, prefer_blanking, allow_exposures;
X} Saver;
END_OF_FILE
if test 2677 -ne `wc -c <'xsaver.h'`; then
    echo shar: \"'xsaver.h'\" unpacked with wrong size!
fi
# end of 'xsaver.h'
fi
if test -f 'xsaver.man.s' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'xsaver.man.s'\"
else
echo shar: Extracting \"'xsaver.man.s'\" \(8043 characters\)
sed "s/^X//" >'xsaver.man.s' <<'END_OF_FILE'
X.\"
X.\" $Source: /mit/sipbsrc/uus/src/xscreensaver/RCS/xscreensaver.man.sed,v $
X.\" $Author: jik $
X.\" $Header: xscreensaver.man.sed,v 1.3 89/02/28 06:55:34 jik Exp $
X.\"
X.\" This file is part of xscreensaver.  It's the man page
X.\" (obviously).
X.\"
X.\" Author: Jonathan Kamens, MIT Project Athena and
X.\"                          MIT Student Information Processing Board
X.\"
X.\" Copyright (c) 1989 by Jonathan Kamens.  This code may be
X.\" distributed freely as long as this notice is kept intact in its
X.\" entirety and every effort is made to send all corrections and
X.\" improvements to the code back to the author.  Also, don't try to
X.\" make any money off of it or pretend that you wrote it. 
X.\"
X.TH $TARGET SIPB "22 January  1989" "X Version 11"
X.SH NAME
X$TARGET \- blanks and/or locks display
X.SH SYNOPSIS
X.B $TARGET
X[
X.B X toolkit options
X] [
X.B $TARGET options 
X]
X.SH DESCRIPTION
X.I $TARGET
Xis a client application running under the X Window System that blanks
Xand/or locks the display when activated.
XThe display is restored by pressing a key or a mouse button, and then 
Xentering the appropriate password if the screen is locked.
X.PP
XWhen executed,
X.I $TARGET
Xsplits off a child process to run in the background.  Two default
X.IR bitmap (1)
Xfiles are loaded, one to server as the
X.I $TARGET
Xcommand icon (and icon pixmap) and one to bounce
Xaround the display with other useful information when the screen saver 
Xis activated.  Also, the X server screensaver is deactivated when
X.I $TARGET
Xis either blanking or locking the screen.
X.PP
XWhen
X.I $TARGET
Xis not activated, it manifests itself as a small icon (whose position
Xdefaults to the upper left corner of the screen).  Clicking the left
Xor right mouse button on the icon will cause the screen to lock or
Xblank, depending on whether the auto-lock option has been selected.
XClicking and holding the middle mouse button will bring up a menu for
Xfour items: change auto-lock state, lock screen, blank screen, and exit.
XDrag the mouse cursor to the proper selection and release the mouse
Xbutton to select.  To get rid of the menu without selecting anything,
Xmove the mouse out of the menu and release the mouse button, or type `q'
Xwith the mouse cursor in the menu. 
X.PP
XWhen
X.I $TARGET
Xlocks, it attempts to use the user's password in the
X.I /etc/passwd
Xfile as the password to unlock the display.  If that password is 
Xunuseable for some reason and the user has not specified an alternate
Xkey on the command line or in the X resource database (see below),
X.I $TARGET
Xwill prompt for a password when the screen is first locked, and will not allow
Xthe screen to be locked unless the same password is typed twice at
Xthe prompt.
X.PP
XWhen
X.I $TARGET
Xstarts up, it attempts to write its process ID number into the file
X.I /tmp/Xscreensaver.$(USER).pid.
X.\" Sending a USR1 signal (see \fIsigvec\fR(2)) to the
X.\" .I xscreensaver
X.\" process will cause the screen to immediately lock.
X.PP
XMany of the program defaults are defined in the file
X.I $APPDIR/$APPTARGET.
XTo find out the specific resource strings which may be used to set
Xdefault fonts and other defaults, users should refer to that file.
X.SH OPTIONS
X.I $TARGET
Xwill accept all X toolkit command-line options and resource database 
Xspecifications, using the instance
X.I $TARGET
Xor the class
X.I Xscreensaver;
Xfor more information, see
X.IR X (1).
XIn addition,
X.I $TARGET
Xwill accept the following command-line options (or resource database 
Xspecifications):
X.TP
X.B -b (icon.bitmap, float.bitmap)
XThe
X.B -b
Xoption allows the user to specify the bitmap that will be used both for the
X.I $TARGET
Xcommand icon and for the bouncing icon.  The X resource
X.B icon.bitmap
Xspecifies the command icon bitmap, while
X.B float.bitmap
Xspecifies the bouncing icon bitmap.
X.TP
X.B -B (useBackground = true)
XCauses the root window's pattern or color to be used as the background of the screen when
X.I $TARGET
Xis blanked or locked.
X.TP
X.B -v (velocity)
XSpecifies the velocity of the bouncing icon, supposedly in centimeters
Xper second.  The default is 40.
X.TP
X.B -l (autoLock = true)
XSets the auto-lock function of the screen saver.  When auto-lock is set, 
Xclicking the left or middle mouse button on the
X.I $TARGET
Xicon will cause the screen to lock.  Otherwise, doing so will only cause
Xthe screen to blank.
X.TP
X.B -dtime (displayTime = true)
X.br
X.ns
X.HP 5
X.B +dtime (displayTime = false)
X.br
XWhen dtime is set to true, the current time will be displayed in the
Xbouncing icon.  When it is set to false, the current time will not be
Xdisplayed.
X.TP
X.B -delapsed (displayElapsed = true)
X.br
X.ns
X.HP 5
X.B +delapsed (displayElapsed = false)
X.br
XControls the display of the elapsed time in the bouncing icon.
X.TP
X.B -dtimeout (displayTimeout = true)
X.br
X.ns
X.HP 5
X.B +dtimeout (displayTimeout = false)
X.br
XControls the display of the time left before
X.I $TARGET
Xtimes out in the bouncing icon.
X.TP
X.B -dtimes (DisplayTimes = true) 
X.br
X.ns
X.HP 5
X.B +dtimes (DisplayTimes = false)
X.br
XA class toggle option which controls dtime, delapsed and dtimeout.
X.TP
X.B -t (timeout)
XThe timeout, specified in minutes, tells
X.I $TARGET
Xhow long to leave the screen locked before automatically unlocking it and
Xexiting.  Some sites may have a default timeout hard-coded into the program,
Xand some sites may have a maximum timeout.  To specify no timeout, specify
Xa timeout of 0 minutes.
X.TP
X.B -key (key)
XSpecify a plaintext password to use for locking the screen.
X.TP
X.B -ekey (encryptedKey)
XSpecify an encrypted password, in standard Unix
X.IR crypt (3)
Xformat, for locking the screen.
X.TP
X.B -npw (usePasswd = false)
XWhen this command-line option or X resource is specified,
X.I $TARGET
Xwill ignore the entry in the
X.IR /etc/passwd
Xfile and prompt for a password instead.  Note that it is not necessary
Xto specify this option if the
X.B -key
Xor
X.B -ekey
Xoption is specified.
X.TP
X.B -lc (lockCommand)
XThis option allows the user to specify a command line to be executed by the 
X.IR system (3)
Xsystem call each time the screen is locked.  When the screen is unlocked, the
Xprocess executing the command will be killed if it has not already exited.
X.TP
X.B -uc (unlockCommand)
XThis option allows the user to specify a command line to be executed each time
Xthe screen is unlocked.  The process executing the command will
X.B not
Xbe killed by
X.I $TARGET
Xso the user should be sure that any command specified using this option
Xwill exit on its own.
X.TP
X.B -nofork (noFork)
XPrevents
X.I $TARGET
Xfrom forking into the background when it starts up.
X.TP
X.B -mb (menuButton)
XThis option allows the user to specify which of the three mouse
Xbuttons (1, 2, or 3), when pressed on the
X.I $TARGET
Xicon, should cause the menu to pop up.  The default is
X.BR -mb 2.
X.TP
X.B -cl (leaveClose = true)
XWhen this option is specified, the
X.I $TARGET
Xmenu automatically goes up when the mouse cursor leaves it, without
Xwaiting for the button to be released outside of the window.
X.TP
X.B -L (startLocked = true)
XWhen this flag is specified,
X.I $TARGET
Xwill start up in locked mode.
X.TP
X.B -m (lockMessage)
XThis option allows the user to specify a short message to be displayed
Xin the floating icon when the screen is blanked or locked.  The
Xmessage text 
Xshould be one command-line option following the flag, so if it is
Xspecified on the command line and is more
Xthan one word, it should be placed in quotes or spaces should be quoted.
X.SH FILES
X.TP \w'$APPDIR/$APPTARGET'u+4n
X$BITMAPDIR/$ICONBITMAP
XDefault icon bitmap.
X.TP
X$BITMAPDIR/$FLOATBITMAP
XDefault bouncing icon bitmap.
X.TP
X$BITMAPDIR/$ICONPIXMAP
XDefault window-manager icon bitmap.
X.TP
X$APPDIR/$APPTARGET
X.I $TARGET
Xprogram defaults.
X.TP
X~/.Xresources
Xuser X resource database file.
X.TP
X/tmp/Xscreensaver.$(USER).pid
Xprocess ID of the program
X.SH SEE ALSO
XX(1), bitmap(1), lock(1)
X.SH AUTHOR
XWritten by Jonathan Kamens, MIT Project Athena and MIT Student Information
XProcessing Board, for X Version 11 and the X toolkit
X.PP
XOriginal idea by Edward Moy, Academic Computing Services, University of
XCalifornia at Berkeley, for X Version 10
END_OF_FILE
if test 8043 -ne `wc -c <'xsaver.man.s'`; then
    echo shar: \"'xsaver.man.s'\" unpacked with wrong size!
fi
# end of 'xsaver.man.s'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
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
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list