X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/870f6ba8a2945754a7f2f66097e3a64465fe1a04..184e88237dea64ce48076cdd0184612d057cbafd:/src/src/exim_dbutil.c diff --git a/src/src/exim_dbutil.c b/src/src/exim_dbutil.c index a8dbe61b8..f286acda6 100644 --- a/src/src/exim_dbutil.c +++ b/src/src/exim_dbutil.c @@ -1,10 +1,10 @@ -/* $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. */ @@ -78,12 +78,18 @@ not too much extra baggage. */ /* 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); } @@ -310,7 +316,7 @@ if (rc < 0) 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; } @@ -330,7 +336,7 @@ if (dbblock->dbptr == NULL) "" #endif ); - close(dbblock->lockfd); + (void)close(dbblock->lockfd); return NULL; } @@ -355,7 +361,7 @@ static void dbfn_close(open_db *dbblock) { EXIM_DBCLOSE(dbblock->dbptr); -close(dbblock->lockfd); +(void)close(dbblock->lockfd); } @@ -761,20 +767,20 @@ for(;;) /* 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 */ @@ -888,7 +894,8 @@ for(;;) break; case type_ratelimit: - ratelimit = (dbdata_ratelimit *)value; + ratelimit = (dbdata_ratelimit *)record; + length = sizeof(dbdata_ratelimit); switch(fieldno) { case 0: @@ -898,6 +905,7 @@ for(;;) case 1: ratelimit->time_usec = Uatoi(value); + break; case 2: ratelimit->rate = Ustrtod(value, NULL); @@ -1008,7 +1016,7 @@ for(;;) 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);