67 |
67 |
68 int main(int argc, char **argv) { |
68 int main(int argc, char **argv) { |
69 xmlGenericErrorFunc fnc = xmlerrorfnc; |
69 xmlGenericErrorFunc fnc = xmlerrorfnc; |
70 initGenericErrorDefaultFunc(&fnc); |
70 initGenericErrorDefaultFunc(&fnc); |
71 ctx = dav_context_new(); |
71 ctx = dav_context_new(); |
72 ctx->key_input = util_key_input; |
|
73 load_config(ctx); |
72 load_config(ctx); |
74 printxmlerror = 0; |
73 printxmlerror = 0; |
75 #ifdef DO_THE_TEST |
74 #ifdef DO_THE_TEST |
76 test(); |
75 test(); |
77 return 0; |
76 return 0; |
90 CmdArgs *args = cmd_parse_args(argc - 2, argv + 2); |
89 CmdArgs *args = cmd_parse_args(argc - 2, argv + 2); |
91 if(!args) { |
90 if(!args) { |
92 print_usage(argv[0]); |
91 print_usage(argv[0]); |
93 cmd_args_free(args); |
92 cmd_args_free(args); |
94 return -1; |
93 return -1; |
|
94 } |
|
95 |
|
96 if(cmd_getoption(args, "noinput")) { |
|
97 ctx->key_input = NULL; |
|
98 } else { |
|
99 ctx->key_input = util_key_input; |
95 } |
100 } |
96 |
101 |
97 int ret = -1; |
102 int ret = -1; |
98 if(!strcasecmp(cmd, "list") || !strcasecmp(cmd, "ls")) { |
103 if(!strcasecmp(cmd, "list") || !strcasecmp(cmd, "ls")) { |
99 ret = cmd_list(args); |
104 ret = cmd_list(args); |
202 "with an optional path:\n"); |
207 "with an optional path:\n"); |
203 fprintf(stderr, " <repository>/path/\n"); |
208 fprintf(stderr, " <repository>/path/\n"); |
204 fprintf(stderr, "\n"); |
209 fprintf(stderr, "\n"); |
205 } |
210 } |
206 |
211 |
207 int request_auth(Repository *repo, DavSession *sn) { |
212 int request_auth(Repository *repo, DavSession *sn, CmdArgs *a) { |
|
213 if(cmd_getoption(a, "noinput")) { |
|
214 return 0; |
|
215 } |
|
216 |
208 static int login = 0; |
217 static int login = 0; |
209 if(login) { |
218 if(login) { |
210 return 0; |
219 return 0; |
211 } |
220 } |
212 |
221 |
801 int put_file(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *name, FILE *in, off_t len) { |
810 int put_file(Repository *repo, CmdArgs *a, DavSession *sn, char *path, char *name, FILE *in, off_t len) { |
802 DavResource *res = NULL; |
811 DavResource *res = NULL; |
803 for(int i=0;i<2;i++) { |
812 for(int i=0;i<2;i++) { |
804 res = dav_query(sn, "select - from %s", path); |
813 res = dav_query(sn, "select - from %s", path); |
805 if(!res && sn->error == DAV_UNAUTHORIZED) { |
814 if(!res && sn->error == DAV_UNAUTHORIZED) { |
806 if(request_auth(repo, sn)) { |
815 if(request_auth(repo, sn, a)) { |
807 continue; |
816 continue; |
808 } |
817 } |
809 } |
818 } |
810 break; |
819 break; |
811 } |
820 } |