diff -r d94c4fd35c21 -r fdc2fb090cc7 dav/scfg.c --- a/dav/scfg.c Sat Oct 27 15:05:13 2018 +0200 +++ b/dav/scfg.c Sun Nov 04 16:35:44 2018 +0100 @@ -177,6 +177,9 @@ return TAG_FORMAT_UNKNOWN; } +#define CHECK_VALUE(element, value) if(!(value)) \ + print_error(element->line, "missing value element: %s\n", element->name); + static TagConfig* parse_tagconfig(xmlNode *node) { TagConfig conf; conf.store = TAG_STORE_XATTR; @@ -191,10 +194,9 @@ while(c) { if(c->type == XML_ELEMENT_NODE) { char *value = util_xml_get_text(c); - if(xstreq(c->name, "local-store")) { - if(!value) { - return NULL; - } else if(xstreq(value, "xattr")) { + if(xstreq(c->name, "local-store")) { + CHECK_VALUE(c, value); + if(xstreq(value, "xattr")) { conf.store = TAG_STORE_XATTR; } else { return NULL; @@ -207,9 +209,7 @@ xmlFree(format); } } else if(xstreq(c->name, "detect-changes")) { - if(!value) { - return NULL; - } + CHECK_VALUE(c, value); conf.detect_changes = util_getboolean(value); } else if(xstreq(c->name, "xattr-name")) { if(!value) { @@ -217,9 +217,7 @@ } conf.xattr_name = strdup(value); } else if(xstreq(c->name, "on-conflict")) { - if(!value) { - return NULL; - } + CHECK_VALUE(c, value); if(xstreq(value, "no_conflict")) { conf.conflict = TAG_NO_CONFLICT; } else if(xstreq(value, "keep_local")) { @@ -252,6 +250,43 @@ return tagconfig; } +static Versioning* parse_versioning_config(xmlNode *node) { + Versioning v; + v.always = FALSE; + v.type = VERSIONING_SIMPLE; + v.collection = "/.dav-version-history"; + + xmlNode *c = node->children; + while(c) { + if(c->type == XML_ELEMENT_NODE) { + char *value = util_xml_get_text(c); + if(xstreq(c->name, "type")) { + CHECK_VALUE(c, value); + if(!strcmp(value, "simple")) { + v.type = VERSIONING_SIMPLE; + } else if(!strcmp(value, "deltav")) { + v.type = VERSIONING_DELTAV; + } else { + return NULL; + } + } else if(xstreq(c->name, "collection")) { + CHECK_VALUE(c, value); + v.collection = value; + } else if(xstreq(c->name, "always")) { + CHECK_VALUE(c, value); + v.always = util_getboolean(value); + } + } + c = c->next; + } + + v.collection = strdup(v.collection); + + Versioning *versioning = malloc(sizeof(Versioning)); + *versioning = v; + return versioning; +} + static int scfg_load_directory(xmlNode *node) { char *name = NULL; char *path = NULL; @@ -260,6 +295,7 @@ char *repository = NULL; char *database = NULL; TagConfig *tagconfig = NULL; + Versioning *versioning = NULL; UcxList *include = NULL; UcxList *exclude = NULL; UcxList *tagfilter = NULL; @@ -304,6 +340,8 @@ database = value; } else if(xstreq(node->name, "tagconfig")) { tagconfig = parse_tagconfig(node); + } else if(xstreq(node->name, "versioning")) { + versioning = parse_versioning_config(node); } else if(xstreq(node->name, "max-retry")) { int64_t i; if(util_strtoint(value, &i) && i >= 0) { @@ -382,6 +420,7 @@ dir->repository = strdup(repository); dir->database = strdup(database); dir->tagconfig = tagconfig; + dir->versioning = versioning; dir->max_retry = max_retry; dir->allow_cmd = allow_cmd; dir->backuppull = backuppull;