|
|
1.1 root 1: /* readmail.cpp */
2:
3: /* Synchronet private mail reading function */
4:
5: /* $Id: readmail.cpp,v 1.39 2006/11/02 00:19:32 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 2005 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 error;
50: int mismatches=0,act;
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: if(which==MAIL_SENT && useron.rest&FLAG('K')) {
59: bputs(text[R_ReadSentMail]);
60: return;
61: }
62:
63: msg.total_hfields=0; /* init to NULL, cause not allocated yet */
64:
65: fd.dir=cfg.total_dirs+1; /* temp dir for file attachments */
66:
67: if((i=smb_stack(&smb,SMB_STACK_PUSH))!=0) {
68: errormsg(WHERE,ERR_OPEN,"MAIL",i);
69: return; }
70: sprintf(smb.file,"%smail",cfg.data_dir);
71: smb.retry_time=cfg.smb_retry_time;
72: smb.subnum=INVALID_SUB;
73: if((i=smb_open(&smb))!=0) {
74: smb_stack(&smb,SMB_STACK_POP);
75: errormsg(WHERE,ERR_OPEN,smb.file,i,smb.last_error);
76: return; }
77:
78: if(cfg.sys_misc&SM_SYSVDELM && (SYSOP || cfg.sys_misc&SM_USRVDELM))
79: lm_mode=LM_INCDEL;
80: else
81: lm_mode=0;
82: mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode);
83: if(!smb.msgs) {
84: if(which==MAIL_SENT)
85: bputs(text[NoMailSent]);
86: else if(which==MAIL_ALL)
87: bputs(text[NoMailOnSystem]);
88: else
89: bputs(text[NoMailWaiting]);
90: smb_close(&smb);
91: smb_stack(&smb,SMB_STACK_POP);
92: return; }
93:
94: last=smb.status.last_msg;
95:
96: if(which==MAIL_SENT)
97: act=NODE_RSML;
98: else if(which==MAIL_ALL)
99: act=NODE_SYSP;
100: else
101: act=NODE_RMAL;
102: action=act;
103: if(smb.msgs>1 && which!=MAIL_ALL) {
104: if(which==MAIL_SENT)
105: bputs(text[MailSentLstHdr]);
106: else
107: bputs(text[MailWaitingLstHdr]);
108:
109: for(smb.curmsg=0;smb.curmsg<smb.msgs && !msgabort();smb.curmsg++) {
110: if(msg.total_hfields)
111: smb_freemsgmem(&msg);
112: msg.total_hfields=0;
113: msg.idx.offset=mail[smb.curmsg].offset;
114: if(!loadmsg(&msg,mail[smb.curmsg].number))
115: continue;
116: smb_unlockmsghdr(&smb,&msg);
117: bprintf(text[MailWaitingLstFmt],smb.curmsg+1
118: ,which==MAIL_SENT ? msg.to
119: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP ? text[Anonymous]
120: : msg.from
121: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
122: : msg.hdr.attr&MSG_READ ? ' '
123: : msg.from_net.type || msg.to_net.type ? 'N':'*'
124: ,msg.subj);
125: smb_freemsgmem(&msg);
126: msg.total_hfields=0; }
127:
128: ASYNC;
129: if(!(sys_status&SS_ABORT)) {
130: bprintf(text[StartWithN],1L);
131: if((long)(smb.curmsg=getnum(smb.msgs))>0)
132: smb.curmsg--;
133: else if((long)smb.curmsg==-1) {
134: free(mail);
135: smb_close(&smb);
136: smb_stack(&smb,SMB_STACK_POP);
137: return; } }
138: sys_status&=~SS_ABORT; }
139: else {
140: smb.curmsg=0;
141: if(which==MAIL_ALL)
142: domsg=0; }
143: if(which==MAIL_SENT) {
144: sprintf(str,"%s read sent mail",useron.alias);
145: logline("E",str);
146: } else if(which==MAIL_ALL) {
147: sprintf(str,"%s read all mail",useron.alias);
148: logline("S+",str);
149: } else {
150: sprintf(str,"%s read mail",useron.alias);
151: logline("E",str);
152: }
153: if(useron.misc&RIP) {
154: strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL ?
155: "allmail" : "sentmail");
156: menu(str); }
157: while(online && !done) {
158: action=act;
159:
160: if(msg.total_hfields)
161: smb_freemsgmem(&msg);
162: msg.total_hfields=0;
163:
164: msg.idx.offset=mail[smb.curmsg].offset;
165: msg.idx.number=mail[smb.curmsg].number;
166: msg.idx.to=mail[smb.curmsg].to;
167: msg.idx.from=mail[smb.curmsg].from;
168: msg.idx.subj=mail[smb.curmsg].subj;
169:
170: if((i=smb_locksmbhdr(&smb))!=0) {
171: errormsg(WHERE,ERR_LOCK,smb.file,i);
172: break; }
173:
174: if((i=smb_getstatus(&smb))!=0) {
175: smb_unlocksmbhdr(&smb);
176: errormsg(WHERE,ERR_READ,smb.file,i);
177: break; }
178: smb_unlocksmbhdr(&smb);
179:
180: if(smb.status.last_msg!=last) { /* New messages */
181: last=smb.status.last_msg;
182: free(mail);
183: mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode); /* So re-load */
184: if(!smb.msgs)
185: break;
186: for(smb.curmsg=0;smb.curmsg<smb.msgs;smb.curmsg++)
187: if(mail[smb.curmsg].number==msg.idx.number)
188: break;
189: if(smb.curmsg>=smb.msgs)
190: smb.curmsg=(smb.msgs-1);
191: continue; }
192:
193: if(!loadmsg(&msg,mail[smb.curmsg].number)) { /* Message header gone */
194: if(mismatches>5) { /* We can't do this too many times in a row */
195: errormsg(WHERE,ERR_CHK,"message number",mail[smb.curmsg].number);
196: break; }
197: free(mail);
198: mail=loadmail(&smb,&smb.msgs,usernumber,which,lm_mode);
199: if(!smb.msgs)
200: break;
201: if(smb.curmsg>(smb.msgs-1))
202: smb.curmsg=(smb.msgs-1);
203: mismatches++;
204: continue; }
205: smb_unlockmsghdr(&smb,&msg);
206: msg.idx.attr=msg.hdr.attr;
207:
208: mismatches=0;
209:
210: if(domsg && !(sys_status&SS_ABORT)) {
211:
212: show_msg(&msg
213: ,msg.from_ext && msg.idx.from==1 && !msg.from_net.type
214: ? 0:P_NOATCODES);
215:
216: if(msg.hdr.auxattr&MSG_FILEATTACH) { /* Attached file */
217: smb_getmsgidx(&smb,&msg);
218: strcpy(str,msg.subj); /* filenames in title */
219: // strupr(str);
220: tp=str;
221: while(online) {
222: p=strchr(tp,' ');
223: if(p) *p=0;
224: sp=strrchr(tp,'/'); /* sp is slash pointer */
225: if(!sp) sp=strrchr(tp,'\\');
226: if(sp) tp=sp+1;
227: padfname(tp,fd.name);
228: sprintf(str2,"%sfile/%04u.in/%s" /* str2 is path/fname */
229: ,cfg.data_dir,msg.idx.to,tp);
230: length=flength(str2);
231: if(length<1)
232: bputs(text[FileNotFound]);
233: else if(!(useron.exempt&FLAG('T')) && cur_cps && !SYSOP
234: && length/(long)cur_cps>(time_t)timeleft)
235: bputs(text[NotEnoughTimeToDl]);
236: else {
237: sprintf(str3,text[DownloadAttachedFileQ]
238: ,tp,ultoac(length,tmp));
239: if(length>0L && yesno(str3)) {
240: #if 0 /* no such thing as local logon */
241: if(online==ON_LOCAL) {
242: bputs(text[EnterPath]);
243: if(getstr(str3,60,K_LINE)) {
244: backslashcolon(str3);
245: sprintf(tmp,"%s%s",str3,tp);
246: if(!mv(str2,tmp,which!=MAIL_YOUR)) {
247: logon_dlb+=length;
248: logon_dls++;
249: useron.dls=(ushort)adjustuserrec(&cfg,useron.number
250: ,U_DLS,5,1);
251: useron.dlb=adjustuserrec(&cfg,useron.number
252: ,U_DLB,10,length);
253: bprintf(text[FileNBytesSent]
254: ,fd.name,ultoac(length,tmp)); } } }
255:
256: else
257: #endif
258: { /* Remote User */
259: xfer_prot_menu(XFER_DOWNLOAD);
260: mnemonics(text[ProtocolOrQuit]);
261: strcpy(str3,"Q");
262: for(i=0;i<cfg.total_prots;i++)
263: if(cfg.prot[i]->dlcmd[0]
264: && chk_ar(cfg.prot[i]->ar,&useron)) {
265: sprintf(tmp,"%c",cfg.prot[i]->mnemonic);
266: strcat(str3,tmp); }
267: ch=(char)getkeys(str3,0);
268: for(i=0;i<cfg.total_prots;i++)
269: if(cfg.prot[i]->dlcmd[0] && ch==cfg.prot[i]->mnemonic
270: && chk_ar(cfg.prot[i]->ar,&useron))
271: break;
272: if(i<cfg.total_prots) {
273: error=protocol(cfg.prot[i],XFER_DOWNLOAD,str2,nulstr,false);
274: if(checkprotresult(cfg.prot[i],error,&fd)) {
275: if(which==MAIL_YOUR)
276: remove(str2);
277: logon_dlb+=length; /* Update stats */
278: logon_dls++;
279: useron.dls=(ushort)adjustuserrec(&cfg,useron.number
280: ,U_DLS,5,1);
281: useron.dlb=adjustuserrec(&cfg,useron.number
282: ,U_DLB,10,length);
283: bprintf(text[FileNBytesSent]
284: ,fd.name,ultoac(length,tmp));
285: sprintf(str3
286: ,"%s downloaded attached file: %s"
287: ,useron.alias
288: ,fd.name);
289: logline("D-",str3);
290: }
291: autohangup();
292: }
293: }
294: }
295: }
296: if(!p)
297: break;
298: tp=p+1;
299: while(*tp==' ') tp++;
300: }
301: sprintf(str,"%sfile/%04u.in",cfg.data_dir,usernumber);
302: rmdir(str); }
303: if(which==MAIL_YOUR && !(msg.hdr.attr&MSG_READ)) {
304: mail[smb.curmsg].attr|=MSG_READ;
305: if(thisnode.status==NODE_INUSE)
306: telluser(&msg);
307: if(msg.total_hfields)
308: smb_freemsgmem(&msg);
309: msg.total_hfields=0;
310: msg.idx.offset=0; /* Search by number */
311: if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
312: if(loadmsg(&msg,msg.idx.number)) {
313: msg.hdr.attr|=MSG_READ;
314: msg.idx.attr=msg.hdr.attr;
315: if((i=smb_putmsg(&smb,&msg))!=0)
316: errormsg(WHERE,ERR_WRITE,smb.file,i);
317: smb_unlockmsghdr(&smb,&msg); }
318: smb_unlocksmbhdr(&smb); }
319: if(!msg.total_hfields) { /* unsuccessful reload */
320: domsg=0;
321: continue; } }
322: }
323: else domsg=1;
324:
325: if(useron.misc&WIP) {
326: strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL ?
327: "allmail" : "sentmail");
328: menu(str); }
329:
330: ASYNC;
331: if(which==MAIL_SENT)
332: bprintf(text[ReadingSentMail],smb.curmsg+1,smb.msgs);
333: else if(which==MAIL_ALL)
334: bprintf(text[ReadingAllMail],smb.curmsg+1,smb.msgs);
335: else
336: bprintf(text[ReadingMail],smb.curmsg+1,smb.msgs);
337: sprintf(str,"ADFLNQRT?<>[]{}-+");
338: if(SYSOP)
339: strcat(str,"CUSPH");
340: if(which!=MAIL_YOUR)
341: strcat(str,"E");
342: l=getkeys(str,smb.msgs);
343: if(l&0x80000000L) {
344: if(l==-1) /* ctrl-c */
345: break;
346: smb.curmsg=(l&~0x80000000L)-1;
347: continue; }
348: switch(l) {
349: case 'A': /* Auto-reply to last piece */
350: case 'R':
351: if(l==(cfg.sys_misc&SM_RA_EMU ? 'A' : 'R')) /* re-read last message */
352: break;
353:
354: if(which==MAIL_SENT)
355: break;
356: if((msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP) {
357: bputs(text[CantReplyToAnonMsg]);
358: break; }
359:
360: quotemsg(&msg,1);
361:
362: if(msg.from_net.addr==NULL)
363: SAFECOPY(str,msg.from);
364: else if(msg.from_net.type==NET_FIDO) /* FidoNet type */
365: SAFEPRINTF2(str,"%s@%s",msg.from
366: ,smb_faddrtoa((faddr_t *)msg.from_net.addr,tmp));
367: else if(msg.from_net.type==NET_INTERNET) {
368: if(msg.replyto_net.type==NET_INTERNET)
369: SAFECOPY(str,(char *)msg.replyto_net.addr);
370: else
371: SAFECOPY(str,(char *)msg.from_net.addr);
372: } else
373: SAFEPRINTF2(str,"%s@%s",msg.from,(char*)msg.from_net.addr);
374:
375: SAFECOPY(str2,str);
376:
377: bputs(text[Email]);
378: if(!getstr(str,64,K_EDIT|K_AUTODEL))
379: break;
380: msg.hdr.number=msg.idx.number;
381: smb_getmsgidx(&smb,&msg);
382:
383: if(!stricmp(str2,str)) /* Reply to sender */
384: sprintf(str2,text[Regarding],msg.subj);
385: else /* Reply to other */
386: sprintf(str2,text[RegardingByOn],msg.subj,msg.from
387: ,timestr((time_t *)&msg.hdr.when_written.time));
388:
389: p=strrchr(str,'@');
390: if(p) { /* name @addr */
391: replied=netmail(str,msg.subj,WM_QUOTE);
392: sprintf(str2,text[DeleteMailQ],msg.from); }
393: else {
394: if(!msg.from_net.type && !stricmp(str,msg.from))
395: replied=email(msg.idx.from,str2,msg.subj,WM_EMAIL|WM_QUOTE);
396: else if(!stricmp(str,"SYSOP"))
397: replied=email(1,str2,msg.subj,WM_EMAIL|WM_QUOTE);
398: else if((i=finduser(str))!=0)
399: replied=email(i,str2,msg.subj,WM_EMAIL|WM_QUOTE);
400: else
401: replied=false;
402: sprintf(str2,text[DeleteMailQ],msg.from); }
403:
404: if(replied==true && !(msg.hdr.attr&MSG_REPLIED)) {
405: if(msg.total_hfields)
406: smb_freemsgmem(&msg);
407: msg.total_hfields=0;
408: msg.idx.offset=0;
409: if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
410: if(loadmsg(&msg,msg.idx.number)) {
411: msg.hdr.attr|=MSG_REPLIED;
412: msg.idx.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: }
417: smb_unlocksmbhdr(&smb);
418: }
419: }
420:
421: if(msg.hdr.attr&MSG_DELETE || !yesno(str2)) {
422: if(smb.curmsg<smb.msgs-1) smb.curmsg++;
423: else done=1;
424: break; }
425: /* Case 'D': must follow! */
426: case 'D': /* Delete last piece (toggle) */
427: if(msg.hdr.attr&MSG_PERMANENT) {
428: bputs("\r\nPermanent message.\r\n");
429: domsg=0;
430: break; }
431: if(msg.total_hfields)
432: smb_freemsgmem(&msg);
433: msg.total_hfields=0;
434: msg.idx.offset=0;
435: if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
436: if(loadmsg(&msg,msg.idx.number)) {
437: msg.hdr.attr^=MSG_DELETE;
438: msg.idx.attr=msg.hdr.attr;
439: // mail[smb.curmsg].attr=msg.hdr.attr;
440: if((i=smb_putmsg(&smb,&msg))!=0)
441: errormsg(WHERE,ERR_WRITE,smb.file,i);
442: smb_unlockmsghdr(&smb,&msg);
443: }
444: smb_unlocksmbhdr(&smb);
445: }
446: if(smb.curmsg<smb.msgs-1) smb.curmsg++;
447: else done=1;
448: break;
449: case 'F': /* Forward last piece */
450: domsg=0;
451: bputs(text[ForwardMailTo]);
452: if(!getstr(str,LEN_ALIAS,cfg.uq&UQ_NOUPRLWR ? K_NONE:K_UPRLWR))
453: break;
454: i=finduser(str);
455: if(!i)
456: break;
457: domsg=1;
458: if(smb.curmsg<smb.msgs-1) smb.curmsg++;
459: else done=1;
460: smb_getmsgidx(&smb,&msg);
461: forwardmail(&msg,i);
462: if(msg.hdr.attr&MSG_PERMANENT)
463: break;
464: sprintf(str2,text[DeleteMailQ],msg.from);
465: if(!yesno(str2))
466: break;
467: if(msg.total_hfields)
468: smb_freemsgmem(&msg);
469: msg.total_hfields=0;
470: msg.idx.offset=0;
471: if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
472: if(loadmsg(&msg,msg.idx.number)) {
473: msg.hdr.attr|=MSG_DELETE;
474: msg.idx.attr=msg.hdr.attr;
475: // mail[smb.curmsg].attr=msg.hdr.attr;
476: if((i=smb_putmsg(&smb,&msg))!=0)
477: errormsg(WHERE,ERR_WRITE,smb.file,i);
478: smb_unlockmsghdr(&smb,&msg);
479: }
480: smb_unlocksmbhdr(&smb);
481: }
482:
483: break;
484: case 'H':
485: domsg=0;
486: msghdr(&msg);
487: break;
488: case 'L': /* List mail */
489: domsg=0;
490: bprintf(text[StartWithN],(long)smb.curmsg+1);
491: if((i=getnum(smb.msgs))>0)
492: i--;
493: else if(i==-1)
494: break;
495: else
496: i=smb.curmsg;
497: if(which==MAIL_SENT)
498: bputs(text[MailSentLstHdr]);
499: else if(which==MAIL_ALL)
500: bputs(text[MailOnSystemLstHdr]);
501: else
502: bputs(text[MailWaitingLstHdr]);
503: for(;i<smb.msgs && !msgabort();i++) {
504: if(msg.total_hfields)
505: smb_freemsgmem(&msg);
506: msg.total_hfields=0;
507: msg.idx.offset=mail[i].offset;
508: if(!loadmsg(&msg,mail[i].number))
509: continue;
510: smb_unlockmsghdr(&smb,&msg);
511: if(which==MAIL_ALL)
512: bprintf(text[MailOnSystemLstFmt]
513: ,i+1,msg.from,msg.to
514: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
515: : msg.hdr.attr&MSG_READ ? ' '
516: : msg.from_net.type || msg.to_net.type ? 'N':'*'
517: ,msg.subj);
518: else
519: bprintf(text[MailWaitingLstFmt],i+1
520: ,which==MAIL_SENT ? msg.to
521: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
522: ? text[Anonymous] : msg.from
523: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
524: : msg.hdr.attr&MSG_READ ? ' '
525: : msg.from_net.type || msg.to_net.type ? 'N':'*'
526: ,msg.subj);
527: smb_freemsgmem(&msg);
528: msg.total_hfields=0; }
529: break;
530: case 'Q':
531: done=1;
532: break;
533: case 'C': /* Change attributes of last piece */
534: i=chmsgattr(msg.hdr.attr);
535: if(msg.hdr.attr==i)
536: break;
537: if(msg.total_hfields)
538: smb_freemsgmem(&msg);
539: msg.total_hfields=0;
540: msg.idx.offset=0;
541: if(smb_locksmbhdr(&smb)==SMB_SUCCESS) { /* Lock the entire base */
542: if(loadmsg(&msg,msg.idx.number)) {
543: msg.hdr.attr=msg.idx.attr=(ushort)i;
544: if((i=smb_putmsg(&smb,&msg))!=0)
545: errormsg(WHERE,ERR_WRITE,smb.file,i);
546: smb_unlockmsghdr(&smb,&msg);
547: }
548: smb_unlocksmbhdr(&smb);
549: }
550: break;
551: case '>':
552: for(i=smb.curmsg+1;i<smb.msgs;i++)
553: if(mail[i].subj==msg.idx.subj)
554: break;
555: if(i<smb.msgs)
556: smb.curmsg=i;
557: else
558: domsg=0;
559: break;
560: case '<': /* Search Title backward */
561: for(i=smb.curmsg-1;i>-1;i--)
562: if(mail[i].subj==msg.idx.subj)
563: break;
564: if(i>-1)
565: smb.curmsg=i;
566: else
567: domsg=0;
568: break;
569: case '}': /* Search Author forward */
570: strcpy(str,msg.from);
571: for(i=smb.curmsg+1;i<smb.msgs;i++)
572: if(mail[i].from==msg.idx.from)
573: break;
574: if(i<smb.msgs)
575: smb.curmsg=i;
576: else
577: domsg=0;
578: break;
579: case 'N': /* Got to next un-read message */
580: for(i=smb.curmsg+1;i<smb.msgs;i++)
581: if(!(mail[i].attr&MSG_READ))
582: break;
583: if(i<smb.msgs)
584: smb.curmsg=i;
585: else
586: domsg=0;
587: break;
588: case '{': /* Search Author backward */
589: strcpy(str,msg.from);
590: for(i=smb.curmsg-1;i>-1;i--)
591: if(mail[i].from==msg.idx.from)
592: break;
593: if(i>-1)
594: smb.curmsg=i;
595: else
596: domsg=0;
597: break;
598: case ']': /* Search To User forward */
599: strcpy(str,msg.to);
600: for(i=smb.curmsg+1;i<smb.msgs;i++)
601: if(mail[i].to==msg.idx.to)
602: break;
603: if(i<smb.msgs)
604: smb.curmsg=i;
605: else
606: domsg=0;
607: break;
608: case '[': /* Search To User backward */
609: strcpy(str,msg.to);
610: for(i=smb.curmsg-1;i>-1;i--)
611: if(mail[i].to==msg.idx.to)
612: break;
613: if(i>-1)
614: smb.curmsg=i;
615: else
616: domsg=0;
617: break;
618: case 0:
619: case '+':
620: if(smb.curmsg<smb.msgs-1) smb.curmsg++;
621: else done=1;
622: break;
623: case '-':
624: if(smb.curmsg>0) smb.curmsg--;
625: break;
626: case 'S':
627: domsg=0;
628: /*
629: if(!yesno(text[SaveMsgToFile]))
630: break;
631: */
632: bputs(text[FileToWriteTo]);
633: if(getstr(str,40,K_LINE))
634: msgtotxt(&msg,str,1,1);
635: break;
636: case 'E':
637: editmsg(&msg,INVALID_SUB);
638: break;
639: case 'T':
640: domsg=0;
641: i=smb.curmsg;
642: if(i) i++;
643: j=i+10;
644: if(j>smb.msgs)
645: j=smb.msgs;
646:
647: if(which==MAIL_SENT)
648: bputs(text[MailSentLstHdr]);
649: else if(which==MAIL_ALL)
650: bputs(text[MailOnSystemLstHdr]);
651: else
652: bputs(text[MailWaitingLstHdr]);
653: for(;i<j;i++) {
654: if(msg.total_hfields)
655: smb_freemsgmem(&msg);
656: msg.total_hfields=0;
657: msg.idx.offset=mail[i].offset;
658: if(!loadmsg(&msg,mail[i].number))
659: continue;
660: smb_unlockmsghdr(&smb,&msg);
661: if(which==MAIL_ALL)
662: bprintf(text[MailOnSystemLstFmt]
663: ,i+1,msg.from,msg.to
664: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
665: : msg.hdr.attr&MSG_READ ? ' '
666: : msg.from_net.type || msg.to_net.type ? 'N':'*'
667: ,msg.subj);
668: else
669: bprintf(text[MailWaitingLstFmt],i+1
670: ,which==MAIL_SENT ? msg.to
671: : (msg.hdr.attr&MSG_ANONYMOUS) && !SYSOP
672: ? text[Anonymous] : msg.from
673: ,msg.hdr.attr&MSG_DELETE ? '-' : msg.hdr.attr&MSG_REPLIED ? 'R'
674: : msg.hdr.attr&MSG_READ ? ' '
675: : msg.from_net.type || msg.to_net.type ? 'N':'*'
676: ,msg.subj);
677: smb_freemsgmem(&msg);
678: msg.total_hfields=0; }
679: smb.curmsg=(i-1);
680: break;
681: case 'U': /* user edit */
682: msg.hdr.number=msg.idx.number;
683: smb_getmsgidx(&smb,&msg);
684: useredit(which==MAIL_SENT ? msg.idx.to : msg.idx.from);
685: break;
686: case 'P': /* Purge author and all mail to/from */
687: if(noyes(text[AreYouSureQ]))
688: break;
689: msg.hdr.number=msg.idx.number;
690: smb_getmsgidx(&smb,&msg);
691: purgeuser(msg.idx.from);
692: if(smb.curmsg<smb.msgs-1) smb.curmsg++;
693: break;
694: case '?':
695: strcpy(str,which==MAIL_YOUR ? "mailread" : which==MAIL_ALL
696: ? "allmail" : "sentmail");
697: menu(str);
698: if(SYSOP && which==MAIL_SENT)
699: menu("syssmail");
700: else if(SYSOP && which==MAIL_YOUR)
701: menu("sysmailr"); /* Sysop Mail Read */
702: domsg=0;
703: break;
704: } }
705:
706: if(msg.total_hfields)
707: smb_freemsgmem(&msg);
708:
709: if(smb.msgs)
710: free(mail);
711:
712: /***************************************/
713: /* Delete messages marked for deletion */
714: /***************************************/
715:
716: if(cfg.sys_misc&SM_DELEMAIL) {
717: if((i=smb_locksmbhdr(&smb))!=0) /* Lock the base, so nobody */
718: errormsg(WHERE,ERR_LOCK,smb.file,i); /* messes with the index */
719: else
720: delmail(usernumber,which); }
721:
722: smb_close(&smb);
723: smb_stack(&smb,SMB_STACK_POP);
724: }
725:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.