+extern char *getenv(const char *name);
+extern int validate_user(char *name, char *password);
+
+static Bool
+vms_passwd_valid_p(char *pw, Bool verbose_p)
+{
+ return (validate_user (getenv("USER"), typed_passwd) == 1);
+}
+# undef passwd_valid_p
+# define passwd_valid_p vms_passwd_valid_p
+
+#endif /* VMS */
+
+
+#undef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+enum passwd_state { pw_read, pw_ok, pw_null, pw_fail, pw_cancel, pw_time };
+
+struct passwd_dialog_data {
+
+ saver_screen_info *prompt_screen;
+ int previous_mouse_x, previous_mouse_y;
+
+ enum passwd_state state;
+ char typed_passwd [80];
+ XtIntervalId timer;
+ int i_beam;
+
+ float ratio;
+ Position x, y;
+ Dimension width;
+ Dimension height;
+ Dimension border_width;
+
+ char *heading_label;
+ char *body_label;
+ char *user_label;
+ char *passwd_label;
+ char *date_label;
+ char *user_string;
+ char *passwd_string;
+
+ XFontStruct *heading_font;
+ XFontStruct *body_font;
+ XFontStruct *label_font;
+ XFontStruct *passwd_font;
+ XFontStruct *date_font;
+
+ Pixel foreground;
+ Pixel background;
+ Pixel passwd_foreground;
+ Pixel passwd_background;
+ Pixel thermo_foreground;
+ Pixel thermo_background;
+ Pixel shadow_top;
+ Pixel shadow_bottom;
+
+ Dimension logo_width;
+ Dimension logo_height;
+ Dimension thermo_width;
+ Dimension internal_border;
+ Dimension shadow_width;
+
+ Dimension passwd_field_x, passwd_field_y;
+ Dimension passwd_field_width, passwd_field_height;
+
+ Dimension thermo_field_x, thermo_field_y;
+ Dimension thermo_field_height;
+
+ Pixmap logo_pixmap;
+ int logo_npixels;
+ unsigned long *logo_pixels;
+
+ Pixmap save_under;
+};
+
+static void draw_passwd_window (saver_info *si);
+static void update_passwd_window (saver_info *si, const char *printed_passwd,
+ float ratio);
+static void destroy_passwd_window (saver_info *si);
+static void undo_vp_motion (saver_info *si);
+
+
+static void
+make_passwd_window (saver_info *si)
+{
+ struct passwd *p = getpwuid (getuid ());
+ XSetWindowAttributes attrs;
+ unsigned long attrmask = 0;
+ passwd_dialog_data *pw = (passwd_dialog_data *) calloc (1, sizeof(*pw));
+ Screen *screen;
+ Colormap cmap;
+ char *f;
+ saver_screen_info *ssi = &si->screens [mouse_screen (si)];
+
+ pw->prompt_screen = ssi;
+ if (si->prefs.verbose_p)
+ fprintf (stderr, "%s: %d: creating password dialog.\n",
+ blurb(), pw->prompt_screen->number);
+
+ screen = pw->prompt_screen->screen;
+ cmap = DefaultColormapOfScreen (screen);
+
+ pw->ratio = 1.0;
+
+ pw->heading_label = get_string_resource ("passwd.heading.label",
+ "Dialog.Label.Label");
+ pw->body_label = get_string_resource ("passwd.body.label",
+ "Dialog.Label.Label");
+ pw->user_label = get_string_resource ("passwd.user.label",
+ "Dialog.Label.Label");
+ pw->passwd_label = get_string_resource ("passwd.passwd.label",
+ "Dialog.Label.Label");
+ pw->date_label = get_string_resource ("dateFormat", "DateFormat");
+
+ if (!pw->heading_label)
+ pw->heading_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
+ if (!pw->body_label)
+ pw->body_label = strdup("ERROR: REESOURCES NOT INSTALLED CORRECTLY");
+ if (!pw->user_label) pw->user_label = strdup("ERROR");
+ if (!pw->passwd_label) pw->passwd_label = strdup("ERROR");
+ if (!pw->date_label) pw->date_label = strdup("ERROR");
+
+ /* Put the version number in the label. */
+ {
+ char *s = (char *) malloc (strlen(pw->heading_label) + 20);
+ sprintf(s, pw->heading_label, si->version);
+ free (pw->heading_label);
+ pw->heading_label = s;
+ }
+
+ pw->user_string = strdup (p && p->pw_name ? p->pw_name : "???");
+ pw->passwd_string = strdup("");
+
+ f = get_string_resource ("passwd.headingFont", "Dialog.Font");
+ pw->heading_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
+ if (!pw->heading_font) pw->heading_font = XLoadQueryFont (si->dpy, "fixed");
+ if (f) free (f);
+
+ f = get_string_resource("passwd.bodyFont", "Dialog.Font");
+ pw->body_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
+ if (!pw->body_font) pw->body_font = XLoadQueryFont (si->dpy, "fixed");
+ if (f) free (f);
+
+ f = get_string_resource("passwd.labelFont", "Dialog.Font");
+ pw->label_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
+ if (!pw->label_font) pw->label_font = XLoadQueryFont (si->dpy, "fixed");
+ if (f) free (f);
+
+ f = get_string_resource("passwd.passwdFont", "Dialog.Font");
+ pw->passwd_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
+ if (!pw->passwd_font) pw->passwd_font = XLoadQueryFont (si->dpy, "fixed");
+ if (f) free (f);
+
+ f = get_string_resource("passwd.dateFont", "Dialog.Font");
+ pw->date_font = XLoadQueryFont (si->dpy, (f ? f : "fixed"));
+ if (!pw->date_font) pw->date_font = XLoadQueryFont (si->dpy, "fixed");
+ if (f) free (f);
+
+ pw->foreground = get_pixel_resource ("passwd.foreground",
+ "Dialog.Foreground",
+ si->dpy, cmap);
+ pw->background = get_pixel_resource ("passwd.background",
+ "Dialog.Background",
+ si->dpy, cmap);
+
+ if (pw->foreground == pw->background)