1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>db_env_set_func_file_map</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="setfunc.html" title="Appendix��3.�� Berkeley DB Application Space Static Functions" /> 11 <link rel="prev" href="db_env_set_func_exists.html" title="db_env_set_func_exists" /> 12 <link rel="next" href="db_env_set_func_free.html" title="db_env_set_func_free" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">db_env_set_func_file_map</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="db_env_set_func_exists.html">Prev</a>��</td> 22 <th width="60%" align="center">Appendix��3.�� 23 Berkeley DB Application Space Static Functions 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="db_env_set_func_free.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="db_env_set_func_file_map"></a>db_env_set_func_file_map</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41db_env_set_func_file_map(int (*func_file_map)(DB_ENV *dbenv, char *path, 42 size_t len, int is_rdonly, void **addr), 43 int (*func_file_unmap)(DB_ENV *dbenv, void *addr)); </pre> 44 <p> 45 The Berkeley DB library optionally uses the ability to map a file into 46 memory. 47 </p> 48 <p> 49 The <code class="function">db_env_set_func_file_map()</code> function configures all operations 50 performed by a process and all of its threads of control, not 51 operations confined to a single database environment. 52 </p> 53 <p> 54 Although the <code class="function">db_env_set_func_file_map()</code> function may be called at any time 55 during the life of the application, it should normally be called 56 before making calls to the <a class="xref" href="envcreate.html" title="db_env_create">db_env_create</a> or 57 <a class="xref" href="dbcreate.html" title="db_create">db_create</a> methods. 58 </p> 59 <p> 60 The <code class="function">db_env_set_func_file_map()</code> <span> 61 function returns a non-zero error value on failure and 0 on success. 62 </span> 63 </p> 64 <div class="sect2" lang="en" xml:lang="en"> 65 <div class="titlepage"> 66 <div> 67 <div> 68 <h3 class="title"><a id="id1718850"></a>Parameters</h3> 69 </div> 70 </div> 71 </div> 72 <div class="sect3" lang="en" xml:lang="en"> 73 <div class="titlepage"> 74 <div> 75 <div> 76 <h4 class="title"><a id="id1718978"></a>func_file_map</h4> 77 </div> 78 </div> 79 </div> 80 <p> 81 The <span class="bold"><strong>func_file_map</strong></span> parameter is the 82 function which maps a file into memory. The function takes 5 83 parameters: 84 </p> 85 <div class="itemizedlist"> 86 <ul type="disc"> 87 <li> 88 <p> 89 <span class="bold"><strong>dbenv</strong></span> 90 </p> 91 <p> 92 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 93 database environment handle. 94 </p> 95 </li> 96 <li> 97 <p> 98 <span class="bold"><strong>path</strong></span> 99 </p> 100 <p> 101 The <span class="bold"><strong>path</strong></span> parameter is the name of 102 file. Repeated requests for the mapping of the same name should 103 return a reference to the same memory. 104 </p> 105 </li> 106 <li> 107 <p> 108 <span class="bold"><strong>len</strong></span> 109 </p> 110 <p> 111 The <span class="bold"><strong>len</strong></span> parameter is the length, in 112 bytes, of the file. 113 </p> 114 </li> 115 <li> 116 <p> 117 <span class="bold"><strong>is_rdonly</strong></span> 118 </p> 119 <p> 120 The <span class="bold"><strong>is_rdonly</strong></span> parameter will be 121 non-zero if the mapped file is read-only. 122 </p> 123 </li> 124 <li> 125 <p> 126 <span class="bold"><strong>addr</strong></span> 127 </p> 128 <p> 129 The <span class="bold"><strong>addr</strong></span> parameter is the memory 130 location into which a pointer to the mapped file is returned. 131 </p> 132 </li> 133 </ul> 134 </div> 135 <p> 136 The <span class="bold"><strong>func_file_map</strong></span> function must 137 return the value of <span class="bold"><strong>errno</strong></span> on failure 138 and 0 on success. 139 </p> 140 </div> 141 <div class="sect3" lang="en" xml:lang="en"> 142 <div class="titlepage"> 143 <div> 144 <div> 145 <h4 class="title"><a id="id1719171"></a>func_file_unmap</h4> 146 </div> 147 </div> 148 </div> 149 <p> 150 The <span class="bold"><strong>func_file_unmap</strong></span> parameter is the 151 function which unmaps a file from memory. The function takes 2 152 parameters: 153 </p> 154 <div class="itemizedlist"> 155 <ul type="disc"> 156 <li> 157 <p> 158 <span class="bold"><strong>dbenv</strong></span> 159 </p> 160 <p> 161 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 162 database environment handle. 163 </p> 164 </li> 165 <li> 166 <p> 167 <code class="literal">addr</code> 168 </p> 169 <p> 170 The <span class="bold"><strong>addr</strong></span> parameter is the value 171 returned by the <span class="bold"><strong>func_file_map</strong></span> 172 function when the file or region was mapped into memory. 173 </p> 174 </li> 175 </ul> 176 </div> 177 </div> 178 </div> 179 <div class="sect2" lang="en" xml:lang="en"> 180 <div class="titlepage"> 181 <div> 182 <div> 183 <h3 class="title"><a id="id1719186"></a>See Also</h3> 184 </div> 185 </div> 186 </div> 187 <p> 188 <a href="../../programmer_reference/program_runtime.html" class="olink">Run-time configuration</a> 189 190 </p> 191 </div> 192 </div> 193 <div class="navfooter"> 194 <hr /> 195 <table width="100%" summary="Navigation footer"> 196 <tr> 197 <td width="40%" align="left"><a accesskey="p" href="db_env_set_func_exists.html">Prev</a>��</td> 198 <td width="20%" align="center"> 199 <a accesskey="u" href="setfunc.html">Up</a> 200 </td> 201 <td width="40%" align="right">��<a accesskey="n" href="db_env_set_func_free.html">Next</a></td> 202 </tr> 203 <tr> 204 <td width="40%" align="left" valign="top">db_env_set_func_exists��</td> 205 <td width="20%" align="center"> 206 <a accesskey="h" href="index.html">Home</a> 207 </td> 208 <td width="40%" align="right" valign="top">��db_env_set_func_free</td> 209 </tr> 210 </table> 211 </div> 212 </body> 213</html> 214