ソースを参照

Move global variables from .h to .c files

Simplify things by moving the definition of global variables into .c
files, where they belong.
Holger Weiss 12 年 前
コミット
5b0e00782d
5 ファイル変更13 行追加21 行削除
  1. 3 2
      plugins/netutils.c
  2. 3 9
      plugins/netutils.h
  3. 0 1
      plugins/sslutils.c
  4. 5 2
      plugins/utils.c
  5. 2 7
      plugins/utils.h

+ 3 - 2
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

+ 3 - 9
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 */

+ 0 - 1
plugins/sslutils.c

@@ -27,7 +27,6 @@
 *****************************************************************************/
 
 #define MAX_CN_LENGTH 256
-#define LOCAL_TIMEOUT_ALARM_HANDLER
 #include "common.h"
 #include "netutils.h"
 

+ 5 - 2
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

+ 2 - 7
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 */