aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_swap.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-10-18 06:41:22 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-10-18 06:41:22 +0000
commit93ac4565479ce8b32d5a99aec174323ef73bd12f (patch)
treea8cdbefaacbfab110377d73a79d099698068a77e /plugins/check_swap.c
parent44d249d12aca1cf0562ddeca4104b3462b4640a3 (diff)
downloadmonitoring-plugins-93ac4565479ce8b32d5a99aec174323ef73bd12f.tar.gz
remove old call_getopt
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@142 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_swap.c')
-rw-r--r--plugins/check_swap.c65
1 files 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
@@ -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 ();
}