/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#include "config.h"
#ifndef lint
static const char sccsid[] = "@(#)db_err.c 10.25 (Sleepycat) 5/2/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <errno.h>
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#endif
#include "db_int.h"
#include "common_ext.h"
static int __db_keyempty __P((const DB_ENV *));
static int __db_rdonly __P((const DB_ENV *, const char *));
/*
* __db_err --
* Standard DB error routine.
*
* PUBLIC: #ifdef __STDC__
* PUBLIC: void __db_err __P((const DB_ENV *dbenv, const char *fmt, ...));
* PUBLIC: #else
* PUBLIC: void __db_err();
* PUBLIC: #endif
*/
void
#ifdef __STDC__
__db_err(const DB_ENV *dbenv, const char *fmt, ...)
#else
__db_err(dbenv, fmt, va_alist)
const DB_ENV *dbenv;
const char *fmt;
va_dcl
#endif
{
va_list ap;
char errbuf[2048]; /* XXX: END OF THE STACK DON'T TRUST SPRINTF. */
if (dbenv == NULL)
return;
#ifdef __STDC__
va_start(ap, fmt);
#else
va_start(ap);
#endif
if (dbenv->db_errcall != NULL) {
(void)vsnprintf(errbuf, sizeof(errbuf), fmt, ap);
dbenv->db_errcall(dbenv->db_errpfx, errbuf);
}
if (dbenv->db_errfile != NULL) {
if (dbenv->db_errpfx != NULL)
(void)fprintf(dbenv->db_errfile, "%s: ",
dbenv->db_errpfx);
(void)vfprintf(dbenv->db_errfile, fmt, ap);
(void)fprintf(dbenv->db_errfile, "\n");
(void)fflush(dbenv->db_errfile);
}
va_end(ap);
}
/*
* XXX
* Provide ANSI C prototypes for the panic functions. Some compilers, (e.g.,
* MS VC 4.2) get upset if they aren't here, even though the K&R declaration
* appears before the assignment in the __db__panic() call.
*/
static int __db_ecursor __P((DB *, DB_TXN *, DBC **));
static int __db_edel __P((DB *, DB_TXN *, DBT *, u_int32_t));
static int __db_efd __P((DB *, int *));
static int __db_egp __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
static int __db_estat __P((DB *, void *, void *(*)(size_t), u_int32_t));
static int __db_esync __P((DB *, u_int32_t));
/*
* __db_ecursor --
* After-panic cursor routine.
*/
static int
__db_ecursor(a, b, c)
DB *a;
DB_TXN *b;
DBC **c;
{
COMPQUIET(a, NULL);
COMPQUIET(b, NULL);
COMPQUIET(c, NULL);
return (EPERM);
}
/*
* __db_edel --
* After-panic delete routine.
*/
static int
__db_edel(a, b, c, d)
DB *a;
DB_TXN *b;
DBT *c;
u_int32_t d;
{
COMPQUIET(a, NULL);
COMPQUIET