static csync_vio_file_stat_t *owncloud_readdir(csync_vio_method_handle_t *dhandle) { struct listdir_context *fetchCtx = dhandle; if( fetchCtx == NULL) { /* DEBUG_WEBDAV("An empty dir or at end"); */ return NULL; } while( fetchCtx->currResource ) { resource* currResource = fetchCtx->currResource; char *escaped_path = NULL; /* set pointer to next element */ fetchCtx->currResource = fetchCtx->currResource->next; /* It seems strange: first uri->path is unescaped to escape it in the next step again. * The reason is that uri->path is not completely escaped (ie. it seems only to have * spaces escaped), while the fetchCtx->target is fully escaped. * See http://bugs.owncloud.org/thebuggenie/owncloud/issues/oc-613 */ escaped_path = ne_path_escape( currResource->uri ); if (ne_path_compare(fetchCtx->target, escaped_path) != 0) { csync_vio_file_stat_t* lfs = resourceToFileStat(currResource); fill_stat_cache(lfs); SAFE_FREE( escaped_path ); return lfs; } /* This is the target URI */ SAFE_FREE( escaped_path ); } return NULL; }
/* cleanPath to return an escaped path of an uri */ static char *_cleanPath( const char* uri ) { int rc = 0; char *path; char *re = NULL; rc = c_parse_uri( uri, NULL, NULL, NULL, NULL, NULL, &path ); if( rc < 0 ) { DEBUG_WEBDAV(("Unable to cleanPath %s\n", uri ? uri: "" )); re = NULL; } else { re = ne_path_escape( path ); } SAFE_FREE( path ); return re; }
/* cleanPath to return an escaped path of an uri */ char *_cleanPath( const char* uri ) { int rc = 0; char *path = NULL; char *re = NULL; rc = c_parse_uri( uri, NULL, NULL, NULL, NULL, NULL, &path ); if( rc < 0 ) { DEBUG_WEBDAV("Unable to cleanPath %s", uri ? uri: "<zero>" ); re = NULL; } else { if(path) { re = ne_path_escape( path ); } } SAFE_FREE( path ); return re; }
int init(void) { ne_uri u = {0}, proxy = {0}; int optc, n; char *proxy_url = NULL; char str[64], *src; int i; if ((times1=malloc(sizeof(float)*pget_option.requests)) == NULL){ perror("malloc(times1) :"); exit(-1); } if ((times2=malloc(sizeof(float)*pget_option.requests)) == NULL){ perror("malloc(times2) :"); exit(-1); } while ((optc = getopt_long(test_argc, test_argv, "d:hp", longopts, NULL)) != -1) { switch (optc) { case 'd': htdocs_root = optarg; break; case 'p': proxy_url = optarg; break; default: exit(1); } } n = test_argc - optind; if (n == 0 || n > 3 || n == 2) { exit(1); } if (htdocs_root == NULL) htdocs_root = "htdocs"; if (ne_uri_parse(test_argv[optind], &u)) { t_context("couldn't parse server URL `%s'", test_argv[optind]); return FAILHARD; } if (proxy_url) { if (ne_uri_parse(proxy_url, &proxy)) { t_context("couldn't parse proxy URL `%s'", proxy_url); return FAILHARD; } if (proxy.scheme && strcmp(proxy.scheme, "http") != 0) { t_context("cannot use scheme `%s' for proxy", proxy.scheme); return FAILHARD; } if (proxy.port > 0) { proxy_port = proxy.port; } else { proxy_port = 8080; } proxy_hostname = proxy.host; } if (u.scheme && strcmp(u.scheme, "https") == 0) use_secure = 1; i_hostname = u.host; if (u.port > 0) { i_port = u.port; } else { if (use_secure) { i_port = 443; } else { i_port = 80; } } if (ne_path_has_trailing_slash(u.path)) { i_path = u.path; } else { i_path = ne_concat(u.path, "/", NULL); } i_path = ne_path_escape(i_path); if (n > 2) { i_username = test_argv[optind+1]; i_password = test_argv[optind+2]; if (strlen(i_username) >= NE_ABUFSIZ) { t_context("username must be <%d chars", NE_ABUFSIZ); return FAILHARD; } if (strlen(i_password) >= NE_ABUFSIZ) { t_context("password must be <%d chars", NE_ABUFSIZ); return FAILHARD; } } if (proxy_hostname) CALL(test_resolve(proxy_hostname, "proxy server")); else CALL(test_resolve(i_hostname, "server")); CALL(open_foo()); CALL(test_connect()); printf("Done\n"); return OK; }