diff options
author | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 08:06:55 +0000 |
---|---|---|
committer | Karl DeBisschop <kdebisschop@users.sourceforge.net> | 2002-11-08 08:06:55 +0000 |
commit | b39ae71c60f0039cda60590715fc17f92107ac35 (patch) | |
tree | c946cc22a053ffce73a07259d4e9c634223c770a /plugins/check_vsz.c | |
parent | 1c4dd10d70ba9ed6dead6cc56cd0f572627cf619 (diff) | |
download | monitoring-plugins-b39ae71c60f0039cda60590715fc17f92107ac35.tar.gz |
remove call_getopt
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@175 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_vsz.c')
-rw-r--r-- | plugins/check_vsz.c | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/plugins/check_vsz.c b/plugins/check_vsz.c index f53eeae3..2ec8775b 100644 --- a/plugins/check_vsz.c +++ b/plugins/check_vsz.c @@ -33,12 +33,18 @@ * *****************************************************************************/ +#define PROGNAME "check_vsz" +#define REVISION "$Revision$" +#define COPYRIGHT "1999-2002" +#define AUTHOR "Karl DeBisschop" +#define EMAIL "karl@debisschop.net" +#define SUMMARY "Check the image size of a running program.\n" + #include "common.h" #include "popen.h" #include "utils.h" int process_arguments (int argc, char **argv); -int call_getopt (int argc, char **argv); void print_help (char *cmd); void print_usage (char *cmd); @@ -146,47 +152,6 @@ 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 == -1) { - if (!is_intnonneg (argv[c])) { - printf ("%s: critical threshold must be an integer: %s\n", - my_basename (argv[0]), argv[c]); - print_usage (my_basename (argv[0])); - exit (STATE_UNKNOWN); - } - warn = atoi (argv[c]); - } - else if (crit == -1) { - if (!is_intnonneg (argv[c])) { - printf ("%s: critical threshold must be an integer: %s\n", - my_basename (argv[0]), argv[c]); - print_usage (my_basename (argv[0])); - exit (STATE_UNKNOWN); - } - crit = atoi (argv[c]); - } - else if (proc == NULL) { - proc = malloc (strlen (argv[c]) + 1); - if (proc == NULL) - terminate (STATE_UNKNOWN, - "check_vsz: failed malloc of proc in process_arguments"); - strcpy (proc, argv[c]); - } - } - return c; -} - -int -call_getopt (int argc, char **argv) -{ - int c, i = 1; - #ifdef HAVE_GETOPT_H int option_index = 0; static struct option long_options[] = { @@ -199,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, "+hVc:w:C:", long_options, &option_index); @@ -208,14 +176,6 @@ call_getopt (int argc, char **argv) if (c == EOF) break; - i++; - switch (c) { - case 'c': - case 'w': - case 'C': - i++; - } - switch (c) { case '?': /* help */ printf ("%s: Unknown argument: %s\n\n", my_basename (argv[0]), optarg); @@ -254,7 +214,37 @@ call_getopt (int argc, char **argv) break; } } - return i; + + c = optind; + if (warn == -1) { + if (!is_intnonneg (argv[c])) { + printf ("%s: critical threshold must be an integer: %s\n", + PROGNAME, argv[c]); + print_usage (PROGNAME); + exit (STATE_UNKNOWN); + } + warn = atoi (argv[c++]); + } + + if (crit == -1) { + if (!is_intnonneg (argv[c])) { + printf ("%s: critical threshold must be an integer: %s\n", + PROGNAME, argv[c]); + print_usage (PROGNAME); + exit (STATE_UNKNOWN); + } + crit = atoi (argv[c++]); + } + + if (proc == NULL) { + proc = malloc (strlen (argv[c]) + 1); + if (proc == NULL) + terminate (STATE_UNKNOWN, + "check_vsz: failed malloc of proc in process_arguments"); + strcpy (proc, argv[c]); + } + + return c; } void |