diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/utils.c | 40 | ||||
-rw-r--r-- | plugins/utils.h | 27 |
2 files changed, 25 insertions, 42 deletions
diff --git a/plugins/utils.c b/plugins/utils.c index 128052d..5f770a1 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -11,49 +11,19 @@ | |||
11 | * $Date$ | 11 | * $Date$ |
12 | ****************************************************************************/ | 12 | ****************************************************************************/ |
13 | 13 | ||
14 | #define LOCAL_TIMEOUT_ALARM_HANDLER | ||
15 | |||
14 | #include "config.h" | 16 | #include "config.h" |
15 | #include "common.h" | 17 | #include "common.h" |
18 | #include "utils.h" | ||
16 | #include <stdarg.h> | 19 | #include <stdarg.h> |
17 | #include <limits.h> | 20 | #include <limits.h> |
18 | 21 | ||
19 | #include <arpa/inet.h> | 22 | #include <arpa/inet.h> |
20 | 23 | ||
21 | extern void print_usage (void); | 24 | extern void print_usage (void); |
22 | extern int timeout_interval; | ||
23 | extern const char *progname; | 25 | extern const char *progname; |
24 | 26 | ||
25 | void support (void); | ||
26 | char *clean_revstring (const char *); | ||
27 | void print_revision (const char *, const char *); | ||
28 | void die (int result, const char *fmt, ...); | ||
29 | void terminate (int result, const char *fmt, ...); | ||
30 | RETSIGTYPE timeout_alarm_handler (int); | ||
31 | |||
32 | int is_integer (char *); | ||
33 | int is_intpos (char *); | ||
34 | int is_intneg (char *); | ||
35 | int is_intnonneg (char *); | ||
36 | int is_intpercent (char *); | ||
37 | |||
38 | int is_numeric (char *); | ||
39 | int is_positive (char *); | ||
40 | int is_negative (char *); | ||
41 | int is_nonnegative (char *); | ||
42 | int is_percentage (char *); | ||
43 | |||
44 | int is_option (char *str); | ||
45 | |||
46 | double delta_time (struct timeval tv); | ||
47 | |||
48 | void strip (char *); | ||
49 | char *strscpy (char *dest, const char *src); | ||
50 | char *strscat (char *dest, char *src); | ||
51 | char *strnl (char *str); | ||
52 | char *strpcpy (char *dest, const char *src, const char *str); | ||
53 | char *strpcat (char *dest, const char *src, const char *str); | ||
54 | |||
55 | char *state_text (int result); | ||
56 | |||
57 | #define STRLEN 64 | 27 | #define STRLEN 64 |
58 | #define TXTBLK 128 | 28 | #define TXTBLK 128 |
59 | 29 | ||
@@ -65,8 +35,6 @@ char *state_text (int result); | |||
65 | * Note that numerically the above does not hold | 35 | * Note that numerically the above does not hold |
66 | ****************************************************************************/ | 36 | ****************************************************************************/ |
67 | 37 | ||
68 | #define max(a,b) (((a)>(b))?(a):(b)) | ||
69 | |||
70 | int | 38 | int |
71 | max_state (int a, int b) | 39 | max_state (int a, int b) |
72 | { | 40 | { |
@@ -398,7 +366,7 @@ strscpy (char *dest, const char *src) | |||
398 | *****************************************************************************/ | 366 | *****************************************************************************/ |
399 | 367 | ||
400 | char * | 368 | char * |
401 | strscat (char *dest, char *src) | 369 | strscat (char *dest, const char *src) |
402 | { | 370 | { |
403 | 371 | ||
404 | if (dest == NULL) | 372 | if (dest == NULL) |
diff --git a/plugins/utils.h b/plugins/utils.h index b10f0e5..e581afa 100644 --- a/plugins/utils.h +++ b/plugins/utils.h | |||
@@ -13,18 +13,23 @@ suite of plugins. */ | |||
13 | 13 | ||
14 | /* Standardize version information, termination */ | 14 | /* Standardize version information, termination */ |
15 | 15 | ||
16 | char *my_basename (char *); | ||
17 | void support (void); | 16 | void support (void); |
18 | char *clean_revstring (const char *revstring); | 17 | char *clean_revstring (const char *revstring); |
19 | void print_revision (const char *, const char *); | 18 | void print_revision (const char *, const char *); |
20 | void die (int result, const char *fmt, ...); | 19 | void die (int result, const char *fmt, ...); |
21 | void terminate (int result, char *msg, ...); | 20 | void terminate (int result, const char *msg, ...); |
22 | extern RETSIGTYPE timeout_alarm_handler (int); | ||
23 | 21 | ||
24 | /* Handle timeouts */ | 22 | /* Handle timeouts */ |
25 | 23 | ||
26 | time_t start_time, end_time; | 24 | #ifdef LOCAL_TIMEOUT_ALARM_HANDLER |
25 | extern int timeout_interval; | ||
26 | RETSIGTYPE timeout_alarm_handler (int); | ||
27 | #else | ||
27 | int timeout_interval = DEFAULT_SOCKET_TIMEOUT; | 28 | int timeout_interval = DEFAULT_SOCKET_TIMEOUT; |
29 | extern RETSIGTYPE timeout_alarm_handler (int); | ||
30 | #endif | ||
31 | |||
32 | time_t start_time, end_time; | ||
28 | 33 | ||
29 | /* Test input types */ | 34 | /* Test input types */ |
30 | 35 | ||
@@ -59,8 +64,8 @@ double delta_time (struct timeval tv); | |||
59 | /* Handle strings safely */ | 64 | /* Handle strings safely */ |
60 | 65 | ||
61 | void strip (char *buffer); | 66 | void strip (char *buffer); |
62 | char *strscpy (char *dest, char *src); | 67 | char *strscpy (char *dest, const char *src); |
63 | char *strscat (char *dest, char *src); | 68 | char *strscat (char *dest, const char *src); |
64 | char *strnl (char *str); | 69 | char *strnl (char *str); |
65 | char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ | 70 | char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */ |
66 | char *strpcpy (char *dest, const char *src, const char *str); | 71 | char *strpcpy (char *dest, const char *src, const char *str); |
@@ -124,3 +129,13 @@ char *state_text (int result); | |||
124 | #define UT_TIMEOUT "\ | 129 | #define UT_TIMEOUT "\ |
125 | -t, --timeout=INTEGER\n\ | 130 | -t, --timeout=INTEGER\n\ |
126 | Seconds before connection times out (default: %d)\n" | 131 | Seconds before connection times out (default: %d)\n" |
132 | |||
133 | #define UT_SUPPORT "\n\ | ||
134 | Send email to nagios-users@lists.sourceforge.net if you have questions\n\ | ||
135 | regarding use of this software. To submit patches or suggest improvements,\n\ | ||
136 | send email to nagiosplug-devel@lists.sourceforge.net\n" | ||
137 | |||
138 | #define UT_NOWARRANTY "\ | ||
139 | The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n\ | ||
140 | copies of the plugins under the terms of the GNU General Public License.\n\ | ||
141 | For more information about these matters, see the file named COPYING.\n" | ||