#! /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:  float.c getstring.c main.c menuIcon.c xsaver.h
# Wrapped by jik@pit-manager on Mon Jan 27 17:01:53 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'float.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'float.c'\"
else
echo shar: Extracting \"'float.c'\" \(10687 characters\)
sed "s/^X//" >'float.c' <<'END_OF_FILE'
X/*
X * $Source: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/float.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains the code for the
X * floating icon.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * Coyright (c) 1989 by Jonathan Kamens.  This code may be distributed
X * freely as long as this notice is kept intact in its entirety and
X * every effort is made to send all corrections and improvements to
X * the code back to the author.  Also, don't try to make any money off
X * of it or pretend that you wrote it.
X */
X
X/*
X * The code in this file is, for the most part, really gross, and I'm
X * ashamed that I wrote it.  This comment will stay at the top of this
X * file (as a personal penance, I guess :-) until I've written enough
X * of it to no longer be ashamed of it ...
X */
X
X#ifndef lint
X     static char rcsid_float_c[] = "$Header: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/float.c,v 1.8 91/05/09 16:15:20 jik Exp $";
X#endif
X
X#include "xsaver.h"
X#include <signal.h>
X#include "globals.h"
X#include "scaling.h"
X#include "wordwrap.h"
X#include "PromptBox.h"
X#define FLOAT
X#include "float.h"
X
Xextern long random();
Xextern char *widget_string(), *my_malloc();
Xextern Dimension widget_width();
Xextern char *time_string(), *elapsed_string(), *timeleft_string();
Xextern void unlock_command();
X /*
X  * XXX why am I declaring these instead of including headers which
X  * declare them?
X  */
Xextern void XtMoveWidget(); 
Xextern void XawFormDoLayout();
X
X/* Position and offset information */
Xstatic int x, y;
Xstatic int x_off = 0, y_off = 0;
Xstatic int max_float_x, max_float_y;
Xstatic int delay;
X
X/* The pointer to the message lines */
Xchar **message_lines = (char **) NULL;
X
X/* The timer that gets turned off when the float gets deactivated */
Xstatic XtIntervalId float_timer;
X
X/* the form widget itself */
Xstatic Widget float_widget = (Widget) NULL;
X
X/* Widgets we'll be using */
Xstatic Widget icon_w, time_w, elapsed_w, timeout_w;
Xstatic Widget *message_ws;
X
X/* A little bit of state for deciding when to recreate the widget. */
XDimension max_width = 0;
Xint max_chars = 0;
X
X
X
X
Xstatic void SetBounds()
X{
X     Dimension width, height, border;
X     Arg arglist[3];
X     
X     XtSetArg(arglist[0], XtNwidth, &width);
X     XtSetArg(arglist[1], XtNheight, &height);
X     XtSetArg(arglist[2], XtNborderWidth, &border);
X     XtGetValues(float_widget, arglist, 3);
X
X     max_float_x = display_width - width - 2 * border;
X     max_float_y = display_height - height - 2 * border;
X
X     if (x) {
X	  if (x > max_float_x)
X	       x = max_float_x;
X	  if (y > max_float_y)
X	       y = max_float_y;
X     }
X}
X
X
X
Xstatic void SetPosition()
X{
X     x = random() % max_float_x;
X     y = random() % max_float_y;
X}
X
X
Xstatic void SetOffset()
X{
X     x_off = new_off();
X     y_off = new_off();
X}     
X
X
Xvoid StartupFloat()
X{
X     NewFloat();
X     build_float();
X     
X     SetBounds();
X     if (! x_off) {
X	  SetPosition();
X	  SetOffset();
X	  delay = calc_delay(x_off, y_off, defs.velocity);
X     }
X
X     XtMoveWidget(float_widget, x, y);
X     
X     XtMapWidget(float_widget);
X     ActivateFloat();
X}
X
X
X
X
Xvoid ActivateFloat()
X{
X     float_timer = XtAppAddTimeOut(app_context, delay, MoveFloat, NULL);
X}
X
X
X
Xvoid DeactivateFloat()
X{
X     if (float_timer) {
X	  XtRemoveTimeOut(float_timer);
X	  float_timer = (XtIntervalId) NULL;
X     }
X}
X
X
X
X
Xstatic void MoveFloat()
X{
X     int changed_off = 0;
X
X     if (lock_flag && defs.timeout) {
X	  if ((times.current - times.start) >= defs.timeout * 60)
X	       do_timeout();
X     }
X     UpdateFloat();
X     if (x + x_off > max_float_x) {
X	  changed_off += maybe_new_off_opposite_sign(&x_off);
X     }
X     else if (x + x_off < 0) {
X	  changed_off += maybe_new_off_opposite_sign(&x_off);
X     }
X     if (y + y_off > max_float_y) {
X	  changed_off += maybe_new_off_opposite_sign(&y_off);
X     }
X     else if (y + y_off < 0) {
X	  changed_off += maybe_new_off_opposite_sign(&y_off);
X     }
X     x += x_off; y += y_off;
X     if (changed_off)
X	  delay = calc_delay(x_off, y_off, defs.velocity);
X     XtMoveWidget(float_widget, x, y);
X     float_timer = XtAppAddTimeOut(app_context, delay, MoveFloat, NULL);
X}
X
X
X
X
Xstatic void do_timeout()
X{
X     unlock_command();
X#ifdef TIMEOUT_LOGOUT
X     kill(-1, SIGHUP); /* 4.3-ism -- sends SIGHUP to all the user's */
X                       /* processes                                 */
X#endif
X     clean_up_and_die(0); /* removes PID file and exits */
X}
X
X
X
X
X#define max(a,b) ((a) > (b) ? (a) : (b))
X     
Xstatic Boolean Redo(str, wid, width, chars)
Xchar *str;
XWidget wid;
XDimension *width;
Xint *chars;
X{
X     Arg arglist[1];
X     
X     if (str) {
X	  XtSetArg(arglist[0], XtNlabel, str);
X	  XtSetValues(wid, arglist, 1);
X	  *width = max(*width, widget_width(wid));
X	  *chars = max(*chars, strlen(widget_string(wid)));
X	  return(True);
X     }
X     else {
X	  *width = max(*width, widget_width(wid));
X	  *chars = max(*chars, strlen(widget_string(wid)));
X	  return(False);
X     }
X}
X
X#undef max
X
X
X#define SetWidth(a,b) if ((a) && (widget_width(b) != new_width))\
X     XtSetValues(b, arglist, 1)
X
Xstatic void UpdateFloat()
X{
X     Arg arglist[2];
X     Dimension new_width = 0, border;
X     int float_chars = 0;
X
X     Boolean new_time = 0, new_elapsed = 0, new_timeout = 0;
X     
X     UpdateClock();
X     new_width = widget_width(icon_w);
X     if (defs.d_time)
X	  new_time = Redo(time_string(TIME_FORMAT, NoForce), time_w,
X			  &new_width, &float_chars);
X     if (defs.d_elapsed)
X	  new_elapsed = Redo(elapsed_string(ELAPSED_FORMAT, NoForce),
X			     elapsed_w, &new_width, &float_chars);
X     if (defs.d_timeout && lock_flag && defs.timeout)
X	  new_timeout = Redo(timeleft_string(TIMELEFT_FORMAT, NoForce),
X			     timeout_w, &new_width, &float_chars);
X
X     if (float_chars < DEFAULT_MESSAGE_WIDTH)
X	  float_chars = DEFAULT_MESSAGE_WIDTH;
X     if (new_time || new_elapsed || new_timeout) {
X	  if (float_chars != max_chars) {
X	       NewFloat();
X	       build_float();
X	       XtMoveWidget(float_widget, x, y);
X	       XtMapWidget(float_widget);
X	  }
X	  else {
X	       Widget *ptr;
X	       
X	       XawFormDoLayout(float_widget, False);
X
X	       XtSetArg(arglist[0], XtNwidth, (XtArgVal) new_width);
X
X	       SetWidth(1, icon_w);
X	       SetWidth(defs.d_time, time_w);
X	       SetWidth(defs.d_elapsed, elapsed_w);
X	       SetWidth(defs.d_timeout && lock_flag && defs.timeout,
X			timeout_w);
X
X	       for (ptr = message_ws; *ptr; ptr++) {
X		    if (widget_width(*ptr) != new_width)
X			 XtSetValues(*ptr, arglist, 1);
X	       }
X	       
X	       XawFormDoLayout(float_widget, True);
X
X	       XtSetArg(arglist[0], XtNwidth, &new_width);
X	       XtSetArg(arglist[1], XtNborderWidth, &border);
X	       XtGetValues(float_widget, arglist, 2);
X	       max_float_x = display_width - new_width - 2 * border;
X	  }
X     }
X}     
X
X#undef SetWidth
X
X     
X     
X
X
Xstatic int maybe_new_off_opposite_sign(foo)
Xint *foo;
X{
X     int off = - *foo;
X     int changed = 0;
X     
X     if (! (random() % 4)) {
X	  off = random() % 5 + 1;
X	  off = (*foo < 0 ? off : - off);
X	  changed++;
X     }
X     *foo = off;
X     
X     return(changed);
X}
X
X
X
X
X
X
X
Xstatic int new_off()
X{
X     int foo;
X     
X     foo = random() % 11 - 5;
X     if (! foo)
X	  foo = (random() % 1 ? 1 : -1);
X     
X     return(foo);
X}
X
X
X
X#define takemax(a) { int len; len = strlen(a);\
X	             max_chars = (max_chars > len ? max_chars : len); }
X		  
X
Xstatic void build_float()
X{
X     PromptLine lines[MAXPROMPT];
X     int a, i = 0;
X     Widget *return_widgets;
X     static String float_name = "float";
X     static String message_name = "message";
X     
X     max_chars = 0;
X     if (! float_widget) {
X	  /* The first one should pick up a bitmap from the defaults */
X	  lines[i] = default_line;
X	  lines[i].use_default = True;
X	  lines[i].name = float_name;
X	  lines[i].str = "floatIcon";					i++;
X	  if (defs.d_time) {
X	       lines[i] = default_line;
X	       lines[i].name = float_name;
X	       lines[i].str = time_string(TIME_FORMAT, Force);
X	       takemax(lines[i].str);
X	       i++;
X	  }
X	  if (defs.d_elapsed) {
X	       lines[i] = default_line;
X	       lines[i].name = float_name;
X	       lines[i].str = elapsed_string(ELAPSED_FORMAT, Force);
X	       takemax(lines[i].str);
X	       i++;
X	  }
X     
X	  if (defs.d_timeout && lock_flag && defs.timeout) {
X	       lines[i] = default_line;
X	       lines[i].name = float_name;
X	       lines[i].str = timeleft_string(TIMELEFT_FORMAT, Force);
X	       takemax(lines[i].str);
X	       i++;
X	  }
X
X	  if (max_chars < DEFAULT_MESSAGE_WIDTH)
X	       max_chars = DEFAULT_MESSAGE_WIDTH;
X
X	  if (*defs.lock_message) {
X	       char **ptr;
X	       
X	       ptr = message_lines = word_wrap(defs.lock_message, max_chars,
X					       MAXPROMPT - i);
X	       if (*ptr) {
X		    lines[i] = default_line;
X		    lines[i].spread = 10;
X		    lines[i].name = message_name;
X		    lines[i].str = *ptr;
X		    ptr++, i++;
X	       }
X	       
X	       for (; *ptr; i++, ptr++) {
X		    lines[i] = default_line;
X		    lines[i].name = message_name;
X		    lines[i].str = *ptr;
X	       }
X	  }
X	  
X	  return_widgets = (Widget *) my_malloc(sizeof(Widget) * (i + 1),
X						"floating icon");
X	  float_widget = PromptBox(root_widget, "float", lines, i,
X				   return_widgets);
X	  a = 0;
X	  icon_w = return_widgets[a];				a++;
X	  if (defs.d_time) {
X	       time_w = return_widgets[a];			a++;
X	  }
X	  if (defs.d_elapsed) {
X	       elapsed_w = return_widgets[a];			a++;
X	  }
X	  if (defs.d_timeout && lock_flag && defs.timeout) {
X	       timeout_w = return_widgets[a];			a++;
X	  }
X	  message_ws = &return_widgets[a];
X     }
X}
X     
X#undef takemax
X
X
X
X
X
X
X
Xvoid change_message(new_val)
Xchar *new_val;
X{
X     char *buf;
X
X     if (! new_val)
X	  return;
X     
X     buf = my_malloc(strlen(new_val) + 1, "lock message");
X     strcpy(buf, new_val);
X     XtFree(defs.lock_message);
X     defs.lock_message = buf;
X     max_chars = 0;
X}
X
X
X
X
X
Xstatic void UpdateClock()
X{
X     struct timeval tim;
X     gettimeofday(&tim, (struct timezone *) NULL);
X     times.current = tim.tv_sec;
X}
X
X
X
X
Xvoid NewFloat()
X{
X     if (float_widget) {
X	  if (debug_file) {
X	       fprintf(debug_file,
X		       "About to unmap float widget 0x%x (window id 0x%x) in NewFloat.\n",
X		       float_widget, XtWindow(float_widget));
X	  }
X	  XtUnmapWidget(float_widget);
X	  if (debug_file) {
X	       fprintf(debug_file,
X		       "About to destroy float widget 0x%x (window id 0x%x) in NewFloat.\n",
X		       float_widget, XtWindow(float_widget));
X	  }
X	  XtDestroyWidget(float_widget);
X	  float_widget = (Widget) NULL;
X     }
X     if (message_lines) {
X	  discard_wrap(message_lines);
X	  message_lines = (char **) NULL;
X     }
X}
END_OF_FILE
if test 10687 -ne `wc -c <'float.c'`; then
    echo shar: \"'float.c'\" unpacked with wrong size!
fi
# end of 'float.c'
fi
if test -f 'getstring.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'getstring.c'\"
else
echo shar: Extracting \"'getstring.c'\" \(6164 characters\)
sed "s/^X//" >'getstring.c' <<'END_OF_FILE'
X/*
X * $Source: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/getstring.c,v $
X * $Author: jik $
X *
X * This file is part of xscreensaver.  It contains the code for the
X * dialog widgets that pop up to get short strings.
X *
X * Author: Jonathan Kamens, MIT Project Athena and
X *                          MIT Student Information Processing Board
X *
X * This code may be distributed freely as long as this notice is kept
X * intact in its entirety and every effort is made to send all
X * corrections and improvements to the code back to the author.  Also,
X * don't try to make any money off of it or pretend that you wrote it.
X *
X * My copyright isn't on this code because I didn't write it (Well,
X * actually, I wrote the PopupAtPointer code, but that's besides the
X * point.).  This code was written by Barry Jaspan
X * (bjaspan@Athena.MIT.edu), so he holds the copyright.  Conditions
X * are the same, though -- send comments back to me, and I'll forward
X * them.
X * 		jik
X */
X
X#ifndef lint
X     static char rcsid_getstring_c[] = "$Header: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/getstring.c,v 1.11 91/03/10 16:27:23 jik Exp $";
X#endif
X
X#include "xsaver.h"
X#include <X11/Shell.h>
X#include <X11/Xaw/Label.h>
X#include <X11/Xaw/Form.h>
X#include <X11/Xaw/AsciiText.h>
X#include <X11/Xaw/Command.h>
X#include "globals.h"
X#include "getstring.h"
X
Xextern char *malloc();
X
Xstatic char buf[1024];
Xstatic Widget gs_shell, dialog;
Xstatic void (*call_func)();
Xvoid PopupAtPointer(), PopupSafe();
Xstatic int	prev_x = -1, prev_y = -1;
X
Xstatic void AcceptValue()
X{
X     if (debug_file) {
X	  fprintf(debug_file,
X		  "About to destroy getstring widget 0x%x (window id 0x%x) in AcceptValue.\n",
X		  gs_shell, XtWindow(gs_shell));
X     }
X     XtDestroyWidget(gs_shell);
X     (*call_func)(buf);
X}
X
Xstatic void CancelValue()
X{
X     XtPopdown(gs_shell);
X     if (debug_file) {
X	  fprintf(debug_file,
X		  "About to destroy getstring widget 0x%x (window id 0x%x) in CancelValue.\n",
X		  gs_shell, XtWindow(gs_shell));
X     }
X     XtDestroyWidget(gs_shell);
X     (*call_func)((char *) NULL);
X}
X
Xvoid init_getstring()
X{
X     static XtActionsRec action_table[] = {
X	  {"AcceptValue", (XtActionProc) AcceptValue},
X          {"CancelValue", (XtActionProc) CancelValue}
X     };
X
X     XtAppAddActions(app_context, action_table,XtNumber(action_table));
X}
X
X
Xvoid xscr_getstring(parent, name, label, length, func, usage)
X   Widget parent;
X   char *name, *label;
X   int length;
X   void (*func)();
X   int usage;
X{
X     Widget text_widget, label_widget, button1, button2;
X     Dimension dialog_width;
X     int text_horizDistance;
X     Dimension text_borderWidth;
X     
X     call_func = func;
X     *buf = '\0';
X     
X     /* Create Popup Shell to it is centered in parent */
X     gs_shell = XtCreatePopupShell("gsShell", transientShellWidgetClass,
X				   parent, NULL, 0);
X     dialog = XtVaCreateManagedWidget(name, formWidgetClass, gs_shell,
X				      NULL);
X     label_widget = XtVaCreateManagedWidget("label", labelWidgetClass, dialog,
X					    XtNlabel, label,
X					    NULL);
X     text_widget = XtVaCreateManagedWidget("value", asciiTextWidgetClass,
X					   dialog,
X					   XtNfromVert, label_widget,
X					   XtNstring, buf,
X					   NULL);
X     if (length > 0)
X	  XtVaSetValues(text_widget, XtNlength, length);
X
X     button1 = XtVaCreateManagedWidget("gsAccept", commandWidgetClass,
X				       dialog,
X				       XtNfromVert, text_widget,
X				       NULL);
X     button2 = XtVaCreateManagedWidget("gsCancel", commandWidgetClass,
X				       dialog,
X				       XtNfromVert, text_widget,
X				       XtNfromHoriz, button1,
X				       NULL);
X     XtAddCallback(button1, XtNcallback, AcceptValue, (XtPointer) 0);
X     XtAddCallback(button2, XtNcallback, CancelValue, (XtPointer) 0);
X
X     XtSetKeyboardFocus(dialog, text_widget);
X
X     XtRealizeWidget(gs_shell);
X
X     XtVaGetValues(dialog, XtNwidth, &dialog_width, NULL);
X     XtVaGetValues(text_widget,
X		   XtNhorizDistance, &text_horizDistance,
X		   XtNborderWidth, &text_borderWidth,
X		   NULL);
X     
X     XtVaSetValues(text_widget, XtNwidth,
X		   (Dimension) (dialog_width -
X				2 * (text_horizDistance + text_borderWidth)),
X		   NULL);
X		   
X     if ((usage == GS_PREVPOS) && (prev_x == -1))
X	  usage = GS_CURSORPOS;
X     switch (usage) {
X     case GS_CURSORPOS:
X	  PopupAtPointer(gs_shell, parent, XtGrabExclusive);
X	  break;
X     case GS_PREVPOS:
X	  PopupSafe(gs_shell, (Dimension) prev_x, (Dimension) prev_y,
X		    XtGrabExclusive);
X	  break;
X     case GS_WMPOS:
X	  XtPopup(gs_shell, XtGrabExclusive);
X	  break;
X     default:  /* Same as GS_WMPOS */
X	  XtPopup(gs_shell, XtGrabExclusive);
X	  break;
X     }
X}
X
X
X
Xvoid PopupSafe(w, x, y, GrabType)
XWidget w;
XDimension x, y;
XXtGrabKind GrabType;
X{
X     Dimension width, height, border;
X     Arg arglist[5];
X     int i = 0;
X
X     XtSetArg(arglist[i], XtNwidth, &width); i++;
X     XtSetArg(arglist[i], XtNheight, &height); i++;
X     XtSetArg(arglist[i], XtNborderWidth, &border); i++;
X     XtGetValues(w, arglist, i); 			i = 0;
X     if (x + width + 2 * border > display_width)
X	  x = display_width - width - 2 * border;
X     if (y + height + 2 * border > display_height)
X	  y = display_height - height - 2 * border;
X     XtSetArg(arglist[i], XtNx, x); i++;
X     XtSetArg(arglist[i], XtNy, y); i++;
X     XtSetValues(w, arglist, i);
X     prev_x = x;  prev_y = y;
X
X     XtPopup(w, GrabType);
X}
X
X
X     
X/* This came straight from the new xscreensaver */
Xvoid PopupAtPointer(w, parent, GrabType)
XWidget 	w, parent;
XXtGrabKind 	GrabType;
X{
X     Window garbage1, garbage2, window;
X     int root_x, root_y, x2, y2;
X     unsigned int mask;
X     Dimension width, height, border;
X     Arg arglist[3];
X     
X     window = XtWindow(parent);
X
X     if (XQueryPointer(dpy, window, &garbage1, &garbage2,
X		       &root_x, &root_y, &x2, &y2, &mask)) {
X	  XtSetArg(arglist[0], XtNwidth, &width);
X	  XtSetArg(arglist[1], XtNheight, &height);
X	  XtSetArg(arglist[2], XtNborderWidth, &border);
X	  XtGetValues(w, arglist, 3);
X	  if (root_x >= width / 2 + border)
X	       root_x -= width / 2 + border;
X	  else
X	       root_x = 0;
X
X	  PopupSafe(w, (Dimension) root_x, (Dimension) root_y, GrabType);
X     }
X}
X
END_OF_FILE
if test 6164 -ne `wc -c <'getstring.c'`; then
    echo shar: \"'getstring.c'\" unpacked with wrong size!
fi
# end of 'getstring.c'
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'\" \(9981 characters\)
sed "s/^X//" >'main.c' <<'END_OF_FILE'
X/*
X * $Source: /mit/sipbsrc/src/xscreensaver/RCS/main.c,v $
X * $Author: eichin $
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#if !defined(lint) && !defined(SABER)
X     static char rcsid_main_c[] = "$Header: /mit/sipbsrc/src/xscreensaver/RCS/main.c,v 1.37 92/01/09 23:48:54 eichin Exp $";
X#endif
X
X#include "xsaver.h"
X#include <signal.h>
X/* time.h and resource.h are for the setrlimit in the error handlers */
X#include <sys/time.h>
X#include <sys/resource.h>
X#include "resources.h"
X#include "commLine.h"
X#include "getstring.h"
X#define MAIN
X#include "globals.h"
X#include "action.h"
X
X#ifdef XFILESEARCHPATH
Xstatic void AddPathToSearchPath();
X#endif
X
X#ifndef APPCLASS
X#define APPCLASS "Xsaver"
X#endif
X
Xextern char *get_passwd(), *getenv();
Xextern void build_menu(), build_icon(), build_root(), init_scaling();
X#ifdef _IBMR2
Xextern void enable_hft_hotkey();
X#endif
X#ifdef PASSWORD_PORT
Xextern void check_password_port();
X#endif
X
XBoolean signal_caught = False;
X
X
Xhandler(dpy, event)
XDisplay *dpy;
XXErrorEvent *event;
X{
X     char buf[80];
X     struct rlimit limits;
X     
X     fprintf(stderr, "%s: X error occurred; aborting with core dump in /tmp.\n",
X	     whoami);
X     if (debug_file) {
X	  fprintf(debug_file, "X error occurred, type %d\n", event->type);
X	  fprintf(debug_file, "  serial number = %u\n", event->serial);
X	  XGetErrorText(dpy, event->error_code, buf, 80);
X	  fprintf(debug_file, "  error_code = %u\n (%s)", event->error_code,
X		  buf);
X	  fprintf(debug_file, "  request_code = %u\n", event->request_code);
X	  fprintf(debug_file, "  minor_code = %u\n", event->minor_code);
X	  fprintf(debug_file, "  resource ID = %u\n", event->resourceid);
X	  fclose(debug_file);
X     }
X     chdir("/tmp");
X     getrlimit(RLIMIT_CORE, &limits);
X     limits.rlim_cur = limits.rlim_max;
X     setrlimit(RLIMIT_CORE, &limits);
X     abort();
X}
X
X
X/*ARGSUSED*/
XIOhandler(dpy)
XDisplay *dpy;
X{
X#ifdef _IBMR2
X     if (defs.disable_hotkey)
X	  enable_hft_hotkey();
X#endif
X     if (defs.debug) {
X	  struct rlimit limits;
X
X	  fprintf(stderr,
X		 "%s: X IO error occurred; aborting with core dump in /tmp.\n",
X		  whoami);
X	  if (debug_file) {
X	       fprintf(debug_file, "X IO error occurred\n");
X	       fclose(debug_file);
X	  }
X	  chdir("/tmp");
X	  getrlimit(RLIMIT_CORE, &limits);
X	  limits.rlim_cur = limits.rlim_max;
X	  setrlimit(RLIMIT_CORE, &limits);
X	  abort();
X     }
X     else {
X	  exit(1);
X     }
X}
X     
X
X
X
Xclean_up()
X{
X     wait(0);
X}
X
X
X
Xclean_up_and_die(val)
Xint val;
X{
X     char buf[50];
X
X     if (dpy && DisplayString(dpy)) {
X	  sprintf(buf, "/tmp/%s.%s.pid", APPCLASS, DisplayString(dpy));
X	  unlink(buf);
X     }
X     if (debug_file)
X	  fclose(debug_file);
X     
X     exit(val);
X}
X
X
X
Xsignal_die()
X{
X     clean_up_and_die(0);
X#ifdef _IBMR2
X     if (defs.disable_hotkey)
X	  enable_hft_hotkey();
X#endif
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
X#ifndef XlibSpecificationRelease
Xmain(int_argc, argv)
Xint int_argc;
X#else
Xmain(argc, argv)
Xint argc;
X#endif
Xchar *argv[];
X{
X     int child;
X     FILE *pid_file;
X     char pid_file_name[50];
X     char debug_file_name[50];
X     char error_buf[50];
X     XrmDatabase db;
X     XrmValue allBitmap;
X     char bitmap_inst_buf[50];
X     char bitmap_class_buf[50];
X     char *rep_type;
X#ifdef PASSWORD_PORT
X     int password_port;
X#endif
X#ifndef XlibSpecificationRelease
X     Cardinal argc = int_argc;
X#endif
X
X     whoami = ((whoami = rindex(argv[0], '/')) ? whoami + 1 : argv[0]);
X#ifdef XFILESEARCHPATH
X     AddPathToSearchPath(XFILESEARCHPATH);
X#endif
X
X     srandom((int) time((long *)0));
X     signal(SIGCHLD, clean_up);
X     signal(SIGINT, signal_die);
X     signal(SIGTERM, signal_die);
X     signal(SIGHUP, signal_die);
X     signal(SIGQUIT, signal_die);
X
X#ifdef _IBMR2
X     add_converter();
X#endif
X
X     top_widget = XtVaAppInitialize(&app_context,
X				    APPCLASS,
X				    app_options,
X				    XtNumber(app_options),
X				    &argc,
X				    argv,
X				    NULL,	/* fallback resources */
X				    NULL);	/* args */
X
X     if (argc != 1) {
X	  usage();
X	  exit(1);
X     }
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     /*
X      * If the .allBitmap resource is set, then we want to put it back
X      * into the database as *float.bitmap and *icon.bitmap so that
X      * when widgets get built the command-line bitmap will override
X      * anything in the resources.
X      */
X     db = XtDatabase(dpy);
X     sprintf(bitmap_inst_buf, "%s.allBitmap", whoami);
X     sprintf(bitmap_class_buf, "%s.AllBitmap", APPCLASS);
X     if (XrmGetResource(db, bitmap_inst_buf, bitmap_class_buf,
X			&rep_type, &allBitmap)) {
X	  sprintf(bitmap_inst_buf, "%s*float.bitmap", whoami);
X	  XrmPutStringResource(&db, bitmap_inst_buf, allBitmap.addr);
X	  sprintf(bitmap_inst_buf, "%s*icon.bitmap", whoami);
X	  XrmPutStringResource(&db, bitmap_inst_buf, allBitmap.addr);
X     }
X     
X     XtAppAddActions(app_context, 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     if (defs.debug) {
X	  XSetErrorHandler(handler);
X     }
X     XSetIOErrorHandler(IOhandler);
X     if (defs.velocity <= 0) {
X	  fprintf(stderr, "%s: Velocity must be greater than 0.\n",
X		  whoami);
X	  defs.velocity = 1;
X     }
X     
X     init_getstring();
X     
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/*
X * Commenting this out until we can figure out how to get it to work right.
X     signal (SIGUSR1, SetSignal);
X     XtAppAddWorkProc(app_context, CheckSignal, NULL);
X*/
X
X     if (*defs.startup_message)
X	  fprintf(stdout, "%s\n", defs.startup_message);
X
X     if (! defs.no_fork) if ((child = fork()) == -1) {
X	  sprintf(error_buf, "%s: forking", whoami);
X	  perror(error_buf);
X	  exit(1);
X     }
X     else if (child)
X	  exit(0);
X
X     sprintf(pid_file_name, "/tmp/%s.%s.pid", APPCLASS, DisplayString(dpy));
X     if (pid_file = fopen(pid_file_name, "w")) {
X	  fprintf(pid_file, "%d\n", getpid());
X	  fclose(pid_file);
X     }
X
X     if (defs.debug) {
X	  sprintf(debug_file_name, "/tmp/%s.%s.debug", APPCLASS,
X		  DisplayString(dpy));
X	  debug_file = fopen(debug_file_name, "w");
X     }
X     else
X	  debug_file = NULL;
X     
X#ifdef PASSWORD_PORT
X     /* Set up the stuff for listening for the password on a port */
X     password_port = initialize_password_port();
X     if (password_port > 0)
X	  XtAppAddInput(app_context, password_port,
X			(XtPointer) XtInputReadMask, check_password_port,
X			(XtPointer) NULL);
X#endif
X     
X     if (defs.display_icon) {
X	  build_icon();
X	  build_menu();
X
X	  XtRealizeWidget(top_widget);
X     }
X     else {
X	  build_root();
X	  lock_flag = defs.start_locked || defs.auto_lock;
X	  ActivateRoot();
X     }
X     
X     XtAppMainLoop(app_context);
X} /* main */
X
X
X
X#ifdef XFILESEARCHPATH
Xstatic void
XAddPathToSearchPath(path)
Xchar *path;
X{
X     char *old, *new;
X
X     old = getenv("XFILESEARCHPATH");
X     if (old) {
X#if defined(mips) || defined(hpux) || defined(sun) || \
X	  (defined(ibm) && defined(SYSV) && defined(i386))
X	  /* +1 for =, +2 for :, +3 for null */
X	  new = XtMalloc((Cardinal) (strlen("XFILESEARCHPATH") +
X				     strlen(old) +
X				     strlen(path) + 3));
X	  (void) strcpy(new, "XFILESEARCHPATH");
X	  (void) strcat(new, "=");
X	  (void) strcat(new, old);
X	  (void) strcat(new, ":");
X	  (void) strcat(new, path);
X	  putenv(new);
X#else
X	  /* +1 for colon, +2 for null */
X	  new = XtMalloc((Cardinal) (strlen(old) + strlen(path) + 2));
X	  (void) strcpy(new, old);
X	  (void) strcat(new, ":");
X	  (void) strcat(new, path);
X	  setenv("XFILESEARCHPATH", new, 1);
X#endif
X     }
X     else {
X#if defined(mips) || defined(hpux) || defined(sun) || \
X	  (defined(ibm) && defined(SYSV) && defined(i386))
X	  new = XtMalloc((Cardinal) (strlen("XFILESEARCHPATH") +
X				     strlen(path) + 2));
X	  (void) strcpy(new, "XFILESEARCHPATH");
X	  (void) strcat(new, "=");
X	  (void) strcat(new, path);
X	  putenv(new);
X#else
X	  setenv("XFILESEARCHPATH", path, 1);
X#endif
X     }
X}
X#endif
X
X
Xusage()
X{
X     fprintf(stderr, "Usage: %s [toolkit options] [-B] [-v velocity] [-l] [-b bitmapfile]\n\t[-t timeout] [-xsaver] [+/-dtime] [+/-delapsed] [+/-dtimeout]\n\t[+/-dtimes] [-key key] [-ekey key] [-npw] [-lc command | +lc]\n\t[-uc command | +uc] [-nofork] [-mb button] [-cl] [-L] [-m message]\n\t[-debug] [+/-icon]%s\n",
X	     whoami,
X#ifdef PASSWORD_PORT
X	     " [-port port | +port] [-requirePort | +requirePort]"
X#else
X	     ""
X#endif
X	     );
X     
X     return;
X}
END_OF_FILE
if test 9981 -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'\" \(9190 characters\)
sed "s/^X//" >'menuIcon.c' <<'END_OF_FILE'
X/*
X * $Source: /afs/sipb.mit.edu/project/sipbsrc/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: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/menuIcon.c,v 1.19 91/03/10 16:32:50 jik Exp $";
X#endif
X
X#include "xsaver.h"
X#include <X11/Xaw/SimpleMenu.h>
X#include <X11/Xaw/SmeBSB.h>
X#include <X11/Xaw/MenuButton.h>
X#include <X11/Shell.h>
X#include "globals.h"
X#include "getstring.h"
X#include "check_mark"
X
Xextern void ActivateRoot(), XtMoveWidget(), change_timeout(),
X     change_lock(), change_unlock(), change_message();
X
Xvoid ClickSave(), ActivateMenu(), build_menu(), build_icon(), 
X     check_lock();
X
Xstatic Widget menu_shell, icon_widget;
Xstatic Widget *SmeWidgets;
X
Xstatic Pixmap checkmark = NULL;
Xstatic Pixmap blankmark = NULL;
X
X
X/************************************/
X/* Callback procedures for the menu */
X/************************************/
X
X
X/*ARGSUSED*/
Xvoid autolockCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     defs.auto_lock = !defs.auto_lock;
X
X     if (defs.auto_lock)
X	  XtVaSetValues(XtNameToWidget(menu_shell, "autoLock"),
X			XtNleftBitmap, checkmark,
X			NULL);
X     else
X	  XtVaSetValues(XtNameToWidget(menu_shell, "autoLock"),
X			XtNleftBitmap, blankmark,
X			NULL);
X}
X
X
X/*ARGSUSED*/
Xvoid blankCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     lock_flag = False;
X     ActivateRoot();
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid lockCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     lock_flag = True;
X     ActivateRoot();
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid changeTimeoutCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     xscr_getstring(top_widget, "newTimeout", "Enter new timeout:",
X		    -1, change_timeout, GS_PREVPOS);
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid changeLockCommandCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     xscr_getstring(top_widget, "newLock", "Enter new lock command:",
X		    -1, change_lock, GS_PREVPOS);
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid changeUnlockCommandCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     xscr_getstring(top_widget, "newUnlock", "Enter new unlock command:",
X		    -1, change_unlock, GS_PREVPOS);
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid changeLockMessageCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     xscr_getstring(top_widget, "newMessage", "Enter new lock message:",
X		    -1, change_message, GS_PREVPOS);
X     return;
X}
X
X
X/*ARGSUSED*/
Xvoid exitCallback(w, closure, call_data)
XWidget w;
XXtPointer closure, call_data;
X{
X     if (debug_file) {
X	  fprintf(debug_file,
X		  "About to destroy top widget 0x%x (window id 0x%x) in menu_select.\n",
X		  top_widget, XtWindow(top_widget));
X     }
X     XtDestroyWidget(top_widget);
X     XtCloseDisplay(dpy);
X     clean_up_and_die(0);
X}
X
X
X
X/* The array of strings we will use for the popup menu: */
X
X
X
Xstruct menu_elem {
X     String name, label;
X     XtCallbackProc callback;
X};
X
X
X
Xstatic struct menu_elem menu_stringlist[] = {
X     {"autoLock", "Auto-Lock", autolockCallback},
X     {"blank", "Blank Screen", blankCallback},
X     {"lock", "Lock Screen", lockCallback},
X     {"changeTimeout", "Change Timeout", changeTimeoutCallback},
X     {"changeLockCommand", "Change Lock Command", changeLockCommandCallback},
X     {"changeUnlockCommand", "Change Unlock Command", changeUnlockCommandCallback},
X     {"changeLockMessage", "Change Lock Message", changeLockMessageCallback},
X     {"exit", "Exit", exitCallback},
X};
X#define NUMLINES 8
X
X
Xvoid build_icon()
X{
X     XtTranslations trans;
X     static String transStrings[] = {
X	  "<EnterWindow>:	highlight()\n\
X	   <LeaveWindow>:	reset()\n\
X           <Btn1Down>:		set() reset() PopupMenu()\n\
X	   <BtnDown>:		set()\n\
X           <BtnUp>:		notify() reset()\n\
X           <Map>:		check_lock()",
X	  "<EnterWindow>:	highlight()\n\
X	   <LeaveWindow>:	reset()\n\
X           <Btn2Down>:		set() reset() PopupMenu()\n\
X	   <BtnDown>:		set()\n\
X           <BtnUp>:		notify() reset()\n\
X           <Map>:		check_lock()",
X	  "<EnterWindow>:	highlight()\n\
X	   <LeaveWindow>:	reset()\n\
X           <Btn3Down>:		set() reset() PopupMenu()\n\
X	   <BtnDown>:		set()\n\
X           <BtnUp>:		notify() reset()\n\
X           <Map>:		check_lock()"
X     };
X
X     icon_widget = XtVaCreateManagedWidget("icon", menuButtonWidgetClass,
X					   top_widget,
X					   XtNmenuName, "menu",
X					   NULL);
X     XtAddCallback(icon_widget, XtNcallback, ClickSave, NULL);
X     XtUninstallTranslations(icon_widget);
X     trans = XtParseTranslationTable(transStrings[defs.menu_button - 1]);
X     XtOverrideTranslations(icon_widget, trans);
X}
X
X
X
X
Xvoid build_menu()
X{
X     int i = 0;
X     Pixmap fornow = XtUnspecifiedPixmap;
X
X     static String leaveClose =
X	  "<Leave>:		unhighlight() MenuPopdown(menu)\n";
X
X     /* Allocate space for them */
X     SmeWidgets = (Widget *) XtMalloc(sizeof(Widget) * NUMLINES);
X
X     checkmark = XCreateBitmapFromData (XtDisplay(top_widget),
X					RootWindowOfScreen(XtScreen(top_widget)),
X					check_bits, check_width, check_height);
X     blankmark = XCreateBitmapFromData (XtDisplay(top_widget),
X					RootWindowOfScreen(XtScreen(top_widget)),
X					blank_bits, check_width, check_height);
X
X     if (defs.auto_lock) 
X	  fornow = checkmark;
X     else
X	  fornow = blankmark;
X     
X     menu_shell = XtVaCreatePopupShell("menu",
X				       simpleMenuWidgetClass,
X				       top_widget, NULL);
X     
X     for (i = 0; i < NUMLINES; i++) {
X	  String name, label;
X	  
X	  name = menu_stringlist[i].name;
X	  label = menu_stringlist[i].label;
X	  
X	  SmeWidgets[i] = XtVaCreateWidget(name,
X					   smeBSBObjectClass,
X					   menu_shell,
X					   XtNlabel, label,
X					   NULL);
X	  XtAddCallback(SmeWidgets[i], XtNcallback,
X			menu_stringlist[i].callback, NULL);
X     }
X
X     XtVaSetValues(XtNameToWidget(menu_shell, "autoLock"),
X		   XtNleftBitmap, fornow,
X		   NULL);
X     
X     XtManageChildren(SmeWidgets, NUMLINES);
X
X     if (defs.leave_close) {
X	  XtTranslations leaveClose_translations =
X	       XtParseTranslationTable(leaveClose);
X	  XtOverrideTranslations(menu_shell, leaveClose_translations);
X     }
X
X     XtAddCallback(menu_shell, XtNpopupCallback, ActivateMenu, NULL);
X     XtRealizeWidget(menu_shell);
X}
X
X
X
X
X
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/* 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, client_data, call_data)
XWidget w;
XXtPointer client_data, call_data;
X{
X     lock_flag = defs.auto_lock;
X     ActivateRoot();
X}
END_OF_FILE
if test 9190 -ne `wc -c <'menuIcon.c'`; then
    echo shar: \"'menuIcon.c'\" unpacked with wrong size!
fi
# end of 'menuIcon.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'\" \(6643 characters\)
sed "s/^X//" >'xsaver.h' <<'END_OF_FILE'
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xos.h>
X#include <stdio.h>
X
X/*
X * $Source: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/xsaver.h,v $
X * $Author: jik $
X * $Header: /afs/sipb.mit.edu/project/sipbsrc/src/xscreensaver/RCS/xsaver.h,v 1.20 91/11/03 23:21:01 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
X /* If you change anything here that will affect the way things appear */
X /* to the user (e.g. you install a maximum timeout and/or default     */
X /* timeout, or you change the default menu button), you might want to */
X /* consider editing the man page to reflect your changes.	       */
X
X
X /* Length of a valid encrypted password in the /etc/passwd file */
X#define PASSWDLENGTH 		13
X
X /* Maximun length of a user name */
X#define MAXUSERNAME		15
X
X /* Maximum length of a (plaintext) password.  I know that such a      */
X /* limit is artificial since Unix allows arbitrarily long passwords   */
X /* (to some extent), but I've got to stop somewhere.  You should      */
X /* probably leave it defined at 20, and then compile it with a higher */
X /* limit if somebody complains that they can't type their password    */
X /* (why would anyone want a password longer than 20 characters?       */
X#define MAXPASSWORD		20
X
X /* Default timeout, in minutes, in a string (e.g. "30").  If this is */
X /* set to "0", then either there is no default timeout.  If          */
X /* MAXTIMEOUT is defined, then this MUST be set to something 	      */
X /* non-zero, or you'll get spurious error messages from the program. */
X#define TIMEOUT			"0"
X
X /* Maximum timeout.  The user cannot set xscreensaver to timeout in  */
X /* a greater time period than this.  Note that this should be set to */
X /* a number, NOT a string.					      */
X/* #define MAXTIMEOUT		480 */
X
X /* This supposedly defines the centimeters per minute that the        */
X /* bouncing icon travels.  I'm not sure how well it does that, but it */
X /* does give some measure of the speed of the icon.  Define as a      */
X /* string. 							       */
X#define CMPERMINUTE 		"40"
X
X /* Some people don't like the middle button to be the menu button,    */
X /* especially if the mouse only has two buttons and both of them have */
X /* to be pressed to simulate pressing the middle button.  If you have */
X /* a mouse with only two buttons, or if for some other reason you     */
X /* don't think the middle button should be the default, change this.  */
X /* Once again, define it as a string.				       */
X#define MENUBUTTON		"2"
X
X /* If you define TIMEOUT_LOGOUT, then a user will be logged out if    */
X /* his xscreensaver times out.  Note that the method I use to log the */
X /* user out (in the procedure do_timeout) is, I think, somewhat of a  */
X /* BSD-ism -- I send a kill signal to the process "-1," which should  */
X /* make it go to all the user's processes.  If this won't work for    */
X /* you, you might not want to define this symbol.                     */
X#define TIMEOUT_LOGOUT
X
X /* If your C library uses "putenv" instead of "setenv," you need to   */
X /* define setenv to putenv, because my library uses setenv.  If you   */
X /* have neither setenv nor putenv, take a look at the file setenv.c   */
X /* and decide if you want to use it (i.e. if it will compile on your  */
X /* architecture, and if you do, define the symbol COMPILE_SETENV.     */
X/* #define setenv putenv */
X/* #define COMPILE_SETENV */
X
X
X /* If defined, xsaver will listen on port number PASSWORD_PORT for  */
X /* tcp connections while the screen is locked.  If it receives a    */
X /* connection, it will read a line of input from the port (or time  */
X /* out in a short amount of time) and see if that input is the      */
X /* correct password.  If it is, the screen is unlocked.	     */  
X /*								     */
X /* The purpose of this is to get around a mysterious bug I have been */
X /* unable to solve in xscreensaver -- occasionally, the program will */
X /* fail to accept any input from the keyboard when the screen is     */
X /* locked, even though I have grabbed the keyboard.		      */
X /* 								      */
X /* Also, there are resources and command-line options to set the port */
X /* to which xsaver will listen.				       */
X /*								       */
X /* I have this enclosed in an #ifndef here so that it can be 	      */
X /* redefined in the makefile.  If you don't want to use it at all,   */
X /* then comment out these three lines.  You'll probably also have to */
X /* do this if your system doesn't have BSD style sockets, because I  */
X /* wrote it for BSD style sockets and don't know much about other    */
X /* types (if you make it work on another architecture, send the      */
X /* changes to me!).			       			      */
X#ifndef PASSWORD_PORT
X#define PASSWORD_PORT 32253 /* a semi-random number -- I just made it up */
X#endif
X
X
X/*
X *  DO NOT MODIFY ANYTHING BELOW THIS POINT, UNLESS YOU REALLY KNOW
X * WHAT YOU ARE DOING.
X */
X
X
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     Boolean disable_x_screensaver, debug, display_icon;
X#ifdef PASSWORD_PORT
X     int password_port;
X     Boolean require_port;
X#endif
X     String key, ekey, lock_message;
X     String lock_command, unlock_command;
X     String startup_message;
X#ifdef _IBMR2
X     Boolean disable_hotkey, require_hotkey;
X#endif
X} Defaults;
X
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#define CAPS_LOCK_PROMPT        "Check the caps lock key!"
X
X /* State machine states */
X
X#define DOING_NOTHING 0
X#define GETTING_FIRST_INITIAL_PASSWORD 1
X#define GETTING_SECOND_INITIAL_PASSWORD 2
X#define GETTING_LOCKED_PASSWORD 3
X#define SHOWING_CAPSLOCK_WARNING 4
X
X
Xtypedef enum {
X     Force,
X     NoForce,
X} ForceType;
X
X
Xtypedef struct {
X     int start, current;
X} Times;
END_OF_FILE
if test 6643 -ne `wc -c <'xsaver.h'`; then
    echo shar: \"'xsaver.h'\" unpacked with wrong size!
fi
# end of 'xsaver.h'
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
