diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2001-01-21 22:17:06 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2001-01-21 22:17:06 +0000 |
commit | 167a83e7b8733416154f871e39e86ba77eb1554d (patch) | |
tree | 4f725bdbff499cf7343d2eaeec15f8a0f0926140 /contrib/sendmail/libsmdb | |
parent | f84ac9120cb7d9f087e5dcb863c4bf25ba2985e6 (diff) | |
download | FreeBSD-src-167a83e7b8733416154f871e39e86ba77eb1554d.zip FreeBSD-src-167a83e7b8733416154f871e39e86ba77eb1554d.tar.gz |
Import sendmail 8.11.2
Diffstat (limited to 'contrib/sendmail/libsmdb')
-rw-r--r-- | contrib/sendmail/libsmdb/smdb1.c | 50 | ||||
-rw-r--r-- | contrib/sendmail/libsmdb/smdb2.c | 50 | ||||
-rw-r--r-- | contrib/sendmail/libsmdb/smndbm.c | 52 |
3 files changed, 129 insertions, 23 deletions
diff --git a/contrib/sendmail/libsmdb/smdb1.c b/contrib/sendmail/libsmdb/smdb1.c index c9eb96f..797bf2f 100644 --- a/contrib/sendmail/libsmdb/smdb1.c +++ b/contrib/sendmail/libsmdb/smdb1.c @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: smdb1.c,v 8.43.4.1 2000/08/24 17:08:00 gshapiro Exp $"; +static char id[] = "@(#)$Id: 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 @@ -212,14 +216,22 @@ smdb1_get(database, key, data, flags) { int result; DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db; + DBT dbkey, dbdata; - result = db->get(db, &key->db, &data->db, flags); + memset(&dbdata, '\0', sizeof dbdata); + memset(&dbkey, '\0', sizeof dbkey); + dbkey.data = key->data; + dbkey.size = key->size; + + 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; } @@ -231,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; + + 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, &key->db, &data->db, - smdb_put_flags_to_db1_flags(flags)); + return db->put(db, &dbkey, &dbdata, + smdb_put_flags_to_db1_flags(flags)); } int @@ -309,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; } @@ -329,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 diff --git a/contrib/sendmail/libsmdb/smdb2.c b/contrib/sendmail/libsmdb/smdb2.c index 8f46c20..e6f350a 100644 --- a/contrib/sendmail/libsmdb/smdb2.c +++ b/contrib/sendmail/libsmdb/smdb2.c @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: smdb2.c,v 8.53.2.1.2.2 2000/08/24 17:08:00 gshapiro Exp $"; +static char id[] = "@(#)$Id: smdb2.c,v 8.53.2.1.2.5 2000/10/26 00:39:56 geir Exp $"; #endif /* ! lint */ #include <fcntl.h> @@ -250,8 +250,12 @@ smdb2_del(database, key, flags) u_int flags; { DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db; + DBT dbkey; - return db2_error_to_smdb(db->del(db, NULL, &key->db, flags)); + memset(&dbkey, '\0', sizeof dbkey); + dbkey.data = key->data; + dbkey.size = key->size; + return db2_error_to_smdb(db->del(db, NULL, &dbkey, flags)); } int @@ -281,9 +285,19 @@ smdb2_get(database, key, data, flags) SMDB_DBENT *data; u_int flags; { + int result; DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db; + DBT dbkey, dbdata; + + memset(&dbdata, '\0', sizeof dbdata); + memset(&dbkey, '\0', sizeof dbkey); + dbkey.data = key->data; + dbkey.size = key->size; - return db2_error_to_smdb(db->get(db, NULL, &key->db, &data->db, flags)); + result = db->get(db, NULL, &dbkey, &dbdata, flags); + data->data = dbdata.data; + data->size = dbdata.size; + return db2_error_to_smdb(result); } int @@ -294,8 +308,16 @@ smdb2_put(database, key, data, flags) u_int flags; { DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db; + DBT dbkey, dbdata; - return db2_error_to_smdb(db->put(db, NULL, &key->db, &data->db, + 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 db2_error_to_smdb(db->put(db, NULL, &dbkey, &dbdata, smdb_put_flags_to_db2_flags(flags))); } @@ -362,11 +384,19 @@ smdb2_cursor_get(cursor, key, value, flags) int db2_flags; int result; DBC *dbc = (DBC *) cursor->smdbc_impl; + DBT dbkey, dbdata; + + memset(&dbdata, '\0', sizeof dbdata); + memset(&dbkey, '\0', sizeof dbkey); db2_flags = smdb_cursor_get_flags_to_db2(flags); - result = dbc->c_get(dbc, &key->db, &value->db, db2_flags); + result = dbc->c_get(dbc, &dbkey, &dbdata, db2_flags); if (result == DB_NOTFOUND) return SMDBE_LAST_ENTRY; + key->data = dbkey.data; + key->size = dbkey.size; + value->data = dbdata.data; + value->size = dbdata.size; return db2_error_to_smdb(result); } @@ -378,8 +408,16 @@ smdb2_cursor_put(cursor, key, value, flags) SMDB_FLAG flags; { DBC *dbc = (DBC *) cursor->smdbc_impl; + 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 db2_error_to_smdb(dbc->c_put(dbc, &key->db, &value->db, 0)); + return db2_error_to_smdb(dbc->c_put(dbc, &dbkey, &dbdata, 0)); } int diff --git a/contrib/sendmail/libsmdb/smndbm.c b/contrib/sendmail/libsmdb/smndbm.c index 8c78ffc..47e5cb5 100644 --- a/contrib/sendmail/libsmdb/smndbm.c +++ b/contrib/sendmail/libsmdb/smndbm.c @@ -8,7 +8,7 @@ */ #ifndef lint -static char id[] = "@(#)$Id: smndbm.c,v 8.40.4.1 2000/08/24 17:08:00 gshapiro Exp $"; +static char id[] = "@(#)$Id: smndbm.c,v 8.40.4.3 2000/10/05 22:27:50 gshapiro Exp $"; #endif /* ! lint */ #include <fcntl.h> @@ -124,9 +124,14 @@ smdbm_del(database, key, flags) { int result; DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm; + datum dbkey; + + memset(&dbkey, '\0', sizeof dbkey); + dbkey.dptr = key->data; + dbkey.dsize = key->size; errno = 0; - result = dbm_delete(dbm, key->dbm); + result = dbm_delete(dbm, dbkey); if (result != 0) { int save_errno = errno; @@ -173,10 +178,16 @@ smdbm_get(database, key, data, flags) u_int flags; { DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm; + datum dbkey, dbdata; + + memset(&dbkey, '\0', sizeof dbkey); + memset(&dbdata, '\0', sizeof dbdata); + dbkey.dptr = key->data; + dbkey.dsize = key->size; errno = 0; - data->dbm = dbm_fetch(dbm, key->dbm); - if (data->dbm.dptr == NULL) + dbdata = dbm_fetch(dbm, dbkey); + if (dbdata.dptr == NULL) { int save_errno = errno; @@ -188,7 +199,8 @@ smdbm_get(database, key, data, flags) return SMDBE_NOT_FOUND; } - + data->data = dbdata.dptr; + data->size = dbdata.dsize; return SMDBE_OK; } @@ -202,9 +214,17 @@ smdbm_put(database, key, data, flags) int result; int save_errno; DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm; + datum dbkey, dbdata; + + memset(&dbkey, '\0', sizeof dbkey); + memset(&dbdata, '\0', sizeof dbdata); + dbkey.dptr = key->data; + dbkey.dsize = key->size; + dbdata.dptr = data->data; + dbdata.dsize = data->size; errno = 0; - result = dbm_store(dbm, key->dbm, data->dbm, + result = dbm_store(dbm, dbkey, dbdata, smdb_put_flags_to_ndbm_flags(flags)); switch (result) { @@ -321,6 +341,10 @@ smdbm_cursor_get(cursor, key, value, flags) SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl; SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db; DBM *dbm = db->smndbm_dbm; + datum dbkey, dbdata; + + memset(&dbkey, '\0', sizeof dbkey); + memset(&dbdata, '\0', sizeof dbdata); if (flags == SMDB_CURSOR_GET_RANGE) return SMDBE_UNSUPPORTED; @@ -347,8 +371,8 @@ smdbm_cursor_get(cursor, key, value, flags) } errno = 0; - value->dbm = dbm_fetch(dbm, dbm_cursor->smndbmc_current_key); - if (value->dbm.dptr == NULL) + dbdata = dbm_fetch(dbm, dbm_cursor->smndbmc_current_key); + if (dbdata.dptr == NULL) { int save_errno = errno; @@ -360,7 +384,10 @@ smdbm_cursor_get(cursor, key, value, flags) return SMDBE_NOT_FOUND; } - key->dbm = dbm_cursor->smndbmc_current_key; + value->data = dbdata.dptr; + value->size = dbdata.dsize; + key->data = dbm_cursor->smndbmc_current_key.dptr; + key->size = dbm_cursor->smndbmc_current_key.dsize; return SMDBE_OK; } @@ -377,9 +404,14 @@ smdbm_cursor_put(cursor, key, value, flags) SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl; SMDB_DBM_DATABASE *db = dbm_cursor->smndbmc_db; DBM *dbm = db->smndbm_dbm; + datum dbdata; + + memset(&dbdata, '\0', sizeof dbdata); + dbdata.dptr = value->data; + dbdata.dsize = value->size; errno = 0; - result = dbm_store(dbm, dbm_cursor->smndbmc_current_key, value->dbm, + result = dbm_store(dbm, dbm_cursor->smndbmc_current_key, dbdata, smdb_put_flags_to_ndbm_flags(flags)); switch (result) { |