130 stderr, |
130 stderr, |
131 " get-property [-pc] [-n <uri>] <url> <property>\n"); |
131 " get-property [-pc] [-n <uri>] <url> <property>\n"); |
132 fprintf( |
132 fprintf( |
133 stderr, |
133 stderr, |
134 " set-property [-pc] [-n <uri>] <url> <property> [value]\n"); |
134 " set-property [-pc] [-n <uri>] <url> <property> [value]\n"); |
|
135 fprintf(stderr, " info [-pc] <url>\n"); |
135 fprintf(stderr, " date [url]\n"); |
136 fprintf(stderr, " date [url]\n"); |
136 fprintf(stderr, "\n"); |
137 fprintf(stderr, "\n"); |
137 fprintf(stderr, "Options:\n"); |
138 fprintf(stderr, "Options:\n"); |
138 fprintf(stderr, |
139 fprintf(stderr, |
139 " -k <key> Key to use for encryption or decryption\n"); |
140 " -k <key> Key to use for encryption\n"); |
140 fprintf(stderr, " -p Don't encrypt or decrypt files\n"); |
141 fprintf(stderr, " -p Don't encrypt or decrypt files\n"); |
141 fprintf(stderr, " -c Enable full encryption\n"); |
142 fprintf(stderr, " -c Enable full encryption\n"); |
142 fprintf(stderr, |
143 fprintf(stderr, |
143 " -R " |
144 " -R " |
144 "Recursively do the operation for all children\n"); |
145 "Recursively do the operation for all children\n"); |
231 repo->name = strdup(""); |
232 repo->name = strdup(""); |
232 repo->decrypt_content = true; |
233 repo->decrypt_content = true; |
233 if(url[ulen-1] == '/') { |
234 if(url[ulen-1] == '/') { |
234 repo->url = strdup(url); |
235 repo->url = strdup(url); |
235 *path = strdup("/"); |
236 *path = strdup("/"); |
236 } else { |
237 } else if (strchr(url, '/')) { |
237 repo->url = util_parent_path(url); |
238 repo->url = util_parent_path(url); |
238 // TODO: check/fix |
239 // TODO: check/fix |
239 *path = strdup(util_resource_name(url)-1); |
240 *path = strdup(util_resource_name(url)-1); |
|
241 } else { |
|
242 repo->url = strdup(url); |
|
243 *path = strdup("/"); |
240 } |
244 } |
241 } |
245 } |
242 |
246 |
243 return repo; |
247 return repo; |
244 } |
248 } |
246 void print_resource_error(DavSession *sn, char *path) { |
250 void print_resource_error(DavSession *sn, char *path) { |
247 char *res_url = util_concat_path(sn->base_url, path); |
251 char *res_url = util_concat_path(sn->base_url, path); |
248 switch(sn->error) { |
252 switch(sn->error) { |
249 default: { |
253 default: { |
250 fprintf(stderr, "Operation failed for resource %s.\n", res_url); |
254 fprintf(stderr, "Operation failed for resource %s.\n", res_url); |
|
255 if(sn->errorstr) { |
|
256 fprintf(stderr, "%s\n", sn->errorstr); |
|
257 } |
251 break; |
258 break; |
252 } |
259 } |
253 case DAV_NOT_FOUND: { |
260 case DAV_NOT_FOUND: { |
254 fprintf(stderr, "Resource %s not found.\n", res_url); |
261 fprintf(stderr, "Resource %s not found.\n", res_url); |
255 break; |
262 break; |
268 case DAV_CONFLICT: { |
275 case DAV_CONFLICT: { |
269 fprintf( |
276 fprintf( |
270 stderr, |
277 stderr, |
271 "Missing intermediate collections for resource %s.\n", |
278 "Missing intermediate collections for resource %s.\n", |
272 res_url); |
279 res_url); |
|
280 } |
|
281 case DAV_UNSUPPORTED_PROTOCOL: { |
|
282 fprintf(stderr, "Unsupported protocol.\n"); |
|
283 if(sn->errorstr) { |
|
284 fprintf(stderr, "%s\n", sn->errorstr); |
|
285 } |
|
286 break; |
|
287 } |
|
288 case DAV_COULDNT_RESOLVE_PROXY: { |
|
289 fprintf(stderr, "Cannot resolve proxy host.\n"); |
|
290 break; |
|
291 } |
|
292 case DAV_COULDNT_RESOLVE_HOST: { |
|
293 fprintf(stderr, "Cannot resolve host name.\n"); |
|
294 break; |
|
295 } |
|
296 case DAV_COULDNT_CONNECT: { |
|
297 fprintf(stderr, "Cannot connect to host.\n"); |
|
298 break; |
|
299 } |
|
300 case DAV_TIMEOUT: { |
|
301 fprintf(stderr, "Operation timed out.\n"); |
|
302 break; |
|
303 } |
|
304 case DAV_SSL_ERROR: { |
|
305 fprintf(stderr, "SSL error.\n"); |
|
306 if(sn->errorstr) { |
|
307 fprintf(stderr, "%s\n", sn->errorstr); |
|
308 } |
273 } |
309 } |
274 } |
310 } |
275 free(res_url); |
311 free(res_url); |
276 } |
312 } |
277 |
313 |