Now you can add pass more files to clainsafecli
This commit is contained in:
parent
082d1ae23a
commit
efbcccbe03
1 changed files with 17 additions and 73 deletions
|
@ -134,27 +134,27 @@ main(int argc, char **argv)
|
||||||
/* TODO: make it iterate on args so you can upload multiple files
|
/* TODO: make it iterate on args so you can upload multiple files
|
||||||
* at once (clainsafecli file1 file2 ... filen)
|
* at once (clainsafecli file1 file2 ... filen)
|
||||||
*/
|
*/
|
||||||
|
for(int i = optind; i<argc; i++) {
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME,"file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_FILE,argv[optind],
|
CURLFORM_FILE,argv[i],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
/* Actual file content */
|
/* Actual file content */
|
||||||
curl_formadd(&post,&last,
|
curl_formadd(&post,&last,
|
||||||
CURLFORM_COPYNAME,"file",
|
CURLFORM_COPYNAME,"file",
|
||||||
CURLFORM_COPYCONTENTS,argv[optind],
|
CURLFORM_COPYCONTENTS,argv[i],
|
||||||
CURLFORM_END);
|
CURLFORM_END);
|
||||||
|
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag);
|
curl_easy_setopt(easy_handle,CURLOPT_NOPROGRESS,silent_flag);
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress);
|
curl_easy_setopt(easy_handle,CURLOPT_PROGRESSFUNCTION,progress);
|
||||||
|
|
||||||
curl_easy_setopt(easy_handle,CURLOPT_HTTPPOST,post);
|
curl_easy_setopt(easy_handle,CURLOPT_HTTPPOST,post);
|
||||||
|
|
||||||
curl_easy_perform(easy_handle);
|
curl_easy_perform(easy_handle);
|
||||||
if(!silent_flag) puts("");
|
if(!silent_flag) puts("");
|
||||||
|
|
||||||
puts(buffer);
|
|
||||||
|
|
||||||
|
puts(buffer);
|
||||||
|
}
|
||||||
curl_formfree(post);
|
curl_formfree(post);
|
||||||
curl_easy_cleanup(easy_handle);
|
curl_easy_cleanup(easy_handle);
|
||||||
|
|
||||||
|
@ -168,59 +168,3 @@ main(int argc, char **argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
|
||||||
write_data(void *buffer, size_t size, size_t nmemb,
|
|
||||||
void *userp)
|
|
||||||
{
|
|
||||||
memcpy(userp, buffer, nmemb*size);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
print_usage()
|
|
||||||
{
|
|
||||||
printf("USAGE: clainsafecli [--tor|--i2p] [-6|-4] [--server] file\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
store_link(const char *path, const char *buf)
|
|
||||||
{
|
|
||||||
FILE *fp = fopen(path,"a+");
|
|
||||||
if(fp == NULL) {
|
|
||||||
fprintf(stderr,"Error opening file %i: %s\n",errno,
|
|
||||||
strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
fwrite(buf,strlen(buf),1,fp);
|
|
||||||
fputc('\n',fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
print_help()
|
|
||||||
{
|
|
||||||
printf("--server <server>: specifies the lainsafe server\n%s\n%s\n%s\n%s\n%s\%s",
|
|
||||||
"--tor: uses tor.",
|
|
||||||
"--i2p: uses i2p.",
|
|
||||||
"-6|--ipv6: uses IPv6 only.",
|
|
||||||
"-4|--ipv6: uses IPv4 only.",
|
|
||||||
"--silent: doesn't print progress.",
|
|
||||||
"--help: print this message.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
progress(void *clientp,
|
|
||||||
double dltotal,
|
|
||||||
double dlnow,
|
|
||||||
double ultotal,
|
|
||||||
double ulnow)
|
|
||||||
{
|
|
||||||
/* So I don't get a warning */
|
|
||||||
dltotal += 1;
|
|
||||||
dlnow += 1;
|
|
||||||
printf("\r%0.f uploaded of %0.f (%0.f%%)",ulnow,ultotal,
|
|
||||||
ulnow*100/ultotal);
|
|
||||||
fflush(stdout);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue