added collection config for sync directories

Mon, 04 Aug 2014 14:33:56 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 04 Aug 2014 14:33:56 +0200
changeset 56
99f7816fcf01
parent 55
4cb389452a44
child 57
3c1ce5f203d7

added collection config for sync directories

dav/scfg.c file | annotate | diff | comparison | revisions
dav/scfg.h file | annotate | diff | comparison | revisions
dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/scfg.c	Mon Aug 04 12:53:36 2014 +0200
+++ b/dav/scfg.c	Mon Aug 04 14:33:56 2014 +0200
@@ -79,6 +79,7 @@
 int scfg_load_directory(xmlNode *node) {
     char *name = NULL;
     char *path = NULL;
+    char *collection = NULL;
     char *repository = NULL;
     char *database = NULL;
     
@@ -92,6 +93,8 @@
                 name = value;
             } else if(xstreq(node->name, "path")) {
                 path = value;
+            } else if(xstreq(node->name, "collection")) {
+                collection = value;
             } else if(xstreq(node->name, "repository")) {
                 repository = value;
             } else if(xstreq(node->name, "database")) {
@@ -121,6 +124,7 @@
     SyncDirectory *dir = malloc(sizeof(SyncDirectory));
     dir->name = strdup(name);
     dir->path = strdup(path);
+    dir->collection = collection ? strdup(collection) : NULL;
     dir->repository = strdup(repository);
     dir->database = strdup(database);
     
--- a/dav/scfg.h	Mon Aug 04 12:53:36 2014 +0200
+++ b/dav/scfg.h	Mon Aug 04 14:33:56 2014 +0200
@@ -40,6 +40,7 @@
 typedef struct SyncDirectory {
     char *name;
     char *path;
+    char *collection;
     char *repository;
     char *database;
 } SyncDirectory;
--- a/dav/sync.c	Mon Aug 04 12:53:36 2014 +0200
+++ b/dav/sync.c	Mon Aug 04 14:33:56 2014 +0200
@@ -130,11 +130,18 @@
         return -1;
     }
     
+    char *new_url = NULL;
+    if(dir->collection) {
+        new_url = util_concat_path(repo->url, dir->collection);
+    }
     DavSession *sn = dav_session_new_auth(
             ctx,
-            repo->url,
+            new_url ? new_url : repo->url,
             repo->user,
             repo->password);
+    if(new_url) {
+        free(new_url);
+    }
     dav_session_set_flags(sn, get_repository_flags(repo));
     sn->key = dav_context_get_key(ctx, repo->default_key);
     
@@ -372,11 +379,18 @@
         return -1;
     }
     
+    char *new_url = NULL;
+    if(dir->collection) {
+        new_url = util_concat_path(repo->url, dir->collection);
+    }
     DavSession *sn = dav_session_new_auth(
             ctx,
-            repo->url,
+            new_url ? new_url : repo->url,
             repo->user,
             repo->password);
+    if(new_url) {
+        free(new_url);
+    }
     dav_session_set_flags(sn, get_repository_flags(repo));
     sn->key = dav_context_get_key(ctx, repo->default_key);
     

mercurial