Deleted Added
full compact
ndbm.c (14287) ndbm.c (17235)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 78 unchanged lines hidden (view full) ---

87 * DATUM on success
88 * NULL on failure
89 */
90extern datum
91dbm_fetch(db, key)
92 DBM *db;
93 datum key;
94{
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Margo Seltzer.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 78 unchanged lines hidden (view full) ---

87 * DATUM on success
88 * NULL on failure
89 */
90extern datum
91dbm_fetch(db, key)
92 DBM *db;
93 datum key;
94{
95 datum retval;
95 datum retdata;
96 int status;
96 int status;
97 DBT dbtkey, dbtretdata;
97
98
98 status = (db->get)(db, (DBT *)&key, (DBT *)&retval, 0);
99 dbtkey.data = key.dptr;
100 dbtkey.size = key.dsize;
101 status = (db->get)(db, &dbtkey, &dbtretdata, 0);
99 if (status) {
102 if (status) {
100 retval.dptr = NULL;
101 retval.dsize = 0;
103 dbtretdata.data = NULL;
104 dbtretdata.size = 0;
102 }
105 }
103 return (retval);
106 retdata.dptr = dbtretdata.data;
107 retdata.dsize = dbtretdata.size;
108 return (retdata);
104}
105
106/*
107 * Returns:
108 * DATUM on success
109 * NULL on failure
110 */
111extern datum
112dbm_firstkey(db)
113 DBM *db;
114{
115 int status;
109}
110
111/*
112 * Returns:
113 * DATUM on success
114 * NULL on failure
115 */
116extern datum
117dbm_firstkey(db)
118 DBM *db;
119{
120 int status;
116 datum retdata, retkey;
121 datum retkey;
122 DBT dbtretkey, dbtretdata;
117
123
118 status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_FIRST);
124 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
119 if (status)
125 if (status)
120 retkey.dptr = NULL;
126 dbtretkey.data = NULL;
127 retkey.dptr = dbtretkey.data;
128 retkey.dsize = dbtretkey.size;
121 return (retkey);
122}
123
124/*
125 * Returns:
126 * DATUM on success
127 * NULL on failure
128 */
129extern datum
130dbm_nextkey(db)
131 DBM *db;
132{
133 int status;
129 return (retkey);
130}
131
132/*
133 * Returns:
134 * DATUM on success
135 * NULL on failure
136 */
137extern datum
138dbm_nextkey(db)
139 DBM *db;
140{
141 int status;
134 datum retdata, retkey;
142 datum retkey;
143 DBT dbtretkey, dbtretdata;
135
144
136 status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_NEXT);
145 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
137 if (status)
146 if (status)
138 retkey.dptr = NULL;
147 dbtretkey.data = NULL;
148 retkey.dptr = dbtretkey.data;
149 retkey.dsize = dbtretkey.size;
139 return (retkey);
140}
150 return (retkey);
151}
152
141/*
142 * Returns:
143 * 0 on success
144 * <0 failure
145 */
146extern int
147dbm_delete(db, key)
148 DBM *db;
149 datum key;
150{
151 int status;
153/*
154 * Returns:
155 * 0 on success
156 * <0 failure
157 */
158extern int
159dbm_delete(db, key)
160 DBM *db;
161 datum key;
162{
163 int status;
164 DBT dbtkey;
152
165
153 status = (db->del)(db, (DBT *)&key, 0);
166 dbtkey.data = key.dptr;
167 dbtkey.size = key.dsize;
168 status = (db->del)(db, &dbtkey, 0);
154 if (status)
155 return (-1);
156 else
157 return (0);
158}
159
160/*
161 * Returns:
162 * 0 on success
163 * <0 failure
164 * 1 if DBM_INSERT and entry exists
165 */
166extern int
169 if (status)
170 return (-1);
171 else
172 return (0);
173}
174
175/*
176 * Returns:
177 * 0 on success
178 * <0 failure
179 * 1 if DBM_INSERT and entry exists
180 */
181extern int
167dbm_store(db, key, content, flags)
182dbm_store(db, key, data, flags)
168 DBM *db;
183 DBM *db;
169 datum key, content;
184 datum key, data;
170 int flags;
171{
185 int flags;
186{
172 return ((db->put)(db, (DBT *)&key, (DBT *)&content,
187 DBT dbtkey, dbtdata;
188
189 dbtkey.data = key.dptr;
190 dbtkey.size = key.dsize;
191 dbtdata.data = data.dptr;
192 dbtdata.size = data.dsize;
193 return ((db->put)(db, &dbtkey, &dbtdata,
173 (flags == DBM_INSERT) ? R_NOOVERWRITE : 0));
174}
175
176extern int
177dbm_error(db)
178 DBM *db;
179{
180 HTAB *hp;

--- 22 unchanged lines hidden ---
194 (flags == DBM_INSERT) ? R_NOOVERWRITE : 0));
195}
196
197extern int
198dbm_error(db)
199 DBM *db;
200{
201 HTAB *hp;

--- 22 unchanged lines hidden ---