X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fmessages.c;h=f10f3bbdf3540f77b7207ab686dbce29ac663cf9;hb=8134bf8f534a19de35fb39a1eed47eb75f27a47c;hp=9b16e2a94b4d0a8a1f0a7ff6d32f4c38b45c1e72;hpb=32bb074082ebf14d486fadb144d5e63abd710e45;p=citadel.git diff --git a/webcit/messages.c b/webcit/messages.c index 9b16e2a94..f10f3bbdf 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -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); } }