From fa6d1ee3d97d547897b217930b69fc8b3c0cb122 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Thu, 20 Dec 2001 01:26:13 +0000 Subject: [PATCH] Changed delfattach() to an exported C function that now deletes netmail file attachments as well as local mail file attachments. --- src/sbbs3/mail.cpp | 24 ++++++++++++++++++------ src/sbbs3/sbbs.h | 3 +-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/sbbs3/mail.cpp b/src/sbbs3/mail.cpp index 129f53a52b..cddbd61808 100644 --- a/src/sbbs3/mail.cpp +++ b/src/sbbs3/mail.cpp @@ -79,11 +79,23 @@ int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent) /***************************/ /* Delete file attachments */ /***************************/ -void sbbs_t::delfattach(uint to, char *title) +extern "C" void delfattach(scfg_t* cfg, smbmsg_t* msg) { - char str[128],str2[128],*tp,*sp,*p; + char str[MAX_PATH+1]; + char str2[MAX_PATH+1]; + char *tp,*sp,*p; - strcpy(str,title); + if(msg->idx.to==0) { /* netmail */ + sprintf(str,"%s%04u.out/%s" + ,cfg->data_dir,msg->idx.from,getfname(msg->subj)); + remove(str); + sprintf(str,"%s%04u.out" + ,cfg->data_dir,msg->idx.from); + rmdir(str); + return; + } + + strcpy(str,msg->subj); tp=str; while(1) { p=strchr(tp,SP); @@ -92,12 +104,12 @@ void sbbs_t::delfattach(uint to, char *title) if(!sp) sp=strrchr(tp,'\\'); if(sp) tp=sp+1; sprintf(str2,"%sfile/%04u.in/%s" /* str2 is path/fname */ - ,cfg.data_dir,to,tp); + ,cfg->data_dir,msg->idx.to,tp); remove(str2); if(!p) break; tp=p+1; } - sprintf(str,"%sfile/%04u.in",cfg.data_dir,to); + sprintf(str,"%sfile/%04u.in",cfg->data_dir,msg->idx.to); rmdir(str); /* remove the dir if it's empty */ } @@ -157,7 +169,7 @@ int sbbs_t::delmail(uint usernumber, int which) if((i=smb_freemsg(&smb,&msg))!=0) errormsg(WHERE,ERR_REMOVE,smb.file,i,smb.last_error); if(msg.hdr.auxattr&MSG_FILEATTACH) - delfattach(msg.idx.to,msg.subj); + delfattach(&cfg,&msg); smb_freemsgmem(&msg); } continue; } idxbuf[l]=msg.idx; diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h index 3b652092ad..8162385b6f 100644 --- a/src/sbbs3/sbbs.h +++ b/src/sbbs3/sbbs.h @@ -424,7 +424,6 @@ public: /* mail.cpp */ int delmail(uint usernumber,int which); - void delfattach(uint to, char *title); void telluser(smbmsg_t* msg); void delallmail(uint usernumber); @@ -723,7 +722,7 @@ extern "C" { DLLEXPORT mail_t * DLLCALL loadmail(smb_t* smb, ulong* msgs, uint usernumber ,int which, long mode); DLLEXPORT void DLLCALL freemail(mail_t* mail); - + DLLEXPORT void DLLCALL delfattach(scfg_t*, smbmsg_t*); /* postmsg.cpp */ DLLEXPORT int DLLCALL savemsg(scfg_t* cfg, smb_t* smb ,uint subnum, smbmsg_t* msg, char* msgbuf); -- GitLab