summaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/libsmdb/smdb2.c
diff options
context:
space:
mode:
authorgshapiro <gshapiro@FreeBSD.org>2002-02-17 21:56:45 +0000
committergshapiro <gshapiro@FreeBSD.org>2002-02-17 21:56:45 +0000
commit8449595fe97f4474b9b9a7e4edee1ef35dcff393 (patch)
treee7a33b132264d449a512ddf4a8685df097669c1d /contrib/sendmail/libsmdb/smdb2.c
parent289b381b31415647269c7520d881017e2dcb27f1 (diff)
downloadFreeBSD-src-8449595fe97f4474b9b9a7e4edee1ef35dcff393.zip
FreeBSD-src-8449595fe97f4474b9b9a7e4edee1ef35dcff393.tar.gz
Import sendmail 8.12.2
Diffstat (limited to 'contrib/sendmail/libsmdb/smdb2.c')
-rw-r--r--contrib/sendmail/libsmdb/smdb2.c69
1 files changed, 32 insertions, 37 deletions
diff --git a/contrib/sendmail/libsmdb/smdb2.c b/contrib/sendmail/libsmdb/smdb2.c
index af56fe9..89a57de 100644
--- a/contrib/sendmail/libsmdb/smdb2.c
+++ b/contrib/sendmail/libsmdb/smdb2.c
@@ -7,9 +7,8 @@
** the sendmail distribution.
*/
-#ifndef lint
-static char id[] = "@(#)$Id: smdb2.c,v 8.53.2.1.2.7 2001/02/14 04:07:24 gshapiro Exp $";
-#endif /* ! lint */
+#include <sm/gen.h>
+SM_RCSID("@(#)$Id: smdb2.c,v 8.69 2001/09/12 21:19:12 gshapiro Exp $")
#include <fcntl.h>
#include <stdlib.h>
@@ -30,7 +29,7 @@ struct smdb_db2_database
};
typedef struct smdb_db2_database SMDB_DB2_DATABASE;
- /*
+/*
** SMDB_TYPE_TO_DB2_TYPE -- Translates smdb database type to db2 type.
**
** Parameters:
@@ -57,9 +56,7 @@ smdb_type_to_db2_type(type)
return DB_UNKNOWN;
}
-
-
- /*
+/*
** DB2_ERROR_TO_SMDB -- Translates db2 errors to smdbe errors
**
** Parameters:
@@ -142,8 +139,7 @@ db2_error_to_smdb(error)
}
return result;
}
-
- /*
+/*
** SMDB_PUT_FLAGS_TO_DB2_FLAGS -- Translates smdb put flags to db2 put flags.
**
** Parameters:
@@ -157,7 +153,7 @@ db2_error_to_smdb(error)
**
*/
-u_int
+unsigned int
smdb_put_flags_to_db2_flags(flags)
SMDB_FLAG flags;
{
@@ -170,8 +166,7 @@ smdb_put_flags_to_db2_flags(flags)
return return_flags;
}
-
- /*
+/*
** SMDB_CURSOR_GET_FLAGS_TO_DB2 -- Translates smdb cursor get flags to db2
** getflags.
**
@@ -209,6 +204,11 @@ smdb_cursor_get_flags_to_db2(flags)
}
}
+/*
+** Except for smdb_db_open, the rest of these functions correspond to the
+** interface laid out in smdb.h.
+*/
+
SMDB_DB2_DATABASE *
smdb2_malloc_database()
{
@@ -221,38 +221,34 @@ smdb2_malloc_database()
return db2;
}
-
-/*
-** Except for smdb_db_open, the rest of these function correspond to the
-** interface laid out in smdb.h.
-*/
-
int
smdb2_close(database)
SMDB_DATABASE *database;
{
+ int result;
SMDB_DB2_DATABASE *db2 = (SMDB_DB2_DATABASE *) database->smdb_impl;
DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db;
+ result = db2_error_to_smdb(db->close(db, 0));
if (db2->smdb2_lock_fd != -1)
close(db2->smdb2_lock_fd);
free(db2);
database->smdb_impl = NULL;
- return db2_error_to_smdb(db->close(db, 0));
+ return result;
}
int
smdb2_del(database, key, flags)
SMDB_DATABASE *database;
SMDB_DBENT *key;
- u_int flags;
+ unsigned int flags;
{
DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db;
DBT dbkey;
- memset(&dbkey, '\0', sizeof dbkey);
+ (void) memset(&dbkey, '\0', sizeof dbkey);
dbkey.data = key->data;
dbkey.size = key->size;
return db2_error_to_smdb(db->del(db, NULL, &dbkey, flags));
@@ -277,20 +273,19 @@ smdb2_lockfd(database)
return db2->smdb2_lock_fd;
}
-
int
smdb2_get(database, key, data, flags)
SMDB_DATABASE *database;
SMDB_DBENT *key;
SMDB_DBENT *data;
- u_int flags;
+ unsigned 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);
+ (void) memset(&dbdata, '\0', sizeof dbdata);
+ (void) memset(&dbkey, '\0', sizeof dbkey);
dbkey.data = key->data;
dbkey.size = key->size;
@@ -305,13 +300,13 @@ smdb2_put(database, key, data, flags)
SMDB_DATABASE *database;
SMDB_DBENT *key;
SMDB_DBENT *data;
- u_int flags;
+ unsigned int flags;
{
DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db;
DBT dbkey, dbdata;
- memset(&dbdata, '\0', sizeof dbdata);
- memset(&dbkey, '\0', sizeof dbkey);
+ (void) memset(&dbdata, '\0', sizeof dbdata);
+ (void) memset(&dbkey, '\0', sizeof dbkey);
dbkey.data = key->data;
dbkey.size = key->size;
dbdata.data = data->data;
@@ -348,7 +343,7 @@ smdb2_set_owner(database, uid, gid)
int
smdb2_sync(database, flags)
SMDB_DATABASE *database;
- u_int flags;
+ unsigned int flags;
{
DB *db = ((SMDB_DB2_DATABASE *) database->smdb_impl)->smdb2_db;
@@ -389,8 +384,8 @@ smdb2_cursor_get(cursor, key, value, flags)
DBC *dbc = (DBC *) cursor->smdbc_impl;
DBT dbkey, dbdata;
- memset(&dbdata, '\0', sizeof dbdata);
- memset(&dbkey, '\0', sizeof dbkey);
+ (void) memset(&dbdata, '\0', sizeof dbdata);
+ (void) memset(&dbkey, '\0', sizeof dbkey);
db2_flags = smdb_cursor_get_flags_to_db2(flags);
result = dbc->c_get(dbc, &dbkey, &dbdata, db2_flags);
@@ -413,8 +408,8 @@ smdb2_cursor_put(cursor, key, value, flags)
DBC *dbc = (DBC *) cursor->smdbc_impl;
DBT dbkey, dbdata;
- memset(&dbdata, '\0', sizeof dbdata);
- memset(&dbkey, '\0', sizeof dbkey);
+ (void) memset(&dbdata, '\0', sizeof dbdata);
+ (void) memset(&dbkey, '\0', sizeof dbkey);
dbkey.data = key->data;
dbkey.size = key->size;
dbdata.data = value->data;
@@ -467,7 +462,7 @@ smdb_db_open_internal(db_name, db_type, db_flags, db_params, db)
DB_INFO db_info;
params = NULL;
- memset(&db_info, '\0', sizeof db_info);
+ (void) memset(&db_info, '\0', sizeof db_info);
if (db_params != NULL)
{
db_info.db_cachesize = db_params->smdbp_cache_size;
@@ -537,7 +532,7 @@ smdb_db_open_internal(db_name, db_type, db_flags, db_params, db)
return db2_error_to_smdb(result);
}
# endif /* DB_VERSION_MAJOR > 2 */
- /*
+/*
** SMDB_DB_OPEN -- Opens a db database.
**
** Parameters:
@@ -576,7 +571,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, db_params
SMDB_USER_INFO *user_info;
SMDB_DBPARAMS *db_params;
{
- bool lockcreated = FALSE;
+ bool lockcreated = false;
int result;
int db_flags;
int lock_fd;
@@ -604,7 +599,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, db_params
if (stat_info.st_mode == ST_MODE_NOFILE &&
bitset(mode, O_CREAT))
- lockcreated = TRUE;
+ lockcreated = true;
result = smdb_lock_file(&lock_fd, db_name, mode, sff,
SMDB2_FILE_EXTENSION);
OpenPOWER on IntegriCloud