2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 1996, 1997, 1998
5 * Sleepycat Software. All rights reserved.
11 static const char sccsid
[] = "@(#)bt_conv.c 10.6 (Sleepycat) 4/10/98";
14 #ifndef NO_SYSTEM_INCLUDES
15 #include <sys/types.h>
25 * Convert host-specific page layout from the host-independent format
28 * PUBLIC: int __bam_pgin __P((db_pgno_t, void *, DBT *));
31 __bam_pgin(pg
, pp
, cookie
)
38 pginfo
= (DB_PGINFO
*)cookie
->data
;
39 if (!pginfo
->needswap
)
41 return (pg
== PGNO_METADATA
?
42 __bam_mswap(pp
) : __db_pgin(pg
, pginfo
->db_pagesize
, pp
));
47 * Convert host-specific page layout to the host-independent format
50 * PUBLIC: int __bam_pgout __P((db_pgno_t, void *, DBT *));
53 __bam_pgout(pg
, pp
, cookie
)
60 pginfo
= (DB_PGINFO
*)cookie
->data
;
61 if (!pginfo
->needswap
)
63 return (pg
== PGNO_METADATA
?
64 __bam_mswap(pp
) : __db_pgout(pg
, pginfo
->db_pagesize
, pp
));
69 * Swap the bytes on the btree metadata page.
71 * PUBLIC: int __bam_mswap __P((PAGE *));
81 /* Swap the meta-data information. */
82 SWAP32(p
); /* lsn.file */
83 SWAP32(p
); /* lsn.offset */
85 SWAP32(p
); /* magic */
86 SWAP32(p
); /* version */
87 SWAP32(p
); /* pagesize */
88 SWAP32(p
); /* maxkey */
89 SWAP32(p
); /* minkey */
91 SWAP32(p
); /* flags */
93 /* Swap the statistics. */
94 p
= (u_int8_t
*)&((BTMETA
*)pg
)->stat
;
95 SWAP32(p
); /* bt_freed */
96 SWAP32(p
); /* bt_pfxsaved */
97 SWAP32(p
); /* bt_split */
98 SWAP32(p
); /* bt_rootsplit */
99 SWAP32(p
); /* bt_fastsplit */
100 SWAP32(p
); /* bt_added */
101 SWAP32(p
); /* bt_deleted */
102 SWAP32(p
); /* bt_get */
103 SWAP32(p
); /* bt_cache_hit */
104 SWAP32(p
); /* bt_cache_miss */