Index: xcs.c =================================================================== --- 1/xcs/xcs.c (revision 76) +++ 2/xcs/xcs.c (revision 78) @@ -230,12 +230,30 @@ filename = g_build_filename (g_get_home_dir(), XCS_RCPATH, "config.xml", NULL); if (g_file_test (filename, G_FILE_TEST_EXISTS)) - { - configuration->private->xmlconfig = - xmlParseFile (filename); - } - else - { + { + xmlXPathObjectPtr xpathobj; + xmlDocPtr xmldoc; + + xmldoc = xmlParseFile (filename); + new_configuration = FALSE; + + xpathobj = xml_execute_xpath_expression (xmldoc, "/" XCS_ROOT_NODE_NAME, NULL); + + if ((!xpathobj) || (!xpathobj->nodesetval) || (!xpathobj->nodesetval->nodeNr)) + { + new_configuration = TRUE; + xmlFreeDoc (xmldoc); + } + else + { + configuration->private->xmlconfig = xmldoc; + } + + xmlXPathFreeObject (xpathobj); + } + + if (new_configuration) + { configuration->private->xmlconfig = xmlNewDoc ((unsigned char*)"1.0"); node = xmlNewNode (NULL, (unsigned char*)XCS_ROOT_NODE_NAME); @@ -245,10 +263,8 @@ xmlDocSetRootElement (configuration->private-> xmlconfig, node); + } - new_configuration = TRUE; - } - g_free (filename); g_message("running: %s", G_OBJECT_TYPE_NAME(configuration)); @@ -256,7 +272,7 @@ static xmlXPathObjectPtr xcs_get_from_xpath (Xcs *configuration, - const gchar * xpath_expr) + const gchar * xpath_expr) { xmlXPathObjectPtr xpathObj = NULL;