From f4c6f7f09305c1c9916da6ac4f7aadcb31e319e0 Mon Sep 17 00:00:00 2001 From: Subhendu Ghosh Date: Wed, 19 Jun 2002 05:11:52 +0000 Subject: more POSIX return value comparison related code fixes git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@55 f882894a-f735-0410-b71e-b25c423dba1c --- plugins/utils.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'plugins/utils.c') diff --git a/plugins/utils.c b/plugins/utils.c index 49e4d3d7..8bec1cf1 100644 --- a/plugins/utils.c +++ b/plugins/utils.c @@ -58,6 +58,44 @@ char *strpcat (char *dest, const char *src, const char *str); #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 + * 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; + } + + +} + char * my_basename (char *path) { -- cgit v1.2.3