summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-19 13:01:05 +0000
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-03-19 13:01:05 +0000
commit4f29ac7115a5852a747242fc7973a6137817c3df (patch)
treecc5fcb8d542ed67ffd3a25057292e4ba20924f6b /plugins/utils.c
parent8535da68ef4fdd8ccebc9a0fe72bf3bf61e71f65 (diff)
downloadmonitoring-plugins-4f29ac7115a5852a747242fc7973a6137817c3df.tar.gz
make state_text a function
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@440 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index e204e238..b35b78af 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -24,7 +24,8 @@ extern const char *progname;
24void support (void); 24void support (void);
25char *clean_revstring (const char *); 25char *clean_revstring (const char *);
26void print_revision (const char *, const char *); 26void print_revision (const char *, const char *);
27void terminate (int, const char *fmt, ...); 27void die (int result, const char *fmt, ...);
28void terminate (int result, const char *fmt, ...);
28RETSIGTYPE timeout_alarm_handler (int); 29RETSIGTYPE timeout_alarm_handler (int);
29 30
30int is_integer (char *); 31int is_integer (char *);
@@ -50,6 +51,8 @@ char *strnl (char *str);
50char *strpcpy (char *dest, const char *src, const char *str); 51char *strpcpy (char *dest, const char *src, const char *str);
51char *strpcat (char *dest, const char *src, const char *str); 52char *strpcat (char *dest, const char *src, const char *str);
52 53
54char *state_text (int result);
55
53#define LABELLEN 63 56#define LABELLEN 63
54#define STRLEN 64 57#define STRLEN 64
55#define TXTBLK 128 58#define TXTBLK 128
@@ -140,6 +143,33 @@ print_revision (const char *command_name, const char *revision_string)
140 143
141} 144}
142 145
146char *
147state_text (int result)
148{
149 switch (result) {
150 case STATE_OK:
151 return "OK";
152 case STATE_WARNING:
153 return "WARNING";
154 case STATE_CRITICAL:
155 return "CRITICAL";
156 case STATE_DEPENDENT:
157 return "DEPENDENT";
158 default:
159 return "UNKNOWN";
160 }
161}
162
163void
164die (int result, const char *fmt, ...)
165{
166 printf ("%s %s: ", sizeof (char) + index(progname, '_'), state_text(result));
167 va_list ap;
168 va_start (ap, fmt);
169 vprintf (fmt, ap);
170 va_end (ap);
171 exit (result);
172}
143 173
144void 174void
145terminate (int result, const char *fmt, ...) 175terminate (int result, const char *fmt, ...)