dav/main.c

changeset 212
01e80c7cfe96
parent 211
3d12817414e9
child 213
cd870d5f8659
--- a/dav/main.c	Tue Mar 15 11:21:30 2016 +0100
+++ b/dav/main.c	Tue Mar 15 16:47:22 2016 +0100
@@ -69,7 +69,6 @@
     xmlGenericErrorFunc fnc = xmlerrorfnc;
     initGenericErrorDefaultFunc(&fnc);
     ctx = dav_context_new();
-    ctx->key_input = util_key_input;
     load_config(ctx);
     printxmlerror = 0;
 #ifdef DO_THE_TEST
@@ -94,6 +93,12 @@
         return -1;
     }
     
+    if(cmd_getoption(args, "noinput")) {
+        ctx->key_input = NULL;
+    } else {
+        ctx->key_input = util_key_input;
+    }
+    
     int ret = -1;
     if(!strcasecmp(cmd, "list") || !strcasecmp(cmd, "ls")) {
         ret = cmd_list(args);
@@ -204,7 +209,11 @@
     fprintf(stderr, "\n");
 }
 
-int request_auth(Repository *repo, DavSession *sn) {
+int request_auth(Repository *repo, DavSession *sn, CmdArgs *a) {
+    if(cmd_getoption(a, "noinput")) {
+        return 0;
+    }
+    
     static int login = 0;
     if(login) {
         return 0;
@@ -366,7 +375,7 @@
         
         if(!ls) {
             if(sn->error == DAV_UNAUTHORIZED) {
-                if(request_auth(repo, sn)) {
+                if(request_auth(repo, sn, a)) {
                     continue;
                 }
             }
@@ -601,7 +610,7 @@
                 depth,
                 t);
         if(!res && sn->error == DAV_UNAUTHORIZED) {
-            if(request_auth(repo, sn)) {
+            if(request_auth(repo, sn, a)) {
                 continue;
             }
         }
@@ -803,7 +812,7 @@
     for(int i=0;i<2;i++) {
         res = dav_query(sn, "select - from %s", path);
         if(!res && sn->error == DAV_UNAUTHORIZED) {
-            if(request_auth(repo, sn)) {
+            if(request_auth(repo, sn, a)) {
                 continue;
             }
         }
@@ -875,7 +884,7 @@
     int err = 0;
     for(int i=0;i<2;i++) {
         err = dav_delete(res);
-        if(err && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn)) {
+        if(err && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
             continue;
         } else {
             break;
@@ -932,7 +941,7 @@
     int err = 0;
     for(int i=0;i<2;i++) {
         err = dav_create(res);
-        if(err && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn)) {
+        if(err && sn->error == DAV_UNAUTHORIZED && request_auth(repo, sn, a)) {
             continue;
         } else {
             break;

mercurial