diff --git a/archiver/ChangeLog b/archiver/ChangeLog index 991280208..1f1e259e9 100644 --- a/archiver/ChangeLog +++ b/archiver/ChangeLog @@ -1,6 +1,15 @@ 2001-01-25 Bradford Hovinen - * location.c (location_rollback_all_to): Increment array index + * config-log.c (get_current_date): Use local time rather than + Greenwich Mean Time + + * location.c (location_store_xml): Implement; copy from + location_store + (location_store): Free filename after use + + * archive.c (archive_load): Free prefix only if not global + + * location.c (location_rollback_all_to): Increment array * util.c (parse_date): Normalize values diff --git a/archiver/TODO b/archiver/TODO index 24768bf8e..628df031b 100644 --- a/archiver/TODO +++ b/archiver/TODO @@ -4,6 +4,8 @@ * Support multiple backends from CLI * Add translateable backend description support * Some way to store the rollback time for each backend, for GUI purposes + * Have defaults stored somewhere, to be restored when the user goes + back before the first configuration edit Long-term * Add clustering support: diff --git a/archiver/archive.c b/archiver/archive.c index 6030ce84f..b1365e657 100644 --- a/archiver/archive.c +++ b/archiver/archive.c @@ -196,7 +196,7 @@ archive_load (gboolean is_global) "prefix", prefix, NULL); - if (is_global) + if (!is_global) g_free (prefix); if (do_load (ARCHIVE (object)) == FALSE) { diff --git a/archiver/config-log.c b/archiver/config-log.c index c026db797..779892cb1 100644 --- a/archiver/config-log.c +++ b/archiver/config-log.c @@ -851,7 +851,7 @@ get_current_date (void) struct tm *time_1, *ret; current_time = time (NULL); - time_1 = gmtime (¤t_time); + time_1 = localtime (¤t_time); ret = g_new (struct tm, 1); memcpy (ret, time_1, sizeof (struct tm)); return ret; diff --git a/archiver/location.c b/archiver/location.c index 873b5feb9..dd6235d75 100644 --- a/archiver/location.c +++ b/archiver/location.c @@ -434,6 +434,7 @@ location_store (Location *location, gchar *backend_id, FILE *input) filename = g_strdup_printf ("%s/%08x.xml", location->p->fullpath, id); output = fopen (filename, "w"); + g_free (filename); if (output == NULL) return; @@ -445,6 +446,45 @@ location_store (Location *location, gchar *backend_id, FILE *input) fclose (output); } +/** + * location_store_xml: + * @location: + * @backend_id: + * @input: + * + * Store configuration data from the given XML document object in the location + * under the given backend id + **/ + +void +location_store_xml (Location *location, gchar *backend_id, xmlDocPtr xml_doc) +{ + gint id; + char *filename; + + g_return_if_fail (location != NULL); + g_return_if_fail (IS_LOCATION (location)); + g_return_if_fail (location->p->config_log != NULL); + g_return_if_fail (IS_CONFIG_LOG (location->p->config_log)); + + if (!location_contains (location, backend_id)) { + if (!location->p->inherits_location) + g_warning ("Could not find a location in the " \ + "tree ancestry that stores this " \ + "backend."); + else + location_store_xml (location->p->inherits_location, + backend_id, xml_doc); + } + + id = config_log_write_entry (location->p->config_log, backend_id); + + filename = g_strdup_printf ("%s/%08x.xml", + location->p->fullpath, id); + xmlSaveFile (filename, xml_doc); + g_free (filename); +} + /** * location_rollback_backend_to: * @location: diff --git a/archiver/location.h b/archiver/location.h index 389d57433..f3b6cd1c2 100644 --- a/archiver/location.h +++ b/archiver/location.h @@ -25,6 +25,7 @@ #define __LOCATION_H #include +#include #include "config-log.h" @@ -64,6 +65,9 @@ void location_delete (Location *location); void location_store (Location *location, gchar *backend_id, FILE *input); +void location_store_xml (Location *location, + gchar *backend_id, + xmlDocPtr xml_doc); void location_rollback_backend_to (Location *location, struct tm *date,