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 --- plugins/check_swap.c | 65 +++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/plugins/check_swap.c b/plugins/check_swap.c index d225e1dc..ca8442a4 100644 --- a/plugins/check_swap.c +++ b/plugins/check_swap.c @@ -149,36 +149,6 @@ main (int argc, char **argv) /* process command-line arguments */ 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; @@ -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,17 +174,9 @@ 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)) { @@ -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 v1.2.3