Commit 6458c447 authored by rswindell's avatar rswindell
Browse files

Bugfix: smb.curmsg/msgs wasn't being updated/used in readmail.c. Required

loadmail() change which had a trickle-up effect to the higher level functions
that use loadmail().
parent 67d31695
......@@ -119,7 +119,7 @@ void DLLCALL delfattach(scfg_t* cfg, smbmsg_t* msg)
/* of pointers to mail_t (message numbers and attributes) */
/* smb_open(&smb) must be called prior */
/****************************************************************************/
mail_t* DLLCALL loadmail(smb_t* smb, ulong* msgs, uint usernumber
mail_t* DLLCALL loadmail(smb_t* smb, long* msgs, uint usernumber
,int which, long mode)
{
ulong l=0;
......
......@@ -505,7 +505,7 @@ static BOOL parse_header_object(JSContext* cx, private_t* p, JSObject* hdr, smbm
return(TRUE);
}
BOOL msg_offset_by_id(private_t* p, char* id, ulong* offset)
static BOOL msg_offset_by_id(private_t* p, char* id, long* offset)
{
smbmsg_t msg;
......
......@@ -151,7 +151,7 @@ void sbbs_t::telluser(smbmsg_t* msg)
void sbbs_t::delallmail(uint usernumber)
{
int i;
ulong l,msgs,deleted=0;
long l,msgs,deleted=0;
mail_t *mail;
smbmsg_t msg;
......
......@@ -641,7 +641,8 @@ static void pop3_thread(void* arg)
ulong l;
ulong lines;
ulong lines_sent;
ulong msgs,bytes,msgnum;
long msgs;
ulong bytes,msgnum;
SOCKET socket;
HOSTENT* host;
smb_t smb;
......
......@@ -50,7 +50,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
int mode;
uint i,j,k,conf;
long l,size,msgndx,posts,ex;
ulong mailmsgs=0;
long mailmsgs=0;
ulong totalcdt,totaltime,lastmsg
,files,submsgs,msgs,netfiles=0,preqwk=0;
ulong subs_scanned=0;
......@@ -284,7 +284,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
else
mode&=~QM_TO_QNET;
for(l=0;(ulong)l<mailmsgs;l++) {
for(l=0;l<mailmsgs;l++) {
bprintf("\b\b\b\b\b\b\b\b\b\b\b\b%4lu of %-4lu"
,l+1,mailmsgs);
......
......@@ -49,7 +49,7 @@ bool sbbs_t::pack_rep(uint hubnum)
int file,mode;
uint i,j,k;
long l,msgcnt,submsgs,posts,packedmail,netfiles=0,deleted;
ulong mailmsgs;
long mailmsgs;
ulong last,msgs;
post_t HUGE16 *post;
mail_t *mail;
......@@ -98,7 +98,7 @@ bool sbbs_t::pack_rep(uint hubnum)
packedmail=0;
if(mailmsgs) {
eprintf(LOG_INFO,"Packing NetMail for %s", cfg.qhub[hubnum]->id);
for(l=0;(ulong)l<mailmsgs;l++) {
for(l=0;l<mailmsgs;l++) {
// bprintf("\b\b\b\b\b%-5lu",l+1);
memset(&msg,0,sizeof(msg));
......@@ -270,7 +270,7 @@ bool sbbs_t::pack_rep(uint hubnum)
deleted=0;
/* Mark as READ and DELETE */
for(l=0;(ulong)l<mailmsgs;l++) {
for(l=0;l<mailmsgs;l++) {
if(mail[l].number>qwkmail_last)
continue;
memset(&msg,0,sizeof(msg));
......
......@@ -300,7 +300,7 @@ void sbbs_t::qwk_success(ulong msgcnt, char bi, char prepack)
{
char str[MAX_PATH+1];
int i;
ulong l,msgs,deleted=0;
long l,msgs,deleted=0;
mail_t *mail;
smbmsg_t msg;
......
......@@ -48,7 +48,6 @@ void sbbs_t::readmail(uint usernumber, int which)
int i,j;
int error;
int mismatches=0,act;
ulong msgs,curmsg;
long length,l,lm_mode;
ulong last;
bool replied;
......@@ -80,8 +79,8 @@ void sbbs_t::readmail(uint usernumber, int which)
lm_mode=LM_INCDEL;
else
lm_mode=0;
mail=loadmail(&smb,&msgs,usernumber,which,lm_mode);
if(!msgs) {
mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode);
if(!smb.msgs) {
if(which==MAIL_SENT)
bputs(text[NoMailSent]);
else if(which==MAIL_ALL)
......@@ -101,21 +100,21 @@ void sbbs_t::readmail(uint usernumber, int which)
else
act=NODE_RMAL;
action=act;
if(msgs>1 && which!=MAIL_ALL) {
if(smb.msgs>1 && which!=MAIL_ALL) {
if(which==MAIL_SENT)
bputs(text[MailSentLstHdr]);
else
bputs(text[MailWaitingLstHdr]);
for(curmsg=0;curmsg<msgs && !msgabort();curmsg++) {
for(smb.curmsg=0;smb.curmsg<smb.msgs && !msgabort();smb.curmsg++) {
if(msg.total_hfields)
smb_freemsgmem(&msg);
msg.total_hfields=0;
msg.idx.offset=mail[curmsg].offset;
if(!loadmsg(&msg,mail[curmsg].number))
msg.idx.offset=mail[smb.curmsg].offset;
if(!loadmsg(&msg,mail[smb.curmsg].number))
continue;
smb_unlockmsghdr(&smb,&msg);
bprintf(text[MailWaitingLstFmt],curmsg+1
bprintf(text[MailWaitingLstFmt],smb.curmsg+1
,which==MAIL_SENT ? msg.to
: (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous]
: msg.from
......@@ -129,16 +128,16 @@ void sbbs_t::readmail(uint usernumber, int which)
ASYNC;
if(!(sys_status&SS_ABORT)) {
bprintf(text[StartWithN],1L);
if((long)(curmsg=getnum(msgs))>0)
curmsg--;
else if((long)curmsg==-1) {
if((long)(smb.curmsg=getnum(smb.msgs))>0)
smb.curmsg--;
else if((long)smb.curmsg==-1) {
FREE(mail);
smb_close(&smb);
smb_stack(&smb,SMB_STACK_POP);
return; } }
sys_status&=~SS_ABORT; }
else {
curmsg=0;
smb.curmsg=0;
if(which==MAIL_ALL)
domsg=0; }
if(which==MAIL_SENT) {
......@@ -162,11 +161,11 @@ void sbbs_t::readmail(uint usernumber, int which)
smb_freemsgmem(&msg);
msg.total_hfields=0;
msg.idx.offset=mail[curmsg].offset;
msg.idx.number=mail[curmsg].number;
msg.idx.to=mail[curmsg].to;
msg.idx.from=mail[curmsg].from;
msg.idx.subj=mail[curmsg].subj;
msg.idx.offset=mail[smb.curmsg].offset;
msg.idx.number=mail[smb.curmsg].number;
msg.idx.to=mail[smb.curmsg].to;
msg.idx.from=mail[smb.curmsg].from;
msg.idx.subj=mail[smb.curmsg].subj;
if((i=smb_locksmbhdr(&smb))!=0) {
errormsg(WHERE,ERR_LOCK,smb.file,i);
......@@ -181,26 +180,26 @@ void sbbs_t::readmail(uint usernumber, int which)
if(smb.status.last_msg!=last) { /* New messages */
last=smb.status.last_msg;
FREE(mail);
mail=loadmail(&smb,&msgs,usernumber,which,lm_mode); /* So re-load */
if(!msgs)
mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode); /* So re-load */
if(!smb.msgs)
break;
for(curmsg=0;curmsg<msgs;curmsg++)
if(mail[curmsg].number==msg.idx.number)
for(smb.curmsg=0;smb.curmsg<smb.msgs;smb.curmsg++)
if(mail[smb.curmsg].number==msg.idx.number)
break;
if(curmsg>=msgs)
curmsg=(msgs-1);
if(smb.curmsg>=smb.msgs)
smb.curmsg=(smb.msgs-1);
continue; }
if(!loadmsg(&msg,mail[curmsg].number)) { /* Message header gone */
if(!loadmsg(&msg,mail[smb.curmsg].number)) { /* Message header gone */
if(mismatches>5) { /* We can't do this too many times in a row */
errormsg(WHERE,ERR_CHK,"message number",mail[curmsg].number);
errormsg(WHERE,ERR_CHK,"message number",mail[smb.curmsg].number);
break; }
FREE(mail);
mail=loadmail(&smb,&msgs,usernumber,which,lm_mode);
if(!msgs)
mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode);
if(!smb.msgs)
break;
if(curmsg>(msgs-1))
curmsg=(msgs-1);
if(smb.curmsg>(smb.msgs-1))
smb.curmsg=(smb.msgs-1);
mismatches++;
continue; }
smb_unlockmsghdr(&smb,&msg);
......@@ -299,7 +298,7 @@ void sbbs_t::readmail(uint usernumber, int which)
sprintf(str,"%sfile/%04u.in",cfg.data_dir,usernumber);
rmdir(str); }
if(which==MAIL_YOUR && !(msg.hdr.attr&MSG_READ)) {
mail[curmsg].attr|=MSG_READ;
mail[smb.curmsg].attr|=MSG_READ;
if(thisnode.status==NODE_INUSE)
telluser(&msg);
if(msg.total_hfields)
......@@ -327,21 +326,21 @@ void sbbs_t::readmail(uint usernumber, int which)
ASYNC;
if(which==MAIL_SENT)
bprintf(text[ReadingSentMail],curmsg+1,msgs);
bprintf(text[ReadingSentMail],smb.curmsg+1,smb.msgs);
else if(which==MAIL_ALL)
bprintf(text[ReadingAllMail],curmsg+1,msgs);
bprintf(text[ReadingAllMail],smb.curmsg+1,smb.msgs);
else
bprintf(text[ReadingMail],curmsg+1,msgs);
bprintf(text[ReadingMail],smb.curmsg+1,smb.msgs);
sprintf(str,"ADFLNQRT?<>[]{}-+");
if(SYSOP)
strcat(str,"CUSPH");
if(which!=MAIL_YOUR)
strcat(str,"E");
l=getkeys(str,msgs);
l=getkeys(str,smb.msgs);
if(l&0x80000000L) {
if(l==-1) /* ctrl-c */
break;
curmsg=(l&~0x80000000L)-1;
smb.curmsg=(l&~0x80000000L)-1;
continue; }
switch(l) {
case 'A': /* Auto-reply to last piece */
......@@ -410,7 +409,7 @@ void sbbs_t::readmail(uint usernumber, int which)
}
if(msg.hdr.attr&MSG_DELETE || !yesno(str2)) {
if(curmsg<msgs-1) curmsg++;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
else done=1;
break; }
/* Case 'D': must follow! */
......@@ -426,11 +425,11 @@ void sbbs_t::readmail(uint usernumber, int which)
if(loadmsg(&msg,msg.idx.number)) {
msg.hdr.attr^=MSG_DELETE;
msg.idx.attr=msg.hdr.attr;
// mail[curmsg].attr=msg.hdr.attr;
// mail[smb.curmsg].attr=msg.hdr.attr;
if((i=smb_putmsg(&smb,&msg))!=0)
errormsg(WHERE,ERR_WRITE,smb.file,i);
smb_unlockmsghdr(&smb,&msg); }
if(curmsg<msgs-1) curmsg++;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
else done=1;
break;
case 'F': /* Forward last piece */
......@@ -442,7 +441,7 @@ void sbbs_t::readmail(uint usernumber, int which)
if(!i)
break;
domsg=1;
if(curmsg<msgs-1) curmsg++;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
else done=1;
smb_getmsgidx(&smb,&msg);
forwardmail(&msg,i);
......@@ -458,7 +457,7 @@ void sbbs_t::readmail(uint usernumber, int which)
if(loadmsg(&msg,msg.idx.number)) {
msg.hdr.attr|=MSG_DELETE;
msg.idx.attr=msg.hdr.attr;
// mail[curmsg].attr=msg.hdr.attr;
// mail[smb.curmsg].attr=msg.hdr.attr;
if((i=smb_putmsg(&smb,&msg))!=0)
errormsg(WHERE,ERR_WRITE,smb.file,i);
smb_unlockmsghdr(&smb,&msg); }
......@@ -470,20 +469,20 @@ void sbbs_t::readmail(uint usernumber, int which)
break;
case 'L': /* List mail */
domsg=0;
bprintf(text[StartWithN],(long)curmsg+1);
if((i=getnum(msgs))>0)
bprintf(text[StartWithN],(long)smb.curmsg+1);
if((i=getnum(smb.msgs))>0)
i--;
else if(i==-1)
break;
else
i=curmsg;
i=smb.curmsg;
if(which==MAIL_SENT)
bputs(text[MailSentLstHdr]);
else if(which==MAIL_ALL)
bputs(text[MailOnSystemLstHdr]);
else
bputs(text[MailWaitingLstHdr]);
for(;(ulong)i<msgs && !msgabort();i++) {
for(;i<smb.msgs && !msgabort();i++) {
if(msg.total_hfields)
smb_freemsgmem(&msg);
msg.total_hfields=0;
......@@ -528,79 +527,79 @@ void sbbs_t::readmail(uint usernumber, int which)
smb_unlockmsghdr(&smb,&msg); }
break;
case '>':
for(i=curmsg+1;(ulong)i<msgs;i++)
for(i=smb.curmsg+1;i<smb.msgs;i++)
if(mail[i].subj==msg.idx.subj)
break;
if((ulong)i<msgs)
curmsg=i;
if(i<smb.msgs)
smb.curmsg=i;
else
domsg=0;
break;
case '<': /* Search Title backward */
for(i=curmsg-1;i>-1;i--)
for(i=smb.curmsg-1;i>-1;i--)
if(mail[i].subj==msg.idx.subj)
break;
if(i>-1)
curmsg=i;
smb.curmsg=i;
else
domsg=0;
break;
case '}': /* Search Author forward */
strcpy(str,msg.from);
for(i=curmsg+1;(ulong)i<msgs;i++)
for(i=smb.curmsg+1;i<smb.msgs;i++)
if(mail[i].from==msg.idx.from)
break;
if((ulong)i<msgs)
curmsg=i;
if(i<smb.msgs)
smb.curmsg=i;
else
domsg=0;
break;
case 'N': /* Got to next un-read message */
for(i=curmsg+1;(ulong)i<msgs;i++)
for(i=smb.curmsg+1;i<smb.msgs;i++)
if(!(mail[i].attr&MSG_READ))
break;
if((ulong)i<msgs)
curmsg=i;
if(i<smb.msgs)
smb.curmsg=i;
else
domsg=0;
break;
case '{': /* Search Author backward */
strcpy(str,msg.from);
for(i=curmsg-1;i>-1;i--)
for(i=smb.curmsg-1;i>-1;i--)
if(mail[i].from==msg.idx.from)
break;
if(i>-1)
curmsg=i;
smb.curmsg=i;
else
domsg=0;
break;
case ']': /* Search To User forward */
strcpy(str,msg.to);
for(i=curmsg+1;(ulong)i<msgs;i++)
for(i=smb.curmsg+1;i<smb.msgs;i++)
if(mail[i].to==msg.idx.to)
break;
if((ulong)i<msgs)
curmsg=i;
if(i<smb.msgs)
smb.curmsg=i;
else
domsg=0;
break;
case '[': /* Search To User backward */
strcpy(str,msg.to);
for(i=curmsg-1;i>-1;i--)
for(i=smb.curmsg-1;i>-1;i--)
if(mail[i].to==msg.idx.to)
break;
if(i>-1)
curmsg=i;
smb.curmsg=i;
else
domsg=0;
break;
case 0:
case '+':
if(curmsg<msgs-1) curmsg++;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
else done=1;
break;
case '-':
if(curmsg>0) curmsg--;
if(smb.curmsg>0) smb.curmsg--;
break;
case 'S':
domsg=0;
......@@ -617,11 +616,11 @@ void sbbs_t::readmail(uint usernumber, int which)
break;
case 'T':
domsg=0;
i=curmsg;
i=smb.curmsg;
if(i) i++;
j=i+10;
if((ulong)j>msgs)
j=msgs;
if(j>smb.msgs)
j=smb.msgs;
if(which==MAIL_SENT)
bputs(text[MailSentLstHdr]);
......@@ -655,7 +654,7 @@ void sbbs_t::readmail(uint usernumber, int which)
,msg.subj);
smb_freemsgmem(&msg);
msg.total_hfields=0; }
curmsg=(i-1);
smb.curmsg=(i-1);
break;
case 'U': /* user edit */
msg.hdr.number=msg.idx.number;
......@@ -668,7 +667,7 @@ void sbbs_t::readmail(uint usernumber, int which)
msg.hdr.number=msg.idx.number;
smb_getmsgidx(&smb,&msg);
purgeuser(msg.idx.from);
if(curmsg<msgs-1) curmsg++;
if(smb.curmsg<smb.msgs-1) smb.curmsg++;
break;
case '?':
strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL
......@@ -685,7 +684,7 @@ void sbbs_t::readmail(uint usernumber, int which)
if(msg.total_hfields)
smb_freemsgmem(&msg);
if(msgs)
if(smb.msgs)
FREE(mail);
/***************************************/
......
......@@ -783,7 +783,7 @@ extern "C" {
/* getmail.c */
DLLEXPORT int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent);
DLLEXPORT mail_t * DLLCALL loadmail(smb_t* smb, ulong* msgs, uint usernumber
DLLEXPORT mail_t * DLLCALL loadmail(smb_t* smb, long* msgs, uint usernumber
,int which, long mode);
DLLEXPORT void DLLCALL freemail(mail_t* mail);
DLLEXPORT void DLLCALL delfattach(scfg_t*, smbmsg_t*);
......
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