diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-03-19 13:01:05 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2003-03-19 13:01:05 +0000 |
commit | 4f29ac7115a5852a747242fc7973a6137817c3df (patch) | |
tree | cc5fcb8d542ed67ffd3a25057292e4ba20924f6b /plugins/utils.c | |
parent | 8535da68ef4fdd8ccebc9a0fe72bf3bf61e71f65 (diff) | |
download | monitoring-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.c | 32 |
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; void support (void); char *clean_revstring (const char *); void print_revision (const char *, const char *); -void terminate (int, const char *fmt, ...); +void die (int result, const char *fmt, ...); +void terminate (int result, const char *fmt, ...); RETSIGTYPE timeout_alarm_handler (int); int is_integer (char *); @@ -50,6 +51,8 @@ char *strnl (char *str); char *strpcpy (char *dest, const char *src, const char *str); char *strpcat (char *dest, const char *src, const char *str); +char *state_text (int result); + #define LABELLEN 63 #define STRLEN 64 #define TXTBLK 128 @@ -140,6 +143,33 @@ print_revision (const char *command_name, const char *revision_string) } +char * +state_text (int result) +{ + switch (result) { + case STATE_OK: + return "OK"; + case STATE_WARNING: + return "WARNING"; + case STATE_CRITICAL: + return "CRITICAL"; + case STATE_DEPENDENT: + return "DEPENDENT"; + default: + return "UNKNOWN"; + } +} + +void +die (int result, const char *fmt, ...) +{ + printf ("%s %s: ", sizeof (char) + index(progname, '_'), state_text(result)); + va_list ap; + va_start (ap, fmt); + vprintf (fmt, ap); + va_end (ap); + exit (result); +} void terminate (int result, const char *fmt, ...) |