home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: ParseGrabs.br 1.1 (3.9.95) ** ** ParseGrabs.br will check for any grabs in the download directory and ** parse them. If there are active events which have not been deleted it ** will list these events and then ask the user whether to delete them or ** not. ** ** Requires C:List, C:Delete, C:Ask and C:Resident to be present. ** ** Set makeresident to 1 below for some extra speed. ** ** ** Todo: Close window after parsing if fromthor = 1. HOW?!? ** ** 1.1 (28.8.95) ** ~~~~~~~~~~~~~ ** New: GUI interface if run from Thor ** ** Fixed: Event packing didn't always work as it should ** C:List was never made resident ** Misc. stuff ** */ options results signal on break_c signal on error signal on halt pubscreen = "Workbench" /* Public screen to open progressbars on if run from Shell */ makeresident = 1 /* Make list resident before starting. 0 = FALSE, 1 = TRUE */ remresident = 1 /* Remove list from resident list after finishing. 0 = FALSE, 1 = TRUE */ tiopen = 0; glopen = 0 EDB_DELETED = 0 /* Event is deleted */ EDB_DONE = 2 /* Event is done */ EDB_ERROR = 3 /* Error performing this event */ EDB_FREEZE = 5 /* Event is frozen. Will not be done as long as this flag is set. */ /* See if I'm run from Thor */ if left(address(), 5) = 'THOR.' then do thorport = address() address(thorport) GETGLOBALCONFIG STEM globcfg if rc ~= 0 then call displayerror(0) pubscreen = globcfg.PUBSCREENNAME LOCKGUI fromthor = 1 end else fromthor = 0 /* Open BBSREAD ARexx port */ if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end /* Find Thor's path */ call open(pn, 'ENV:Thor/THORPATH', 'R') thorpath = readln(pn) call close(pn) /* Fetch some needed info from bbsread */ address(bbsread) GETGLOBALDATA globdata if rc ~= 0 then call displayerror(1) GETBBSLIST bbslist if rc ~= 0 then call displayerror(1) if makeresident = 1 then do address(command) 'Resident C:List PURE' end if bbslist.COUNT > 0 then do i = 1 to bbslist.COUNT address(bbsread) GETBBSDATA '"'bbslist.i'"' bbsdata if rc ~= 0 then call displayerror(1) if bbsdata.DNLOADPATH ~= '' then dlpath = bbsdata.DNLOADPATH else dlpath = globdata.DNLOADPATH address(command) 'List >T:GrabList 'dlpath || bbsdata.GRABNAME'#? LFORMAT "%s"' if exists("T:GrabList") then do glopen = open(gl, "T:GrabList", 'R') do until eof(gl) entry = readln(gl) if entry ~= '' then do if fromthor = 0 then say '1B'x'[1mParsing 'bbsdata.BBSTYPE' grab from 'bbsdata.NAME': "'dlpath || entry'"' || '1B'x'[0m' if bbsdata.NUMEVENTS > 0 then do if fromthor = 0 then do say 'There are active events on "'bbsdata.NAME'":' thorpath'bin/ListEvents "'bbsdata.NAME'" FULL' signal off error 'Ask "*NDelete these events? [y/N]"' signal on error if rc = 5 then delevents = 1 end else do address(thorport) REQUESTNOTIFY '"There are 'bbsdata.NUMEVENTS' active events on\n'bbsdata.NAME'. Delete them?"' '"Yes|No"' if result = 1 then delevents = 1 end if delevents = 1 then do address(bbsread) do e = bbsdata.FIRSTEVENT to bbsdata.LASTEVENT drop eventdata. READBREVENT '"'bbsdata.NAME'"' EVENTNR e DATASTEM eventdata if rc ~= 0 then call displayerror(0) if ~bittst(eventdata.FLAGS, EDB_DELETED) & ~bittst(eventdata.FLAGS, EDB_ERROR) & ~bittst(eventdata.FLAGS, EDB_DONE) & ~bittst(eventdata.FLAGS, EDB_FREEZE) then do UPDATEBREVENT BBSNAME '"'bbsdata.NAME'"' EVENTNR e SETDONE if rc ~= 0 then call displayerror(0) end end PACKDATAFILE BBSNAME '"'bbsdata.NAME'"' EVENTDATA SHOWPROGRESS if rc ~= 0 then call displayerror(0) GETBBSDATA '"'bbslist.i'"' bbsdata if rc ~= 0 then call displayerror(0) address(command) if bbsdata.UPLOADPATH ~= '' then ulpath = bbsdata.UPLOADPATH else ulpath = globdata.UPLOADPATH If exists(ulpath||bbsdata.REPLYPACKET) then do 'Delete "'ulpath||bbsdata.REPLYPACKET'" QUIET FORCE' end end end address(command) thorpath'bin/CfgType >T:TypeInfo 'bbsdata.BBSTYPE tiopen = open(ti, "T:TypeInfo", 'R') tmp = readln(ti); tmp = readln(ti); tmp = readln(ti); tmp = readln(ti) parser = subword(tmp, 4); parser = left(parser, index(parser, ',') - 1) call close(ti) thorpath || parser' "'bbsdata.NAME'" "'dlpath || entry'" ARCHIVE DELETE PUBSCREEN "'pubscreen'"' end end call close(gl) end end break_c: error: halt: if fromthor = 1 then do address(thorport) UNLOCKGUI RESCAN end address(command) if glopen then call close(gl) if exists("T:GrabList") then 'Delete "T:GrabList" QUIET' if tiopen then call close(ti) if exists("T:TypeInfo") then 'Delete "T:TypeInfo" QUIET' if remresident = 1 then 'Resident LIST REMOVE' exit(0) displayerror: procedure expose thorport BBSREAD.LASTERROR fromthor parse arg finito if fromthor = 0 then say BBSREAD.LASTERROR else do address(thorport) REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"I see"' address(bbsread) end if finito = 1 then signal break_c return