# HG changeset patch # User Olaf Wintermann # Date 1376909442 -7200 # Node ID 78935b45e2cec4c514f0e6fb8b90cee9fa647db0 # Parent 6bb9479d9c640d1bc3f3f49b3f9ba2c7d7e42be1 fixed put bugs diff -r 6bb9479d9c64 -r 78935b45e2ce dav/Makefile --- a/dav/Makefile Sat Aug 17 14:57:17 2013 +0200 +++ b/dav/Makefile Mon Aug 19 12:50:42 2013 +0200 @@ -28,9 +28,6 @@ include ../$(CONF).mk -DAV_CFLAGS = `curl-config --cflags` `pkg-config --cflags openssl libxml-2.0` -DAV_LDFLAGS = `curl-config --libs` `pkg-config --libs openssl libxml-2.0` - SRC = main.c SRC += utils.c SRC += webdav.c diff -r 6bb9479d9c64 -r 78935b45e2ce dav/config.c --- a/dav/config.c Sat Aug 17 14:57:17 2013 +0200 +++ b/dav/config.c Mon Aug 19 12:50:42 2013 +0200 @@ -122,11 +122,23 @@ node = node->next; } - if(repo->name) { - ucx_map_cstr_put(repos, repo->name, repo); - } else { - // TODO: free + if(!repo->name) { + fprintf( + stderr, + "Cannot load config.xml: missing name for repository.\n"); + fprintf(stderr, "Abort.\n"); + exit(-1); } + if(!repo->url) { + fprintf( + stderr, + "Cannot load config.xml: " + "missing url for repository '%s'.\n", repo->name); + fprintf(stderr, "Abort.\n"); + exit(-1); + } + + ucx_map_cstr_put(repos, repo->name, repo); } void load_key(xmlNode *keynode) { diff -r 6bb9479d9c64 -r 78935b45e2ce dav/main.c --- a/dav/main.c Sat Aug 17 14:57:17 2013 +0200 +++ b/dav/main.c Mon Aug 19 12:50:42 2013 +0200 @@ -590,10 +590,20 @@ return -1; } - DavResource *res = dav_resource_new(sn, path); + DavResource *res = dav_query(sn, "get - from %s", path); if(!res) { - fprintf(stderr, "error\n"); - return -1; + if(sn->error = DAV_NOT_FOUND) { + res = dav_resource_new(sn, path); + } else { + fprintf(stderr, "error\n"); + return -1; + } + } else if(res->iscollection) { + // TODO: free res + char *newpath = util_concat_path(path, file); + free(path); + path = newpath; + res = dav_resource_new(sn, path); } AESEncrypter *enc = NULL; @@ -602,14 +612,16 @@ char *plain = cmd_getoption(a, "plain"); if(!plain && (keyname || repo)) { kn = keyname ? keyname : repo->default_key; - Key *key = get_key(kn); - if(!key) { - fprintf(stderr, "Key %s not found!\nAbort.\n", kn); - // TODO: free - return -1; - } - if(keyname || repo->encrypt) { - enc = aes_encrypter_new(key, in, (dav_read_func)fread); + if(kn) { + Key *key = get_key(kn); + if(!key) { + fprintf(stderr, "Key %s not found!\nAbort.\n", kn); + // TODO: free + return -1; + } + if(keyname || repo->encrypt) { + enc = aes_encrypter_new(key, in, (dav_read_func)fread); + } } } if(enc) { diff -r 6bb9479d9c64 -r 78935b45e2ce dav/webdav.c --- a/dav/webdav.c Sat Aug 17 14:57:17 2013 +0200 +++ b/dav/webdav.c Mon Aug 19 12:50:42 2013 +0200 @@ -47,6 +47,9 @@ } context->sessions = NULL; context->namespaces = ucx_map_new(16); + context->http_proxy = NULL; + context->https_proxy = NULL; + context->no_proxy = NULL; if(!context->namespaces) { free(context); return NULL; @@ -121,6 +124,24 @@ } sn->context = context; sn->handle = curl_easy_init(); + + // set proxy + if(sstrprefix(url, S("https"))) { + if(context->https_proxy) { + //printf("use https_proxy: %s\n", context->https_proxy); + curl_easy_setopt(sn->handle, CURLOPT_PROXY, context->https_proxy); + } + } else { + if(context->http_proxy) { + //printf("use http_proxy: %s\n", context->http_proxy); + curl_easy_setopt(sn->handle, CURLOPT_PROXY, context->http_proxy); + } + } + if(context->no_proxy) { + //printf("use no_proxy: %s\n", context->no_proxy); + curl_easy_setopt(sn->handle, CURLOPT_NOPROXY, context->no_proxy); + } + // set url curl_easy_setopt(sn->handle, CURLOPT_URL, base_url); sn->mp = ucx_mempool_new(1024); diff -r 6bb9479d9c64 -r 78935b45e2ce dav/webdav.h --- a/dav/webdav.h Sat Aug 17 14:57:17 2013 +0200 +++ b/dav/webdav.h Mon Aug 19 12:50:42 2013 +0200 @@ -99,6 +99,9 @@ struct DavContext { UcxMap *namespaces; UcxList *sessions; + char *http_proxy; + char *https_proxy; + char *no_proxy; }; struct dav_content_data {