Преглед изворни кода

convert PROGANE from a define to a const char

git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@238 f882894a-f735-0410-b71e-b25c423dba1c
Karl DeBisschop пре 23 година
родитељ
комит
0c3386274e

+ 8 - 10
plugins/check_by_ssh.c

@@ -22,7 +22,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
  
  
-#define PROGRAM check_by_ssh
+const char *progname = "check_by_ssh";
 #define DESCRIPTION "Run checks on a remote system using ssh, wrapping the proper timeout around the ssh invocation."
 #define DESCRIPTION "Run checks on a remote system using ssh, wrapping the proper timeout around the ssh invocation."
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
 #define EMAIL "karl@debisschop.net"
 #define EMAIL "karl@debisschop.net"
@@ -34,11 +34,9 @@
 #include "utils.h"
 #include "utils.h"
 #include <time.h>
 #include <time.h>
 
 
-#define PROGNAME "check_by_ssh"
-
 int process_arguments (int, char **);
 int process_arguments (int, char **);
 int validate_arguments (void);
 int validate_arguments (void);
-void print_help (char *command_name);
+void print_help (const char *command_name);
 void print_usage (void);
 void print_usage (void);
 
 
 
 
@@ -223,10 +221,10 @@ process_arguments (int argc, char **argv)
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
-			print_help (PROGNAME);
+			print_help (progname);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v':									/* help */
 		case 'v':									/* help */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -286,7 +284,7 @@ process_arguments (int argc, char **argv)
 	c = optind;
 	c = optind;
 	if (hostname == NULL) {
 	if (hostname == NULL) {
 		if (!is_host (argv[c]))
 		if (!is_host (argv[c]))
-			terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", PROGNAME, argv[c]);
+			terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", progname, argv[c]);
 		hostname = argv[c++];
 		hostname = argv[c++];
 	}
 	}
 
 
@@ -317,10 +315,10 @@ validate_arguments (void)
 		return ERROR;
 		return ERROR;
 
 
 	if (passive && commands != services)
 	if (passive && commands != services)
-		terminate (STATE_UNKNOWN, "%s: In passive mode, you must provide a service name for each command.\n", PROGNAME);
+		terminate (STATE_UNKNOWN, "%s: In passive mode, you must provide a service name for each command.\n", progname);
 
 
 	if (passive && host_shortname == NULL)
 	if (passive && host_shortname == NULL)
-		terminate (STATE_UNKNOWN, "%s: In passive mode, you must provide the host short name from the nagios configs.\n", PROGNAME);
+		terminate (STATE_UNKNOWN, "%s: In passive mode, you must provide the host short name from the nagios configs.\n", progname);
 
 
 	return OK;
 	return OK;
 }
 }
@@ -330,7 +328,7 @@ validate_arguments (void)
 
 
 
 
 void
 void
-print_help (char *cmd)
+print_help (const char *cmd)
 {
 {
 	print_revision (cmd, "$Revision$");
 	print_revision (cmd, "$Revision$");
 
 

+ 4 - 4
plugins/check_dig.c

@@ -25,7 +25,7 @@
 #include "utils.h"
 #include "utils.h"
 #include "popen.h"
 #include "popen.h"
 
 
-#define PROGNAME "check_dig"
+const char *progname = "check_dig";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "2000-2002"
 #define COPYRIGHT "2000-2002"
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
@@ -197,7 +197,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -240,7 +240,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
@@ -272,5 +272,5 @@ print_usage (void)
 	printf
 	printf
 		("Usage: %s -H host -l lookup [-t timeout] [-v]\n"
 		("Usage: %s -H host -l lookup [-t timeout] [-v]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }

+ 4 - 4
plugins/check_disk.c

@@ -45,7 +45,7 @@ int check_disk (int usp, int free_disk);
 void print_help (void);
 void print_help (void);
 void print_usage (void);
 void print_usage (void);
 
 
-const char *PROGNAME = "check_disk";
+const char *progname = "check_disk";
 
 
 int w_df = -1;
 int w_df = -1;
 int c_df = -1;
 int c_df = -1;
@@ -252,7 +252,7 @@ process_arguments (int argc, char **argv)
  			exclude_device = optarg;
  			exclude_device = optarg;
  			break;
  			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -323,7 +323,7 @@ check_disk (usp, free_disk)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		 "This plugin will check the percent of used disk space on a mounted\n"
 		 "This plugin will check the percent of used disk space on a mounted\n"
@@ -362,5 +362,5 @@ print_usage (void)
 	printf
 	printf
 		("Usage: %s -w limit -c limit [-p path | -x device] [-t timeout] [-m] [-e] [--verbose]\n"
 		("Usage: %s -w limit -c limit [-p path | -x device] [-t timeout] [-m] [-e] [--verbose]\n"
 		 "       %s (-h|--help)\n"
 		 "       %s (-h|--help)\n"
-		 "       %s (-V|--version)\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s (-V|--version)\n", progname, progname, progname);
 }
 }

+ 5 - 5
plugins/check_dns.c

@@ -48,7 +48,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_dns"
+const char *progname = "check_dns";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "2000-2002"
 #define COPYRIGHT "2000-2002"
 
 
@@ -292,14 +292,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?': /* args not parsable */
 		case '?': /* args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", PROGNAME, optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h': /* help */
 		case 'h': /* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V': /* version */
 		case 'V': /* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v': /* version */
 		case 'v': /* version */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -388,13 +388,13 @@ void
 print_usage (void)
 print_usage (void)
 {
 {
 	printf ("Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n" "       %s --help\n"
 	printf ("Usage: %s -H host [-s server] [-a expected-address] [-t timeout]\n" "       %s --help\n"
-					"       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+					"       %s --version\n", progname, progname, progname);
 }
 }
 
 
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n");
 	printf ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n");
 	print_usage ();
 	print_usage ();
 	printf
 	printf

+ 6 - 4
plugins/check_dummy.c

@@ -37,8 +37,10 @@
 #include "common.h"
 #include "common.h"
 #include "utils.h"
 #include "utils.h"
 
 
-void print_help (char *);
-void print_usage (char *);
+const char *progname = "check_dummy";
+
+void print_help (const char *);
+void print_usage (const char *);
 
 
 int
 int
 main (int argc, char **argv)
 main (int argc, char **argv)
@@ -82,7 +84,7 @@ main (int argc, char **argv)
 }
 }
 
 
 void
 void
-print_help (char *cmd)
+print_help (const char *cmd)
 {
 {
 	print_revision (cmd, "$Revision$");
 	print_revision (cmd, "$Revision$");
 	printf ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"
 	printf ("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"
@@ -94,7 +96,7 @@ print_help (char *cmd)
 }
 }
 
 
 void
 void
-print_usage (char *cmd)
+print_usage (const char *cmd)
 {
 {
 	printf ("Usage: %s <integer state>\n", cmd);
 	printf ("Usage: %s <integer state>\n", cmd);
 }
 }

+ 7 - 7
plugins/check_fping.c

@@ -32,7 +32,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_fping"
+const char *progname = "check_fping";
 #define PACKET_COUNT 1
 #define PACKET_COUNT 1
 #define PACKET_SIZE 56
 #define PACKET_SIZE 56
 #define UNKNOWN_PACKET_LOSS 200	/* 200% */
 #define UNKNOWN_PACKET_LOSS 200	/* 200% */
@@ -243,14 +243,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v':									/* verbose mode */
 		case 'v':									/* verbose mode */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -325,12 +325,12 @@ get_threshold (char *arg, char *rv[2])
 		arg1[strcspn (arg1, ",:")] = 0;
 		arg1[strcspn (arg1, ",:")] = 0;
 		if (strstr (arg1, "%") && strstr (arg2, "%"))
 		if (strstr (arg1, "%") && strstr (arg2, "%"))
 			terminate (STATE_UNKNOWN,
 			terminate (STATE_UNKNOWN,
-								 "%s: Only one threshold may be packet loss (%s)\n", PROGNAME,
+								 "%s: Only one threshold may be packet loss (%s)\n", progname,
 								 arg);
 								 arg);
 		if (!strstr (arg1, "%") && !strstr (arg2, "%"))
 		if (!strstr (arg1, "%") && !strstr (arg2, "%"))
 			terminate (STATE_UNKNOWN,
 			terminate (STATE_UNKNOWN,
 								 "%s: Only one threshold must be packet loss (%s)\n",
 								 "%s: Only one threshold must be packet loss (%s)\n",
-								 PROGNAME, arg);
+								 progname, arg);
 	}
 	}
 
 
 	if (arg2 && strstr (arg2, "%")) {
 	if (arg2 && strstr (arg2, "%")) {
@@ -358,7 +358,7 @@ get_threshold (char *arg, char *rv[2])
 void
 void
 print_usage (void)
 print_usage (void)
 {
 {
-	printf ("Usage: %s <host_address>\n", PROGNAME);
+	printf ("Usage: %s <host_address>\n", progname);
 }
 }
 
 
 
 
@@ -369,7 +369,7 @@ void
 print_help (void)
 print_help (void)
 {
 {
 
 
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 
 
 	printf
 	printf
 		("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n\n"
 		("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n\n"

+ 4 - 4
plugins/check_hpjd.c

@@ -65,7 +65,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_hpjd"
+const char *progname = "check_hpjd"
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "2000-2002"
 #define COPYRIGHT "2000-2002"
 
 
@@ -438,7 +438,7 @@ process_arguments (int argc, char **argv)
 			community = optarg;
 			community = optarg;
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -482,7 +482,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		 "This plugin tests the STATUS of an HP printer with a JetDirect card.\n"
 		 "This plugin tests the STATUS of an HP printer with a JetDirect card.\n"
@@ -510,7 +510,7 @@ print_usage (void)
 	printf
 	printf
 		("Usage: %s -H host [-C community]\n"
 		("Usage: %s -H host [-C community]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }
 
 
 
 

+ 4 - 4
plugins/check_http.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_http"
+const char *progname = "check_http";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2001"
 #define COPYRIGHT "1999-2001"
 #define AUTHORS "Ethan Galstad/Karl DeBisschop"
 #define AUTHORS "Ethan Galstad/Karl DeBisschop"
@@ -328,7 +328,7 @@ process_arguments (int argc, char **argv)
 			exit (STATE_OK);
 			exit (STATE_OK);
 			break;
 			break;
 		case 'V': /* version */
 		case 'V': /* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 			break;
 			break;
 		case 't': /* timeout period */
 		case 't': /* timeout period */
@@ -1058,7 +1058,7 @@ my_close (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHORS, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHORS, EMAIL, SUMMARY);
@@ -1083,5 +1083,5 @@ print_usage (void)
 	        " %s -h for detailed help\n"
 	        " %s -h for detailed help\n"
 	        " %s -V for version information\n",
 	        " %s -V for version information\n",
 #endif
 #endif
-	PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+	progname, OPTIONS, progname, progname);
 }
 }

+ 8 - 8
plugins/check_ldap.c

@@ -20,7 +20,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_ldap"
+const char *progname = "check_ldap";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 
 
 #include "config.h"
 #include "config.h"
@@ -35,8 +35,8 @@
 
 
 int process_arguments (int, char **);
 int process_arguments (int, char **);
 int validate_arguments (void);
 int validate_arguments (void);
-static void print_help (void);
-static void print_usage (void);
+void print_help (void);
+void print_usage (void);
 
 
 char ld_defattr[] = "(objectclass=*)";
 char ld_defattr[] = "(objectclass=*)";
 char *ld_attr = ld_defattr;
 char *ld_attr = ld_defattr;
@@ -165,7 +165,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 't':									/* timeout period */
 		case 't':									/* timeout period */
 			if (!is_intnonneg (optarg))
 			if (!is_intnonneg (optarg))
@@ -225,10 +225,10 @@ validate_arguments ()
 
 
 
 
 /* function print_help */
 /* function print_help */
-static void
+void
 print_help ()
 print_help ()
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n"
 		("Copyright (c) 1999 Didi Rieder (adrieder@sbox.tu-graz.ac.at)\n"
 		 "License: GPL\n" "\n");
 		 "License: GPL\n" "\n");
@@ -248,11 +248,11 @@ print_help ()
 }
 }
 
 
 
 
-static void
+void
 print_usage ()
 print_usage ()
 {
 {
 	printf
 	printf
 		("Usage: %s -H <host> -b <base_dn> -p <port> [-a <attr>] [-D <binddn>]\n"
 		("Usage: %s -H <host> -b <base_dn> -p <port> [-a <attr>] [-D <binddn>]\n"
 		 "         [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
 		 "         [-P <password>] [-w <warn_time>] [-c <crit_time>] [-t timeout]\n"
-		 "(Note: all times are in seconds.)\n", PROGNAME);
+		 "(Note: all times are in seconds.)\n", progname);
 }
 }

+ 3 - 3
plugins/check_load.c

@@ -44,7 +44,7 @@
 
 
 #endif
 #endif
 
 
-#define PROGNAME "check_load"
+const char *progname = "check_load";
 
 
 int process_arguments (int argc, char **argv);
 int process_arguments (int argc, char **argv);
 int validate_arguments (void);
 int validate_arguments (void);
@@ -212,7 +212,7 @@ process_arguments (int argc, char **argv)
 				usage ("Critical threshold must be float or float triplet!\n");
 				usage ("Critical threshold must be float or float triplet!\n");
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -303,7 +303,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n"
 		("Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>\n"
 		 "Copyright (c) 2000 Karl DeBisschop\n\n"
 		 "Copyright (c) 2000 Karl DeBisschop\n\n"

+ 5 - 5
plugins/check_mrtg.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_mrtg"
+const char *progname = "check_mrtg";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 
 
@@ -287,7 +287,7 @@ process_arguments (int argc, char **argv)
 			units_label = optarg;
 			units_label = optarg;
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -308,7 +308,7 @@ process_arguments (int argc, char **argv)
 		else
 		else
 			terminate (STATE_UNKNOWN,
 			terminate (STATE_UNKNOWN,
 			           "%s is not a valid expiration time\nUse '%s -h' for additional help\n",
 			           "%s is not a valid expiration time\nUse '%s -h' for additional help\n",
-			           argv[c], PROGNAME);
+			           argv[c], progname);
 	}
 	}
 
 
 	if (argc > c && strcmp (argv[c], "MAX") == 0) {
 	if (argc > c && strcmp (argv[c], "MAX") == 0) {
@@ -359,7 +359,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY);
 	printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY);
 	print_usage ();
 	print_usage ();
 	printf ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n");
 	printf ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n");
@@ -377,5 +377,5 @@ print_usage (void)
 					" %s -h for detailed help\n"
 					" %s -h for detailed help\n"
 					" %s -V for version information\n",
 					" %s -V for version information\n",
 #endif
 #endif
-					PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+					progname, OPTIONS, progname, progname);
 }
 }

+ 4 - 4
plugins/check_mrtgtraf.c

@@ -52,7 +52,7 @@
 #include "common.h"
 #include "common.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_mrtgtraf"
+const char *progname = "check_mrtgtraf";
 
 
 int process_arguments (int, char **);
 int process_arguments (int, char **);
 int validate_arguments (void);
 int validate_arguments (void);
@@ -292,7 +292,7 @@ process_arguments (int argc, char **argv)
 							&outgoing_warning_threshold);
 							&outgoing_warning_threshold);
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -356,7 +356,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n"
 		 "This plugin tests the UPS service on the specified host.\n\n");
 		 "This plugin tests the UPS service on the specified host.\n\n");
@@ -390,5 +390,5 @@ print_usage (void)
 		("Usage: %s  -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n"
 		("Usage: %s  -F <log_file> -a <AVG | MAX> -v <variable> -w <warning_pair> -c <critical_pair>\n"
 		 "            [-e expire_minutes] [-t timeout] [-v]\n"
 		 "            [-e expire_minutes] [-t timeout] [-v]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }

+ 4 - 4
plugins/check_mysql.c

@@ -14,7 +14,7 @@
 * This plugin is for testing a mysql server.
 * This plugin is for testing a mysql server.
 ******************************************************************************/
 ******************************************************************************/
 
 
-#define PROGNAME "check_mysql"
+const char *progname = "check_mysql"
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 
 
@@ -178,7 +178,7 @@ process_arguments (int argc, char **argv)
 			db_port = atoi (optarg);
 			db_port = atoi (optarg);
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -230,7 +230,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) 2000 Didi Rieder/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Didi Rieder/Karl DeBisschop\n\n"
 		 "This plugin is for testing a mysql server.\n");
 		 "This plugin is for testing a mysql server.\n");
@@ -267,5 +267,5 @@ print_usage (void)
 	printf
 	printf
 		("Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"
 		("Usage: %s [-d database] [-H host] [-P port] [-u user] [-p password]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }

+ 9 - 9
plugins/check_nagios.c

@@ -30,7 +30,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-const char *PROGNAME = "check_nagios";
+const char *progname = "check_nagios";
 
 
 int process_arguments (int, char **);
 int process_arguments (int, char **);
 void print_usage (void);
 void print_usage (void);
@@ -166,7 +166,7 @@ process_arguments (int argc, char **argv)
 		else
 		else
 			terminate (STATE_UNKNOWN,
 			terminate (STATE_UNKNOWN,
 								 "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n",
 								 "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n",
-								 PROGNAME);
+								 progname);
 		process_string = argv[3];
 		process_string = argv[3];
 		return OK;
 		return OK;
 	}
 	}
@@ -183,14 +183,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %c\n\n", PROGNAME, optopt);
+			printf ("%s: Unknown argument: %c\n\n", progname, optopt);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'F':									/* hostname */
 		case 'F':									/* hostname */
 			status_log = optarg;
 			status_log = optarg;
@@ -204,7 +204,7 @@ process_arguments (int argc, char **argv)
 			else
 			else
 				terminate (STATE_UNKNOWN,
 				terminate (STATE_UNKNOWN,
 									 "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n",
 									 "Expiration time must be an integer (seconds)\nType '%s -h' for additional help\n",
-									 PROGNAME);
+									 progname);
 			break;
 			break;
 		}
 		}
 	}
 	}
@@ -213,11 +213,11 @@ process_arguments (int argc, char **argv)
 	if (status_log == NULL)
 	if (status_log == NULL)
 		terminate (STATE_UNKNOWN,
 		terminate (STATE_UNKNOWN,
 							 "You must provide the status_log\nType '%s -h' for additional help\n",
 							 "You must provide the status_log\nType '%s -h' for additional help\n",
-							 PROGNAME);
+							 progname);
 	else if (process_string == NULL)
 	else if (process_string == NULL)
 		terminate (STATE_UNKNOWN,
 		terminate (STATE_UNKNOWN,
 							 "You must provide a process string\nType '%s -h' for additional help\n",
 							 "You must provide a process string\nType '%s -h' for additional help\n",
-							 PROGNAME);
+							 progname);
 
 
 	return OK;
 	return OK;
 }
 }
@@ -231,7 +231,7 @@ print_usage (void)
 {
 {
 	printf
 	printf
 		("Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n",
 		("Usage: %s -F <status log file> -e <expire_minutes> -C <process_string>\n",
-		 PROGNAME);
+		 progname);
 }
 }
 
 
 
 
@@ -241,7 +241,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		 "This plugin attempts to check the status of the Nagios process on the local\n"
 		 "This plugin attempts to check the status of the Nagios process on the local\n"

+ 6 - 8
plugins/check_nwstat.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_nwstat"
+const char *progname = "check_nwstat";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 
 
@@ -128,8 +128,6 @@ int check_netware_version=FALSE;
 unsigned long vars_to_check=CHECK_NONE;
 unsigned long vars_to_check=CHECK_NONE;
 int sap_number=-1;
 int sap_number=-1;
 
 
-#define PROGNAME "check_nwstat"
-
 int process_arguments(int, char **);
 int process_arguments(int, char **);
 void print_usage(void);
 void print_usage(void);
 void print_help(void);
 void print_help(void);
@@ -674,14 +672,14 @@ int process_arguments(int argc, char **argv){
 		switch (c)
 		switch (c)
 			{
 			{
 			case '?': /* print short usage statement if args not parsable */
 			case '?': /* print short usage statement if args not parsable */
-				printf("%s: Unknown argument: %s\n\n",my_basename(argv[0]),optarg);
+				printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 				print_usage();
 				print_usage();
 				exit(STATE_UNKNOWN);
 				exit(STATE_UNKNOWN);
 			case 'h': /* help */
 			case 'h': /* help */
 				print_help();
 				print_help();
 				exit(STATE_OK);
 				exit(STATE_OK);
 			case 'V': /* version */
 			case 'V': /* version */
-				print_revision(my_basename(argv[0]),"$Revision$");
+				print_revision(progname,"$Revision$");
 				exit(STATE_OK);
 				exit(STATE_OK);
 			case 'H': /* hostname */
 			case 'H': /* hostname */
 				server_address=optarg;
 				server_address=optarg;
@@ -693,7 +691,7 @@ int process_arguments(int argc, char **argv){
 				if (is_intnonneg(optarg))
 				if (is_intnonneg(optarg))
 					server_port=atoi(optarg);
 					server_port=atoi(optarg);
 				else
 				else
-					terminate(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",PROGNAME);
+					terminate(STATE_UNKNOWN,"Server port an integer (seconds)\nType '%s -h' for additional help\n",progname);
 				break;
 				break;
 			case 'v':
 			case 'v':
 				if(strlen(optarg)<3)
 				if(strlen(optarg)<3)
@@ -806,12 +804,12 @@ void print_usage(void)
 		 " %s -h for detailed help\n"
 		 " %s -h for detailed help\n"
 		 " %s -V for version information\n",
 		 " %s -V for version information\n",
 #endif
 #endif
-		 PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+		 progname, OPTIONS, progname, progname);
 }
 }
 
 
 void print_help(void)
 void print_help(void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY);
 	printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY);
 	print_usage();
 	print_usage();
 	printf
 	printf

+ 6 - 6
plugins/check_overcr.c

@@ -58,7 +58,7 @@
 
 
 #define PORT	2000
 #define PORT	2000
 
 
-#define PROGNAME "check_overcr"
+const char *progname = "check_overcr";
 
 
 char *server_address = NULL;
 char *server_address = NULL;
 int server_port = PORT;
 int server_port = PORT;
@@ -367,14 +367,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'H':									/* hostname */
 		case 'H':									/* hostname */
 			server_address = optarg;
 			server_address = optarg;
@@ -385,7 +385,7 @@ process_arguments (int argc, char **argv)
 			else
 			else
 				terminate (STATE_UNKNOWN,
 				terminate (STATE_UNKNOWN,
 									 "Server port an integer (seconds)\nType '%s -h' for additional help\n",
 									 "Server port an integer (seconds)\nType '%s -h' for additional help\n",
-									 PROGNAME);
+									 progname);
 			break;
 			break;
 		case 'v':									/* variable */
 		case 'v':									/* variable */
 			if (strcmp (optarg, "LOAD1") == 0)
 			if (strcmp (optarg, "LOAD1") == 0)
@@ -438,7 +438,7 @@ print_usage (void)
 {
 {
 	printf
 	printf
 		("Usage: %s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n",
 		("Usage: %s -H host [-p port] [-v variable] [-w warning] [-c critical] [-t timeout]\n",
-		 PROGNAME);
+		 progname);
 }
 }
 
 
 
 
@@ -448,7 +448,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		 "This plugin attempts to contact the Over-CR collector daemon running on the\n"
 		 "This plugin attempts to contact the Over-CR collector daemon running on the\n"

+ 5 - 5
plugins/check_pgsql.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_pgsql"
+const char *progname = "check_pgsql"
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2001"
 #define COPYRIGHT "1999-2001"
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
@@ -122,7 +122,7 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
 <manvolnum>5<manvolnum>
 <manvolnum>5<manvolnum>
 </refmeta>
 </refmeta>
 <refnamdiv>
 <refnamdiv>
-<refname>&PROGNAME;</refname>
+<refname>&progname;</refname>
 <refpurpose>&SUMMARY;</refpurpose>
 <refpurpose>&SUMMARY;</refpurpose>
 </refnamdiv>
 </refnamdiv>
 </refentry>
 </refentry>
@@ -218,7 +218,7 @@ main (int argc, char **argv)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
@@ -235,7 +235,7 @@ print_usage (void)
 	printf ("Usage:\n" " %s %s\n"
 	printf ("Usage:\n" " %s %s\n"
 					" %s (-h | --help) for detailed help\n"
 					" %s (-h | --help) for detailed help\n"
 					" %s (-V | --version) for version information\n",
 					" %s (-V | --version) for version information\n",
-					PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+					progname, OPTIONS, progname, progname);
 }
 }
 
 
 
 
@@ -281,7 +281,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':     /* version */
 		case 'V':     /* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 't':     /* timeout period */
 		case 't':     /* timeout period */
 			if (!is_integer (optarg))
 			if (!is_integer (optarg))

+ 4 - 4
plugins/check_ping.c

@@ -10,7 +10,7 @@
 *
 *
 *****************************************************************************/
 *****************************************************************************/
 
 
-#define PROGNAME "check_ping"
+const char *progname = "check_ping";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2001"
 #define COPYRIGHT "1999-2001"
 #define AUTHOR "Ethan Galstad/Karl DeBisschop"
 #define AUTHOR "Ethan Galstad/Karl DeBisschop"
@@ -189,7 +189,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':	/* version */
 		case 'V':	/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 't':	/* timeout period */
 		case 't':	/* timeout period */
 			timeout_interval = atoi (optarg);
 			timeout_interval = atoi (optarg);
@@ -482,13 +482,13 @@ print_usage (void)
 					" %s -h for detailed help\n"
 					" %s -h for detailed help\n"
 					" %s -V for version information\n",
 					" %s -V for version information\n",
 #endif
 #endif
-					PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+					progname, OPTIONS, progname, progname);
 }
 }
 
 
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);

+ 7 - 7
plugins/check_procs.c

@@ -34,7 +34,7 @@
 *
 *
 ******************************************************************************/
 ******************************************************************************/
 
 
-#define PROGNAME "check_snmp"
+const char *progname = "check_snmp";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -298,12 +298,12 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 't':									/* timeout period */
 		case 't':									/* timeout period */
 			if (!is_integer (optarg)) {
 			if (!is_integer (optarg)) {
 				printf ("%s: Timeout Interval must be an integer!\n\n",
 				printf ("%s: Timeout Interval must be an integer!\n\n",
-				        my_basename (argv[0]));
+				        progname);
 				print_usage ();
 				print_usage ();
 				exit (STATE_UNKNOWN);
 				exit (STATE_UNKNOWN);
 			}
 			}
@@ -325,7 +325,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			else {
 			else {
 				printf ("%s: Critical Process Count must be an integer!\n\n",
 				printf ("%s: Critical Process Count must be an integer!\n\n",
-				        my_basename (argv[0]));
+				        progname);
 				print_usage ();
 				print_usage ();
 				exit (STATE_UNKNOWN);
 				exit (STATE_UNKNOWN);
 			}
 			}
@@ -345,7 +345,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			else {
 			else {
 				printf ("%s: Warning Process Count must be an integer!\n\n",
 				printf ("%s: Warning Process Count must be an integer!\n\n",
-				        my_basename (argv[0]));
+				        progname);
 				print_usage ();
 				print_usage ();
 				exit (STATE_UNKNOWN);
 				exit (STATE_UNKNOWN);
 			}
 			}
@@ -356,7 +356,7 @@ process_arguments (int argc, char **argv)
 				break;
 				break;
 			}
 			}
 			printf ("%s: Parent Process ID must be an integer!\n\n",
 			printf ("%s: Parent Process ID must be an integer!\n\n",
-			        my_basename (argv[0]));
+			        progname);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 's':									/* status */
 		case 's':									/* status */
@@ -462,7 +462,7 @@ if (wmax >= 0 && wmin == -1)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);

+ 6 - 6
plugins/check_radius.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_radius"
+const char *progname = "check_radius"
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2001"
 #define COPYRIGHT "1999-2001"
 #define AUTHORS "Robert August Vincent II/Karl DeBisschop"
 #define AUTHORS "Robert August Vincent II/Karl DeBisschop"
@@ -112,7 +112,7 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
 <manvolnum>5<manvolnum>
 <manvolnum>5<manvolnum>
 </refmeta>
 </refmeta>
 <refnamdiv>
 <refnamdiv>
-<refname>&PROGNAME;</refname>
+<refname>&progname;</refname>
 <refpurpose>&SUMMARY;</refpurpose>
 <refpurpose>&SUMMARY;</refpurpose>
 </refnamdiv>
 </refnamdiv>
 </refentry>
 </refentry>
@@ -264,14 +264,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (OK);
 			exit (OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (OK);
 			exit (OK);
 		case 'v':									/* verbose mode */
 		case 'v':									/* verbose mode */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -324,7 +324,7 @@ process_arguments (int argc, char **argv)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHORS, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHORS, EMAIL, SUMMARY);
@@ -347,5 +347,5 @@ print_usage (void)
 					" %s -h for detailed help\n"
 					" %s -h for detailed help\n"
 					" %s -V for version information\n",
 					" %s -V for version information\n",
 #endif
 #endif
-					PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+					progname, OPTIONS, progname, progname);
 }
 }

+ 4 - 4
plugins/check_real.c

@@ -48,7 +48,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_real"
+const char *progname = "check_real";
 
 
 #define PORT	554
 #define PORT	554
 #define EXPECT	"RTSP/1."
 #define EXPECT	"RTSP/1."
@@ -370,7 +370,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -410,7 +410,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Pedro Leite (leite@cic.ua.pt)/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Pedro Leite (leite@cic.ua.pt)/Karl DeBisschop\n\n"
 		 "This plugin tests the REAL service on the specified host.\n\n");
 		 "This plugin tests the REAL service on the specified host.\n\n");
@@ -454,7 +454,7 @@ print_usage (void)
 		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n"
 		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n"
 		 "            [-t timeout] [-v]\n"
 		 "            [-t timeout] [-v]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }
 
 
 
 

+ 4 - 4
plugins/check_smtp.c

@@ -39,7 +39,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_smtp"
+const char *progname = "check_smtp";
 
 
 #define SMTP_PORT	25
 #define SMTP_PORT	25
 #define SMTP_EXPECT     "220"
 #define SMTP_EXPECT     "220"
@@ -294,7 +294,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -340,7 +340,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Ethan Galstad/Karl DeBisschop\n\n"
 		 "This plugin test the SMTP service on the specified host.\n\n");
 		 "This plugin test the SMTP service on the specified host.\n\n");
@@ -381,5 +381,5 @@ print_usage (void)
 	printf
 	printf
 		("Usage: %s -H host [-e expect] [-p port] [-f from addr] [-w warn] [-c crit] [-t timeout] [-v]\n"
 		("Usage: %s -H host [-e expect] [-p port] [-f from addr] [-w warn] [-c crit] [-t timeout] [-v]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }

+ 5 - 6
plugins/check_snmp.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_snmp"
+const char *progname = "check_snmp";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -475,7 +475,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK); 
 			exit (STATE_OK); 
 		case 'V':	/* version */
 		case 'V':	/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v': /* verbose */
 		case 'v': /* verbose */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -753,10 +753,9 @@ validate_arguments ()
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
-		("Copyright (c) %s %s <%s>\n\n%s\n",
-		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
+		("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 	print_usage ();
 	print_usage ();
 	printf
 	printf
 		("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n" NOTES "\n", 
 		("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n" NOTES "\n", 
@@ -771,7 +770,7 @@ print_usage (void)
 		("Usage:\n" " %s %s\n"
 		("Usage:\n" " %s %s\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-V | --version) for version information\n",
 		 " %s (-V | --version) for version information\n",
-		 PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+		 progname, OPTIONS, progname, progname);
 }
 }
 
 
 
 

+ 4 - 4
plugins/check_ssh.c

@@ -15,7 +15,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_ssh"
+const char *progname = "check_ssh";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 
 
 #ifndef MSG_DONTWAIT
 #ifndef MSG_DONTWAIT
@@ -95,7 +95,7 @@ process_arguments (int argc, char **argv)
 		case '?':									/* help */
 		case '?':									/* help */
 			usage ("");
 			usage ("");
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -238,7 +238,7 @@ ssh_connect (char *haddr, short hport)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf ("Copyright (c) 1999 Remi Paulmier (remi@sinfomic.fr)\n\n");
 	printf ("Copyright (c) 1999 Remi Paulmier (remi@sinfomic.fr)\n\n");
 	print_usage ();
 	print_usage ();
 	printf ("by default, port is %d\n", SSH_DFL_PORT);
 	printf ("by default, port is %d\n", SSH_DFL_PORT);
@@ -251,7 +251,7 @@ print_usage (void)
 		("Usage:\n"
 		("Usage:\n"
 		 " %s -t [timeout] -p [port] <host>\n"
 		 " %s -t [timeout] -p [port] <host>\n"
 		 " %s -V prints version info\n"
 		 " %s -V prints version info\n"
-		 " %s -h prints more detailed help\n", PROGNAME, PROGNAME, PROGNAME);
+		 " %s -h prints more detailed help\n", progname, progname, progname);
 }
 }
 
 
 /* end of check_ssh.c */
 /* end of check_ssh.c */

+ 4 - 4
plugins/check_swap.c

@@ -29,7 +29,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_swap"
+const char *progname = "check_swap";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "2000-2002"
 #define COPYRIGHT "2000-2002"
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
@@ -267,7 +267,7 @@ process_arguments (int argc, char **argv)
 			verbose = TRUE;
 			verbose = TRUE;
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -336,7 +336,7 @@ print_usage (void)
 		 " %s [-a] -w <bytes_free> -c <bytes_free>\n"
 		 " %s [-a] -w <bytes_free> -c <bytes_free>\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-V | --version) for version information\n",
 		 " %s (-V | --version) for version information\n",
-		 PROGNAME, PROGNAME, PROGNAME, PROGNAME);
+		 progname, progname, progname, progname);
 }
 }
 
 
 
 
@@ -346,7 +346,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		("Copyright (c) %s %s <%s>\n\n%s\n", COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 	print_usage ();
 	print_usage ();

+ 16 - 16
plugins/check_tcp.c

@@ -22,7 +22,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGRAM check_tcp
+/* const char *progname = "check_tcp"; */
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define DESCRIPTION "Check a TCP port"
 #define DESCRIPTION "Check a TCP port"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -65,7 +65,7 @@ int process_arguments (int, char **);
 void print_usage (void);
 void print_usage (void);
 void print_help (void);
 void print_help (void);
 
 
-char *PROGNAME = NULL;
+char *progname = NULL;
 char *SERVICE = NULL;
 char *SERVICE = NULL;
 char *SEND = NULL;
 char *SEND = NULL;
 char *EXPECT = NULL;
 char *EXPECT = NULL;
@@ -103,7 +103,7 @@ main (int argc, char **argv)
 	struct timeval tv;
 	struct timeval tv;
 
 
 	if (strstr (argv[0], "check_udp")) {
 	if (strstr (argv[0], "check_udp")) {
-		asprintf (&PROGNAME, "check_udp");
+		asprintf (&progname, "check_udp");
 		asprintf (&SERVICE, "UDP");
 		asprintf (&SERVICE, "UDP");
 		SEND = NULL;
 		SEND = NULL;
 		EXPECT = NULL;
 		EXPECT = NULL;
@@ -112,7 +112,7 @@ main (int argc, char **argv)
 		PORT = 0;
 		PORT = 0;
 	}
 	}
 	else if (strstr (argv[0], "check_tcp")) {
 	else if (strstr (argv[0], "check_tcp")) {
-		asprintf (&PROGNAME, "check_tcp");
+		asprintf (&progname, "check_tcp");
 		asprintf (&SERVICE, "TCP");
 		asprintf (&SERVICE, "TCP");
 		SEND = NULL;
 		SEND = NULL;
 		EXPECT = NULL;
 		EXPECT = NULL;
@@ -121,7 +121,7 @@ main (int argc, char **argv)
 		PORT = 0;
 		PORT = 0;
 	}
 	}
 	else if (strstr (argv[0], "check_ftp")) {
 	else if (strstr (argv[0], "check_ftp")) {
-		asprintf (&PROGNAME, "check_ftp");
+		asprintf (&progname, "check_ftp");
 		asprintf (&SERVICE, "FTP");
 		asprintf (&SERVICE, "FTP");
 		SEND = NULL;
 		SEND = NULL;
 		asprintf (&EXPECT, "220");
 		asprintf (&EXPECT, "220");
@@ -130,7 +130,7 @@ main (int argc, char **argv)
 		PORT = 21;
 		PORT = 21;
 	}
 	}
 	else if (strstr (argv[0], "check_smtp")) {
 	else if (strstr (argv[0], "check_smtp")) {
-		asprintf (&PROGNAME, "check_smtp");
+		asprintf (&progname, "check_smtp");
 		asprintf (&SERVICE, "SMTP");
 		asprintf (&SERVICE, "SMTP");
 		SEND = NULL;
 		SEND = NULL;
 		asprintf (&EXPECT, "220");
 		asprintf (&EXPECT, "220");
@@ -139,7 +139,7 @@ main (int argc, char **argv)
 		PORT = 25;
 		PORT = 25;
 	}
 	}
 	else if (strstr (argv[0], "check_pop")) {
 	else if (strstr (argv[0], "check_pop")) {
-		asprintf (&PROGNAME, "check_pop");
+		asprintf (&progname, "check_pop");
 		asprintf (&SERVICE, "POP");
 		asprintf (&SERVICE, "POP");
 		SEND = NULL;
 		SEND = NULL;
 		asprintf (&EXPECT, "+OK");
 		asprintf (&EXPECT, "+OK");
@@ -148,7 +148,7 @@ main (int argc, char **argv)
 		PORT = 110;
 		PORT = 110;
 	}
 	}
 	else if (strstr (argv[0], "check_imap")) {
 	else if (strstr (argv[0], "check_imap")) {
-		asprintf (&PROGNAME, "check_imap");
+		asprintf (&progname, "check_imap");
 		asprintf (&SERVICE, "IMAP");
 		asprintf (&SERVICE, "IMAP");
 		SEND = NULL;
 		SEND = NULL;
 		asprintf (&EXPECT, "* OK");
 		asprintf (&EXPECT, "* OK");
@@ -158,7 +158,7 @@ main (int argc, char **argv)
 	}
 	}
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
 	else if (strstr(argv[0],"check_simap")) {
 	else if (strstr(argv[0],"check_simap")) {
-		asprintf (&PROGNAME, "check_simap");
+		asprintf (&progname, "check_simap");
 		asprintf (&SERVICE, "SIMAP");
 		asprintf (&SERVICE, "SIMAP");
 		SEND=NULL;
 		SEND=NULL;
 		asprintf (&EXPECT, "* OK");
 		asprintf (&EXPECT, "* OK");
@@ -168,7 +168,7 @@ main (int argc, char **argv)
 		PORT=993;
 		PORT=993;
 	}
 	}
 	else if (strstr(argv[0],"check_spop")) {
 	else if (strstr(argv[0],"check_spop")) {
-		asprintf (&PROGNAME, "check_spop");
+		asprintf (&progname, "check_spop");
 		asprintf (&SERVICE, "SPOP");
 		asprintf (&SERVICE, "SPOP");
 		SEND=NULL;
 		SEND=NULL;
 		asprintf (&EXPECT, "+OK");
 		asprintf (&EXPECT, "+OK");
@@ -179,7 +179,7 @@ main (int argc, char **argv)
 	}
 	}
 #endif
 #endif
 	else if (strstr (argv[0], "check_nntp")) {
 	else if (strstr (argv[0], "check_nntp")) {
-		asprintf (&PROGNAME, "check_nntp");
+		asprintf (&progname, "check_nntp");
 		asprintf (&SERVICE, "NNTP");
 		asprintf (&SERVICE, "NNTP");
 		SEND = NULL;
 		SEND = NULL;
 		EXPECT = NULL;
 		EXPECT = NULL;
@@ -387,21 +387,21 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':                 /* print short usage statement if args not parsable */
 		case '?':                 /* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':                 /* help */
 		case 'h':                 /* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':                 /* version */
 		case 'V':                 /* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v':                 /* verbose mode */
 		case 'v':                 /* verbose mode */
 			verbose = TRUE;
 			verbose = TRUE;
 			break;
 			break;
 		case 'H':                 /* hostname */
 		case 'H':                 /* hostname */
 			if (is_host (optarg) == FALSE)
 			if (is_host (optarg) == FALSE)
-				usage ("Invalid host name/address\n");
+				usage2 ("invalid host name or address", optarg);
 			server_address = optarg;
 			server_address = optarg;
 			break;
 			break;
 		case 'c':                 /* critical */
 		case 'c':                 /* critical */
@@ -479,7 +479,7 @@ print_usage (void)
 {
 {
 	printf
 	printf
 		("Usage: %s -H host -p port [-w warn_time] [-c crit_time] [-s send]\n"
 		("Usage: %s -H host -p port [-w warn_time] [-c crit_time] [-s send]\n"
-		 "         [-e expect] [-W wait] [-t to_sec] [-v]\n", PROGNAME);
+		 "         [-e expect] [-W wait] [-t to_sec] [-v]\n", progname);
 }
 }
 
 
 
 
@@ -489,7 +489,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n"
 		("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n"
 		 "This plugin tests %s connections with the specified host.\n\n",
 		 "This plugin tests %s connections with the specified host.\n\n",

+ 4 - 4
plugins/check_time.c

@@ -39,7 +39,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_time"
+const char *progname = "check_time";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -209,7 +209,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'H':									/* hostname */
 		case 'H':									/* hostname */
 			if (is_host (optarg) == FALSE)
 			if (is_host (optarg) == FALSE)
@@ -306,7 +306,7 @@ print_usage (void)
 		 "           [-W connect_time] [-C connect_time] [-t timeout]\n"
 		 "           [-W connect_time] [-C connect_time] [-t timeout]\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-h | --help) for detailed help\n"
 		 " %s (-V | --version) for version information\n",
 		 " %s (-V | --version) for version information\n",
-		 PROGNAME, PROGNAME, PROGNAME);
+		 progname, progname, progname);
 }
 }
 
 
 
 
@@ -316,7 +316,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);

+ 5 - 5
plugins/check_udp.c

@@ -41,7 +41,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_udp"
+const char *progname = "check_udp";
 
 
 int warning_time = 0;
 int warning_time = 0;
 int check_warning_time = FALSE;
 int check_warning_time = FALSE;
@@ -163,14 +163,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'v':									/* verbose mode */
 		case 'v':									/* verbose mode */
 			verbose = TRUE;
 			verbose = TRUE;
@@ -233,7 +233,7 @@ print_usage (void)
 {
 {
 	printf
 	printf
 		("Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n"
 		("Usage: %s -H <host_address> [-p port] [-w warn_time] [-c crit_time]\n"
-		 "         [-e expect] [-s send] [-t to_sec] [-v]\n", PROGNAME);
+		 "         [-e expect] [-s send] [-t to_sec] [-v]\n", progname);
 }
 }
 
 
 
 
@@ -243,7 +243,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n"
 		("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n\n"
 		 "This plugin tests an UDP connection with the specified host.\n\n");
 		 "This plugin tests an UDP connection with the specified host.\n\n");

+ 5 - 5
plugins/check_ups.c

@@ -56,7 +56,7 @@
 #include "netutils.h"
 #include "netutils.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_ups"
+const char *progname = "check_ups";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -64,7 +64,7 @@
 
 
 #define CHECK_NONE	0
 #define CHECK_NONE	0
 
 
-#define PORT	3305
+#define PORT     3493
 
 
 #define UPS_NONE     0   /* no supported options */
 #define UPS_NONE     0   /* no supported options */
 #define UPS_UTILITY  1   /* supports utility line voltage */
 #define UPS_UTILITY  1   /* supports utility line voltage */
@@ -535,7 +535,7 @@ process_arguments (int argc, char **argv)
 			}
 			}
 			break;
 			break;
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
@@ -571,7 +571,7 @@ validate_arguments (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n"
 		("Copyright (c) 2000 Tom Shields/Karl DeBisschop\n\n"
 		 "This plugin tests the UPS service on the specified host.\n"
 		 "This plugin tests the UPS service on the specified host.\n"
@@ -611,5 +611,5 @@ print_usage (void)
 		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n"
 		("Usage: %s -H host [-e expect] [-p port] [-w warn] [-c crit]\n"
 		 "            [-t timeout] [-v]\n"
 		 "            [-t timeout] [-v]\n"
 		 "       %s --help\n"
 		 "       %s --help\n"
-		 "       %s --version\n", PROGNAME, PROGNAME, PROGNAME);
+		 "       %s --version\n", progname, progname, progname);
 }
 }

+ 5 - 5
plugins/check_users.c

@@ -48,7 +48,7 @@
 #include "popen.h"
 #include "popen.h"
 #include "utils.h"
 #include "utils.h"
 
 
-#define PROGNAME "check_users"
+const char *progname = "check_users";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Ethan Galstad"
 #define AUTHOR "Ethan Galstad"
@@ -162,14 +162,14 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* print short usage statement if args not parsable */
 		case '?':									/* print short usage statement if args not parsable */
-			printf ("%s: Unknown argument: %s\n\n", PROGNAME, optarg);
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
 			print_usage ();
 			print_usage ();
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
 			print_help ();
 			print_help ();
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'c':									/* critical */
 		case 'c':									/* critical */
 			if (!is_intnonneg (optarg))
 			if (!is_intnonneg (optarg))
@@ -207,7 +207,7 @@ process_arguments (int argc, char **argv)
 void
 void
 print_usage (void)
 print_usage (void)
 {
 {
-	printf ("Usage: %s -w <users> -c <users>\n", PROGNAME);
+	printf ("Usage: %s -w <users> -c <users>\n", progname);
 }
 }
 
 
 
 
@@ -217,7 +217,7 @@ print_usage (void)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) " COPYRIGHT " " AUTHOR "(" EMAIL ")\n\n"
 		("Copyright (c) " COPYRIGHT " " AUTHOR "(" EMAIL ")\n\n"
 		 "This plugin checks the number of users currently logged in on the local\n"
 		 "This plugin checks the number of users currently logged in on the local\n"

+ 19 - 19
plugins/check_vsz.c

@@ -33,7 +33,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "check_vsz"
+const char *progname = "check_vsz";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "1999-2002"
 #define COPYRIGHT "1999-2002"
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
@@ -45,8 +45,8 @@
 #include "utils.h"
 #include "utils.h"
 
 
 int process_arguments (int argc, char **argv);
 int process_arguments (int argc, char **argv);
-void print_help (char *cmd);
-void print_usage (char *cmd);
+void print_help (const char *cmd);
+void print_usage (const char *cmd);
 
 
 int warn = -1;
 int warn = -1;
 int crit = -1;
 int crit = -1;
@@ -64,8 +64,8 @@ main (int argc, char **argv)
 	char *message = "";
 	char *message = "";
 
 
 	if (!process_arguments (argc, argv)) {
 	if (!process_arguments (argc, argv)) {
-		printf ("%s: failure parsing arguments\n", my_basename (argv[0]));
-		print_help (my_basename (argv[0]));
+		printf ("%s: failure parsing arguments\n", progname);
+		print_help (progname);
 		return STATE_UNKNOWN;
 		return STATE_UNKNOWN;
 	}
 	}
 
 
@@ -166,20 +166,20 @@ process_arguments (int argc, char **argv)
 
 
 		switch (c) {
 		switch (c) {
 		case '?':									/* help */
 		case '?':									/* help */
-			printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg);
-			print_usage (my_basename (argv[0]));
+			printf ("%s: Unknown argument: %s\n\n", progname, optarg);
+			print_usage (progname);
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		case 'h':									/* help */
 		case 'h':									/* help */
-			print_help (my_basename (argv[0]));
+			print_help (progname);
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'V':									/* version */
 		case 'V':									/* version */
-			print_revision (my_basename (argv[0]), "$Revision$");
+			print_revision (progname, "$Revision$");
 			exit (STATE_OK);
 			exit (STATE_OK);
 		case 'c':									/* critical threshold */
 		case 'c':									/* critical threshold */
 			if (!is_intnonneg (optarg)) {
 			if (!is_intnonneg (optarg)) {
 				printf ("%s: critical threshold must be an integer: %s\n",
 				printf ("%s: critical threshold must be an integer: %s\n",
-								my_basename (argv[0]), optarg);
-				print_usage (my_basename (argv[0]));
+								progname, optarg);
+				print_usage (progname);
 				exit (STATE_UNKNOWN);
 				exit (STATE_UNKNOWN);
 			}
 			}
 			crit = atoi (optarg);
 			crit = atoi (optarg);
@@ -187,8 +187,8 @@ process_arguments (int argc, char **argv)
 		case 'w':									/* warning threshold */
 		case 'w':									/* warning threshold */
 			if (!is_intnonneg (optarg)) {
 			if (!is_intnonneg (optarg)) {
 				printf ("%s: warning threshold must be an integer: %s\n",
 				printf ("%s: warning threshold must be an integer: %s\n",
-								my_basename (argv[0]), optarg);
-				print_usage (my_basename (argv[0]));
+								progname, optarg);
+				print_usage (progname);
 				exit (STATE_UNKNOWN);
 				exit (STATE_UNKNOWN);
 			}
 			}
 			warn = atoi (optarg);
 			warn = atoi (optarg);
@@ -203,8 +203,8 @@ process_arguments (int argc, char **argv)
 	if (warn == -1) {
 	if (warn == -1) {
 		if (!is_intnonneg (argv[c])) {
 		if (!is_intnonneg (argv[c])) {
 			printf ("%s: critical threshold must be an integer: %s\n",
 			printf ("%s: critical threshold must be an integer: %s\n",
-							PROGNAME, argv[c]);
-			print_usage (PROGNAME);
+							progname, argv[c]);
+			print_usage (progname);
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		}
 		}
 		warn = atoi (argv[c++]);
 		warn = atoi (argv[c++]);
@@ -213,8 +213,8 @@ process_arguments (int argc, char **argv)
 	if (crit == -1) {
 	if (crit == -1) {
 		if (!is_intnonneg (argv[c])) {
 		if (!is_intnonneg (argv[c])) {
 			printf ("%s: critical threshold must be an integer: %s\n",
 			printf ("%s: critical threshold must be an integer: %s\n",
-							PROGNAME, argv[c]);
-			print_usage (PROGNAME);
+							progname, argv[c]);
+			print_usage (progname);
 			exit (STATE_UNKNOWN);
 			exit (STATE_UNKNOWN);
 		}
 		}
 		crit = atoi (argv[c++]);
 		crit = atoi (argv[c++]);
@@ -227,14 +227,14 @@ process_arguments (int argc, char **argv)
 }
 }
 
 
 void
 void
-print_usage (char *cmd)
+print_usage (const char *cmd)
 {
 {
 	printf ("Usage: %s -w <wsize> -c <csize> [-C command]\n"
 	printf ("Usage: %s -w <wsize> -c <csize> [-C command]\n"
 					"       %s --help\n" "       %s --version\n", cmd, cmd, cmd);
 					"       %s --help\n" "       %s --version\n", cmd, cmd, cmd);
 }
 }
 
 
 void
 void
-print_help (char *cmd)
+print_help (const char *cmd)
 {
 {
 	print_revision ("check_vsz", "$Revision$");
 	print_revision ("check_vsz", "$Revision$");
 	printf
 	printf

+ 9 - 9
plugins/negate.c

@@ -23,7 +23,7 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
-#define PROGNAME "negate"
+const char *progname = "negate";
 #define REVISION "$Revision$"
 #define REVISION "$Revision$"
 #define COPYRIGHT "2002"
 #define COPYRIGHT "2002"
 #define AUTHOR "Karl DeBisschop"
 #define AUTHOR "Karl DeBisschop"
@@ -52,10 +52,10 @@ Otherwise, the output state of the wrapped plugin is unchanged.\n"
 
 
 char *command_line;
 char *command_line;
 
 
-static int process_arguments (int, char **);
-static int validate_arguments (void);
-static void print_usage (void);
-static void print_help (void);
+int process_arguments (int, char **);
+int validate_arguments (void);
+void print_usage (void);
+void print_help (void);
 
 
 /******************************************************************************
 /******************************************************************************
 
 
@@ -76,7 +76,7 @@ Please note that all tags must be lowercase to use the DocBook XML DTD.
 <manvolnum>5<manvolnum>
 <manvolnum>5<manvolnum>
 </refmeta>
 </refmeta>
 <refnamdiv>
 <refnamdiv>
-<refname>&PROGNAME;</refname>
+<refname>&progname;</refname>
 <refpurpose>&SUMMARY;</refpurpose>
 <refpurpose>&SUMMARY;</refpurpose>
 </refnamdiv>
 </refnamdiv>
 </refentry>
 </refentry>
@@ -174,7 +174,7 @@ main (int argc, char **argv)
 void
 void
 print_help (void)
 print_help (void)
 {
 {
-	print_revision (PROGNAME, REVISION);
+	print_revision (progname, REVISION);
 	printf
 	printf
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		("Copyright (c) %s %s <%s>\n\n%s\n",
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
 		 COPYRIGHT, AUTHOR, EMAIL, SUMMARY);
@@ -196,7 +196,7 @@ print_usage (void)
 					" %s -h for detailed help\n"
 					" %s -h for detailed help\n"
 					" %s -V for version information\n",
 					" %s -V for version information\n",
 #endif
 #endif
-					PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+					progname, OPTIONS, progname, progname);
 }
 }
 
 
 
 
@@ -249,7 +249,7 @@ process_arguments (int argc, char **argv)
 			print_help ();
 			print_help ();
 			exit (EXIT_SUCCESS);
 			exit (EXIT_SUCCESS);
 		case 'V':     /* version */
 		case 'V':     /* version */
-			print_revision (PROGNAME, REVISION);
+			print_revision (progname, REVISION);
 			exit (EXIT_SUCCESS);
 			exit (EXIT_SUCCESS);
 		case 't':     /* timeout period */
 		case 't':     /* timeout period */
 			if (!is_integer (optarg))
 			if (!is_integer (optarg))

+ 11 - 10
plugins/urlize.c

@@ -37,12 +37,14 @@
  *
  *
  *****************************************************************************/
  *****************************************************************************/
 
 
+const char *progname = "urlize";
+
 #include "common.h"
 #include "common.h"
 #include "utils.h"
 #include "utils.h"
 #include "popen.h"
 #include "popen.h"
 
 
-void print_usage (char *);
-void print_help (char *);
+void print_usage (const char *);
+void print_help (const char *);
 
 
 int
 int
 main (int argc, char **argv)
 main (int argc, char **argv)
@@ -52,7 +54,7 @@ main (int argc, char **argv)
 	char input_buffer[MAX_INPUT_BUFFER];
 	char input_buffer[MAX_INPUT_BUFFER];
 
 
 	if (argc < 2) {
 	if (argc < 2) {
-		print_usage (my_basename (argv[0]));
+		print_usage (progname);
 		exit (STATE_UNKNOWN);
 		exit (STATE_UNKNOWN);
 	}
 	}
 
 
@@ -62,12 +64,12 @@ main (int argc, char **argv)
 	}
 	}
 
 
 	if (!strcmp (argv[1], "-V") || !strcmp (argv[1], "--version")) {
 	if (!strcmp (argv[1], "-V") || !strcmp (argv[1], "--version")) {
-		print_revision (my_basename (argv[0]), "$Revision$");
+		print_revision (progname, "$Revision$");
 		exit (STATE_OK);
 		exit (STATE_OK);
 	}
 	}
 
 
 	if (argc < 2) {
 	if (argc < 2) {
-		print_usage (my_basename (argv[0]));
+		print_usage (progname);
 		exit (STATE_UNKNOWN);
 		exit (STATE_UNKNOWN);
 	}
 	}
 
 
@@ -120,16 +122,15 @@ main (int argc, char **argv)
 }
 }
 
 
 void
 void
-print_usage (char *cmd)
+print_usage (const char *cmd)
 {
 {
-	printf ("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n",
-					my_basename (cmd));
+	printf ("Usage:\n %s <url> <plugin> <arg1> ... <argN>\n",	cmd);
 }
 }
 
 
 void
 void
-print_help (char *cmd)
+print_help (const char *cmd)
 {
 {
-	print_revision ("urlize", "$Revision$");
+	print_revision (progname, "$Revision$");
 	printf
 	printf
 		("Copyright (c) 2000 Karl DeBisschop (kdebiss@alum.mit.edu)\n\n"
 		("Copyright (c) 2000 Karl DeBisschop (kdebiss@alum.mit.edu)\n\n"
 		 "\nThis plugin wraps the text output of another command (plugin) in HTML\n"
 		 "\nThis plugin wraps the text output of another command (plugin) in HTML\n"

+ 24 - 13
plugins/utils.c

@@ -18,11 +18,11 @@
 #include <limits.h>
 #include <limits.h>
 
 
 extern int timeout_interval;
 extern int timeout_interval;
+extern const char *progname;
 
 
-char *my_basename (char *);
 void support (void);
 void support (void);
 char *clean_revstring (const char *);
 char *clean_revstring (const char *);
-void print_revision (char *, const char *);
+void print_revision (const char *, const char *);
 void terminate (int, const char *fmt, ...);
 void terminate (int, const char *fmt, ...);
 RETSIGTYPE timeout_alarm_handler (int);
 RETSIGTYPE timeout_alarm_handler (int);
 
 
@@ -57,8 +57,6 @@ char *strpcat (char *dest, const char *src, const char *str);
 #define STRLEN 64
 #define STRLEN 64
 #define TXTBLK 128
 #define TXTBLK 128
 
 
-#define max(a,b) ((a)>(b))?(a):(b)
-
 /* **************************************************************************
 /* **************************************************************************
  * max_state(STATE_x, STATE_y)
  * max_state(STATE_x, STATE_y)
  * compares STATE_x to  STATE_y and returns result based on the following
  * compares STATE_x to  STATE_y and returns result based on the following
@@ -68,7 +66,7 @@ char *strpcat (char *dest, const char *src, const char *str);
  ****************************************************************************/
  ****************************************************************************/
 
 
 int
 int
-max_state(int a, int b)
+max_state (int a, int b)
 {
 {
 	if (a == STATE_CRITICAL || b == STATE_CRITICAL)
 	if (a == STATE_CRITICAL || b == STATE_CRITICAL)
 		return STATE_CRITICAL;
 		return STATE_CRITICAL;
@@ -84,13 +82,26 @@ max_state(int a, int b)
 		return max (a, b);
 		return max (a, b);
 }
 }
 
 
-char *
-my_basename (char *path)
+void usage (char *msg)
 {
 {
-	if (!strstr (path, "/"))
-		return path;
-	else
-		return 1 + strrchr (path, '/');
+	printf (msg);
+	print_usage ();
+	exit (STATE_UNKNOWN);
+}
+
+void usage2(char *msg, char *arg)
+{
+	printf ("%s: %s - %s\n",progname,msg,arg);
+	print_usage ();
+	exit (STATE_UNKNOWN);
+}
+
+void
+usage3 (char *msg, char arg)
+{
+	printf ("%s: %s - %c\n", progname, msg, arg);
+	print_usage();
+	exit (STATE_UNKNOWN);
 }
 }
 
 
 
 
@@ -115,14 +126,14 @@ clean_revstring (const char *revstring)
 }
 }
 
 
 void
 void
-print_revision (char *command_name, const char *revision_string)
+print_revision (const char *command_name, const char *revision_string)
 {
 {
 	char plugin_revision[STRLEN];
 	char plugin_revision[STRLEN];
 
 
 	if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1)
 	if (sscanf (revision_string, "$Revision: %[0-9.]", plugin_revision) != 1)
 		strncpy (plugin_revision, "N/A", STRLEN);
 		strncpy (plugin_revision, "N/A", STRLEN);
 	printf ("%s (nagios-plugins %s) %s\n",
 	printf ("%s (nagios-plugins %s) %s\n",
-					my_basename (command_name), VERSION, plugin_revision);
+					progname, VERSION, plugin_revision);
 	printf
 	printf
 		("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"
 		("The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"
 		 "copies of the plugins under the terms of the GNU General Public License.\n"
 		 "copies of the plugins under the terms of the GNU General Public License.\n"

+ 6 - 20
plugins/utils.h.in

@@ -16,7 +16,7 @@ suite of plugins. */
 char *my_basename (char *);
 char *my_basename (char *);
 void support (void);
 void support (void);
 char *clean_revstring (const char *revstring);
 char *clean_revstring (const char *revstring);
-void print_revision (char *, const char *);
+void print_revision (const char *, const char *);
 void terminate (int result, char *msg, ...);
 void terminate (int result, char *msg, ...);
 extern RETSIGTYPE timeout_alarm_handler (int);
 extern RETSIGTYPE timeout_alarm_handler (int);
 
 
@@ -69,28 +69,14 @@ char *ssprintf (char *str, const char *fmt, ...); /* deprecate for asprintf */
 char *strpcpy (char *dest, const char *src, const char *str);
 char *strpcpy (char *dest, const char *src, const char *str);
 char *strpcat (char *dest, const char *src, const char *str);
 char *strpcat (char *dest, const char *src, const char *str);
 
 
-/* Handle comparisions for STATE_* */
-int max_state(int, int);
+int max_state (int a, int b);
 
 
-#define max(a,b) ((a)>(b))?(a):(b)
+void usage (char *msg);
+void usage2(char *msg, char *arg);
+void usage3(char *msg, char arg);
 
 
-#define usage(msg) {\
- printf(msg);\
- print_usage();\
- exit(STATE_UNKNOWN);\
-}
 
 
-#define usage2(msg,arg) {\
- printf("%s: %s - %s\n",PROGNAME,msg,arg);\
- print_usage();\
- exit(STATE_UNKNOWN);\
-}
-
-#define usage3(msg,arg) {\
- printf("%s: %s - %c\n",PROGNAME,msg,arg);\
- print_usage();\
- exit(STATE_UNKNOWN);\
-}
+#define max(a,b) (((a)>(b))?(a):(b))
 
 
 #define state_text(a) \
 #define state_text(a) \
 (a)==0?"OK":\
 (a)==0?"OK":\