home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / internet / rnr214.zip / RNRCREA.PAS < prev    next >
Pascal/Delphi Source File  |  1996-04-01  |  59KB  |  2,153 lines

  1. unit rnrcrea;  {formerly from rnrselb}
  2.  
  3. {$I rnr-def.pas}
  4.  
  5.  
  6. interface
  7.  
  8. uses rnrglob,rnrconf,genericf,rnrfunc,rnrproc,rnrio,rnrfile,rnrmous,rnrart
  9.  
  10. {$ifdef charset}
  11. ,rnrchar
  12. {$endif}
  13.  
  14. ;
  15.  
  16. procedure delivermail(mailfn: string);
  17. procedure sendnewsasmail(infn: string; addr: string);
  18. procedure injnews(newartfn: string; newsgroups, originalnewsgroups: string);
  19. procedure copylocalmessage(localfn: string; newfn: string);
  20.  
  21.  
  22. procedure createpostorcancel(iscancel: boolean;
  23.  newsgroups, originalnewsgroups, followupto, subject,
  24.  references, author, originalauthor: string; includedfile: string);
  25.  
  26. procedure createcancel(newsgroups, subject, references,
  27.  originalauthor: string);
  28.  
  29. procedure createpost(newsgroups, originalnewsgroups, followupto, subject,
  30.  references, author, originalauthor: string; includedfile: string);
  31.  
  32.  
  33. procedure editanddeliver(subject,inreplyto,replyaddr,replyname,ccaddr,
  34.  originalfrom,author: string; defaultreply: boolean; includedfile: string;
  35.  justremail: boolean);
  36.  
  37. procedure editandinjnews(newsgroups, originalnewsgroups, author: string);
  38.  
  39.  
  40. procedure post;
  41. procedure mail;
  42. procedure postfile;
  43. procedure mailfile;
  44.  
  45. implementation
  46.  
  47. { assumes setsendencoding() has already been called }
  48. procedure copylocalmessage(localfn: string; newfn: string);
  49.  
  50. var
  51.   localf: text;
  52.   newf: text;
  53.   emptylinefound: boolean;
  54.   oneline: string;
  55.  
  56. begin
  57.   safereset(localf,localfn);
  58.   saferewrite(newf,newfn);
  59.  
  60.   emptylinefound := false;
  61.   while not eof(localf) do
  62.     begin
  63.       readln(localf,oneline);
  64.       if oneline='' then
  65.         emptylinefound := true;
  66.  
  67. {$ifdef charset}
  68.       if uselocalcharset then
  69.         if emptylinefound then
  70.           localtoline(oneline);
  71. {$endif}
  72.  
  73.       writeln(newf,oneline);
  74.     end;
  75.  
  76.   close(localf);
  77.   close(newf);
  78. end;
  79.  
  80. procedure execrmail(addrlist: string; lffn: string);
  81.  
  82. begin
  83.   if pos('%f',mailcmdline)=0 then
  84.     execviacomspec(extwafexpand(mailcmdline,addrlist,'')+' < '+lffn)
  85.   else
  86.     execviacomspec(extwafexpand(mailcmdline,addrlist,lffn));
  87. end;
  88.  
  89. procedure delivermailtolist(mailfn: string; addrlist: string);
  90.  
  91. var
  92.   builtin: boolean;
  93.  
  94.   realaddrlist: string;
  95.   mangledaddrlist: string;
  96.   oneaddress: string;
  97.  
  98.   firstinlist: boolean;
  99.  
  100. {LF file -- empty if there's no need for a LF file this pass}
  101.   lffn: string;
  102.   lff: text;
  103.  
  104. {file the mail's currently in}
  105.   mailf: text;
  106.  
  107. {new sequence #}
  108.   seqstr: string;
  109.  
  110. {outbox copy}
  111.   outboxfn: string;
  112.   outboxf: text;
  113.  
  114. {--outgoing-mail folder copy}
  115.   folderfn: string;
  116.   folderf: text;
  117.  
  118.   emptylinefound: boolean;
  119.   oneline: string;
  120.  
  121. {whether to fake rmail-single (in case of a long list)}
  122.   usingrmailsingle: boolean;
  123.  
  124.   basesite: string;
  125.  
  126. begin
  127.   builtin := mailcmdline=builtincookie;
  128.  
  129.   usingrmailsingle := rmailsingle;
  130.  
  131.   realaddrlist := expandmail(addrlist);
  132.  
  133.   if length(realaddrlist)>64 then
  134.     usingrmailsingle := true;
  135.  
  136.   firstinlist := true;
  137.  
  138.   mangledaddrlist := realaddrlist;
  139.   while mangledaddrlist<>'' do
  140.     begin
  141.       oneaddress := chopfirstaddr(mangledaddrlist);
  142.  
  143.       basesite := copy(basesitename(oneaddress),1,8);
  144.       outboxfn := withbackslash(outboxdir)+basesite;
  145.  
  146. {getuniqfext makes sure it's not a device}
  147.  
  148. {}{}{}{} {getuniqfile doesn't quite!}
  149.  
  150.       if outform='flat' then
  151.         outboxfn := getuniqfext(outboxfn)
  152.       else
  153.         begin
  154.           mkhier(outboxfn);
  155.           outboxfn := getuniqfile(outboxfn);
  156.         end;
  157.  
  158.       lffn := '';
  159.       if builtin then
  160.         begin
  161.           maybemkhier(smarthostdir);
  162.  
  163.           seqstr := integertozstring(newseqnumber,4);
  164.           lffn := withbackslash(smarthostdir)+seqstr+'.dat';
  165.         end
  166.       else if firstinlist or usingrmailsingle then
  167.         begin
  168.           lffn := withbackslash(temporarydir)+userid+'.nl';
  169.         end;
  170.  
  171.       saferewrite(outboxf,outboxfn);
  172.       if fileresult<>0 then
  173.         begin
  174.           xwritelnss('could not write to ',outboxfn);
  175.           shutdown(1);
  176.         end;
  177.  
  178.       if lffn<>'' then
  179.         begin
  180.           saferewrite(lff,lffn);
  181.           if fileresult<>0 then
  182.             begin
  183.               xwritelnss('could not write to ',lffn);
  184.               shutdown(1);
  185.             end;
  186.         end;
  187.  
  188.       safereset(mailf,mailfn);
  189.       if fileresult<>0 then
  190.         begin
  191.           xwritelnss('could not read ',mailfn);
  192.           shutdown(1);
  193.         end;
  194.       
  195.       emptylinefound := false;
  196.       while not eof(mailf) do
  197.         begin
  198.           readln(mailf,oneline);
  199.           if oneline='' then
  200.             emptylinefound := true;
  201.  
  202. {$ifdef charset}
  203.           if uselocalcharset then
  204.             if emptylinefound then
  205.               localtoline(oneline);
  206. {$endif}
  207.  
  208.           if not trusted then
  209.             if not emptylinefound then
  210.               if makesame(oneline,'From: ',mailfrom) then
  211.                 begin end;
  212.  
  213.           writeln(outboxf,oneline);
  214.           if lffn<>'' then
  215.             write(lff,oneline,lf);
  216.         end;
  217.  
  218.       close(mailf);
  219.       close(outboxf);
  220.       if lffn<>'' then
  221.         close(lff);
  222.  
  223.       if builtin then
  224.         begin {builtin}
  225.  
  226. {once .DAT is written, create .XQT}
  227.  
  228.           lffn := withbackslash(smarthostdir)+seqstr+'.xqt';
  229.           saferewrite(lff,lffn);
  230.           write(lff,'U ',fromuserid,' ',uucpname,lf);
  231.           write(lff,'Z',lf);
  232.           write(lff,'F D.',uucpname,seqstr,lf);
  233.           write(lff,'I D.',uucpname,seqstr,lf);
  234.           write(lff,'C rmail ',oneaddress,lf);
  235.           close(lff);
  236.  
  237. {once .DAT and .XQT are written, create .CMD}
  238.  
  239.           lffn := withbackslash(smarthostdir)+seqstr+'.cmd';
  240.           saferewrite(lff,lffn);
  241.           writeln(lff,'S ',seqstr,'.DAT D.',uucpname,seqstr,' ',
  242.            fromuserid,' - ',seqstr,'.DAT 0600');
  243.           writeln(lff,'S ',seqstr,'.XQT X.',uucpname,seqstr,' ',
  244.            fromuserid,' - ',seqstr,'.XQT 0600');
  245.           close(lff);
  246.  
  247.         end {builtin}
  248.       else if usingrmailsingle then
  249.         begin {usingrmailsingle}
  250.  
  251.           mouseshutdown;
  252.  
  253.           execrmail(oneaddress,lffn);
  254.  
  255.           mouseinit;
  256.  
  257.           if execresult<>0 then
  258.             warnerr(mailcmdline,execresult);
  259.  
  260.         end {usingrmailsingle}
  261.       else if firstinlist then
  262.         begin {firstinlist}
  263.  
  264.           mouseshutdown;
  265.  
  266.           execrmail(uncomma(realaddrlist),lffn);
  267.  
  268.           mouseinit;
  269.  
  270.           if execresult<>0 then
  271.             warnerr(mailcmdline,execresult);
  272.  
  273.         end; {firstinlist}
  274.  
  275.       firstinlist := false;
  276.     end;
  277. end;
  278.  
  279. procedure delivermail;
  280.  
  281. var
  282.   toaddr: string;
  283.   ccaddr: string;
  284.  
  285. {the --outgoing-mail should only get one copy, even with two lists}
  286.   outgoingmaildir: string;
  287.   outgoingmailfn: string;
  288.   outgoingmailf: text;
  289.  
  290. begin
  291. {two :mail commands in a row don't work without this!}
  292.   headerinmem := '';
  293.  
  294. {$ifdef charset}
  295.  
  296. { Must do this _before_ opening mailfile with reset(), or it will fail }
  297. { for the poor users who have share loaded                             }
  298.  
  299.   if uselocalcharset then
  300.     setsendencoding(
  301.      getheaderline(mailfn,'content-type:'),
  302.      getheaderline(mailfn,'content-transfer-encoding:'));
  303. {$endif}
  304.   
  305.   toaddr := getheaderline(mailfn,'to:');
  306.   ccaddr := getheaderline(mailfn,'cc:');
  307.  
  308.   if toaddr=couldnotreadfilecookie then
  309.     begin
  310.       warn('not sent -- could not read '+mailfn+'!');
  311.     end
  312.   else if ccaddr=couldnotreadfilecookie then
  313.     begin
  314.       warn('not sent -- could not read '+mailfn+'!');
  315.     end
  316.   else
  317.     begin
  318.       delivermailtolist(mailfn,toaddr);
  319.       if ccaddr<>'' then
  320.         delivermailtolist(mailfn,ccaddr);
  321.  
  322.       if outgoingmail<>'' then
  323.         begin
  324.           outgoingmaildir := getgroupdir(outgoingmail);
  325.           if outgoingmaildir='' then
  326.             warn('could not find a directory for '+outgoingmail)
  327.           else
  328.             begin
  329.               mkhier(outgoingmaildir);
  330.               outgoingmailfn := getuniqfile(outgoingmaildir);
  331.               xclreolxy(1,lpp);
  332.               xwritesss('Saving a copy in ',outgoingmailfn,'...');
  333.               copylocalmessage(mailfn,outgoingmailfn);
  334.             end;
  335.         end;
  336.     end;
  337.  
  338.   {caller will refresh}
  339. end;
  340.  
  341. procedure sendnewsasmail;
  342.  
  343. var
  344.   inf: text;
  345.   tempfn: string;
  346.   tempf: text;
  347.   oneline: string;
  348.   toseen: boolean;
  349.   emptylinefound: boolean;
  350.   ccaddrfound: string;
  351.   isccline: boolean;
  352.   toaddr: string;
  353.   ccaddr: string;
  354.  
  355. begin
  356.   warn('mailing to '+copy(addr,1,50));
  357.  
  358.   toaddr := '';
  359.   ccaddr := '';
  360.  
  361.   xwrites('mailing...');
  362.  
  363.   safereset(inf,infn);
  364.  
  365.   tempfn := withbackslash(temporarydir)+userid+'.n2m';
  366.   saferewrite(tempf,tempfn);
  367.  
  368.   if not nomailfrom then
  369.     writeln(tempf,'From ',fromuserid,'  ',copy(cdow,1,3),', ',
  370.      dayofmonth,' ',copy(monthname,1,3),' ',year,' ',currenttimestring,' ',
  371.      timezone,' ','remote from ',uucpname);
  372.  
  373.   if not isheaderinlist('Received:',nomailheaders) then
  374.     begin
  375.       writeln(tempf,'Received: by ',fqdn,' ('+newsreadername+')');
  376.       writeln(tempf,'       via ',newsreadername,'; ',copy(cdow,1,3),', ',
  377.        dayofmonth,' ',copy(monthname,1,3),' ',year,' ',
  378.        currenttimestring,' ',timezone);
  379.     end;
  380.  
  381. { supress CC:s until very end -- if there was a To: then give up the CC: }
  382. { unchanged; otherwise change the CC: to a To: so there's one for uupc }
  383.  
  384.   toseen := false;
  385.   emptylinefound := false;
  386.   ccaddrfound := '';
  387.  
  388.   while not eof(inf) do
  389.     begin
  390.       readln(inf,oneline);
  391.       isccline := false;
  392.  
  393.       if not emptylinefound then  {must write it before the empty line!}
  394.         begin
  395.           if lower(copy(ltrim(oneline),1,3))='to:' then
  396.             begin
  397.               toseen := true;
  398.               oneline := ltrim(copy(ltrim(oneline),4,255));
  399.               if (oneline='poster') or (oneline='sender') then
  400.                 oneline := addr;
  401.               toaddr := expandmail(oneline);
  402.               oneline := 'To: '+toaddr;
  403.             end;
  404.           if lower(copy(ltrim(oneline),1,3))='cc:' then
  405.             begin
  406.               ccaddrfound := ltrim(copy(ltrim(oneline),4,255));
  407.               isccline := true;
  408.             end;
  409.  
  410.           if oneline='' then
  411.             emptylinefound := true;
  412.  
  413.           if emptylinefound then  {it must have _just_ become true}
  414.             begin
  415.  
  416.               if not isheaderinlist('Comments:',nomailheaders) then
  417.                 begin
  418.                   writeln(tempf,'Comments: ',
  419.                    'this message originated as a public newsgroup posting');
  420.                 end;
  421.  
  422.               if toseen then  {was a To: -- print out the CC: we suppressed}
  423.                 begin
  424.                   if ccaddrfound<>'' then
  425.                     begin
  426.                       if (ccaddrfound='poster') or (ccaddrfound='sender') then
  427.                         ccaddrfound := addr;
  428.                       ccaddrfound := expandmail(ccaddrfound);
  429.                       ccaddr := ccaddrfound;
  430.                       writeln(tempf,'CC: ',ccaddr);
  431.                     end;
  432.                 end
  433.               else
  434.                 begin
  435.                   if ccaddrfound='' then
  436.                     ccaddrfound := addr;
  437.                   if (ccaddrfound='poster') or (ccaddrfound='sender') then
  438.                     ccaddrfound := addr;
  439.                   ccaddrfound := expandmail(ccaddrfound);
  440.                   toaddr := ccaddrfound;
  441.                   writeln(tempf,'To: ',toaddr);
  442.                   toseen := true;
  443.                 end;
  444.  
  445.               if indicatepostedmailinbody then
  446.                 begin
  447.                   {finish headers}
  448.                   writeln(tempf);
  449.  
  450.                   writeln(tempf,
  451.               '[ this message originated as a public newsgroup posting ]');
  452.                   {empty line (the first one!) will follow}
  453.                 end;
  454.             end;
  455.         end;
  456.  
  457.       if not isccline then
  458.         writeln(tempf,oneline);
  459.     end;
  460.  
  461.   close(inf);
  462.   close(tempf);
  463.  
  464.   delivermail(tempfn);
  465.  
  466. end;
  467.  
  468. {}{} {should be a three-part process!}
  469.  
  470. procedure injnews;
  471.   
  472. var
  473.   goingtomail: boolean;
  474.   newartf: text;
  475.   newartlffn: string;
  476.   newartlff: text;
  477.   emptylinefound: boolean;
  478.   oneline: string;
  479.   newnewsgroups: string;
  480.   mungedgroups: string;
  481.   firstnewsgroup: string;
  482.   firstcommapos: integer;
  483.   newfrom: string;
  484.   newapproved: string;
  485.   outgoinggroup: string;
  486.   outgoingdir: string;
  487.   outgoingfn: string;
  488.   outgoingf: text;
  489.   fromfound: boolean;
  490.   moderatoraddr: string;
  491.   onlylf: boolean;
  492.  
  493. begin
  494.   goingtomail := false;
  495.  
  496.   headerinmem := '';
  497.  
  498. { Must do this _before_ opening mailfile with reset(), or it will fail }
  499. { for the poor users who have share loaded                             }
  500.  
  501. {$ifdef charset}
  502.   if uselocalcharset then
  503.     setsendencoding(
  504.      getheaderline(newartfn,'content-type:'),
  505.      getheaderline(newartfn,'content-transfer-encoding:'));
  506. {$endif}  
  507.  
  508.   newnewsgroups := getheaderline(newartfn,'newsgroups:');
  509.  
  510.   newfrom := getheaderline(newartfn,'from:');
  511.   newapproved := getheaderline(newartfn,'approved:');
  512.  
  513.   safereset(newartf,newartfn);
  514.  
  515. {copy to outgoing directory if asked -- just pick the first one found}
  516.      
  517.   outgoingfn := '';
  518.   outgoinggroup := '';
  519.  
  520. {first:  try to find an outgoing group for any group it was posted to}
  521.  
  522. {the `done' isn't necessary, even a space would do, and probably}
  523. {even ending the string at the `,' would do, but why take chances}
  524. {with the string routines?}
  525.  
  526.   mungedgroups := newnewsgroups+',done';
  527.  
  528.   while (outgoinggroup='') and (numoccur(',',mungedgroups)>0) do
  529.     begin
  530.       firstcommapos := pos(',',mungedgroups);
  531.       firstnewsgroup := copy(mungedgroups,1,firstcommapos-1);
  532.       mungedgroups := copy(mungedgroups,firstcommapos+1,255);
  533.       outgoinggroup := groupsattr(firstnewsgroup,'/spy=');
  534.     end;
  535.  
  536. {second:  try to find an outgoing group for any group before editing}
  537.  
  538. {the `done' isn't necessary, even a space would do, and probably}
  539. {even ending the string at the `,' would do, but why take chances}
  540. {with the string routines?}
  541.  
  542.   mungedgroups := newsgroups+',done';
  543.  
  544.   while (outgoinggroup='') and (numoccur(',',mungedgroups)>0) do
  545.     begin
  546.       firstcommapos := pos(',',mungedgroups);
  547.       firstnewsgroup := copy(mungedgroups,1,firstcommapos-1);
  548.       mungedgroups := copy(mungedgroups,firstcommapos+1,255);
  549.       outgoinggroup := groupsattr(firstnewsgroup,'/spy=');
  550.     end;
  551.  
  552. {finally:  try to find an outgoing group for any group before Followup-To: }
  553.  
  554. {the `done' isn't necessary, even a space would do, and probably}
  555. {even ending the string at the `,' would do, but why take chances}
  556. {with the string routines?}
  557.  
  558.   mungedgroups := originalnewsgroups+',done';
  559.  
  560.   while (outgoinggroup='') and (numoccur(',',mungedgroups)>0) do
  561.     begin
  562.       firstcommapos := pos(',',mungedgroups);
  563.       firstnewsgroup := copy(mungedgroups,1,firstcommapos-1);
  564.       mungedgroups := copy(mungedgroups,firstcommapos+1,255);
  565.       outgoinggroup := groupsattr(firstnewsgroup,'/spy=');
  566.     end;
  567.  
  568.   if outgoinggroup='' then
  569.     outgoinggroup := outgoingnews;
  570.  
  571.   if outgoinggroup='' then
  572.     begin
  573.       if not quiet then
  574.         warn('(there is no outgoing group copy for this post)');
  575.     end
  576.   else
  577.     begin
  578.       outgoingdir := getgroupdir(outgoinggroup);
  579.       if outgoingdir='' then
  580.         begin
  581.           warn('no dir found for outgoing group '+outgoinggroup+' !');
  582.         end
  583.       else
  584.         begin
  585.           outgoingfn := getuniqfile(outgoingdir);
  586.         end;
  587.     end;
  588.  
  589. {check if any group on the list is moderated}
  590.  
  591. {the `done' isn't necessary, even a space would do, and probably}
  592. {even ending the string at the `,' would do, but why take chances}
  593. {with the string routines?}
  594.  
  595.   mungedgroups := newnewsgroups+',done';
  596.   moderatoraddr := '';
  597.  
  598.   while (moderatoraddr='') and (numoccur(',',mungedgroups)>0) do
  599.     begin
  600.       firstcommapos := pos(',',mungedgroups);
  601.       firstnewsgroup := copy(mungedgroups,1,firstcommapos-1);
  602.       mungedgroups := copy(mungedgroups,firstcommapos+1,255);
  603.       if ismoderated(firstnewsgroup) then
  604.         begin
  605.           moderatoraddr := groupsattr(firstnewsgroup,'/mod=');
  606.           if moderatoraddr='' then
  607.             begin
  608. {1996-02-15 -- this crepl caused a stack overflow}
  609.               moderatoraddr := crepl(firstnewsgroup,'.','-');
  610.               moderatoraddr := moderatoraddr+'@'+backbone;
  611.             end;
  612.         end;
  613.     end;
  614.  
  615. {
  616.   allow only trusted users to issue Control: messages, post to alt.hackers,
  617.   be group moderators, etc.
  618. }
  619.  
  620.   if trusted then
  621.     if newapproved<>'' then
  622.       moderatoraddr := '';
  623.  
  624.   goingtomail := (moderatoraddr<>'');
  625.  
  626. {use LF for posts, CRLF for mail}
  627.  
  628.   onlylf := not goingtomail;
  629.  
  630.   newartlffn := withbackslash(temporarydir)+userid+'.nl';
  631.   saferewrite(newartlff,newartlffn);
  632.  
  633.   if outgoingfn<>'' then
  634.     begin
  635.       mkhier(outgoingdir);
  636.  
  637.       saferewrite(outgoingf,outgoingfn);
  638.  
  639.       if fileresult<>0 then
  640.         begin
  641.           warn('could not write to outgoing file '+outgoingfn);
  642.           outgoingfn := '';
  643.         end;
  644.     end;
  645.  
  646.   emptylinefound := false;
  647.   reset(newartf);
  648.   while not eof(newartf) do
  649.     begin
  650.       readln(newartf,oneline);
  651.  
  652. {$ifdef charset}
  653.       if (uselocalcharset) then
  654.         if emptylinefound then
  655.           localtoline(oneline);
  656. {$endif}
  657.  
  658.       if not trusted then
  659.         if not emptylinefound then
  660.           if makesame(oneline,'From: ',mailfrom) then
  661.             begin end;
  662.  
  663.       if not emptylinefound then
  664.         if copy(oneline,1,6)='From: ' then
  665.           fromfound := true;
  666.  
  667.       if oneline='' then
  668.         begin
  669.           if not emptylinefound then  {this must be the first empty line}
  670.             begin
  671.               if not fromfound then
  672.                 begin
  673.                   if onlylf then
  674.                     write(newartlff,'From: ',newsfrom,lf)
  675.                   else
  676.                     writeln(newartlff,'From: ',newsfrom);
  677.  
  678.                   if outgoingfn<>'' then
  679.                     writeln(outgoingf,'From: ',newsfrom);
  680.  
  681.                   fromfound := true;
  682.                 end;
  683.             end;
  684.           emptylinefound := true;
  685.         end;
  686.  
  687.       if onlylf then
  688.         write(newartlff,oneline,lf)
  689.       else
  690.         writeln(newartlff,oneline);
  691.  
  692.       if outgoingfn<>'' then
  693.         writeln(outgoingf,oneline);
  694.     end;
  695.   close(newartf);
  696.   close(newartlff);
  697.   if outgoingfn<>'' then
  698.     close(outgoingf);
  699.  
  700.   if goingtomail then
  701.     begin
  702.       sendnewsasmail(newartlffn,moderatoraddr);
  703.     end
  704.   else
  705.     begin
  706.  
  707. {}{} {should use rnews in bin directory only?}
  708.  
  709.       mouseshutdown;
  710.  
  711.       if pos('%f',newscmdline)=0 then
  712.         execviacomspec(wafexpand(newscmdline)+' < '+newartlffn)
  713.       else
  714.         execviacomspec(extwafexpand(newscmdline,'',newartlffn));
  715.  
  716.       mouseinit;
  717.  
  718. {}{} {waffle's rnews sometimes displays random error message on low memory}
  719.      {but then doesn't exit with an error return code!}
  720.  
  721.       waitnseconds(1);
  722.  
  723.       if execresult<>0 then
  724.         warnerr(newscmdline,execresult);
  725.  
  726.     end;
  727. end;
  728.  
  729. procedure createpostorcancel;
  730.  
  731. { if author<>'', opens then closes artf }
  732.  
  733. var
  734.   newartfn: string;
  735.   newartf: text;
  736.   refline: string;
  737.   wref: string;
  738.   nextref: string;
  739.   ref1,ref2: string;
  740.   emptylinefound: boolean;
  741.   sigfn: string;
  742.   sigf: text;
  743.   oneline: string;
  744.   ccaddr: string;
  745.  
  746. begin
  747.  
  748. { don't propogate errors in the Newsgroups: line if you can help it }
  749.  
  750.   newsgroups := unspace(newsgroups);
  751.   followupto := unspace(followupto);
  752.  
  753.   newartfn := withbackslash(temporarydir)+userid+'.fol';
  754.   saferewrite(newartf,newartfn);
  755.  
  756. {this done since waf164 didn't handle newsname like waf165 does}
  757.  
  758.   if not isheaderinlist('Path:',nonewsheaders) then
  759.     writeln(newartf,'Path: ',newsname,'!',pathuserid);
  760.  
  761.   writeln(newartf,'Newsgroups: ',newsgroups);
  762.   if (originalnewsgroups<>'') and (originalnewsgroups<>newsgroups) then
  763.     writeln(newartf,'X-Original-Newsgroups: ',originalnewsgroups);
  764.   if followupto<>'' then
  765.     writeln(newartf,'Followup-To: ',followupto);
  766.   if originalauthor<>'' then
  767.     writeln(newartf,'X-Original-Article-From: ',originalauthor);
  768.  
  769.   if iscancel then
  770.     begin
  771.       if newsfrom=originalauthor then
  772.         begin
  773.           writeln(newartf,'From: ',newsfrom);
  774.           writeln(newartf,'Sender: ',newsfrom);
  775.         end
  776.       else
  777.         begin
  778.           writeln(newartf,'From: ',originalauthor);
  779.           writeln(newartf,'Sender: ',newsfrom);
  780.         end;
  781.     end
  782.   else
  783.     begin
  784.       writeln(newartf,'From: ',newsfrom);
  785.     end;
  786.  
  787.   if replyto<>'' then
  788.     writeln(newartf,'Reply-To: ',replyto);
  789.  
  790.   writeln(newartf,'Subject: ',subject);
  791.  
  792.   if not isheaderinlist('Message-ID:',nonewsheaders) then
  793.     writeln(newartf,'Message-ID: ',newmessageid);
  794.  
  795.   writeln(newartf,'Date: ',copy(cdow,1,3),', ',dayofmonth,' ',
  796.    copy(monthname,1,3),' ',year,' ',currenttimestring,' ',timezone);
  797.  
  798.   if references<>'' then
  799.     begin
  800.  
  801. {$ifdef rnewscontbroken}
  802.       writeln(newartf,'References: ',references);
  803. {$else}
  804.  
  805. { wref is the space-terminated string of references that are yet to be }
  806. { written out - it starts with two spaces if need be (other than line one) }
  807.  
  808.       wref := 'References: ';
  809.       while references<>'' do
  810.         begin
  811.           references := ltrim(references);
  812.           nextref := chopfirstw(references);
  813.           if length(wref+nextref)>70 then
  814.             begin
  815.               writeln(newartf,wref);
  816.               wref := '  '+nextref+' ';
  817.             end
  818.           else
  819.             wref := wref+nextref+' ';
  820.         end;
  821.       if wref<>'' then
  822.         writeln(newartf,trim(wref));
  823. {$endif}
  824.  
  825.     end;
  826.  
  827.   if organ<>'' then
  828.     writeln(newartf,'Organization: ',organ);
  829.  
  830. {$ifdef charset}
  831.   if uselocalcharset then
  832.     begin
  833.       writeln(newartf,'MIME-Version: 1.0');
  834.       writeln(newartf,'Content-Type: text/plain; charset=',mailingsetname);
  835.       writeln(newartf,'Content-Transfer-Encoding: ',mailxfername);
  836.     end;
  837. {$endif}
  838.  
  839.   if iscancel then
  840.     writeln(newartf,'Control: ','cancel ',references);
  841.  
  842.   if not isheaderinlist('X-Newsreader:',nonewsheaders) then
  843.     writeln(newartf,'X-Newsreader: ',newsreadername,' ',newsreaderversion);
  844.  
  845.   writeln(newartf);
  846.  
  847.   if iscancel then
  848.     writeln(newartf,'cancelled within ',newsreadername)
  849.   else if includedfile<>'' then
  850.     begin
  851.       writeln(newartf,'encoded file ',includedfile,' follows:');
  852.       writeln(newartf);
  853.       close(newartf);
  854.       appendencodedfile(newartfn,includedfile);
  855.       assign(newartf,newartfn);
  856.       append(newartf);
  857.       writeln(newartf);
  858.     end
  859.   else if author='' then
  860.     writeln(newartf,newsmarkerline)
  861.   else
  862.     begin
  863.       writeln(newartf,author,' writes:');
  864.       writeln(newartf);
  865.  
  866.       emptylinefound := false;
  867.  
  868.       artreset;
  869.       while not arteof and not emptylinefound do
  870.         begin
  871.           getartl(oneline,255,notoscreen);
  872.           if oneline='' then
  873.             emptylinefound := true;
  874.         end;
  875.  
  876.       while not arteof do
  877.         begin
  878.  
  879. {don't use just cols here, to be polite}
  880.  
  881.           getartl(oneline,min(cols,80)-3,notoscreen);
  882.  
  883. {$ifdef charset}
  884.           if uselocalcharset then
  885.              linetolocal(oneline);
  886. {$endif}
  887.  
  888.           if oneline='' then
  889.             writeln(newartf,'>')
  890.           else if (copy(oneline,1,1)='>') and not quotewithspace then
  891.             writeln(newartf,'>',expand(oneline))
  892.           else
  893.             writeln(newartf,'> ',expand(oneline));
  894.  
  895.         end;
  896.       artclose;
  897.     end;
  898.  
  899.   sigfn := unslash(getconfig('signature'));
  900.   if sigfn='' then
  901.     sigfn := 'sig';
  902.   if numoccur('\',sigfn)=0 then
  903.     sigfn := withbackslash(home)+sigfn;
  904.  
  905.   safereset(sigf,sigfn);
  906.   if fileresult=0 then
  907.     begin
  908.       readln(sigf,oneline);
  909.       if oneline<>'-- ' then
  910.         writeln(newartf,'-- ');
  911.       reset(sigf);
  912.       while not eof(sigf) do
  913.         begin
  914.           readln(sigf,oneline);
  915.           writeln(newartf,oneline);
  916.         end;
  917.       close(sigf);
  918.     end;
  919.   close(newartf);
  920. end;
  921.  
  922. procedure createcancel;
  923.  
  924. begin
  925.   createpostorcancel(true,newsgroups,'','',subject,
  926.    references,'',originalauthor,'');
  927. end;
  928.  
  929. procedure createpost;
  930.  
  931. begin
  932.   createpostorcancel(false,newsgroups,originalnewsgroups,followupto,
  933.    subject,references,author,originalauthor,includedfile);
  934. end;
  935.  
  936. procedure editandinjnews;
  937.   
  938. var
  939.   newartfn: string;
  940.   sendeditvspellquit: char;
  941.   ccaddr: string;
  942.  
  943.   cansend: boolean;
  944.   sendprompt: string;
  945.   sendchar: char;
  946.   invalidmessage: string;
  947.  
  948.   anyunknowngroups: boolean;
  949.   anymailgroups: boolean;
  950.  
  951.   newsgroupsline: string;
  952.   onenewsgroup: string;
  953.   onenewsgroupwithdesc: string;
  954.   onenewsgroupwithdescline: integer;
  955.  
  956.   groupwidth: integer;
  957.   descwidth: integer;
  958.  
  959. begin
  960.  
  961. { don't propogate errors in the Newsgroups: line if you can help it }
  962.  
  963.   newsgroups := unspace(newsgroups);
  964.  
  965.   newartfn := withbackslash(temporarydir)+userid+'.fol';
  966.  
  967. {edit the first time around}
  968.   sendeditvspellquit := 'e';
  969.  
  970.   while (sendeditvspellquit<>'s') and (sendeditvspellquit<>'q') do
  971.     begin
  972.       if not trusted then
  973.         if sendeditvspellquit='E' then
  974.           sendeditvspellquit := 'e';
  975.  
  976.       if sendeditvspellquit='v' then
  977.         begin
  978.           mouseshutdown;
  979.           execp(vspeller,vspelleroptions+' '+newartfn);
  980.           mouseinit;
  981.  
  982.           if execresult<>0 then
  983.             warnerr(vspeller,execresult);
  984.  
  985.           if editaftervspell then
  986.             sendeditvspellquit := 'e';
  987.         end;
  988.  
  989.       if sendeditvspellquit='e' then
  990.         begin
  991.           mouseshutdown;
  992.           execp(editor,editoroptions+' '+newartfn);
  993.           mouseinit;
  994.  
  995.           if execresult<>0 then
  996.             warnerr(editor,execresult);
  997.         end;
  998.  
  999.       if sendeditvspellquit='E' then
  1000.         begin
  1001.           mouseshutdown;
  1002.           execp(editor,editoroptions+' '+newartfn+' '+artfn);
  1003.           mouseinit;
  1004.  
  1005.           if execresult<>0 then
  1006.             warnerr(editor,execresult);
  1007.         end;
  1008.  
  1009.  
  1010. {}{} {check headers and headers-ran-into-body messages}
  1011.      {invalid format of Newsgroups: line (spaces, etc.)}
  1012.      {warn if any groups in Newsgroups: not in forum set}
  1013.      {delete any duplicates from Newsgroups: line}
  1014.      {check From:}
  1015.      {check for /solo groups}
  1016.      {a Lines: header might be polite.  maybe not}
  1017.  
  1018.       headerinmem := '';  {invalidate cache from last getheaderline}
  1019.  
  1020.       cansend := true;
  1021.  
  1022.       xclreolxy(1,lpp);
  1023.       xwrites('checking headers...');
  1024.  
  1025.       if cansend then
  1026.         if getheaderline(newartfn,'from:')=couldnotreadfilecookie then
  1027.           begin
  1028.             warn('not sent -- could not read '+newartfn+'!');
  1029.             cansend := false;
  1030.           end;
  1031.  
  1032.       if cansend then
  1033.         if trim(getheaderline(newartfn,'from:'))='' then
  1034.           begin
  1035.             warn('no From: header -- cannot send');
  1036.             cansend := false;
  1037.           end;
  1038.  
  1039.       if cansend then
  1040.         if not trusted then
  1041.           if getfromaddr(getheaderline(newartfn,'from:'))<>
  1042.            getfromaddr(newsfrom) then
  1043.             begin
  1044.               warn('changed From: header -- cannot send');
  1045.               cansend := false;
  1046.             end;
  1047.  
  1048.       if cansend then
  1049.         if trim(getheaderline(newartfn,'subject:'))='' then
  1050.           begin
  1051.             warn('no Subject: header -- cannot send');
  1052.             cansend := false;
  1053.           end;
  1054.  
  1055.       if cansend then
  1056.         if lower(trim(getheaderline(newartfn,'subject:')))='re:' then
  1057.           begin
  1058.             warn('no Subject: header -- cannot send');
  1059.             cansend := false;
  1060.           end;
  1061.  
  1062.       if cansend then
  1063.         begin
  1064.           newsgroupsline := getheaderline(newartfn,'newsgroups:');
  1065.           newsgroupsline := ltrim(trim(newsgroupsline));
  1066.           newsgroupsline := crepl(newsgroupsline,tab,' ');
  1067.         end;
  1068.  
  1069.       if cansend then
  1070.         if newsgroupsline='' then
  1071.           begin
  1072.             warn('no Newsgroups: header -- cannot send');
  1073.             cansend := false;
  1074.           end;
  1075.  
  1076.       if cansend then
  1077.         if numoccur(' ',newsgroupsline)<>0 then
  1078.           begin
  1079.             warn('no spaces are allowed in Newsgroups: header -- cannot send');
  1080.             cansend := false;
  1081.           end;
  1082.  
  1083.       if cansend then
  1084.         begin
  1085.           invalidmessage := findproblemwithmessage(newartfn);
  1086.           if invalidmessage<>'' then
  1087.             begin
  1088.               warn2(invalidmessage,'cannot send');
  1089.               cansend := false;
  1090.             end;
  1091.         end;
  1092.  
  1093.       if cansend then
  1094.         if toomuchquoting(newartfn) then
  1095.           begin
  1096.             warn('lots of quoting, not much new material -- please edit');
  1097.             if not trusted then
  1098.               cansend := false;
  1099.           end;
  1100.  
  1101.       if cansend then
  1102.         if not trusted then
  1103.           if trim(getheaderline(newartfn,'approved:'))<>'' then
  1104.             begin
  1105.               warn('without --trusted, cannot send approved articles');
  1106.               cansend := false;
  1107.             end;
  1108.  
  1109.       if cansend then
  1110.         if toolongline(newartfn,255) then
  1111.           begin
  1112.  
  1113. {}{}{}{} {should offer to word-wrap in place instead}
  1114.             warn('some line is very long, and will be lost');
  1115.             cansend := false;
  1116.           end;
  1117.  
  1118.       if cansend then
  1119.         if toolongline(newartfn,80) then
  1120.           begin
  1121.             warn2('some lines are >80 chars, which people with really old',
  1122.             'or poorly-planned software will have problems seeing');
  1123.           end;
  1124.  
  1125. {don't let trusted users post to more than 3 groups (2 commas)}
  1126.       if cansend then
  1127.         if numoccur(',',newsgroupsline)>2 then
  1128.           begin
  1129.             warn('massive crossposting -- please edit');
  1130.             if not trusted then
  1131.               cansend := false;
  1132.           end;
  1133.  
  1134.  
  1135.       if cansend then
  1136.         begin
  1137.           anyunknowngroups := false;
  1138.           anymailgroups := false;
  1139.  
  1140.           onenewsgroupwithdescline := lpp-2;
  1141.  
  1142. { the message will go on lpp, so clear lpp-1 to start }
  1143.           xclreolxy(1,lpp-1);
  1144.  
  1145. { clear space for the first description }
  1146.           xclreolxy(1,onenewsgroupwithdescline);
  1147.  
  1148. {
  1149.   there are cols-1 useful columns
  1150.   groupwidth and its trailing space are already used
  1151. }
  1152.  
  1153.           groupwidth := max(cols div 2-10,10);
  1154.           descwidth := cols-1 - (groupwidth+1);
  1155.  
  1156.           newsgroupsline := uncomma(newsgroupsline);
  1157.  
  1158.           while newsgroupsline<>'' do
  1159.             begin
  1160.               onenewsgroup := chopfirstw(newsgroupsline);
  1161.  
  1162.               if ismailgroup(onenewsgroup) then
  1163.                 anymailgroups := true;
  1164.  
  1165.               if getgroupdir(onenewsgroup)='' then
  1166.                 anyunknowngroups := true;
  1167.  
  1168.               if onenewsgroupwithdescline>4 then
  1169.                 begin
  1170.                   onenewsgroupwithdesc :=
  1171.                    leftjustify(right(onenewsgroup,groupwidth),groupwidth,' ')+
  1172.                    ' '+
  1173.                    copy(sourcedesc(onenewsgroup,sourcegroup),1,descwidth);
  1174.  
  1175. { clear the line above to make it stand out }
  1176.                   xclreolxy(1,onenewsgroupwithdescline-1);
  1177.  
  1178. {
  1179.  this line must already be clear then, either from the pre-loop
  1180.  code or the previous iteration
  1181. }
  1182.                   writexy(1,onenewsgroupwithdescline,onenewsgroupwithdesc);
  1183.  
  1184.                   dec(onenewsgroupwithdescline);
  1185.                 end;
  1186.             end;
  1187.  
  1188.           if anymailgroups then
  1189.             begin
  1190.               warn('cannot crosspost to a private mail pseudo-group!');
  1191.               cansend := false;
  1192.             end
  1193.           else if anyunknowngroups then
  1194.             warn('some groups not on this site -- might be invalid');
  1195.         end;
  1196.  
  1197.       if cansend then
  1198.         begin
  1199.           sendprompt := '{s}end ';  {note trailing space}
  1200.           sendchar := 's';
  1201.         end
  1202.       else
  1203.         begin
  1204.           sendprompt := '';
  1205.           sendchar := 'q';  {can always quit}
  1206.         end;
  1207.  
  1208.       if author='' then
  1209.         sendeditvspellquit :=
  1210.          onekey('Public: '+sendprompt+'{e}dit {v}spell {q}uit',
  1211.           sendchar+'evq')
  1212.       else
  1213.         sendeditvspellquit :=
  1214.          onekey('Public: '+sendprompt+'{e}dit {E}dit-both {v}spell {q}uit',
  1215.          sendchar+'eEvq');
  1216.  
  1217.       if sendeditvspellquit='s' then
  1218.         xwrites('sending...')
  1219.       else if sendeditvspellquit='e' then
  1220.         xwrites('editing...')
  1221.       else if sendeditvspellquit='E' then
  1222.         xwrites('editing both...')
  1223.       else if sendeditvspellquit='v' then
  1224.         xwrites('vspelling...')
  1225.       else if sendeditvspellquit='q' then
  1226.         xwrites('quit');
  1227.  
  1228.     end;
  1229.  
  1230.   if sendeditvspellquit='s' then
  1231.     begin
  1232.       headerinmem:= '';  { In case user edited headers ... }
  1233.  
  1234.       injnews(newartfn,newsgroups,originalnewsgroups);
  1235.       ccaddr := getheaderline(newartfn,'cc:');
  1236.  
  1237.       if ccaddr<>'' then
  1238.         begin
  1239.           if (ccaddr='poster') or (ccaddr='sender') then
  1240.             ccaddr := author;
  1241.  
  1242.           sendnewsasmail(newartfn,ccaddr);
  1243.         end;
  1244.  
  1245.     end;
  1246.  
  1247. {leave refresh and artf re-opening to the caller}
  1248.  
  1249. end;
  1250.  
  1251. procedure post;
  1252.  
  1253. var
  1254.   nsubject: string;
  1255.   ngroups: string;
  1256.   postforgetit: char;
  1257.  
  1258. begin
  1259.   ngroups := internalcmdlineparams;
  1260.  
  1261.   if ngroups<>'' then
  1262.     if not isavalidgroup(ngroups) then
  1263.       if joinedtogroup(ngroups) then
  1264.         ;
  1265.  
  1266.   if ngroups='' then
  1267.     begin
  1268.       if currsourcekind=sourcegroup then
  1269.         ngroups := currsource
  1270.       else
  1271.         ngroups := 'misc.misc';
  1272.     end;
  1273.  
  1274.   if not maypost then
  1275.     warn('you do not have access to post this way')
  1276.   else
  1277.     begin
  1278.       if ismoderated(ngroups) then
  1279.         warn(ngroups+' group is moderated');
  1280.  
  1281.       postforgetit := 'p';
  1282.       if ismailgroup(ngroups) then
  1283.         begin
  1284.           ngroups := 'misc.misc';
  1285.           postforgetit :=
  1286.            onekeydef('this is a mail group - {p}ost {f}orget it','pf','f');
  1287.         end;
  1288.  
  1289.       if postforgetit='p' then
  1290.         begin
  1291.           xclreolxy(1,lpp-3);
  1292.           xclreolxy(1,lpp-2);
  1293.           xwrites(sourcedesc(ngroups,sourcegroup));
  1294.           xclreolxy(1,lpp-1);
  1295.           xclreolxy(1,lpp);
  1296.           xwrites('Subject: ');
  1297.           xreadlns(nsubject,max(cols-10,70),nopreserve);
  1298.           xclreolxy(1,lpp);
  1299.           xwrites('Newsgroups: ');
  1300.           xreadlns(ngroups,max(cols-15,70),yespreserve);
  1301.  
  1302.           if ngroups='' then
  1303.             ngroups := 'misc.misc';
  1304.  
  1305.           if not isavalidgroup(ngroups) then
  1306.             if joinedtogroup(ngroups) then
  1307.               ;
  1308.  
  1309.           createpost(ngroups,'','',nsubject,'','','','');
  1310.           editandinjnews(ngroups,'','');
  1311.         end;
  1312.     end;
  1313.  
  1314. { caller must refresh }
  1315.  
  1316. end;
  1317.  
  1318. procedure postfile;
  1319.  
  1320. var
  1321.   nsubject: string;
  1322.   ngroups: string;
  1323.   postforgetit: char;
  1324.   includedfile: string;
  1325.   cannotusemsg: string;
  1326.  
  1327. begin
  1328.   ngroups := internalcmdlineparams;
  1329.  
  1330.   if ngroups<>'' then
  1331.     if not isavalidgroup(ngroups) then
  1332.       if joinedtogroup(ngroups) then
  1333.         ;
  1334.  
  1335.   if ngroups='' then
  1336.     begin
  1337.       if currsourcekind=sourcegroup then
  1338.         ngroups := currsource
  1339.       else
  1340.         ngroups := 'misc.misc';
  1341.     end;
  1342.  
  1343.   if not trusted then
  1344.     warn('you do not have access to post files this way')
  1345.   else if not maypost then
  1346.     warn('you do not have access to post this way')
  1347.   else
  1348.     begin
  1349.       if ismoderated(ngroups) then
  1350.         warn(ngroups+' group is moderated');
  1351.  
  1352.       postforgetit := 'p';
  1353.       if ismailgroup(ngroups) then
  1354.         begin
  1355.           ngroups := 'misc.misc';
  1356.           postforgetit :=
  1357.            onekeydef('this is a mail group - {p}ost {f}orget it','pf','f');
  1358.         end;
  1359.  
  1360.       if postforgetit='p' then
  1361.         begin
  1362.           xclreolxy(1,lpp-6);
  1363.           xclreolxy(1,lpp-5);
  1364.           xwritehighlights(
  1365.            'do {NOT} post large files to discussion groups!  almost');
  1366.           xclreolxy(1,lpp-4);
  1367.           xwrites('any group with ".binaries." in the name should be ok;');
  1368.           xclreolxy(1,lpp-3);
  1369.           xwritehighlights(
  1370.            'any other is almost definitely not -- {PLEASE BE CAREFUL}');
  1371.           xclreolxy(1,lpp-2);
  1372.           xclreolxy(1,lpp-1);
  1373.           warn('this is the last warning you will receive');
  1374.  
  1375.           xclreolxy(1,lpp-3);
  1376.           xclreolxy(1,lpp-2);
  1377.           xwrites(sourcedesc(ngroups,sourcegroup));
  1378.           xclreolxy(1,lpp-1);
  1379.  
  1380.           includedfile := '';
  1381.  
  1382.           cannotusemsg := '(no file entered yet!)';
  1383.           while cannotusemsg<>'' do
  1384.             begin
  1385.               getexistingfilename(
  1386.                includedfile,'(blank to exit) File:',includedfile);
  1387.  
  1388.               includedfile := unslash(includedfile);
  1389.  
  1390.               cannotusemsg := '';
  1391.  
  1392.               if includedfile<>'' then
  1393.                 if illegalfn(includedfile) then
  1394.                   cannotusemsg := 'illegal filename';
  1395.  
  1396.               if (includedfile<>'') and not trusted and (cannotusemsg='') then
  1397.                 if suspiciousfn(includedfile) then
  1398.                   cannotusemsg := 'without -t/--trusted';
  1399.  
  1400.               if (includedfile<>'') and (cannotusemsg='') then
  1401.                 if isdev(includedfile) then
  1402.                   cannotusemsg := 'reserved device name';
  1403.  
  1404.               if (includedfile<>'') and (cannotusemsg='') then
  1405.                 if not fexists(includedfile) then
  1406.                   cannotusemsg := 'file does not exist';
  1407.  
  1408.               if (includedfile<>'') and (cannotusemsg<>'') then
  1409.                 warn('unable to use: '+cannotusemsg);
  1410.             end;
  1411.  
  1412.           if (includedfile<>'') and (cannotusemsg='') then
  1413.             begin
  1414.               nsubject := 'included file: '+includedfile;
  1415.  
  1416.               if not trusted then
  1417.                 includedfile := withbackslash(home)+includedfile;
  1418.  
  1419.               xclreolxy(1,lpp);
  1420.               xwrites('Subject: ');
  1421.               xreadlns(nsubject,max(cols-10,70),yespreserve);
  1422.  
  1423.               xclreolxy(1,lpp);
  1424.               xwrites('Newsgroups: ');
  1425.               xreadlns(ngroups,max(cols-15,70),yespreserve);
  1426.  
  1427.               if ngroups='' then
  1428.                 ngroups := 'misc.misc';
  1429.  
  1430.               if not isavalidgroup(ngroups) then
  1431.                 if joinedtogroup(ngroups) then
  1432.                   ;
  1433.  
  1434.               createpost(ngroups,'','',nsubject,'','','',includedfile);
  1435.               editandinjnews(ngroups,'','');
  1436.             end;
  1437.         end;
  1438.     end;
  1439.  
  1440. { caller must refresh }
  1441.  
  1442. end;
  1443.  
  1444. procedure editanddeliver;
  1445.  
  1446. { expects artf to be closed;  will open and close if author<>'' }
  1447.  
  1448. var
  1449.   groupormail: string;
  1450.   mailfn: string;
  1451.   mailf: text;
  1452.   mailcheckedfn: string;
  1453.   mailcheckedf: text;
  1454.   emptylinefound: boolean;
  1455.   fromfound: boolean;
  1456.   sigfn: string;
  1457.   sigf: text;
  1458.   oneline: string;
  1459.   sendeditvspellquit: char;
  1460.   outmailfn: string;
  1461.   outmailf: text;
  1462.   basesite: string;
  1463.  
  1464.   cansend: boolean;
  1465.   sendprompt: string;
  1466.   sendchar: char;
  1467.   invalidmessage: string;
  1468.  
  1469. begin
  1470.   if ismailgroup(currsource) then
  1471.     groupormail := 'mail'
  1472.   else if currsourcekind=sourcegroup then
  1473.     groupormail := currsource
  1474.   else
  1475.     groupormail := 'somewhere mysterious';
  1476.  
  1477.   mailfn := withbackslash(temporarydir)+userid+'.mai';
  1478.   saferewrite(mailf,mailfn);
  1479.  
  1480.   if not nomailfrom then
  1481.     writeln(mailf,'From ',fromuserid,'  ',copy(cdow,1,3),', ',
  1482.      dayofmonth,' ',copy(monthname,1,3),' ',year,' ',currenttimestring,' ',
  1483.      timezone,' ','remote from ',uucpname);
  1484.  
  1485.   if not isheaderinlist('Received:',nomailheaders) then
  1486.     begin
  1487.       writeln(mailf,'Received: by ',fqdn,' ('+newsreadername+')');
  1488.       writeln(mailf,'       via ',newsreadername,'; ',copy(cdow,1,3),', ',
  1489.        dayofmonth,' ',copy(monthname,1,3),' ',year,' ',
  1490.        currenttimestring,' ',timezone);
  1491.     end;
  1492.  
  1493. { don't bother with this line anymore -- makes future expansion easier }
  1494.  
  1495. {
  1496.   writeln(mailf,'       for ',replyaddr);
  1497. }
  1498.  
  1499.   write(mailf,'To: ',replyaddr);
  1500.   if replyname='' then
  1501.     writeln(mailf)
  1502.   else if (pos(',',replyname)<>0)
  1503.    or (pos('(',replyname)<>0)
  1504.    or (pos(')',replyname)<>0)
  1505.    or (pos('<',replyname)<>0)
  1506.    or (pos('>',replyname)<>0) then
  1507.     writeln(mailf,' ("',replyname,'")')
  1508.   else
  1509.     writeln(mailf,' (',replyname,')');
  1510.  
  1511.   if ccaddr<>'' then
  1512.     writeln(mailf,'CC: ',ccaddr);
  1513.  
  1514.   if originalfrom<>'' then
  1515.     writeln(mailf,'X-Original-Article-From: ',originalfrom);
  1516.  
  1517.   writeln(mailf,'Subject: ',subject);
  1518.   writeln(mailf,'From: ',mailfrom);
  1519.  
  1520.   if replyto<>'' then
  1521.     writeln(mailf,'Reply-To: ',replyto);
  1522.  
  1523.   if not isheaderinlist('Message-ID:',nomailheaders) then
  1524.     writeln(mailf,'Message-ID: ',newmessageid);
  1525.  
  1526.   writeln(mailf,'Date: ',copy(cdow,1,3),', ',dayofmonth,' ',
  1527.    copy(monthname,1,3),' ',year,' ',currenttimestring,' ',timezone);
  1528.  
  1529. {$ifdef charset}
  1530.   if uselocalcharset then
  1531.     begin
  1532.       writeln(mailf,'MIME-Version: 1.0');
  1533.       writeln(mailf,'Content-Type: text/plain; charset=',postingsetname);
  1534.       writeln(mailf,'Content-Transfer-Encoding: 8bit');
  1535.     end;
  1536. {$endif}
  1537.  
  1538.   if inreplyto<>'' then
  1539.     writeln(mailf,'In-Reply-To: ',inreplyto);
  1540.  
  1541.   if organ<>'' then
  1542.     writeln(mailf,'Organization: ',organ);
  1543.  
  1544.   if not isheaderinlist('X-Newsreader:',nomailheaders) then
  1545.     writeln(mailf,'X-Newsreader: ',newsreadername,' ',newsreaderversion);
  1546.  
  1547.   writeln(mailf);
  1548.  
  1549.   if includedfile<>'' then
  1550.     begin
  1551.       writeln(mailf,'encoded file ',includedfile,' follows:');
  1552.       writeln(mailf);
  1553.       close(mailf);
  1554.       appendencodedfile(mailfn,includedfile);
  1555.       assign(mailf,mailfn);
  1556.       append(mailf);
  1557.       writeln(mailf);
  1558.     end
  1559.   else if justremail then
  1560.     begin
  1561.       writeln(mailf,'[re-mailed to you from ',groupormail,']');
  1562.       if getfromaddr(author)<>getfromaddr(mailfrom) then
  1563.         if getfromaddr(author)<>getfromaddr(newsfrom) then
  1564.           writeln(mailf,'[the original seemed to come from ',author,']');
  1565.       writeln(mailf);
  1566.  
  1567.       emptylinefound := false;
  1568.  
  1569.       artreset;
  1570.       while not arteof and not emptylinefound do
  1571.         begin
  1572.           getartl(oneline,255,notoscreen);
  1573.           if oneline='' then
  1574.             emptylinefound := true;
  1575.         end;
  1576.  
  1577.       while not arteof do
  1578.         begin
  1579.  
  1580. {don't use just cols here, to be polite}
  1581.  
  1582.           getartl(oneline,min(cols,80)-3,notoscreen);
  1583.  
  1584. {$ifdef charset}
  1585.           if (uselocalcharset) then
  1586.             linetolocal(oneline);
  1587. {$endif}
  1588.  
  1589.           writeln(mailf,expand(oneline));
  1590.         end;
  1591.       artclose;
  1592.     end
  1593.   else if author='' then
  1594.     writeln(mailf,mailmarkerline)
  1595.   else
  1596.     begin
  1597.       if defaultreply and (ccaddr='') then
  1598.         writeln(mailf,'In ',groupormail,' you write:')
  1599.       else
  1600.         if length(groupormail)+length(author)<60 then
  1601.           writeln(mailf,'In ',groupormail,', ',author,' writes:')
  1602.         else
  1603.           writeln(mailf,'In ',groupormail,', ',
  1604.            copy(author,1,max(60-length(groupormail),20)),'... writes:');
  1605.       writeln(mailf);
  1606.  
  1607.       emptylinefound := false;
  1608.  
  1609.       artreset;
  1610.       while not arteof and not emptylinefound do
  1611.         begin
  1612.           getartl(oneline,255,notoscreen);
  1613.           if oneline='' then
  1614.             emptylinefound := true;
  1615.         end;
  1616.  
  1617.       while not arteof do
  1618.         begin
  1619.  
  1620. {don't use just cols here, to be polite}
  1621.  
  1622.           getartl(oneline,min(cols,80)-3,notoscreen);
  1623.  
  1624. {$ifdef charset}
  1625.           if (uselocalcharset) then
  1626.             linetolocal(oneline);
  1627. {$endif}
  1628.  
  1629.           if oneline='' then
  1630.             writeln(mailf,'>')
  1631.           else if (copy(oneline,1,1)='>') and not quotewithspace then
  1632.             writeln(mailf,'>',expand(oneline))
  1633.           else
  1634.             writeln(mailf,'> ',expand(oneline));
  1635.  
  1636.         end;
  1637.       artclose;
  1638.     end;
  1639.  
  1640.   sigfn := unslash(getconfig('signature'));
  1641.   if sigfn='' then
  1642.     sigfn := 'mailsig';
  1643.   if numoccur('\',sigfn)=0 then
  1644.     sigfn := withbackslash(home)+sigfn;
  1645.  
  1646.   safereset(sigf,sigfn);
  1647.   if fileresult<>0 then
  1648.     begin
  1649.       sigfn := withbackslash(home)+'sig';
  1650.       safereset(sigf,sigfn);
  1651.     end;
  1652.  
  1653.   if fileresult=0 then
  1654.     begin
  1655.       readln(sigf,oneline);
  1656.       if oneline<>'-- ' then
  1657.         writeln(mailf,'-- ');
  1658.       reset(sigf);
  1659.       while not eof(sigf) do
  1660.         begin
  1661.           readln(sigf,oneline);
  1662.           writeln(mailf,expand(oneline));
  1663.         end;
  1664.       close(sigf);
  1665.     end;
  1666.  
  1667.   close(mailf);
  1668.  
  1669. {edit the first time around}
  1670.   sendeditvspellquit := 'e';
  1671.  
  1672.   while (sendeditvspellquit<>'s') and (sendeditvspellquit<>'q') do
  1673.     begin
  1674.       if not trusted then
  1675.         if sendeditvspellquit='E' then
  1676.           sendeditvspellquit := 'e';
  1677.  
  1678.       if sendeditvspellquit='v' then
  1679.         begin
  1680.           mouseshutdown;
  1681.           execp(vspeller,vspelleroptions+' '+mailfn);
  1682.           mouseinit;
  1683.  
  1684.           if execresult<>0 then
  1685.             warnerr(vspeller,execresult);
  1686.  
  1687.           if editaftervspell then
  1688.             sendeditvspellquit := 'e';
  1689.         end;
  1690.  
  1691.       if sendeditvspellquit='e' then
  1692.         begin
  1693.           mouseshutdown;
  1694.           execp(editor,editoroptions+' '+mailfn);
  1695.           mouseinit;
  1696.  
  1697.           if execresult<>0 then
  1698.             warnerr(editor,execresult);
  1699.         end;
  1700.  
  1701.       if sendeditvspellquit='E' then
  1702.         begin
  1703.           mouseshutdown;
  1704.           execp(editor,editoroptions+' '+mailfn+' '+artfn);
  1705.           mouseinit;
  1706.  
  1707.           if execresult<>0 then
  1708.             warnerr(editor,execresult);
  1709.         end;
  1710.  
  1711.       headerinmem := '';  {invalidate cache from last getheaderline}
  1712.  
  1713.       cansend := true;
  1714.  
  1715.       xclreolxy(1,lpp);
  1716.       xwrites('checking headers...');
  1717.  
  1718.       if cansend then
  1719.         if getheaderline(mailfn,'from:')=couldnotreadfilecookie then
  1720.           begin
  1721.             warn('not sent -- could not read '+mailfn+'!');
  1722.             cansend := false;
  1723.           end;
  1724.  
  1725.       if cansend then
  1726.         if trim(getheaderline(mailfn,'from:'))='' then
  1727.           begin
  1728.             warn('no From: header -- cannot send');
  1729.             cansend := false;
  1730.           end;
  1731.  
  1732.       if cansend then
  1733.         if not trusted then
  1734.           if getfromaddr(getheaderline(mailfn,'from:'))<>
  1735.            getfromaddr(mailfrom) then
  1736.             begin
  1737.               warn('changed From: header -- cannot send');
  1738.               cansend := false;
  1739.             end;
  1740.  
  1741.       if cansend then
  1742.         if trim(getheaderline(mailfn,'subject:'))='' then
  1743.           begin
  1744.             warn('no Subject: header -- cannot send');
  1745.             cansend := false;
  1746.           end;
  1747.  
  1748.       if cansend then
  1749.         if lower(trim(getheaderline(mailfn,'subject:')))='re:' then
  1750.           begin
  1751.             warn('no Subject: header -- cannot send');
  1752.             cansend := false;
  1753.           end;
  1754.  
  1755.       if cansend then
  1756.         if trim(getheaderline(mailfn,'to:'))='' then
  1757.           if trim(getheaderline(mailfn,'cc:'))='' then
  1758.             begin
  1759.               warn('no To: header and no CC: header -- cannot send');
  1760.               cansend := false;
  1761.             end;
  1762.  
  1763.       if cansend then
  1764.         begin
  1765.           invalidmessage := findproblemwithmessage(mailfn);
  1766.           if invalidmessage<>'' then
  1767.             begin
  1768.               warn2(invalidmessage,'cannot send');
  1769.               cansend := false;
  1770.             end;
  1771.         end;
  1772.  
  1773.       if cansend then
  1774.         if toomuchquoting(mailfn) then
  1775.           begin
  1776.             warn('lots of quoting, not much new material -- please edit');
  1777.             if not trusted then
  1778.               cansend := false;
  1779.           end;
  1780.  
  1781. {looks silly for mail, but prevents problems at stupid mail<->news gateways}
  1782.       if cansend then
  1783.         if not trusted then
  1784.           if trim(getheaderline(mailfn,'approved:'))<>'' then
  1785.             begin
  1786.               warn('without --trusted, cannot send approved articles');
  1787.               cansend := false;
  1788.             end;
  1789.  
  1790.       if cansend then
  1791.         if toolongline(mailfn,255) then
  1792.           begin
  1793.  
  1794. {}{}{}{} {should offer to word-wrap in place instead}
  1795.             warn('some line is very long, and will be lost');
  1796.             cansend := false;
  1797.           end;
  1798.  
  1799.       if cansend then
  1800.         if toolongline(mailfn,80) then
  1801.           begin
  1802.             warn2('some lines are >80 chars, which people with really old',
  1803.             'or poorly-planned software will have problems seeing');
  1804.           end;
  1805.  
  1806.  
  1807.       xclreolxy(1,lpp-1);
  1808.  
  1809.       if cansend then
  1810.         begin
  1811.           sendprompt := '{s}end ';  {note trailing space}
  1812.           sendchar := 's';
  1813.         end
  1814.       else
  1815.         begin
  1816.           sendprompt := '';
  1817.           sendchar := 'q';  {can always quit}
  1818.         end;
  1819.  
  1820.       sendeditvspellquit :=
  1821.        onekey('Private: '+sendprompt+'{e}dit {E}dit-both {v}spell {q}uit',
  1822.        sendchar+'eEvq');
  1823.  
  1824.       if sendeditvspellquit='s' then
  1825.         xwrites('sending...')
  1826.       else if sendeditvspellquit='e' then
  1827.         xwrites('editing...')
  1828.       else if sendeditvspellquit='E' then
  1829.         xwrites('editing both...')
  1830.       else if sendeditvspellquit='v' then
  1831.         xwrites('vspelling...')
  1832.       else if sendeditvspellquit='q' then
  1833.         xwrites('quit');
  1834.  
  1835.     end;
  1836.  
  1837.   if sendeditvspellquit='s' then
  1838.     begin
  1839.  
  1840.       mailcheckedfn := withbackslash(temporarydir)+userid+'.chk';
  1841.  
  1842.       { here copy mailf to mailcheckedf }
  1843.  
  1844.       saferewrite(mailcheckedf,mailcheckedfn);
  1845.  
  1846.       safereset(mailf,mailfn);
  1847.  
  1848. {check for changed From: lines on non-trusted users and replace}
  1849.  
  1850. {must make sure a From: line is actually found!}
  1851.  
  1852.       emptylinefound := false;
  1853.       fromfound := false;
  1854.  
  1855.       while not eof(mailf) do
  1856.         begin
  1857.           read(mailf,oneline);
  1858.           if eoln(mailf) then
  1859.             readln(mailf);
  1860.  
  1861.           if not trusted then
  1862.             begin
  1863.               if oneline='' then
  1864.                 begin
  1865.                   emptylinefound := true;
  1866.                   if not fromfound then
  1867.                     begin
  1868.                       writeln(mailcheckedf,'From: ',mailfrom);
  1869.                       fromfound := true;
  1870.                     end;
  1871.                 end
  1872.               else if not emptylinefound then
  1873.                 begin
  1874.                   if getfirstw(oneline)='From:' then
  1875.                     fromfound := true;
  1876.                   if makesame(oneline,'From: ',mailfrom) then
  1877.                     begin
  1878.                       warn3
  1879.                        (
  1880.                        'From: line was changed back to '+mailfrom,
  1881.                        '(the default).  the -t flag is required to change the',
  1882.                        'From: line.  adding a Reply-To: is probably better.'
  1883.                        );
  1884. {
  1885.                       xclreolxy(1,1);
  1886.                       xclreolxy(1,2);
  1887.                       xclreolxy(1,3);
  1888.                       xclreolxy(1,4);
  1889.                       xclreolxy(1,5);
  1890.                       xclreolxy(1,6);
  1891.                       xclreolxy(1,7);
  1892.                       writexy(1,1,'From: line was changed from');
  1893.                       writexy(1,2,oneline+' to');
  1894.                       writexy(1,3,mailfrom);
  1895.                       writexy(1,4,'and has been changed back.  if you need');
  1896.                       writexy(1,5,'to change From:, run as a trusted user.');
  1897.                       writexy(1,6,'adding a Reply-To: is probably better');
  1898. }
  1899.                     end;
  1900.                 end;
  1901.             end;
  1902.           writeln(mailcheckedf,oneline);
  1903.         end;
  1904.  
  1905.       close(mailf);
  1906.       close(mailcheckedf);
  1907.  
  1908.       delivermail(mailcheckedfn);
  1909.  
  1910.     end;
  1911.  
  1912. {leave refresh and re-opening of artf to caller}
  1913.  
  1914. end;
  1915.  
  1916. procedure mail;
  1917.  
  1918. var
  1919.   toaddr: string;
  1920.   ccaddr: string;
  1921.   nsubject: string;
  1922.   afullname: string;
  1923.  
  1924. begin
  1925.   if not maymail then
  1926.     warn('you may not mail -- check your configuration')
  1927.   else
  1928.     begin
  1929.       toaddr := internalcmdlineparams;
  1930.  
  1931.       xclreolxy(1,lpp);
  1932.       xwrites('To: ');
  1933.       xreadlns(toaddr,max(cols-5,75),yespreserve);
  1934.       toaddr := expandmail(toaddr);
  1935.  
  1936.       if toaddr<>'' then
  1937.         begin
  1938.           if not quiet then
  1939.             begin
  1940.               xclreolxy(1,lpp-1);
  1941.               xclreolxy(1,lpp-2);
  1942.               if (pos('!',toaddr)=0) and
  1943.                (pos('@',toaddr)=0) and
  1944.                (pos(',',toaddr)=0) then
  1945.                 begin
  1946.                   afullname := getfullnameforuser(lower(toaddr));
  1947.                   if afullname='' then
  1948.                     afullname := ' (local, unknown name)'
  1949.                   else
  1950.                     afullname := ', '+afullname;
  1951.                   xwritesss('To: ',toaddr,afullname)
  1952.                 end
  1953.               else
  1954.                 xwritess('To: ',toaddr);
  1955.             end;
  1956.  
  1957.           xclreolxy(1,lpp);
  1958.           xwrites('CC: ');
  1959.           xreadlns(ccaddr,max(cols-5,75),nopreserve);
  1960.           ccaddr := expandmail(ccaddr);
  1961.  
  1962.           if (ccaddr<>'') and not quiet then
  1963.             begin
  1964.               xclreolxy(1,lpp-1);
  1965.               xclreolxy(1,lpp-2);
  1966.               if (pos('!',ccaddr)=0) and
  1967.                (pos('@',ccaddr)=0) and
  1968.                (pos(',',ccaddr)=0) then
  1969.                 begin
  1970.                   afullname := getfullnameforuser(lower(ccaddr));
  1971.                   if afullname='' then
  1972.                     afullname := ' (local, unknown name)'
  1973.                   else
  1974.                     afullname := ', '+afullname;
  1975.                   xwritesss('CC: ',ccaddr,afullname)
  1976.                 end
  1977.               else
  1978.                 xwritess('CC: ',ccaddr);
  1979.             end;
  1980.  
  1981.           xclreolxy(1,lpp);
  1982.           xwrites('Subject: ');
  1983.           xreadlns(nsubject,max(cols-10,70),nopreserve);
  1984.  
  1985.           editanddeliver(
  1986.           {subject        }  nsubject,
  1987.           {inreplyto      }  '',
  1988.           {replyaddr      }  toaddr,
  1989.           {replyname      }  '',
  1990.           {ccaddr         }  ccaddr,
  1991.           {originalfrom   }  '',
  1992.           {author         }  '',
  1993.           {defaultreply   }  false,
  1994.           {includedfile   }  '',
  1995.           {justremail     }  false
  1996.                         );
  1997.         end;
  1998.     end;
  1999.  
  2000. { caller must refresh }
  2001.  
  2002. end;
  2003.  
  2004. procedure mailfile;
  2005.  
  2006. var
  2007.   toaddr: string;
  2008.   ccaddr: string;
  2009.   nsubject: string;
  2010.   includedfile: string;
  2011.   cannotusemsg: string;
  2012.   afullname: string;
  2013.  
  2014. begin
  2015.   if not trusted then
  2016.     warn('you may not mail files this way')
  2017.   else if not maymail then
  2018.     warn('you may not mail -- check your configuration')
  2019.   else
  2020.     begin
  2021.       toaddr := internalcmdlineparams;
  2022.  
  2023.       xclreolxy(1,lpp-6);
  2024.       xclreolxy(1,lpp-5);
  2025.       xwritehighlights(
  2026.        'do {NOT} mail large files unless you are sure all recipients');
  2027.       xclreolxy(1,lpp-4);
  2028.       xwrites('can handle them, and it will not cause any network problems');
  2029.       xclreolxy(1,lpp-3);
  2030.       xwritehighlights(
  2031.         'between you and any of the recipients -- {PLEASE BE CAREFUL}');
  2032.       xclreolxy(1,lpp-2);
  2033.       xclreolxy(1,lpp-1);
  2034.       warn('this is the last warning you will receive');
  2035.  
  2036.       xclreolxy(1,lpp);
  2037.       xwrites('To: ');
  2038.       xreadlns(toaddr,max(cols-5,75),yespreserve);
  2039.       toaddr := expandmail(toaddr);
  2040.  
  2041.       if toaddr<>'' then
  2042.         begin
  2043.           if not quiet then
  2044.             begin
  2045.               xclreolxy(1,lpp-1);
  2046.               xclreolxy(1,lpp-2);
  2047.               if (pos('!',toaddr)=0) and
  2048.                (pos('@',toaddr)=0) and
  2049.                (pos(',',toaddr)=0) then
  2050.                 begin
  2051.                   afullname := getfullnameforuser(lower(toaddr));
  2052.                   if afullname='' then
  2053.                     afullname := ' (local, unknown name)'
  2054.                   else
  2055.                     afullname := ', '+afullname;
  2056.                   xwritesss('To: ',toaddr,afullname)
  2057.                 end
  2058.               else
  2059.                 xwritess('To: ',toaddr);
  2060.             end;
  2061.  
  2062.           xclreolxy(1,lpp);
  2063.           xwrites('CC: ');
  2064.           xreadlns(ccaddr,max(cols-5,75),nopreserve);
  2065.           ccaddr := expandmail(ccaddr);
  2066.  
  2067.           if (ccaddr<>'') and not quiet then
  2068.             begin
  2069.               xclreolxy(1,lpp-1);
  2070.               xclreolxy(1,lpp-2);
  2071.               if (pos('!',ccaddr)=0) and
  2072.                (pos('@',ccaddr)=0) and
  2073.                (pos(',',ccaddr)=0) then
  2074.                 begin
  2075.                   afullname := getfullnameforuser(lower(ccaddr));
  2076.                   if afullname='' then
  2077.                     afullname := ' (local, unknown name)'
  2078.                   else
  2079.                     afullname := ', '+afullname;
  2080.                   xwritesss('CC: ',ccaddr,afullname)
  2081.                 end
  2082.               else
  2083.                 xwritess('CC: ',ccaddr);
  2084.             end;
  2085.  
  2086.           xclreolxy(1,lpp);
  2087.  
  2088.           includedfile := '';
  2089.  
  2090.           cannotusemsg := '(no file entered yet!)';
  2091.           while cannotusemsg<>'' do
  2092.             begin
  2093.               getexistingfilename(
  2094.                includedfile,'(blank to exit) File:',includedfile);
  2095.  
  2096.               includedfile := unslash(includedfile);
  2097.  
  2098.               cannotusemsg := '';
  2099.  
  2100.               if includedfile<>'' then
  2101.                 if illegalfn(includedfile) then
  2102.                   cannotusemsg := 'illegal filename';
  2103.  
  2104.               if (includedfile<>'') and not trusted and (cannotusemsg='') then
  2105.                 if suspiciousfn(includedfile) then
  2106.                   cannotusemsg := 'without -t/--trusted';
  2107.  
  2108.               if (includedfile<>'') and (cannotusemsg='') then
  2109.                 if isdev(includedfile) then
  2110.                   cannotusemsg := 'reserved device name';
  2111.  
  2112.               if (includedfile<>'') and (cannotusemsg='') then
  2113.                 if not fexists(includedfile) then
  2114.                   cannotusemsg := 'file does not exist';
  2115.  
  2116.               if (includedfile<>'') and (cannotusemsg<>'') then
  2117.                 warn('unable to use: '+cannotusemsg);
  2118.             end;
  2119.  
  2120.           if (includedfile<>'') and (cannotusemsg='') then
  2121.             begin
  2122.               nsubject := 'included file: '+includedfile;
  2123.  
  2124.               if not trusted then
  2125.                 includedfile := withbackslash(home)+includedfile;
  2126.  
  2127.               xclreolxy(1,lpp);
  2128.               xwrites('Subject: ');
  2129.               xreadlns(nsubject,max(cols-10,70),yespreserve);
  2130.  
  2131.               editanddeliver(
  2132.               {subject        }  nsubject,
  2133.               {inreplyto      }  '',
  2134.               {replyaddr      }  toaddr,
  2135.               {replyname      }  '',
  2136.               {ccaddr         }  ccaddr,
  2137.               {originalfrom   }  '',
  2138.               {author         }  '',
  2139.               {defaultreply   }  false,
  2140.               {includedfile   }  includedfile,
  2141.               {justremail     }  false
  2142.                             );
  2143.  
  2144.             end;
  2145.         end;
  2146.     end;
  2147.  
  2148. { caller must refresh }
  2149.  
  2150. end;
  2151.  
  2152. end.
  2153.