diff options
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 8589ce6..cf67b11 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c | |||
@@ -30,26 +30,27 @@ | |||
30 | #include "utils_tcp.h" | 30 | #include "utils_tcp.h" |
31 | 31 | ||
32 | int | 32 | int |
33 | np_expect_match(char* status, char** server_expect, int expect_count, int all, int exact_match, int verbose) | 33 | np_expect_match(char* status, char** server_expect, int expect_count, int flags) |
34 | { | 34 | { |
35 | int match = 0; | 35 | int match = 0; |
36 | int i; | 36 | int i; |
37 | for (i = 0; i < expect_count; i++) { | 37 | for (i = 0; i < expect_count; i++) { |
38 | if (verbose) | 38 | if (flags & NP_MATCH_VERBOSE) |
39 | printf ("looking for [%s] %s [%s]\n", server_expect[i], | 39 | printf ("looking for [%s] %s [%s]\n", server_expect[i], |
40 | (exact_match) ? "in beginning of" : "anywhere in", | 40 | (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", |
41 | status); | 41 | status); |
42 | 42 | ||
43 | if ((exact_match && !strncmp(status, server_expect[i], strlen(server_expect[i]))) || | 43 | if ((flags & NP_MATCH_EXACT && |
44 | (! exact_match && strstr(status, server_expect[i]))) | 44 | !strncmp(status, server_expect[i], strlen(server_expect[i]))) || |
45 | (!(flags & NP_MATCH_EXACT) && strstr(status, server_expect[i]))) | ||
45 | { | 46 | { |
46 | if(verbose) puts("found it"); | 47 | if(flags & NP_MATCH_VERBOSE) puts("found it"); |
47 | match += 1; | 48 | match += 1; |
48 | } else | 49 | } else |
49 | if(verbose) puts("couldn't find it"); | 50 | if(flags & NP_MATCH_VERBOSE) puts("couldn't find it"); |
50 | } | 51 | } |
51 | if ((all == TRUE && match == expect_count) || | 52 | if ((flags & NP_MATCH_ALL && match == expect_count) || |
52 | (! all && match >= 1)) { | 53 | (!(flags & NP_MATCH_ALL) && match >= 1)) { |
53 | return TRUE; | 54 | return TRUE; |
54 | } else | 55 | } else |
55 | return FALSE; | 56 | return FALSE; |