bt_conv.c

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

Generated on Wed Jul 20 21:03:00 2005 for MySQL 5.0.9 Beta by  doxygen 1.4.3