From d3d5bb1dfc21ac30b77fc4484ff942d0a9100275 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 20 Mar 2014 21:16:59 +0100 Subject: Make setup files versioned and add fallback for old versions This commit makes setup files (setup.xml and referenced design setup xml file) versioned and adds checks for correct versions. If a newer versioned file is detected, warning is printed out in assumption that a stray cgg version is used. If the version information is missing or is lower than expected version, files are read in legacy mode. Some values are left on defaults and missing mandatory values are either read from renamed keys or made up to suit current requirements. This essentially brings back compatibility with old setup.xml files that are usually part of galleries. However, some values are hardcoded and should be kept in mind to update and test the legacy mode along with future enhancements. --- src/cgg.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/cgg.c') diff --git a/src/cgg.c b/src/cgg.c index 2891f6f..ea493ac 100644 --- a/src/cgg.c +++ b/src/cgg.c @@ -151,11 +151,23 @@ main (int argc, char* argv[]) fprintf (stderr, "error: could not parse gallery settings file\n"); return -2; } - setup->design = parse_design_setup_xml (setup->design_setup_file); - if (! setup->design) { - fprintf (stderr, "error: could not parse design setup file\n"); - return -6; + + if (SETUP_IS_LEGACY (setup)) { + /* Design legacy mode */ + setup->design = makeup_legacy_design (setup->setup_xml_path); + if (! setup->design) { + fprintf (stderr, "error: could not parse design from legacy setup file\n"); + return -6; + } + } else { + /* Design native mode */ + setup->design = parse_design_setup_xml (setup->design_setup_file); + if (! setup->design) { + fprintf (stderr, "error: could not parse design setup file\n"); + return -6; + } } + if (! validate_design_setup (setup->design)) return -7; @@ -174,6 +186,10 @@ main (int argc, char* argv[]) if (verbose) { printf ("cgg v%s [%s]\n\n", VERSION, APP_BUILD_DATE); printf ("Using setup file \"%s\"\n", setup->setup_xml_path); + if (SETUP_IS_NEWER (setup)) + printf ("WARNING: Reported setup.xml version is greater than current cgg engine, consider upgrading or expect random issues\n"); + if (SETUP_IS_LEGACY (setup)) + printf ("WARNING: Parsing setup.xml in legacy mode\n"); } /* Setup number of threads */ -- cgit v1.2.3