-/* $Cambridge: exim/src/src/exim_dbutil.c,v 1.4 2005/05/23 16:58:56 fanf2 Exp $ */
+/* $Cambridge: exim/src/src/exim_dbutil.c,v 1.11 2007/01/08 10:50:18 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 2005 */
+/* Copyright (c) University of Cambridge 1995 - 2007 */
/* See the file NOTICE for conditions of use and distribution. */
/* For Berkeley DB >= 2, we can define a function to be called in case of DB
errors. This should help with debugging strange DB problems, e.g. getting "File
-exists" when you try to open a db file. */
+exists" when you try to open a db file. The API changed at release 4.3. */
#if defined(USE_DB) && defined(DB_VERSION_STRING)
void
+#if DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
+dbfn_bdb_error_callback(const DB_ENV *dbenv, const char *pfx, const char *msg)
+{
+dbenv = dbenv;
+#else
dbfn_bdb_error_callback(const char *pfx, char *msg)
{
+#endif
pfx = pfx;
printf("Berkeley DB error: %s\n", msg);
}
printf("** Failed to get %s lock for %s: %s",
((flags & O_RDONLY) != 0)? "read" : "write", buffer,
(errno == ETIMEDOUT)? "timed out" : strerror(errno));
- close(dbblock->lockfd);
+ (void)close(dbblock->lockfd);
return NULL;
}
""
#endif
);
- close(dbblock->lockfd);
+ (void)close(dbblock->lockfd);
return NULL;
}
dbfn_close(open_db *dbblock)
{
EXIM_DBCLOSE(dbblock->dbptr);
-close(dbblock->lockfd);
+(void)close(dbblock->lockfd);
}
/* If the buffer contains just one digit, or just consists of "d", use the
previous name for an update. */
- if ((isdigit((uschar)buffer[0]) && !isdigit((uschar)buffer[1])) ||
- Ustrcmp(buffer, "d") == 0)
+ if ((isdigit((uschar)buffer[0]) && (buffer[1] == ' ' || buffer[1] == '\0'))
+ || Ustrcmp(buffer, "d") == 0)
{
if (name[0] == 0)
{
printf("No previous record name is set\n");
continue;
}
- sscanf(CS buffer, "%s %s", field, value);
+ (void)sscanf(CS buffer, "%s %s", field, value);
}
else
{
name[0] = 0;
- sscanf(CS buffer, "%s %s %s", name, field, value);
+ (void)sscanf(CS buffer, "%s %s %s", name, field, value);
}
/* Handle an update request */
break;
case type_ratelimit:
- ratelimit = (dbdata_ratelimit *)value;
+ ratelimit = (dbdata_ratelimit *)record;
+ length = sizeof(dbdata_ratelimit);
switch(fieldno)
{
case 0:
case 1:
ratelimit->time_usec = Uatoi(value);
+ break;
case 2:
ratelimit->rate = Ustrtod(value, NULL);
break;
case type_ratelimit:
- ratelimit = (dbdata_ratelimit *)value;
+ ratelimit = (dbdata_ratelimit *)record;
printf("0 time stamp: %s\n", print_time(ratelimit->time_stamp));
printf("1 fract. time: .%06d\n", ratelimit->time_usec);
printf("2 sender rate: % .3f\n", ratelimit->rate);