diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-12 17:42:10 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2013-09-12 17:42:10 +0200 |
commit | 662997251d4fc43f4155784f9e7df827f193305e (patch) | |
tree | 0a9ad5c5607598da0eb6b6d71fa8c47ca44186fb /plugins/check_tcp.c | |
parent | ca9ce71576ddf78cc54fe3b6f0428cdfea72e9df (diff) | |
download | monitoring-plugins-662997251d4fc43f4155784f9e7df827f193305e.tar.gz |
Improve interface of np_expect_match() function
Replace the three boolean parameters of lib/utils_tcp.c's
np_expect_match() function with a single "flags" parameter.
Diffstat (limited to 'plugins/check_tcp.c')
-rw-r--r-- | plugins/check_tcp.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/plugins/check_tcp.c b/plugins/check_tcp.c index 9e62638b..e8d7ec68 100644 --- a/plugins/check_tcp.c +++ b/plugins/check_tcp.c @@ -82,15 +82,14 @@ static int sd = 0; #define MAXBUF 1024 static char buffer[MAXBUF]; static int expect_mismatch_state = STATE_WARNING; +static int match_flags = NP_MATCH_EXACT; #define FLAG_SSL 0x01 #define FLAG_VERBOSE 0x02 -#define FLAG_EXACT_MATCH 0x04 -#define FLAG_TIME_WARN 0x08 -#define FLAG_TIME_CRIT 0x10 -#define FLAG_HIDE_OUTPUT 0x20 -#define FLAG_MATCH_ALL 0x40 -static size_t flags = FLAG_EXACT_MATCH; +#define FLAG_TIME_WARN 0x04 +#define FLAG_TIME_CRIT 0x08 +#define FLAG_HIDE_OUTPUT 0x10 +static size_t flags; int main (int argc, char **argv) @@ -296,12 +295,7 @@ main (int argc, char **argv) (int)len + 1, status); while(isspace(status[len])) status[len--] = '\0'; - match = np_expect_match(status, - server_expect, - server_expect_count, - (flags & FLAG_MATCH_ALL ? TRUE : FALSE), - (flags & FLAG_EXACT_MATCH ? TRUE : FALSE), - (flags & FLAG_VERBOSE ? TRUE : FALSE)); + match = np_expect_match(status, server_expect, server_expect_count, match_flags); } if (server_quit != NULL) { @@ -450,6 +444,7 @@ process_arguments (int argc, char **argv) exit (STATE_OK); case 'v': /* verbose mode */ flags |= FLAG_VERBOSE; + match_flags |= NP_MATCH_VERBOSE; break; case '4': address_family = AF_INET; @@ -506,7 +501,7 @@ process_arguments (int argc, char **argv) xasprintf(&server_send, "%s", optarg); break; case 'e': /* expect string (may be repeated) */ - flags &= ~FLAG_EXACT_MATCH; + match_flags &= ~NP_MATCH_EXACT; if (server_expect_count == 0) server_expect = malloc (sizeof (char *) * (++server_expect_count)); else @@ -584,7 +579,7 @@ process_arguments (int argc, char **argv) #endif break; case 'A': - flags |= FLAG_MATCH_ALL; + match_flags |= NP_MATCH_ALL; break; } } |