-static char *
-reformat_hack(const char *hack)
-{
- int i;
- const char *in = hack;
- int indent = 13;
- char *h2 = (char *) malloc(strlen(in) + indent + 2);
- char *out = h2;
-
- while (isspace(*in)) in++; /* skip whitespace */
- while (*in && !isspace(*in) && *in != ':')
- *out++ = *in++; /* snarf first token */
- while (isspace(*in)) in++; /* skip whitespace */
-
- if (*in == ':')
- *out++ = *in++; /* copy colon */
- else
- {
- in = hack;
- out = h2; /* reset to beginning */
- }
-
- *out = 0;
-
- while (isspace(*in)) in++; /* skip whitespace */
- for (i = strlen(h2); i < indent; i++) /* indent */
- *out++ = ' ';
-
- while (*in) *out++ = *in++; /* copy rest of line */
- *out = 0;
-
- return h2;
-}
-
-
-static void
-get_screenhacks (saver_info *si)
-{
- saver_preferences *p = &si->prefs;
- int i = 0;
- int hacks_size = 60;
- int size;
- char *d;
-
- d = get_string_resource ("monoPrograms", "MonoPrograms");
- if (d && !*d) { free(d); d = 0; }
- if (!d)
- d = get_string_resource ("colorPrograms", "ColorPrograms");
- if (d && !*d) { free(d); d = 0; }
-
- if (d)
- {
- fprintf (stderr,
- "%s: the `monoPrograms' and `colorPrograms' resources are obsolete;\n\
- see the manual for details.\n", blurb());
- free(d);
- }
-
- d = get_string_resource ("programs", "Programs");
-
- size = d ? strlen (d) : 0;
- p->screenhacks = (char **) malloc (sizeof (char *) * hacks_size);
- p->screenhacks_count = 0;
-
- while (i < size)
- {
- int end, start = i;
- if (d[i] == ' ' || d[i] == '\t' || d[i] == '\n' || d[i] == 0)
- {
- i++;
- continue;
- }
- if (hacks_size <= p->screenhacks_count)
- p->screenhacks = (char **) realloc (p->screenhacks,
- (hacks_size = hacks_size * 2) *
- sizeof (char *));
- p->screenhacks [p->screenhacks_count++] = d + i;
- while (d[i] != 0 && d[i] != '\n')
- i++;
- end = i;
- while (i > start && (d[i-1] == ' ' || d[i-1] == '\t'))
- i--;
- d[i] = 0;
- i = end + 1;
- }
-
- /* shrink all whitespace to one space, for the benefit of the "demo"
- mode display. We only do this when we can easily tell that the
- whitespace is not significant (no shell metachars).
- */
- for (i = 0; i < p->screenhacks_count; i++)
- {
- char *s = p->screenhacks [i];
- char *s2;
- int L = strlen (s);
- int j, k;
- for (j = 0; j < L; j++)
- {
- switch (s[j])
- {
- case '\'': case '"': case '`': case '\\':
- goto DONE;
- case '\t':
- s[j] = ' ';
- case ' ':
- k = 0;
- for (s2 = s+j+1; *s2 == ' ' || *s2 == '\t'; s2++)
- k++;
- if (k > 0)
- {
- for (s2 = s+j+1; s2[k]; s2++)
- *s2 = s2[k];
- *s2 = 0;
- }
- break;
- }
- }
- DONE:
- p->screenhacks[i] = reformat_hack(s); /* mallocs */
- }
-
- if (p->screenhacks_count)
- {
- /* Shrink down the screenhacks array to be only as big as it needs to.
- This doesn't really matter at all. */
- p->screenhacks = (char **)
- realloc (p->screenhacks, ((p->screenhacks_count + 1) *
- sizeof(char *)));
- p->screenhacks [p->screenhacks_count] = 0;
- }
- else
- {
- free (p->screenhacks);
- p->screenhacks = 0;
- }
-}
-
-
-static Bool blurb_timestamp_p = False; /* kludge */
-
-
-static void
-get_resources (saver_info *si)
-{
- char *s;
- saver_preferences *p = &si->prefs;
-
- p->xsync_p = get_boolean_resource ("synchronous", "Synchronous");
- if (p->xsync_p)
- XSynchronize(si->dpy, True);
-
- p->verbose_p = get_boolean_resource ("verbose", "Boolean");
- p->timestamp_p = get_boolean_resource ("timestamp", "Boolean");
- p->lock_p = get_boolean_resource ("lock", "Boolean");
- p->fade_p = get_boolean_resource ("fade", "Boolean");
- p->unfade_p = get_boolean_resource ("unfade", "Boolean");
- p->fade_seconds = get_seconds_resource ("fadeSeconds", "Time");
- p->fade_ticks = get_integer_resource ("fadeTicks", "Integer");
- p->install_cmap_p = get_boolean_resource ("installColormap", "Boolean");
- p->nice_inferior = get_integer_resource ("nice", "Nice");
-
- p->initial_delay = get_seconds_resource ("initialDelay", "Time");
- p->splash_duration = 1000 * get_seconds_resource ("splashDuration", "Time");
- p->timeout = 1000 * get_minutes_resource ("timeout", "Time");
- p->lock_timeout = 1000 * get_minutes_resource ("lockTimeout", "Time");
- p->cycle = 1000 * get_minutes_resource ("cycle", "Time");
-
-#ifndef NO_LOCKING
- p->passwd_timeout = 1000 * get_seconds_resource ("passwdTimeout", "Time");
-#endif
-
- p->pointer_timeout = 1000 * get_seconds_resource ("pointerPollTime", "Time");
- p->notice_events_timeout = 1000*get_seconds_resource("windowCreationTimeout",
- "Time");
- p->shell = get_string_resource ("bourneShell", "BourneShell");
-
- p->help_url = get_string_resource("helpURL", "URL");
- p->load_url_command = get_string_resource("loadURL", "LoadURL");
-
- if ((s = get_string_resource ("splash", "Boolean")))
- if (!get_boolean_resource("splash", "Boolean"))
- p->splash_duration = 0;
- if (s) free (s);
-
- /* don't set use_xidle_extension unless it is explicitly specified */
- if ((s = get_string_resource ("xidleExtension", "Boolean")))
- p->use_xidle_extension = get_boolean_resource ("xidleExtension","Boolean");
- else
-#ifdef HAVE_XIDLE_EXTENSION /* pick a default */
- p->use_xidle_extension = True; /* if we have it, use it */
-#else /* !HAVE_XIDLE_EXTENSION */
- p->use_xidle_extension = False;
-#endif /* !HAVE_XIDLE_EXTENSION */
- if (s) free (s);
-
- /* don't set use_mit_extension unless it is explicitly specified */
- if ((s = get_string_resource ("mitSaverExtension", "Boolean")))
- p->use_mit_saver_extension = get_boolean_resource ("mitSaverExtension",
- "Boolean");
- else
-#ifdef HAVE_MIT_SAVER_EXTENSION /* pick a default */
- p->use_mit_saver_extension = False; /* Default false, because it sucks */
-#else /* !HAVE_MIT_SAVER_EXTENSION */
- p->use_mit_saver_extension = False;
-#endif /* !HAVE_MIT_SAVER_EXTENSION */
- if (s) free (s);
-
-
- /* don't set use_mit_extension unless it is explicitly specified */
- if ((s = get_string_resource ("sgiSaverExtension", "Boolean")))
- p->use_sgi_saver_extension = get_boolean_resource ("sgiSaverExtension",
- "Boolean");
- else
-#ifdef HAVE_SGI_SAVER_EXTENSION /* pick a default */
- p->use_sgi_saver_extension = True; /* if we have it, use it */
-#else /* !HAVE_SGI_SAVER_EXTENSION */
- p->use_sgi_saver_extension = False;
-#endif /* !HAVE_SGI_SAVER_EXTENSION */
- if (s) free (s);
-
-
- /* Throttle the various timeouts to reasonable values.
- */
-#ifndef NO_LOCKING
- if (p->passwd_timeout == 0) p->passwd_timeout = 30000; /* 30 secs */
-#endif
- if (p->timeout < 10000) p->timeout = 10000; /* 10 secs */
- if (p->cycle != 0 && p->cycle < 2000) p->cycle = 2000; /* 2 secs */
- if (p->pointer_timeout == 0) p->pointer_timeout = 5000; /* 5 secs */
- if (p->notice_events_timeout == 0)
- p->notice_events_timeout = 10000; /* 10 secs */
- if (p->fade_seconds == 0 || p->fade_ticks == 0)
- p->fade_p = False;
- if (! p->fade_p) p->unfade_p = False;
-
- p->watchdog_timeout = p->cycle;
- if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000; /* 30 secs */
- if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /* 1 hr */
-
-#ifdef NO_LOCKING
- si->locking_disabled_p = True;
- si->nolock_reason = "not compiled with locking support";
-#endif /* NO_LOCKING */
-
- get_screenhacks (si);
-
- if (p->debug_p)
- {
- XSynchronize(si->dpy, True);
- p->xsync_p = True;
- p->verbose_p = True;
- p->timestamp_p = True;
- p->initial_delay = 0;
- }
-
- blurb_timestamp_p = p->timestamp_p;
-}
-
-