* swap I/O to the new functions
[citadel.git] / webcit / messages.c
index 9b16e2a94b4d0a8a1f0a7ff6d32f4c38b45c1e72..f10f3bbdf3540f77b7207ab686dbce29ac663cf9 100644 (file)
@@ -1588,26 +1588,23 @@ void mimepart(int force_download)
 /*
  * Read any MIME part of a message, from the server, into memory.
  */
-char *load_mimepart(long msgnum, char *partnum)
+StrBuf *load_mimepart(long msgnum, char *partnum)
 {
-       char buf[SIZ];
        off_t bytes;
-       char content_type[SIZ];
-       char *content;
+       StrBuf *Buf;
        
+       Buf = NewStrBuf();
        serv_printf("DLAT %ld|%s", msgnum, partnum);
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '6') {
-               bytes = extract_long(&buf[4], 0);
-               extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
-
-               content = malloc(bytes + 2);
-               serv_read(content, bytes);
+       StrBuf_ServGetlnBuffered(Buf);
+       if (GetServerStatus(Buf, NULL) == 6) {
+               StrBufCutLeft(Buf, 4);
+               bytes = StrBufExtract_long(Buf, 0, '|');
 
-               content[bytes] = 0;     /* null terminate for good measure */
-               return(content);
+               StrBuf_ServGetBLOBBuffered(Buf, bytes);
+               return(Buf);
        }
        else {
+               FreeStrBuf(&Buf);
                return(NULL);
        }
 }