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: #ifndef lint
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
delete
defined in line
59; used 27 times
- in /usr/ingres/source/dbu/btreeupdate.c line
181
- in /usr/ingres/source/dbu/destroy.c line
107
- in /usr/ingres/source/dbu/modupdate.c line
144
- in /usr/ingres/source/dbu/purgetup.c line
35
- in /usr/ingres/source/dbu/rmqm.c line
376,
451,
507
- in /usr/ingres/source/dbu/secupdate.c line
145
- in /usr/ingres/source/dbu/udestroy.c line
68,
114
- in /usr/ingres/source/dbu/update.c line
225
- in /usr/ingres/source/ovqp/scan.c line
324
- in /usr/ingres/source/parser/tree.c line
917
- in /usr/ingres/source/support/restore.c line
377,
430,
478,
503,
602,
669,
877,
905,
975,
992,
1066,
1083
- in /usr/src/new/dipress/src/bin/maha/maha.c line
465,
485
fetch
defined in line
45; used 28 times
- in /usr/include/dbm.h line
20
- in /usr/src/new/X/X/dispatch.c line
1240
- in /usr/src/new/X/X/main.c line
834,
849
- in /usr/src/new/news/misc/article.c line
25,
92
- in /usr/src/new/news/src/funcs2.c line
405,
426
- in /usr/src/new/news/src/ifuncs.c line
475,
497
- in /usr/src/new/nntp/rrn/bits.c line
301,
347
- in /usr/src/new/nntp/server/misc.c line
93,
128
- in /usr/src/new/rn/bits.c line
301,
347
- in /usr/src/ucb/vacation.c line
68,
286
- in /usr/src/usr.lib/libdbm/dbm.h line
20
- in /usr/src/usr.lib/sendmail/aux/praliases.c line
6,
26,
34
- in /usr/src/usr.lib/sendmail/aux/showdbm.c line
6,
26,
34
- in /usr/src/usr.lib/sendmail/include/userdbm.h line
14
- in /usr/src/usr.lib/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