Execution-Modes.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <html lang="en">
  2. <head>
  3. <title>Execution Modes - avram - a virtual machine code interpreter</title>
  4. <meta http-equiv="Content-Type" content="text/html">
  5. <meta name="description" content="avram - a virtual machine code interpreter">
  6. <meta name="generator" content="makeinfo 4.13">
  7. <link title="Top" rel="start" href="index.html#Top">
  8. <link rel="up" href="Invocation.html#Invocation" title="Invocation">
  9. <link rel="prev" href="Command-Line-Parsing.html#Command-Line-Parsing" title="Command Line Parsing">
  10. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  11. <meta http-equiv="Content-Style-Type" content="text/css">
  12. <style type="text/css"><!--
  13. pre.display { font-family:inherit }
  14. pre.format { font-family:inherit }
  15. pre.smalldisplay { font-family:inherit; font-size:smaller }
  16. pre.smallformat { font-family:inherit; font-size:smaller }
  17. pre.smallexample { font-size:smaller }
  18. pre.smalllisp { font-size:smaller }
  19. span.sc { font-variant:small-caps }
  20. span.roman { font-family:serif; font-weight:normal; }
  21. span.sansserif { font-family:sans-serif; font-weight:normal; }
  22. --></style>
  23. </head>
  24. <body>
  25. <div class="node">
  26. <a name="Execution-Modes"></a>
  27. <p>
  28. Previous:&nbsp;<a rel="previous" accesskey="p" href="Command-Line-Parsing.html#Command-Line-Parsing">Command Line Parsing</a>,
  29. Up:&nbsp;<a rel="up" accesskey="u" href="Invocation.html#Invocation">Invocation</a>
  30. <hr>
  31. </div>
  32. <h4 class="subsection">3.4.2 Execution Modes</h4>
  33. <p>Some functions declared in <samp><span class="file">exmodes.h</span></samp> are useful for executing
  34. interactive applications or filter mode transducers in a manner
  35. consistent with the specifications described in the previous chapter.
  36. <div class="defun">
  37. &mdash; Function: void <b>avm_interact</b> (<var>list avm_interactor, int step_mode, int ask_to_overwrite_mode, int quiet_mode</var>)<var><a name="index-avm_005finteract-593"></a></var><br>
  38. <blockquote>
  39. <p>This function executes an interactive virtual code application. The
  40. parameters have these interpretations.
  41. <dl>
  42. <dt><var>avm_interactor</var><dd>is the virtual code for a function that performs as specified in
  43. <a href="Output-From-Interactive-Applications.html#Output-From-Interactive-Applications">Output From Interactive Applications</a>.
  44. <br><dt><var>step_mode</var><dd>will cause all shell commands to be echoed if set to a non-zero
  45. value, and will cause the program to pause after each shell command
  46. until a key is pressed.
  47. <br><dt><var>ask_to_overwrite_mode</var><dd>can be set to a non-zero value by the caller to cause the program to ask
  48. permission of the user to overwrite any existing files in cases where
  49. the virtual code returns a file list as described in <a href="Mixed-Modes-of-Interaction.html#Mixed-Modes-of-Interaction">Mixed Modes of Interaction</a>.
  50. <br><dt><var>quiet_mode</var><dd>can be set to a non-zero value to suppress console messages in the case
  51. of file output per <a href="Mixed-Modes-of-Interaction.html#Mixed-Modes-of-Interaction">Mixed Modes of Interaction</a>.
  52. </dl>
  53. <p>The meaning of this function is accessible to any reader willing to slog
  54. through <a href="Output-From-Interactive-Applications.html#Output-From-Interactive-Applications">Output From Interactive Applications</a>. The only subtle
  55. point is that <var>avm_interactor</var> parameter in this function
  56. does not correspond to the virtual code application that <code>avram</code>
  57. reads from a virtual code file, but to the result computed when the
  58. application read from the file is applied to the data structure
  59. representing the command line and environment.
  60. <p>Any of the memory overflows or i/o errors possible with other functions
  61. in the library are possible from this one as well, and will also cause
  62. it to print an error message and halt the program. A badly designed
  63. <a name="index-deadlock-594"></a>virtual code application could cause a deadlock, which will not be
  64. detected or reported
  65. </p></blockquote></div>
  66. <div class="defun">
  67. &mdash; Function: void <b>avm_trace_interaction</b> ()<var><a name="index-avm_005ftrace_005finteraction-595"></a></var><br>
  68. <blockquote>
  69. <p>This function enables diagnostic output for the <code>avm_recoverable_interact</code>
  70. function.
  71. </p></blockquote></div>
  72. <div class="defun">
  73. &mdash; Function: void <b>avm_disable_interaction</b> ()<var><a name="index-avm_005fdisable_005finteraction-596"></a></var><br>
  74. <blockquote>
  75. <p>This function causes <code>avm_interact</code> and <code>avm_recoverable_interact</code>
  76. to terminate with an error instead of executing, as required by the
  77. <code>--jail</code> command line option.
  78. </p></blockquote></div>
  79. <div class="defun">
  80. &mdash; Function: list <b>avm_recoverable_interact</b> (<var>list interactor, int *fault</var>)<var><a name="index-avm_005frecoverable_005finteract-597"></a></var><br>
  81. <blockquote>
  82. <p>This function is similar to <code>avm_interact</code> but always closes the
  83. pipe and performs no file i/o, and will return an error message rather
  84. than exiting. Otherwise it returns a transcript of the intereaction as
  85. a list of lists of strings represented as lists of character
  86. encodings. It implements the <var>interact</var> combinator with the
  87. virtual code for the transducer function given as the parameter. A
  88. prior call to <code>avm_trace_interaction</code> will cause diagnostic
  89. information to be written to standard output when this function is
  90. executed.
  91. </p></blockquote></div>
  92. <div class="defun">
  93. &mdash; Function: void <b>avm_byte_transduce</b> (<var>list operator</var>)<var><a name="index-avm_005fbyte_005ftransduce-598"></a></var><br>
  94. <blockquote>
  95. <p>This function executes a filter mode byte transducer application, which
  96. behaves as described in <a href="Byte-Transducers.html#Byte-Transducers">Byte Transducers</a>. The argument is the
  97. virtual code for the application, which would be found in a virtual code
  98. file. There are limited opportunities for i/o errors, as only standard
  99. input and standard output are involved with this function, but fatal
  100. errors due to memory overflow are possible.
  101. </p></blockquote></div>
  102. <div class="defun">
  103. &mdash; Function: void <b>avm_line_map</b> (<var>list operator</var>)<var><a name="index-avm_005fline_005fmap-599"></a></var><br>
  104. <blockquote>
  105. <p>This function executes line mapped filter mode applications, which are
  106. explained in <a href="Line-Maps.html#Line-Maps">Line Maps</a>. The argument is the virtual code for the
  107. application. Similar comments to those above apply.
  108. </p></blockquote></div>
  109. <div class="defun">
  110. &mdash; Function: void <b>avm_initialize_exmodes</b> ()<var><a name="index-avm_005finitialize_005fexmodes-600"></a></var><br>
  111. <blockquote>
  112. <p>This function should be called before any of the other functions in this
  113. section in order to initialize some local variables. Results are
  114. undefined if this function isn't called first.
  115. </p></blockquote></div>
  116. <div class="defun">
  117. &mdash; Function: void <b>avm_count_exmodes</b> ()<var><a name="index-avm_005fcount_005fexmodes-601"></a></var><br>
  118. <blockquote>
  119. <p>This function doesn't do anything in the present version of the library,
  120. but should be called after the last call to any of the other functions
  121. in this section in order to maintain compatibility with future versions,
  122. which may use it for cleaning up local variables.
  123. </p></blockquote></div>
  124. </body></html>