diff --git a/TODO b/TODO index 5e3705d..00e88ef 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ * Global - Makefiles: - ° Use -D DEBUG instead of #defines. ° Translate comments & help. - Use string for network exchanges? - Mark arguments as const in function headers if needed diff --git a/libowlps-client/Makefile b/libowlps-client/Makefile index f7709b3..033d797 100644 --- a/libowlps-client/Makefile +++ b/libowlps-client/Makefile @@ -23,6 +23,7 @@ OBJS=$(LIB_CIBLE).o # Flags LIBOWLPS_DIR = ../libowlps CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I$(LIBOWLPS_DIR) +CFLAGS += -D DEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps-client/Makefile_atheros b/libowlps-client/Makefile_atheros index 7458d4a..0398f6d 100644 --- a/libowlps-client/Makefile_atheros +++ b/libowlps-client/Makefile_atheros @@ -26,6 +26,7 @@ OBJS=$(LIB_CIBLE).o # Flags LIBOWLPS_DIR = ../libowlps CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I$(LIBOWLPS_DIR) +CFLAGS += -D DEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps-client/Makefile_atheros_openwrt-10.03 b/libowlps-client/Makefile_atheros_openwrt-10.03 index 114024d..e171c83 100644 --- a/libowlps-client/Makefile_atheros_openwrt-10.03 +++ b/libowlps-client/Makefile_atheros_openwrt-10.03 @@ -26,6 +26,7 @@ OBJS=$(LIB_CIBLE).o # Flags LIBOWLPS_DIR = ../libowlps CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O -I$(LIBOWLPS_DIR) +CFLAGS += -D DEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps-client/libowlps-client.c b/libowlps-client/libowlps-client.c index b9e9e53..29a4c07 100644 --- a/libowlps-client/libowlps-client.c +++ b/libowlps-client/libowlps-client.c @@ -7,8 +7,6 @@ #include -#define DEBUG - /* diff --git a/libowlps/Makefile b/libowlps/Makefile index cafbcc0..0afa9f3 100644 --- a/libowlps/Makefile +++ b/libowlps/Makefile @@ -35,6 +35,7 @@ OBJS=$(LIB_CIBLE).o # Flags CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O +#CFLAGS += -D NDEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps/Makefile_atheros b/libowlps/Makefile_atheros index 890b063..03d1eaa 100644 --- a/libowlps/Makefile_atheros +++ b/libowlps/Makefile_atheros @@ -38,6 +38,7 @@ OBJS=$(LIB_CIBLE).o # Flags CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O +#CFLAGS += -D NDEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps/Makefile_atheros_openwrt-10.03 b/libowlps/Makefile_atheros_openwrt-10.03 index 0d219a3..69b9690 100644 --- a/libowlps/Makefile_atheros_openwrt-10.03 +++ b/libowlps/Makefile_atheros_openwrt-10.03 @@ -38,6 +38,7 @@ OBJS=$(LIB_CIBLE).o # Flags CFLAGS = -O2 -Wall -Wextra -Wstrict-prototypes -O +#CFLAGS += -D NDEBUG DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC diff --git a/libowlps/libowlps.c b/libowlps/libowlps.c index bde390c..aaa0881 100644 --- a/libowlps/libowlps.c +++ b/libowlps/libowlps.c @@ -17,7 +17,6 @@ #include -#define DEBUG owl_bool owl_run = TRUE ; @@ -389,9 +388,9 @@ void owl_sigint_handler(const int num) owl_run = FALSE ; -#ifdef DEBUG +#ifndef NDEBUG fprintf(stderr, "\nSignal received: end.\n"); -#endif // DEBUG +#endif // NDEBUG fflush(NULL) ; } @@ -428,11 +427,11 @@ void owl_close_fd(void *const fd) const int *const file_desc = fd ; if (close(*file_desc) != 0) perror("Error closing file descriptor") ; -#ifdef DEBUG +#ifndef NDEBUG else fprintf(stderr, "File descriptor %d closed successfully.\n", *file_desc) ; -#endif // DEBUG +#endif // NDEBUG } @@ -452,8 +451,8 @@ void owl_close_file(void *const file) if (fclose(*stream) != 0) perror("Error closing stream") ; -#ifdef DEBUG +#ifndef NDEBUG else fprintf(stderr, "Stream closed successfully.\n") ; -#endif // DEBUG +#endif // NDEBUG } diff --git a/owlps-aggregator/Makefile b/owlps-aggregator/Makefile index 1164a19..8767453 100644 --- a/owlps-aggregator/Makefile +++ b/owlps-aggregator/Makefile @@ -31,6 +31,7 @@ DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" +#OWLPSFLAGS += -D NDEBUG LIBS = -pthread -lconfuse -L$(LIBOWLPS_DIR) -lowlps OS := $(shell uname) diff --git a/owlps-aggregator/owlps-aggregator.h b/owlps-aggregator/owlps-aggregator.h index b94c091..d69f01b 100644 --- a/owlps-aggregator/owlps-aggregator.h +++ b/owlps-aggregator/owlps-aggregator.h @@ -96,10 +96,10 @@ void got_request(owl_captured_request request) ; void* monitor_requests(void *NULL_value) ; void free_request_list(void) ; -#ifdef DEBUG +#ifndef NDEBUG void print_request_list(void) ; void print_request_info(request_info_list *info) ; -#endif // DEBUG +#endif // NDEBUG void* listen_for_aps(void *NULL_value) ; void update_ap(uint8_t mac_addr_bytes[ETHER_ADDR_LEN], diff --git a/owlps-aggregator/owlps-aggregatord.c b/owlps-aggregator/owlps-aggregatord.c index 24caef8..761906b 100644 --- a/owlps-aggregator/owlps-aggregatord.c +++ b/owlps-aggregator/owlps-aggregatord.c @@ -1180,7 +1180,7 @@ void free_ap_list() -#ifdef DEBUG +#ifndef NDEBUG /* * Prints the request list. */ @@ -1259,7 +1259,7 @@ void print_request_info(request_info_list *info) info->antenna_signal_dbm - 0x100 ) ; } -#endif // DEBUG +#endif // NDEBUG diff --git a/owlps-client/Makefile b/owlps-client/Makefile index bdfd0d2..68fabe0 100644 --- a/owlps-client/Makefile +++ b/owlps-client/Makefile @@ -33,6 +33,7 @@ DEPFLAGS = -MMD XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG = -fPIC OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" +OWLPSFLAGS += -D DEBUG LIBS = -L$(LIBOWLPS_DIR) -lowlps \ -L$(LIBOWLPSCLIENT_DIR) -lowlps-client diff --git a/owlps-client/Makefile_atheros b/owlps-client/Makefile_atheros index 33bca1a..871a021 100644 --- a/owlps-client/Makefile_atheros +++ b/owlps-client/Makefile_atheros @@ -46,6 +46,7 @@ LATHEROS = -L$(TOOLCHAIN_USR)/lib -L$(TOOLCHAIN_USR_2)/lib IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include LDFLAGS = $(IATHEROS) $(LATHEROS) OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" +OWLPSFLAGS += -D DEBUG ## Cibles de compilation standard ## diff --git a/owlps-client/Makefile_atheros_openwrt-10.03 b/owlps-client/Makefile_atheros_openwrt-10.03 index 7ba4406..32a460a 100644 --- a/owlps-client/Makefile_atheros_openwrt-10.03 +++ b/owlps-client/Makefile_atheros_openwrt-10.03 @@ -47,6 +47,7 @@ LATHEROS = -L$(TOOLCHAIN1)/lib -L$(TOOLCHAIN1)/usr/lib \ IATHEROS = -I$(TOOLCHAIN1)/usr/include -I$(TOOLCHAIN2)/usr/include LDFLAGS = $(IATHEROS) $(LATHEROS) OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" +OWLPSFLAGS += -D DEBUG ## Cibles de compilation standard ## diff --git a/owlps-client/owlps-client.c b/owlps-client/owlps-client.c index 9a1cdf0..d642a7e 100644 --- a/owlps-client/owlps-client.c +++ b/owlps-client/owlps-client.c @@ -12,7 +12,6 @@ #include -#define DEBUG /* Error codes */ #define ERR_BAD_USAGE 1 // Bad program call (bad number of arguments) diff --git a/owlps-listener/Makefile b/owlps-listener/Makefile index 8b2eddb..02687c1 100644 --- a/owlps-listener/Makefile +++ b/owlps-listener/Makefile @@ -34,6 +34,7 @@ XCFLAGS = $(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG = -fPIC OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \ -D USE_CONFIG_FILE -lconfuse -D USE_PTHREAD -pthread +#OWLPSFLAGS += -D NDEBUG LIBS = -L$(LIBOWLPS_DIR) -lowlps \ -L$(LIBOWLPSCLIENT_DIR) -lowlps-client \ -lpcap -liw diff --git a/owlps-listener/Makefile_atheros b/owlps-listener/Makefile_atheros index 8bdefb9..fd3fb4d 100644 --- a/owlps-listener/Makefile_atheros +++ b/owlps-listener/Makefile_atheros @@ -45,6 +45,7 @@ IATHEROS = -I$(TOOLCHAIN_USR)/include -I$(TOOLCHAIN_USR_2)/include OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \ -D USE_PTHREAD -pthread #OWLPSFLAGS += -D USE_CONFIG_FILE -lconfuse +#OWLPSFLAGS += -D NDEBUG LDFLAGS = $(OWLPSFLAGS) $(LIBS) diff --git a/owlps-listener/Makefile_atheros_openwrt-10.03 b/owlps-listener/Makefile_atheros_openwrt-10.03 index cb6c8e7..d0e75d2 100644 --- a/owlps-listener/Makefile_atheros_openwrt-10.03 +++ b/owlps-listener/Makefile_atheros_openwrt-10.03 @@ -49,6 +49,7 @@ IATHEROS = -I$(TOOLCHAIN1)/usr/include -I$(TOOLCHAIN2)/usr/include OWLPSFLAGS = -D OWLPS_VERSION=\"$(OWLPS_VERSION)\" \ -D USE_PTHREAD -pthread OWLPSFLAGS += -D USE_CONFIG_FILE -lconfuse +#OWLPSFLAGS += -D NDEBUG LDFLAGS = $(OWLPSFLAGS) $(LIBS) diff --git a/owlps-listener/owlps-listenerd.c b/owlps-listener/owlps-listenerd.c index 103a6d5..51e7914 100644 --- a/owlps-listener/owlps-listenerd.c +++ b/owlps-listener/owlps-listenerd.c @@ -1347,10 +1347,10 @@ uint_fast16_t make_packet(uint8_t **packet) memcpy(&pkt[offset], &my_position_y, sizeof(float)) ; offset += sizeof(float) ; memcpy(&pkt[offset], &my_position_z, sizeof(float)) ; -#ifdef DEBUG +#ifndef NDEBUG offset += sizeof(float) ; assert(offset == size) ; -#endif // DEBUG +#endif // NDEBUG *packet = pkt ; return size ;