Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

qam_conv.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1999-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: qam_conv.c,v 12.1 2005/06/16 20:23:32 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <sys/types.h>
00014 #endif
00015 
00016 #include "db_int.h"
00017 #include "dbinc/db_page.h"
00018 #include "dbinc/db_swap.h"
00019 #include "dbinc/db_am.h"
00020 #include "dbinc/qam.h"
00021 
00022 /*
00023  * __qam_mswap --
00024  *      Swap the bytes on the queue metadata page.
00025  *
00026  * PUBLIC: int __qam_mswap __P((PAGE *));
00027  */
00028 int
00029 __qam_mswap(pg)
00030         PAGE *pg;
00031 {
00032         u_int8_t *p;
00033 
00034          __db_metaswap(pg);
00035 
00036          p = (u_int8_t *)pg + sizeof(DBMETA);
00037 
00038         SWAP32(p);              /* first_recno */
00039         SWAP32(p);              /* cur_recno */
00040         SWAP32(p);              /* re_len */
00041         SWAP32(p);              /* re_pad */
00042         SWAP32(p);              /* rec_page */
00043         SWAP32(p);              /* page_ext */
00044         p += 91 * sizeof(u_int32_t); /* unused */
00045         SWAP32(p);              /* crypto_magic */
00046 
00047         return (0);
00048 }
00049 
00050 /*
00051  * __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 __qam_pgin_out __P((DB_ENV *, db_pgno_t, void *, DBT *));
00057  */
00058 int
00059 __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 (!F_ISSET(pginfo, DB_AM_SWAP))
00072                 return (0);
00073 
00074         h = pp;
00075         if (h->type == P_QAMMETA)
00076             return (__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 }

Generated on Sun Dec 25 12:14:44 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2