home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
WHOIS3.ZIP
/
WHOIS.CMD
Wrap
OS/2 REXX Batch file
|
1991-12-29
|
12KB
|
326 lines
/* WHOIS.CMD - a REXX procedure to interpret those cryptic hexadecimal */
/* filenames in your Binkley-style outbound directory. */
/* */
/* Written by Emmitt Dove, Fernwood BBS, 1:141/209 */
/* Branford, CT USA */
/* (203) 483-0348 HST 14.4 and v.32 */
/* */
/* Last modified 911228 */
/* Additions and enhancements by Marcel Stikkleman 910401 */
/* Additions and enhancements by Jaap Geluk 911227 */
/* */
/* */
/* Requires: OS/2 EE 1.2, SE 1.3 or EE 1.3 (so far); may also work */
/* with Personal REXX from Mansfield, though I haven't */
/* tried that. */
/* */
/* Usage form one: WHOIS filename.ext */
/* */
/* where "filename.ext" is just about any file you may find */
/* in your outbound directory. WHOIS understands mail */
/* packets, archived mail bundles, file-attaches, incomplete */
/* transmission indicators (*.Z), requests, call progress */
/* entries and no-sends. */
/* */
/* No checking is done on filename validity - you're on */
/* your own to be sure you enter a valid name. */
/* */
/* Usage form two: WHOIS net/node */
/* */
/* where net/node is any valid address. WHOIS will return the */
/* two flavors of outbound filenames for the net/node. */
/* Note that WHOIS only understands 2-D addresses in this */
/* mode. EXAMPLE: WHOIS 141/209 */
/* */
/* Usage form three: WHOIS [d:][\path\]outbound[\filespec] */
/* */
/* WHERE "d:" is the drive on which the outbound directory */
/* resides, */
/* "\path\" is the path to the outbound directory, */
/* "outbound" is the outbound directory itself, and */
/* "\filespec" is a valid file specification including */
/* wildcards. */
/* */
/* EXAMPLES: WHOIS d:\max\outbound\*.* will list all files */
/* in the specified directory */
/* WHOIS outbound\*.clo will list all crash */
/* attach lists in a directory named outbound */
/* which exists beneath the current directory */
/* */
/* WHOIS gets your net/node address from one of two places. */
/* First, you can modify lines 66 and 67 to represent your */
/* own net and node number. Second, you can set an OS/2 */
/* environment variable Fido4DAddress to your full 4-D */
/* address. Example: SET Fido4DAddress=1:141/209.0 */
/* */
/* If the environment variable is set, it is used and lines */
/* 66 and 67 are overridden. */
/* */
/* This file may be freely used, distributed and modified. */
/* Be nice and leave my credit in if you modify it and */
/* distribute the modifications. It would also be nice if */
/* you were to share your enhancements with the author. */
trace off
mynet = 141
mynode = 209
NetNode = Value('Fido4DAddress',,'OS2ENVIRONMENT')
if NetNode \= '' then do
if pos('.', NetNode) > 0 then NetNode = left(NetNode, pos('.', NetNode) - 1)
if pos(':', NetNode) > 0 then NetNode = substr(NetNode, pos(':', NetNode) + 1)
mynet = left(NetNode, pos('/', NetNode) - 1)
mynode = substr(NetNode, pos('/', NetNode) + 1)
end
/* Get the parameter and parse it */
arg filename
if filename = '?' | filename = '' then signal HELP
if pos('/', filename) > 0 then signal TOHEX
fullname = stream(filename, 'c', 'query exists')
filename = filespec('name', fullname)
if filename = '' then arg filename
temp = directory()
if directory(fullname) = fullname then fullname = fullname || '\*.*'
call directory temp
drop temp
parse source . . WhoIs
if pos('?',filename) > 0 | pos('*',filename) > 0 then do
if fullname = '' then
arg fullname
'@dir ' fullname ' > null'
if rc <> 0 then do
say filename "not found ..."
return
end
'@for %%i in (' fullname ') do @call' WhoIs '%%i'
return
end
netdiff = substr(filename,1,4)
nodediff = substr(filename,5,4)
ext = substr(filename,10,3)
extflavor = substr(filename,10,1)
exttype = substr(filename,11,2)
/* Decide which routine to execute */
if extflavor = 'Z' then signal BADFLAG
if extflavor = '$' then signal DIALED
if exttype = 'UT' then signal PACKET
if exttype = 'LO' then signal ATTACH
if exttype = 'EQ' then signal REQUEST
if ext = 'NOT' then signal NOSEND
/* If we didn't go somewhere else, we have a compressed mail bundle. */
/* Since the hex values we have are offsets from our own net/node number, */
/* we have to convert to decimal, undo the offset and make certain it is */
/* not a negative result. */
/* First, the network portion. */
if netdiff = 0 then
hisnet = mynet
else do
dnetdiff = x2d(netdiff)
newdiff = mynet-dnetdiff
if newdiff < 0 then
hisnet = 65536+newdiff
else
hisnet = newdiff
end
/* Now, the node portion. */
if nodediff = 0 then
hisnode = mynode
else do
dnodediff = x2d(nodediff)
newdiff = mynode-dnodediff
if newdiff < 0 then
hisnode = 65536+newdiff
else
hisnode = newdiff
end
/* Report the result and leave. */
say
say filename "is a compressed mail file to "hisnet"/"hisnode"."
signal done
PACKET:
/* We are here since the last two characters of the extension are "UT". */
/* This is a simpler case since all we have to do is a hex to decimal */
/* conversion. But, we also want to figure out the flavor (crash, hold, */
/* etc.) and report it. */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
select
when extflavor = 'C' then flavor = crash
when extflavor = 'D' then flavor = direct
when extflavor = 'H' then flavor = hold
when extflavor = 'O' then flavor = normal
otherwise flavor = '???'
end
say
say filename "is a "flavor" mail packet to "hisnet"/"hisnode"."
signal done
ATTACH:
/* We are here since the last two characters of the extension are "LO", */
/* indicating we have a file-attach. Otherwise, it is almost identical */
/* to the packet case. There are minor differences in the flavor cases. */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
select
when extflavor = 'C' then flavor = crash
when extflavor = 'D' then flavor = direct
when extflavor = 'F' then flavor = normal
when extflavor = 'H' then flavor = hold
otherwise flavor = '???'
end
say
say filename "is a "flavor" file-attach list to "hisnet"/"hisnode"."
call stream fullname, 'c', 'open read'
do while lines(fullname)
say linein(fullname)
end
call stream fullname, 'c', 'close'
signal DONE
BADFLAG:
/* This indicates a .Z file. Very easy to handle. */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
say
say filename "indicates an incomplete transmission to "hisnet"/"hisnode"."
signal DONE
DIALED:
/* We have a .$$? extension. Is it undialable yet? */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
if substr(filename,12,1) = 0 then do
say
say filename "is a call progress entry for "hisnet"/"hisnode"."
end
else
select
when substr(filename,12,1) = 1 then do
say
say filename "is a call progress entry for "hisnet"/"hisnode "indicating one bad connect."
end
when substr(filename,12,1) = 2 then do
say
say filename "is a call progress entry for "hisnet"/"hisnode "indicating two bad connects."
end
when substr(filename,12,1) = 3 then do
say
say filename "is a call progress entry for "hisnet"/"hisnode "indicating three bad connects."
say
say hisnet"/"hisnode "is now undialable."
end
otherwise
say
say "Beats the hell outa me!"
end
signal DONE
REQUEST:
/* .REQ files are lists of file requests. */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
say
say filename "is a list of requests for "hisnet"/"hisnode"."
call stream fullname, 'c', 'open read'
do while lines(fullname)
say linein(fullname)
end
call stream fullname, 'c', 'close'
signal DONE
NOSEND:
/* This type has been "left" by oMMM - that is, flagged to not be sent or */
/* routed under any conditions. */
net = substr(filename,1,4)
node = substr(filename,5,4)
hisnet = x2d(net)
hisnode = x2d(node)
say
say filename "indicates that the mail for "hisnet"/"hisnode" should not be sent"
say "under any circumstances."
signal DONE
TOHEX:
/* This routine calculates the filenames from the node address */
address = right(filename,length(filename)-pos(':',filename))
net = substr(address,1,pos('/',address)-1)
node = substr(address,pos('/',address)+1,length(address)-pos('/',address))
say
say ".?LO/.OUT of" filename "=" d2x(net,4) || d2x(node,4)
say ".MO?/.TU? of" filename "=" d2x(mynet - net,4) || d2x(mynode - node,4)
signal DONE
HELP:
say "WHOIS.CMD - a tool for sysops of Binkley and compatible systems"
say " which will tell you who the file is for and what kind"
say " of file it is."
say
say "Usage: WHOIS <filename.ext | net/node>"
say
say " where 'filename.ext' is a qualified filename you will find"
say " in your outbound directory. Wildcards and pathnames supported."
say " or"
say " where 'net/node' is the address for which you are seeking"
say " the outbound files."
say
DONE:
/* That's all, folks! Not bad for my first REXX program, eh? */
exit