• 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/tcl/docs/
1<!--Copyright 1999-2009 Oracle.  All rights reserved.-->
2<HTML>
3<HEAD>
4   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
5   <META NAME="GENERATOR" CONTENT="Mozilla/4.08 [en] (X11; I; FreeBSD 2.2.8-19990120-SNAP i386) [Netscape]">
6</HEAD>
7<BODY>
8
9<H2>
10<A NAME="Compatibility Commands"></A>Compatibility Commands</H2>
11The compatibility commands for old Dbm and Ndbm are described in the <A HREF="../../docs/api_c/dbm.html">dbm</A>
12manpage.
13<P><B>> berkdb dbminit <I>filename</I></B>
14<P>This command will invoke the dbminit function.&nbsp;&nbsp; <B><I>Filename</I></B>
15is used as the name of the database.
16<P>
17<HR WIDTH="100%"><B>> berkdb dbmclose</B>
18<P>This command will invoke the dbmclose function.
19<P>
20<HR WIDTH="100%"><B>> berkdb fetch <I>key</I></B>
21<P>This command will invoke the fetch function.&nbsp;&nbsp; It will return
22the data associated with the given <B><I>key </I></B>or a Tcl error.
23<P>
24<HR WIDTH="100%"><B>> berkdb store <I>key data</I></B>
25<P>This command will invoke the store function.&nbsp;&nbsp; It will store
26the <B><I>key/data</I></B> pair.&nbsp; It will return a 0 on success or
27throw a Tcl error.
28<P>
29<HR WIDTH="100%"><B>> berkdb delete <I>key</I></B>
30<P>This command will invoke the deletet function.&nbsp;&nbsp; It will delete
31the <B><I>key</I></B> from the database.&nbsp; It will return a 0 on success
32or throw a Tcl error.
33<P>
34<HR WIDTH="100%"><B>> berkdb firstkey</B>
35<P>This command will invoke the firstkey function.&nbsp;&nbsp; It will
36return the first key in the database or a Tcl error.
37<P>
38<HR WIDTH="100%"><B>> berkdb nextkey <I>key</I></B>
39<P>This command will invoke the nextkey function.&nbsp;&nbsp; It will return
40the next key after the given <B><I>key</I></B> or a Tcl error.
41<P>
42<HR WIDTH="100%"><B>> berkdb hcreate <I>nelem</I></B>
43<P>This command will invoke the hcreate function with <B><I>nelem</I></B>
44elements.&nbsp; It will return a 0 on success or a Tcl error.
45<P>
46<HR WIDTH="100%"><B>> berkdb hsearch <I>key data action</I></B>
47<P>This command will invoke the hsearch function with <B><I>key</I></B>
48and <B><I>data</I></B>.&nbsp; The <B><I>action</I></B> must be either <B>find</B>
49or <B>enter</B>.&nbsp; If it is <B>find</B>, it will return the resultant
50data.&nbsp; If it is <B>enter</B>, it will return a 0 on success or a Tcl
51error.
52<P>
53<HR WIDTH="100%"><B>> berkdb hdestroy</B>
54<P>This command will invoke the hdestroy function.&nbsp; It will return
55a 0.
56<HR WIDTH="100%"><B>> berkdb ndbm_open [-create] [-rdonly] [-truncate]
57[-mode
58<I>mode</I>] [--] <I>filename</I></B>
59<P>This command will invoke the dbm_open function.&nbsp;&nbsp;&nbsp; After
60it successfully gets a handle to a database, we bind it to a new Tcl command
61of the form <B><I>ndbmX, </I></B>where X is an integer starting at 0 (e.g.
62<B>ndbm0,
63ndbm1, </B>etc).&nbsp; We use the <I>Tcl_CreateObjCommand()&nbsp;</I> to
64create the top level database function.&nbsp; It is through this handle
65that the user can access all of the commands described below.&nbsp; Internally,
66the database handle is sent as the <I>ClientData</I> portion of the new
67command set so that all future database calls access the appropriate handle.
68<P>The arguments are:
69<UL>
70<LI>
71<B>-- </B>- Terminate the list of options and use remaining arguments as
72the file or subdb names (thus allowing the use of filenames beginning with
73a dash '-')</LI>
74
75<LI>
76<B>-create</B> selects the O_CREAT flag&nbsp; to create underlying files</LI>
77
78<LI>
79<B>-rdonly</B> selects the O_RDONLY flag for opening in read-only mode</LI>
80
81<LI>
82<B>-truncate</B> selects the O_TRUNC flag to truncate the database</LI>
83
84<LI>
85<B>-mode<I> mode</I></B> specifies the mode for created files</LI>
86
87<LI>
88<B><I>filename</I></B> indicates the name of the database</LI>
89</UL>
90
91<P><BR>
92<HR WIDTH="100%">
93<BR><B>> &lt;ndbm> close</B>
94<P>This command closes the database and renders the handle invalid.&nbsp;&nbsp;
95This command directly translates to the dbm_close function call.&nbsp;
96It returns either a 0 (for success),&nbsp; or it throws a Tcl error with
97a system message.
98<P>Additionally, since the handle is no longer valid, we will call <I>Tcl_DeleteCommand()
99</I>so
100that further uses of the handle will be dealt with properly by Tcl itself.&nbsp;
101<HR WIDTH="100%">
102<BR><B>> &lt;ndbm> clearerr</B>
103<P>This command clears errors&nbsp; the database.&nbsp;&nbsp; This command
104directly translates to the dbm_clearerr function call.&nbsp; It returns
105either a 0 (for success),&nbsp; or it throws a Tcl error with a system
106message.
107<P>
108<HR WIDTH="100%">
109<BR><B>> &lt;ndbm> delete <I>key</I></B>
110<P>This command deletes the <B><I>key</I></B> from thedatabase.&nbsp;&nbsp;
111This command directly translates to the dbm_delete function call.&nbsp;
112It returns either a 0 (for success),&nbsp; or it throws a Tcl error with
113a system message.
114<P>
115<HR WIDTH="100%">
116<BR><B>> &lt;ndbm> dirfno</B>
117<P>This command directly translates to the dbm_dirfno function call.&nbsp;
118It returns either resultts,&nbsp; or it throws a Tcl error with a system
119message.
120<P>
121<HR WIDTH="100%">
122<BR><B>> &lt;ndbm> error</B>
123<P>This command returns the last error.&nbsp;&nbsp; This command directly
124translates to the dbm_error function call.&nbsp; It returns an error string..
125<P>
126<HR WIDTH="100%">
127<BR><B>> &lt;ndbm> fetch <I>key</I></B>
128<P>This command gets the given <B><I>key</I></B> from the database.&nbsp;&nbsp;
129This command directly translates to the dbm_fetch function call.&nbsp;
130It returns either the data,&nbsp; or it throws a Tcl error with a system
131message.
132<P>
133<HR WIDTH="100%">
134<BR><B>> &lt;ndbm> firstkey</B>
135<P>This command returns the first key in the database.&nbsp;&nbsp; This
136command directly translates to the dbm_firstkey function call.&nbsp; It
137returns either the key,&nbsp; or it throws a Tcl error with a system message.
138<P>
139<HR WIDTH="100%">
140<BR><B>> &lt;ndbm> nextkey</B>
141<P>This command returns the next key in the database.&nbsp;&nbsp; This
142command directly translates to the dbm_nextkey function call.&nbsp; It
143returns either the key,&nbsp; or it throws a Tcl error with a system message.
144<P>
145<HR WIDTH="100%">
146<BR><B>> &lt;ndbm> pagfno</B>
147<P>This command directly translates to the dbm_pagfno function call.&nbsp;
148It returns either resultts,&nbsp; or it throws a Tcl error with a system
149message.
150<BR>
151<HR WIDTH="100%">
152<BR><B>> &lt;ndbm> rdonly</B>
153<P>This command changes the database to readonly.&nbsp;&nbsp; This command
154directly translates to the dbm_rdonly function call.&nbsp; It returns either
155a 0 (for success),&nbsp; or it throws a Tcl error with a system message.
156<P>
157<HR WIDTH="100%">
158<BR><B>> &lt;ndbm> store <I>key data </I>insert|replace</B>
159<P>This command puts the given <B><I>key</I></B> and <B><I>data</I></B>
160pair into the database.&nbsp;&nbsp; This command directly translates to
161the dbm_store function call.&nbsp; It will either <B>insert</B> or <B>replace</B>
162the data based on the action given in the third argument.&nbsp; It returns
163either a 0 (for success),&nbsp; or it throws a Tcl error with a system
164message.
165<BR>
166<HR WIDTH="100%">
167</BODY>
168</HTML>
169