This commit is contained in:
qorg11 2021-03-27 16:48:38 +01:00
parent efbcccbe03
commit 89ad06ce23
No known key found for this signature in database
GPG Key ID: 343FC20A4ACA62B9
2 changed files with 65 additions and 3 deletions

View File

@ -1,13 +1,13 @@
# clainsafecli makefile
TARGET = clainsafecli
OBJS = clainsafecli.o
OBJS = clainsafecli.o funcs.o
CC = cc
CFLAGSDEF = -MD -std=c11 -Wall -Wextra -O2 -march=native -lcurl
CFLAGSDEF = -MD -std=c11 -Wall -Wextra -lcurl
CFLAGS = -O2 -march=native
$(TARGET): clainsafecli.o
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(CFLAGSDEF) $(OBJS) -o $(TARGET)
%.o: %.c

62
clainsafecli/funcs.c Normal file
View File

@ -0,0 +1,62 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "clainsafecli.h"
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\n%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);
}