* use modern functions for downloads.
[citadel.git] / webcit / tcp_sockets.c
index 2352ca72643d4afc00e629c2add293eed79f137f..345b1d56eb5e8277d23f671744a19c184b121bd5 100644 (file)
@@ -38,13 +38,15 @@ int uds_connectsock(char *sockpath)
 
        s = socket(AF_UNIX, SOCK_STREAM, 0);
        if (s < 0) {
-               lprintf(1, "Can't create socket: %s\n",
+               lprintf(1, "Can't create socket[%s]: %s\n",
+                       sockpath,
                        strerror(errno));
                return(-1);
        }
 
        if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
-               lprintf(1, "Can't connect: %s\n",
+               lprintf(1, "Can't connect [%s]: %s\n",
+                       sockpath,
                        strerror(errno));
                close(s);
                return(-1);
@@ -220,6 +222,32 @@ int StrBuf_ServGetlnBuffered(StrBuf *buf)
        return rc;
 }
 
+int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize)
+{
+       wcsession *WCC = WC;
+       const char *Err;
+       int rc;
+       
+       rc = StrBufReadBLOBBuffered(buf, 
+                                   WCC->ReadBuf, 
+                                   &WCC->ReadPos,
+                                   &WCC->serv_sock, 
+                                   1, 
+                                   BlobSize, 
+                                   NNN_TERM,
+                                   &Err);
+       if (rc < 0)
+       {
+               lprintf(1, "Server connection broken: %s\n",
+                       Err);
+               wc_backtrace();
+               WCC->serv_sock = (-1);
+               WCC->connected = 0;
+               WCC->logged_in = 0;
+       }
+       return rc;
+}
+
 int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize)
 {
        wcsession *WCC = WC;