# HG changeset patch # User Olaf Wintermann # Date 1569655470 -7200 # Node ID 8bf1d9688698c39515cab8022d5cc81ca05a5de6 # Parent 37a8bfae995ecc5cfb5679ab0adacd5755bb0989 change versioning config diff -r 37a8bfae995e -r 8bf1d9688698 dav/scfg.c --- a/dav/scfg.c Sat Sep 28 09:09:14 2019 +0200 +++ b/dav/scfg.c Sat Sep 28 09:24:30 2019 +0200 @@ -177,8 +177,8 @@ return TAG_FORMAT_UNKNOWN; } -#define CHECK_VALUE(element, value) if(!(value)) \ - print_error(element->line, "missing value element: %s\n", element->name); +#define CHECK_VALUE_RET_NULL(element, value) if(!(value)) \ + print_error(element->line, "missing value element: %s\n", element->name); return NULL; static TagConfig* parse_tagconfig(xmlNode *node) { TagConfig conf; @@ -195,21 +195,20 @@ if(c->type == XML_ELEMENT_NODE) { char *value = util_xml_get_text(c); if(xstreq(c->name, "local-store")) { - CHECK_VALUE(c, value); + CHECK_VALUE_RET_NULL(c, value); if(xstreq(value, "xattr")) { conf.store = TAG_STORE_XATTR; } else { return NULL; } - xmlAttr *attr = c->properties; xmlChar *format = xmlGetNoNsProp(node, BAD_CAST "format"); if(format) { conf.local_format = str2tagformat((char*)format); xmlFree(format); } } else if(xstreq(c->name, "detect-changes")) { - CHECK_VALUE(c, value); + CHECK_VALUE_RET_NULL(c, value); conf.detect_changes = util_getboolean(value); } else if(xstreq(c->name, "xattr-name")) { if(!value) { @@ -217,7 +216,7 @@ } conf.xattr_name = strdup(value); } else if(xstreq(c->name, "on-conflict")) { - CHECK_VALUE(c, value); + CHECK_VALUE_RET_NULL(c, value); if(xstreq(value, "no_conflict")) { conf.conflict = TAG_NO_CONFLICT; } else if(xstreq(value, "keep_local")) { @@ -340,28 +339,43 @@ Versioning v; v.always = FALSE; v.type = VERSIONING_SIMPLE; - v.collection = "/.dav-version-history"; + v.collection = VERSIONING_DEFAULT_PATH; + + int err = 0; + + xmlChar *attr_type = xmlGetNoNsProp(node, BAD_CAST "format"); + xmlChar *attr_always = xmlGetNoNsProp(node, BAD_CAST "always"); + + if(attr_type) { + if(xstreq(attr_type, "simple")) { + v.type = VERSIONING_SIMPLE; + } else if(xstreq(attr_type, "deltav")) { + v.type = VERSIONING_DELTAV; + } else { + print_error(node->line, + "type attribute: unknown value: %s\n", + attr_type); + err = 1; + } + xmlFree(attr_type); + } + if(attr_always) { + v.always = util_getboolean(attr_always); + xmlFree(attr_always); + } + + if(err) { + return NULL; + } 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); + if(xstreq(c->name, "history")) { + CHECK_VALUE_RET_NULL(c, value); v.collection = value; - } else if(xstreq(c->name, "always")) { - CHECK_VALUE(c, value); - v.always = util_getboolean(value); - } + } } c = c->next; } diff -r 37a8bfae995e -r 8bf1d9688698 dav/scfg.h --- a/dav/scfg.h Sat Sep 28 09:09:14 2019 +0200 +++ b/dav/scfg.h Sat Sep 28 09:24:30 2019 +0200 @@ -53,6 +53,8 @@ #define DEFAULT_TAG_XATTR "tags" #define MACOS_TAG_XATTR "com.apple.metadata:_kMDItemUserTags" +#define VERSIONING_DEFAULT_PATH "/.dav-version-history" + #define SYNC_SYMLINK(dir) \ (((dir)->symlink & SYNC_SYMLINK_SYNC) == SYNC_SYMLINK_SYNC)