File-Names.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on December 10, 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: 3.3.1 File Names</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 3.3.1 File Names">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 3.3.1 File Names">
  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="File-Names"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="File-Manipulation.html#File-Manipulation" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="Raw-Files.html#Raw-Files" 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="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="File-Manipulation.html#File-Manipulation" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" 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="File-Names-1"></a>
  58. <h3 class="subsection">3.3.1 File Names</h3>
  59. <p>A standard representation is used by virtual code applications for the
  60. <a name="index-file-names-2"></a>
  61. path names of files, following the description in <a href="Input-Data-Structure.html#Input-Data-Structure">Input Data Structure</a>. The functions and constants declared in <code>fnames.h</code>
  62. provide an API for operating on file names in this form.
  63. </p>
  64. <dl>
  65. <dt><a name="index-avm_005fpath_005frepresentation"></a><u>Function:</u> list <b>avm_path_representation</b><i> (char *<var>path</var>)</i></dt>
  66. <dd><p>If a C program is to invoke a virtual code application and pass a path
  67. name to it as a parameter, this function can be used to generate the
  68. appropriate representation from a given character string.
  69. </p>
  70. <table><tr><td>&nbsp;</td><td><pre class="example">conf_path = avm_path_representation(&quot;/etc/resolve.conf&quot;);
  71. </pre></td></tr></table>
  72. <p>In this example, <code>conf_path</code> is a <code>list</code>. For potentially
  73. better portability, a C program can use the character constant
  74. <code>avm_path_separator_character</code> in place of the slashes in hard
  75. coded path names.
  76. </p>
  77. <p>Other useful constants are <code>avm_current_directory_prefix</code> as a
  78. <a name="index-avm_005fpath_005fseparator_005fcharacter"></a>
  79. <a name="index-avm_005fpath_005fseparator"></a>
  80. <a name="index-avm_005fcurrent_005fdirectory_005fprefix"></a>
  81. <a name="index-avm_005fparent_005fdirectory_005fprefix"></a>
  82. <a name="index-avm_005froot_005fdirectory_005fprefix"></a>
  83. portable replacement for <code>&quot;./&quot;</code>, as well as
  84. <code>avm_parent_directory_prefix</code> instead of <code>&quot;../&quot;</code>. There is
  85. also <code>avm_root_directory_prefix</code> for <code>&quot;/&quot;</code>. These three
  86. constants are null terminated strings, unlike
  87. <code>avm_path_separator_character</code>, which is a character.
  88. </p>
  89. <p>If a <code>NULL</code> pointer is passed as the <code><var>path</var></code>, a
  90. <code>NULL</code> list is returned, which is the path representation for
  91. standard input or standard output. If the address of an empty string is
  92. passed to this function as the <code><var>path</var></code>, the list of the empty
  93. string will be returned, which is the path representation for the root
  94. directory. Trailing path separators are ignored, so <code>&quot;/&quot;</code> is the
  95. same as the empty string.
  96. </p>
  97. <p>Some memory needs to be allocated for the result of this function. If
  98. the memory is not available, an error message is written to standard
  99. error and the process is terminated.
  100. </p></dd></dl>
  101. <dl>
  102. <dt><a name="index-avm_005fdate_005frepresentation"></a><u>Function:</u> list <b>avm_date_representation</b><i> (char *<var>path</var>)</i></dt>
  103. <dd><p>This function is essentially a wrapper around the standard
  104. <code>ctime_r</code> function that not only gets the time stamp for a file at
  105. a given path, but transforms it to a list representation according to
  106. <a href="Character-Table.html#Character-Table">Character Table</a>. It needs to allocate memory for the result and
  107. will cause the program to exit with an error message if there is not
  108. enough memory available.
  109. </p>
  110. <p>The time stamp will usually be in a format like <code>Sun Mar 4 10:56:40
  111. GMT 2001</code>. If for some reason the time stamp can not be obtained, the
  112. <a name="index-unknown-date"></a>
  113. result will be a representation of the string <code>unknown date</code>.
  114. </p></dd></dl>
  115. <dl>
  116. <dt><a name="index-avm_005fpath_005fname"></a><u>Function:</u> char* <b>avm_path_name</b><i> (list <var>path</var>)</i></dt>
  117. <dd><p>This function is the inverse of <code>avm_path_representation</code>, in that
  118. it takes a list representing a path to the path name expressed as a character
  119. string. This function can be used in C programs that invoke virtual code
  120. applications returning paths as part of their results, so that the C
  121. program can get the path into a character string in order to open the file.
  122. </p>
  123. <p>If the <code><var>path</var></code> parameter is <code>NULL</code>, a <code>NULL</code> pointer
  124. is returned as the result. The calling program should check for a
  125. <a name="index-standard-input-9"></a>
  126. <a name="index-standard-output-4"></a>
  127. <code>NULL</code> result and interpret it as the path to standard input or
  128. standard output.
  129. </p>
  130. <p>The memory needed for the character string whose address is returned is
  131. allocated by this function if possible. The given <code><var>path</var></code> is
  132. not required to be consistent with the host file system, but it is
  133. required to consist of representations of non-null printable characters
  134. or spaces as lists per <a href="Character-Table.html#Character-Table">Character Table</a>. In the event of any error
  135. or overflow, control does not return to the caller, but an error message
  136. is printed and the program is aborted. The possible error messages from
  137. this function are the following.
  138. <a name="index-counter-overflow-1"></a>
  139. <a name="index-memory-overflow-1"></a>
  140. <a name="index-null-character-in-file-name-1"></a>
  141. <a name="index-bad-character-in-file-name-1"></a>
  142. <a name="index-invalid-file-name"></a>
  143. </p>
  144. <ul>
  145. <li> <code><var>program-name</var>: counter overflow (code <var>nn</var>)</code>
  146. </li><li> <code><var>program-name</var>: memory overflow (code <var>nn</var>)</code>
  147. </li><li> <code><var>program-name</var>: null character in file name</code>
  148. </li><li> <code><var>program-name</var>: bad character in file name</code>
  149. </li><li> <code><var>program-name</var>: invalid file name (code <var>nn</var>)</code>
  150. </li></ul>
  151. </dd></dl>
  152. <dl>
  153. <dt><a name="index-avm_005finitialize_005ffnames"></a><u>Function:</u> void <b>avm_initialize_fnames</b><i> ()</i></dt>
  154. <dd><p>A few housekeeping operations relevant to internal data structures are
  155. performed by this function, making it necessary to be called by the
  156. client program prior to using any of the other ones.
  157. </p></dd></dl>
  158. <dl>
  159. <dt><a name="index-avm_005fcount_005ffnames"></a><u>Function:</u> void <b>avm_count_fnames</b><i> ()</i></dt>
  160. <dd><p>This function can be used after the the last call to any of the other
  161. functions in this section during a run, and it will detect memory leaks
  162. that may be attributable to code in these functions or misuse
  163. thereof. If any unreclaimed storage remains when this function is
  164. called, a warning message will be written to standard error. If the
  165. function <code>avm_count_lists</code> is also being used by the client, it
  166. should be called after this one.
  167. </p></dd></dl>
  168. <hr size="1">
  169. <table cellpadding="1" cellspacing="1" border="0">
  170. <tr><td valign="middle" align="left">[<a href="File-Manipulation.html#File-Manipulation" title="Previous section in reading order"> &lt; </a>]</td>
  171. <td valign="middle" align="left">[<a href="Raw-Files.html#Raw-Files" title="Next section in reading order"> &gt; </a>]</td>
  172. <td valign="middle" align="left"> &nbsp; </td>
  173. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  174. <td valign="middle" align="left">[<a href="File-Manipulation.html#File-Manipulation" title="Up section"> Up </a>]</td>
  175. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  176. <td valign="middle" align="left"> &nbsp; </td>
  177. <td valign="middle" align="left"> &nbsp; </td>
  178. <td valign="middle" align="left"> &nbsp; </td>
  179. <td valign="middle" align="left"> &nbsp; </td>
  180. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  181. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  182. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  183. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  184. </tr></table>
  185. <p>
  186. <font size="-1">
  187. This document was generated on <i>December 10, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  188. </font>
  189. <br>
  190. </p>
  191. </body>
  192. </html>