diff --git a/Makefile b/Makefile index 264ac31..3a05502 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ PKG_LIBS = libimobiledevice-1.0 libirecovery-1.0 libusb-1.0 \ CFLAGS += $(shell pkg-config --cflags $(PKG_LIBS) 2>/dev/null) LDFLAGS += $(shell pkg-config --libs $(PKG_LIBS) 2>/dev/null) +$(foreach lib,$(PKG_LIBS),$(if $(shell pkg-config --exists $(lib) 2>/dev/null && echo ok),,$(warning Library $(lib) not found by pkg-config))) + # Auto-discover all C sources under src/ SRCS = $(shell find src -name '*.c') OBJS = $(SRCS:.c=.o) diff --git a/include/exploit/exploit.h b/include/exploit/exploit.h index 9d86531..78f122a 100644 --- a/include/exploit/exploit.h +++ b/include/exploit/exploit.h @@ -12,8 +12,8 @@ /* Exploit phase constants */ #define EXPLOIT_PHASE_INIT 0 #define EXPLOIT_PHASE_RESET 1 -#define EXPLOIT_PHASE_SPRAY 2 -#define EXPLOIT_PHASE_SETUP 3 +#define EXPLOIT_PHASE_SETUP 2 +#define EXPLOIT_PHASE_SPRAY 3 #define EXPLOIT_PHASE_PATCH 4 #define EXPLOIT_PHASE_DONE 5 diff --git a/include/tr4mpass.h b/include/tr4mpass.h index ae81e36..d6955e6 100644 --- a/include/tr4mpass.h +++ b/include/tr4mpass.h @@ -6,7 +6,7 @@ #include #include -#define TR4MPASS_VERSION "0.1.0" +#define TR4MPASS_VERSION "0.2.0" #define TR4MPASS_OK 0 #define TR4MPASS_ERR -1 diff --git a/src/util/log.c b/src/util/log.c index 67d45b8..2c6cc2b 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -1,5 +1,6 @@ #include #include +#include #include "util/log.h" #define ANSI_RESET "\033[0m" @@ -8,7 +9,15 @@ #define ANSI_YELLOW "\033[33m" #define ANSI_RED "\033[31m" -static log_level_t g_level = LOG_INFO; +static log_level_t g_level = LOG_INFO; +static int g_use_color = -1; /* -1 = uninitialized */ + +static int should_use_color(void) +{ + if (g_use_color == -1) + g_use_color = isatty(STDERR_FILENO); + return g_use_color; +} void log_set_level(log_level_t level) { @@ -20,9 +29,15 @@ static void log_vprint(log_level_t level, const char *color, { if (level < g_level) return; - fprintf(stderr, "%s%s ", color, tag); + if (should_use_color()) + fprintf(stderr, "%s%s ", color, tag); + else + fprintf(stderr, "%s ", tag); vfprintf(stderr, fmt, ap); - fprintf(stderr, "%s\n", ANSI_RESET); + if (should_use_color()) + fprintf(stderr, "%s\n", ANSI_RESET); + else + fprintf(stderr, "\n"); } void log_debug(const char *fmt, ...)