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 /lib/utils_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 'lib/utils_tcp.c')
-rw-r--r-- | lib/utils_tcp.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c index 8589ce67..cf67b116 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c @@ -30,26 +30,27 @@ #include "utils_tcp.h" int -np_expect_match(char* status, char** server_expect, int expect_count, int all, int exact_match, int verbose) +np_expect_match(char* status, char** server_expect, int expect_count, int flags) { int match = 0; int i; for (i = 0; i < expect_count; i++) { - if (verbose) + if (flags & NP_MATCH_VERBOSE) printf ("looking for [%s] %s [%s]\n", server_expect[i], - (exact_match) ? "in beginning of" : "anywhere in", + (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); - if ((exact_match && !strncmp(status, server_expect[i], strlen(server_expect[i]))) || - (! exact_match && strstr(status, server_expect[i]))) + if ((flags & NP_MATCH_EXACT && + !strncmp(status, server_expect[i], strlen(server_expect[i]))) || + (!(flags & NP_MATCH_EXACT) && strstr(status, server_expect[i]))) { - if(verbose) puts("found it"); + if(flags & NP_MATCH_VERBOSE) puts("found it"); match += 1; } else - if(verbose) puts("couldn't find it"); + if(flags & NP_MATCH_VERBOSE) puts("couldn't find it"); } - if ((all == TRUE && match == expect_count) || - (! all && match >= 1)) { + if ((flags & NP_MATCH_ALL && match == expect_count) || + (!(flags & NP_MATCH_ALL) && match >= 1)) { return TRUE; } else return FALSE; |