# HG changeset patch # User Olaf Wintermann # Date 1528794856 -7200 # Node ID d7a086201a6e65d2020a71b236fdfd90ef30202a # Parent 6e1861e8262c19afef3814a76f8c7fad9ca925d6 adds attribute for tagfilter scope diff -r 6e1861e8262c -r d7a086201a6e dav/scfg.c --- a/dav/scfg.c Mon Jun 11 19:32:41 2018 +0200 +++ b/dav/scfg.c Tue Jun 12 11:14:16 2018 +0200 @@ -121,6 +121,24 @@ "malformed tag filter: %s\n", value); return 1; + } else { + // get scope + xmlChar *scope = xmlGetNoNsProp(node, "scope"); + if(scope) { + if(xstreq(scope, "resource")) + { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_RESOURCE; + } else if(xstreq(scope, "collection")) { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; + } else if(xstreq(scope, "all")) { + (*tagfilter)->scope = + DAV_SYNC_TAGFILTER_SCOPE_RESOURCE + | DAV_SYNC_TAGFILTER_SCOPE_COLLECTION; + } + } + xmlFree(scope); } } } else { @@ -141,18 +159,6 @@ return 0; } - -static char* get_attr_content(xmlNode *node) { - // TODO: remove code duplication (util_xml_get_text) and config.h - while(node) { - if(node->type == XML_TEXT_NODE) { - return (char*)node->content; - } - node = node->next; - } - return NULL; -} - static TagFormat str2tagformat(const char *str) { if(!strcmp(str, "text")) { return TAG_FORMAT_TEXT; @@ -190,17 +196,10 @@ } xmlAttr *attr = c->properties; - while(attr) { - if(attr->type == XML_ATTRIBUTE_NODE) { - const char *value = get_attr_content(attr->children); - if(!value) { - break; - } - if(xstreq(attr->name, "format")) { - conf.local_format = str2tagformat(value); - } - } - attr = attr->next; + xmlChar *format = xmlGetNoNsProp(node, "format"); + if(format) { + conf.local_format = str2tagformat(format); + xmlFree(format); } } else if(xstreq(c->name, "detect-changes")) { if(!value) {