00001
00002
00003
00004
00005
00006
00007 #include "config.h"
00008
00009 #ifndef lint
00010 static const char revid[] = "$Id: hash__conv_8c-source.html,v 1.1 2008/06/08 10:19:24 sebdiaz Exp $";
00011 #endif
00012
00013 #ifndef NO_SYSTEM_INCLUDES
00014 #include <sys/types.h>
00015 #endif
00016
00017 #include "db_int.h"
00018 #include "db_page.h"
00019 #include "db_swap.h"
00020 #include "hash.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029 int
00030 CDB___ham_pgin(dbenv, pg, pp, cookie)
00031 DB_ENV *dbenv;
00032 db_pgno_t pg;
00033 void *pp;
00034 DBT *cookie;
00035 {
00036 DB_PGINFO *pginfo;
00037 PAGE *h;
00038
00039 h = pp;
00040 pginfo = (DB_PGINFO *)cookie->data;
00041
00042
00043
00044
00045
00046
00047 if (TYPE(h) != P_HASHMETA && h->pgno == PGNO_INVALID) {
00048 P_INIT(pp, pginfo->db_pagesize,
00049 pg, PGNO_INVALID, PGNO_INVALID, 0, P_HASH, 0);
00050 return (0);
00051 }
00052
00053 if (!pginfo->needswap)
00054 return (0);
00055
00056 return (TYPE(h) == P_HASHMETA ? CDB___ham_mswap(pp) :
00057 CDB___db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 1));
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067 int
00068 CDB___ham_pgout(dbenv, pg, pp, cookie)
00069 DB_ENV *dbenv;
00070 db_pgno_t pg;
00071 void *pp;
00072 DBT *cookie;
00073 {
00074 DB_PGINFO *pginfo;
00075 PAGE *h;
00076
00077 pginfo = (DB_PGINFO *)cookie->data;
00078 if (!pginfo->needswap)
00079 return (0);
00080
00081 h = pp;
00082 return (TYPE(h) == P_HASHMETA ? CDB___ham_mswap(pp) :
00083 CDB___db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 0));
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 int
00093 CDB___ham_mswap(pg)
00094 void *pg;
00095 {
00096 u_int8_t *p;
00097 int i;
00098
00099 CDB___db_metaswap(pg);
00100
00101 p = (u_int8_t *)pg + sizeof(DBMETA);
00102
00103 SWAP32(p);
00104 SWAP32(p);
00105 SWAP32(p);
00106 SWAP32(p);
00107 SWAP32(p);
00108 SWAP32(p);
00109 for (i = 0; i < NCACHED; ++i)
00110 SWAP32(p);
00111 return (0);
00112 }