1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved. The Berkeley software License Agreement
4: * specifies the terms and conditions for redistribution.
5: */
6:
7: #if !defined(lint) && !defined(NOSCCS)
8: static char sccsid[] = "@(#)dbm.c 5.3 (Berkeley) 85/08/15";
9: #endif not lint
10:
11: #include "dbm.h"
12:
13: #define NODB ((DBM *)0)
14:
15: static DBM *cur_db = NODB;
16:
17: static char no_db[] = "dbm: no open database\n";
18:
19: dbminit(file)
20: char *file;
21: {
22: if (cur_db != NODB)
23: dbm_close(cur_db);
24:
25: cur_db = dbm_open(file, 2, 0);
26: if (cur_db == NODB) {
27: cur_db = dbm_open(file, 0, 0);
28: if (cur_db == NODB)
29: return (-1);
30: }
31: return (0);
32: }
33:
34: long
35: forder(key)
36: datum key;
37: {
38: if (cur_db == NODB) {
39: printf(no_db);
40: return (0L);
41: }
42: return (dbm_forder(cur_db, key));
43: }
44:
45: datum
46: fetch(key)
47: datum key;
48: {
49: datum item;
50:
51: if (cur_db == NODB) {
52: printf(no_db);
53: item.dptr = 0;
54: return (item);
55: }
56: return (dbm_fetch(cur_db, key));
57: }
58:
59: delete(key)
60: datum key;
61: {
62: if (cur_db == NODB) {
63: printf(no_db);
64: return (-1);
65: }
66: if (dbm_rdonly(cur_db))
67: return (-1);
68: return (dbm_delete(cur_db, key));
69: }
70:
71: store(key, dat)
72: datum key, dat;
73: {
74: if (cur_db == NODB) {
75: printf(no_db);
76: return (-1);
77: }
78: if (dbm_rdonly(cur_db))
79: return (-1);
80:
81: return (dbm_store(cur_db, key, dat, DBM_REPLACE));
82: }
83:
84: datum
85: firstkey()
86: {
87: datum item;
88:
89: if (cur_db == NODB) {
90: printf(no_db);
91: item.dptr = 0;
92: return (item);
93: }
94: return (dbm_firstkey(cur_db));
95: }
96:
97: datum
98: nextkey(key)
99: datum key;
100: {
101: datum item;
102:
103: if (cur_db == NODB) {
104: printf(no_db);
105: item.dptr = 0;
106: return (item);
107: }
108: return (dbm_nextkey(cur_db, key));
109: }
Defined functions
fetch
defined in line
45; used 25 times
- in /usr/include/dbm.h line
20
- in /usr/src/include/dbm.h line
20
- in /usr/src/new/nntp/server/misc.c line
111,
170
- in /usr/src/new/nntp/xfer/nntpxfer.c line
493
- in /usr/src/new/rn/bits.c line
314,
360
- in /usr/src/ucb/vacation.c line
69,
287
- in /usr/src/usr.lib/libdbm/dbm.h line
20
- in /usr/src/usr.sbin/sendmail.MX/aux/praliases.c line
35,
55,
61
- in /usr/src/usr.sbin/sendmail.MX/include/userdbm.h line
20
- in /usr/src/usr.sbin/sendmail.MX/src/alias.c line
67,
141
- in /usr/src/usr.sbin/sendmail/aux/praliases.c line
6,
26,
34
- in /usr/src/usr.sbin/sendmail/aux/showdbm.c line
6,
26,
34
- in /usr/src/usr.sbin/sendmail/include/userdbm.h line
14
- in /usr/src/usr.sbin/sendmail/src/alias.c line
64,
138
store
defined in line
71; used 8 times
Defined variables
no_db
defined in line
17; used 6 times
sccsid
defined in line
8;
never used
Defined macros
NODB
defined in line
13; used 10 times