db_iface.c revision 1
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998
* Sleepycat Software. All rights reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "config.h"
#ifndef lint
static const char sccsid[] = "@(#)db_iface.c 10.40 (Sleepycat) 12/19/98";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <errno.h>
#endif
#include "db_int.h"
#include "db_page.h"
#include "db_auto.h"
#include "db_ext.h"
#include "common_ext.h"
/*
* __db_cdelchk --
* Common cursor delete argument checking routine.
*
* PUBLIC: int __db_cdelchk __P((const DB *, u_int32_t, int, int));
*/
int
{
/* Check for changes to a read-only tree. */
if (isrdonly)
/* Check for invalid function flags. */
switch (flags) {
case 0:
break;
default:
}
/*
* The cursor must be initialized, return -1 for an invalid cursor,
* otherwise 0.
*/
}
/*
* __db_cgetchk --
* Common cursor get argument checking routine.
*
* PUBLIC: int __db_cgetchk __P((const DB *, DBT *, DBT *, u_int32_t, int));
*/
int
int isvalid;
{
key_einval = key_flags = 0;
/* Check for invalid function flags. */
switch (flags) {
case DB_NEXT_DUP:
goto err;
/* FALLTHROUGH */
case DB_CURRENT:
case DB_FIRST:
case DB_LAST:
case DB_NEXT:
case DB_PREV:
key_flags = 1;
break;
case DB_GET_BOTH:
case DB_SET_RANGE:
break;
case DB_SET:
key_einval = 1;
break;
case DB_GET_RECNO:
goto err;
break;
case DB_SET_RECNO:
goto err;
break;
default:
}
return (ret);
return (ret);
/* Check for missing keys. */
/*
* The cursor must be initialized for DB_CURRENT, return -1 for an
* invalid cursor, otherwise 0.
*/
}
/*
* __db_cputchk --
* Common cursor put argument checking routine.
*
* PUBLIC: int __db_cputchk __P((const DB *,
* PUBLIC: const DBT *, DBT *, u_int32_t, int, int));
*/
int
{
key_einval = key_flags = 0;
/* Check for changes to a read-only tree. */
if (isrdonly)
/* Check for invalid function flags. */
switch (flags) {
case DB_AFTER:
case DB_BEFORE:
goto err;
goto err;
goto err;
break;
case DB_CURRENT:
/*
* If there is a comparison function, doing a DB_CURRENT
* must not change the part of the data item that is used
* for the comparison.
*/
break;
case DB_KEYFIRST:
case DB_KEYLAST:
goto err;
break;
default:
}
return (ret);
return (ret);
/* Check for missing keys. */
/*
* The cursor must be initialized for anything other than DB_KEYFIRST
* and DB_KEYLAST, return -1 for an invalid cursor, otherwise 0.
*/
return (isvalid ||
}
/*
* __db_closechk --
* DB->close flag check.
*
* PUBLIC: int __db_closechk __P((const DB *, u_int32_t));
*/
int
{
/* Check for invalid function flags. */
return (0);
}
/*
* __db_delchk --
* Common delete argument checking routine.
*
* PUBLIC: int __db_delchk __P((const DB *, DBT *, u_int32_t, int));
*/
int
int isrdonly;
{
/* Check for changes to a read-only tree. */
if (isrdonly)
/* Check for invalid function flags. */
switch (flags) {
case 0:
break;
default:
}
/* Check for missing keys. */
return (0);
}
/*
* __db_getchk --
* Common get argument checking routine.
*
* PUBLIC: int __db_getchk __P((const DB *, const DBT *, DBT *, u_int32_t));
*/
int
{
int ret;
/* Check for invalid function flags. */
switch (flags) {
case 0:
case DB_GET_BOTH:
break;
case DB_SET_RECNO:
goto err;
break;
default:
}
return (ret);
return (ret);
/* Check for missing keys. */
return (0);
}
/*
* __db_joinchk --
* Common join argument checking routine.
*
* PUBLIC: int __db_joinchk __P((const DB *, u_int32_t));
*/
int
{
if (flags != 0)
return (0);
}
/*
* __db_putchk --
* Common put argument checking routine.
*
* PUBLIC: int __db_putchk
* PUBLIC: __P((const DB *, DBT *, const DBT *, u_int32_t, int, int));
*/
int
{
int ret;
/* Check for changes to a read-only tree. */
if (isrdonly)
/* Check for invalid function flags. */
switch (flags) {
case 0:
case DB_NOOVERWRITE:
break;
case DB_APPEND:
goto err;
break;
default:
}
return (ret);
return (ret);
/* Check for missing keys. */
/* Check for partial puts in the presence of duplicates. */
"a partial put in the presence of duplicates requires a cursor operation");
return (EINVAL);
}
return (0);
}
/*
* __db_statchk --
* Common stat argument checking routine.
*
* PUBLIC: int __db_statchk __P((const DB *, u_int32_t));
*/
int
{
/* Check for invalid function flags. */
switch (flags) {
case 0:
break;
case DB_RECORDCOUNT:
break;
break;
goto err;
default:
}
return (0);
}
/*
* __db_syncchk --
* Common sync argument checking routine.
*
* PUBLIC: int __db_syncchk __P((const DB *, u_int32_t));
*/
int
{
/* Check for invalid function flags. */
switch (flags) {
case 0:
break;
default:
}
return (0);
}
/*
* __dbt_ferr --
* Check a DBT for flag errors.
*/
static int
const char *name;
int check_thread;
{
int ret;
/*
* Check for invalid DBT flags. We allow any of the flags to be
* specified to any DB or DBcursor call so that applications can
* set DB_DBT_MALLOC when retrieving a data item from a secondary
* database and then specify that same DBT as a key to a primary
* database, without having to clear flags.
*/
return (ret);
return (ret);
"missing flag thread flag for %s DBT", name);
return (EINVAL);
}
return (0);
}
/*
* __db_eopnotsup --
* Common operation not supported message.
*
* PUBLIC: int __db_eopnotsup __P((const DB_ENV *));
*/
int
{
#ifdef EOPNOTSUPP
return (EOPNOTSUPP);
#else
return (EINVAL);
#endif
}
/*
* __db_keyempty --
* Common missing or empty key value message.
*/
static int
{
return (EINVAL);
}
/*
* __db_rdonly --
* Common readonly message.
*/
static int
const char *name;
{
return (EACCES);
}