/*
* This file is part of SkunkDB
* Copyright (c) 2001 Gianni Tedesco
*
*    SkunkDB is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    SkunkDB is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with SkunkDB; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/


#ifndef __SKUNK_HEADER_INCLUDED__
#define __SKUNK_HEADER_INCLUDED__

#include <sys/types.h>

/* Configuration */
#undef SKUNK_HASH_64		/* Use 64bit hash */
#undef SKUNK_DB_64		/* Use 64bit offsets */

#ifdef SKUNK_HASH_64
typedef u_int64_t skunkhash_t;
#else
typedef u_int32_t skunkhash_t;
#endif

/* REALLY needs to be unsigned */
#ifdef SKUNK_DB_64
typedef u_int64_t skunk_ofs_t;
#else
typedef u_int32_t skunk_ofs_t;
#endif

typedef struct skunkrec {
	struct skunkrec	*next;
	skunkhash_t	hash;
	skunk_ofs_t	key_len;
	skunk_ofs_t	val_len;
	u_int8_t	*key;
	u_int8_t	*val;
}skunkrec_t, *p_skunkrec;

/* These are our two on-disk structures */
typedef struct skunk_table{
	skunk_ofs_t	ofs;
	skunk_ofs_t	len;
}skunk_table_t, *p_skunk_table;

typedef struct skunk_bucket {
	skunkhash_t	hash;
	skunk_ofs_t	ofs;
	skunk_ofs_t	klen;
	skunk_ofs_t	vlen;
}skunk_bucket_t, *p_skunk_bucket;

#define SKUNK_DIRECTORY_MOD		2048
#define SKUNK_DIRECTORY_SIZE		(SKUNK_DIRECTORY_MOD*(2*sizeof(skunk_ofs_t)))
#define MOD(x)				(x % SKUNK_DIRECTORY_MOD)

#define SKUNK_BUFFER			8192

#endif /* __SKUNK_HEADER_INCLUDED__ */
