summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c953de7)
raw | patch | inline | side by side (parent: c953de7)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Mon, 18 Nov 2002 07:22:28 +0000 (07:22 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Mon, 18 Nov 2002 07:22:28 +0000 (07:22 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@207 f882894a-f735-0410-b71e-b25c423dba1c
plugins/utils.c | patch | blob | history |
diff --git a/plugins/utils.c b/plugins/utils.c
index 10d544c43bdf0aedf8a071714537db4f73020ea6..da9cceddd7fa8a95287124f76c7c348ecec3c36c 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
#define max(a,b) ((a)>(b))?(a):(b)
/* **************************************************************************
- * max_state(result, STATE_x)
- * compares STATE_x to result and returns result if STATE_x is less than a based on the following
+ * max_state(STATE_x, STATE_y)
+ * compares STATE_x to STATE_y and returns result based on the following
* STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL
*
* Note that numerically the above does not hold
int
max_state(int a, int b)
{
- if(a == STATE_CRITICAL){
- return a;
- }
- else if (a == STATE_WARNING) {
-
- if (b == STATE_CRITICAL){
- return b;
- }else {
- return a;
- }
- }
- else if (a == STATE_OK) {
-
- if ( b== STATE_CRITICAL || b == STATE_WARNING) {
- return b;
- }else{
- return a;
- }
- }
- else {
- /* a == UNKNOWN */
- return b;
- }
-
-
+ if (a == STATE_CRITICAL || b == STATE_CRITICAL)
+ return STATE_CRITICAL;
+ else if (a == STATE_WARNING || b == STATE_WARNING)
+ return STATE_WARNING;
+ else if (a == STATE_OK || b == STATE_OK)
+ return STATE_OK;
+ else if (a == STATE_UNKNOWN || b == STATE_UNKNOWN)
+ return STATE_UNKNOWN;
+ else if (a == STATE_DEPENDENT || b == STATE_DEPENDENT)
+ return STATE_DEPENDENT;
+ else
+ return max (a, b);
}
char *