summaryrefslogtreecommitdiff
path: root/gnu/usr.sbin/sendmail/libsmdb/smdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.sbin/sendmail/libsmdb/smdb.c')
-rw-r--r--gnu/usr.sbin/sendmail/libsmdb/smdb.c62
1 files changed, 21 insertions, 41 deletions
diff --git a/gnu/usr.sbin/sendmail/libsmdb/smdb.c b/gnu/usr.sbin/sendmail/libsmdb/smdb.c
index 03756c87079..da694d07fe1 100644
--- a/gnu/usr.sbin/sendmail/libsmdb/smdb.c
+++ b/gnu/usr.sbin/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[] = "@(#)$Sendmail: smdb.c,v 8.37.4.2 2000/08/24 17:08:00 gshapiro Exp $";
-#endif /* ! lint */
+#include <sm/gen.h>
+SM_RCSID("@(#)$Sendmail: smdb.c,v 8.49 2001/09/04 22:43:45 ca Exp $")
#include <fcntl.h>
#include <stdlib.h>
@@ -38,7 +37,7 @@ 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;
}
@@ -61,7 +60,6 @@ smdb_free_database(database)
if (database != NULL)
free(database);
}
-
/*
** SMDB_LOCKFILE -- lock a file using flock or (shudder) fcntl locking
**
@@ -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,15 +147,14 @@ 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.
**
@@ -208,11 +199,11 @@ smdb_open_database(database, db_name, mode, mode_mask, sff, type, 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 */
@@ -255,7 +246,6 @@ 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.
**
@@ -296,14 +286,13 @@ 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.
**
@@ -342,7 +331,6 @@ smdb_lock_file(lock_fd, db_name, mode, sff, extension)
return SMDBE_OK;
}
-
/*
** SMDB_UNLOCK_FILE -- Unlocks a file
**
@@ -367,7 +355,6 @@ smdb_unlock_file(lock_fd)
return SMDBE_OK;
}
-
/*
** SMDB_LOCK_MAP -- Locks a database.
**
@@ -395,7 +382,6 @@ smdb_lock_map(database, type)
return SMDBE_LOCK_NOT_GRANTED;
return SMDBE_OK;
}
-
/*
** SMDB_UNLOCK_MAP -- Unlocks a database
**
@@ -419,8 +405,6 @@ smdb_unlock_map(database)
return SMDBE_LOCK_NOT_HELD;
return SMDBE_OK;
}
-
-
/*
** SMDB_SETUP_FILE -- Gets db file ready for use.
**
@@ -465,7 +449,6 @@ 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.
**
@@ -496,10 +479,7 @@ 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.