#include "db_config.h"
#ifndef lint
static const char revid[] = "$Id: hash_conv.c,v 1.2 2004/03/30 01:23:27 jtownsen Exp $";
#endif
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#endif
#include "db_int.h"
#include "dbinc/db_page.h"
#include "dbinc/db_swap.h"
#include "dbinc/hash.h"
int
__ham_pgin(dbenv, dummydbp, pg, pp, cookie)
DB_ENV *dbenv;
DB *dummydbp;
db_pgno_t pg;
void *pp;
DBT *cookie;
{
DB_PGINFO *pginfo;
PAGE *h;
h = pp;
pginfo = (DB_PGINFO *)cookie->data;
if (h->type != P_HASHMETA && h->pgno == PGNO_INVALID) {
P_INIT(pp, (db_indx_t)pginfo->db_pagesize,
pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH);
return (0);
}
if (!F_ISSET(pginfo, DB_AM_SWAP))
return (0);
return (h->type == P_HASHMETA ? __ham_mswap(pp) :
__db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 1));
}
int
__ham_pgout(dbenv, dummydbp, pg, pp, cookie)
DB_ENV *dbenv;
DB *dummydbp;
db_pgno_t pg;
void *pp;
DBT *cookie;
{
DB_PGINFO *pginfo;
PAGE *h;
pginfo = (DB_PGINFO *)cookie->data;
if (!F_ISSET(pginfo, DB_AM_SWAP))
return (0);
h = pp;
return (h->type == P_HASHMETA ? __ham_mswap(pp) :
__db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 0));
}
int
__ham_mswap(pg)
void *pg;
{
u_int8_t *p;
int i;
__db_metaswap(pg);
p = (u_int8_t *)pg + sizeof(DBMETA);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
SWAP32(p);
for (i = 0; i < NCACHED; ++i)
SWAP32(p);
p += 59 * sizeof(u_int32_t);
SWAP32(p);
return (0);
}