From 51540594d94cff9027e22c9cbf7fcf4113c65697 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Thu, 6 May 2010 21:36:35 +0000 Subject: [PATCH] * implement client_read_random_blob(); its hear to read a blob of undefined size; Its to be used _once_ after a successfull select of the master loop. --- citadel/sysdep.c | 32 ++++++++++++++++++++++++++++++++ citadel/sysdep_decls.h | 1 + 2 files changed, 33 insertions(+) diff --git a/citadel/sysdep.c b/citadel/sysdep.c index f7f9ecc42..ce3523d98 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -621,6 +621,38 @@ int client_read_blob(StrBuf *Target, int bytes, int timeout) return retval; } + +int client_read_random_blob(StrBuf *Target, int timeout) +{ + CitContext *CCC=CC; + int rc; + + rc = client_read_blob(Target, 1, timeout); + if (rc > 0) + { + long len; + const char *pch; + + len = StrLength(CCC->ReadBuf); + pch = ChrPtr(CCC->ReadBuf); + + if (len > 0) + { + if (CCC->Pos != NULL) { + len -= CCC->Pos - pch; + pch = CCC->Pos; + } + StrBufAppendBufPlain(Target, pch, len, 0); + FlushStrBuf(CCC->ReadBuf); + CCC->Pos = NULL; + return StrLength(Target); + } + return rc; + } + else + return rc; +} + int client_read_to(char *buf, int bytes, int timeout) { CitContext *CCC=CC; diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index d04332223..4789914fd 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -65,6 +65,7 @@ int client_read (char *buf, int bytes); int client_getln (char *buf, int maxbytes); int CtdlClientGetLine(StrBuf *Target); int client_read_blob(StrBuf *Target, int bytes, int timeout); +int client_read_random_blob(StrBuf *Target, int timeout); void sysdep_master_cleanup (void); void kill_session (int session_to_kill); void start_daemon (int do_close_stdio); -- 2.30.2