summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/tests/test_tcp.c6
-rw-r--r--lib/utils_tcp.c11
2 files changed, 10 insertions, 7 deletions
diff --git a/lib/tests/test_tcp.c b/lib/tests/test_tcp.c
index ae6dc1f4..114252b4 100644
--- a/lib/tests/test_tcp.c
+++ b/lib/tests/test_tcp.c
@@ -21,10 +21,11 @@
21#include "tap.h" 21#include "tap.h"
22 22
23int 23int
24main (int argc, char **argv) 24main(void)
25{ 25{
26 char** server_expect; 26 char **server_expect;
27 int server_expect_count = 3; 27 int server_expect_count = 3;
28
28 plan_tests(9); 29 plan_tests(9);
29 30
30 server_expect = malloc(sizeof(char*) * server_expect_count); 31 server_expect = malloc(sizeof(char*) * server_expect_count);
@@ -55,4 +56,3 @@ main (int argc, char **argv)
55 56
56 return exit_status(); 57 return exit_status();
57} 58}
58
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c
index 497a1701..46ad7f72 100644
--- a/lib/utils_tcp.c
+++ b/lib/utils_tcp.c
@@ -36,14 +36,16 @@
36 } while (0) 36 } while (0)
37 37
38enum np_match_result 38enum np_match_result
39np_expect_match(char* status, char** server_expect, int expect_count, int flags) 39np_expect_match(char *status, char **server_expect, int expect_count, int flags)
40{ 40{
41 int i, match = 0, partial = 0; 41 int i, match = 0, partial = 0;
42
42 for (i = 0; i < expect_count; i++) { 43 for (i = 0; i < expect_count; i++) {
43 if (flags & NP_MATCH_VERBOSE) 44 if (flags & NP_MATCH_VERBOSE)
44 printf ("looking for [%s] %s [%s]\n", server_expect[i], 45 printf("looking for [%s] %s [%s]\n", server_expect[i],
45 (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", 46 (flags & NP_MATCH_EXACT) ?
46 status); 47 "in beginning of" : "anywhere in",
48 status);
47 49
48 if (flags & NP_MATCH_EXACT) { 50 if (flags & NP_MATCH_EXACT) {
49 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) { 51 if (strncmp(status, server_expect[i], strlen(server_expect[i])) == 0) {
@@ -62,6 +64,7 @@ np_expect_match(char* status, char** server_expect, int expect_count, int flags)
62 } 64 }
63 VERBOSE("couldn't find it"); 65 VERBOSE("couldn't find it");
64 } 66 }
67
65 if ((flags & NP_MATCH_ALL && match == expect_count) || 68 if ((flags & NP_MATCH_ALL && match == expect_count) ||
66 (!(flags & NP_MATCH_ALL) && match >= 1)) 69 (!(flags & NP_MATCH_ALL) && match >= 1))
67 return NP_MATCH_SUCCESS; 70 return NP_MATCH_SUCCESS;