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

  1. /* 
  2. Usage: ShowCLI [ 0xnnnnnn ] 
  3. Version 1.00  02-Nov-88
  4.  
  5. Dumps the CLI structure for a process address
  6. */
  7. address 'COMMAND'
  8. 'version >nil: exec.library 36 '
  9. lrc = rc
  10.  
  11. if (rc = 0) then
  12.   check = addlib('rexxsupport.library',0,-30,0) 
  13.  
  14. address
  15.  
  16.  
  17. parse arg name '0x' tsk .
  18.  
  19. NULL = "00000000"x
  20.  
  21. if (name = '?') then
  22.    do
  23.    do i = 2 to 6
  24.       'd "'||strip(sourceline(i),'T',"0a"x) '"'
  25.    end
  26.    exit(0)
  27.    end
  28. else if (tsk ~= '') then
  29.    do
  30.    name = right(tsk,8,'0')
  31.    taskbase = x2c(name)
  32.    name = '0x'||name
  33.    end
  34. else
  35.    do
  36.    options results
  37.    'opt task'
  38.    tasklist = result
  39.    options
  40.    tasklist = strip(tasklist)
  41.    name = right(tasklist, 9)
  42.    name = left(name,8)
  43.    taskbase = x2c(name)
  44.    name = '0x'||name
  45.    end
  46.  
  47. tasknum   = right(c2d(import(offset(taskbase,140),4)), 9)
  48. cli       = x2c(c2x(d2c(c2d(import(offset(taskbase,172),4))*4,4)))
  49. command = 'No command loaded'
  50. module = ''
  51. if (cli ~= NULL) then
  52.    do
  53.       cmdname = d2c(c2d(import(offset(cli,16),4))*4,4)
  54.       cmdlen = c2d(import(cmdname, 1))
  55.       module = import(offset(cmdname,1), cmdlen)
  56.       if cmdlen ~= 0 then
  57.          command = 'Loaded as command:' module 
  58.       end
  59.       'd "Process' tasknum ||':' command '"'
  60.       /* Now dump the CLI Structure */
  61.  
  62.       pbstr = d2c(c2d(import(offset(cli,24),4))*4,4)
  63.       prompt = import(offset(pbstr,1),c2d(import(pbstr,1)))
  64.       'd "Prompt     : \"' || prompt || '\""'
  65.  
  66.       cbstr = d2c(c2d(import(offset(cli,4),4))*4,4)
  67.       curdir = import(offset(cbstr,1),c2d(import(cbstr,1)))
  68.       'd "Currentdir : \"' || curdir || '\""'
  69.  
  70.       ebstr = d2c(c2d(import(offset(cli,36),4))*4,4)
  71.       execfile = import(offset(ebstr,1),c2d(import(ebstr,1)))
  72.       'd "ExecuteFile: \"' || execfile || '\""'
  73.  
  74.       rslt2 = right(c2d(import(cli,4)),8)
  75.       retc  = right(c2d(import(offset(cli,12),4)),8)
  76.       stack = c2d(import(offset(cli,52),4))*4
  77.       'd "Result2:   ' rslt2 '  ReturnCode:    ' retc '   Stack:' stack '"'
  78.  
  79.       faillev = right(c2d(import(offset(cli,20),4)),8)
  80.       interactive = "NONInteractive"
  81.       if (import(offset(cli,40),4) ~= NULL) then interactive = "Interactive   "
  82.       type = "Foreground"
  83.       if (import(offset(cli,44),4) ~= NULL) then type = "Background"
  84.       'd "FailLevel: ' faillev ' ' interactive '            ' type '"'
  85.  
  86.       stdin = '0x'||c2x(d2c(c2d(import(offset(cli,28),4))*4,4))
  87.       curin = '0x'||c2x(d2c(c2d(import(offset(cli,32),4))*4,4))
  88.       redir = ''
  89.       if (stdin ~= curin) then redir = '  <Redirected>'
  90.       'd "StdInput: ' stdin '  CurrentInput: ' curin redir'"'
  91.  
  92.       stdout = '0x'||c2x(d2c(c2d(import(offset(cli,48),4))*4,4))
  93.       curout = '0x'||c2x(d2c(c2d(import(offset(cli,56),4))*4,4))
  94.       redir = ''
  95.       if (stdin ~= curin) then redir = '  <Redirected>'
  96.       'd "StdOutput:' stdout '  CurrentOutput:' curout redir'"'
  97.  
  98.       seglist = '0x'||c2x(d2c(c2d(import(offset(cli,60),4))*4,4))
  99.       path    = '0x'||c2x(d2c(c2d(import(offset(cli,8),4))*4,4))
  100.       'd "Seglist:  ' seglist '  Path:         ' path '"'
  101.       exit(0)
  102.    end
  103.  
  104. 'd "Unable to find' name '"'
  105. exit(0)
  106.  
  107. /* Find a given library in the system 
  108. findlib:
  109. parse arg tofind
  110. execbase = next("00000004"x)
  111. liboff = 378
  112. nodebase = import(offset(execbase, liboff), 4)
  113.  
  114. do while(import(nodebase,4) ~= NULL)
  115.    if import(import(offset(nodebase,10),4)) = tofind then return nodebase
  116.    nodebase = import(nodebase,4)
  117. end
  118.  
  119. 'd "Could not find' tofind||'"'
  120. exit(0)
  121. */