2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid[] = "@(#)bt_conv.c 10.4 (Sleepycat) 9/3/97";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
24 * __bam_pgin, __bam_pgout --
25 * Convert host-specific page layout to/from the host-independent
26 * format stored on disk.
28 * PUBLIC: int __bam_pgin __P((db_pgno_t, void *, DBT *));
29 * PUBLIC: int __bam_pgout __P((db_pgno_t, void *, DBT *));
32 __bam_pgin(pg, pp, cookie)
39 pginfo = (DB_PGINFO *)cookie->data;
40 if (!pginfo->needswap)
42 return (pg == PGNO_METADATA ? __bam_mswap(pp) : __db_pgin(pg, pp));
46 __bam_pgout(pg, pp, cookie)
53 pginfo = (DB_PGINFO *)cookie->data;
54 if (!pginfo->needswap)
56 return (pg == PGNO_METADATA ? __bam_mswap(pp) : __db_pgout(pg, pp));
61 * Swap the bytes on the btree metadata page.
63 * PUBLIC: int __bam_mswap __P((PAGE *));
73 /* Swap the meta-data information. */
74 SWAP32(p); /* lsn.file */
75 SWAP32(p); /* lsn.offset */
77 SWAP32(p); /* magic */
78 SWAP32(p); /* version */
79 SWAP32(p); /* pagesize */
80 SWAP32(p); /* maxkey */
81 SWAP32(p); /* minkey */
83 SWAP32(p); /* flags */
85 /* Swap the statistics. */
86 p = (u_int8_t *)&((BTMETA *)pg)->stat;
87 SWAP32(p); /* bt_freed */
88 SWAP32(p); /* bt_pfxsaved */
89 SWAP32(p); /* bt_split */
90 SWAP32(p); /* bt_rootsplit */
91 SWAP32(p); /* bt_fastsplit */
92 SWAP32(p); /* bt_added */
93 SWAP32(p); /* bt_deleted */
94 SWAP32(p); /* bt_get */
95 SWAP32(p); /* bt_cache_hit */
96 SWAP32(p); /* bt_cache_miss */