From 93ac4565479ce8b32d5a99aec174323ef73bd12f Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Fri, 18 Oct 2002 06:41:22 +0000 Subject: remove old call_getopt git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@142 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_swap.c b/plugins/check_swap.c index d225e1d..ca8442a 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -150,36 +150,6 @@ main (int argc, char **argv) int process_arguments (int argc, char **argv) { - int c; - - if (argc < 2) - return ERROR; - - c = 0; - while (c += (call_getopt (argc - c, &argv[c]))) { - if (argc <= c) - break; - - if (warn_percent > 100 && is_intnonneg (argv[c])) - warn_percent = atoi (argv[c]); - else if (crit_percent > 100 && is_intnonneg (argv[c])) - crit_percent = atoi (argv[c]); - else if (warn_size < 0 && is_intnonneg (argv[c])) - warn_size = atoi (argv[c]); - else if (crit_size < 0 && is_intnonneg (argv[c])) - crit_size = atoi (argv[c]); - } - - return validate_arguments (); -} - - - - - -int -call_getopt (int argc, char **argv) -{ int c, i = 0; #ifdef HAVE_GETOPT_H @@ -194,6 +164,9 @@ call_getopt (int argc, char **argv) }; #endif + if (argc < 2) + return ERROR; + while (1) { #ifdef HAVE_GETOPT_H c = getopt_long (argc, argv, "+?Vhc:w:", long_options, &option_index); @@ -201,18 +174,10 @@ call_getopt (int argc, char **argv) c = getopt (argc, argv, "+?Vhc:w:"); #endif - i++; - if (c == -1 || c == EOF) break; switch (c) { - case 'c': - case 'w': - i++; - } - - switch (c) { case 'w': /* warning time threshold */ if (is_intnonneg (optarg)) { warn_size = atoi (optarg); @@ -257,7 +222,29 @@ call_getopt (int argc, char **argv) usage ("Invalid argument\n"); } } - return i; + + c = optind; + if (c == argc) + return validate_arguments (); + if (warn_percent > 100 && is_intnonneg (argv[c])) + warn_percent = atoi (argv[c++]); + + if (c == argc) + return validate_arguments (); + if (crit_percent > 100 && is_intnonneg (argv[c])) + crit_percent = atoi (argv[c++]); + + if (c == argc) + return validate_arguments (); + if (warn_size < 0 && is_intnonneg (argv[c])) + warn_size = atoi (argv[c++]); + + if (c == argc) + return validate_arguments (); + if (crit_size < 0 && is_intnonneg (argv[c])) + crit_size = atoi (argv[c++]); + + return validate_arguments (); } -- cgit v0.10-9-g596f