summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 44d249d)
raw | patch | inline | side by side (parent: 44d249d)
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 18 Oct 2002 06:41:22 +0000 (06:41 +0000) | ||
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | |
Fri, 18 Oct 2002 06:41:22 +0000 (06:41 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@142 f882894a-f735-0410-b71e-b25c423dba1c
plugins/check_swap.c | patch | blob | history |
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index d225e1dcb0310d53681101d459a4a5459855e12c..ca8442a416c28bb501a86de2447aca2bb1eda03d 100644 (file)
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
/* 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;
};
#endif
+ if (argc < 2)
+ return ERROR;
+
while (1) {
#ifdef HAVE_GETOPT_H
c = getopt_long (argc, argv, "+?Vhc:w:", long_options, &option_index);
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)) {
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 ();
}