123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <html lang="en">
- <head>
- <title>Raw Files - avram - a virtual machine code interpreter</title>
- <meta http-equiv="Content-Type" content="text/html">
- <meta name="description" content="avram - a virtual machine code interpreter">
- <meta name="generator" content="makeinfo 4.13">
- <link title="Top" rel="start" href="index.html#Top">
- <link rel="up" href="File-Manipulation.html#File-Manipulation" title="File Manipulation">
- <link rel="prev" href="File-Names.html#File-Names" title="File Names">
- <link rel="next" href="Formatted-Input.html#Formatted-Input" title="Formatted Input">
- <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
- <meta http-equiv="Content-Style-Type" content="text/css">
- <style type="text/css"><!--
- pre.display { font-family:inherit }
- pre.format { font-family:inherit }
- pre.smalldisplay { font-family:inherit; font-size:smaller }
- pre.smallformat { font-family:inherit; font-size:smaller }
- pre.smallexample { font-size:smaller }
- pre.smalllisp { font-size:smaller }
- span.sc { font-variant:small-caps }
- span.roman { font-family:serif; font-weight:normal; }
- span.sansserif { font-family:sans-serif; font-weight:normal; }
- --></style>
- </head>
- <body>
- <div class="node">
- <a name="Raw-Files"></a>
- <p>
- Next: <a rel="next" accesskey="n" href="Formatted-Input.html#Formatted-Input">Formatted Input</a>,
- Previous: <a rel="previous" accesskey="p" href="File-Names.html#File-Names">File Names</a>,
- Up: <a rel="up" accesskey="u" href="File-Manipulation.html#File-Manipulation">File Manipulation</a>
- <hr>
- </div>
- <h4 class="subsection">3.3.2 Raw Files</h4>
- <p>Some low level operations involving lists and data files are provided by
- these functions, which are declared in the header file <samp><span class="file">rawio.h</span></samp>.
- <div class="defun">
- — Function: list <b>avm_received_list</b> (<var>FILE *object, char *filename</var>)<var><a name="index-avm_005freceived_005flist-547"></a></var><br>
- <blockquote><p>This function is a convenient way of transferring data directly from a
- raw format file into a list in memory. It might typically be used to
- load the virtual code for an application that has been written to a file
- by a compiler.
- <dl>
- <dt><var>object</var><dd>is the address of a file which should
- already be open for reading before this function is called, and will be
- read from its current position.
- <br><dt><var>filename</var><dd>should be set by the caller to the address of a null terminated string
- containing the name of the file, but is not used unless it needs to be
- printed as part of an error message. If it is a null pointer, standard
- input is assumed.
- </dl>
- <p>The result returned is a list containing data read from the file.
- <p>The file format is described in <a href="File-Format.html#File-Format">File Format</a>. The preamble section
- of the file, if any, is ignored. If the file ends prematurely or
- otherwise conflicts with the format, the program is aborted with a
- message of
- <a name="index-g_t_0040code_007binvalid-raw-file-format_007d-548"></a>
- <pre class="display"> <var>program-name</var><code>: invalid raw file format in </code><var>filename</var>
- </pre>
- <p>written to standard error. The program will also be aborted by this
- function in the event of a memory overflow.
- <p>The file is left open when this function returns, and could therefore be
- used to store other data after the end of the list. The end of a list is
- detected automatically by this function, and it reads no further,
- leaving the file position on the next character, if any.
- </p></blockquote></div>
- <div class="defun">
- — 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>
- <blockquote><p>This function can be used to transfer data from a list in memory to a
- file, essentially by implementing the printing algorithm described in
- <a href="Bit-String-Encoding.html#Bit-String-Encoding">Bit String Encoding</a>.
- <dl>
- <dt><var>repository</var><dd>is the address of a file already open for writing, to which the data are
- written starting from the current position.
- <br><dt><var>operand</var><dd>is the list containing the data to be written
- <br><dt><var>filename</var><dd>is the address of a null terminated string containing the name of the
- file that will be reported in an error message if necessary.
- </dl>
- <p>No preamble section is written by this function, but one could be
- <a name="index-preamble-550"></a>written to the file by the caller prior to calling it. Error messages
- are possible either because of i/o errors or because of insufficient
- memory. I/o errors are not fatal and will result only in a warning
- message being printed to standard error, but a memory overflow will
- cause the process to abort. An i/o error message reported by this
- function would be of the form
- <a name="index-g_t_0040code_007bcan_0027t-write_007d-551"></a>
- <pre class="display"> <var>program-name</var><code>: can't write to </code><var>filename</var>
- </pre>
- <p>followed by the diagnostic obtained from the standard <code>strerror</code>
- <a name="index-g_t_0040code_007bstrerror_007d-552"></a>function if it exists on the host platform. The file is left open when
- this function returns.
- </p></blockquote></div>
- <div class="defun">
- — Function: void <b>avm_initialize_rawio</b> ()<var><a name="index-avm_005finitialize_005frawio-553"></a></var><br>
- <blockquote><p>This function initializes some necessary data structures for the
- functions in this section, and should be called prior to them at the
- beginning of a run.
- </p></blockquote></div>
- <div class="defun">
- — Function: void <b>avm_count_rawio</b> ()<var><a name="index-avm_005fcount_005frawio-554"></a></var><br>
- <blockquote><p>This function does nothing in the present version of the library, but
- should be called after the last call to all of the other functions in
- this section in order to maintain compatibility with future versions of
- the library. Future versions may decide to use this function to do some
- cleaning up of local data structures.
- </p></blockquote></div>
- </body></html>
|