summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/sendmail/libsmdb/smdb1.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-01-15 21:09:13 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-01-15 21:09:13 +0000
commit5062bcecfa81a7e0dd07894d6e93655a97239964 (patch)
treefd0e0dd2a71271dbe81c195cd9fbdd57fb7c20fb /gnu/usr.sbin/sendmail/libsmdb/smdb1.c
parent91deaea81040227b9ba537ff047f1f863f75fc31 (diff)
sendmail 8.11.2 with BSD Makefiles
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsmdb/smdb1.c')
-rw-r--r--gnu/usr.sbin/sendmail/libsmdb/smdb1.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/gnu/usr.sbin/sendmail/libsmdb/smdb1.c b/gnu/usr.sbin/sendmail/libsmdb/smdb1.c
index 1fd260741ac..6052d3a7dc3 100644
--- a/gnu/usr.sbin/sendmail/libsmdb/smdb1.c
+++ b/gnu/usr.sbin/sendmail/libsmdb/smdb1.c
@@ -8,7 +8,7 @@
*/
#ifndef lint
-static char id[] = "@(#)$Sendmail: smdb1.c,v 8.43 2000/03/17 07:32:43 gshapiro Exp $";
+static char id[] = "@(#)$Sendmail: smdb1.c,v 8.43.4.3 2000/10/05 23:06:30 gshapiro Exp $";
#endif /* ! lint */
#include <unistd.h>
@@ -175,8 +175,12 @@ smdb1_del(database, key, flags)
u_int flags;
{
DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db;
+ DBT dbkey;
- return db->del(db, &key->db, flags);
+ memset(&dbkey, '\0', sizeof dbkey);
+ dbkey.data = key->data;
+ dbkey.size = key->size;
+ return db->del(db, &dbkey, flags);
}
int
@@ -194,6 +198,16 @@ smdb1_fd(database, fd)
}
int
+smdb1_lockfd(database)
+ SMDB_DATABASE *database;
+{
+ SMDB_DB1_DATABASE *db1 = (SMDB_DB1_DATABASE *) database->smdb_impl;
+
+ return db1->smdb1_lock_fd;
+}
+
+
+int
smdb1_get(database, key, data, flags)
SMDB_DATABASE *database;
SMDB_DBENT *key;
@@ -202,14 +216,22 @@ smdb1_get(database, key, data, flags)
{
int result;
DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db;
+ DBT dbkey, dbdata;
+
+ memset(&dbdata, '\0', sizeof dbdata);
+ memset(&dbkey, '\0', sizeof dbkey);
+ dbkey.data = key->data;
+ dbkey.size = key->size;
- result = db->get(db, &key->db, &data->db, flags);
+ result = db->get(db, &dbkey, &dbdata, flags);
if (result != 0)
{
if (result == 1)
return SMDBE_NOT_FOUND;
return errno;
}
+ data->data = dbdata.data;
+ data->size = dbdata.size;
return SMDBE_OK;
}
@@ -221,9 +243,17 @@ smdb1_put(database, key, data, flags)
u_int flags;
{
DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db;
+ DBT dbkey, dbdata;
- return db->put(db, &key->db, &data->db,
- smdb_put_flags_to_db1_flags(flags));
+ memset(&dbdata, '\0', sizeof dbdata);
+ memset(&dbkey, '\0', sizeof dbkey);
+ dbkey.data = key->data;
+ dbkey.size = key->size;
+ dbdata.data = data->data;
+ dbdata.size = data->size;
+
+ return db->put(db, &dbkey, &dbdata,
+ smdb_put_flags_to_db1_flags(flags));
}
int
@@ -299,13 +329,21 @@ smdb1_cursor_get(cursor, key, value, flags)
SMDB_DB1_CURSOR *db1_cursor = (SMDB_DB1_CURSOR *) cursor->smdbc_impl;
SMDB_DB1_DATABASE *db1 = db1_cursor->db;
DB *db = db1->smdb1_db;
+ DBT dbkey, dbdata;
+
+ memset(&dbdata, '\0', sizeof dbdata);
+ memset(&dbkey, '\0', sizeof dbkey);
db1_flags = smdb_cursor_get_flags_to_smdb1(flags);
- result = db->seq(db, &key->db, &value->db, db1_flags);
+ result = db->seq(db, &dbkey, &dbdata, db1_flags);
if (result == -1)
return errno;
if (result == 1)
return SMDBE_LAST_ENTRY;
+ value->data = dbdata.data;
+ value->size = dbdata.size;
+ key->data = dbkey.data;
+ key->size = dbkey.size;
return SMDBE_OK;
}
@@ -319,8 +357,16 @@ smdb1_cursor_put(cursor, key, value, flags)
SMDB_DB1_CURSOR *db1_cursor = (SMDB_DB1_CURSOR *) cursor->smdbc_impl;
SMDB_DB1_DATABASE *db1 = db1_cursor->db;
DB *db = db1->smdb1_db;
+ DBT dbkey, dbdata;
+
+ memset(&dbdata, '\0', sizeof dbdata);
+ memset(&dbkey, '\0', sizeof dbkey);
+ dbkey.data = key->data;
+ dbkey.size = key->size;
+ dbdata.data = value->data;
+ dbdata.size = value->size;
- return db->put(db, &key->db, &value->db, R_CURSOR);
+ return db->put(db, &dbkey, &dbdata, R_CURSOR);
}
int
@@ -482,6 +528,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info,
smdb_db->smdb_close = smdb1_close;
smdb_db->smdb_del = smdb1_del;
smdb_db->smdb_fd = smdb1_fd;
+ smdb_db->smdb_lockfd = smdb1_lockfd;
smdb_db->smdb_get = smdb1_get;
smdb_db->smdb_put = smdb1_put;
smdb_db->smdb_set_owner = smdb1_set_owner;