Esempio n. 1
0
static int
hash_delete(
	const DB *dbp,
	const DBT *key,
	uint flag)		/* Ignored */
{
	HTAB *hashp;
	int rv;

	hashp = (HTAB *)dbp->internal;
	if (!hashp)
		return (DBM_ERROR);

	if (flag && flag != R_CURSOR) {
		hashp->dbmerrno = errno = EINVAL;
		return (DBM_ERROR);
	}
	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
		hashp->dbmerrno = errno = EPERM;
		return (DBM_ERROR);
	}
	rv = hash_access(hashp, HASH_DELETE, (DBT *)key, NULL);

	if(rv == DATABASE_CORRUPTED_ERROR)
	  {
#if defined(unix) && defined(DEBUG)
		printf("\n\nDBM Database has been corrupted, tell Lou...\n\n");
#endif
	  	__remove_database((DB *)dbp);
	  }

	return(rv);
}
Esempio n. 2
0
/*
 * All the access routines return
 *
 * Returns:
 *	 0 on SUCCESS
 *	 1 to indicate an external DBM_ERROR (i.e. key not found, etc)
 *	-1 to indicate an internal DBM_ERROR (i.e. out of memory, etc)
 */
static int
hash_get(
	const DB *dbp,
	const DBT *key,
	DBT *data,
	uint flag)
{
	HTAB *hashp;
	int rv;

	hashp = (HTAB *)dbp->internal;
	if (!hashp)
		return (DBM_ERROR);

	if (flag) {
		hashp->dbmerrno = errno = EINVAL;
		return (DBM_ERROR);
	}

	rv = hash_access(hashp, HASH_GET, (DBT *)key, data);

	if(rv == DATABASE_CORRUPTED_ERROR)
	  {
#if defined(unix) && defined(DEBUG)
		printf("\n\nDBM Database has been corrupted, tell Lou...\n\n");
#endif
	  	__remove_database((DB *)dbp);
	  }

	return(rv);
}
Esempio n. 3
0
/*
 * All the access routines return
 *
 * Returns:
 *	 0 on SUCCESS
 *	 1 to indicate an external ERROR (i.e. key not found, etc)
 *	-1 to indicate an internal ERROR (i.e. out of memory, etc)
 */
static int
hash_get(const DB *dbp, const DBT *key, DBT *data, u_int32_t flag)
{
	HTAB *hashp;

	hashp = (HTAB *)dbp->internal;
	if (flag) {
		hashp->error = errno = EINVAL;
		return (ERROR);
	}
	return (hash_access(hashp, HASH_GET, (DBT *)key, data));
}
Esempio n. 4
0
/*
 * All the access routines return
 *
 * Returns:
 *	 0 on SUCCESS
 *	 1 to indicate an external ERROR (i.e. key not found, etc)
 *	-1 to indicate an internal ERROR (i.e. out of memory, etc)
 */
static int
hash_get(const DB *dbp, const DBT *key, DBT *data, uint32_t flag)
{
	HTAB *hashp;

	hashp = dbp->internal;
	if (flag) {
		hashp->err = errno = EINVAL;
		return (ERROR);
	}
	return (hash_access(hashp, HASH_GET, __UNCONST(key), data));
}
Esempio n. 5
0
static int
hash_delete(const DB *dbp, const DBT *key, u_int32_t flag)
{
	HTAB *hashp;

	hashp = (HTAB *)dbp->internal;
	if (flag && flag != R_CURSOR) {
		hashp->error = errno = EINVAL;
		return (ERROR);
	}
	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
		hashp->error = errno = EPERM;
		return (ERROR);
	}
	return (hash_access(hashp, HASH_DELETE, key, NULL));
}
Esempio n. 6
0
static int
hash_put(const DB *dbp, DBT *key, const DBT *data, u_int32_t flag)
{
	HTAB *hashp;

	hashp = (HTAB *)dbp->internal;
	if (flag && flag != R_NOOVERWRITE) {
		hashp->error = errno = EINVAL;
		return (ERROR);
	}
	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
		hashp->error = errno = EPERM;
		return (ERROR);
	}
	return (hash_access(hashp, flag == R_NOOVERWRITE ?
	    HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data));
}
Esempio n. 7
0
static int
hash_put(const DB *dbp, DBT *key, const DBT *data, uint32_t flag)
{
	HTAB *hashp;

	hashp = dbp->internal;
	if (flag && flag != R_NOOVERWRITE) {
		hashp->err = errno = EINVAL;
		return (ERROR);
	}
	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
		hashp->err = errno = EPERM;
		return (ERROR);
	}
	/* LINTED const castaway */
	return (hash_access(hashp, flag == R_NOOVERWRITE ?
	    HASH_PUTNEW : HASH_PUT, __UNCONST(key), __UNCONST(data)));
}
Esempio n. 8
0
static int
hash_put(
	const DB *dbp,
	DBT *key,
	const DBT *data,
	uint flag)
{
	HTAB *hashp;
	int rv;

	hashp = (HTAB *)dbp->internal;
	if (!hashp)
		return (DBM_ERROR);

	if (flag && flag != R_NOOVERWRITE) {
		hashp->dbmerrno = errno = EINVAL;
		return (DBM_ERROR);
	}
	if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
		hashp->dbmerrno = errno = EPERM;
		return (DBM_ERROR);
	}

	rv =  hash_access(hashp, flag == R_NOOVERWRITE ?
	    HASH_PUTNEW : HASH_PUT, (DBT *)key, (DBT *)data);

	if(rv == DATABASE_CORRUPTED_ERROR)
	  {
#if defined(unix) && defined(DEBUG)
		printf("\n\nDBM Database has been corrupted, tell Lou...\n\n");
#endif
	  	__remove_database((DB *)dbp);
	  }

	return(rv);
}