dav/scfg.c

changeset 368
11797f33bc24
parent 367
4a6a59f89f9f
child 401
3bb3210f3e6e
--- a/dav/scfg.c	Fri Feb 02 18:57:21 2018 +0100
+++ b/dav/scfg.c	Sat Feb 03 15:59:53 2018 +0100
@@ -155,7 +155,9 @@
     conf.store = TAG_STORE_XATTR;
     conf.local_format = TAG_FORMAT_TEXT;
     conf.server_format = TAG_FORMAT_XML;
-    conf.scan = false;
+    conf.xattr_name = NULL;
+    conf.detect_changes = false;
+    conf.conflict = TAG_NO_CONFLICT;
     xmlNode *c = node->children;
     
     // TODO: error handling
@@ -184,16 +186,47 @@
                     }
                     attr = attr->next;
                 }
-            } else if(xstreq(c->name, "scan")) {
+            } else if(xstreq(c->name, "detect-changes")) {
+                if(!value) {
+                    return NULL;
+                }
+                conf.detect_changes = util_getboolean(value);
+            } else if(xstreq(c->name, "xattr-name")) {
+                if(!value) {
+                    return NULL;
+                }
+                conf.xattr_name = strdup(value);
+            } else if(xstreq(c->name, "on-conflict")) {
                 if(!value) {
                     return NULL;
                 }
-                conf.scan = util_getboolean(value);
+                if(xstreq(value, "no_conflict")) {
+                    conf.conflict = TAG_NO_CONFLICT;
+                } else if(xstreq(value, "keep_local")) {
+                    conf.conflict = TAG_KEEP_LOCAL;
+                } else if(xstreq(value, "keep_remote")) {
+                    conf.conflict = TAG_KEEP_REMOTE;
+                } else if(xstreq(value, "merge")) {
+                    conf.conflict = TAG_MERGE;
+                } else {
+                    fprintf(stderr, "on-conflict: unknown value: %s\n", value);
+                    return NULL;
+                }
             }
         }
         c = c->next;
     }
     
+    if(conf.store == TAG_STORE_XATTR && !conf.xattr_name) {
+        switch(conf.local_format) {
+            default:
+            case TAG_FORMAT_TEXT: 
+            case TAG_FORMAT_CSV: 
+            case TAG_FORMAT_XML: conf.xattr_name = strdup(DEFAULT_TAG_XATTR); break;
+            case TAG_FORMAT_MACOS: conf.xattr_name = strdup(MACOS_TAG_XATTR); break;
+        }
+    }
+    
     TagConfig *tagconfig = malloc(sizeof(TagConfig));
     *tagconfig = conf;
     return tagconfig;

mercurial