Input-for-Mapped-Applications.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on November 8, 2012 by texi2html 1.82
  4. texi2html was written by:
  5. Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Many creative people.
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <head>
  13. <title>avram - a virtual machine code interpreter: 2.6.2 Input for Mapped Applications</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 2.6.2 Input for Mapped Applications">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 2.6.2 Input for Mapped Applications">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="texi2html 1.82">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <style type="text/css">
  21. <!--
  22. a.summary-letter {text-decoration: none}
  23. blockquote.smallquotation {font-size: smaller}
  24. pre.display {font-family: serif}
  25. pre.format {font-family: serif}
  26. pre.menu-comment {font-family: serif}
  27. pre.menu-preformatted {font-family: serif}
  28. pre.smalldisplay {font-family: serif; font-size: smaller}
  29. pre.smallexample {font-size: smaller}
  30. pre.smallformat {font-family: serif; font-size: smaller}
  31. pre.smalllisp {font-size: smaller}
  32. span.roman {font-family:serif; font-weight:normal;}
  33. span.sansserif {font-family:sans-serif; font-weight:normal;}
  34. ul.toc {list-style: none}
  35. -->
  36. </style>
  37. </head>
  38. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  39. <a name="Input-for-Mapped-Applications"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="Input-Data-Structure.html#Input-Data-Structure" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="Output-From-Non_002dinteractive-Applications.html#Output-From-Non_002dinteractive-Applications" title="Next section in reading order"> &gt; </a>]</td>
  43. <td valign="middle" align="left"> &nbsp; </td>
  44. <td valign="middle" align="left">[<a href="Virtual-Machine-Specification.html#Virtual-Machine-Specification" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="Parameter-Mode-Interface.html#Parameter-Mode-Interface" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Next chapter"> &gt;&gt; </a>]</td>
  47. <td valign="middle" align="left"> &nbsp; </td>
  48. <td valign="middle" align="left"> &nbsp; </td>
  49. <td valign="middle" align="left"> &nbsp; </td>
  50. <td valign="middle" align="left"> &nbsp; </td>
  51. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  52. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  53. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  54. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  55. </tr></table>
  56. <hr size="1">
  57. <a name="Input-for-Mapped-Applications-1"></a>
  58. <h3 class="subsection">2.6.2 Input for Mapped Applications</h3>
  59. <p>Applications invoked using the &lsquo;<samp>--map-to-each-file</samp>&rsquo; option
  60. <a name="index-map_002dto_002deach_002dfile-command-line-option-1"></a>
  61. benefit from a slightly different interface than the one described
  62. above. As the purpose of this option is to save memory by loading only
  63. one file at a time, the application does not have access to all input
  64. files named on the command line simultaneously within the same data
  65. structure. Although the data structure is of the type already described,
  66. the <var>files</var> field is not a list of arbitrary length. Instead, it is
  67. a list containing exactly one item for an input file. If <kbd>-</kbd>
  68. is used as a command line parameter, indicating standard input, then
  69. <var>files</var> will have another item pertaining to standard
  70. input. In no event will it have other than one or two items.
  71. </p>
  72. <p>The mapped application is expected to work by being applied individually
  73. to each of any number of separately constructed data structures, doing
  74. the same in each case as it would if that case were the only one. To make
  75. that possible, copies of the environment variables, the contents of standard
  76. input, and the list of application specific options are contained in the
  77. data structure used for every invocation.
  78. </p>
  79. <a name="index-command-line-3"></a>
  80. <p>The position numbers in the options are adjusted for each invocation to
  81. reflect the position of the particular input file associated with it.
  82. For example, in the following command
  83. </p><table><tr><td>&nbsp;</td><td><pre class="display"><kbd>avram --map-to-each-file mapster.avm fa.txt --data fb.dat --code fc.o</kbd>
  84. </pre></td></tr></table>
  85. <p>the function in the virtual code file &lsquo;<tt>mapster.avm</tt>&rsquo; would be
  86. applied to each of three data structures, corresponding to the commands
  87. </p>
  88. <table><tr><td>&nbsp;</td><td><pre class="display"><kbd>avram mapster.avm fa.txt --data --code</kbd>
  89. <kbd>avram mapster.avm --data fb.dat --code</kbd>
  90. <kbd>avram mapster.avm --data --code fc.o</kbd>
  91. </pre></td></tr></table>
  92. <p>If the relative positions of the options and filenames were important to
  93. the application, they could be reliably inferred from the position
  94. numbers. In the first case, they would be 1 and 2, implying that the
  95. file is in position 0. In the second case they would be 0 and 2,
  96. implying that the file is in position 1, and in the third case they
  97. would be 0 and 1, implying that the file is in position 2. (Of course,
  98. nothing compels an application to concern itself with the positions of
  99. its parameters, and the alternative might be preferable.)
  100. </p>
  101. <p>For the most part, any application that can operate on one file at a
  102. time without needing information from any others can be executed more
  103. economically with the &lsquo;<samp>--map-to-each-file</samp>&rsquo; option and few if any
  104. changes to the code. The effect will normally be analogous to the above
  105. example, subject to a few possible differences.
  106. </p>
  107. <ul>
  108. <li> If an application is supposed to do something by default when
  109. there are no file parameters or only standard input, it won&rsquo;t work as a
  110. mapped application, because if there are no file parameters it won&rsquo;t be
  111. executed at all.
  112. </li><li> If a mapped application causes any output files to be generated, they
  113. may be written before other input files are read, possibly causing the
  114. input files to be overwritten if they have the same names, and causing
  115. subsequent invocations to use the overwritten versions. This behavior
  116. differs from that of loading all input files at the outset, which
  117. ensures the application seeing all of the original versions. The latter may be
  118. more convenient for maintaining a group of files in some sort of
  119. consistent state.
  120. </li><li> If an application causes standard output to be written along with
  121. output files, normally standard output is written last as a security
  122. measure against malicious code altering the &lsquo;<samp>--ask-to-overwrite</samp>&rsquo;
  123. prompts by subtly clobbering the console. In a mapped application,
  124. standard output isn&rsquo;t always last because there may be more invocations
  125. to come.
  126. </li></ul>
  127. <hr size="1">
  128. <table cellpadding="1" cellspacing="1" border="0">
  129. <tr><td valign="middle" align="left">[<a href="Input-Data-Structure.html#Input-Data-Structure" title="Previous section in reading order"> &lt; </a>]</td>
  130. <td valign="middle" align="left">[<a href="Output-From-Non_002dinteractive-Applications.html#Output-From-Non_002dinteractive-Applications" title="Next section in reading order"> &gt; </a>]</td>
  131. <td valign="middle" align="left"> &nbsp; </td>
  132. <td valign="middle" align="left">[<a href="Virtual-Machine-Specification.html#Virtual-Machine-Specification" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  133. <td valign="middle" align="left">[<a href="Parameter-Mode-Interface.html#Parameter-Mode-Interface" title="Up section"> Up </a>]</td>
  134. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Next chapter"> &gt;&gt; </a>]</td>
  135. <td valign="middle" align="left"> &nbsp; </td>
  136. <td valign="middle" align="left"> &nbsp; </td>
  137. <td valign="middle" align="left"> &nbsp; </td>
  138. <td valign="middle" align="left"> &nbsp; </td>
  139. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  140. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  141. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  142. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  143. </tr></table>
  144. <p>
  145. <font size="-1">
  146. This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  147. </font>
  148. <br>
  149. </p>
  150. </body>
  151. </html>