Raw-Files.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <html lang="en">
  2. <head>
  3. <title>Raw Files - 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="File-Manipulation.html#File-Manipulation" title="File Manipulation">
  9. <link rel="prev" href="File-Names.html#File-Names" title="File Names">
  10. <link rel="next" href="Formatted-Input.html#Formatted-Input" title="Formatted Input">
  11. <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
  12. <meta http-equiv="Content-Style-Type" content="text/css">
  13. <style type="text/css"><!--
  14. pre.display { font-family:inherit }
  15. pre.format { font-family:inherit }
  16. pre.smalldisplay { font-family:inherit; font-size:smaller }
  17. pre.smallformat { font-family:inherit; font-size:smaller }
  18. pre.smallexample { font-size:smaller }
  19. pre.smalllisp { font-size:smaller }
  20. span.sc { font-variant:small-caps }
  21. span.roman { font-family:serif; font-weight:normal; }
  22. span.sansserif { font-family:sans-serif; font-weight:normal; }
  23. --></style>
  24. </head>
  25. <body>
  26. <div class="node">
  27. <a name="Raw-Files"></a>
  28. <p>
  29. Next:&nbsp;<a rel="next" accesskey="n" href="Formatted-Input.html#Formatted-Input">Formatted Input</a>,
  30. Previous:&nbsp;<a rel="previous" accesskey="p" href="File-Names.html#File-Names">File Names</a>,
  31. Up:&nbsp;<a rel="up" accesskey="u" href="File-Manipulation.html#File-Manipulation">File Manipulation</a>
  32. <hr>
  33. </div>
  34. <h4 class="subsection">3.3.2 Raw Files</h4>
  35. <p>Some low level operations involving lists and data files are provided by
  36. these functions, which are declared in the header file <samp><span class="file">rawio.h</span></samp>.
  37. <div class="defun">
  38. &mdash; Function: list <b>avm_received_list</b> (<var>FILE *object, char *filename</var>)<var><a name="index-avm_005freceived_005flist-547"></a></var><br>
  39. <blockquote><p>This function is a convenient way of transferring data directly from a
  40. raw format file into a list in memory. It might typically be used to
  41. load the virtual code for an application that has been written to a file
  42. by a compiler.
  43. <dl>
  44. <dt><var>object</var><dd>is the address of a file which should
  45. already be open for reading before this function is called, and will be
  46. read from its current position.
  47. <br><dt><var>filename</var><dd>should be set by the caller to the address of a null terminated string
  48. containing the name of the file, but is not used unless it needs to be
  49. printed as part of an error message. If it is a null pointer, standard
  50. input is assumed.
  51. </dl>
  52. <p>The result returned is a list containing data read from the file.
  53. <p>The file format is described in <a href="File-Format.html#File-Format">File Format</a>. The preamble section
  54. of the file, if any, is ignored. If the file ends prematurely or
  55. otherwise conflicts with the format, the program is aborted with a
  56. message of
  57. <a name="index-g_t_0040code_007binvalid-raw-file-format_007d-548"></a>
  58. <pre class="display"> <var>program-name</var><code>: invalid raw file format in </code><var>filename</var>
  59. </pre>
  60. <p>written to standard error. The program will also be aborted by this
  61. function in the event of a memory overflow.
  62. <p>The file is left open when this function returns, and could therefore be
  63. used to store other data after the end of the list. The end of a list is
  64. detected automatically by this function, and it reads no further,
  65. leaving the file position on the next character, if any.
  66. </p></blockquote></div>
  67. <div class="defun">
  68. &mdash; Function: void <b>avm_send_list</b> (<var>FILE *repository, list operand, char *filename</var>)<var><a name="index-avm_005fsend_005flist-549"></a></var><br>
  69. <blockquote><p>This function can be used to transfer data from a list in memory to a
  70. file, essentially by implementing the printing algorithm described in
  71. <a href="Bit-String-Encoding.html#Bit-String-Encoding">Bit String Encoding</a>.
  72. <dl>
  73. <dt><var>repository</var><dd>is the address of a file already open for writing, to which the data are
  74. written starting from the current position.
  75. <br><dt><var>operand</var><dd>is the list containing the data to be written
  76. <br><dt><var>filename</var><dd>is the address of a null terminated string containing the name of the
  77. file that will be reported in an error message if necessary.
  78. </dl>
  79. <p>No preamble section is written by this function, but one could be
  80. <a name="index-preamble-550"></a>written to the file by the caller prior to calling it. Error messages
  81. are possible either because of i/o errors or because of insufficient
  82. memory. I/o errors are not fatal and will result only in a warning
  83. message being printed to standard error, but a memory overflow will
  84. cause the process to abort. An i/o error message reported by this
  85. function would be of the form
  86. <a name="index-g_t_0040code_007bcan_0027t-write_007d-551"></a>
  87. <pre class="display"> <var>program-name</var><code>: can't write to </code><var>filename</var>
  88. </pre>
  89. <p>followed by the diagnostic obtained from the standard <code>strerror</code>
  90. <a name="index-g_t_0040code_007bstrerror_007d-552"></a>function if it exists on the host platform. The file is left open when
  91. this function returns.
  92. </p></blockquote></div>
  93. <div class="defun">
  94. &mdash; Function: void <b>avm_initialize_rawio</b> ()<var><a name="index-avm_005finitialize_005frawio-553"></a></var><br>
  95. <blockquote><p>This function initializes some necessary data structures for the
  96. functions in this section, and should be called prior to them at the
  97. beginning of a run.
  98. </p></blockquote></div>
  99. <div class="defun">
  100. &mdash; Function: void <b>avm_count_rawio</b> ()<var><a name="index-avm_005fcount_005frawio-554"></a></var><br>
  101. <blockquote><p>This function does nothing in the present version of the library, but
  102. should be called after the last call to all of the other functions in
  103. this section in order to maintain compatibility with future versions of
  104. the library. Future versions may decide to use this function to do some
  105. cleaning up of local data structures.
  106. </p></blockquote></div>
  107. </body></html>