diff options
Diffstat (limited to 'lib/utils_tcp.c')
-rw-r--r-- | lib/utils_tcp.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c index daae1d54..1482458b 100644 --- a/lib/utils_tcp.c +++ b/lib/utils_tcp.c | |||
@@ -29,18 +29,21 @@ | |||
29 | #include "common.h" | 29 | #include "common.h" |
30 | #include "utils_tcp.h" | 30 | #include "utils_tcp.h" |
31 | 31 | ||
32 | #define VERBOSE(message) \ | 32 | #define VERBOSE(message) \ |
33 | do { \ | 33 | do { \ |
34 | if (flags & NP_MATCH_VERBOSE) \ | 34 | if (flags & NP_MATCH_VERBOSE) \ |
35 | puts(message); \ | 35 | puts(message); \ |
36 | } while (0) | 36 | } while (0) |
37 | 37 | ||
38 | enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, int flags) { | 38 | enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, |
39 | int flags) { | ||
39 | int i, match = 0, partial = 0; | 40 | int i, match = 0, partial = 0; |
40 | 41 | ||
41 | for (i = 0; i < expect_count; i++) { | 42 | for (i = 0; i < expect_count; i++) { |
42 | if (flags & NP_MATCH_VERBOSE) | 43 | if (flags & NP_MATCH_VERBOSE) { |
43 | printf("looking for [%s] %s [%s]\n", server_expect[i], (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); | 44 | printf("looking for [%s] %s [%s]\n", server_expect[i], |
45 | (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); | ||
46 | } | ||
44 | 47 | ||
45 | if (flags & NP_MATCH_EXACT) { | 48 | if (flags & NP_MATCH_EXACT) { |
46 | if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) { | 49 | if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) { |
@@ -60,10 +63,12 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp | |||
60 | VERBOSE("couldn't find it"); | 63 | VERBOSE("couldn't find it"); |
61 | } | 64 | } |
62 | 65 | ||
63 | if ((flags & NP_MATCH_ALL && match == expect_count) || (!(flags & NP_MATCH_ALL) && match >= 1)) | 66 | if ((flags & NP_MATCH_ALL && match == expect_count) || |
67 | (!(flags & NP_MATCH_ALL) && match >= 1)) { | ||
64 | return NP_MATCH_SUCCESS; | 68 | return NP_MATCH_SUCCESS; |
65 | else if (partial > 0 || !(flags & NP_MATCH_EXACT)) | 69 | } else if (partial > 0 || !(flags & NP_MATCH_EXACT)) { |
66 | return NP_MATCH_RETRY; | 70 | return NP_MATCH_RETRY; |
67 | else | 71 | } else { |
68 | return NP_MATCH_FAILURE; | 72 | return NP_MATCH_FAILURE; |
73 | } | ||
69 | } | 74 | } |