X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fprefs.c;h=747db1e58e85c4107755ebdede87c3e3c37e985f;hb=af290bcdf2d1c61efc8aaaff653745c900cbe98c;hp=306e694a09a1fc5453c52a5e82a3b7e1e913bc20;hpb=c31d10b6605cd8dc1a7b61fef4256f06198767e5;p=xscreensaver diff --git a/driver/prefs.c b/driver/prefs.c index 306e694a..747db1e5 100644 --- a/driver/prefs.c +++ b/driver/prefs.c @@ -75,6 +75,24 @@ extern const char *blurb (void); static void get_screenhacks (saver_preferences *p); +static char * +chase_symlinks (const char *file) +{ +# ifdef HAVE_REALPATH + if (file) + { + char buf [2048]; + if (realpath (file, buf)) + return strdup (buf); + + sprintf (buf, "%s: realpath", blurb()); + perror(buf); + } +# endif /* HAVE_REALPATH */ + return 0; +} + + const char * init_file_name (void) { @@ -123,6 +141,10 @@ init_file_tmp_name (void) { const char *name = init_file_name(); const char *suffix = ".tmp"; + + char *n2 = chase_symlinks (name); + if (n2) name = n2; + if (!name || !*name) file = ""; else @@ -131,6 +153,8 @@ init_file_tmp_name (void) strcpy(file, name); strcat(file, suffix); } + + if (n2) free (n2); } if (file && *file) @@ -174,6 +198,7 @@ static const char * const prefs[] = { "sgiSaverExtension", "mitSaverExtension", "xidleExtension", + "procInterrupts", "overlayStderr", "overlayTextBackground", /* not saved -- X resources only */ "overlayTextForeground", /* not saved -- X resources only */ @@ -338,6 +363,7 @@ parse_init_file (saver_preferences *p) if (!p->db) abort(); handle_entry (&p->db, key, value, name, line); } + fclose (in); free(buf); p->init_file_date = write_date; @@ -491,6 +517,7 @@ write_init_file (saver_preferences *p, const char *version_string) { const char *name = init_file_name(); const char *tmp_name = init_file_tmp_name(); + char *n2 = chase_symlinks (name); struct stat st; int i, j; @@ -503,7 +530,9 @@ write_init_file (saver_preferences *p, const char *version_string) char *stderr_font; FILE *out; - if (!name) return; + if (!name) goto END; + + if (n2) name = n2; if (p->verbose_p) fprintf (stderr, "%s: writing \"%s\".\n", blurb(), name); @@ -516,7 +545,7 @@ write_init_file (saver_preferences *p, const char *version_string) sprintf(buf, "%s: error writing \"%s\"", blurb(), name); perror(buf); free(buf); - return; + goto END; } /* Give the new .xscreensaver file the same permissions as the old one; @@ -535,7 +564,7 @@ write_init_file (saver_preferences *p, const char *version_string) tmp_name, (unsigned int) mode); perror(buf); free(buf); - return; + goto END; } } @@ -633,6 +662,7 @@ write_init_file (saver_preferences *p, const char *version_string) CHECK("sgiSaverExtension")type = pref_bool, b=p->use_sgi_saver_extension; CHECK("mitSaverExtension")type = pref_bool, b=p->use_mit_saver_extension; CHECK("xidleExtension") type = pref_bool, b = p->use_xidle_extension; + CHECK("procInterrupts") type = pref_bool, b = p->use_proc_interrupts; CHECK("overlayStderr") type = pref_bool, b = overlay_stderr_p; CHECK("overlayTextBackground") continue; /* don't save */ CHECK("overlayTextForeground") continue; /* don't save */ @@ -696,7 +726,7 @@ write_init_file (saver_preferences *p, const char *version_string) perror(buf); unlink (tmp_name); free(buf); - return; + goto END; } if (rename (tmp_name, name) != 0) @@ -707,7 +737,7 @@ write_init_file (saver_preferences *p, const char *version_string) perror(buf); unlink (tmp_name); free(buf); - return; + goto END; } else { @@ -725,8 +755,11 @@ write_init_file (saver_preferences *p, const char *version_string) perror(buf); free(buf); unlink (tmp_name); - return; + goto END; } + + END: + if (n2) free (n2); } @@ -792,12 +825,12 @@ load_init_file (saver_preferences *p) "Boolean"); p->use_sgi_saver_extension = get_boolean_resource ("sgiSaverExtension", "Boolean"); + p->use_proc_interrupts = get_boolean_resource ("procInterrupts", "Boolean"); /* Throttle the various timeouts to reasonable values. */ if (p->passwd_timeout <= 0) p->passwd_timeout = 30000; /* 30 secs */ if (p->timeout < 10000) p->timeout = 10000; /* 10 secs */ - if (p->cycle < 0) p->cycle = 0; 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) @@ -806,15 +839,7 @@ load_init_file (saver_preferences *p) p->fade_p = False; if (! p->fade_p) p->unfade_p = False; - if (p->verbose_p && !p->fading_possible_p && (p->fade_p || p->unfade_p)) - { - fprintf (stderr, "%s: there are no PseudoColor or GrayScale visuals.\n", - blurb()); - fprintf (stderr, "%s: ignoring the request for fading/unfading.\n", - blurb()); - } - - p->watchdog_timeout = p->cycle; + p->watchdog_timeout = p->cycle * 0.6; if (p->watchdog_timeout < 30000) p->watchdog_timeout = 30000; /* 30 secs */ if (p->watchdog_timeout > 3600000) p->watchdog_timeout = 3600000; /* 1 hr */