1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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,
const char *path) {
37 print_resource_error_to_file(stderr, sn, path);
38 }
39
40 void print_resource_error_to_file(
FILE *file, DavSession *sn,
const char *path) {
41 char *res_url = util_concat_path(sn->base_url, path);
42 switch(sn->error) {
43 default: {
44 fprintf(file,
"Operation failed for resource %s.\n", res_url);
45 if(sn->errorstr) {
46 fprintf(file,
"%s\n", sn->errorstr);
47 }
48 break;
49 }
50 case DAV_NOT_FOUND: {
51 fprintf(file,
"Resource %s not found.\n", res_url);
52 break;
53 }
54 case DAV_UNAUTHORIZED: {
55 fprintf(file,
"Authentication required.\n");
56 break;
57 }
58 case DAV_PROXY_AUTH_REQUIRED: {
59 fprintf(file,
"Proxy authentication required.\n");
60 break;
61 }
62 case DAV_NET_AUTH_REQUIRED: {
63 fprintf(file,
"Network authentication required.\n");
64 break;
65 }
66 case DAV_FORBIDDEN: {
67 fprintf(file,
"Access forbidden.\n");
68 break;
69 }
70 case DAV_METHOD_NOT_ALLOWED: {
71 fprintf(file,
"Method not allowed.\n");
72 break;
73 }
74 case DAV_CONFLICT: {
75 fprintf(
76 stderr,
77 "Missing intermediate collections for resource %s.\n",
78 res_url);
79 break;
80 }
81 case DAV_LOCKED: {
82 fprintf(
83 stderr,
84 "Resource is locked.\n");
85 break;
86 }
87 case DAV_UNSUPPORTED_PROTOCOL: {
88 fprintf(file,
"Unsupported protocol.\n");
89 if(sn->errorstr) {
90 fprintf(file,
"%s\n", sn->errorstr);
91 }
92 break;
93 }
94 case DAV_COULDNT_RESOLVE_PROXY: {
95 fprintf(file,
"Cannot resolve proxy host.\n");
96 break;
97 }
98 case DAV_COULDNT_RESOLVE_HOST: {
99 fprintf(file,
"Cannot resolve host name.\n");
100 break;
101 }
102 case DAV_COULDNT_CONNECT: {
103 fprintf(file,
"Cannot connect to host.\n");
104 break;
105 }
106 case DAV_TIMEOUT: {
107 fprintf(file,
"Operation timed out.\n");
108 break;
109 }
110 case DAV_SSL_ERROR: {
111 fprintf(file,
"SSL error.\n");
112 if(sn->errorstr) {
113 fprintf(file,
"%s\n", sn->errorstr);
114 }
115 break;
116 }
117 case DAV_CONTENT_VERIFICATION_ERROR: {
118 fprintf(
119 file,
120 "Content checksum verification failed for resource %s.\n",
121 res_url);
122 break;
123 }
124 case DAV_REQUEST_ENTITY_TOO_LARGE: {
125 fprintf(file,
"Request entity too large.\n");
126 break;
127 }
128 case DAV_REQUEST_URL_TOO_LONG: {
129 fprintf(file,
"Request URL too long.\n");
130 break;
131 }
132 }
133 free(res_url);
134 }
135