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::set_msgcall()</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="db.html" title="Chapter 2. The Db Handle" /> 11 <link rel="prev" href="dbset_message_stream.html" title="Db::set_message_stream()" /> 12 <link rel="next" href="dbset_msgfile.html" title="Db::set_msgfile()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">Db::set_msgcall()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbset_message_stream.html">Prev</a> </td> 22 <th width="60%" align="center">Chapter 2. 23 The Db Handle 24 </th> 25 <td width="20%" align="right"> <a accesskey="n" href="dbset_msgfile.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="dbset_msgcall"></a>Db::set_msgcall()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40void Db::set_msgcall(void (*db_msgcall_fcn)(const DbEnv *dbenv, char *msg));</pre> 41 <p> 42 There are interfaces in the Berkeley DB library which either directly 43 output informational messages or statistical information, or configure 44 the library to output such messages when performing other operations, 45 for example, <a class="xref" href="envset_verbose.html" title="DbEnv::set_verbose()">DbEnv::set_verbose()</a> and 46 <a class="xref" href="envstat.html" title="DbEnv::stat_print()">DbEnv::stat_print()</a>. 47 </p> 48 <p> 49 The <a class="xref" href="envset_msgcall.html" title="DbEnv::set_msgcall()">DbEnv::set_msgcall()</a> and 50 <code class="methodname">Db::set_msgcall()</code> methods are used to 51 pass these messages to the application, and Berkeley DB will call 52 <span class="bold"><strong>db_msgcall_fcn</strong></span> with each message. It 53 is up to the <span class="bold"><strong>db_msgcall_fcn</strong></span> function 54 to display the message in an appropriate manner. 55 </p> 56 <p> 57 Setting <span class="bold"><strong>db_msgcall_fcn</strong></span> to NULL 58 unconfigures the callback interface. 59 </p> 60 <p> 61 Alternatively, you can use the 62 <span> 63 <a class="xref" href="envset_error_stream.html" title="DbEnv::set_error_stream()">DbEnv::set_error_stream()</a> 64 and 65 <a class="xref" href="dbset_error_stream.html" title="Db::set_error_stream()">Db::set_error_stream()</a> 66 methods to display the messages via an output stream, or the 67 </span> 68 <a class="xref" href="dbset_msgfile.html" title="Db::set_msgfile()">Db::set_msgfile()</a> or 69 <a class="xref" href="envset_msgfile.html" title="DbEnv::set_msgfile()">Db::set_msgfile()</a> 70 methods to display the messages via a C library FILE *. 71 <span>You should not mix these approaches.</span> 72 </p> 73 <p> 74 For <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handles opened 75 inside of Berkeley DB environments, calling the <code class="methodname">Db::set_msgcall()</code> 76 method affects the entire environment and is equivalent to calling the 77 <code class="methodname">DbEnv::set_msgcall()</code> method. 78 </p> 79 <p> 80 The <code class="methodname">Db::set_msgcall()</code> method configures operations performed using 81 the specified <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handle, 82 not all operations performed on the underlying database. 83 </p> 84 <p> 85 The <code class="methodname">Db::set_msgcall()</code> method may be called at any time during the 86 life of the application. 87 </p> 88 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> 89 <h3 class="title">Note</h3> 90 <p> 91 Berkeley DB is not re-entrant. Callback functions should not attempt to make 92 library calls (for example, to release locks or close open handles). Re-entering 93 Berkeley DB is not guaranteed to work correctly, and the results are undefined. 94 </p> 95 </div> 96 <div class="sect2" lang="en" xml:lang="en"> 97 <div class="titlepage"> 98 <div> 99 <div> 100 <h3 class="title"><a id="id1649036"></a>Parameters</h3> 101 </div> 102 </div> 103 </div> 104 <div class="sect3" lang="en" xml:lang="en"> 105 <div class="titlepage"> 106 <div> 107 <div> 108 <h4 class="title"><a id="id1649330"></a>db_msgcall_fcn</h4> 109 </div> 110 </div> 111 </div> 112 <p> 113 The <span class="bold"><strong>db_msgcall_fcn</strong></span> parameter is the 114 application-specified message reporting function. The function takes 115 two parameters: 116 </p> 117 <div class="itemizedlist"> 118 <ul type="disc"> 119 <li> 120 <p> 121 <code class="literal">dbenv</code> 122 </p> 123 <p> 124 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 125 database environment. 126 </p> 127 </li> 128 <li> 129 <p> 130 <code class="literal">msg</code> 131 </p> 132 <p> 133 The <span class="bold"><strong>msg</strong></span> parameter is the message 134 string. 135 </p> 136 </li> 137 </ul> 138 </div> 139 </div> 140 </div> 141 <div class="sect2" lang="en" xml:lang="en"> 142 <div class="titlepage"> 143 <div> 144 <div> 145 <h3 class="title"><a id="id1649605"></a>Class</h3> 146 </div> 147 </div> 148 </div> 149 <p> 150 <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> 151 </p> 152 </div> 153 <div class="sect2" lang="en" xml:lang="en"> 154 <div class="titlepage"> 155 <div> 156 <div> 157 <h3 class="title"><a id="id1649745"></a>See Also</h3> 158 </div> 159 </div> 160 </div> 161 <p> 162 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 163 </p> 164 </div> 165 </div> 166 <div class="navfooter"> 167 <hr /> 168 <table width="100%" summary="Navigation footer"> 169 <tr> 170 <td width="40%" align="left"><a accesskey="p" href="dbset_message_stream.html">Prev</a> </td> 171 <td width="20%" align="center"> 172 <a accesskey="u" href="db.html">Up</a> 173 </td> 174 <td width="40%" align="right"> <a accesskey="n" href="dbset_msgfile.html">Next</a></td> 175 </tr> 176 <tr> 177 <td width="40%" align="left" valign="top">Db::set_message_stream() </td> 178 <td width="20%" align="center"> 179 <a accesskey="h" href="index.html">Home</a> 180 </td> 181 <td width="40%" align="right" valign="top"> Db::set_msgfile()</td> 182 </tr> 183 </table> 184 </div> 185 </body> 186</html> 187