/**/q_outs=1 v="$VER: XFLO Rexx XFERQ Mail Handler Williamson 55.13" options results;options failat 99 Parse upper arg OUTDIR hostaddress ADDRESS_LIST if words(ADDRESS_LIST)>1 then hold_address=word(ADDRESS_LIST,1);else hold_address=ADDRESS_LIST XFQ_SITE_OBJECT=XfqGetAddress(hold_address) if XfqSessionUp(XFQ_SITE_OBJECT) then do if ~XfqHoldMailer(XFQ_SITE_OBJECT) then do Say 'HOLD Failed:'XFQERRORMSG hold_address drop XFQERRORCODE XFQERRORMSG;call XfqDropObject(XFQ_SITE_OBJECT);call XfqClose();exit end end;else do Say 'Site 'hold_address' not online, exiting' drop XFQERRORCODE XFQERRORMSG;call XfqDropObject(XFQ_SITE_OBJECT);call XfqClose();exit end ADDRESS_LIST=strip(ADDRESS_LIST) XQ_NOTHING=20;XQ_DELETE=21;XQ_TRUNCATE=22;xpri.H=0;xpri.C=50;xpri.D=30;xpri.N=0;xpri.F=0;xpri.O=0 log=show('p','ROOFLOG');call putlog(ADDRESS_LIST) id=pragma('ID') do ai=1 to words(ADDRESS_LIST) REMOTE_ADDRESS=word(ADDRESS_LIST,ai) parse var REMOTE_ADDRESS rad "#" raz ":" ran "/" raf "." rap call sendflos;call sendouts end cleanup: call XfqReleaseMailer(XFQ_SITE_OBJECT);call XfqDropObject(XFQ_SITE_OBJECT) call XfqClose();call delete('T:flo'id);call delete('T:out'id) exit 0 SENDOUTS: Address COMMAND 'LIST >T:out'id OUTDIR||raz'.'ran'.'raf'.'rap'.?UT quick nohead' if word(statef("T:out"id),2)=0 then do;call PutLog('No 4D ?UT files in 'OUTDIR' for 'REMOTE_ADDRESS);return;end if ~open('outs',"T:out"id,'R') then do;call PutLog("Error opening 4D .?UT list");return;end do while ~eof('outs') outfile=upper(readln('outs'));if outfile="" then iterate parse var outfile x '.' x '.' x '.' x '.' ext;drop x if ~q_outs & ext="OUT" then do;call PutLog('Skipping Unarchived echomail:'outfile);Iterate;end xtype=left(ext,1);if pos(xtype,'H C D N O')>0 then priority=xpri.xtype else do;call PutLog('ERROR: cannot queue 'outfile);Iterate;end file=OUTDIR||outfile;sendas=left(date(),2)||compress(time(),":")||".PKT" flags=XQ_DELETE QUERY.XQ_NAME=file;QUERY.XQ_SITE=XFQ_SITE_OBJECT work=NULL;work=XfqFindWork(QUERY) if work=NULL then do;call PutLog('Sending:'file' as 'sendas' for:'REMOTE_ADDRESS' Disp:'flags' Pri:'priority) call XfqAddWorkQuick(REMOTE_ADDRESS,file,sendas,priority,flags) end;else call XfqUnlockWork(work) if work~=NULL then call XfqDropObject(work) end call close('outs') return SENDFLOS: Address COMMAND 'LIST >T:flo'id OUTDIR||raz'.'ran'.'raf'.'rap'.?LO quick nohead' if word(statef("T:flo"id),2)=0 then do;call PutLog('No 4D ?LO files in 'OUTDIR' for 'REMOTE_ADDRESS);return;end if ~open('flolist',"T:flo"id,'R') then do;call PutLog("Error opening 4D .FLO listing");return;end i=0 do while ~eof('flolist') Line=Upper(strip(space(ReadLn('flolist'),1),'B'));if Line="" then iterate i=i+1;flofile.i=Line parse var Line flonode.i.zone"."flonode.i.net"."flonode.i.node"."flonode.i.point"."junk flofileadr.i=RAD'#'flonode.i.zone":"flonode.i.net"/"flonode.i.node"."flonode.i.point ftype=left(junk,1);if pos(ftype,'H C D N F')>0 then flofile.i.pri=xpri.ftype else do;call PutLog('Skipping Unknown FLO file:'flofile.i);i=i-1;iterate;end end call close('flolist') if i=0 then do;call PutLog("Error: No Sendable 4D ?LO Files");return;end flofile.numnodes=i do anode=1 until anode=flofile.numnodes;err=0 call PutLog("Converting" flofile.anode "for" flofileadr.anode) floname=upper(OUTDIR||flofile.anode) if ~exists(floname) then do;call PutLog("Error: Can't find "floname);err=1;end else if ~Open('flofile',floname,'R') then do;call PutLog("Error: Can't open" floname);err=1;end if ~err then do do while ~eof('flofile') Line=upper(ReadLn('flofile'));if Line="" then Iterate flags=XQ_NOTHING disp=left(Line,1);if disp="#" then do;flags=XQ_TRUNCATE;Line=delstr(Line,1,1);end else if disp="^"|disp="-" then do;flags=XQ_DELETE;Line=delstr(Line,1,1);end else if disp="@" then do;flags=XQ_NOTHING;Line=delstr(Line,1,1);end if ~exists(Line) then do;call PutLog("File "Line" No Longer Exists");Iterate;end parse var Line x '.' x '.' x '.' x '.' ext;drop x if ext="" then do if right(Line,3)="TIC" then flags=XQ_DELETE;else flags=XQ_NOTHING sendas=get_fn(Line);priority=flofile.anode.pri end;else do tmpext=upper(left(ext,2)) if datatype(right(ext,1),'n')&(tmpext="MO"|tmpext="TU"|tmpext="WE"|tmpext="TH"|tmpext="FR"|tmpext="SA"|tmpext="SU") then do parse var hostaddress myaddress.domain "#" myaddress.zone ":" myaddress.net "/" myaddress.node "." myaddress.point sendas=UPPER(d2x(65536+myaddress.net-flonode.anode.net,4)||d2x(65536+myaddress.node-flonode.anode.node,4)||'.'ext) flags=XQ_DELETE;priority=flofile.anode.pri end;else do sendas=get_fn(line);flags=XQ_NOTHING;priority=flofile.anode.pri end end;drop ext QUERY.XQ_NAME=Line;QUERY.XQ_SITE=XFQ_SITE_OBJECT work=NULL;work=XfqFindWork(QUERY) if work=NULL then do;call PutLog('Sending:'Line' as 'sendas' for 'REMOTE_ADDRESS' Disp:'flags' Pri:'priority) call XfqAddWorkQuick(REMOTE_ADDRESS,Line,sendas,priority,flags) end;else call XfqUnlockWork(work) end call close('flofile');call delete(floname) end if work~=NULL then call XfqDropObject(work) end return get_fn: procedure if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1) else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1) else return arg(1) PutLog: procedure expose log if log then address 'ROOFLOG' 'LOGLINE' left(time(),5) 'XFLO: 'arg(1);else say arg(1) return 0