1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 1999,2008 Oracle. All rights reserved. 5 * 6 * $Id: qam_conv.c,v 12.9 2008/01/30 12:18:23 mjc Exp $ 7 */ 8 9#include "db_config.h" 10 11#include "db_int.h" 12#include "dbinc/db_page.h" 13#include "dbinc/db_swap.h" 14#include "dbinc/db_am.h" 15#include "dbinc/qam.h" 16 17/* 18 * __qam_mswap -- 19 * Swap the bytes on the queue metadata page. 20 * 21 * PUBLIC: int __qam_mswap __P((ENV *, PAGE *)); 22 */ 23int 24__qam_mswap(env, pg) 25 ENV *env; 26 PAGE *pg; 27{ 28 u_int8_t *p; 29 30 COMPQUIET(env, NULL); 31 32 __db_metaswap(pg); 33 p = (u_int8_t *)pg + sizeof(DBMETA); 34 35 SWAP32(p); /* first_recno */ 36 SWAP32(p); /* cur_recno */ 37 SWAP32(p); /* re_len */ 38 SWAP32(p); /* re_pad */ 39 SWAP32(p); /* rec_page */ 40 SWAP32(p); /* page_ext */ 41 p += 91 * sizeof(u_int32_t); /* unused */ 42 SWAP32(p); /* crypto_magic */ 43 44 return (0); 45} 46 47/* 48 * __qam_pgin_out -- 49 * Convert host-specific page layout to/from the host-independent format 50 * stored on disk. 51 * We only need to fix up a few fields in the header 52 * 53 * PUBLIC: int __qam_pgin_out __P((ENV *, db_pgno_t, void *, DBT *)); 54 */ 55int 56__qam_pgin_out(env, pg, pp, cookie) 57 ENV *env; 58 db_pgno_t pg; 59 void *pp; 60 DBT *cookie; 61{ 62 DB_PGINFO *pginfo; 63 QPAGE *h; 64 65 COMPQUIET(pg, 0); 66 pginfo = (DB_PGINFO *)cookie->data; 67 if (!F_ISSET(pginfo, DB_AM_SWAP)) 68 return (0); 69 70 h = pp; 71 if (h->type == P_QAMMETA) 72 return (__qam_mswap(env, pp)); 73 74 M_32_SWAP(h->lsn.file); 75 M_32_SWAP(h->lsn.offset); 76 M_32_SWAP(h->pgno); 77 78 return (0); 79} 80