home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / hce.lha / HCE / LibSource / clib / Misc / src / System0.doc < prev    next >
Encoding:
Text File  |  1992-09-02  |  3.4 KB  |  105 lines

  1. #! rnews 11784
  2. Path: van-bc!ubc-cs!ubc-vision!uw-beaver!mit-eddie!bloom-beacon!think!ames!pas
  3. teur!ucbvax!decvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!unido!rmi!kkaemp
  4. f
  5. From: kkaempf@rmi.UUCP (Klaus Kaempf)
  6. Newsgroups: comp.sys.amiga
  7. Subject: Execute()
  8. Keywords: shell, BCPL, AmigaDOS, fork(), fexec()
  9. Message-ID: <857@rmi.UUCP>
  10. Date: 22 Jan 88 15:40:47 GMT
  11. Reply-To: kkaempf@rmi.UUCP
  12. Organization: RMI Net, Aachen, W.Germany
  13. Lines: 385
  14. Posted: Fri Jan 22 16:40:47 1988
  15.  
  16. Wanna call a CLI-command in your own application? Maybe you
  17. don't have "RUN" in your "C:" directory? Or it's "PROMPT",
  18. "STACK", "CD" or the like? So forget "Execute()"! But it's
  19. one of these BCPL programs - darn!
  20.  
  21. Try this one!
  22.  
  23. This small program can be used to execute CLI-commands, even
  24. the ones that rely on the correct BCPL setup.
  25.  
  26. Two restrictions:
  27.  
  28. "System0()" must be called from a CLI-PROCESS (or SHELL or
  29. whatever). You cannot call it from WorkBench, a simple task
  30. or interrupt (argh!).
  31.  
  32. "EXECUTE" (the CLI-command) will not loop through the
  33. batchfile itself, but rather change the "cli_CurrentInput",
  34. so the shell will execute the incoming lines until "EOF" is
  35. encountered and then restore "cli_CurrentInput". So this is
  36. not a restriction, if you return to the input-loop directly
  37. after "System0()" has been called (normally true in shell
  38. program). Batchfiles called this way may be nested, but do
  39. not try to "EXECUTE" several batch-files ...
  40.  
  41. System0("Execute", seglist, "first");
  42. System0("Execute", seglist, "second");
  43. System0("Execute", seglist, "third");
  44.  
  45. ... without returning to the input-loop first.
  46.  
  47. "System0()" WON'T handle loading and unloading of the code,
  48. I/O-redirection or whatever, but this is fairly simple.
  49.  
  50. Commands should be checked in the following order:
  51.  
  52. built-in commands of the shell
  53. resident commands ("NetHand")
  54. current directory (WindowPtr = -1)
  55. path list ("CommandDir", WindowPtr = -1)
  56. "C:" (WindowPtr = 0)
  57.  
  58. As an option for shells: Try to execute it as a batchfile
  59. (current directory or "S:"), if everything else fails (but
  60. use "WindowPtr = -1" for "C:" then).
  61.  
  62. I/O-redirection should save the values of "pr_CIS" and
  63. "pr_COS", put the new ones into these fields and restore
  64. them after the command has finished. That's why "EXECUTE" is
  65. not that much impressed if you supply it with ">" or "<".
  66.  
  67. "System0()" returns the return code (register D0 or
  68. "Exit()"-parameter) of the program called (not the same as
  69. "Execute()"!), or an internal error code:
  70.  
  71. -1: process not a CLI
  72. -2: not enough memory for stack
  73.  
  74. It does not rely on some strange undocumented data
  75. structures the way Aztec's "fexec#?()" does. You do not need
  76. a special startup code to save the registers (Csh 2.04). I
  77. still have to find the command, that cannot be called this
  78. way, but you will certainly manage this. :-)
  79.  
  80. Two non-standard include files are used. "extern/exec.i"
  81. contains the "_LVO" equates for "exec", you can use
  82. "amiga.lib" instead. "extras/asm.i" provides ...
  83.  
  84. AbsExecBase equ 4
  85.  
  86. REG_SysBase equr a6
  87.  
  88. callsys macro
  89.         jsr _LVO\1(REG_SysBase)
  90.         endm
  91.  
  92. The uuencoded object file has been created using the
  93. Metacomco Macro Assembler. A new release (11.1) of this one
  94. has been announced for the ST, does anybody have further
  95. information about an Amiga-version?
  96.  
  97. multam salutem omnibus
  98.  
  99. !ralph
  100.  
  101. P.S.: If someone would be as kind as to mail me a disk with
  102. the latest version of Matt's shell for Lattice-C? Thanks!
  103.  
  104. ################
  105.