[Nagiosplug-checkins] CVS: nagiosplug/plugins check_mysql.c,1.1.1.1,1.2 check_real.c,1.1.1.1,1.2 check_ups.c,1.3,1.4

Karl DeBisschop kdebisschop at users.sourceforge.net
Tue Nov 12 03:27:01 CET 2002


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory usw-pr-cvs1:/tmp/cvs-serv3145

Modified Files:
	check_mysql.c check_real.c check_ups.c 
Log Message:
remove call_getopt

Index: check_mysql.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_mysql.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_mysql.c	28 Feb 2002 06:42:58 -0000	1.1.1.1
--- check_mysql.c	12 Nov 2002 11:26:01 -0000	1.2
***************
*** 16,19 ****
--- 16,21 ----
  
  #define PROGNAME "check_mysql"
+ #define REVISION "$Revision$"
+ #define COPYRIGHT "1999-2002"
  
  #include "common.h"
***************
*** 23,34 ****
  #include <mysql/errmsg.h>
  
! char *db_user = NULL;
! char *db_host = NULL;
! char *db_pass = NULL;
! char *db = NULL;
  unsigned int db_port = MYSQL_PORT;
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  int check_disk (int usp, int free_disk);
--- 25,35 ----
  #include <mysql/errmsg.h>
  
! char *db_user = "";
! char *db_host = "";
! char *db_pass = "";
! char *db = "";
  unsigned int db_port = MYSQL_PORT;
  
  int process_arguments (int, char **);
  int validate_arguments (void);
  int check_disk (int usp, int free_disk);
***************
*** 127,172 ****
  	int c;
  
- 	if (argc < 1)
- 		return ERROR;
- 
- 	c = 0;
- 	while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (db_host == NULL)
- 			if (is_host (argv[c])) {
- 				db_host = argv[c];
- 			}
- 			else {
- 				usage ("Invalid host name");
- 			}
- 		else if (db_user == NULL)
- 			db_user = argv[c];
- 		else if (db_pass == NULL)
- 			db_pass = argv[c];
- 		else if (db == NULL)
- 			db = argv[c];
- 		else if (is_intnonneg (argv[c]))
- 			db_port = atoi (argv[c]);
- 	}
- 
- 	if (db_host == NULL)
- 		db_host = strscpy (db_host, "127.0.0.1");
- 
- 	return validate_arguments ();
- }
- 
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
--- 128,131 ----
***************
*** 184,210 ****
  #endif
  
  	while (1) {
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "+hVP:p:u:d:H:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "+?hVP:p:u:d:H:");
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'P':
- 		case 'p':
- 		case 'u':
- 		case 'd':
- 		case 'H':
- 			i++;
- 		}
- 
- 		switch (c) {
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
--- 143,161 ----
  #endif
  
+ 	if (argc < 1)
+ 		return ERROR;
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
  		c =
! 			getopt_long (argc, argv, "hVP:p:u:d:H:", long_options, &option_index);
  #else
! 		c = getopt (argc, argv, "hVP:p:u:d:H:");
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
***************
*** 228,232 ****
  			break;
  		case 'V':									/* version */
! 			print_revision (my_basename (argv[0]), "$Revision$");
  			exit (STATE_OK);
  		case 'h':									/* help */
--- 179,183 ----
  			break;
  		case 'V':									/* version */
! 			print_revision (PROGNAME, REVISION);
  			exit (STATE_OK);
  		case 'h':									/* help */
***************
*** 237,241 ****
  		}
  	}
! 	return i;
  }
  
--- 188,215 ----
  		}
  	}
! 
! 	c = optind;
! 
! 	if (strlen(db_host) == 0 && argc > c)
! 		if (is_host (argv[c])) {
! 			db_host = argv[c++];
! 		}
! 		else {
! 			usage ("Invalid host name");
! 		}
! 
! 	if (strlen(db_user) == 0 && argc > c)
! 		db_user = argv[c++];
! 
! 	if (strlen(db_pass) == 0 && argc > c)
! 		db_pass = argv[c++];
! 
! 	if (strlen(db) == 0 && argc > c)
! 		db = argv[c++];
! 
! 	if (is_intnonneg (argv[c]))
! 		db_port = atoi (argv[c++]);
! 
! 	return validate_arguments ();
  }
  
***************
*** 257,261 ****
  print_help (void)
  {
! 	print_revision (PROGNAME, "$Revision$");
  	printf
  		("Copyright (c) 2000 Didi Rieder/Karl DeBisschop\n\n"
--- 231,235 ----
  print_help (void)
  {
! 	print_revision (PROGNAME, REVISION);
  	printf
  		("Copyright (c) 2000 Didi Rieder/Karl DeBisschop\n\n"

Index: check_real.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_real.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -r1.1.1.1 -r1.2
*** check_real.c	28 Feb 2002 06:42:58 -0000	1.1.1.1
--- check_real.c	12 Nov 2002 11:26:01 -0000	1.2
***************
*** 56,60 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  int check_disk (int usp, int free_disk);
--- 56,59 ----
***************
*** 63,70 ****
  
  int server_port = PORT;
! char *server_address = NULL;
  char *host_name = NULL;
  char *server_url = NULL;
! char *server_expect = NULL;
  int warning_time = 0;
  int check_warning_time = FALSE;
--- 62,69 ----
  
  int server_port = PORT;
! char *server_address = "";
  char *host_name = NULL;
  char *server_url = NULL;
! char *server_expect = EXPECT;
  int warning_time = 0;
  int check_warning_time = FALSE;
***************
*** 118,122 ****
  
  	/* make sure we find the response we are looking for */
! 	if (!strstr (buffer, EXPECT)) {
  		if (server_port == PORT)
  			printf ("Invalid REAL response received from host\n");
--- 117,121 ----
  
  	/* make sure we find the response we are looking for */
! 	if (!strstr (buffer, server_expect)) {
  		if (server_port == PORT)
  			printf ("Invalid REAL response received from host\n");
***************
*** 191,195 ****
  		else {
  			/* make sure we find the response we are looking for */
! 			if (!strstr (buffer, EXPECT)) {
  				if (server_port == PORT)
  					printf ("Invalid REAL response received from host\n");
--- 190,194 ----
  		else {
  			/* make sure we find the response we are looking for */
! 			if (!strstr (buffer, server_expect)) {
  				if (server_port == PORT)
  					printf ("Invalid REAL response received from host\n");
***************
*** 276,325 ****
  	int c;
  
- 	if (argc < 2)
- 		return ERROR;
- 
- 	for (c = 1; c < argc; c++) {
- 		if (strcmp ("-to", argv[c]) == 0)
- 			strcpy (argv[c], "-t");
- 		else if (strcmp ("-wt", argv[c]) == 0)
- 			strcpy (argv[c], "-w");
- 		else if (strcmp ("-ct", argv[c]) == 0)
- 			strcpy (argv[c], "-c");
- 	}
- 
- 
- 
- 	c = 0;
- 	while ((c += (call_getopt (argc - c, &argv[c]))) < argc) {
- 
- 		if (is_option (argv[c]))
- 			continue;
- 
- 		if (server_address == NULL) {
- 			if (is_host (argv[c])) {
- 				server_address = argv[c];
- 			}
- 			else {
- 				usage ("Invalid host name");
- 			}
- 		}
- 	}
- 
- 	if (server_expect == NULL)
- 		server_expect = strscpy (NULL, EXPECT);
- 
- 	return validate_arguments ();
- }
- 
- 
- 
- 
- 
- 
- int
- call_getopt (int argc, char **argv)
- {
- 	int c, i = 0;
- 
  #ifdef HAVE_GETOPT_H
  	int option_index = 0;
--- 275,278 ----
***************
*** 340,343 ****
--- 293,308 ----
  #endif
  
+ 	if (argc < 2)
+ 		return ERROR;
+ 
+ 	for (c = 1; c < argc; c++) {
+ 		if (strcmp ("-to", argv[c]) == 0)
+ 			strcpy (argv[c], "-t");
+ 		else if (strcmp ("-wt", argv[c]) == 0)
+ 			strcpy (argv[c], "-w");
+ 		else if (strcmp ("-ct", argv[c]) == 0)
+ 			strcpy (argv[c], "-c");
+ 	}
+ 
  	while (1) {
  #ifdef HAVE_GETOPT_H
***************
*** 349,378 ****
  #endif
  
! 		i++;
! 
! 		if (c == -1 || c == EOF || c == 1)
  			break;
  
  		switch (c) {
- 		case 'I':
- 		case 'H':
- 		case 'e':
- 		case 'u':
- 		case 'p':
- 		case 'w':
- 		case 'c':
- 		case 't':
- 			i++;
- 		}
- 
- 		switch (c) {
  		case 'I':									/* hostname */
- 			if (is_host (optarg)) {
- 				server_address = optarg;
- 			}
- 			else {
- 				usage ("Invalid host name\n");
- 			}
- 			break;
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
--- 314,322 ----
  #endif
  
! 		if (c == -1 || c == EOF)
  			break;
  
  		switch (c) {
  		case 'I':									/* hostname */
  		case 'H':									/* hostname */
  			if (is_host (optarg)) {
***************
*** 386,390 ****
  			server_expect = optarg;
  			break;
! 		case 'u':									/* string to expect in response header */
  			server_url = optarg;
  			break;
--- 330,334 ----
  			server_expect = optarg;
  			break;
! 		case 'u':									/* server URL */
  			server_url = optarg;
  			break;
***************
*** 436,440 ****
  		}
  	}
! 	return i;
  }
  
--- 380,395 ----
  		}
  	}
! 
! 	c = optind;
! 	if (strlen(server_address) == 0 && argc > c) {
! 		if (is_host (argv[c])) {
! 			server_address = argv[c++];
! 		}
! 		else {
! 			usage ("Invalid host name");
! 		}
! 	}
! 
! 	return validate_arguments ();
  }
  

Index: check_ups.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ups.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** check_ups.c	9 Nov 2002 11:37:14 -0000	1.3
--- check_ups.c	12 Nov 2002 11:26:01 -0000	1.4
***************
*** 83,87 ****
  
  int server_port = PORT;
! char *server_address = NULL;
  char *ups_name = NULL;
  double warning_value = 0.0L;
--- 83,87 ----
  
  int server_port = PORT;
! char *server_address = "127.0.0.1";
  char *ups_name = NULL;
  double warning_value = 0.0L;
***************
*** 104,108 ****
  
  int process_arguments (int, char **);
- int call_getopt (int, char **);
  int validate_arguments (void);
  void print_help (void);
--- 104,107 ----
***************
*** 548,562 ****
  
  
! 	if (server_address == NULL) {
! 		if (optind >= argc) {
! 			server_address = strscpy (NULL, "127.0.0.1");
! 		}
! 		else if (is_host (argv[optind])) {
  			server_address = argv[optind++];
! 		}
! 		else {
  			usage ("Invalid host name");
- 		}
  	}
  	return validate_arguments();
  }
--- 547,557 ----
  
  
! 	if (server_address == NULL && argc > optind) {
! 		if (is_host (argv[optind]))
  			server_address = argv[optind++];
! 		else
  			usage ("Invalid host name");
  	}
+ 
  	return validate_arguments();
  }





More information about the Commits mailing list