|
|
1.1 ! root 1: /* readmail.cpp */ ! 2: ! 3: /* Synchronet private mail reading function */ ! 4: ! 5: /* $Id: readmail.cpp,v 1.5 2000/12/11 23:21:12 rswindell Exp $ */ ! 6: ! 7: /**************************************************************************** ! 8: * @format.tab-size 4 (Plain Text/Source Code File Header) * ! 9: * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * ! 10: * * ! 11: * Copyright 2000 Rob Swindell - http://www.synchro.net/copyright.html * ! 12: * * ! 13: * This program is free software; you can redistribute it and/or * ! 14: * modify it under the terms of the GNU General Public License * ! 15: * as published by the Free Software Foundation; either version 2 * ! 16: * of the License, or (at your option) any later version. * ! 17: * See the GNU General Public License for more details: gpl.txt or * ! 18: * http://www.fsf.org/copyleft/gpl.html * ! 19: * * ! 20: * Anonymous FTP access to the most recent released source is available at * ! 21: * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net * ! 22: * * ! 23: * Anonymous CVS access to the development source and modification history * ! 24: * is available at cvs.synchro.net:/cvsroot/sbbs, example: * ! 25: * cvs -d :pserver:[email protected]:/cvsroot/sbbs login * ! 26: * (just hit return, no password is necessary) * ! 27: * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src * ! 28: * * ! 29: * For Synchronet coding style and modification guidelines, see * ! 30: * http://www.synchro.net/source.html * ! 31: * * ! 32: * You are encouraged to submit any modifications (preferably in Unix diff * ! 33: * format) via e-mail to [email protected] * ! 34: * * ! 35: * Note: If this box doesn't appear square, then you need to fix your tabs. * ! 36: ****************************************************************************/ ! 37: ! 38: #include "sbbs.h" ! 39: ! 40: /****************************************************************************/ ! 41: /* Reads mail waiting for usernumber. */ ! 42: /****************************************************************************/ ! 43: void sbbs_t::readmail(uint usernumber, int which) ! 44: { ! 45: char str[256],str2[256],str3[256],done=0,domsg=1 ! 46: ,*p,*tp,*sp,ch; ! 47: char tmp[512]; ! 48: int i,j; ! 49: int mismatches=0,act; ! 50: ulong msgs,curmsg; ! 51: long length,l,lm_mode; ! 52: ulong last; ! 53: bool replied; ! 54: file_t fd; ! 55: mail_t *mail; ! 56: smbmsg_t msg; ! 57: ! 58: msg.total_hfields=0; /* init to NULL, cause not allocated yet */ ! 59: ! 60: fd.dir=cfg.total_dirs+1; /* temp dir for file attachments */ ! 61: ! 62: if((i=smb_stack(&smb,SMB_STACK_PUSH))!=0) { ! 63: errormsg(WHERE,ERR_OPEN,"MAIL",i); ! 64: return; } ! 65: sprintf(smb.file,"%smail",cfg.data_dir); ! 66: smb.retry_time=cfg.smb_retry_time; ! 67: if((i=smb_open(&smb))!=0) { ! 68: smb_stack(&smb,SMB_STACK_POP); ! 69: errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error); ! 70: return; } ! 71: ! 72: if(cfg.sys_misc&SM_SYSVDELM && (SYSOP || cfg.sys_misc&SM_USRVDELM)) ! 73: lm_mode=LM_INCDEL; ! 74: else ! 75: lm_mode=0; ! 76: mail=loadmail(&smb,&msgs,usernumber,which,lm_mode); ! 77: if(!msgs) { ! 78: if(which==MAIL_SENT) ! 79: bputs(text[NoMailSent]); ! 80: else if(which==MAIL_ALL) ! 81: bputs(text[NoMailOnSystem]); ! 82: else ! 83: bputs(text[NoMailWaiting]); ! 84: smb_close(&smb); ! 85: smb_stack(&smb,SMB_STACK_POP); ! 86: return; } ! 87: ! 88: last=smb.status.last_msg; ! 89: ! 90: if(which==MAIL_SENT) ! 91: act=NODE_RSML; ! 92: else if(which==MAIL_ALL) ! 93: act=NODE_SYSP; ! 94: else ! 95: act=NODE_RMAL; ! 96: action=act; ! 97: if(msgs>1 && which!=MAIL_ALL) { ! 98: if(which==MAIL_SENT) ! 99: bputs(text[MailSentLstHdr]); ! 100: else ! 101: bputs(text[MailWaitingLstHdr]); ! 102: ! 103: for(curmsg=0;curmsg<msgs && !msgabort();curmsg++) { ! 104: if(msg.total_hfields) ! 105: smb_freemsgmem(&msg); ! 106: msg.total_hfields=0; ! 107: msg.idx.offset=mail[curmsg].offset; ! 108: if(!loadmsg(&msg,mail[curmsg].number)) ! 109: continue; ! 110: smb_unlockmsghdr(&smb,&msg); ! 111: bprintf(text[MailWaitingLstFmt],curmsg+1 ! 112: ,which==MAIL_SENT ? msg.to ! 113: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous] ! 114: : msg.from ! 115: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' ! 116: : msg.hdr.attr&MSG_READ ? ' ' ! 117: : msg.from_net.type || msg.to_net.type ? 'N':'*' ! 118: ,msg.subj); ! 119: smb_freemsgmem(&msg); ! 120: msg.total_hfields=0; } ! 121: ! 122: ASYNC; ! 123: if(!(sys_status&SS_ABORT)) { ! 124: bprintf(text[StartWithN],1L); ! 125: if((long)(curmsg=getnum(msgs))>0) ! 126: curmsg--; ! 127: else if(curmsg==-1) { ! 128: FREE(mail); ! 129: smb_close(&smb); ! 130: smb_stack(&smb,SMB_STACK_POP); ! 131: return; } } ! 132: sys_status&=~SS_ABORT; } ! 133: else { ! 134: curmsg=0; ! 135: if(which==MAIL_ALL) ! 136: domsg=0; } ! 137: if(which==MAIL_SENT) ! 138: logline("E","Read sent mail"); ! 139: else if(which==MAIL_ALL) ! 140: logline("S+","Read all mail"); ! 141: else ! 142: logline("E","Read mail"); ! 143: if(useron.misc&RIP) { ! 144: strcpy(str,which==MAIL_YOUR ? "MAILREAD" : which==MAIL_ALL ? ! 145: "ALLMAIL" : "SENTMAIL"); ! 146: menu(str); } ! 147: while(online && !done) { ! 148: action=act; ! 149: ! 150: if(msg.total_hfields) ! 151: smb_freemsgmem(&msg); ! 152: msg.total_hfields=0; ! 153: ! 154: msg.idx.offset=mail[curmsg].offset; ! 155: msg.idx.number=mail[curmsg].number; ! 156: msg.idx.to=mail[curmsg].to; ! 157: msg.idx.from=mail[curmsg].from; ! 158: msg.idx.subj=mail[curmsg].subj; ! 159: ! 160: if((i=smb_locksmbhdr(&smb))!=0) { ! 161: errormsg(WHERE,ERR_LOCK,smb.file,i); ! 162: break; } ! 163: ! 164: if((i=smb_getstatus(&smb))!=0) { ! 165: smb_unlocksmbhdr(&smb); ! 166: errormsg(WHERE,ERR_READ,smb.file,i); ! 167: break; } ! 168: smb_unlocksmbhdr(&smb); ! 169: ! 170: if(smb.status.last_msg!=last) { /* New messages */ ! 171: last=smb.status.last_msg; ! 172: FREE(mail); ! 173: mail=loadmail(&smb,&msgs,usernumber,which,lm_mode); /* So re-load */ ! 174: if(!msgs) ! 175: break; ! 176: for(curmsg=0;curmsg<msgs;curmsg++) ! 177: if(mail[curmsg].number==msg.idx.number) ! 178: break; ! 179: if(curmsg>=msgs) ! 180: curmsg=(msgs-1); ! 181: continue; } ! 182: ! 183: if(!loadmsg(&msg,mail[curmsg].number)) { /* Message header gone */ ! 184: if(mismatches>5) { /* We can't do this too many times in a row */ ! 185: errormsg(WHERE,ERR_CHK,"message number",mail[curmsg].number); ! 186: break; } ! 187: FREE(mail); ! 188: mail=loadmail(&smb,&msgs,usernumber,which,lm_mode); ! 189: if(!msgs) ! 190: break; ! 191: if(curmsg>(msgs-1)) ! 192: curmsg=(msgs-1); ! 193: mismatches++; ! 194: continue; } ! 195: smb_unlockmsghdr(&smb,&msg); ! 196: msg.idx.attr=msg.hdr.attr; ! 197: ! 198: mismatches=0; ! 199: ! 200: if(domsg && !(sys_status&SS_ABORT)) { ! 201: ! 202: show_msg(&msg ! 203: ,msg.from_ext && msg.idx.from==1 && !msg.from_net.type ! 204: ? 0:P_NOATCODES); ! 205: ! 206: if(msg.hdr.auxattr&MSG_FILEATTACH) { /* Attached file */ ! 207: smb_getmsgidx(&smb,&msg); ! 208: strcpy(str,msg.subj); /* filenames in title */ ! 209: strupr(str); ! 210: tp=str; ! 211: while(online) { ! 212: p=strchr(tp,SP); ! 213: if(p) *p=0; ! 214: sp=strrchr(tp,'/'); /* sp is slash pointer */ ! 215: if(!sp) sp=strrchr(tp,'\\'); ! 216: if(sp) tp=sp+1; ! 217: padfname(tp,fd.name); ! 218: sprintf(str2,"%sfile/%04u.in/%s" /* str2 is path/fname */ ! 219: ,cfg.data_dir,msg.idx.to,tp); ! 220: length=flength(str2); ! 221: if(length<1) ! 222: bputs(text[FileNotFound]); ! 223: else if(!(useron.exempt&FLAG('T')) && cur_cps && !SYSOP ! 224: && length/(long)cur_cps>(time_t)timeleft) ! 225: bputs(text[NotEnoughTimeToDl]); ! 226: else { ! 227: sprintf(str3,text[DownloadAttachedFileQ] ! 228: ,tp,ultoac(length,tmp)); ! 229: if(length>0L && yesno(str3)) { ! 230: if(online==ON_LOCAL) { ! 231: bputs(text[EnterPath]); ! 232: if(getstr(str3,60,K_LINE|K_UPPER)) { ! 233: backslashcolon(str3); ! 234: sprintf(tmp,"%s%s",str3,tp); ! 235: if(!mv(str2,tmp,which!=MAIL_YOUR)) { ! 236: logon_dlb+=length; ! 237: logon_dls++; ! 238: useron.dls=(ushort)adjustuserrec(&cfg,useron.number ! 239: ,U_DLS,5,1); ! 240: useron.dlb=adjustuserrec(&cfg,useron.number ! 241: ,U_DLB,10,length); ! 242: bprintf(text[FileNBytesSent] ! 243: ,fd.name,ultoac(length,tmp)); } } } ! 244: ! 245: else { /* Remote User */ ! 246: menu("dlprot"); ! 247: mnemonics(text[ProtocolOrQuit]); ! 248: strcpy(str3,"Q"); ! 249: for(i=0;i<cfg.total_prots;i++) ! 250: if(cfg.prot[i]->dlcmd[0] ! 251: && chk_ar(cfg.prot[i]->ar,&useron)) { ! 252: sprintf(tmp,"%c",cfg.prot[i]->mnemonic); ! 253: strcat(str3,tmp); } ! 254: ch=(char)getkeys(str3,0); ! 255: for(i=0;i<cfg.total_prots;i++) ! 256: if(cfg.prot[i]->dlcmd[0] && ch==cfg.prot[i]->mnemonic ! 257: && chk_ar(cfg.prot[i]->ar,&useron)) ! 258: break; ! 259: if(i<cfg.total_prots) { ! 260: j=protocol(cmdstr(cfg.prot[i]->dlcmd,str2,nulstr ! 261: ,NULL),0); ! 262: if((cfg.prot[i]->misc&PROT_DSZLOG ! 263: && checkprotlog(&fd)) ! 264: || (!(cfg.prot[i]->misc&PROT_DSZLOG) && !j)) { ! 265: if(which==MAIL_YOUR) ! 266: remove(str2); ! 267: logon_dlb+=length; /* Update stats */ ! 268: logon_dls++; ! 269: useron.dls=(ushort)adjustuserrec(&cfg,useron.number ! 270: ,U_DLS,5,1); ! 271: useron.dlb=adjustuserrec(&cfg,useron.number ! 272: ,U_DLB,10,length); ! 273: bprintf(text[FileNBytesSent] ! 274: ,fd.name,ultoac(length,tmp)); ! 275: sprintf(str3 ! 276: ,"Downloaded attached file: %s" ! 277: ,fd.name); ! 278: logline("D-",str3); } ! 279: autohangup(); } } } } ! 280: if(!p) ! 281: break; ! 282: tp=p+1; ! 283: while(*tp==SP) tp++; } ! 284: sprintf(str,"%sfile/%04u.in",cfg.data_dir,usernumber); ! 285: rmdir(str); } ! 286: if(which==MAIL_YOUR && !(msg.hdr.attr&MSG_READ)) { ! 287: mail[curmsg].attr|=MSG_READ; ! 288: if(thisnode.status==NODE_INUSE) ! 289: telluser(&msg); ! 290: if(msg.total_hfields) ! 291: smb_freemsgmem(&msg); ! 292: msg.total_hfields=0; ! 293: msg.idx.offset=0; /* Search by number */ ! 294: if(!smb_locksmbhdr(&smb)) { /* Lock the entire base */ ! 295: if(loadmsg(&msg,msg.idx.number)) { ! 296: msg.hdr.attr|=MSG_READ; ! 297: msg.idx.attr=msg.hdr.attr; ! 298: if((i=smb_putmsg(&smb,&msg))!=0) ! 299: errormsg(WHERE,ERR_WRITE,smb.file,i); ! 300: smb_unlockmsghdr(&smb,&msg); } ! 301: smb_unlocksmbhdr(&smb); } ! 302: if(!msg.total_hfields) { /* unsuccessful reload */ ! 303: domsg=0; ! 304: continue; } } ! 305: } ! 306: else domsg=1; ! 307: ! 308: if(useron.misc&WIP) { ! 309: strcpy(str,which==MAIL_YOUR ? "MAILREAD" : which==MAIL_ALL ? ! 310: "ALLMAIL" : "SENTMAIL"); ! 311: menu(str); } ! 312: ! 313: ASYNC; ! 314: if(which==MAIL_SENT) ! 315: bprintf(text[ReadingSentMail],curmsg+1,msgs); ! 316: else if(which==MAIL_ALL) ! 317: bprintf(text[ReadingAllMail],curmsg+1,msgs); ! 318: else ! 319: bprintf(text[ReadingMail],curmsg+1,msgs); ! 320: sprintf(str,"ADFLNQRT?<>[]{}-+"); ! 321: if(SYSOP) ! 322: strcat(str,"CUSP"); ! 323: if(which!=MAIL_YOUR) ! 324: strcat(str,"E"); ! 325: l=getkeys(str,msgs); ! 326: if(l&0x80000000L) { ! 327: if(l==-1) /* ctrl-c */ ! 328: break; ! 329: curmsg=(l&~0x80000000L)-1; ! 330: continue; } ! 331: switch(l) { ! 332: case 'A': /* Auto-reply to last piece */ ! 333: case 'R': ! 334: if(l==(cfg.sys_misc&SM_RA_EMU ? 'A' : 'R')) /* re-read last message */ ! 335: break; ! 336: ! 337: if(which==MAIL_SENT) ! 338: break; ! 339: if((msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP) { ! 340: bputs(text[CantReplyToAnonMsg]); ! 341: break; } ! 342: ! 343: quotemsg(&msg,1); ! 344: ! 345: if(msg.from_net.type==NET_FIDO) /* FidoNet type */ ! 346: sprintf(str,"%s @%s",msg.from ! 347: ,faddrtoa(*(faddr_t *)msg.from_net.addr)); ! 348: else if(msg.from_net.type==NET_INTERNET) ! 349: strcpy(str,(char *)msg.from_net.addr); ! 350: else if(msg.from_net.type) ! 351: sprintf(str,"%s@%s",msg.from,msg.from_net.addr); ! 352: else /* No net */ ! 353: strcpy(str,msg.from); ! 354: ! 355: strcpy(str2,str); ! 356: ! 357: bputs(text[Email]); ! 358: if(!getstr(str,64,K_EDIT|K_AUTODEL)) ! 359: break; ! 360: msg.hdr.number=msg.idx.number; ! 361: smb_getmsgidx(&smb,&msg); ! 362: ! 363: if(!stricmp(str2,str)) /* Reply to sender */ ! 364: sprintf(str2,text[Regarding],msg.subj); ! 365: else /* Reply to other */ ! 366: sprintf(str2,text[RegardingByOn],msg.subj,msg.from ! 367: ,timestr((time_t *)&msg.hdr.when_written.time)); ! 368: ! 369: p=strrchr(str,'@'); ! 370: if(p) { /* name @addr */ ! 371: replied=netmail(str,msg.subj,WM_QUOTE); ! 372: sprintf(str2,text[DeleteMailQ],msg.from); } ! 373: else { ! 374: if(!msg.from_net.type && !stricmp(str,msg.from)) ! 375: replied=email(msg.idx.from,str2,msg.subj,WM_EMAIL|WM_QUOTE); ! 376: else if(!stricmp(str,"SYSOP")) ! 377: replied=email(1,str2,msg.subj,WM_EMAIL|WM_QUOTE); ! 378: else if((i=finduser(str))!=0) ! 379: replied=email(i,str2,msg.subj,WM_EMAIL|WM_QUOTE); ! 380: sprintf(str2,text[DeleteMailQ],msg.from); } ! 381: ! 382: if(replied==true && !(msg.hdr.attr&MSG_REPLIED)) { ! 383: if(msg.total_hfields) ! 384: smb_freemsgmem(&msg); ! 385: msg.total_hfields=0; ! 386: msg.idx.offset=0; ! 387: if(loadmsg(&msg,msg.idx.number)) { ! 388: msg.hdr.attr|=MSG_REPLIED; ! 389: msg.idx.attr=msg.hdr.attr; ! 390: if((i=smb_putmsg(&smb,&msg))!=0) ! 391: errormsg(WHERE,ERR_WRITE,smb.file,i); ! 392: smb_unlockmsghdr(&smb,&msg); } ! 393: } ! 394: ! 395: if(!yesno(str2)) { ! 396: if(curmsg<msgs-1) curmsg++; ! 397: else done=1; ! 398: break; } ! 399: /* Case 'D': must follow! */ ! 400: case 'D': /* Delete last piece (toggle) */ ! 401: if(msg.hdr.attr&MSG_PERMANENT) { ! 402: bputs("\r\nPermanent message.\r\n"); ! 403: domsg=0; ! 404: break; } ! 405: if(msg.total_hfields) ! 406: smb_freemsgmem(&msg); ! 407: msg.total_hfields=0; ! 408: msg.idx.offset=0; ! 409: if(loadmsg(&msg,msg.idx.number)) { ! 410: msg.hdr.attr^=MSG_DELETE; ! 411: msg.idx.attr=msg.hdr.attr; ! 412: // mail[curmsg].attr=msg.hdr.attr; ! 413: if((i=smb_putmsg(&smb,&msg))!=0) ! 414: errormsg(WHERE,ERR_WRITE,smb.file,i); ! 415: smb_unlockmsghdr(&smb,&msg); } ! 416: if(curmsg<msgs-1) curmsg++; ! 417: else done=1; ! 418: break; ! 419: case 'F': /* Forward last piece */ ! 420: domsg=0; ! 421: bputs(text[ForwardMailTo]); ! 422: if(!getstr(str,LEN_ALIAS,K_UPRLWR)) ! 423: break; ! 424: i=finduser(str); ! 425: if(!i) ! 426: break; ! 427: domsg=1; ! 428: if(curmsg<msgs-1) curmsg++; ! 429: else done=1; ! 430: smb_getmsgidx(&smb,&msg); ! 431: forwardmail(&msg,i); ! 432: if(msg.hdr.attr&MSG_PERMANENT) ! 433: break; ! 434: sprintf(str2,text[DeleteMailQ],msg.from); ! 435: if(!yesno(str2)) ! 436: break; ! 437: if(msg.total_hfields) ! 438: smb_freemsgmem(&msg); ! 439: msg.total_hfields=0; ! 440: msg.idx.offset=0; ! 441: if(loadmsg(&msg,msg.idx.number)) { ! 442: msg.hdr.attr|=MSG_DELETE; ! 443: msg.idx.attr=msg.hdr.attr; ! 444: // mail[curmsg].attr=msg.hdr.attr; ! 445: if((i=smb_putmsg(&smb,&msg))!=0) ! 446: errormsg(WHERE,ERR_WRITE,smb.file,i); ! 447: smb_unlockmsghdr(&smb,&msg); } ! 448: ! 449: break; ! 450: case 'L': /* List mail */ ! 451: domsg=0; ! 452: bprintf(text[StartWithN],(long)curmsg+1); ! 453: if((i=getnum(msgs))>0) ! 454: i--; ! 455: else if(i==-1) ! 456: break; ! 457: else ! 458: i=curmsg; ! 459: if(which==MAIL_SENT) ! 460: bputs(text[MailSentLstHdr]); ! 461: else if(which==MAIL_ALL) ! 462: bputs(text[MailOnSystemLstHdr]); ! 463: else ! 464: bputs(text[MailWaitingLstHdr]); ! 465: for(;(ulong)i<msgs && !msgabort();i++) { ! 466: if(msg.total_hfields) ! 467: smb_freemsgmem(&msg); ! 468: msg.total_hfields=0; ! 469: msg.idx.offset=mail[i].offset; ! 470: if(!loadmsg(&msg,mail[i].number)) ! 471: continue; ! 472: smb_unlockmsghdr(&smb,&msg); ! 473: if(which==MAIL_ALL) ! 474: bprintf(text[MailOnSystemLstFmt] ! 475: ,i+1,msg.from,msg.to ! 476: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' ! 477: : msg.hdr.attr&MSG_READ ? SP ! 478: : msg.from_net.type || msg.to_net.type ? 'N':'*' ! 479: ,msg.subj); ! 480: else ! 481: bprintf(text[MailWaitingLstFmt],i+1 ! 482: ,which==MAIL_SENT ? msg.to ! 483: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ! 484: ? text[Anonymous] : msg.from ! 485: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' ! 486: : msg.hdr.attr&MSG_READ ? SP ! 487: : msg.from_net.type || msg.to_net.type ? 'N':'*' ! 488: ,msg.subj); ! 489: smb_freemsgmem(&msg); ! 490: msg.total_hfields=0; } ! 491: break; ! 492: case 'Q': ! 493: done=1; ! 494: break; ! 495: case 'C': /* Change attributes of last piece */ ! 496: i=chmsgattr(msg.hdr.attr); ! 497: if(msg.hdr.attr==i) ! 498: break; ! 499: if(msg.total_hfields) ! 500: smb_freemsgmem(&msg); ! 501: msg.total_hfields=0; ! 502: msg.idx.offset=0; ! 503: if(loadmsg(&msg,msg.idx.number)) { ! 504: msg.hdr.attr=msg.idx.attr=(ushort)i; ! 505: if((i=smb_putmsg(&smb,&msg))!=0) ! 506: errormsg(WHERE,ERR_WRITE,smb.file,i); ! 507: smb_unlockmsghdr(&smb,&msg); } ! 508: break; ! 509: case '>': ! 510: for(i=curmsg+1;(ulong)i<msgs;i++) ! 511: if(mail[i].subj==msg.idx.subj) ! 512: break; ! 513: if((ulong)i<msgs) ! 514: curmsg=i; ! 515: else ! 516: domsg=0; ! 517: break; ! 518: case '<': /* Search Title backward */ ! 519: for(i=curmsg-1;i>-1;i--) ! 520: if(mail[i].subj==msg.idx.subj) ! 521: break; ! 522: if(i>-1) ! 523: curmsg=i; ! 524: else ! 525: domsg=0; ! 526: break; ! 527: case '}': /* Search Author forward */ ! 528: strcpy(str,msg.from); ! 529: for(i=curmsg+1;(ulong)i<msgs;i++) ! 530: if(mail[i].from==msg.idx.from) ! 531: break; ! 532: if((ulong)i<msgs) ! 533: curmsg=i; ! 534: else ! 535: domsg=0; ! 536: break; ! 537: case 'N': /* Got to next un-read message */ ! 538: for(i=curmsg+1;(ulong)i<msgs;i++) ! 539: if(!(mail[i].attr&MSG_READ)) ! 540: break; ! 541: if((ulong)i<msgs) ! 542: curmsg=i; ! 543: else ! 544: domsg=0; ! 545: break; ! 546: case '{': /* Search Author backward */ ! 547: strcpy(str,msg.from); ! 548: for(i=curmsg-1;i>-1;i--) ! 549: if(mail[i].from==msg.idx.from) ! 550: break; ! 551: if(i>-1) ! 552: curmsg=i; ! 553: else ! 554: domsg=0; ! 555: break; ! 556: case ']': /* Search To User forward */ ! 557: strcpy(str,msg.to); ! 558: for(i=curmsg+1;(ulong)i<msgs;i++) ! 559: if(mail[i].to==msg.idx.to) ! 560: break; ! 561: if((ulong)i<msgs) ! 562: curmsg=i; ! 563: else ! 564: domsg=0; ! 565: break; ! 566: case '[': /* Search To User backward */ ! 567: strcpy(str,msg.to); ! 568: for(i=curmsg-1;(ulong)i>-1;i--) ! 569: if(mail[i].to==msg.idx.to) ! 570: break; ! 571: if((ulong)i>-1) ! 572: curmsg=i; ! 573: else ! 574: domsg=0; ! 575: break; ! 576: case 0: ! 577: case '+': ! 578: if(curmsg<msgs-1) curmsg++; ! 579: else done=1; ! 580: break; ! 581: case '-': ! 582: if(curmsg>0) curmsg--; ! 583: break; ! 584: case 'S': ! 585: domsg=0; ! 586: /* ! 587: if(!yesno(text[SaveMsgToFile])) ! 588: break; ! 589: */ ! 590: bputs(text[FileToWriteTo]); ! 591: if(getstr(str,40,K_LINE|K_UPPER)) ! 592: msgtotxt(&msg,str,1,1); ! 593: break; ! 594: case 'E': ! 595: editmsg(&msg,INVALID_SUB); ! 596: break; ! 597: case 'T': ! 598: domsg=0; ! 599: i=curmsg; ! 600: if(i) i++; ! 601: j=i+10; ! 602: if((ulong)j>msgs) ! 603: j=msgs; ! 604: ! 605: if(which==MAIL_SENT) ! 606: bputs(text[MailSentLstHdr]); ! 607: else if(which==MAIL_ALL) ! 608: bputs(text[MailOnSystemLstHdr]); ! 609: else ! 610: bputs(text[MailWaitingLstHdr]); ! 611: for(;i<j;i++) { ! 612: if(msg.total_hfields) ! 613: smb_freemsgmem(&msg); ! 614: msg.total_hfields=0; ! 615: msg.idx.offset=mail[i].offset; ! 616: if(!loadmsg(&msg,mail[i].number)) ! 617: continue; ! 618: smb_unlockmsghdr(&smb,&msg); ! 619: if(which==MAIL_ALL) ! 620: bprintf(text[MailOnSystemLstFmt] ! 621: ,i+1,msg.from,msg.to ! 622: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' ! 623: : msg.hdr.attr&MSG_READ ? SP ! 624: : msg.from_net.type || msg.to_net.type ? 'N':'*' ! 625: ,msg.subj); ! 626: else ! 627: bprintf(text[MailWaitingLstFmt],i+1 ! 628: ,which==MAIL_SENT ? msg.to ! 629: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ! 630: ? text[Anonymous] : msg.from ! 631: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R' ! 632: : msg.hdr.attr&MSG_READ ? SP ! 633: : msg.from_net.type || msg.to_net.type ? 'N':'*' ! 634: ,msg.subj); ! 635: smb_freemsgmem(&msg); ! 636: msg.total_hfields=0; } ! 637: curmsg=(i-1); ! 638: break; ! 639: case 'U': /* user edit */ ! 640: msg.hdr.number=msg.idx.number; ! 641: smb_getmsgidx(&smb,&msg); ! 642: useredit(which==MAIL_SENT ? msg.idx.to : msg.idx.from,0); ! 643: break; ! 644: case 'P': /* Purge author and all mail to/from */ ! 645: if(noyes(text[AreYouSureQ])) ! 646: break; ! 647: msg.hdr.number=msg.idx.number; ! 648: smb_getmsgidx(&smb,&msg); ! 649: purgeuser(msg.idx.from); ! 650: if(curmsg<msgs-1) curmsg++; ! 651: break; ! 652: case '?': ! 653: strcpy(str,which==MAIL_YOUR ? "MAILREAD" : which==MAIL_ALL ! 654: ? "ALLMAIL" : "SENTMAIL"); ! 655: menu(str); ! 656: if(SYSOP && which==MAIL_SENT) ! 657: menu("syssmail"); ! 658: else if(SYSOP && which==MAIL_YOUR) ! 659: menu("sysmailr"); /* Sysop Mail Read */ ! 660: domsg=0; ! 661: break; ! 662: } } ! 663: ! 664: if(msg.total_hfields) ! 665: smb_freemsgmem(&msg); ! 666: ! 667: if(msgs) ! 668: FREE(mail); ! 669: ! 670: /***************************************/ ! 671: /* Delete messages marked for deletion */ ! 672: /***************************************/ ! 673: ! 674: if(cfg.sys_misc&SM_DELEMAIL) { ! 675: if((i=smb_locksmbhdr(&smb))!=0) /* Lock the base, so nobody */ ! 676: errormsg(WHERE,ERR_LOCK,smb.file,i); /* messes with the index */ ! 677: else ! 678: delmail(usernumber,which); } ! 679: ! 680: smb_close(&smb); ! 681: smb_stack(&smb,SMB_STACK_POP); ! 682: } ! 683:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.