[Nagiosplug-checkins] CVS: nagiosplug/plugins utils.c,1.20,1.21 utils.h,1.2,1.3

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Mar 19 05:02:05 CET 2003


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

Modified Files:
	utils.c utils.h 
Log Message:
make state_text a function

Index: utils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -r1.20 -r1.21
*** utils.c	15 Mar 2003 01:25:35 -0000	1.20
--- utils.c	19 Mar 2003 13:01:05 -0000	1.21
***************
*** 25,29 ****
  char *clean_revstring (const char *);
  void print_revision (const char *, const char *);
! void terminate (int, const char *fmt, ...);
  RETSIGTYPE timeout_alarm_handler (int);
  
--- 25,30 ----
  char *clean_revstring (const char *);
  void print_revision (const char *, const char *);
! void die (int result, const char *fmt, ...);
! void terminate (int result, const char *fmt, ...);
  RETSIGTYPE timeout_alarm_handler (int);
  
***************
*** 51,54 ****
--- 52,57 ----
  char *strpcat (char *dest, const char *src, const char *str);
  
+ char *state_text (int result);
+ 
  #define LABELLEN 63
  #define STRLEN 64
***************
*** 141,144 ****
--- 144,174 ----
  }
  
+ 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

Index: utils.h
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/utils.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** utils.h	15 Mar 2003 01:25:35 -0000	1.2
--- utils.h	19 Mar 2003 13:01:05 -0000	1.3
***************
*** 18,21 ****
--- 18,22 ----
  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);
***************
*** 72,85 ****
  void usage3(char *msg, char arg);
  
  
  #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, 
--- 73,79 ----
  void usage3(char *msg, char arg);
  
+ char *state_text (int result);
  
  #define max(a,b) (((a)>(b))?(a):(b))
  
  /* The idea here is that, although not every plugin will use all of these, 





More information about the Commits mailing list