home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / rexx / status.cpr < prev    next >
Encoding:
Text File  |  1996-12-24  |  1.6 KB  |  60 lines

  1. /* Show all CLI tasks */
  2. address 'COMMAND'
  3. 'version >nil: exec.library 36 '
  4. lrc = rc
  5.  
  6. if (rc = 0) then
  7.   check = addlib('rexxsupport.library',0,-30,0) 
  8.  
  9. address
  10.  
  11. NULL = "00000000"x
  12.  
  13. dosbase   = findlib("dos.library")
  14. rootnode  = import(offset(dosbase,34),4)
  15. tasktable = d2c(c2d(import(rootnode,4))*4,4)
  16. taskcount = c2d(import(tasktable,4))
  17. do tasknum = 1 to taskcount
  18.    proc = import(offset(tasktable,tasknum*4),4)
  19.    if (proc ~= NULL) then
  20.       do
  21.       proc = offset(proc,-92)
  22.       cli = d2c(c2d(import(offset(proc,172),4))*4,4)
  23.       command = 'No command loaded'
  24.       args = ''
  25.       if (cli ~= NULL) then
  26.          do
  27.          cmdname = d2c(c2d(import(offset(cli,16),4))*4,4)
  28.          cmdlen = c2d(import(cmdname, 1))
  29.          if cmdlen ~= 0 then
  30.             do
  31.             command = 'Command:' import(offset(cmdname,1), cmdlen)
  32.             cis = d2c(c2d(import(offset(cli,32),4))*4,4)
  33.             cptr = d2c(c2d(import(offset(cis,12),4))*4,4)
  34.             args = import(cptr,80)
  35.             args = translate(args,"'"||'0a0a'x,'"'||'0d00'x)
  36.             y = pos('0a'x, args)
  37.             if (y ~= 0) then args = left(args,y-1)
  38.             end
  39.          end
  40.       'd "Process' tasknum||': 0x'||c2x(proc) command args'"'
  41.       end
  42. end
  43. exit(0)
  44.  
  45. /* Find a given library in the system */
  46. findlib:
  47. parse arg tofind
  48. execbase = next("00000004"x)
  49. liboff = 378
  50. nodebase = import(offset(execbase, liboff), 4)
  51.  
  52. do while(import(nodebase,4) ~= NULL)
  53.    namestr = import(import(offset(nodebase,10),4))
  54.    if namestr = tofind then return nodebase
  55.    nodebase = import(nodebase,4)
  56. end
  57.  
  58. 'd "Could not find' tofind||'"'
  59. exit(0)
  60.