Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

bt_conv.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: bt_conv.c,v 12.2 2005/06/16 20:20:13 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015 
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/db_swap.h"
00019 #include "dbinc/btree.h"
00020 
00021 /*
00022  * __bam_pgin --
00023  *      Convert host-specific page layout from the host-independent format
00024  *      stored on disk.
00025  *
00026  * PUBLIC: int __bam_pgin __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
00027  */
00028 int
00029 __bam_pgin(dbenv, dummydbp, pg, pp, cookie)
00030         DB_ENV *dbenv;
00031         DB *dummydbp;
00032         db_pgno_t pg;
00033         void *pp;
00034         DBT *cookie;
00035 {
00036         DB_PGINFO *pginfo;
00037         PAGE *h;
00038 
00039         pginfo = (DB_PGINFO *)cookie->data;
00040         if (!F_ISSET(pginfo, DB_AM_SWAP))
00041                 return (0);
00042 
00043         h = pp;
00044         return (TYPE(h) == P_BTREEMETA ?  __bam_mswap(pp) :
00045             __db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 1));
00046 }
00047 
00048 /*
00049  * __bam_pgout --
00050  *      Convert host-specific page layout to the host-independent format
00051  *      stored on disk.
00052  *
00053  * PUBLIC: int __bam_pgout __P((DB_ENV *, DB *, db_pgno_t, void *, DBT *));
00054  */
00055 int
00056 __bam_pgout(dbenv, dummydbp, pg, pp, cookie)
00057         DB_ENV *dbenv;
00058         DB *dummydbp;
00059         db_pgno_t pg;
00060         void *pp;
00061         DBT *cookie;
00062 {
00063         DB_PGINFO *pginfo;
00064         PAGE *h;
00065 
00066         pginfo = (DB_PGINFO *)cookie->data;
00067         if (!F_ISSET(pginfo, DB_AM_SWAP))
00068                 return (0);
00069 
00070         h = pp;
00071         return (TYPE(h) == P_BTREEMETA ?  __bam_mswap(pp) :
00072             __db_byteswap(dbenv, dummydbp, pg, pp, pginfo->db_pagesize, 0));
00073 }
00074 
00075 /*
00076  * __bam_mswap --
00077  *      Swap the bytes on the btree metadata page.
00078  *
00079  * PUBLIC: int __bam_mswap __P((PAGE *));
00080  */
00081 int
00082 __bam_mswap(pg)
00083         PAGE *pg;
00084 {
00085         u_int8_t *p;
00086 
00087         __db_metaswap(pg);
00088 
00089         p = (u_int8_t *)pg + sizeof(DBMETA);
00090 
00091         p += sizeof(u_int32_t); /* unused */
00092         SWAP32(p);              /* minkey */
00093         SWAP32(p);              /* re_len */
00094         SWAP32(p);              /* re_pad */
00095         SWAP32(p);              /* root */
00096         p += 92 * sizeof(u_int32_t); /* unused */
00097         SWAP32(p);              /* crypto_magic */
00098 
00099         return (0);
00100 }

Generated on Sun Dec 25 12:14:12 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2