aboutsummaryrefslogtreecommitdiff
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 05:11:52 +0000
committerGravatar Subhendu Ghosh <sghosh@users.sourceforge.net> 2002-06-19 05:11:52 +0000
commitf4c6f7f09305c1c9916da6ac4f7aadcb31e319e0 (patch)
treebec7f042f90eac26b30122806846fc6a0e3f13b7 /plugins/utils.c
parentd36016a7adf28424d7f4adaa50612c41f1937c3b (diff)
downloadmonitoring-plugins-f4c6f7f09305c1c9916da6ac4f7aadcb31e319e0.tar.gz
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
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c38
1 files changed, 38 insertions, 0 deletions
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)
{