diff --git a/Makefile b/Makefile index b8b672d..c206e65 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,40 @@ CC = gcc CFLAGS = -Wall -Wextra -std=c99 -Isrc -Isrc/miniz -Isrc/microtar +CFLAGS_MINIZ = -Wall -Wextra -std=c99 -D_POSIX_C_SOURCE=200112L -Isrc -Isrc/miniz -Isrc/microtar -Wno-unused-function -Wno-implicit-function-declaration LIBS = -lm LIBS_STATIC = -static -lm ARCH = $(shell uname -m) TARGET = build/otp-$(ARCH) -SOURCES = $(wildcard src/*.c) $(wildcard src/miniz/*.c) $(wildcard src/microtar/*.c) +SOURCES = $(wildcard src/*.c) +MINIZ_SOURCES = $(wildcard src/miniz/*.c) +MICROTAR_SOURCES = $(wildcard src/microtar/*.c) OBJS = $(SOURCES:.c=.o) +MINIZ_OBJS = $(MINIZ_SOURCES:.c=.o) +MICROTAR_OBJS = $(MICROTAR_SOURCES:.c=.o) +ALL_OBJS = $(OBJS) $(MINIZ_OBJS) $(MICROTAR_OBJS) # Default build target -$(TARGET): $(OBJS) +$(TARGET): $(ALL_OBJS) @mkdir -p build - $(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS) - @rm -f $(OBJS) + $(CC) $(CFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS) + @rm -f $(ALL_OBJS) # Static linking target -static: $(OBJS) +static: $(ALL_OBJS) @mkdir -p build - $(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS_STATIC) - @rm -f $(OBJS) + $(CC) $(CFLAGS) -o $(TARGET) $(ALL_OBJS) $(LIBS_STATIC) + @rm -f $(ALL_OBJS) -%.o: %.c +# Compile main source files with full warnings +src/%.o: src/%.c + $(CC) $(CFLAGS) -c $< -o $@ + +# Compile miniz library files with reduced warnings +src/miniz/%.o: src/miniz/%.c + $(CC) $(CFLAGS_MINIZ) -c $< -o $@ + +# Compile microtar library files normally +src/microtar/%.o: src/microtar/%.c $(CC) $(CFLAGS) -c $< -o $@ clean: diff --git a/README.md b/README.md index 619c994..3e3f8cb 100644 --- a/README.md +++ b/README.md @@ -58,14 +58,14 @@ One-time pads can be trivially encrypted and decrypted using pencil and paper, m ### Download Pre-Built Binaries -**[Download Current Linux x86](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.39/otp-v0.3.39-linux-x86_64)** +**[Download Current Linux x86](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.40/otp-v0.3.40-linux-x86_64)** -**[Download Current Raspberry Pi 64](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.39/otp-v0.3.39-linux-arm64)** +**[Download Current Raspberry Pi 64](https://git.laantungir.net/laantungir/otp/releases/download/v0.3.40/otp-v0.3.40-linux-arm64)** After downloading: ```bash # Rename for convenience, then make executable -mv otp-v0.3.39-linux-x86_64 otp +mv otp-v0.3.40-linux-x86_64 otp chmod +x otp # Run it diff --git a/src/main.h b/src/main.h index 0fcce78..1fa3586 100644 --- a/src/main.h +++ b/src/main.h @@ -23,7 +23,7 @@ #include // Version - Updated automatically by build.sh -#define OTP_VERSION "v0.3.39" +#define OTP_VERSION "v0.3.40" // Constants #define MAX_INPUT_SIZE 4096 diff --git a/src/pads.c b/src/pads.c index 1ef9023..141419d 100644 --- a/src/pads.c +++ b/src/pads.c @@ -470,6 +470,13 @@ char* select_pad_interactive(const char* title, const char* prompt, pad_filter_t return NULL; } + // If only one pad available, auto-select it + if (pad_count == 1) { + printf("\n%s\n", title); + printf("Only one pad available - auto-selecting: %.16s...\n\n", pads[0].chksum); + return strdup(pads[0].chksum); + } + // Calculate minimal unique prefixes for each pad char prefixes[100][65]; int prefix_lengths[100];