home *** CD-ROM | disk | FTP | other *** search
- /* This file is Copyright(C) 1990 Francois Rouaix and the Software Winery */
- /* This file must be distributed unmodified in the RXGEN package */
-
- /* Fd.rexx
- Syntax : FD INFO <functionname> [<libraryname>]
- Example: FD INFO FindPort exec
- Result : prints the description of the function (offset, registers)
-
- Syntax : FD OFFS <offset> [<libraryname>]
- Example: FD OFFS FF7A exec
- Result : prints the description of the function
-
- Syntax : FD LIBS
- Result : prints the available libraries (described by an FD.FILE)
- */
-
- parse arg comselect others
-
- do while (words(getclip('FDDIR')) == 0)
- say "Please enter the directory where the FD.FILES reside:"
- say "Exemple: Extras 1.3:FD1.3"
- pull fddir
- fddir = strip(fddir)
- call setclip('FDDIR',fddir)
- end
- fddir=getclip('FDDIR')
- fdfiles=showdir(fddir,'File')
- comselect = upper(comselect)
- select
- when comselect=='INFO' then do
- parse var others functionname libname
- if length(libname) == 0
- then call map('findin '''functionname"',", fdfiles)
- else call findin(functionname,strip(libname)||'_LIB.FD')
- end
- when comselect=='OFFS' then do
- parse var others offs libname
- select
- when datatype(offs) == NUM then nop
- when datatype(offs) == CHAR then offs=x2d(offs) - 65536
- otherwise do
- say "Offset: -num (-30)"
- say " hex (FFA0)"
- exit 0
- end
- end
- if length(libname) == 0
- then call map('getfunc ' offs ",", fdfiles)
- else call getfunc(offs,strip(libname)||'_LIB.FD')
- end
- when comselect=='LIBS' then do
- fdlibs = map('fname2libname', fdfiles)
- say "Libraries:" fdlibs
- end
- otherwise
- do
- say "Syntax : FD INFO <functionname> [<libraryname>]"
- say " FD OFFS <offset> [<libraryname>]"
- say " FD LIBS"
- end
- end
-
- exit 0
-
- /* this should be familiar to you ol' lispers */
- map: procedure expose fddir
- if (words(arg(2)) == 0)
- then return('')
- else
- parse value arg(2) with _car _cdr
- interpret 'call' arg(1) '_car'
- leftval = result
- return( leftval map(arg(1), _cdr))
-
- fname2libname: procedure
- arg _fname
- parse upper var _fname _libname '_LIB.FD'
- return _libname
-
- findin: procedure expose fddir
- success = open('handle',fddir||'/'||arg(2),'Read')
- found = 0
- offset = 0
- privateflag = 'public '
- if success then do until (found | eof('handle'))
- line = readln('handle')
- select
- when left(line,1) == '*' then nop
- when left(line,6) == '##bias' then do
- parse var line '##bias' offset
- offset = strip(offset)
- end
- when left(line,8) == '##public' then privateflag = 'public '
- when left(line,9) == '##private' then privateflag = 'private'
- when left(line,5) == '##end' then do close('handle') ; return('') ; end
- when left(line,6) == '##base' then nop
- otherwise do
- if upper(left(line,length(arg(1)))) == upper(arg(1))
- then found = 1
- else offset = offset + 6
-
- end
- end
- end
- else do
- say "I don't find" arg(2) "in" fddir
- return('')
- end
- call close('handle')
- if found
- then do
- res=left(fname2libname(arg(2)),20) privateflag left('-'offset,4) d2x(65536 - offset) line
- say res
- return('')
- end
- else return('')
-
- getfunc: procedure expose fddir /* offs library */
- success = open('handle',fddir||'/'||arg(2),'Read')
- found = 0
- offset = 0
- privateflag = 'public '
- if success then do until (found | eof('handle'))
- line = readln('handle')
- select
- when left(line,1) == '*' then nop
- when left(line,6) == '##bias' then do
- parse var line '##bias' offset
- offset = strip(offset)
- end
- when left(line,8) == '##public' then privateflag = 'public '
- when left(line,9) == '##private' then privateflag = 'private'
- when left(line,5) == '##end' then do close('handle') ; return('') ; end
- when left(line,6) == '##base' then nop
- otherwise do
- if (offset == -arg(1))
- then found = 1
- else offset = offset + 6
- end
- end
- end
- else do
- say "I don't find" arg(2) "in" fddir
- return('')
- end
- call close('handle')
- if found
- then do
- res=left(fname2libname(arg(2)),20) privateflag left('-'offset,4) d2x(65536 - offset) line
- say res
- return('')
- end
- else return('')
-