bt_conv.c

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1996, 1997, 1998, 1999, 2000
00005  *      Sleepycat Software.  All rights reserved.
00006  */
00007 
00008 #include "config.h"
00009 
00010 #ifndef lint
00011 static const char revid[] = "$Id: bt__conv_8c-source.html,v 1.1 2008/06/08 10:13:30 sebdiaz Exp $";
00012 #endif /* not lint */
00013 
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016 #endif
00017 
00018 #include "db_int.h"
00019 #include "db_page.h"
00020 #include "db_swap.h"
00021 #include "btree.h"
00022 
00023 /*
00024  * CDB___bam_pgin --
00025  *      Convert host-specific page layout from the host-independent format
00026  *      stored on disk.
00027  *
00028  * PUBLIC: int CDB___bam_pgin __P((DB_ENV *, db_pgno_t, void *, DBT *));
00029  */
00030 int
00031 CDB___bam_pgin(dbenv, pg, pp, cookie)
00032         DB_ENV *dbenv;
00033         db_pgno_t pg;
00034         void *pp;
00035         DBT *cookie;
00036 {
00037         DB_PGINFO *pginfo;
00038         PAGE *h;
00039 
00040         pginfo = (DB_PGINFO *)cookie->data;
00041         if (!pginfo->needswap)
00042                 return (0);
00043 
00044         h = pp;
00045         return (TYPE(h) == P_BTREEMETA ?  CDB___bam_mswap(pp) :
00046              CDB___db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 1));
00047 }
00048 
00049 /*
00050  * CDB___bam_pgout --
00051  *      Convert host-specific page layout to the host-independent format
00052  *      stored on disk.
00053  *
00054  * PUBLIC: int CDB___bam_pgout __P((DB_ENV *, db_pgno_t, void *, DBT *));
00055  */
00056 int
00057 CDB___bam_pgout(dbenv, pg, pp, cookie)
00058         DB_ENV *dbenv;
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 (!pginfo->needswap)
00068                 return (0);
00069 
00070         h = pp;
00071         return (TYPE(h) == P_BTREEMETA ?  CDB___bam_mswap(pp) :
00072             CDB___db_byteswap(dbenv, pg, pp, pginfo->db_pagesize, 0));
00073 }
00074 
00075 /*
00076  * CDB___bam_mswap --
00077  *      Swap the bytes on the btree metadata page.
00078  *
00079  * PUBLIC: int CDB___bam_mswap __P((PAGE *));
00080  */
00081 int
00082 CDB___bam_mswap(pg)
00083         PAGE *pg;
00084 {
00085         u_int8_t *p;
00086 
00087         CDB___db_metaswap(pg);
00088 
00089         p = (u_int8_t *)pg + sizeof(DBMETA);
00090 
00091         SWAP32(p);              /* maxkey */
00092         SWAP32(p);              /* minkey */
00093         SWAP32(p);              /* re_len */
00094         SWAP32(p);              /* re_pad */
00095         SWAP32(p);              /* root */
00096 
00097         return (0);
00098 }

Generated on Sun Jun 8 10:56:34 2008 for GNUmifluz by  doxygen 1.5.5