dav/config.c

changeset 154
3cfb4670d9e6
parent 150
37fb12574acd
child 185
cd42cccee550
--- a/dav/config.c	Thu Oct 08 14:25:53 2015 +0200
+++ b/dav/config.c	Mon Oct 12 14:36:16 2015 +0200
@@ -161,6 +161,7 @@
     repo->decrypt_name = false;
     repo->decrypt_content = true;
     repo->ssl_version = CURL_SSLVERSION_DEFAULT;
+    repo->authmethods = CURLAUTH_BASIC;
     return repo;
 }
 
@@ -202,7 +203,7 @@
     ucx_map_cstr_put(repos, repo->name, repo);
 }
 
-int repo_add_config(Repository *repo, char *key, char *value) {
+int repo_add_config(Repository *repo, char *key, char *value) {  
     if(xstreq(key, "name")) {
         repo->name = strdup(value);
     } else if(xstreq(key, "url")) {
@@ -253,6 +254,30 @@
         else {
             fprintf(stderr, "Unknown ssl version: %s\n", value);
         }
+    } else if(xstreq(key, "authmethods")) {
+        repo->authmethods = CURLAUTH_NONE;
+        const char *delims = " ,\r\n";
+        char *meths = strdup(value);
+        char *meth = strtok(meths, delims);
+        while (meth) {
+            if(xstrEQ(value, "basic")) {
+                repo->authmethods |= CURLAUTH_BASIC;
+            } else if(xstrEQ(value, "digest")) {
+                repo->authmethods |= CURLAUTH_DIGEST;
+            } else if(xstrEQ(value, "negotiate")) {
+                repo->authmethods |= CURLAUTH_GSSNEGOTIATE;
+            } else if(xstrEQ(value, "ntlm")) {
+                repo->authmethods |= CURLAUTH_NTLM;
+            } else if(xstrEQ(value, "any")) {
+                repo->authmethods = CURLAUTH_ANY;
+            } else if(xstrEQ(value, "none")) {
+                /* skip */
+            } else {
+                fprintf(stderr, "Unknown authentication method: %s\n", value);
+            }
+            meth = strtok(NULL, delims);
+        }
+        free(meths);
     } else {
         return -1;
     }

mercurial