From e8044713d41f5ef1d9ce814df4a079d8f92306b0 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Thu, 12 Sep 2013 21:37:20 +0200 Subject: check_tcp: Properly deal will partial recv(3)s The np_expect_match() function now returns one of three possible states instead of just TRUE or FALSE: - NP_MATCH_SUCCESS - NP_MATCH_FAILURE - NP_MATCH_RETRY The NP_MATCH_RETRY state indicates that matching might succeed if np_expect_match() is called with a longer input string. This allows check_tcp to decide whether it makes sense to wait for additional data from the server. --- lib/utils_tcp.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/utils_tcp.h') diff --git a/lib/utils_tcp.h b/lib/utils_tcp.h index 34b771d6..0328a9cf 100644 --- a/lib/utils_tcp.h +++ b/lib/utils_tcp.h @@ -4,5 +4,19 @@ #define NP_MATCH_EXACT 0x2 #define NP_MATCH_VERBOSE 0x4 -int np_expect_match(char* status, char** server_expect, int server_expect_count, - int flags); +/* + * The NP_MATCH_RETRY state indicates that matching might succeed if + * np_expect_match() is called with a longer input string. This allows the + * caller to decide whether it makes sense to wait for additional data from the + * server. + */ +enum np_match_result { + NP_MATCH_FAILURE, + NP_MATCH_SUCCESS, + NP_MATCH_RETRY +}; + +enum np_match_result np_expect_match(char *status, + char **server_expect, + int server_expect_count, + int flags); -- cgit v1.2.3-74-g34f1