Code

had been grandfathered ibto core, finally use normal getopts, add options for player...
[nagiosplug.git] / plugins / check_mrtg.c
index 4d297aaa1f70f20293c1bff3da26e3b6fd912e65..095dcbc8ccd63200145e98532f20a3786cdb71b4 100644 (file)
@@ -23,7 +23,7 @@
  *
  *****************************************************************************/
 
-#define PROGNAME "check_mrtg"
+const char *progname = "check_mrtg";
 #define REVISION "$Revision$"
 #define COPYRIGHT "Copyright (c) 1999-2001 Ethan Galstad"
 
@@ -214,7 +214,6 @@ process_arguments (int argc, char **argv)
 {
        int c;
 
-#ifdef HAVE_GETOPT_H
        int option_index = 0;
        static struct option long_options[] = {
                {"logfile", required_argument, 0, 'F'},
@@ -230,7 +229,6 @@ process_arguments (int argc, char **argv)
                {"help", no_argument, 0, 'h'},
                {0, 0, 0, 0}
        };
-#endif
 
        if (argc < 2)
                return ERROR;
@@ -245,13 +243,8 @@ process_arguments (int argc, char **argv)
        }
 
        while (1) {
-#ifdef HAVE_GETOPT_H
-               c =
-                       getopt_long (argc, argv, "hVF:e:a:v:c:w:l:u:", long_options,
+               c = getopt_long (argc, argv, "hVF:e:a:v:c:w:l:u:", long_options,
                                                                         &option_index);
-#else
-               c = getopt (argc, argv, "hVF:e:a:v:c:w:l:u:");
-#endif
 
                if (c == -1 || c == EOF)
                        break;
@@ -287,7 +280,7 @@ process_arguments (int argc, char **argv)
                        units_label = optarg;
                        break;
                case 'V':                                                                       /* version */
-                       print_revision (PROGNAME, REVISION);
+                       print_revision (progname, REVISION);
                        exit (STATE_OK);
                case 'h':                                                                       /* help */
                        print_help ();
@@ -308,7 +301,7 @@ process_arguments (int argc, char **argv)
                else
                        terminate (STATE_UNKNOWN,
                                   "%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) {
@@ -332,7 +325,7 @@ process_arguments (int argc, char **argv)
                value_warning_threshold = strtoul (argv[c++], NULL, 10);
        }
 
-       if (vargc > c && alue_critical_threshold == 0) {
+       if (argc > c && value_critical_threshold == 0) {
                value_critical_threshold = strtoul (argv[c++], NULL, 10);
        }
 
@@ -359,7 +352,7 @@ validate_arguments (void)
 void
 print_help (void)
 {
-       print_revision (PROGNAME, REVISION);
+       print_revision (progname, REVISION);
        printf ("%s\n\n%s\n", COPYRIGHT, SUMMARY);
        print_usage ();
        printf ("\nOptions:\n" LONGOPTIONS "\n" DESCRIPTION "\n");
@@ -370,12 +363,7 @@ void
 print_usage (void)
 {
        printf ("Usage:\n" " %s %s\n"
-#ifdef HAVE_GETOPT_H
                                        " %s (-h | --help) for detailed help\n"
                                        " %s (-V | --version) for version information\n",
-#else
-                                       " %s -h for detailed help\n"
-                                       " %s -V for version information\n",
-#endif
-                                       PROGNAME, OPTIONS, PROGNAME, PROGNAME);
+                                       progname, OPTIONS, progname, progname);
 }