]> code.citadel.org Git - citadel.git/blobdiff - citadel/clientsocket.c
Use IOBuffer with its StrBuf + const char* inside instead of having two of them
[citadel.git] / citadel / clientsocket.c
index 8052e24e4ac8ced4b22747d4029f5ba3fa313e4d..49cfd54ef7c68fa03b590aad4347549e13213ea5 100644 (file)
@@ -136,8 +136,8 @@ int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout)
 
 
        retval = StrBufReadBLOBBuffered(Target,
-                                       CCC->sReadBuf,
-                                       &CCC->sPos,
+                                       CCC->SBuf.Buf,
+                                       &CCC->SBuf.ReadWritePointer,
                                        Socket, 1, bytes, O_TERM, &Error);
        if (retval < 0) {
                CtdlLogPrintf(CTDL_CRIT,
@@ -147,28 +147,6 @@ int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout)
 }
 
 
-int sock_read_to(int *sock, char *buf, int bytes, int timeout,
-                int keep_reading_until_full)
-{
-       CitContext *CCC = MyContext();
-       int rc;
-
-       FlushStrBuf(CCC->MigrateBuf);
-       rc = socket_read_blob(sock, CCC->sMigrateBuf, bytes, timeout);
-       if (rc < 0) {
-               *buf = '\0';
-               return rc;
-       } else {
-               if (StrLength(CCC->MigrateBuf) < bytes)
-                       bytes = StrLength(CCC->MigrateBuf);
-               memcpy(buf, ChrPtr(CCC->MigrateBuf), bytes);
-
-               FlushStrBuf(CCC->MigrateBuf);
-               return rc;
-       }
-}
-
-
 int CtdlSockGetLine(int *sock, StrBuf * Target, int nSec)
 {
        CitContext *CCC = MyContext();
@@ -177,8 +155,8 @@ int CtdlSockGetLine(int *sock, StrBuf * Target, int nSec)
 
        FlushStrBuf(Target);
        rc = StrBufTCP_read_buffered_line_fast(Target,
-                                              CCC->sReadBuf,
-                                              &CCC->sPos,
+                                              CCC->SBuf.Buf,
+                                              &CCC->SBuf.ReadWritePointer,
                                               sock, nSec, 1, &Error);
        if ((rc < 0) && (Error != NULL))
                CtdlLogPrintf(CTDL_CRIT,
@@ -215,18 +193,6 @@ int sock_getln(int *sock, char *buf, int bufsize)
 }
 
 
-/*
- * sock_read() - input binary data from socket.
- * Returns the number of bytes read, or -1 for error.
- */
-INLINE int sock_read(int *sock, char *buf, int bytes,
-                    int keep_reading_until_full)
-{
-       return sock_read_to(sock, buf, bytes, CLIENT_TIMEOUT,
-                           keep_reading_until_full);
-}
-
-
 /*
  * sock_write() - send binary to server.
  * Returns the number of bytes written, or -1 for error.