diff options
| author | Gregory Neil Shapiro <gshapiro@FreeBSD.org> | 2002-02-17 21:56:45 +0000 |
|---|---|---|
| committer | Gregory Neil Shapiro <gshapiro@FreeBSD.org> | 2002-02-17 21:56:45 +0000 |
| commit | 4026605903c0ab8df33c4ae8c419acdb2b652af8 (patch) | |
| tree | e7a33b132264d449a512ddf4a8685df097669c1d /contrib/sendmail/libsmdb | |
| parent | c86d59657f992c17a947200225b50f07e1776cd1 (diff) | |
Notes
Diffstat (limited to 'contrib/sendmail/libsmdb')
| -rw-r--r-- | contrib/sendmail/libsmdb/Makefile.m4 | 1 | ||||
| -rw-r--r-- | contrib/sendmail/libsmdb/smdb.c | 93 | ||||
| -rw-r--r-- | contrib/sendmail/libsmdb/smdb1.c | 74 | ||||
| -rw-r--r-- | contrib/sendmail/libsmdb/smdb2.c | 69 | ||||
| -rw-r--r-- | contrib/sendmail/libsmdb/smndbm.c | 64 |
5 files changed, 131 insertions, 170 deletions
diff --git a/contrib/sendmail/libsmdb/Makefile.m4 b/contrib/sendmail/libsmdb/Makefile.m4 index f24c0a0d63c30..90cecfe129504 100644 --- a/contrib/sendmail/libsmdb/Makefile.m4 +++ b/contrib/sendmail/libsmdb/Makefile.m4 @@ -1,5 +1,6 @@ include(confBUILDTOOLSDIR`/M4/switch.m4') +define(`confREQUIRE_LIBSM', `true') # sendmail dir SMSRCDIR= ifdef(`confSMSRCDIR', `confSMSRCDIR', `${SRCDIR}/sendmail') PREPENDDEF(`confENVDEF', `confMAPDEF') diff --git a/contrib/sendmail/libsmdb/smdb.c b/contrib/sendmail/libsmdb/smdb.c index 597cbff8a2c0c..e4bc3413a2506 100644 --- a/contrib/sendmail/libsmdb/smdb.c +++ b/contrib/sendmail/libsmdb/smdb.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -7,9 +7,8 @@ ** the sendmail distribution. */ -#ifndef lint -static char id[] = "@(#)$Id: smdb.c,v 8.37.4.2 2000/08/24 17:08:00 gshapiro Exp $"; -#endif /* ! lint */ +#include <sm/gen.h> +SM_RCSID("@(#)$Id: smdb.c,v 8.53 2001/11/19 19:31:14 gshapiro Exp $") #include <fcntl.h> #include <stdlib.h> @@ -19,7 +18,7 @@ static char id[] = "@(#)$Id: smdb.c,v 8.37.4.2 2000/08/24 17:08:00 gshapiro Exp #include <sendmail/sendmail.h> #include <libsmdb/smdb.h> -/* +/* ** SMDB_MALLOC_DATABASE -- Allocates a database structure. ** ** Parameters: @@ -38,13 +37,13 @@ smdb_malloc_database() db = (SMDB_DATABASE *) malloc(sizeof(SMDB_DATABASE)); if (db != NULL) - memset(db, '\0', sizeof(SMDB_DATABASE)); + (void) memset(db, '\0', sizeof(SMDB_DATABASE)); return db; } -/* +/* ** SMDB_FREE_DATABASE -- Unallocates a database structure. ** ** Parameters: @@ -61,8 +60,7 @@ smdb_free_database(database) if (database != NULL) free(database); } - -/* +/* ** SMDB_LOCKFILE -- lock a file using flock or (shudder) fcntl locking ** ** Parameters: @@ -72,8 +70,8 @@ smdb_free_database(database) ** LOCK_NB -- non-blocking. ** ** Returns: -** TRUE if the lock was acquired. -** FALSE otherwise. +** true if the lock was acquired. +** false otherwise. */ static bool @@ -87,7 +85,7 @@ smdb_lockfile(fd, type) int action; struct flock lfd; - memset(&lfd, '\0', sizeof lfd); + (void) memset(&lfd, '\0', sizeof lfd); if (bitset(LOCK_UN, type)) lfd.l_type = F_UNLCK; else if (bitset(LOCK_EX, type)) @@ -103,9 +101,7 @@ smdb_lockfile(fd, type) while ((i = fcntl(fd, action, &lfd)) < 0 && errno == EINTR) continue; if (i >= 0) - { - return TRUE; - } + return true; save_errno = errno; /* @@ -118,9 +114,7 @@ smdb_lockfile(fd, type) */ if (save_errno == EINVAL) - { - return TRUE; - } + return true; if (!bitset(LOCK_NB, type) || (save_errno != EACCES && save_errno != EAGAIN)) @@ -132,18 +126,16 @@ smdb_lockfile(fd, type) # endif /* F_GETFL */ # if 0 syslog(LOG_ERR, "cannot lockf(%s%s, fd=%d, type=%o, omode=%o, euid=%d)", - filename, ext, fd, type, omode, geteuid()); + filename, ext, fd, type, omode, (int) geteuid()); # endif /* 0 */ - return FALSE; + return false; } #else /* !HASFLOCK */ while ((i = flock(fd, type)) < 0 && errno == EINTR) continue; if (i >= 0) - { - return TRUE; - } + return true; save_errno = errno; if (!bitset(LOCK_NB, type) || save_errno != EWOULDBLOCK) @@ -155,16 +147,15 @@ smdb_lockfile(fd, type) # endif /* F_GETFL */ # if 0 syslog(LOG_ERR, "cannot flock(%s%s, fd=%d, type=%o, omode=%o, euid=%d)", - filename, ext, fd, type, omode, geteuid()); + filename, ext, fd, type, omode, (int) geteuid()); # endif /* 0 */ - return FALSE; + return false; } #endif /* !HASFLOCK */ errno = save_errno; - return FALSE; + return false; } - -/* +/* ** SMDB_OPEN_DATABASE -- Opens a database. ** ** This opens a database. If type is SMDB_DEFAULT it tries to @@ -207,12 +198,11 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, user_info, SMDB_USER_INFO *user_info; SMDB_DBPARAMS *params; { - int result; - bool type_was_default = FALSE; + bool type_was_default = false; if (type == SMDB_TYPE_DEFAULT) { - type_was_default = TRUE; + type_was_default = true; #ifdef NEWDB type = SMDB_TYPE_HASH; #else /* NEWDB */ @@ -229,6 +219,8 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, user_info, (strncmp(type, SMDB_TYPE_BTREE, SMDB_TYPE_BTREE_LEN) == 0)) { #ifdef NEWDB + int result; + result = smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, params); # ifdef NDBM @@ -245,6 +237,8 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, user_info, if (strncmp(type, SMDB_TYPE_NDBM, SMDB_TYPE_NDBM_LEN) == 0) { #ifdef NDBM + int result; + result = smdb_ndbm_open(database, db_name, mode, mode_mask, sff, type, user_info, params); return result; @@ -255,8 +249,7 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, user_info, return SMDBE_UNKNOWN_DB_TYPE; } - -/* +/* ** SMDB_ADD_EXTENSION -- Adds an extension to a file name. ** ** Just adds a . followed by a string to a db_name if there @@ -296,15 +289,14 @@ smdb_add_extension(full_name, max_full_name_len, db_name, extension) if (db_name_len < extension_len + 1 || db_name[db_name_len - extension_len - 1] != '.' || strcmp(&db_name[db_name_len - extension_len], extension) != 0) - snprintf(full_name, max_full_name_len, "%s.%s", db_name, - extension); + (void) sm_snprintf(full_name, max_full_name_len, "%s.%s", + db_name, extension); else - (void) strlcpy(full_name, db_name, max_full_name_len); + (void) sm_strlcpy(full_name, db_name, max_full_name_len); return SMDBE_OK; } - -/* +/* ** SMDB_LOCK_FILE -- Locks the database file. ** ** Locks the actual database file. @@ -342,8 +334,7 @@ smdb_lock_file(lock_fd, db_name, mode, sff, extension) return SMDBE_OK; } - -/* +/* ** SMDB_UNLOCK_FILE -- Unlocks a file ** ** Unlocks a file. @@ -367,8 +358,7 @@ smdb_unlock_file(lock_fd) return SMDBE_OK; } - -/* +/* ** SMDB_LOCK_MAP -- Locks a database. ** ** Parameters: @@ -395,8 +385,7 @@ smdb_lock_map(database, type) return SMDBE_LOCK_NOT_GRANTED; return SMDBE_OK; } - -/* +/* ** SMDB_UNLOCK_MAP -- Unlocks a database ** ** Parameters: @@ -419,9 +408,7 @@ smdb_unlock_map(database) return SMDBE_LOCK_NOT_HELD; return SMDBE_OK; } - - -/* +/* ** SMDB_SETUP_FILE -- Gets db file ready for use. ** ** Makes sure permissions on file are safe and creates it if it @@ -465,8 +452,7 @@ smdb_setup_file(db_name, extension, mode_mask, sff, user_info, stat_info) return SMDBE_OK; } - -/* +/* ** SMDB_FILECHANGED -- Checks to see if a file changed. ** ** Compares the passed in stat_info with a current stat on @@ -496,12 +482,9 @@ smdb_filechanged(db_name, extension, db_fd, stat_info) extension); if (result != SMDBE_OK) return result; - - result = filechanged(db_file_name, db_fd, stat_info); - - return result; + return filechanged(db_file_name, db_fd, stat_info); } -/* +/* ** SMDB_PRINT_AVAILABLE_TYPES -- Prints the names of the available types. ** ** Parameters: @@ -522,7 +505,7 @@ smdb_print_available_types() printf("btree\n"); #endif /* NEWDB */ } -/* +/* ** SMDB_DB_DEFINITION -- Given a database type, return database definition ** ** Reads though a structure making an association with the database diff --git a/contrib/sendmail/libsmdb/smdb1.c b/contrib/sendmail/libsmdb/smdb1.c index 797bf2f847a76..f9dad9f0d539d 100644 --- a/contrib/sendmail/libsmdb/smdb1.c +++ b/contrib/sendmail/libsmdb/smdb1.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -7,9 +7,8 @@ ** the sendmail distribution. */ -#ifndef lint -static char id[] = "@(#)$Id: smdb1.c,v 8.43.4.3 2000/10/05 23:06:30 gshapiro Exp $"; -#endif /* ! lint */ +#include <sm/gen.h> +SM_RCSID("@(#)$Id: smdb1.c,v 8.55 2001/09/12 21:19:12 gshapiro Exp $") #include <unistd.h> #include <stdlib.h> @@ -36,7 +35,7 @@ struct smdb_db1_cursor }; typedef struct smdb_db1_cursor SMDB_DB1_CURSOR; -/* +/* ** SMDB_TYPE_TO_DB1_TYPE -- Translates smdb database type to db1 type. ** ** Parameters: @@ -64,9 +63,7 @@ smdb_type_to_db1_type(type) /* Should never get here thanks to test in smdb_db_open() */ return DB_HASH; } - - -/* +/* ** SMDB_PUT_FLAGS_TO_DB1_FLAGS -- Translates smdb put flags to db1 put flags. ** ** Parameters: @@ -80,7 +77,7 @@ smdb_type_to_db1_type(type) ** */ -u_int +unsigned int smdb_put_flags_to_db1_flags(flags) SMDB_FLAG flags; { @@ -93,8 +90,7 @@ smdb_put_flags_to_db1_flags(flags) return return_flags; } - -/* +/* ** SMDB_CURSOR_GET_FLAGS_TO_SMDB1 ** ** Parameters: @@ -131,6 +127,10 @@ smdb_cursor_get_flags_to_smdb1(flags) } } +/* +** The rest of these functions correspond to the interface laid out in smdb.h. +*/ + SMDB_DB1_DATABASE * smdb1_malloc_database() { @@ -141,43 +141,40 @@ smdb1_malloc_database() if (db1 != NULL) { db1->smdb1_lock_fd = -1; - db1->smdb1_cursor_in_use = FALSE; + db1->smdb1_cursor_in_use = false; } return db1; } -/* -** The rest of these function correspond to the interface laid out -** in smdb.h. -*/ - int smdb1_close(database) SMDB_DATABASE *database; { + int result; SMDB_DB1_DATABASE *db1 = (SMDB_DB1_DATABASE *) database->smdb_impl; DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db; + result = db->close(db); if (db1->smdb1_lock_fd != -1) (void) close(db1->smdb1_lock_fd); free(db1); database->smdb_impl = NULL; - return db->close(db); + return result; } int smdb1_del(database, key, flags) SMDB_DATABASE *database; SMDB_DBENT *key; - u_int flags; + unsigned int flags; { DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db; DBT dbkey; - memset(&dbkey, '\0', sizeof dbkey); + (void) memset(&dbkey, '\0', sizeof dbkey); dbkey.data = key->data; dbkey.size = key->size; return db->del(db, &dbkey, flags); @@ -212,14 +209,14 @@ smdb1_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_DB1_DATABASE *) database->smdb_impl)->smdb1_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; @@ -240,13 +237,13 @@ smdb1_put(database, key, data, flags) SMDB_DATABASE *database; SMDB_DBENT *key; SMDB_DBENT *data; - u_int flags; + unsigned 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); + (void) memset(&dbdata, '\0', sizeof dbdata); + (void) memset(&dbkey, '\0', sizeof dbkey); dbkey.data = key->data; dbkey.size = key->size; dbdata.data = data->data; @@ -282,7 +279,7 @@ smdb1_set_owner(database, uid, gid) int smdb1_sync(database, flags) SMDB_DATABASE *database; - u_int flags; + unsigned int flags; { DB *db = ((SMDB_DB1_DATABASE *) database->smdb_impl)->smdb1_db; @@ -299,7 +296,7 @@ smdb1_cursor_close(cursor) if (!db1->smdb1_cursor_in_use) return SMDBE_NOT_A_VALID_CURSOR; - db1->smdb1_cursor_in_use = FALSE; + db1->smdb1_cursor_in_use = false; free(cursor); return SMDBE_OK; @@ -308,7 +305,7 @@ smdb1_cursor_close(cursor) int smdb1_cursor_del(cursor, flags) SMDB_CURSOR *cursor; - u_int flags; + unsigned int flags; { SMDB_DB1_CURSOR *db1_cursor = (SMDB_DB1_CURSOR *) cursor->smdbc_impl; SMDB_DB1_DATABASE *db1 = db1_cursor->db; @@ -331,8 +328,8 @@ smdb1_cursor_get(cursor, key, value, flags) DB *db = db1->smdb1_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); db1_flags = smdb_cursor_get_flags_to_smdb1(flags); result = db->seq(db, &dbkey, &dbdata, db1_flags); @@ -359,8 +356,8 @@ smdb1_cursor_put(cursor, key, value, flags) DB *db = db1->smdb1_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 = value->data; @@ -373,7 +370,7 @@ int smdb1_cursor(database, cursor, flags) SMDB_DATABASE *database; SMDB_CURSOR **cursor; - u_int flags; + unsigned int flags; { SMDB_DB1_DATABASE *db1 = (SMDB_DB1_DATABASE *) database->smdb_impl; SMDB_CURSOR *cur; @@ -382,7 +379,7 @@ smdb1_cursor(database, cursor, flags) if (db1->smdb1_cursor_in_use) return SMDBE_ONLY_SUPPORTS_ONE_CURSOR; - db1->smdb1_cursor_in_use = TRUE; + db1->smdb1_cursor_in_use = true; db1_cursor = (SMDB_DB1_CURSOR *) malloc(sizeof(SMDB_DB1_CURSOR)); db1_cursor->db = db1; @@ -400,8 +397,7 @@ smdb1_cursor(database, cursor, flags) return SMDBE_OK; } - -/* +/* ** SMDB_DB_OPEN -- Opens a db1 database. ** ** Parameters: @@ -488,7 +484,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, if (db_params != NULL && (strncmp(SMDB_TYPE_HASH, type, SMDB_TYPE_HASH_LEN) == 0)) { - memset(&hash_info, '\0', sizeof hash_info); + (void) memset(&hash_info, '\0', sizeof hash_info); hash_info.nelem = db_params->smdbp_num_elements; hash_info.cachesize = db_params->smdbp_cache_size; params = &hash_info; @@ -497,7 +493,7 @@ smdb_db_open(database, db_name, mode, mode_mask, sff, type, user_info, if (db_params != NULL && (strncmp(SMDB_TYPE_BTREE, type, SMDB_TYPE_BTREE_LEN) == 0)) { - memset(&btree_info, '\0', sizeof btree_info); + (void) memset(&btree_info, '\0', sizeof btree_info); btree_info.cachesize = db_params->smdbp_cache_size; if (db_params->smdbp_allow_dup) btree_info.flags |= R_DUP; diff --git a/contrib/sendmail/libsmdb/smdb2.c b/contrib/sendmail/libsmdb/smdb2.c index af56fe9101786..89a57de43cea4 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); diff --git a/contrib/sendmail/libsmdb/smndbm.c b/contrib/sendmail/libsmdb/smndbm.c index 47e5cb5335fe1..421b4bc06fe3d 100644 --- a/contrib/sendmail/libsmdb/smndbm.c +++ b/contrib/sendmail/libsmdb/smndbm.c @@ -1,5 +1,5 @@ /* -** Copyright (c) 1999-2000 Sendmail, Inc. and its suppliers. +** Copyright (c) 1999-2001 Sendmail, Inc. and its suppliers. ** All rights reserved. ** ** By using this file, you agree to the terms and conditions set @@ -7,9 +7,8 @@ ** the sendmail distribution. */ -#ifndef lint -static char id[] = "@(#)$Id: smndbm.c,v 8.40.4.3 2000/10/05 22:27:50 gshapiro Exp $"; -#endif /* ! lint */ +#include <sm/gen.h> +SM_RCSID("@(#)$Id: smndbm.c,v 8.50 2001/09/11 04:04:53 gshapiro Exp $") #include <fcntl.h> #include <stdlib.h> @@ -38,7 +37,7 @@ struct smdb_dbm_cursor_struct }; typedef struct smdb_dbm_cursor_struct SMDB_DBM_CURSOR; -/* +/* ** SMDB_PUT_FLAGS_TO_NDBM_FLAGS -- Translates smdb put flags to ndbm put flags. ** ** Parameters: @@ -67,15 +66,9 @@ smdb_put_flags_to_ndbm_flags(flags) return return_flags; } -/* -** smdbm_malloc_database -- Create and initialize SMDB_DBM_DATABASE -** -** Parameters: -** None -** -** Returns: -** A pointer to an allocated SMDB_DBM_DATABASE or NULL -** +/* +** Except for smdb_ndbm_open, the rest of these function correspond to the +** interface laid out in smdb.h. */ SMDB_DBM_DATABASE * @@ -88,17 +81,12 @@ smdbm_malloc_database() { db->smndbm_dbm = NULL; db->smndbm_lock_fd = -1; - db->smndbm_cursor_in_use = FALSE; + db->smndbm_cursor_in_use = false; } return db; } -/* -** Except for smdb_ndbm_open, the rest of these function correspond to the -** interface laid out in smdb.h. -*/ - int smdbm_close(database) SMDB_DATABASE *database; @@ -120,13 +108,13 @@ int smdbm_del(database, key, flags) SMDB_DATABASE *database; SMDB_DBENT *key; - u_int flags; + unsigned int flags; { int result; DBM *dbm = ((SMDB_DBM_DATABASE *) database->smdb_impl)->smndbm_dbm; datum dbkey; - memset(&dbkey, '\0', sizeof dbkey); + (void) memset(&dbkey, '\0', sizeof dbkey); dbkey.dptr = key->data; dbkey.dsize = key->size; @@ -175,13 +163,13 @@ smdbm_get(database, key, data, flags) SMDB_DATABASE *database; SMDB_DBENT *key; SMDB_DBENT *data; - u_int flags; + unsigned 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); + (void) memset(&dbkey, '\0', sizeof dbkey); + (void) memset(&dbdata, '\0', sizeof dbdata); dbkey.dptr = key->data; dbkey.dsize = key->size; @@ -209,15 +197,15 @@ smdbm_put(database, key, data, flags) SMDB_DATABASE *database; SMDB_DBENT *key; SMDB_DBENT *data; - u_int flags; + unsigned int 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); + (void) memset(&dbkey, '\0', sizeof dbkey); + (void) memset(&dbdata, '\0', sizeof dbdata); dbkey.dptr = key->data; dbkey.dsize = key->size; dbdata.dptr = data->data; @@ -282,7 +270,7 @@ smndbm_set_owner(database, uid, gid) int smdbm_sync(database, flags) SMDB_DATABASE *database; - u_int flags; + unsigned int flags; { return SMDBE_UNSUPPORTED; } @@ -297,7 +285,7 @@ smdbm_cursor_close(cursor) if (!db->smndbm_cursor_in_use) return SMDBE_NOT_A_VALID_CURSOR; - db->smndbm_cursor_in_use = FALSE; + db->smndbm_cursor_in_use = false; free(dbm_cursor); free(cursor); @@ -307,7 +295,7 @@ smdbm_cursor_close(cursor) int smdbm_cursor_del(cursor, flags) SMDB_CURSOR *cursor; - u_int flags; + unsigned int flags; { int result; SMDB_DBM_CURSOR *dbm_cursor = (SMDB_DBM_CURSOR *) cursor->smdbc_impl; @@ -343,8 +331,8 @@ smdbm_cursor_get(cursor, key, value, flags) DBM *dbm = db->smndbm_dbm; datum dbkey, dbdata; - memset(&dbkey, '\0', sizeof dbkey); - memset(&dbdata, '\0', sizeof dbdata); + (void) memset(&dbkey, '\0', sizeof dbkey); + (void) memset(&dbdata, '\0', sizeof dbdata); if (flags == SMDB_CURSOR_GET_RANGE) return SMDBE_UNSUPPORTED; @@ -406,7 +394,7 @@ smdbm_cursor_put(cursor, key, value, flags) DBM *dbm = db->smndbm_dbm; datum dbdata; - memset(&dbdata, '\0', sizeof dbdata); + (void) memset(&dbdata, '\0', sizeof dbdata); dbdata.dptr = value->data; dbdata.dsize = value->size; @@ -448,7 +436,7 @@ smdbm_cursor(database, cursor, flags) if (db->smndbm_cursor_in_use) return SMDBE_ONLY_SUPPORTS_ONE_CURSOR; - db->smndbm_cursor_in_use = TRUE; + db->smndbm_cursor_in_use = true; dbm_cursor = (SMDB_DBM_CURSOR *) malloc(sizeof(SMDB_DBM_CURSOR)); dbm_cursor->smndbmc_db = db; dbm_cursor->smndbmc_current_key.dptr = NULL; @@ -467,8 +455,7 @@ smdbm_cursor(database, cursor, flags) return SMDBE_OK; } - -/* +/* ** SMDB_NDBM_OPEN -- Opens a ndbm database. ** ** Parameters: @@ -481,8 +468,7 @@ smdbm_cursor(database, cursor, flags) ** Only SMDB_NDBM is supported. ** user_info -- Information on the user to use for file ** permissions. -** db_params -- -** No params are supported. +** db_params -- No params are supported. ** ** Returns: ** SMDBE_OK -- Success, otherwise errno: |
