+ settings_destroy (&the_settings);
+}
+
+static void
+settings_copy (struct settings *dst, const struct settings *src)
+{
+ *dst = *src;
+ dst->styles = fmt_settings_clone (src->styles);
+}
+
+/* Returns a copy of the current settings. */
+struct settings *
+settings_get (void)
+{
+ struct settings *s = xmalloc (sizeof *s);
+ settings_copy (s, &the_settings);
+ return s;
+}
+
+/* Replaces the current settings by those in S. The caller retains ownership
+ of S. */
+void
+settings_set (const struct settings *s)
+{
+ settings_destroy (&the_settings);
+ settings_copy (&the_settings, s);
+}
+
+/* Destroys S. */
+void
+settings_destroy (struct settings *s)
+{
+ if (s != NULL)
+ {
+ fmt_settings_destroy (s->styles);
+ if (s != &the_settings)
+ free (s);
+ }