• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/router/db-4.8.30/docs/programmer_reference/
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>Chapter��20.�� Berkeley DB Extensions: Tcl</title>
7    <link rel="stylesheet" href="gettingStarted.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 Programmer's Reference Guide" />
10    <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
11    <link rel="prev" href="sequence.html" title="Chapter��19.�� Sequences" />
12    <link rel="next" href="tcl_using.html" title="Using Berkeley DB with Tcl" />
13  </head>
14  <body>
15    <div class="navheader">
16      <table width="100%" summary="Navigation header">
17        <tr>
18          <th colspan="3" align="center">Chapter��20.��
19		Berkeley DB Extensions: Tcl
20        </th>
21        </tr>
22        <tr>
23          <td width="20%" align="left"><a accesskey="p" href="sequence.html">Prev</a>��</td>
24          <th width="60%" align="center">��</th>
25          <td width="20%" align="right">��<a accesskey="n" href="tcl_using.html">Next</a></td>
26        </tr>
27      </table>
28      <hr />
29    </div>
30    <div class="chapter" lang="en" xml:lang="en">
31      <div class="titlepage">
32        <div>
33          <div>
34            <h2 class="title"><a id="tcl"></a>Chapter��20.��
35		Berkeley DB Extensions: Tcl
36        </h2>
37          </div>
38        </div>
39      </div>
40      <div class="toc">
41        <p>
42          <b>Table of Contents</b>
43        </p>
44        <dl>
45          <dt>
46            <span class="sect1">
47              <a href="tcl.html#tcl_intro">Loading Berkeley DB with Tcl</a>
48            </span>
49          </dt>
50          <dd>
51            <dl>
52              <dt>
53                <span class="sect2">
54                  <a href="tcl.html#id1625703">Installing as a Tcl Package</a>
55                </span>
56              </dt>
57              <dt>
58                <span class="sect2">
59                  <a href="tcl.html#id1625472">Loading Berkeley DB with Tcl</a>
60                </span>
61              </dt>
62            </dl>
63          </dd>
64          <dt>
65            <span class="sect1">
66              <a href="tcl_using.html">Using Berkeley DB with Tcl</a>
67            </span>
68          </dt>
69          <dt>
70            <span class="sect1">
71              <a href="tcl_program.html">Tcl API programming notes</a>
72            </span>
73          </dt>
74          <dt>
75            <span class="sect1">
76              <a href="tcl_error.html">Tcl error handling</a>
77            </span>
78          </dt>
79          <dt>
80            <span class="sect1">
81              <a href="tcl_faq.html">Tcl FAQ</a>
82            </span>
83          </dt>
84        </dl>
85      </div>
86      <div class="sect1" lang="en" xml:lang="en">
87        <div class="titlepage">
88          <div>
89            <div>
90              <h2 class="title" style="clear: both"><a id="tcl_intro"></a>Loading Berkeley DB with Tcl</h2>
91            </div>
92          </div>
93        </div>
94        <div class="toc">
95          <dl>
96            <dt>
97              <span class="sect2">
98                <a href="tcl.html#id1625703">Installing as a Tcl Package</a>
99              </span>
100            </dt>
101            <dt>
102              <span class="sect2">
103                <a href="tcl.html#id1625472">Loading Berkeley DB with Tcl</a>
104              </span>
105            </dt>
106          </dl>
107        </div>
108        <p>Berkeley DB includes a dynamically loadable Tcl API, which requires that
109Tcl/Tk 8.4 or later already be installed on your system.  You can
110download a copy of Tcl from the <a class="ulink" href="http://www.tcl.tk" target="_top">Tcl
111Developer Xchange</a> Web site.</p>
112        <p>This document assumes that you already configured Berkeley DB for Tcl
113support, and you have built and installed everything where you want it
114to be.  If you have not done so, see
115<a class="xref" href="build_unix_conf.html" title="Configuring Berkeley DB">Configuring Berkeley DB</a> or
116<a class="xref" href="build_win_tcl.html" title="Building the Tcl API">Building the Tcl API</a> for more
117information.</p>
118        <div class="sect2" lang="en" xml:lang="en">
119          <div class="titlepage">
120            <div>
121              <div>
122                <h3 class="title"><a id="id1625703"></a>Installing as a Tcl Package</h3>
123              </div>
124            </div>
125          </div>
126          <p>Once enabled, the Berkeley DB shared library for Tcl is automatically installed
127as part of the standard installation process.  However, if you want to be
128able to dynamically load it as a Tcl package into your script, there are
129several steps that must be performed:</p>
130          <div class="orderedlist">
131            <ol type="1">
132              <li>Run the Tcl shell in the install directory.</li>
133              <li>Append this directory to your auto_path variable.</li>
134              <li>Run the pkg_mkIndex proc, giving the name of the Berkeley DB Tcl library.</li>
135            </ol>
136          </div>
137          <p>For example:</p>
138          <pre class="programlisting"># tclsh8.4
139% lappend auto_path /usr/local/BerkeleyDB.4.8/lib
140% pkg_mkIndex /usr/local/BerkeleyDB.4.8/lib libdb_tcl-4.8.so</pre>
141          <p>Note that your Tcl and Berkeley DB version numbers may differ from the
142example, and so your tclsh and library names may be different.</p>
143        </div>
144        <div class="sect2" lang="en" xml:lang="en">
145          <div class="titlepage">
146            <div>
147              <div>
148                <h3 class="title"><a id="id1625472"></a>Loading Berkeley DB with Tcl</h3>
149              </div>
150            </div>
151          </div>
152          <p>The Berkeley DB package may be loaded into the user's interactive Tcl script
153(or wish session) via the <span class="bold"><strong>load</strong></span> command. For example:</p>
154          <pre class="programlisting">load /usr/local/BerkeleyDB.4.8/lib/libdb_tcl-4.8.so</pre>
155          <p>Note that your Berkeley DB version numbers may differ from the example, and so
156the library name may be different.</p>
157          <p>If you installed your library to run as a Tcl package, Tcl application
158scripts should use the <span class="bold"><strong>package</strong></span> command to indicate to the Tcl
159interpreter that it needs the Berkeley DB package and where to find it. For
160example:</p>
161          <pre class="programlisting">lappend auto_path "/usr/local/BerkeleyDB.4.8/lib"
162package require Db_tcl</pre>
163          <p>No matter which way the library gets loaded, it creates a command named
164<span class="bold"><strong>berkdb</strong></span>.  All the Berkeley DB functionality is accessed via this
165command and additional commands it creates on behalf of the application.
166A simple test to determine whether everything is loaded and ready is to
167display the library version, as follows:</p>
168          <pre class="programlisting">berkdb version -string</pre>
169          <p>This should return you the Berkeley DB version in a string format.</p>
170        </div>
171      </div>
172    </div>
173    <div class="navfooter">
174      <hr />
175      <table width="100%" summary="Navigation footer">
176        <tr>
177          <td width="40%" align="left"><a accesskey="p" href="sequence.html">Prev</a>��</td>
178          <td width="20%" align="center">��</td>
179          <td width="40%" align="right">��<a accesskey="n" href="tcl_using.html">Next</a></td>
180        </tr>
181        <tr>
182          <td width="40%" align="left" valign="top">Chapter��19.��
183		Sequences
184        ��</td>
185          <td width="20%" align="center">
186            <a accesskey="h" href="index.html">Home</a>
187          </td>
188          <td width="40%" align="right" valign="top">��Using Berkeley DB with Tcl</td>
189        </tr>
190      </table>
191    </div>
192  </body>
193</html>
194