Commit f4f043c7 authored by rswindell's avatar rswindell
Browse files

Support the decoding/downloading of multiple MIME attachments.

parent dd3e4156
......@@ -269,15 +269,17 @@ void sbbs_t::readmail(uint usernumber, int which)
? 0:P_NOATCODES);
char* txt;
if((txt=smb_getmsgtxt(&smb,&msg, 0)) != NULL) {
int attachment_index = 0;
bool found = true;
while((txt=smb_getmsgtxt(&smb,&msg, 0)) != NULL && found) {
char filename[MAX_PATH+1] = {0};
uint32_t filelen = 0;
uint8_t* filedata;
if((filedata = smb_getattachment(&msg, txt, filename, &filelen)) != NULL
if((filedata = smb_getattachment(&msg, txt, filename, &filelen, attachment_index++)) != NULL
&& filename[0] != 0 && filelen > 0) {
char tmp[32];
sprintf(str3, text[DownloadAttachedFileQ], filename, ultoac(filelen,tmp));
if(yesno(str3)) {
if(!noyes(str3)) {
char fpath[MAX_PATH+1];
SAFEPRINTF2(fpath, "%s%s", cfg.temp_dir, filename);
FILE* fp = fopen(fpath, "wb");
......@@ -292,7 +294,8 @@ void sbbs_t::readmail(uint usernumber, int which)
sendfile(fpath, useron.prot, "attachment");
}
}
}
} else
found = false;
smb_freemsgtxt(txt);
}
......
......@@ -273,7 +273,7 @@ SMBEXPORT void SMBCALL smb_dump_msghdr(FILE* fp, smbmsg_t* msg);
/* smbtxt.c */
SMBEXPORT char* SMBCALL smb_getmsgtxt(smb_t* smb, smbmsg_t* msg, ulong mode);
SMBEXPORT char* SMBCALL smb_getplaintext(smbmsg_t* msg, char* buf);
SMBEXPORT uint8_t* SMBCALL smb_getattachment(smbmsg_t* msg, char* buf, char* filename, uint32_t* filelen);
SMBEXPORT uint8_t* SMBCALL smb_getattachment(smbmsg_t* msg, char* buf, char* filename, uint32_t* filelen, int index);
/* smbfile.c */
SMBEXPORT int SMBCALL smb_feof(FILE* fp);
......
......@@ -440,7 +440,7 @@ uint8_t* SMBCALL smb_getattachment(smbmsg_t* msg, char* buf, char* filename, uin
if(result < 1)
return NULL;
*filelen = result;
return buf;
return (uint8_t*)buf;
}
return NULL; /* No attachment */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment