diff --git a/src/sbbs3/readmail.cpp b/src/sbbs3/readmail.cpp index 0235fcd7fc839eceba5eb8a597e0aef025335cf3..9a5877acb6539ce347f38cca44b8ec1ace1c7a80 100644 --- a/src/sbbs3/readmail.cpp +++ b/src/sbbs3/readmail.cpp @@ -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); } diff --git a/src/smblib/smblib.h b/src/smblib/smblib.h index 007fe40fa58e56c7f9380074cdc3efd92aa1ce4c..bd4344231799cfa955e608f6c820e888980e675f 100644 --- a/src/smblib/smblib.h +++ b/src/smblib/smblib.h @@ -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); diff --git a/src/smblib/smbtxt.c b/src/smblib/smbtxt.c index 225d3166357713a6963ddd6dda6140432b2d33e7..d0d125745037c133e4178be90263b269dceaa2c6 100644 --- a/src/smblib/smbtxt.c +++ b/src/smblib/smbtxt.c @@ -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 */