summaryrefslogtreecommitdiffstats
path: root/plugins/utils.h.in
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/utils.h.in')
-rw-r--r--plugins/utils.h.in92
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/utils.h.in b/plugins/utils.h.in
new file mode 100644
index 00000000..a21d63d6
--- /dev/null
+++ b/plugins/utils.h.in
@@ -0,0 +1,92 @@
1/* header file for nagios plugins uitls.c */
2
3/* this file should be included in all plugins */
4
5/* The purpose of this package is to provide safer alternantives to C
6functions that might otherwise be vulnerable to hacking. This
7currently includes a standard suite of validation routines to be sure
8that an string argument acually converts to its intended type and a
9suite of string handling routine that do their own memory management
10in order to resist overflow attacks. In addition, a few functions are
11provided to standardize version and error reporting accross the entire
12suite of plugins. */
13
14/* Standardize version information, termination */
15
16char *my_basename (char *);
17void support (void);
18char *clean_revstring (const char *revstring);
19void print_revision (char *, const char *);
20void terminate (int result, char *msg, ...);
21extern RETSIGTYPE timeout_alarm_handler (int);
22
23/* Handle timeouts */
24
25time_t start_time, end_time;
26int timeout_interval = DEFAULT_SOCKET_TIMEOUT;
27
28/* Test input types */
29
30int is_host (char *);
31int is_dotted_quad (char *);
32int is_hostname (char *);
33
34int is_integer (char *);
35int is_intpos (char *);
36int is_intneg (char *);
37int is_intnonneg (char *);
38int is_intpercent (char *);
39
40int is_numeric (char *);
41int is_positive (char *);
42int is_negative (char *);
43int is_nonnegative (char *);
44int is_percentage (char *);
45
46int is_option (char *);
47
48/* Handle strings safely */
49
50void strip (char *buffer);
51char *strscpy (char *dest, char *src);
52char *strscat (char *dest, char *src);
53char *strnl (char *str);
54char *ssprintf (char *str, const char *fmt, ...);
55char *strpcpy (char *dest, const char *src, const char *str);
56char *strpcat (char *dest, const char *src, const char *str);
57
58#define max(a,b) ((a)>(b))?(a):(b)
59
60#define usage(msg) {\
61 printf(msg);\
62 print_usage();\
63exit(STATE_UNKNOWN);\
64}
65
66#define usage2(msg,arg) {\
67 printf("%s: %s - %s\n",PROGNAME,msg,arg);\
68 print_usage();\
69 exit(STATE_UNKNOWN);\
70}
71
72#define state_text(a) \
73(a)==0?"OK":\
74(a)==1?"WARNING":\
75(a)==2?"CRITICAL":\
76(a)==-2?"DEPENDENT":\
77"UNKNOWN"
78
79/* The idea here is that, although not every plugin will use all of these,
80 most will or should. Therefore, for consistency, these very common
81 options should have only these meanings throughout the overall suite */
82
83#define STD_OPTS "Vvht:c:w:H:F:"
84#define STD_OPTS_LONG \
85{"version",no_argument,0,'V'},\
86{"verbose",no_argument,0,'v'},\
87{"help",no_argument,0,'h'},\
88{"timeout",required_argument,0,'t'},\
89{"critical",required_argument,0,'c'},\
90{"warning",required_argument,0,'w'},\
91{"hostname",required_argument,0,'H'},\
92{"file",required_argument,0,'F'}