2 * Copyright (c) 1985 The Regents of the University of California.
5 * Redistribution and use in source and binary forms are permitted
6 * provided that the above copyright notice and this notice are
7 * duplicated in all such forms.
9 * [additional clause stricken -- see below]
11 * The name of the University may not be used to endorse or promote
12 * products derived from this software without specific prior written
13 * permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * This notice previously contained the additional clause:
20 * and that any documentation, advertising materials, and other
21 * materials related to such distribution and use acknowledge that
22 * the software was developed by the University of California,
25 * Pursuant to the licensing change made by the Office of Technology
26 * Licensing of the University of California, Berkeley on July 22,
27 * 1999 and documented in:
29 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
31 * this clause has been stricken and no longer is applicable to this
36 static char sccsid[] = "@(#)dbm.c 5.4 (Berkeley) 5/24/89";
41 #define NODB ((DBM *)0)
43 static DBM *cur_db = NODB;
45 static char no_db[] = "dbm: no open database\n";
53 cur_db = dbm_open(file, 2, 0);
55 cur_db = dbm_open(file, 0, 0);
69 return (dbm_forder(cur_db, key));
82 return (dbm_fetch(cur_db, key));
92 if (dbm_rdonly(cur_db))
94 return (dbm_delete(cur_db, key));
98 store(datum key, datum dat)
100 if (cur_db == NODB) {
104 if (dbm_rdonly(cur_db))
107 return (dbm_store(cur_db, key, dat, DBM_REPLACE));
115 if (cur_db == NODB) {
120 return (dbm_firstkey(cur_db));
128 if (cur_db == NODB) {
133 return (dbm_nextkey(cur_db, key));