http://slackware.bholcomb.com/slackware/slackware-11.0/source/xap/xscreensaver/xscree...
[xscreensaver] / driver / test-passwd.c
index 988b00126c7f411303a4a76c5d9fe207cfbfb32e..a42d466bc4cfea1a252792f0f90b6180d35d89b9 100644 (file)
@@ -1,4 +1,4 @@
-/* xscreensaver, Copyright (c) 1998, 2001 Jamie Zawinski <jwz@jwz.org>
+/* xscreensaver, Copyright (c) 1998-2005 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -52,11 +52,15 @@ void start_notice_events_timer (saver_info *si, Window w, Bool b) {}
 Bool handle_clientmessage (saver_info *si, XEvent *e, Bool u) { return False; }
 int BadWindow_ehandler (Display *dpy, XErrorEvent *error) { exit(1); }
 const char *signal_name(int signal) { return "???"; }
-void restore_real_vroot (saver_info *si) {}
+Bool restore_real_vroot (saver_info *si) { return False; }
 void store_saver_status (saver_info *si) {}
 void saver_exit (saver_info *si, int status, const char *core) { exit(status);}
 int move_mouse_grab (saver_info *si, Window to, Cursor c, int ts) { return 0; }
 int mouse_screen (saver_info *si) { return 0; }
+void check_for_leaks (const char *where) { }
+void exec_command (const char *shell, const char *command, int nice) { }
+int on_path_p (const char *program) { return 0; }
+void shutdown_stderr (saver_info *si) { }
 
 const char *blurb(void) { return progname; }
 Atom XA_SCREENSAVER, XA_DEMO, XA_PREFS;
@@ -72,6 +76,8 @@ get_screen_viewport (saver_screen_info *ssi,
   *y_ret = 0;
   *w_ret = WidthOfScreen (ssi->screen);
   *h_ret = HeightOfScreen (ssi->screen);
+
+  if (*w_ret > *h_ret * 2) *w_ret /= 2;  /* xinerama kludge */
 }
 
 
@@ -87,6 +93,12 @@ idle_timer (XtPointer closure, XtIntervalId *id)
 }
 
 
+#ifdef __GNUC__
+ __extension__     /* shut up about "string length is greater than the length
+                      ISO C89 compilers are required to support" when including
+                      the .ad file... */
+#endif
+
 static char *fallback[] = {
 #include "XScreenSaver_ad.h"
  0
@@ -132,16 +144,26 @@ main (int argc, char **argv)
       exit (1);
     }
 
+#ifdef NO_LOCKING
+  if (which == PASS || which == TTY)
+    {
+      fprintf (stderr, "%s: compiled with NO_LOCKING\n", progname);
+      exit (1);
+    }
+#endif
+
+#ifndef NO_LOCKING
   /* before hack_uid() for proper permissions */
   lock_priv_init (argc, argv, True);
 
   hack_uid (si);
 
-  if (! lock_init (argc, argv, si->prefs.verbose_p))
+  if (! lock_init (argc, argv, True))
     {
       si->locking_disabled_p = True;
       si->nolock_reason = "error getting password";
     }
+#endif
 
   progclass = "XScreenSaver";
 
@@ -167,14 +189,14 @@ main (int argc, char **argv)
       db = p->db;
       XtGetApplicationNameAndClass (si->dpy, &progname, &progclass);
 
-      load_init_file (&si->prefs);
-
+      load_init_file (si->dpy, &si->prefs);
     }
 
   p->verbose_p = True;
 
   while (1)
     {
+#ifndef NO_LOCKING
       if (which == PASS)
         {
           if (unlock_p (si))
@@ -185,7 +207,9 @@ main (int argc, char **argv)
           XSync(si->dpy, False);
           sleep (3);
         }
-      else if (which == SPLASH)
+      else
+#endif
+      if (which == SPLASH)
         {
           XEvent event;
           make_splash_dialog (si);
@@ -214,10 +238,12 @@ main (int argc, char **argv)
           if (pass[strlen(pass)-1] == '\n')
             pass[strlen(pass)-1] = 0;
 
+#ifndef NO_LOCKING
           if (passwd_valid_p (pass, True))
             printf ("%s: Ok!\n", progname);
           else
             printf ("%s: Wrong!\n", progname);
+#endif
         }
       else
         abort();