40 |
40 |
41 #include <libidav/utils.h> |
41 #include <libidav/utils.h> |
42 #include <libidav/crypto.h> |
42 #include <libidav/crypto.h> |
43 #include <libidav/session.h> |
43 #include <libidav/session.h> |
44 #include "config.h" |
44 #include "config.h" |
|
45 #include "error.h" |
45 #include "main.h" |
46 #include "main.h" |
46 |
47 |
47 static DavContext *ctx; |
48 static DavContext *ctx; |
48 |
49 |
49 static int printxmlerror = 1; |
50 static int printxmlerror = 1; |
264 } |
265 } |
265 |
266 |
266 return repo; |
267 return repo; |
267 } |
268 } |
268 |
269 |
269 void print_resource_error(DavSession *sn, char *path) { |
|
270 char *res_url = util_concat_path(sn->base_url, path); |
|
271 switch(sn->error) { |
|
272 default: { |
|
273 fprintf(stderr, "Operation failed for resource %s.\n", res_url); |
|
274 if(sn->errorstr) { |
|
275 fprintf(stderr, "%s\n", sn->errorstr); |
|
276 } |
|
277 break; |
|
278 } |
|
279 case DAV_NOT_FOUND: { |
|
280 fprintf(stderr, "Resource %s not found.\n", res_url); |
|
281 break; |
|
282 } |
|
283 case DAV_UNAUTHORIZED: { |
|
284 fprintf(stderr, "Authentication required.\n"); |
|
285 break; |
|
286 } |
|
287 case DAV_FORBIDDEN: { |
|
288 fprintf(stderr, "Access forbidden.\n"); |
|
289 break; |
|
290 } |
|
291 case DAV_METHOD_NOT_ALLOWED: { |
|
292 fprintf(stderr, "Method not allowed.\n"); |
|
293 } |
|
294 case DAV_CONFLICT: { |
|
295 fprintf( |
|
296 stderr, |
|
297 "Missing intermediate collections for resource %s.\n", |
|
298 res_url); |
|
299 } |
|
300 case DAV_UNSUPPORTED_PROTOCOL: { |
|
301 fprintf(stderr, "Unsupported protocol.\n"); |
|
302 if(sn->errorstr) { |
|
303 fprintf(stderr, "%s\n", sn->errorstr); |
|
304 } |
|
305 break; |
|
306 } |
|
307 case DAV_COULDNT_RESOLVE_PROXY: { |
|
308 fprintf(stderr, "Cannot resolve proxy host.\n"); |
|
309 break; |
|
310 } |
|
311 case DAV_COULDNT_RESOLVE_HOST: { |
|
312 fprintf(stderr, "Cannot resolve host name.\n"); |
|
313 break; |
|
314 } |
|
315 case DAV_COULDNT_CONNECT: { |
|
316 fprintf(stderr, "Cannot connect to host.\n"); |
|
317 break; |
|
318 } |
|
319 case DAV_TIMEOUT: { |
|
320 fprintf(stderr, "Operation timed out.\n"); |
|
321 break; |
|
322 } |
|
323 case DAV_SSL_ERROR: { |
|
324 fprintf(stderr, "SSL error.\n"); |
|
325 if(sn->errorstr) { |
|
326 fprintf(stderr, "%s\n", sn->errorstr); |
|
327 } |
|
328 } |
|
329 } |
|
330 free(res_url); |
|
331 } |
|
332 |
|
333 int set_session_config(DavSession *sn, CmdArgs *a) { |
270 int set_session_config(DavSession *sn, CmdArgs *a) { |
334 char *plain = cmd_getoption(a, "plain"); |
271 char *plain = cmd_getoption(a, "plain"); |
335 char *crypt = cmd_getoption(a, "crypt"); |
272 char *crypt = cmd_getoption(a, "crypt"); |
336 |
273 |
337 if(plain && crypt) { |
274 if(plain && crypt) { |