From 5b0e00782da2bbe9f9062884c9ae8ed330d5911e Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 10 Sep 2013 22:45:45 +0200 Subject: Move global variables from .h to .c files Simplify things by moving the definition of global variables into .c files, where they belong. --- plugins/netutils.c | 5 +++-- plugins/netutils.h | 12 +++--------- plugins/sslutils.c | 1 - plugins/utils.c | 7 +++++-- plugins/utils.h | 9 ++------- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/plugins/netutils.c b/plugins/netutils.c index 1d6100ab..9f18723a 100644 --- a/plugins/netutils.c +++ b/plugins/netutils.c @@ -27,11 +27,12 @@ * *****************************************************************************/ -#define LOCAL_TIMEOUT_ALARM_HANDLER - #include "common.h" #include "netutils.h" +unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; +unsigned int socket_timeout_state = STATE_CRITICAL; + int econn_refuse_state = STATE_CRITICAL; int was_refused = FALSE; #if USE_IPV6 diff --git a/plugins/netutils.h b/plugins/netutils.h index 5a495c91..347509e2 100644 --- a/plugins/netutils.h +++ b/plugins/netutils.h @@ -81,20 +81,14 @@ void host_or_die(const char *str); # define is_hostname(addr) resolve_host_or_addr(addr, AF_INET) #endif -#ifdef LOCAL_TIMEOUT_ALARM_HANDLER extern unsigned int socket_timeout; -extern int socket_timeout_state; -RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); -#else -unsigned int socket_timeout = DEFAULT_SOCKET_TIMEOUT; -unsigned int socket_timeout_state = STATE_CRITICAL; -extern RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); -#endif - +extern unsigned int socket_timeout_state; extern int econn_refuse_state; extern int was_refused; extern int address_family; +RETSIGTYPE socket_timeout_alarm_handler (int) __attribute__((noreturn)); + /* SSL-Related functionality */ #ifdef HAVE_SSL /* maybe this could be merged with the above np_net_connect, via some flags */ diff --git a/plugins/sslutils.c b/plugins/sslutils.c index 818f7996..b8d45813 100644 --- a/plugins/sslutils.c +++ b/plugins/sslutils.c @@ -27,7 +27,6 @@ *****************************************************************************/ #define MAX_CN_LENGTH 256 -#define LOCAL_TIMEOUT_ALARM_HANDLER #include "common.h" #include "netutils.h" diff --git a/plugins/utils.c b/plugins/utils.c index 8827e31a..b57d5e17 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -22,8 +22,6 @@ * *****************************************************************************/ -#define LOCAL_TIMEOUT_ALARM_HANDLER - #include "common.h" #include "utils.h" #include "utils_base.h" @@ -38,6 +36,11 @@ extern const char *progname; #define STRLEN 64 #define TXTBLK 128 +unsigned int timeout_state = STATE_CRITICAL; +unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; + +time_t start_time, end_time; + /* ************************************************************************** * max_state(STATE_x, STATE_y) * compares STATE_x to STATE_y and returns result based on the following diff --git a/plugins/utils.h b/plugins/utils.h index 822be940..657d4bfa 100644 --- a/plugins/utils.h +++ b/plugins/utils.h @@ -31,17 +31,12 @@ void print_revision (const char *, const char *); /* Handle timeouts */ -#ifdef LOCAL_TIMEOUT_ALARM_HANDLER extern unsigned int timeout_state; extern unsigned int timeout_interval; + RETSIGTYPE timeout_alarm_handler (int); -#else -unsigned int timeout_state = STATE_CRITICAL; -unsigned int timeout_interval = DEFAULT_SOCKET_TIMEOUT; -extern RETSIGTYPE timeout_alarm_handler (int); -#endif -time_t start_time, end_time; +extern time_t start_time, end_time; /* Test input types */ -- cgit v1.2.3