home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / UTIL / WWIVSOR / READMAIL.C < prev    next >
Text File  |  1996-12-04  |  25KB  |  898 lines

  1. #include "vars.h"
  2.  
  3. #pragma hdrstop
  4.  
  5.  
  6.  
  7. int same_email(tmpmailrec *tm, mailrec *m)
  8. {
  9.   if ((tm->fromsys!=m->fromsys) ||
  10.       (tm->fromuser!=m->fromuser) ||
  11.       (m->tosys!=0) ||
  12.       (m->touser!=usernum) ||
  13.       (tm->daten!=m->daten) ||
  14.       (tm->index==-1) ||
  15.       (memcmp(&tm->msg, &m->msg, sizeof(messagerec)!=0)))
  16.     return(0);
  17.   else
  18.     return(1);
  19. }
  20.  
  21.  
  22. void purgemail(tmpmailrec *mloc,int mw,int *curmail, mailrec *m1, slrec *ss)
  23. {
  24.   int i, f;
  25.   mailrec m;
  26.  
  27.   if (m1->fromuser==65535)
  28.     return;
  29.  
  30.   ansic(5);
  31.   if ((m1->anony & anony_sender) && ((ss->ability & ability_read_email_anony)==0)) {
  32.     outstr(get_string(699));
  33.   } else {
  34.     outstr(get_string(700));
  35.     if (m1->fromsys) {
  36.       npr("#%u @%u? ",m1->fromuser, m1->fromsys);
  37.     } else {
  38.       npr("#%u? ",m1->fromuser);
  39.     }
  40.   }
  41.   if (yn()) {
  42.     f=open_email(1);
  43.     if (f<0)
  44.       return;
  45.     for (i=0; i<mw; i++) {
  46.       if (mloc[i].index>=0) {
  47.         sh_lseek(f,((long) mloc[i].index) * sizeof(mailrec),SEEK_SET);
  48.         sh_read(f,(void *) (&m),sizeof(mailrec));
  49.         if (same_email(mloc+i, &m)) {
  50.           if ((m.fromuser==m1->fromuser) && (m.fromsys==m1->fromsys)) {
  51.             outstr(get_string(701));
  52.             npr("%d\r\n",i+1);
  53.             delmail(f,mloc[i].index);
  54.             mloc[i].index=-1;
  55.             if (*curmail==i)
  56.               ++(*curmail);
  57.           }
  58.         }
  59.       } else {
  60.         if (*curmail==i)
  61.           ++(*curmail);
  62.       }
  63.     }
  64.     f=sh_close(f);
  65.   }
  66. }
  67.  
  68.  
  69. #define MAXMAIL 255
  70.  
  71.  
  72. void resynch_email(tmpmailrec *mloc, int mw, int rec, mailrec *m, int del, unsigned short stat)
  73. {
  74.   int f, i, i1, mp, mfl;
  75.   mailrec m1;
  76.  
  77.   f=open_email(del || stat);
  78.   if (f>0) {
  79.     mfl=filelength(f)/sizeof(mailrec);
  80.  
  81.     for (i=0; i<mw; i++) {
  82.       if (mloc[i].index>=0)
  83.         mloc[i].index=-2;
  84.     }
  85.  
  86.     mp=0;
  87.  
  88.     for (i=0; i<mfl; i++) {
  89.       sh_lseek(f,((long) i) * sizeof(mailrec),SEEK_SET);
  90.       sh_read(f,(void *) (&m1),sizeof(mailrec));
  91.  
  92.       if ((m1.tosys==0) && (m1.touser==usernum)) {
  93.         for (i1=mp; i1<mw; i1++) {
  94.           if (same_email(mloc+i1, &m1)) {
  95.             mloc[i1].index=i;
  96.             mp=i1+1;
  97.             if (i1==rec)
  98.               *m=m1;
  99.             break;
  100.           }
  101.         }
  102.       }
  103.     }
  104.  
  105.     for (i=0; i<mw; i++) {
  106.       if (mloc[i].index==-2)
  107.         mloc[i].index=-1;
  108.     }
  109.  
  110.     if (stat && !del && (mloc[rec].index>=0)) {
  111.       m->status |= stat;
  112.       sh_lseek(f,((long) mloc[rec].index) * sizeof(mailrec),SEEK_SET);
  113.       sh_write(f,(void *) (m),sizeof(mailrec));
  114.     }
  115.     if (del && (mloc[rec].index>=0)) {
  116.       if (del==2) {
  117.         m->touser=0;
  118.         m->tosys=0;
  119.         m->daten=0xffffffff;
  120.         m->msg.storage_type=0;
  121.         m->msg.stored_as=0xffffffff;
  122.         sh_lseek(f,((long) mloc[rec].index) * sizeof(mailrec),SEEK_SET);
  123.         sh_write(f,(void *) (m),sizeof(mailrec));
  124.       } else {
  125.         delmail(f, mloc[rec].index);
  126.       }
  127.       mloc[rec].index=-1;
  128.     }
  129.  
  130.     f=sh_close(f);
  131.  
  132.   } else {
  133.     mloc[rec].index=-1;
  134.   }
  135. }
  136.  
  137.  
  138. int read_same_email(tmpmailrec *mloc, int mw, int rec, mailrec *m, int del, unsigned short stat)
  139. {
  140.   int f;
  141.  
  142.   if (mloc[rec].index<0)
  143.     return(0);
  144.  
  145.   f=open_email(del || stat);
  146.   sh_lseek(f,((long) mloc[rec].index) * sizeof(mailrec),SEEK_SET);
  147.   sh_read(f,(void *) (m),sizeof(mailrec));
  148.  
  149.   if (!same_email(mloc+rec,m)) {
  150.     f=sh_close(f);
  151.     read_status();
  152.     if (emchg) {
  153.       resynch_email(mloc, mw, rec, m, del, stat);
  154.     } else {
  155.       mloc[rec].index=-1;
  156.     }
  157.   } else {
  158.  
  159.     if (stat && !del && (mloc[rec].index>=0)) {
  160.       m->status |= stat;
  161.       sh_lseek(f,((long) mloc[rec].index) * sizeof(mailrec),SEEK_SET);
  162.       sh_write(f,(void *) (m),sizeof(mailrec));
  163.     }
  164.     if (del) {
  165.       if (del==2) {
  166.         m->touser=0;
  167.         m->tosys=0;
  168.         m->daten=0xffffffff;
  169.         m->msg.storage_type=0;
  170.         m->msg.stored_as=0xffffffff;
  171.         sh_lseek(f,((long) mloc[rec].index) * sizeof(mailrec),SEEK_SET);
  172.         sh_write(f,(void *) (m),sizeof(mailrec));
  173.       } else {
  174.         delmail(f, mloc[rec].index);
  175.       }
  176.       mloc[rec].index=-1;
  177.     }
  178.  
  179.     f=sh_close(f);
  180.   }
  181.  
  182.   if (mloc[rec].index!=-1)
  183.     return(1);
  184.   else
  185.     return(0);
  186. }
  187.  
  188. void add_netsubscriber(unsigned short sn)
  189. {
  190.   char s[10], s1[10],ns1[80];
  191.   FILE *host;
  192.  
  193.   if (!valid_system(sn))
  194.     sn=0;
  195.  
  196.   nl();
  197.   prt(1,get_string(1265));
  198.   nln(2);
  199.   prt(2,get_string(1266));
  200.   mpl(7);
  201.   input(s,7);
  202.   if (s[0]==0)
  203.     return;
  204.   strcpy(s1,s);
  205.   sprintf(ns1,"%sN%s.NET",net_data,s);
  206.   if (!exist(ns1)) {
  207.     nl();
  208.     ansic(6);
  209.     npr("%s%s",get_string(1267),ns1);
  210.     nl();
  211.     return;
  212.   }
  213.   nl();
  214.   if (sn) {
  215.     outstr(get_string(1268));
  216.     npr("%u.%s",sn,net_name);
  217.     outstr(get_string(1269));
  218.     npr("%s? ",s);
  219.   }
  220.   if (!sn || !ny()) {
  221.     prt(2,get_string(1270));
  222.     mpl(5);
  223.     input(s,5);
  224.     if (!s[0])
  225.       return;
  226.     sn=atoi(s);
  227.     if (!valid_system(sn)) {
  228.       npr("@%u%s%s.", sn, get_string(1271), net_name);
  229.       nl();
  230.       return;
  231.     }
  232.   }
  233.   sprintf(s,"%u\n",sn);
  234.   host=fsh_open(ns1,"a+t");
  235.   if (host) {
  236.     fprintf(host,s);
  237.     fsh_close(host);
  238.  
  239.     if (exist("AUTOSEND.EXE")) {
  240.       outstr(get_string(1525));
  241.       if (yn()) {
  242.         sprintf(ns1,"AUTOSEND.EXE %s %u .%d",s1,sn,net_num);
  243.         extern_prog(ns1,EFLAG_SHRINK);
  244.       }
  245.     }
  246.   }
  247. }
  248.  
  249. void readmail(void)
  250. {
  251.   int i,i2,f,mw,mfl,curmail,done,abort=0,next,okmail,tp,nn;
  252.   unsigned short xx;
  253.   char s[201],s1[205],s2[81],*b,*ss1;
  254.   mailrec m, m1;
  255.   slrec ss;
  256.   userrec u;
  257.   char ch;
  258.   long len,num_mail,num_mail1;
  259.   unsigned short un, sy;
  260.   net_system_list_rec *csne;
  261.   tmpmailrec *mloc;
  262.  
  263.   emchg=0;
  264.  
  265.   mloc=malloca(MAXMAIL*sizeof(tmpmailrec));
  266.   if (!mloc) {
  267.     pl(get_string(1272));
  268.     return;
  269.   }
  270.  
  271.   if (menu_on())
  272.     printmenu(4);
  273.  
  274.   if (rip_on()) {
  275.     cleared = NEEDCLEAR;
  276.     setmsgview(11);
  277.   }
  278.  
  279.   write_inst(INST_LOC_RMAIL,0,INST_FLAGS_NONE);
  280.   ss=syscfg.sl[actsl];
  281.   f=open_email(0);
  282.   if (f<0) {
  283.     nln(2);
  284.     pl(get_string(702));
  285.     nl();
  286.     bbsfree(mloc);
  287.     return;
  288.   }
  289.   mfl=filelength(f)/sizeof(mailrec);
  290.   mw=0;
  291.   for (i=0; (i<mfl) && (mw<MAXMAIL); i++) {
  292.     sh_lseek(f,((long) (i)) * (sizeof(mailrec)), SEEK_SET);
  293.     sh_read(f,(void *)(&m),sizeof(mailrec));
  294.     if ((m.tosys==0) && (m.touser==usernum)) {
  295.       mloc[mw].index=i;
  296.       mloc[mw].fromsys=m.fromsys;
  297.       mloc[mw].fromuser=m.fromuser;
  298.       mloc[mw].daten=m.daten;
  299.       mloc[mw].msg=m.msg;
  300.       mw++;
  301.     }
  302.   }
  303.   f=sh_close(f);
  304.   thisuser.waiting=mw;
  305.   if (usernum==1)
  306.     fwaiting=mw;
  307.   if (mw==0) {
  308.     nln(2);
  309.     pl("3You have no mail.");
  310.     nl();
  311.     bbsfree(mloc);
  312.     return;
  313.   }
  314. #ifdef RIPDRIVE
  315.   rd_coff();
  316. #endif
  317.   if (mw==1)
  318.     curmail=0;
  319.   else {
  320.     nln(2);
  321.     ansic(0);
  322.     pl("1You have mail from7: ");
  323.     nl();
  324.  
  325.     if ((thisuser.screenchars>=80) && (sysinfo.mail_who_field_len)) {
  326.       (okansi())?strcpy(s1,"┴┬─"):strcpy(s1,"++-");
  327.       sprintf(s,"7%s%c",charstr(4,s1[2]),s1[1]);
  328.       strcat(s,charstr(sysinfo.mail_who_field_len-4,s1[2]));
  329.       strcat(s,charstr(1,s1[1]));
  330.       strcat(s,charstr(thisuser.screenchars-sysinfo.mail_who_field_len-3,s1[2]));
  331.       pla(s,&abort);
  332.     }
  333.  
  334.     for (i=0; ((i<mw) && (!abort)); i++) {
  335.       if (!read_same_email(mloc, mw, i, &m, 0, 0))
  336.         continue;
  337.  
  338.       tp=80;
  339.       if (m.status & status_source_verified)
  340.         tp -= 2;
  341.       if (m.status & status_new_net) {
  342.         tp -= 1;
  343.         if (strlen(m.title)<=tp) {
  344.           nn=(unsigned char) m.title[tp+1];
  345.         } else
  346.           nn=0;
  347.       } else
  348.         nn=0;
  349.       sprintf(s,"5%3d%s7%c1 ",
  350.               i+1,
  351.               m.status&status_seen?" ":"3*",
  352.               okansi()?'│':'|');
  353.  
  354.       if ((m.anony & anony_sender) && ((ss.ability & ability_read_email_anony)==0)) {
  355.         strcat(s,get_string(482));
  356.       } else {
  357.         if (m.fromsys==0) {
  358.           if (m.fromuser==65535) {
  359.             if (nn!=255)
  360.               strcat(s,net_networks[nn].name);
  361.           } else {
  362.             read_user(m.fromuser,&u);
  363.             strcat(s,nam(&u,m.fromuser));
  364.           }
  365.         } else {
  366.           set_net_num(nn);
  367.           csne=next_system(m.fromsys);
  368.           if (csne)
  369.             ss1=csne->name;
  370.           else
  371.             ss1=get_string(622);
  372.           if (nn==255) {
  373.             sprintf(s1,"%s #%u @%u",get_string(704), m.fromuser,m.fromsys);
  374.           } else {
  375.             if (net_num_max>1)
  376.               sprintf(s1,"%s #%u @%u (%s)",
  377.                 net_networks[nn].name,m.fromuser,m.fromsys,ss1);
  378.             else
  379.               sprintf(s1,"%s %u @%u (%s)",get_string(658), m.fromuser,m.fromsys,ss1);
  380.           }
  381.           strcat(s,s1);
  382.         }
  383.       }
  384.  
  385.       if ((thisuser.screenchars >= 80) && (sysinfo.mail_who_field_len)) {
  386.         if (strlen(stripcolors(s))>sysinfo.mail_who_field_len)
  387.           while (strlen(stripcolors(s))>sysinfo.mail_who_field_len)
  388.             s[strlen(s)-1]=0;
  389.         strcat(s,charstr((sysinfo.mail_who_field_len+1)-strlen(stripcolors(s)),' '));
  390.         if (okansi())
  391.           strcat(s,"7│1");
  392.         else
  393.           strcat(s,"|");
  394.         strcat(s," ");
  395.         strcat(s,stripcolors(m.title));
  396.         while (strlen(stripcolors(s))>thisuser.screenchars-1)
  397.           s[strlen(s)-1]=0;
  398.       }
  399.       pla(s,&abort);
  400.       if ((i==(mw-1)) && (thisuser.screenchars>=80) && (!abort) && (sysinfo.mail_who_field_len)) {
  401.         (okansi())?strcpy(s1,"┴┬─"):strcpy(s1,"++-");
  402.         sprintf(s,"7%s%c",charstr(4,s1[2]),s1[0]);
  403.         strcat(s,charstr(sysinfo.mail_who_field_len-4,s1[2]));
  404.         strcat(s,charstr(1,s1[0]));
  405.         strcat(s,charstr(thisuser.screenchars-sysinfo.mail_who_field_len-3,s1[2]));
  406.         pla(s,&abort);
  407.       }
  408.     }
  409.     nl();
  410. #ifdef RIPDRIVE
  411.     rd_con();
  412. #endif
  413.     helpl=10;
  414.     pl("3Hit return or enter number7: 3");
  415.     outstr("7:3");
  416.     input(s,3);
  417.     if (strchr(s,'Q')!=NULL) {
  418.       bbsfree(mloc);
  419.       return;
  420.     }
  421.     i=atoi(s);
  422.     if (i)
  423.       if (i<=mw)
  424.         curmail=i-1;
  425.       else
  426.         curmail=0;
  427.     else
  428.       curmail=0;
  429.   }
  430.   done=0;
  431.   do {
  432.     if (E_C) {
  433.       sprintf(s,"1%u7/1%u0",curmail+1,mw);
  434.       strcat(s,charstr(12-strlen(stripcolors(s)),'.'));
  435.       strcat(s," 2");
  436.     } else {
  437.       sprintf(s,"8│7(1%u7/1%u7)3: ",curmail+1,mw);
  438.     }
  439.     abort=0;
  440.     nln(2);
  441.     if (rip_on())
  442.       msgheader(1);
  443.     outchr(12);
  444.     outstr("8┌────────────────────────────────────────────∙∙∙ ∙  ∙   ·    ·\r\n");
  445.     osan(s,&abort,&next);
  446.     next=0;
  447.     ansic_x(sysinfo.msg_color);
  448.     s[0]=0;
  449.  
  450.     if (!read_same_email(mloc, mw, curmail, &m, 0, 0)) {
  451.       strcat(s,get_string(706));
  452.       okmail=0;
  453.       pl(s);
  454.       nln(2);
  455.     } else {
  456.       strcat(s,m.title);
  457.       strcpy(irt,m.title);
  458.       irt_name[0]=0;
  459.       abort=0;
  460.       i=((ability_read_email_anony & ss.ability)!=0);
  461.       okmail=1;
  462. #ifdef RIPDRIVE
  463.       rd_coff();
  464. #endif
  465.       pla(s,&abort);
  466.       if ((m.fromsys) && (!m.fromuser))
  467.         grab_user_name(&(m.msg),"EMAIL");
  468.       else
  469.         net_email_name[0]=0;
  470.       tp=80;
  471.       if (m.status & status_source_verified) {
  472.         tp -= 2;
  473.         if (strlen(m.title)<=tp) {
  474.           xx=*(short *) (m.title+tp+1);
  475.           strcpy(s,get_string(707));
  476.           sprintf(s+strlen(s),"%u",xx);
  477.           if (xx==1) {
  478.             strcat(s,get_string(708));
  479.           } else if ((xx>256) && (xx<512)) {
  480.             strcpy(s2,get_string(709));
  481.             sprintf(s2+strlen(s2),"%d)",xx-256);
  482.             strcat(s,s2);
  483.           }
  484.         } else {
  485.           strcpy(s,get_string(710));
  486.         }
  487.         if (!abort) {
  488.           ansic(4);
  489.           pla(s,&abort);
  490.         }
  491.       }
  492.       if (m.status & status_new_net) {
  493.         tp -= 1;
  494.         if (strlen(m.title)<=tp) {
  495.           nn=m.title[tp+1];
  496.         } else
  497.           nn=0;
  498.       } else
  499.         nn=0;
  500.       set_net_num(nn);
  501.       if (nn==255)
  502.         setorigin(0,0);
  503.       else
  504.         setorigin(m.fromsys, m.fromuser);
  505.       if (!abort) {
  506.         read_message1(&m.msg, (m.anony & 0x0f), i, &next, "EMAIL");
  507.         if (!(m.status & status_seen)) {
  508.           read_same_email(mloc, mw, curmail, &m, 0, status_seen);
  509.         }
  510.       }
  511. #ifdef RIPDRIVE
  512.       rd_con();
  513. #endif
  514.     }
  515.     do {
  516.       write_inst(INST_LOC_RMAIL,0,INST_FLAGS_NONE);
  517.       set_net_num(nn);
  518.       i2=1;
  519.       irt_name[0]=0;
  520.       if (!(sysinfo.flags & OP_FLAGS_MAIL_PROMPT))
  521.     prt(2,"\r\n1Mail 7(1?7) 1: 7");
  522.       helpl=34;
  523.       if (so()) {
  524.         if (sysinfo.flags & OP_FLAGS_MAIL_PROMPT)
  525.           npr(get_string(1365));
  526.         ch=onek("QSRIDAMF?-+GEZPVUOLCN");
  527.       } else {
  528.         if (cs()) {
  529.           if (sysinfo.flags & OP_FLAGS_MAIL_PROMPT)
  530.             npr(get_string(1366));
  531.           ch=onek("QSRIDAMF?-+GZPVUOC");
  532.         } else {
  533.           if (!okmail) {
  534.             if (sysinfo.flags & OP_FLAGS_MAIL_PROMPT)
  535.               npr(get_string(1367));
  536.             ch=onek("QI?-+G");
  537.           } else {
  538.             if (sysinfo.flags & OP_FLAGS_MAIL_PROMPT)
  539.               npr(get_string(1368));
  540.             ch=onek("QSRIDAMF?+-G");
  541.           }
  542.         }
  543.       }
  544.       if (okmail && !read_same_email(mloc, mw, curmail, &m, 0, 0)) {
  545.         nl();
  546.         pl(get_string(1273));
  547.         nl();
  548.         ch='R';
  549.       }
  550.       switch (ch) {
  551.         case 'N':
  552.           if (m.fromuser==1)
  553.             add_netsubscriber(m.fromsys);
  554.           else
  555.             add_netsubscriber(0);
  556.           break;
  557.         case 'E':
  558.           if ((so()) && (okmail)) {
  559.             b=readfile(&(m.msg),"EMAIL",&len);
  560.             extract_out(b,len,m.title);
  561.           }
  562.           i2=0;
  563.           break;
  564.         case 'Q':
  565.           done=1;
  566.           break;
  567.         case 'O':
  568.           if ((cs()) && (okmail) && (m.fromuser!=65535) && (nn!=255)) {
  569.             show_files("*.FRM",syscfg.gfilesdir);
  570.             prt(2,get_string(712));
  571.             mpl(8);
  572.             input(s,8);
  573.             if (!s[0])
  574.               break;
  575.             sprintf(s1,"%s%s.FRM",syscfg.gfilesdir,s);
  576.             if (!exist(s1))
  577.               sprintf(s1,"%sFORM%s.MSG",syscfg.gfilesdir,s);
  578.             if (exist(s1)) {
  579.               load_workspace(s1,1);
  580.               num_mail=((long) thisuser.feedbacksent) +
  581.                        ((long) thisuser.emailsent) +
  582.                        ((long) thisuser.emailnet);
  583.               grab_quotes(NULL, NULL);
  584.               if (m.fromuser!=65535)
  585.                 email(m.fromuser,m.fromsys,0,m.anony);
  586.               num_mail1=((long) thisuser.feedbacksent) +
  587.                         ((long) thisuser.emailsent) +
  588.                         ((long) thisuser.emailnet);
  589.               if (num_mail != num_mail1) {
  590.                 if (m.fromsys!=0)
  591.                   sprintf(s,"%s: %s",net_name,nam1(&thisuser,usernum,net_sysnum));
  592.                 else
  593.                   strcpy(s,nam1(&thisuser,usernum,net_sysnum));
  594.                 if (m.anony & anony_receiver)
  595.                   strcpy(s,get_string(482));
  596.                 strcat(s,get_string(713));
  597.                 strcat(s,date());
  598.                 if (!(m.status & status_source_verified))
  599.                   ssm(m.fromuser,m.fromsys,s);
  600.                 read_same_email(mloc, mw, curmail, &m, 1, 0);
  601.                 ++curmail;
  602.                 if (curmail>=mw)
  603.                   done=1;
  604.                 if (!wfc)
  605.                   topscreen();
  606.               } else {
  607.                 sprintf(s,"%sINPUT.MSG",syscfgovr.tempdir);/* need instance */
  608.                 unlink(s);
  609.               }
  610.             } else {
  611.               nl();
  612.               pl(get_string(89));
  613.               nl();
  614.               i2=0;
  615.             }
  616.           }
  617.           break;
  618.         case 'G':
  619.           ansic(2);
  620.           outstr(get_string(714));
  621.           npr("%u) ? ",mw);
  622.           ansic(0);
  623.           input(s,3);
  624.           i2=atoi(s);
  625.           if ((i2>0) && (i2<=mw)) {
  626.             curmail=i2-1;
  627.             i2=1;
  628.           } else
  629.             i2=0;
  630.           break;
  631.         case 'I':
  632.         case '+':
  633.           ++curmail;
  634.           if (curmail>=mw)
  635.             done=1;
  636.           break;
  637.         case '-':
  638.           if (curmail)
  639.             --curmail;
  640.            break;
  641.         case 'R':
  642.           break;
  643.         case '?':
  644.           printmenu(4);
  645.           i2=0;
  646.           break;
  647.         case 'D':
  648.           if (!okmail)
  649.             break;
  650.           if (m.fromsys!=0)
  651.             sprintf(s,"%s: %s",net_name,nam1(&thisuser,usernum,net_sysnum));
  652.           else
  653.             strcpy(s,nam1(&thisuser,usernum,net_sysnum));
  654.           if (m.anony & anony_receiver)
  655.             strcpy(s,get_string(482));
  656.           strcat(s,get_string(713));
  657.           strcat(s,date());
  658.           if ((!(m.status & status_source_verified)) && (nn!=255))
  659.             ssm(m.fromuser,m.fromsys,s);
  660.         case 'Z':
  661.           if (!okmail)
  662.             break;
  663.           read_same_email(mloc, mw, curmail, &m, 1, 0);
  664.           ++curmail;
  665.           if (curmail>=mw)
  666.             done=1;
  667.           if (!wfc)
  668.             topscreen();
  669.           break;
  670.         case 'P':
  671.           if (!okmail)
  672.             break;
  673.           purgemail(mloc,mw,&curmail,&m,&ss);
  674.           if (curmail>=mw)
  675.             done=1;
  676.           if (!wfc)
  677.             topscreen();
  678.           break;
  679.         case 'F':
  680.           if (!okmail)
  681.             break;
  682.           if (m.status & status_multimail) {
  683.             nl();
  684.             pl(get_string(715));
  685.             nl();
  686.             break;
  687.           }
  688.           nln(2);
  689.           prt(2,get_string(716));
  690.           input(s,75);
  691.           parse_email_info(s, &un, &sy);
  692.           if (un || sy) {
  693.             if (forwardm(&un, &sy)) {
  694.               pl(get_string(656));
  695.             }
  696.             if ((un==usernum) && (sy==0) && (!cs())) {
  697.               pl(get_string(469));
  698.               un=0;
  699.             }
  700.             if (un || sy) {
  701.               if (sy) {
  702.                 if (net_num_max>1) {
  703.                   if (un) {
  704.                     sprintf(s1,"%s #%u @%u",net_name, un, sy);
  705.                   } else {
  706.                     sprintf(s1,"%s %s @%u",net_name, net_email_name, sy);
  707.                   }
  708.                 } else {
  709.                   if (un) {
  710.                     sprintf(s1,"#%u @%u", un, sy);
  711.                   } else {
  712.                     sprintf(s1,"%s @%u", net_email_name, sy);
  713.                   }
  714.                 }
  715.               } else {
  716.                 set_net_num(nn);
  717.                 read_user(un,&u);
  718.                 strcpy(s1,nam1(&u,un,net_sysnum));
  719.               }
  720.               if (ok_to_mail(un, sy, 0)) {
  721.                 ansic(5);
  722.                 outstr(get_string(393));
  723.                 npr("%s? ",s1);
  724.                 if (yn()) {
  725.                   f=open_email(1);
  726.                   if (f<0)
  727.                     break;
  728.                   sh_lseek(f,((long) mloc[curmail].index) * sizeof(mailrec),SEEK_SET);
  729.                   sh_read(f,(void *) (&m),sizeof(mailrec));
  730.                   if (!same_email(mloc+curmail, &m)) {
  731.                     pl(get_string(1274));
  732.                     break;
  733.                   }
  734.  
  735.                   m1.touser=0;
  736.                   m1.tosys=0;
  737.                   m1.daten=0xffffffff;
  738.                   m1.msg.storage_type=0;
  739.                   m1.msg.stored_as=0xffffffff;
  740.                   sh_lseek(f,((long) mloc[curmail].index) * sizeof(mailrec),SEEK_SET);
  741.                   sh_write(f,(void *) (&m1),sizeof(mailrec));
  742.  
  743.                   f=sh_close(f);
  744.  
  745.                   i=net_num;
  746.                   sprintf(s,"\r\n%s: %s", get_string(717),
  747.                       nam1(&thisuser,usernum,net_sysnum));
  748.                   set_net_num(nn);
  749.                   lineadd(&m.msg,s,"EMAIL");
  750.                   sprintf(s,"%s %s %s",
  751.                       nam1(&thisuser,usernum,net_sysnum),
  752.                       get_string(718), s1);
  753.                   if (!(m.status & status_source_verified))
  754.                     ssm(m.fromuser,m.fromsys,s);
  755.                   set_net_num(i);
  756.                   sprintf(s,get_stringx(1,101), s1);
  757.                   --thisuser.waiting;
  758.                   if (usernum==1)
  759.                     --fwaiting;
  760.                   outstr(get_string(720));
  761.                   if ((nn!=255) && ((status.net_version>=32) || (nn==net_num))) {
  762.                     sendout_email(m.title, &m.msg, m.anony, un, sy, 1,
  763.                                   m.fromuser, m.fromsys?m.fromsys:net_networks[nn].sysnum, 1, nn);
  764.                   } else {
  765.                     sendout_email(m.title, &m.msg, m.anony, un, sy, 1,
  766.                                   usernum, net_sysnum, 1, net_num);
  767.                   }
  768.                   ++curmail;
  769.                   if (curmail>=mw)
  770.                     done=1;
  771.                   if (!wfc)
  772.                     topscreen();
  773.                   mailcheck=1;
  774.                 }
  775.               }
  776.             }
  777.           }
  778.           break;
  779.         case 'A':
  780.         case 'S':
  781.         case 'M':
  782.           if (rip_on()) {
  783.             sprintf(s,"\n!|w000%c271610|e|#\r ", formery);
  784.             comstr(s);
  785.           }
  786.           if (!okmail)
  787.             break;
  788.           if (menu_on())
  789.             printmenu(321);
  790.           num_mail=((long) thisuser.feedbacksent) +
  791.                    ((long) thisuser.emailsent) +
  792.                    ((long) thisuser.emailnet);
  793.           if (nn==255) {
  794.             pl(get_string(679));
  795.             i2=0;
  796.             break;
  797.           } else if (m.fromuser!=65535) {
  798.             grab_quotes(&(m.msg),"EMAIL");
  799.             if (ch=='M') {
  800.               nl();
  801.               pl(get_string(15));
  802.               outstr(":");
  803.               input(s,75);
  804.               parse_email_info(s, &un, &sy);
  805.               if (un || sy) {
  806.                 email(un, sy, 0, 0);
  807.               }
  808.             } else {
  809.               email(m.fromuser,m.fromsys,0,m.anony);
  810.             }
  811.             grab_quotes(NULL, NULL);
  812.           }
  813.           num_mail1=((long) thisuser.feedbacksent) +
  814.                     ((long) thisuser.emailsent) +
  815.                     ((long) thisuser.emailnet);
  816.           if ((ch=='A') || (ch=='M')) {
  817.             if (num_mail!=num_mail1) {
  818.               if (m.fromsys!=0)
  819.                 sprintf(s,"%s: %s",net_name,nam1(&thisuser,usernum,net_sysnum));
  820.               else
  821.                 strcpy(s,nam1(&thisuser,usernum,net_sysnum));
  822.               if (m.anony & anony_receiver)
  823.                 strcpy(s,get_string(482));
  824.               strcat(s,get_string(713));
  825.               strcat(s,date());
  826.               if (!(m.status & status_source_verified))
  827.                 ssm(m.fromuser,m.fromsys,s);
  828.               read_same_email(mloc, mw, curmail, &m, 1, 0);
  829.               ++curmail;
  830.               if (curmail>=mw)
  831.                 done=1;
  832.               if (!wfc)
  833.                 topscreen();
  834.             } else {
  835.               nl();
  836.               pl(get_string(721));
  837.               nl();
  838.               i2=0;
  839.             }
  840.           } else {
  841.             if (num_mail != num_mail1) {
  842.               if (!(m.status & status_replied)) {
  843.                 read_same_email(mloc, mw, curmail, &m, 0, status_replied);
  844.               }
  845.               ++curmail;
  846.               if (curmail>=mw)
  847.                 done=1;
  848.               if (!wfc)
  849.                 topscreen();
  850.             }
  851.           }
  852.           if (menu_on())
  853.             printmenu(4);
  854.           break;
  855.         case 'U':
  856.         case 'V':
  857.         case 'C':
  858.           if (!okmail)
  859.             break;
  860.           if ((m.fromsys==0) && (cs()) && (m.fromuser!=65535))
  861.             if (ch=='V')
  862.               valuser(m.fromuser);
  863.             else if (ch=='U')
  864.               uedit(m.fromuser,0);
  865.             else
  866.               uedit(m.fromuser,3);
  867.           else if (cs()) {
  868.             nl();
  869.             pl(get_string(722));
  870.             nl();
  871.           }
  872.           i2=0;
  873.           break;
  874.         case 'L':
  875.           if (!so())
  876.             break;
  877.           nl();
  878.           prt(2,get_string(7));
  879.           input(s,50);
  880.           if (s[0]) {
  881.             nl();
  882.             prt(5,get_string(17));
  883.             if (yn()) {
  884.               nl();
  885.               load_workspace(s,0);
  886.             } else {
  887.               nl();
  888.               load_workspace(s,1);
  889.             }
  890.           }
  891.           break;
  892.       }
  893.     } while ((!i2) && (!hangup));
  894.   } while ((!hangup) && (!done));
  895.  
  896.   bbsfree(mloc);
  897. }
  898.