1 .\" Copyright (c) 1999 Tim Singletary
2 .\" No copyright is claimed.
4 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
5 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
8 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
9 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
10 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
11 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
12 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
13 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
16 .\" $FreeBSD: src/lib/libc/db/man/dbm.3,v 1.10 2009/01/30 15:28:35 gabor Exp $
32 .Nd database access functions
71 .Fa "const char *file"
73 .Fa "mode_t file_mode"
83 Database access functions.
84 These functions are implemented using
101 .Fn dbm_open file open_flags file_mode
103 opens or creates a database file.
107 is the basename of the file containing
108 the database; the actual database has a
114 .Qq Li /home/me/mystuff
115 then the actual database is in the file
116 .Pa /home/me/mystuff.db .
124 .Pq Dv O_RDWR | O_CREAT
125 is a typical value for
128 is a typical value for
133 The pointer returned by
135 identifies the database and is the
137 argument to the other functions.
145 if there were any errors.
153 .Fn dbm_store db key content store_mode
155 inserts or replaces an entry in the database.
167 and the database already contains an entry for
169 that entry is not replaced.
170 Otherwise the entry is replaced or inserted.
174 normally returns zero but returns 1 if the entry could not be
181 already exists) or returns -1 and sets
183 if there were any errors.
196 .Fn dbm_delete db key
198 deletes the entry for
203 normally returns zero but returns 1 if there was no entry with
205 in the database or returns -1 and sets
207 if there were any errors.
212 returns the first key in the database.
216 returns subsequent keys.
220 must be called before
222 The order in which keys are returned is unspecified and may appear
229 after all keys have been returned.
236 value of the most recent error.
240 resets this value to 0 and returns 0.
245 returns the file descriptor to the database.
247 .Fd #include <fcntl.h>
248 .Fd #include <ndbm.h>
252 is necessary for all functions.
257 .Fa "const char *file"
271 These functions (except