memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
Msg->MsgBody->msgnum = msgnum;
FoundCharset = NewStrBuf();
- while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
+ while ((StrBuf_ServGetlnBuffered(Buf)>=0) && !Done) {
if ( (StrLength(Buf)==3) &&
!strcmp(ChrPtr(Buf), "000"))
{
case 2: /* Message Body */
if (Msg->MsgBody->size_known > 0) {
- StrBuf_ServGetBLOB(Msg->MsgBody->Data, Msg->MsgBody->length);
+ StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
state ++;
/*/ todo: check next line, if not 000, append following lines */
}
serv_printf("MSG0 %ld|1", MsgNum); /* ask for headers only */
- StrBuf_ServGetln(Buf);
+ StrBuf_ServGetlnBuffered(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
FreeStrBuf(&Buf);
return NULL;
Msg = (message_summary*)malloc(sizeof(message_summary));
memset(Msg, 0, sizeof(message_summary));
- while (len = StrBuf_ServGetln(Buf),
+ while (len = StrBuf_ServGetlnBuffered(Buf),
((len != 3) ||
strcmp(ChrPtr(Buf), "000")== 0)){
buf = ChrPtr(Buf);
long len;
int n;
int skipit;
+ const char *Ptr;
if (WCC->summ != NULL) {
DeleteHash(&WCC->summ);
Buf = NewStrBuf();
serv_puts(servcmd);
- StrBuf_ServGetln(Buf);
+ StrBuf_ServGetlnBuffered(Buf);
if (GetServerStatus(Buf, NULL) != 1) {
FreeStrBuf(&Buf);
return (nummsgs);
}
Buf2 = NewStrBuf();
- while (len = StrBuf_ServGetln(Buf),
+ while (len = StrBuf_ServGetlnBuffered(Buf),
((len != 3) ||
strcmp(ChrPtr(Buf), "000")!= 0))
{
if (nummsgs < maxload) {
skipit = 0;
+ Ptr = NULL;
Msg = (message_summary*)malloc(sizeof(message_summary));
memset(Msg, 0, sizeof(message_summary));
- Msg->msgnum = StrBufExtract_long(Buf, 0, '|');
- Msg->date = StrBufExtract_long(Buf, 1, '|');
+ Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
+ Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');
/*
* as citserver probably gives us messages in forward date sorting
* nummsgs should be the same order as the message date.
}
if (!skipit) {
Msg->from = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_token(Buf2, Buf, 2, '|');
+ StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
if (StrLength(Buf2) != 0) {
/** Handle senders with RFC2047 encoding */
StrBuf_RFC822_to_Utf8(Msg->from, Buf2, WCC->DefaultCharset, FoundCharset);
}
/** Nodename */
- StrBufExtract_token(Buf2, Buf, 3, '|');
+ StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
if ((StrLength(Buf2) !=0 ) &&
( ((WCC->room_flags & QR_NETWORK)
|| ((strcasecmp(ChrPtr(Buf2), ChrPtr(WCC->serv_info->serv_nodename))
/** Not used:
StrBufExtract_token(Msg->inetaddr, Buf, 4, '|');
*/
-
+ StrBufSkip_NTokenS(Buf, &Ptr, '|', 1);
Msg->subj = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_token(Buf2, Buf, 5, '|');
+ StrBufExtract_NextToken(Buf2, Buf, &Ptr, '|');
if (StrLength(Buf2) == 0)
StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
else {
int sortit = 0;
int defaultsortorder = 0;
WCTemplputParams SubTP;
+ char *ab_name;
if (havebstr("is_summary") && (1 == (ibstr("is_summary"))))
WCC->wc_view = VIEW_MAILBOX;
case VIEW_CALBRIEF:
case VIEW_CALENDAR:
load_seen = 1;
- strcpy(cmd, "MSGS ALL|||1");
+ strcpy(cmd, "MSGS ALL");
maxmsgs = 32767;
parse_calendar_view_request(&calv);
break;
display_note(Msg, Msg->is_new);
break;
case VIEW_ADDRESSBOOK:
- fetch_ab_name(Msg, buf);
+ ab_name = NULL;
+ fetch_ab_name(Msg, &ab_name);
++num_ab;
addrbook = realloc(addrbook,
(sizeof(addrbookent) * num_ab) );
- safestrncpy(addrbook[num_ab-1].ab_name, buf,
+ safestrncpy(addrbook[num_ab-1].ab_name, ab_name,
sizeof(addrbook[num_ab-1].ab_name));
addrbook[num_ab-1].ab_msgnum = Msg->msgnum;
+ free(ab_name);
break;
case VIEW_BBS: /* Tag the mails we want to show in bbview... */
default:
{
const StrBuf *ref = sbstr("references");
references = NewStrBufPlain(ChrPtr(ref), StrLength(ref));
- lprintf(9, "Converting: %s\n", ChrPtr(references));
+ if (*ChrPtr(references) == '|') { /* remove leading '|' if present */
+ StrBufCutLeft(references, 1);
+ }
StrBufReplaceChars(references, '|', '!');
- lprintf(9, "Converted: %s\n", ChrPtr(references));
}
if (havebstr("subject")) {
const StrBuf *Subj;
else {
content_type = NewStrBufDup(part->ContentType);
}
- output_headers(0, 0, 0, 0, 0, 0);
StrBufAppendBuf(WC->WBuf, part->Data, 0);
http_transmit_thing(ChrPtr(content_type), 0);
} else {
void mimepart(int force_download)
{
wcsession *WCC = WC;
-
- char buf[256];
+ StrBuf *Buf;
off_t bytes;
- char content_type[256];
- const char *ContentType = &content_type[0];
+ StrBuf *ContentType = NewStrBufPlain(HKEY("application/octet-stream"));
+ const char *CT;
+ Buf = NewStrBuf();
serv_printf("OPNA %s|%s", ChrPtr(WCC->UrlFragment2), ChrPtr(WCC->UrlFragment3));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '2') {
- bytes = extract_long(&buf[4], 0);
- if (force_download) {
- strcpy(content_type, "application/octet-stream");
- }
- else {
- extract_token(content_type, &buf[4], 3, '|', sizeof content_type);
+ StrBuf_ServGetlnBuffered(Buf);
+ if (GetServerStatus(Buf, NULL) == 2) {
+ StrBufCutLeft(Buf, 4);
+ bytes = StrBufExtract_long(Buf, 0, '|');
+ if (!force_download) {
+ StrBufExtract_token(ContentType, Buf, 3, '|');
}
- read_server_binary(WCC->WBuf, bytes);
+ read_server_binary(WCC->WBuf, bytes, Buf);
serv_puts("CLOS");
- serv_getln(buf, sizeof buf);
+ StrBuf_ServGetlnBuffered(Buf);
+ CT = ChrPtr(ContentType);
if (!force_download) {
- if (!strcasecmp(ContentType, "application/octet-stream")) {
- ContentType = GuessMimeByFilename(SKEY(WCC->UrlFragment4));
+ if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
+ CT = GuessMimeByFilename(SKEY(WCC->UrlFragment4));
}
- if (!strcasecmp(ContentType, "application/octet-stream")) {
- ContentType = GuessMimeType(SKEY(WCC->WBuf));
+ if (!strcasecmp(ChrPtr(ContentType), "application/octet-stream")) {
+ CT = GuessMimeType(SKEY(WCC->WBuf));
}
}
- output_headers(0, 0, 0, 0, 0, 0);
- http_transmit_thing(ContentType, 0);
+ http_transmit_thing(CT, 0);
} else {
- hprintf("HTTP/1.1 404 %s\n", &buf[4]);
+ StrBufCutLeft(Buf, 4);
+ hprintf("HTTP/1.1 404 %s\n", ChrPtr(Buf));
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-Type: text/plain\r\n");
- wprintf(_("An error occurred while retrieving this part: %s\n"), &buf[4]);
+ wprintf(_("An error occurred while retrieving this part: %s\n"),
+ ChrPtr(Buf));
end_burst();
}
+ FreeStrBuf(&ContentType);
+ FreeStrBuf(&Buf);
}
/*
* 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);
+ StrBuf_ServGetlnBuffered(Buf);
+ if (GetServerStatus(Buf, NULL) == 6) {
+ StrBufCutLeft(Buf, 4);
+ bytes = StrBufExtract_long(Buf, 0, '|');
- content = malloc(bytes + 2);
- serv_read(content, bytes);
-
- content[bytes] = 0; /* null terminate for good measure */
- return(content);
+ StrBuf_ServGetBLOBBuffered(Buf, bytes);
+ return(Buf);
}
else {
+ FreeStrBuf(&Buf);
return(NULL);
}
}
*/
void MimeLoadData(wc_mime_attachment *Mime)
{
- char buf[SIZ];
+ StrBuf *Buf;
off_t bytes;
/* TODO: is there a chance the contenttype is different to the one we know? */
serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '6') {
- bytes = extract_long(&buf[4], 0);
-
+ Buf = NewStrBuf();
+ StrBuf_ServGetlnBuffered(Buf);
+ if (GetServerStatus(Buf, NULL) == 6) {
+ bytes = extract_long(&(ChrPtr(Buf)[4]), 0);
+
if (Mime->Data == NULL)
Mime->Data = NewStrBufPlain(NULL, bytes);
- StrBuf_ServGetBLOB(Mime->Data, bytes);
-
+ StrBuf_ServGetBLOBBuffered(Mime->Data, bytes);
}
else {
FlushStrBuf(Mime->Data);
/* TODO XImportant message */
}
+ FreeStrBuf(&Buf);
}