From 1b09022d6b8cc927c14ce84f9d78cedd4e2f1d33 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 22 Jan 2021 00:15:36 +1000 Subject: [PATCH] * reorganize #include's --- src/appconfig.c | 3 +++ src/appconfig.h | 3 --- src/backend.c | 4 ++++ src/backend.h | 3 --- src/common.h | 4 +--- src/daemon.c | 20 ++++++++++++-------- src/filter-test.c | 5 +++++ src/filter.c | 4 ++++ src/filter.h | 3 --- src/ipaddr.c | 3 +++ src/ipaddr.h | 6 ------ src/jail.c | 9 +++++++++ src/jail.h | 9 --------- src/log.c | 2 +- src/source.c | 5 +++++ src/source.h | 3 --- src/statefile.c | 1 + t/t_filters.c | 1 + t/t_ipaddr.c | 3 +++ t/t_statefile.c | 1 + 20 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/appconfig.c b/src/appconfig.c index 6277c42..f21a033 100644 --- a/src/appconfig.c +++ b/src/appconfig.c @@ -9,6 +9,9 @@ #include "config.h" #include "appconfig.h" +#include +#include + f2b_appconfig_t appconfig = { .coredumps = false, .daemon = false, diff --git a/src/appconfig.h b/src/appconfig.h index 6b128b0..2dd7918 100644 --- a/src/appconfig.h +++ b/src/appconfig.h @@ -7,9 +7,6 @@ #ifndef F2B_APPCONFIG_H_ #define F2B_APPCONFIG_H_ -#include -#include - typedef struct f2b_appconfig_t { bool daemon; bool coredumps; diff --git a/src/backend.c b/src/backend.c index 3624ea2..c46284d 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5,8 +5,12 @@ * published by the Free Software Foundation. */ #include "common.h" +#include "config.h" +#include "log.h" #include "backend.h" +#include + #define BACKEND_LIBRARY_PARAM "load" f2b_backend_t * diff --git a/src/backend.h b/src/backend.h index c5227ad..36a609a 100644 --- a/src/backend.h +++ b/src/backend.h @@ -7,9 +7,6 @@ #ifndef F2B_BACKEND_H_ #define F2B_BACKEND_H_ -#include "config.h" -#include "log.h" - /** * @file * This header describes backend module definition and related routines diff --git a/src/common.h b/src/common.h index fb883c2..1bb16b9 100644 --- a/src/common.h +++ b/src/common.h @@ -9,10 +9,8 @@ #include #include -#include #include -#include -#include +#include /* PATH_MAX */ #include #include #include diff --git a/src/daemon.c b/src/daemon.c index 7f79582..91403ef 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -5,20 +5,24 @@ * published by the Free Software Foundation. */ #include "common.h" - -#include -#include -#include - -#include "ipaddr.h" +#include "log.h" #include "config.h" -#include "jail.h" -#include "backend.h" #include "appconfig.h" +#include "matches.h" +#include "ipaddr.h" +#include "source.h" +#include "filter.h" +#include "backend.h" +#include "statefile.h" +#include "jail.h" #include "buf.h" #include "commands.h" #include "csocket.h" +#include +#include +#include + /** * @def SA_REGISTER * Register signal handler diff --git a/src/filter-test.c b/src/filter-test.c index 43460dd..89ec780 100644 --- a/src/filter-test.c +++ b/src/filter-test.c @@ -6,10 +6,15 @@ */ #include "common.h" #include "log.h" +#include "matches.h" #include "ipaddr.h" #include "config.h" #include "filter.h" +#include +#include /* struct in_addr */ +#include + void usage() { fprintf(stderr, "Usage: filter-test []\n"); exit(EXIT_FAILURE); diff --git a/src/filter.c b/src/filter.c index 13c7395..fd454dc 100644 --- a/src/filter.c +++ b/src/filter.c @@ -5,8 +5,12 @@ * published by the Free Software Foundation. */ #include "common.h" +#include "config.h" +#include "log.h" #include "filter.h" +#include + #define REGEX_LINE_MAX 256 #define HOST_TOKEN "" #define FILTER_LIBRARY_PARAM "load" diff --git a/src/filter.h b/src/filter.h index 9eead58..9f5e616 100644 --- a/src/filter.h +++ b/src/filter.h @@ -7,9 +7,6 @@ #ifndef F2B_FILTER_H_ #define F2B_FILTER_H_ -#include "config.h" -#include "log.h" - /** * @file * This header describes filter module definition and related routines diff --git a/src/ipaddr.c b/src/ipaddr.c index 45fa6c2..2a1282e 100644 --- a/src/ipaddr.c +++ b/src/ipaddr.c @@ -5,8 +5,11 @@ * published by the Free Software Foundation. */ #include "common.h" +#include "matches.h" #include "ipaddr.h" +#include + f2b_ipaddr_t * f2b_ipaddr_create(const char *addr) { f2b_ipaddr_t *a = NULL; diff --git a/src/ipaddr.h b/src/ipaddr.h index 88f4323..b2430a9 100644 --- a/src/ipaddr.h +++ b/src/ipaddr.h @@ -7,17 +7,11 @@ #ifndef F2B_IPADDR_H_ #define F2B_IPADDR_H_ -#include -#include -#include - /** * @file * This file contains definition of ipaddr struct and related routines */ -#include "matches.h" - /** * @def IPADDR_MAX * Maximum text length of address diff --git a/src/jail.c b/src/jail.c index 09d2435..994db98 100644 --- a/src/jail.c +++ b/src/jail.c @@ -5,6 +5,15 @@ * published by the Free Software Foundation. */ #include "common.h" +#include "log.h" +#include "config.h" +#include "appconfig.h" +#include "matches.h" +#include "ipaddr.h" +#include "source.h" +#include "filter.h" +#include "backend.h" +#include "statefile.h" #include "jail.h" #define DEFAULT_BANTIME 3600 /* in seconds, 1 hour */ diff --git a/src/jail.h b/src/jail.h index 29e95be..366f612 100644 --- a/src/jail.h +++ b/src/jail.h @@ -7,15 +7,6 @@ #ifndef F2B_JAIL_H_ #define F2B_JAIL_H_ -#include "log.h" -#include "ipaddr.h" -#include "config.h" -#include "appconfig.h" -#include "statefile.h" -#include "source.h" -#include "filter.h" -#include "backend.h" - /** * @file * This header describes jail definition and related routines diff --git a/src/log.c b/src/log.c index 9ae24c5..68660f0 100644 --- a/src/log.c +++ b/src/log.c @@ -7,7 +7,7 @@ #include "common.h" #include "log.h" -#include "syslog.h" +#include static log_msgtype_t minlevel = log_info; static enum { log_stderr = 0, log_file = 1, log_syslog = 2 } dest = log_stderr; diff --git a/src/source.c b/src/source.c index 0d10fcd..9fe4603 100644 --- a/src/source.c +++ b/src/source.c @@ -5,6 +5,11 @@ * published by the Free Software Foundation. */ #include "common.h" +#include "config.h" +#include "log.h" + +#include + #include "source.h" #define SOURCE_LIBRARY_PARAM "load" diff --git a/src/source.h b/src/source.h index b133978..fd53d62 100644 --- a/src/source.h +++ b/src/source.h @@ -7,9 +7,6 @@ #ifndef F2B_SOURCE_H_ #define F2B_SOURCE_H_ -#include "config.h" -#include "log.h" - /** * @file * This header describes source module definition and related routines diff --git a/src/statefile.c b/src/statefile.c index 5eef53b..65fc9f0 100644 --- a/src/statefile.c +++ b/src/statefile.c @@ -7,6 +7,7 @@ #include "common.h" #include "log.h" +#include "matches.h" #include "ipaddr.h" #include "statefile.h" diff --git a/t/t_filters.c b/t/t_filters.c index 80e017e..777be01 100644 --- a/t/t_filters.c +++ b/t/t_filters.c @@ -1,5 +1,6 @@ #include "../src/common.h" #include "../src/log.h" +#include "../src/matches.h" #include "../src/ipaddr.h" #include "../src/filters/filter.h" diff --git a/t/t_ipaddr.c b/t/t_ipaddr.c index 76ce094..f17a2a3 100644 --- a/t/t_ipaddr.c +++ b/t/t_ipaddr.c @@ -1,6 +1,9 @@ #include "../src/common.h" +#include "../src/matches.h" #include "../src/ipaddr.h" +#include + int main() { bool res = false; f2b_ipaddr_t *list = NULL; diff --git a/t/t_statefile.c b/t/t_statefile.c index f3501b3..0ce2909 100644 --- a/t/t_statefile.c +++ b/t/t_statefile.c @@ -1,4 +1,5 @@ #include "../src/common.h" +#include "../src/matches.h" #include "../src/ipaddr.h" #include "../src/statefile.h"