[Nagiosplug-checkins] CVS: nagiosplug/plugins utils.c,1.12,1.13

Karl DeBisschop kdebisschop at projects.sourceforge.net
Mon Nov 18 06:41:02 CET 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv12138/plugins

Modified Files:
	utils.c 
Log Message:
more readable max_state() code

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** utils.c	14 Nov 2002 18:25:10 -0000	1.12
--- utils.c	18 Nov 2002 07:22:28 -0000	1.13
***************
*** 61,66 ****
  
  /* **************************************************************************
!  * 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
   *
--- 61,66 ----
  
  /* **************************************************************************
!  * 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
   *
***************
*** 71,99 ****
  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;
! 	}
! 		
! 
  }
  
--- 71,86 ----
  max_state(int a, int 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);
  }
  





More information about the Commits mailing list