aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_ldap.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-14 02:26:34 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2002-11-14 02:26:34 +0000
commit2a68978c564e53cddc90882ee7776a43839dfcff (patch)
tree7c8432f893e4c43f2d20d022ba8ccdc05752e4e6 /plugins/check_ldap.c
parent9e009c4b1128352c6039d25b39213fd480e9b055 (diff)
downloadmonitoring-plugins-2a68978c564e53cddc90882ee7776a43839dfcff.tar.gz
remove call_getopt and ssprintf
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@191 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_ldap.c')
-rw-r--r--plugins/check_ldap.c59
1 files changed, 13 insertions, 46 deletions
diff --git a/plugins/check_ldap.c b/plugins/check_ldap.c
index d3f06158..213dc4a8 100644
--- a/plugins/check_ldap.c
+++ b/plugins/check_ldap.c
@@ -34,7 +34,6 @@
#define UNKNOWN -1
int process_arguments (int, char **);
-int call_getopt (int, char **);
int validate_arguments (void);
static void print_help (void);
static void print_usage (void);
@@ -124,35 +123,10 @@ process_arguments (int argc, char **argv)
{
int c;
- if (argc < 2)
- return ERROR;
-
- for (c = 1; c < argc; c++) {
- if (strcmp ("-to", argv[c]) == 0)
- strcpy (argv[c], "-t");
- }
-
- c = 0;
- while (c += (call_getopt (argc - c, &argv[c]))) {
- if (argc <= c)
- break;
- if (ld_host[0] == 0) {
- strncpy (ld_host, argv[c], sizeof (ld_host) - 1);
- ld_host[sizeof (ld_host) - 1] = 0;
- }
- }
-
- return c;
-}
-
-int
-call_getopt (int argc, char **argv)
-{
- int c, i = 1;
#ifdef HAVE_GETOPT_H
int option_index = 0;
/* initialize the long option struct */
- static struct option long_options[] = {
+ static struct option longopts[] = {
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
{"timeout", required_argument, 0, 't'},
@@ -168,15 +142,17 @@ call_getopt (int argc, char **argv)
};
#endif
- for (c = 1; c < argc; c++)
+ if (argc < 2)
+ return ERROR;
+
+ for (c = 1; c < argc; c++) {
if (strcmp ("-to", argv[c]) == 0)
strcpy (argv[c], "-t");
+ }
while (1) {
#ifdef HAVE_GETOPT_H
- c =
- getopt_long (argc, argv, "+hVt:c:w:H:b:p:a:D:P:", long_options,
- &option_index);
+ c = getopt_long (argc, argv, "hVt:c:w:H:b:p:a:D:P:", longopts, &option_index);
#else
c = getopt (argc, argv, "+?hVt:c:w:H:b:p:a:D:P:");
#endif
@@ -184,20 +160,6 @@ call_getopt (int argc, char **argv)
if (c == -1 || c == EOF)
break;
- i++;
- switch (c) {
- case 't':
- case 'c':
- case 'w':
- case 'H':
- case 'b':
- case 'p':
- case 'a':
- case 'D':
- case 'P':
- i++;
- }
-
switch (c) {
case 'h': /* help */
print_help ();
@@ -239,7 +201,12 @@ call_getopt (int argc, char **argv)
break;
}
}
- return i;
+
+ if (ld_host[0] == 0) {
+ asprintf (&ld_host, "%s", argv[c]);
+ }
+
+ return validate_arguments ();
}
int