[nagiosplug] Move global variables from .h to .c files
"Nagios Plugin Development" <[email protected]> Tue, 10 Sep 2013 21:00:33 +0000
| Newsgroups | gmane.network.nagios.plugins.cvs |
|---|---|
| Message-ID | <[email protected]> |
Module: nagiosplug Branch: master Commit: 5b0e00782da2bbe9f9062884c9ae8ed330d5911e Author: Holger Weiss <[email protected]> Date: Tue Sep 10 22:45:45 2013 +0200 URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=5b0e007 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 1d6100a..9f18723 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 5a495c9..347509e 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 818f799..b8d4581 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 8827e31..b57d5e1 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 822be94..657d4bf 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 */ ------------------------------------------------------------------------------ How ServiceNow helps IT people transform IT departments: 1. Consolidate legacy IT systems to a single system of record for IT 2. Standardize and globalize service processes across IT 3. Implement zero-touch automation to replace manual, redundant tasks http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk