Skip to content

Commit

Permalink
fix: cli missing macro define
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Dec 25, 2023
1 parent 7c23c9d commit de2f9f4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ add_executable(ua2f
target_link_libraries(ua2f mnl netfilter_queue pthread nfnetlink)

if (UA2F_ENABLE_UCI)
add_compile_definitions(UA2F_USE_UCI=1)
add_compile_definitions(UA2F_ENABLE_UCI=1)
target_link_libraries(ua2f uci)
else ()
message(STATUS "UCI support is disabled.")
Expand Down
5 changes: 5 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@ void try_print_info(const int argc, char *argv[]) {
#else
printf("Embed UA: not set\n");
#endif

#ifdef UA2F_ENABLE_UCI
if (config.use_custom_ua) {
printf("Config UA: %s\n", config.custom_ua);
} else {
printf("Config UA: not set\n");
}
#else
printf("UCI support disabled\n");
#endif
exit(0);
}

Expand Down
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#include <uci.h>
#include <string.h>
#include <syslog.h>
Expand Down Expand Up @@ -40,4 +40,4 @@ void load_config() {
cleanup:
uci_free_context(ctx);
}
#endif //UA2F_USE_UCI
#endif
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#ifndef UA2F_CONFIG_H
#define UA2F_CONFIG_H

Expand All @@ -14,4 +14,4 @@ void load_config();
extern struct ua2f_config config;

#endif //UA2F_CONFIG_H
#endif //UA2F_USE_UCI
#endif
6 changes: 2 additions & 4 deletions src/handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include "statistics.h"
#include "custom.h"

#ifdef UA2F_USE_UCI

#ifdef UA2F_ENABLE_UCI
#include "config.h"

#endif

#include <libnetfilter_queue/pktbuff.h>
Expand All @@ -34,7 +32,7 @@ void init_handler() {

bool ua_set = false;

#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
if (config.use_custom_ua) {
memset(replacement_user_agent_string, ' ', MAX_USER_AGENT_LENGTH);
strncpy(replacement_user_agent_string, config.custom_ua, strlen(config.custom_ua));
Expand Down
6 changes: 3 additions & 3 deletions src/ua2f.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "cli.h"
#include "third/nfqueue-mnl.h"

#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
#include "config.h"
#endif

Expand All @@ -26,11 +26,11 @@ void signal_handler(const int signum) {
int main(const int argc, char *argv[]) {
openlog("UA2F", LOG_PID, LOG_SYSLOG);

#ifdef UA2F_USE_UCI
#ifdef UA2F_ENABLE_UCI
load_config();
#else
syslog(LOG_INFO, "uci support is disabled");
#endif //UA2F_USE_UCI
#endif

try_print_info(argc, argv);

Expand Down

0 comments on commit de2f9f4

Please sign in to comment.