home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
529a.lha
/
offset
/
offset.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1991-07-02
|
2KB
|
87 lines
/* offset.rexx $VER: v1.1a_1991-04-20 E.Lundevall */
parse arg lib funcs
private = ''
if lib = '' then do
say 'Usage: offset library [ function | offset ][function | offset ]...'
exit
end
pos = index(lib,'.library')
if pos = 0 then do
pos = index(lib,'.resource')
if pos = 0 then
pos = index(lib,'.device')
end
if pos ~= 0 then lib = left(lib,pos-1) /* Strip extension */
filename = 'FD:' || lib || '_lib.fd'
if ~open(fdfil,filename,'R') then do
say 'Could not open fd file -' filename
exit 20
end
if funcs = '' then loopend = 1
else loopend = words(funcs)
do loop = 1 to loopend
bang = 0
func = word(funcs,loop)
if left(func,1) = '!' then do /* Search for substring */
func = right(func,length(func)-1)
bang = 1
end
else if index(func,'$') ~= 0 then do /* Translate hex offset to decimal */
func = translate(func,'','$')
if index(func,'-') = 1 then func = 0 - x2d(right(func,length(func)-2))
else func = x2d(func) - 65536
end
call seek(fdfil,0,'B') /* Go to start of fd file */
do until word(line,1) = '##bias'
line = readln(fdfil)
end
offset = 0 - word(line,2) /* Initial offset */
if datatype(func) = NUM then do /* Look for an offset value */
offset = offset + 6
do until offset = func | eof(fdfil)
line = readln(fdfil)
if left(line,1) = '*' then iterate
if left(line,2) = '##' then do
if word(line,1) = '##public' then private = ''
else if word(line,1) = '##private' then private = '*private*'
iterate
end
offset = offset - 6
end
if ~eof(fdfil) then say '$'d2x(offset,4) '-$'d2x(0-offset) offset line private
end
else do
func = upper(func)
do until word(line,1) = '##end' /* Look for a function, or all functions */
line = readln(fdfil)
if left(line,1) = '*' then iterate
if left(line,2) = '##' then do
if word(line,1) = '##public' then private = ''
else if word(line,1) = '##private' then private = '*private*'
iterate
end
parse var line name '(' dummy
if bang = 1 & index(upper(name),func) ~= 0 | func = '' then
say '$'d2x(offset,4) '-$'d2x(0-offset) offset line private
else if func = upper(name) then do
say '$'d2x(offset,4) '-$'d2x(0-offset) offset line private
leave
end
offset = offset - 6
end
end
end
call close(fdfil)