00001 /*- 00002 * See the file LICENSE for redistribution information. 00003 * 00004 * Copyright (c) 1999, 2000 00005 * Sleepycat Software. All rights reserved. 00006 */ 00007 00008 #include "config.h" 00009 00010 #ifndef lint 00011 static const char revid[] = "$Id: qam__conv_8c-source.html,v 1.1 2008/06/08 10:21:42 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 "qam.h" 00021 #include "db_swap.h" 00022 #include "db_am.h" 00023 00024 /* 00025 * CDB___qam_mswap -- 00026 * Swap the bytes on the queue metadata page. 00027 * 00028 * PUBLIC: int CDB___qam_mswap __P((PAGE *)); 00029 */ 00030 int 00031 CDB___qam_mswap(pg) 00032 PAGE *pg; 00033 { 00034 u_int8_t *p; 00035 00036 CDB___db_metaswap(pg); 00037 00038 p = (u_int8_t *)pg + sizeof(DBMETA); 00039 00040 SWAP32(p); /* start */ 00041 SWAP32(p); /* first_recno */ 00042 SWAP32(p); /* cur_recno */ 00043 SWAP32(p); /* re_len */ 00044 SWAP32(p); /* re_pad */ 00045 SWAP32(p); /* rec_page */ 00046 00047 return (0); 00048 } 00049 00050 /* 00051 * CDB___qam_pgin_out -- 00052 * Convert host-specific page layout to/from the host-independent format 00053 * stored on disk. 00054 * We only need to fix up a few fields in the header 00055 * 00056 * PUBLIC: int CDB___qam_pgin_out __P((DB_ENV *, db_pgno_t, void *, DBT *)); 00057 */ 00058 int 00059 CDB___qam_pgin_out(dbenv, pg, pp, cookie) 00060 DB_ENV *dbenv; 00061 db_pgno_t pg; 00062 void *pp; 00063 DBT *cookie; 00064 { 00065 DB_PGINFO *pginfo; 00066 QPAGE *h; 00067 00068 COMPQUIET(pg, 0); 00069 COMPQUIET(dbenv, NULL); 00070 pginfo = (DB_PGINFO *)cookie->data; 00071 if (!pginfo->needswap) 00072 return (0); 00073 00074 h = pp; 00075 if (TYPE(h) == P_QAMMETA) 00076 return (CDB___qam_mswap(pp)); 00077 00078 M_32_SWAP(h->lsn.file); 00079 M_32_SWAP(h->lsn.offset); 00080 M_32_SWAP(h->pgno); 00081 00082 return (0); 00083 }