/* lock.c --- handling the password dialog for locking-mode.
- * xscreensaver, Copyright (c) 1993-1997 Jamie Zawinski <jwz@netscape.com>
+ * xscreensaver, Copyright (c) 1993-1998 Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include "xscreensaver.h"
+#include "resources.h"
#ifndef VMS
# include <pwd.h>
static enum { pw_read, pw_ok, pw_fail, pw_cancel, pw_time } passwd_state;
-#define PASSWDLEN 80
-static char typed_passwd [PASSWDLEN];
+static char typed_passwd [80];
\f
#if defined(HAVE_ATHENA) || (XmVersion >= 1002)
#ifndef VMS
# ifdef HAVE_ATHENA
- strncpy(typed_passwd, XawDialogGetValueString(passwd_form), PASSWDLEN);
+ strncpy(typed_passwd, XawDialogGetValueString(passwd_form),
+ sizeof(typed_passwd)-1);
+ typed_passwd[sizeof(typed_passwd)-1] = 0;
# endif /* HAVE_ATHENA */
if (passwd_valid_p (typed_passwd))
passwd_state = pw_ok;
else if (vcb->text->ptr != 0)
{
int i;
- strncat (typed_passwd, vcb->text->ptr, vcb->text->length);
- typed_passwd [vcb->endPos + vcb->text->length] = 0;
+ int L = vcb->text->length;
+ if (L >= sizeof(typed_passwd))
+ L = sizeof(typed_passwd)-1;
+ strncat (typed_passwd, vcb->text->ptr, L);
+ typed_passwd [vcb->endPos + L] = 0;
for (i = 0; i < vcb->text->length; i++)
vcb->text->ptr [i] = '*';
}
keypress (Widget w, XEvent *event, String *argv, Cardinal *argc)
{
int i, j;
- char s [sizeof (typed_passwd)];
- int size = XLookupString ((XKeyEvent *) event, s, sizeof (s), 0, 0);
+ char s [sizeof(typed_passwd)];
+ int size = XLookupString ((XKeyEvent *) event, s, sizeof(s)-1, 0, 0);
if (size != 1) return;
/* hack because I can't get translations to dance to my tune... */
if (*s == '\015') { done (w, event, argv, argc); return; }
i = j = strlen (typed_passwd);
+
+ if (i >= (sizeof(typed_passwd)-1))
+ {
+ XBell(XtDisplay(w), 0);
+ return;
+ }
+
typed_passwd [i] = *s;
s [++i] = 0;
while (i--)
static void
backspace (Widget w, XEvent *event, String *argv, Cardinal *argc)
{
- char s [sizeof (typed_passwd)];
+ char s [sizeof(typed_passwd)];
int i = strlen (typed_passwd);
int j = i;
if (i == 0)
static void
kill_line (Widget w, XEvent *event, String *argv, Cardinal *argc)
{
- memset (typed_passwd, 0, sizeof (typed_passwd));
+ memset (typed_passwd, 0, sizeof(typed_passwd));
text_field_set_string (passwd_text, "", 0);
}
format_into_label (passwd_label3, (username ? username : "???"));
}
-static int passwd_idle_timer_tick;
+static int passwd_idle_timer_tick = -1;
static XtIntervalId passwd_idle_id;
static void
{
XGCValues gcv;
#ifdef HAVE_MOTIF
- unsigned long fg, bg, ts, bs;
+ unsigned long fg = 0, bg = 0, ts = 0, bs = 0;
Dimension w = 0, h = 0;
XtVaGetValues(XtParent(passwd_done),
XmNwidth, &w,
x = (w / 2);
+#ifdef __sgi /* Kludge -- SGI's Motif hacks place buttons differently. */
+ {
+ static int sgi_mode = -1;
+ if (sgi_mode == -1)
+ sgi_mode = get_boolean_resource("sgiMode", "sgiMode") ? 1 : 0;
+
+ if (sgi_mode)
+ x = d;
+ }
+#endif /* __sgi */
+
x -= d/2;
y += d/2;
Arg av [100];
int ac = 0;
- unsigned long fg, bg;
+ unsigned long fg = 0, bg = 0;
XtSetArg (av [ac], XtNheight, &d); ac++;
XtGetValues (passwd_done, av, ac);
ac = 0;
}
}
+
#ifdef HAVE_ATHENA
void
XMapRaised (dpy, XtWindow (passwd_dialog));
#endif
+ monitor_power_on (si);
#ifdef HAVE_ATHENA
pop_up_athena_dialog_box (parent, passwd_text, passwd_dialog,
passwd_form, 2);
#else
pop_up_dialog_box (passwd_dialog, passwd_form,
-#ifdef DEBUG
+ /* for debugging -- don't ask */
(si->prefs.debug_p ? 69 : 0) +
-#endif
2);
XtManageChild (passwd_form);
#endif
roger(roger_label, 0, 0);
#endif /* HAVE_ATHENA */
-#ifdef DEBUG
if (!si->prefs.debug_p)
-#endif
- XGrabServer (dpy); /* ############ DANGER! */
+ XGrabServer (dpy); /* ############ DANGER! */
/* this call to ungrab used to be in main_loop() - see comment in
xscreensaver.c around line 857. */
- ungrab_keyboard_and_mouse (si->dpy);
+ ungrab_keyboard_and_mouse (si);
while (passwd_state == pw_read)
{
passwd_set_label(lose,strlen(lose)+1);
/* and clear the password line */
- memset(typed_passwd, 0, PASSWDLEN);
+ memset(typed_passwd, 0, sizeof(typed_passwd));
text_field_set_string (passwd_text, "", 0);
#else
text_field_set_string (passwd_text, lose, strlen (lose) + 1);
}
}
}
- memset (typed_passwd, 0, sizeof (typed_passwd));
+ memset (typed_passwd, 0, sizeof(typed_passwd));
text_field_set_string (passwd_text, "", 0);
XtSetKeyboardFocus (parent, None);