dav/sync.c

changeset 73
41e88442ad4e
parent 72
aac29f2e8030
child 75
56962faf2b42
equal deleted inserted replaced
72:aac29f2e8030 73:41e88442ad4e
131 } 131 }
132 } 132 }
133 return 1; 133 return 1;
134 } 134 }
135 135
136 static DavSession* create_session(DavContext *ctx, Repository *repo, char *url) {
137 DavSession *sn = dav_session_new_auth(
138 ctx,
139 url,
140 repo->user,
141 repo->password);
142 curl_easy_setopt(sn->handle, CURLOPT_SSLVERSION, repo->ssl_version);
143 sn->flags = get_repository_flags(repo);
144 sn->key = dav_context_get_key(ctx, repo->default_key);
145 return sn;
146 }
147
136 int cmd_pull(CmdArgs *a) { 148 int cmd_pull(CmdArgs *a) {
137 if(a->argc != 1) { 149 if(a->argc != 1) {
138 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many"); 150 fprintf(stderr, "Too %s arguments\n", a->argc < 1 ? "few" : "many");
139 return -1; 151 return -1;
140 } 152 }
159 171
160 char *new_url = NULL; 172 char *new_url = NULL;
161 if(dir->collection) { 173 if(dir->collection) {
162 new_url = util_concat_path(repo->url, dir->collection); 174 new_url = util_concat_path(repo->url, dir->collection);
163 } 175 }
164 // TODO: session creator function 176 DavSession *sn = create_session(ctx, repo, new_url ? new_url : repo->url);
165 DavSession *sn = dav_session_new_auth(
166 ctx,
167 new_url ? new_url : repo->url,
168 repo->user,
169 repo->password);
170 if(new_url) { 177 if(new_url) {
171 free(new_url); 178 free(new_url);
172 } 179 }
173 sn->flags = get_repository_flags(repo);
174 sn->key = dav_context_get_key(ctx, repo->default_key);
175 if (cmd_getoption(a, "verbose")) { 180 if (cmd_getoption(a, "verbose")) {
176 curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L); 181 curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L);
177 curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr); 182 curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr);
178 } 183 }
179 184
463 468
464 char *new_url = NULL; 469 char *new_url = NULL;
465 if(dir->collection) { 470 if(dir->collection) {
466 new_url = util_concat_path(repo->url, dir->collection); 471 new_url = util_concat_path(repo->url, dir->collection);
467 } 472 }
468 // TODO: session creator function 473 DavSession *sn = create_session(ctx, repo, new_url ? new_url : repo->url);
469 DavSession *sn = dav_session_new_auth(
470 ctx,
471 new_url ? new_url : repo->url,
472 repo->user,
473 repo->password);
474 if(new_url) { 474 if(new_url) {
475 free(new_url); 475 free(new_url);
476 } 476 }
477 sn->flags = get_repository_flags(repo);
478 sn->key = dav_context_get_key(ctx, repo->default_key);
479 if (cmd_getoption(a, "verbose")) { 477 if (cmd_getoption(a, "verbose")) {
480 curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L); 478 curl_easy_setopt(sn->handle, CURLOPT_VERBOSE, 1L);
481 curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr); 479 curl_easy_setopt(sn->handle, CURLOPT_STDERR, stderr);
482 } 480 }
483 481

mercurial