dav/main.c

changeset 40
a95ee94b9204
parent 38
b855f76e965b
child 43
03076907b58a
equal deleted inserted replaced
39:3e55bed345f9 40:a95ee94b9204
37 #include <ucx/string.h> 37 #include <ucx/string.h>
38 #include <dirent.h> 38 #include <dirent.h>
39 39
40 40
41 #include <libidav/utils.h> 41 #include <libidav/utils.h>
42 #include <libidav/crypto.h>
42 #include "config.h" 43 #include "config.h"
43 #include "crypto.h"
44 #include "main.h" 44 #include "main.h"
45 45
46 static DavContext *ctx; 46 static DavContext *ctx;
47 47
48 void xmlerrorfnc(void * c, const char * msg, ... ) { 48 void xmlerrorfnc(void * c, const char * msg, ... ) {
50 } 50 }
51 51
52 int main(int argc, char **argv) { 52 int main(int argc, char **argv) {
53 xmlGenericErrorFunc fnc = xmlerrorfnc; 53 xmlGenericErrorFunc fnc = xmlerrorfnc;
54 initGenericErrorDefaultFunc(&fnc); 54 initGenericErrorDefaultFunc(&fnc);
55 load_config();
56 ctx = dav_context_new(); 55 ctx = dav_context_new();
56 load_config(ctx);
57 dav_add_namespace(ctx, "U", "http://www.uap-core.de/"); 57 dav_add_namespace(ctx, "U", "http://www.uap-core.de/");
58 58
59 memcpy(ctx->http_proxy, get_http_proxy(), sizeof(Proxy)); 59 memcpy(ctx->http_proxy, get_http_proxy(), sizeof(Proxy));
60 memcpy(ctx->https_proxy, get_https_proxy(), sizeof(Proxy)); 60 memcpy(ctx->https_proxy, get_https_proxy(), sizeof(Proxy));
61 61
249 return -1; 249 return -1;
250 } 250 }
251 251
252 char *url = a->argv[0]; 252 char *url = a->argv[0];
253 char *path = NULL; 253 char *path = NULL;
254 char *base = NULL; 254 //char *base = NULL;
255 DavSession *sn = NULL; 255 DavSession *sn = NULL;
256 Repository *repo = url2repo(url, &path); 256 Repository *repo = url2repo(url, &path);
257 base = util_concat_path(repo->url, path); 257 //base = util_concat_path(repo->url, path);
258 sn = dav_session_new_auth(ctx, base, repo->user, repo->password); 258 sn = dav_session_new_auth(ctx, repo->url, repo->user, repo->password);
259 259
260 char *update = cmd_getoption(a, "update"); 260 char *update = cmd_getoption(a, "update");
261 time_t t = 0; 261 time_t t = 0;
262 if(update) { 262 if(update) {
263 t = util_parse_lastmodified(update); 263 t = util_parse_lastmodified(update);
265 265
266 int ret = -1; 266 int ret = -1;
267 DavResource *ls; 267 DavResource *ls;
268 while(ret != 0) { 268 while(ret != 0) {
269 if(cmd_getoption(a, "recursive")) { 269 if(cmd_getoption(a, "recursive")) {
270 printf("base: %s\n", base); 270 //printf("base: %s\n", base);
271 if(update) { 271 if(update) {
272 ls = dav_query( 272 ls = dav_query(
273 sn, 273 sn,
274 "get U:crypto-key from /* where lastmodified > %t", 274 "get U:crypto-key from %s* where lastmodified > %t",
275 path,
275 t); 276 t);
276 } else { 277 } else {
277 ls = dav_query(sn, "get U:crypto-key from /*"); 278 ls = dav_query(sn, "get U:crypto-key from %s*", path);
278 } 279 }
279 } else { 280 } else {
280 if(update) { 281 if(update) {
281 ls = dav_query( 282 ls = dav_query(
282 sn, 283 sn,
283 "get U:crypto-key from / where lastmodified > %t", t); 284 "get U:crypto-key from %s where lastmodified > %t",
285 path,
286 t);
284 } else { 287 } else {
285 ls = dav_query(sn, "get U:crypto-key from /"); 288 ls = dav_query(sn, "get U:crypto-key from %s", path);
286 } 289 }
287 } 290 }
288 291
289 if(!ls) { 292 if(!ls) {
290 if(sn->error == DAV_UNAUTHORIZED) { 293 if(sn->error == DAV_UNAUTHORIZED) {
315 // leave loop 318 // leave loop
316 ret = 0; 319 ret = 0;
317 } 320 }
318 321
319 free(path); 322 free(path);
320 free(base); 323 //free(base);
321 324
322 return ret; 325 return ret;
323 } 326 }
324 327
325 static char* ls_date_str(time_t tm) { 328 static char* ls_date_str(time_t tm) {

mercurial