|
1 /* |
|
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
|
3 * |
|
4 * Copyright 2016 Olaf Wintermann. All rights reserved. |
|
5 * |
|
6 * Redistribution and use in source and binary forms, with or without |
|
7 * modification, are permitted provided that the following conditions are met: |
|
8 * |
|
9 * 1. Redistributions of source code must retain the above copyright |
|
10 * notice, this list of conditions and the following disclaimer. |
|
11 * |
|
12 * 2. Redistributions in binary form must reproduce the above copyright |
|
13 * notice, this list of conditions and the following disclaimer in the |
|
14 * documentation and/or other materials provided with the distribution. |
|
15 * |
|
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
26 * POSSIBILITY OF SUCH DAMAGE. |
|
27 */ |
|
28 |
|
29 #include <stdio.h> |
|
30 #include <stdlib.h> |
|
31 |
|
32 #include "../libidav/utils.h" |
|
33 |
|
34 #include "error.h" |
|
35 |
|
36 void print_resource_error(DavSession *sn, char *path) { |
|
37 char *res_url = util_concat_path(sn->base_url, path); |
|
38 switch(sn->error) { |
|
39 default: { |
|
40 fprintf(stderr, "Operation failed for resource %s.\n", res_url); |
|
41 if(sn->errorstr) { |
|
42 fprintf(stderr, "%s\n", sn->errorstr); |
|
43 } |
|
44 break; |
|
45 } |
|
46 case DAV_NOT_FOUND: { |
|
47 fprintf(stderr, "Resource %s not found.\n", res_url); |
|
48 break; |
|
49 } |
|
50 case DAV_UNAUTHORIZED: { |
|
51 fprintf(stderr, "Authentication required.\n"); |
|
52 break; |
|
53 } |
|
54 case DAV_FORBIDDEN: { |
|
55 fprintf(stderr, "Access forbidden.\n"); |
|
56 break; |
|
57 } |
|
58 case DAV_METHOD_NOT_ALLOWED: { |
|
59 fprintf(stderr, "Method not allowed.\n"); |
|
60 } |
|
61 case DAV_CONFLICT: { |
|
62 fprintf( |
|
63 stderr, |
|
64 "Missing intermediate collections for resource %s.\n", |
|
65 res_url); |
|
66 } |
|
67 case DAV_UNSUPPORTED_PROTOCOL: { |
|
68 fprintf(stderr, "Unsupported protocol.\n"); |
|
69 if(sn->errorstr) { |
|
70 fprintf(stderr, "%s\n", sn->errorstr); |
|
71 } |
|
72 break; |
|
73 } |
|
74 case DAV_COULDNT_RESOLVE_PROXY: { |
|
75 fprintf(stderr, "Cannot resolve proxy host.\n"); |
|
76 break; |
|
77 } |
|
78 case DAV_COULDNT_RESOLVE_HOST: { |
|
79 fprintf(stderr, "Cannot resolve host name.\n"); |
|
80 break; |
|
81 } |
|
82 case DAV_COULDNT_CONNECT: { |
|
83 fprintf(stderr, "Cannot connect to host.\n"); |
|
84 break; |
|
85 } |
|
86 case DAV_TIMEOUT: { |
|
87 fprintf(stderr, "Operation timed out.\n"); |
|
88 break; |
|
89 } |
|
90 case DAV_SSL_ERROR: { |
|
91 fprintf(stderr, "SSL error.\n"); |
|
92 if(sn->errorstr) { |
|
93 fprintf(stderr, "%s\n", sn->errorstr); |
|
94 } |
|
95 } |
|
96 } |
|
97 free(res_url); |
|
98 } |