+ XtAppContext app;
+ prefs_pair Pair, *pair;
+ saver_preferences P, P2, *p, *p2;
+ Bool prefs = False;
+ int i;
+ Display *dpy;
+ Widget toplevel_shell;
+ char *real_progname = argv[0];
+ char *s;
+
+ s = strrchr (real_progname, '/');
+ if (s) real_progname = s+1;
+
+ p = &P;
+ p2 = &P2;
+ pair = &Pair;
+ pair->a = p;
+ pair->b = p2;
+ memset (p, 0, sizeof (*p));
+ memset (p2, 0, sizeof (*p2));
+
+ progname = real_progname;
+
+ /* We must read exactly the same resources as xscreensaver.
+ That means we must have both the same progclass *and* progname,
+ at least as far as the resource database is concerned. So,
+ put "xscreensaver" in argv[0] while initializing Xt.
+ */
+ argv[0] = "xscreensaver";
+ progname = argv[0];
+
+
+ toplevel_shell = XtAppInitialize (&app, progclass, 0, 0, &argc, argv,
+ defaults, 0, 0);
+
+ dpy = XtDisplay (toplevel_shell);
+ db = XtDatabase (dpy);
+ XtGetApplicationNameAndClass (dpy, &progname, &progclass);
+ XSetErrorHandler (demo_ehandler);
+
+ /* Complain about unrecognized command-line arguments.
+ */
+ for (i = 1; i < argc; i++)
+ {
+ char *s = argv[i];
+ if (s[0] == '-' && s[1] == '-')
+ s++;
+ if (!strcmp (s, "-prefs"))
+ prefs = True;
+ else
+ {
+ fprintf (stderr, "usage: %s [ -display dpy-string ] [ -prefs ]\n",
+ real_progname);
+ exit (1);
+ }
+ }
+
+ short_version = (char *) malloc (5);
+ memcpy (short_version, screensaver_id + 17, 4);
+ short_version [4] = 0;
+
+ /* Load the init file, which may end up consulting the X resource database
+ and the site-wide app-defaults file. Note that at this point, it's
+ important that `progname' be "xscreensaver", rather than whatever
+ was in argv[0].
+ */
+ p->db = db;
+ load_init_file (p);
+ *p2 = *p;
+
+ /* Now that Xt has been initialized, and the resources have been read,
+ we can set our `progname' variable to something more in line with
+ reality.
+ */
+ progname = real_progname;
+
+
+#ifdef HAVE_ATHENA
+ global_prefs_kludge = p; /* I hate C so much... */
+#endif /* HAVE_ATHENA */
+
+#if 0
+ {
+ XrmName name = { 0 };
+ XrmClass class = { 0 };
+ int count = 0;
+ XrmEnumerateDatabase (db, &name, &class, XrmEnumAllLevels, mapper,
+ (POINTER) &count);
+ }
+#endif
+
+
+ XA_VROOT = XInternAtom (dpy, "__SWM_VROOT", False);
+ XA_SCREENSAVER = XInternAtom (dpy, "SCREENSAVER", False);
+ XA_SCREENSAVER_VERSION = XInternAtom (dpy, "_SCREENSAVER_VERSION",False);
+ XA_SCREENSAVER_STATUS = XInternAtom (dpy, "_SCREENSAVER_STATUS", False);
+ XA_SCREENSAVER_ID = XInternAtom (dpy, "_SCREENSAVER_ID", False);
+ XA_SCREENSAVER_RESPONSE = XInternAtom (dpy, "_SCREENSAVER_RESPONSE", False);
+ XA_SELECT = XInternAtom (dpy, "SELECT", False);
+ XA_DEMO = XInternAtom (dpy, "DEMO", False);
+ XA_BLANK = XInternAtom (dpy, "BLANK", False);
+ XA_LOCK = XInternAtom (dpy, "LOCK", False);
+ XA_EXIT = XInternAtom (dpy, "EXIT", False);
+ XA_RESTART = XInternAtom (dpy, "RESTART", False);
+
+ make_demo_dialog (toplevel_shell, pair);
+
+ if (prefs)
+ {
+ make_preferences_dialog (pair, toplevel_shell);
+ pop_preferences_dialog (pair);
+ }
+
+ the_network_is_not_the_computer (preferences_dialog
+ ? preferences_dialog
+ : demo_dialog);
+
+ XtAppMainLoop (app);
+
+ exit (0);