Made the thing better for BSD systems
This commit is contained in:
parent
491e309c9d
commit
dbb3038f8f
3 changed files with 21 additions and 84 deletions
|
@ -1,51 +0,0 @@
|
|||
.\"Manpage for lainsafe
|
||||
.TH sakisafecli 1
|
||||
.SH NAME
|
||||
sakisafecli \- File uploader
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
sakisafecli is a file uploader. Intended for lainsafe, but also works
|
||||
for 0x0.st, i.kalli.st and probably others.
|
||||
|
||||
.SH INSTALLATION
|
||||
.in +4n
|
||||
.EX
|
||||
make
|
||||
(or gcc sakisafecli.c -lcurl -o sakisafecli)
|
||||
cp sakisafecli ~/.local/bin
|
||||
.EE
|
||||
.SH OPTIONS
|
||||
|
||||
.PP
|
||||
.B
|
||||
--server=<SERVER>
|
||||
Specifies which server to use, can be a lainsafe instance, 0x0.st
|
||||
instance or i.kalli.st. Probably other similar software.
|
||||
|
||||
.B
|
||||
--tor
|
||||
Routes all the traffic on the socks proxy at 127.0.0.1:9050,
|
||||
which is usually tor. This can be edited in the
|
||||
.B options.h
|
||||
file
|
||||
|
||||
.B
|
||||
--i2p
|
||||
Routes all the traffic on the http proxy at 127.0.0.1:4444,
|
||||
which is usually I2P. This can be edited in the
|
||||
.B options.h
|
||||
file
|
||||
|
||||
.B
|
||||
--ipv6 or -6
|
||||
Forces curl to use IPv6 only.
|
||||
|
||||
.B
|
||||
--ipv4 or -4
|
||||
Forces curl to use IPv4 only.
|
||||
|
||||
.B
|
||||
--silent or -S
|
||||
tells sakisafecli to be silent. This means, it won't
|
||||
print the progress.
|
|
@ -1,24 +1,7 @@
|
|||
# sakisafecli makefile
|
||||
|
||||
TARGET = sakisafecli
|
||||
OBJS = sakisafecli.o funcs.o
|
||||
CC = cc
|
||||
CFLAGSDEF += -MD -std=c11 -Wall -Wextra -lcurl -lconfig
|
||||
CFLAGS += -O2 -ggdb
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(CFLAGSDEF) $(OBJS) -o $(TARGET)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $(CFLAGSDEF) $< -o $@
|
||||
|
||||
-include *.d
|
||||
|
||||
install: all
|
||||
@cp sakisafecli /usr/local/bin/
|
||||
|
||||
.PHONY: clean install
|
||||
clean:
|
||||
rm -f *.d *.o sakisafecli
|
||||
PROG = sakisafecli
|
||||
SRCS += funcs.c sakisafecli.c
|
||||
MAN = sakisafecli.1
|
||||
LDADD = -lssl -lz -lpthread -lnghttp2 -lcurl -lconfig -lcrypto -L/usr/local/lib
|
||||
CPPFLAGS = -I/usr/local/include
|
||||
BINDIR=/usr/local/bin
|
||||
.include <bsd.prog.mk>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <curl/curl.h>
|
||||
|
@ -22,6 +22,13 @@ config_t runtime_config;
|
|||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
#ifdef __OpenBSD__
|
||||
if(pledge("stdio rpath cpath inet dns unveil tmppath","") == -1) {
|
||||
err(1,"pledge");
|
||||
_exit(-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
struct curl_httppost *post = NULL;
|
||||
struct curl_httppost *last = NULL;
|
||||
|
||||
|
@ -36,7 +43,7 @@ main(int argc, char **argv)
|
|||
}
|
||||
char config_location[512];
|
||||
char *sakisafeclirc_env = getenv("SAKISAFECLIRC");
|
||||
|
||||
|
||||
if(sakisafeclirc_env == NULL) {
|
||||
snprintf(config_location, 512, "%s/.sakisafeclirc", getenv("HOME"));
|
||||
FILE *fp = fopen(config_location, "r");
|
||||
|
@ -45,7 +52,11 @@ main(int argc, char **argv)
|
|||
fclose(fp);
|
||||
}
|
||||
} else {
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
strlcpy(config_location, sakisafeclirc_env, 512);
|
||||
#else /* Linux sucks! */
|
||||
strncpy(config_location, sakisafeclirc_env, 512);
|
||||
#endif
|
||||
FILE *fp = fopen(config_location, "r");
|
||||
if(fp != NULL) {
|
||||
parse_config_file(fp);
|
||||
|
@ -201,17 +212,11 @@ main(int argc, char **argv)
|
|||
if(!silent_flag)
|
||||
putchar('\n');
|
||||
|
||||
printf("%s", buffer);
|
||||
puts(buffer);
|
||||
}
|
||||
curl_formfree(post);
|
||||
curl_easy_cleanup(easy_handle);
|
||||
|
||||
/* Store link if needed */
|
||||
|
||||
if(enable_links_history) {
|
||||
snprintf(history_file_path, 256, "%s/%s", getenv("HOME"), path);
|
||||
store_link(history_file_path, buffer);
|
||||
}
|
||||
free(buffer);
|
||||
config_destroy(&runtime_config);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue