+/*
+ * Read data from the client socket.
+ *
+ * sock socket fd to read from
+ * buf buffer to read into
+ * bytes number of bytes to read
+ * timeout Number of seconds to wait before timing out
+ *
+ * Possible return values:
+ * 1 Requested number of bytes has been read.
+ * 0 Request timed out.
+ * -1 Connection is broken, or other error.
+ */
+int socket_read_blob(int *Socket, StrBuf * Target, int bytes, int timeout)
+{
+ CitContext *CCC = MyContext();
+ const char *Error;
+ int retval = 0;
+
+
+ retval = StrBufReadBLOBBuffered(Target,
+ CCC->SBuf.Buf,
+ &CCC->SBuf.ReadWritePointer,
+ Socket, 1, bytes, O_TERM, &Error);
+
+ if (retval < 0) {
+ syslog(LOG_CRIT, "socket_read_blob() failed: %s", Error);
+ }
+ return retval;
+}
+
+
+int CtdlSockGetLine(int *sock, StrBuf * Target, int nSec)
+{
+ CitContext *CCC = MyContext();
+ const char *Error;
+ int rc;
+
+ FlushStrBuf(Target);
+ rc = StrBufTCP_read_buffered_line_fast(Target,
+ CCC->SBuf.Buf,
+ &CCC->SBuf.ReadWritePointer,
+ sock, nSec, 1, &Error);
+ if ((rc < 0) && (Error != NULL))
+ syslog(LOG_CRIT, "CtdlSockGetLine() failed: %s", Error);
+ return rc;