summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8535da6)
raw | patch | inline | side by side (parent: 8535da6)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 19 Mar 2003 13:01:05 +0000 (13:01 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Wed, 19 Mar 2003 13:01:05 +0000 (13:01 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@440 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history | |
plugins/utils.h | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index e204e2388666f252dc761579e4b119e1a3f82506..b35b78af9c4a0842b31b0325f4e7469a42084113 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
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 *);
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
}
+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, ...)
diff --git a/plugins/utils.h b/plugins/utils.h
index 43b612c17e4f93fb3cbb68c8e148550171074b91..b345f7a2b7da517822a756019ce29413797d9914 100644 (file)
--- a/plugins/utils.h
+++ b/plugins/utils.h
void support (void);
char *clean_revstring (const char *revstring);
void print_revision (const char *, const char *);
+void die (int result, const char *fmt, ...);
void terminate (int result, char *msg, ...);
extern RETSIGTYPE timeout_alarm_handler (int);
void usage2(char *msg, char *arg);
void usage3(char *msg, char arg);
+char *state_text (int result);
#define max(a,b) (((a)>(b))?(a):(b))
-#define state_text(a) \
-(a)==0?"OK":\
-(a)==1?"WARNING":\
-(a)==2?"CRITICAL":\
-(a)==3?"UNKNOWN":\
-(a)==4?"DEPENDENT":\
-"UNKNOWN"
-
/* The idea here is that, although not every plugin will use all of these,
most will or should. Therefore, for consistency, these very common
options should have only these meanings throughout the overall suite */