* implement client_read_random_blob(); its hear to read a blob of undefined size...
authorWilfried Göesgens <willi@citadel.org>
Thu, 6 May 2010 21:36:35 +0000 (21:36 +0000)
committerWilfried Göesgens <willi@citadel.org>
Thu, 6 May 2010 21:36:35 +0000 (21:36 +0000)
citadel/sysdep.c
citadel/sysdep_decls.h

index f7f9ecc42ba7e1f72f914129f471c161b7c3af0c..ce3523d98fb47f95096acb65146ecef7642a5eb8 100644 (file)
@@ -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;
index d0433222356c5e415b5ac88ba67df9c830bdd4ad..4789914fdbaf0f1479439c046717d27b45e0eeeb 100644 (file)
@@ -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);