Deleted Added
full compact
smndbm.c (66494) smndbm.c (71345)
1/*
2** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers.
3** All rights reserved.
4**
5** By using this file, you agree to the terms and conditions set
6** forth in the LICENSE file which can be found at the top level of
7** the sendmail distribution.
8*/
9
10#ifndef lint
1/*
2** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers.
3** All rights reserved.
4**
5** By using this file, you agree to the terms and conditions set
6** forth in the LICENSE file which can be found at the top level of
7** the sendmail distribution.
8*/
9
10#ifndef lint
11static char id[] = "@(#)$Id: smndbm.c,v 8.40.4.1 2000/08/24 17:08:00 gshapiro Exp $";
11static char id[] = "@(#)$Id: smndbm.c,v 8.40.4.3 2000/10/05 22:27:50 gshapiro Exp $";
12#endif /* ! lint */
13
14#include <fcntl.h>
15#include <stdlib.h>
16#include <unistd.h>
17
18#include <sendmail/sendmail.h>
19#include <libsmdb/smdb.h>

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

119int
120smdbm_del(database, key, flags)
121 SMDB_DATABASE *database;
122 SMDB_DBENT *key;
123 u_int flags;
124{
125 int result;
126 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
12#endif /* ! lint */
13
14#include <fcntl.h>
15#include <stdlib.h>
16#include <unistd.h>
17
18#include <sendmail/sendmail.h>
19#include <libsmdb/smdb.h>

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

119int
120smdbm_del(database, key, flags)
121 SMDB_DATABASE *database;
122 SMDB_DBENT *key;
123 u_int flags;
124{
125 int result;
126 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
127 datum dbkey;
127
128
129 memset(&dbkey, '\0', sizeof dbkey);
130 dbkey.dptr = key->data;
131 dbkey.dsize = key->size;
132
128 errno = 0;
133 errno = 0;
129 result = dbm_delete(dbm, key->dbm);
134 result = dbm_delete(dbm, dbkey);
130 if (result != 0)
131 {
132 int save_errno = errno;
133
134 if (dbm_error(dbm))
135 return SMDBE_IO_ERROR;
136
137 if (save_errno != 0)

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

168int
169smdbm_get(database, key, data, flags)
170 SMDB_DATABASE *database;
171 SMDB_DBENT *key;
172 SMDB_DBENT *data;
173 u_int flags;
174{
175 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
135 if (result != 0)
136 {
137 int save_errno = errno;
138
139 if (dbm_error(dbm))
140 return SMDBE_IO_ERROR;
141
142 if (save_errno != 0)

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

173int
174smdbm_get(database, key, data, flags)
175 SMDB_DATABASE *database;
176 SMDB_DBENT *key;
177 SMDB_DBENT *data;
178 u_int flags;
179{
180 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
181 datum dbkey, dbdata;
176
182
183 memset(&dbkey, '\0', sizeof dbkey);
184 memset(&dbdata, '\0', sizeof dbdata);
185 dbkey.dptr = key->data;
186 dbkey.dsize = key->size;
187
177 errno = 0;
188 errno = 0;
178 data->dbm = dbm_fetch(dbm, key->dbm);
179 if (data->dbm.dptr == NULL)
189 dbdata = dbm_fetch(dbm, dbkey);
190 if (dbdata.dptr == NULL)
180 {
181 int save_errno = errno;
182
183 if (dbm_error(dbm))
184 return SMDBE_IO_ERROR;
185
186 if (save_errno != 0)
187 return save_errno;
188
189 return SMDBE_NOT_FOUND;
190 }
191 {
192 int save_errno = errno;
193
194 if (dbm_error(dbm))
195 return SMDBE_IO_ERROR;
196
197 if (save_errno != 0)
198 return save_errno;
199
200 return SMDBE_NOT_FOUND;
201 }
191
202 data->data = dbdata.dptr;
203 data->size = dbdata.dsize;
192 return SMDBE_OK;
193}
194
195int
196smdbm_put(database, key, data, flags)
197 SMDB_DATABASE *database;
198 SMDB_DBENT *key;
199 SMDB_DBENT *data;
200 u_int flags;
201{
202 int result;
203 int save_errno;
204 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
204 return SMDBE_OK;
205}
206
207int
208smdbm_put(database, key, data, flags)
209 SMDB_DATABASE *database;
210 SMDB_DBENT *key;
211 SMDB_DBENT *data;
212 u_int flags;
213{
214 int result;
215 int save_errno;
216 DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm;
217 datum dbkey, dbdata;
205
218
219 memset(&dbkey, '\0', sizeof dbkey);
220 memset(&dbdata, '\0', sizeof dbdata);
221 dbkey.dptr = key->data;
222 dbkey.dsize = key->size;
223 dbdata.dptr = data->data;
224 dbdata.dsize = data->size;
225
206 errno = 0;
226 errno = 0;
207 result = dbm_store(dbm, key->dbm, data->dbm,
227 result = dbm_store(dbm, dbkey, dbdata,
208 smdb_put_flags_to_ndbm_flags(flags));
209 switch (result)
210 {
211 case 1:
212 return SMDBE_DUPLICATE;
213
214 case 0:
215 return SMDBE_OK;

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

316 SMDB_CURSOR *cursor;
317 SMDB_DBENT *key;
318 SMDB_DBENT *value;
319 SMDB_FLAG flags;
320{
321 SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl;
322 SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db;
323 DBM *dbm = db->smndbm_dbm;
228 smdb_put_flags_to_ndbm_flags(flags));
229 switch (result)
230 {
231 case 1:
232 return SMDBE_DUPLICATE;
233
234 case 0:
235 return SMDBE_OK;

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

336 SMDB_CURSOR *cursor;
337 SMDB_DBENT *key;
338 SMDB_DBENT *value;
339 SMDB_FLAG flags;
340{
341 SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl;
342 SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db;
343 DBM *dbm = db->smndbm_dbm;
344 datum dbkey, dbdata;
324
345
346 memset(&dbkey, '\0', sizeof dbkey);
347 memset(&dbdata, '\0', sizeof dbdata);
348
325 if (flags == SMDB_CURSOR_GET_RANGE)
326 return SMDBE_UNSUPPORTED;
327
328 if (dbm_cursor->smndbmc_current_key.dptr == NULL)
329 {
330 dbm_cursor->smndbmc_current_key = dbm_firstkey(dbm);
331 if (dbm_cursor->smndbmc_current_key.dptr == NULL)
332 {

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

342 {
343 if (dbm_error(dbm))
344 return SMDBE_IO_ERROR;
345 return SMDBE_LAST_ENTRY;
346 }
347 }
348
349 errno = 0;
349 if (flags == SMDB_CURSOR_GET_RANGE)
350 return SMDBE_UNSUPPORTED;
351
352 if (dbm_cursor->smndbmc_current_key.dptr == NULL)
353 {
354 dbm_cursor->smndbmc_current_key = dbm_firstkey(dbm);
355 if (dbm_cursor->smndbmc_current_key.dptr == NULL)
356 {

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

366 {
367 if (dbm_error(dbm))
368 return SMDBE_IO_ERROR;
369 return SMDBE_LAST_ENTRY;
370 }
371 }
372
373 errno = 0;
350 value->dbm = dbm_fetch(dbm, dbm_cursor->smndbmc_current_key);
351 if (value->dbm.dptr == NULL)
374 dbdata = dbm_fetch(dbm, dbm_cursor->smndbmc_current_key);
375 if (dbdata.dptr == NULL)
352 {
353 int save_errno = errno;
354
355 if (dbm_error(dbm))
356 return SMDBE_IO_ERROR;
357
358 if (save_errno != 0)
359 return save_errno;
360
361 return SMDBE_NOT_FOUND;
362 }
376 {
377 int save_errno = errno;
378
379 if (dbm_error(dbm))
380 return SMDBE_IO_ERROR;
381
382 if (save_errno != 0)
383 return save_errno;
384
385 return SMDBE_NOT_FOUND;
386 }
363 key->dbm = dbm_cursor->smndbmc_current_key;
387 value->data = dbdata.dptr;
388 value->size = dbdata.dsize;
389 key->data = dbm_cursor->smndbmc_current_key.dptr;
390 key->size = dbm_cursor->smndbmc_current_key.dsize;
364
365 return SMDBE_OK;
366}
367
368int
369smdbm_cursor_put(cursor, key, value, flags)
370 SMDB_CURSOR *cursor;
371 SMDB_DBENT *key;
372 SMDB_DBENT *value;
373 SMDB_FLAG flags;
374{
375 int result;
376 int save_errno;
377 SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl;
378 SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db;
379 DBM *dbm = db->smndbm_dbm;
391
392 return SMDBE_OK;
393}
394
395int
396smdbm_cursor_put(cursor, key, value, flags)
397 SMDB_CURSOR *cursor;
398 SMDB_DBENT *key;
399 SMDB_DBENT *value;
400 SMDB_FLAG flags;
401{
402 int result;
403 int save_errno;
404 SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl;
405 SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db;
406 DBM *dbm = db->smndbm_dbm;
407 datum dbdata;
380
408
409 memset(&dbdata, '\0', sizeof dbdata);
410 dbdata.dptr = value->data;
411 dbdata.dsize = value->size;
412
381 errno = 0;
413 errno = 0;
382 result = dbm_store(dbm, dbm_cursor->smndbmc_current_key, value->dbm,
414 result = dbm_store(dbm, dbm_cursor->smndbmc_current_key, dbdata,
383 smdb_put_flags_to_ndbm_flags(flags));
384 switch (result)
385 {
386 case 1:
387 return SMDBE_DUPLICATE;
388
389 case 0:
390 return SMDBE_OK;

--- 199 unchanged lines hidden ---
415 smdb_put_flags_to_ndbm_flags(flags));
416 switch (result)
417 {
418 case 1:
419 return SMDBE_DUPLICATE;
420
421 case 0:
422 return SMDBE_OK;

--- 199 unchanged lines hidden ---