summaryrefslogtreecommitdiffstats
path: root/lib/utils_tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/utils_tcp.c')
-rw-r--r--lib/utils_tcp.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/utils_tcp.c b/lib/utils_tcp.c
index 1482458b..a82d5a3f 100644
--- a/lib/utils_tcp.c
+++ b/lib/utils_tcp.c
@@ -26,8 +26,10 @@
26 * 26 *
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#include "common.h" 29#include "../config.h"
30#include "utils_tcp.h" 30#include "utils_tcp.h"
31#include <stdio.h>
32#include <string.h>
31 33
32#define VERBOSE(message) \ 34#define VERBOSE(message) \
33 do { \ 35 do { \
@@ -37,9 +39,9 @@
37 39
38enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count, 40enum np_match_result np_expect_match(char *status, char **server_expect, int expect_count,
39 int flags) { 41 int flags) {
40 int i, match = 0, partial = 0; 42 int match = 0;
41 43 int partial = 0;
42 for (i = 0; i < expect_count; i++) { 44 for (int i = 0; i < expect_count; i++) {
43 if (flags & NP_MATCH_VERBOSE) { 45 if (flags & NP_MATCH_VERBOSE) {
44 printf("looking for [%s] %s [%s]\n", server_expect[i], 46 printf("looking for [%s] %s [%s]\n", server_expect[i],
45 (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status); 47 (flags & NP_MATCH_EXACT) ? "in beginning of" : "anywhere in", status);
@@ -50,7 +52,9 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp
50 VERBOSE("found it"); 52 VERBOSE("found it");
51 match++; 53 match++;
52 continue; 54 continue;
53 } else if (strncmp(status, server_expect[i], strlen(status)) == 0) { 55 }
56
57 if (strncmp(status, server_expect[i], strlen(status)) == 0) {
54 VERBOSE("found a substring"); 58 VERBOSE("found a substring");
55 partial++; 59 partial++;
56 continue; 60 continue;
@@ -66,9 +70,9 @@ enum np_match_result np_expect_match(char *status, char **server_expect, int exp
66 if ((flags & NP_MATCH_ALL && match == expect_count) || 70 if ((flags & NP_MATCH_ALL && match == expect_count) ||
67 (!(flags & NP_MATCH_ALL) && match >= 1)) { 71 (!(flags & NP_MATCH_ALL) && match >= 1)) {
68 return NP_MATCH_SUCCESS; 72 return NP_MATCH_SUCCESS;
69 } else if (partial > 0 || !(flags & NP_MATCH_EXACT)) { 73 }
74 if (partial > 0 || !(flags & NP_MATCH_EXACT)) {
70 return NP_MATCH_RETRY; 75 return NP_MATCH_RETRY;
71 } else {
72 return NP_MATCH_FAILURE;
73 } 76 }
77 return NP_MATCH_FAILURE;
74} 78}